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;
89 bool DebugScript::Execute(View *view, Screen *scr)
91 if (currentAction.loops == 0)
94 switch(currentAction.type)
101 view->Translate(currentAction.x, currentAction.y);
104 view->Translate(Real(currentAction.ix)/Real(scr->ViewportWidth()), Real(currentAction.iy)/Real(scr->ViewportHeight()));
107 view->ScaleAroundPoint(currentAction.x, currentAction.y, currentAction.z);
110 view->ScaleAroundPoint(Real(currentAction.ix)/Real(scr->ViewportWidth()),Real(currentAction.iy)/Real(scr->ViewportHeight()), Real(expf(-currentAction.iz/20.f)));
112 case AT_SetGPURendering:
113 view->SetGPURendering(true);
115 case AT_SetCPURendering:
116 view->SetGPURendering(false);
118 case AT_EnableLazyRendering:
119 view->SetLazyRendering(true);
121 case AT_DisableLazyRendering:
122 view->SetLazyRendering(false);
125 Fatal("Unknown script command in queue.");
127 currentAction.loops--;