X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fdebugscript.cpp;h=f92153cd9a7abe2f9fd8afe5ba8a8da8345a60e8;hp=a8bcd788a6eedea5b774d73229d617cca5e1525a;hb=ef0af5fd0129161a9e079bd3cd1298b53f1fe11a;hpb=875df16552ba91c5eb4a7aaf3c48537b3d93b3fb diff --git a/src/debugscript.cpp b/src/debugscript.cpp index a8bcd78..f92153c 100644 --- a/src/debugscript.cpp +++ b/src/debugscript.cpp @@ -46,50 +46,76 @@ void DebugScript::ParseAction() currentAction.x = RealFromStr(_x.c_str()); currentAction.y = RealFromStr(_y.c_str()); currentAction.z = RealFromStr(_z.c_str()); - return; } else if (actionType == "pxtranslate") { inp >> currentAction.ix >> currentAction.iy; currentAction.type = AT_TranslatePx; - return; } else if (actionType == "pxzoom") { inp >> currentAction.ix >> currentAction.iy >> currentAction.iz; currentAction.type = AT_ZoomPx; - return; } else if (actionType == "gpu") { currentAction.type = AT_SetGPURendering; - return; } else if (actionType == "cpu") { currentAction.type = AT_SetCPURendering; - return; } else if (actionType == "lazy") { currentAction.type = AT_EnableLazyRendering; - return; } else if (actionType == "nolazy") { currentAction.type = AT_DisableLazyRendering; - return; } else if (actionType == "quit") { currentAction.type = AT_Quit; } + else if (actionType == "loadsvg") + { + currentAction.type = AT_LoadSVG; + inp >> currentAction.textargs; + } + else if (actionType == "label") + { + currentAction.type = AT_Label; + inp >> currentAction.textargs; + } + else if (actionType == "goto") + { + currentAction.type = AT_Goto; + inp >> currentAction.textargs; + } + else if (actionType == "debug") + { + currentAction.type = AT_Debug; + getline(inp,currentAction.textargs); + } } bool DebugScript::Execute(View *view, Screen *scr) { - if (currentAction.loops == 0) - ParseAction(); + if (currentAction.loops <= 0) + { + if (m_index >= m_actions.size()) + { + ParseAction(); + if (m_labels.size() > 0) + { + m_actions.push_back(currentAction); + m_index++; + } + + } + else + currentAction = m_actions[m_index++]; + } switch(currentAction.type) { @@ -121,6 +147,35 @@ bool DebugScript::Execute(View *view, Screen *scr) case AT_DisableLazyRendering: view->SetLazyRendering(false); break; + case AT_LoadSVG: + { + #ifdef TRANSFORM_OBJECTS_NOT_VIEW + view->Doc().LoadSVG(currentAction.textargs, Rect(Real(1)/Real(2),Real(1)/Real(2),Real(1)/Real(800),Real(1)/Real(600))); + #else + const Rect & bounds = view->GetBounds(); + view->Doc().LoadSVG(currentAction.textargs, Rect(bounds.x+bounds.w/Real(2),bounds.y+bounds.h/Real(2),bounds.w/Real(800),bounds.h/Real(600))); + #endif + currentAction.type = AT_WaitFrame; + view->ForceRenderDirty(); + view->ForceBufferDirty(); + view->ForceBoundsDirty(); + currentAction.loops = 1; + break; + } + case AT_Label: + m_labels[currentAction.textargs] = m_index; + currentAction.type = AT_WaitFrame; + currentAction.loops = 1; + break; + case AT_Goto: + m_index = m_labels[currentAction.textargs]; + currentAction.loops = 1; + break; + case AT_Debug: + Debug("View bounds: %s", view->GetBounds().Str().c_str()); + if (currentAction.textargs.size() > 0) + Debug("%s", currentAction.textargs.c_str()); + break; default: Fatal("Unknown script command in queue."); }