1 #include "debugscript.h"
7 void DebugScript::ParseAction()
9 std::string actionType;
12 while (actionType[0] == '#')
15 std::getline(inp, tmp);
16 inp >> std::ws >> actionType;
18 if (actionType == "loop")
20 inp >> currentAction.loops >> actionType;
24 currentAction.loops = 1;
27 if (actionType == "wait")
29 currentAction.type = AT_WaitFrame;
32 else if (actionType == "translate")
36 currentAction.type = AT_Translate;
37 currentAction.x = RealFromStr(_x.c_str());
38 currentAction.y = RealFromStr(_y.c_str());
41 else if (actionType == "zoom")
43 std::string _x, _y, _z;
44 inp >> _x >> _y >> _z;
45 currentAction.type = AT_Zoom;
46 currentAction.x = RealFromStr(_x.c_str());
47 currentAction.y = RealFromStr(_y.c_str());
48 currentAction.z = RealFromStr(_z.c_str());
51 else if (actionType == "pxtranslate")
53 inp >> currentAction.ix >> currentAction.iy;
54 currentAction.type = AT_TranslatePx;
57 else if (actionType == "pxzoom")
59 inp >> currentAction.ix >> currentAction.iy >> currentAction.iz;
60 currentAction.type = AT_ZoomPx;
63 else if (actionType == "gpu")
65 currentAction.type = AT_SetGPURendering;
68 else if (actionType == "cpu")
70 currentAction.type = AT_SetCPURendering;
73 else if (actionType == "lazy")
75 currentAction.type = AT_EnableLazyRendering;
78 else if (actionType == "nolazy")
80 currentAction.type = AT_DisableLazyRendering;
83 else if (actionType == "quit")
85 currentAction.type = AT_Quit;
87 else if (actionType == "loadsvg")
89 currentAction.type = AT_LoadSVG;
90 inp >> currentAction.filename;
94 bool DebugScript::Execute(View *view, Screen *scr)
96 if (currentAction.loops <= 0)
99 switch(currentAction.type)
106 view->Translate(currentAction.x, currentAction.y);
109 view->Translate(Real(currentAction.ix)/Real(scr->ViewportWidth()), Real(currentAction.iy)/Real(scr->ViewportHeight()));
112 view->ScaleAroundPoint(currentAction.x, currentAction.y, currentAction.z);
115 view->ScaleAroundPoint(Real(currentAction.ix)/Real(scr->ViewportWidth()),Real(currentAction.iy)/Real(scr->ViewportHeight()), Real(expf(-currentAction.iz/20.f)));
117 case AT_SetGPURendering:
118 view->SetGPURendering(true);
120 case AT_SetCPURendering:
121 view->SetGPURendering(false);
123 case AT_EnableLazyRendering:
124 view->SetLazyRendering(true);
126 case AT_DisableLazyRendering:
127 view->SetLazyRendering(false);
130 #ifdef TRANSFORM_OBJECTS_NOT_VIEW
131 view->Doc().LoadSVG(currentAction.filename, Rect(Real(1)/Real(2),Real(1)/Real(2),Real(1)/Real(800),Real(1)/Real(600)));
133 Rect & bounds = view->GetBounds();
134 view->Doc().LoadSVG(currentAction.filename, Rect(bounds.x+bounds.w/Real(2),bounds.y+bounds.h/Real(2),bounds.w/Real(800),bounds.h/Real(600)));
136 currentAction.type = AT_WaitFrame;
137 view->ForceRenderDirty();
138 view->ForceBufferDirty();
139 view->ForceBoundsDirty();
140 currentAction.loops = 1;
143 Fatal("Unknown script command in queue.");
145 currentAction.loops--;