00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <stdio.h>
00023
00024 #include "BaseActions.h"
00025 #include "Actions.h"
00026 #include "BaseClasses.h"
00027 #include "ParseNode.h"
00028 #include "ASN1Codes.h"
00029 #include "Ingredients.h"
00030 #include "Engine.h"
00031 #include "Variables.h"
00032 #include "Programs.h"
00033 #include "Bitmap.h"
00034 #include "Visible.h"
00035 #include "Text.h"
00036 #include "DynamicLineArt.h"
00037 #include "Link.h"
00038 #include "TokenGroup.h"
00039 #include "Stream.h"
00040 #include "Logging.h"
00041
00042
00043
00044 class MHUnimplementedAction: public MHElemAction
00045 {
00046 public:
00047 MHUnimplementedAction(int nTag): MHElemAction("")
00048 {
00049 m_nTag = nTag;
00050 }
00051 virtual void Initialise(MHParseNode *, MHEngine *) {}
00052 virtual void PrintMe(FILE *fd, int ) const
00053 {
00054 fprintf(fd, "****Missing action %d\n", m_nTag);
00055 }
00056 virtual void Perform(MHEngine *)
00057 {
00058 MHERROR(QString("Unimplemented action %1").arg(m_nTag));
00059 }
00060 protected:
00061 int m_nTag;
00062 };
00063
00064
00065
00066
00067 void MHActionSequence::Initialise(MHParseNode *p, MHEngine *engine)
00068 {
00069
00070 for (int i = 0; i < p->GetArgCount(); i++)
00071 {
00072 MHParseNode *pElemAction = p->GetArgN(i);
00073 MHElemAction *pAction;
00074
00075 switch (pElemAction->GetTagNo())
00076 {
00077 case C_ACTIVATE:
00078 pAction = new MHActivate(":Activate", true);
00079 break;
00080 case C_ADD:
00081 pAction = new MHAdd;
00082 break;
00083 case C_ADD_ITEM:
00084 pAction = new MHAddItem;
00085 break;
00086 case C_APPEND:
00087 pAction = new MHAppend;
00088 break;
00089 case C_BRING_TO_FRONT:
00090 pAction = new MHBringToFront;
00091 break;
00092 case C_CALL:
00093 pAction = new MHCall(":Call", false);
00094 break;
00095 case C_CALL_ACTION_SLOT:
00096 pAction = new MHCallActionSlot;
00097 break;
00098 case C_CLEAR:
00099 pAction = new MHClear;
00100 break;
00101 case C_CLONE:
00102 pAction = new MHClone;
00103 break;
00104 case C_CLOSE_CONNECTION:
00105 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00106 break;
00107 case C_DEACTIVATE:
00108 pAction = new MHActivate(":Deactivate", false);
00109 break;
00110 case C_DEL_ITEM:
00111 pAction = new MHDelItem;
00112 break;
00113 case C_DESELECT:
00114 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00115 break;
00116 case C_DESELECT_ITEM:
00117 pAction = new MHDeselectItem;
00118 break;
00119 case C_DIVIDE:
00120 pAction = new MHDivide;
00121 break;
00122 case C_DRAW_ARC:
00123 pAction = new MHDrawArcSector(":DrawArc", false);
00124 break;
00125 case C_DRAW_LINE:
00126 pAction = new MHDrawLine;
00127 break;
00128 case C_DRAW_OVAL:
00129 pAction = new MHDrawOval;
00130 break;
00131 case C_DRAW_POLYGON:
00132 pAction = new MHDrawPoly(":DrawPolygon", true);
00133 break;
00134 case C_DRAW_POLYLINE:
00135 pAction = new MHDrawPoly(":DrawPolyline", false);
00136 break;
00137 case C_DRAW_RECTANGLE:
00138 pAction = new MHDrawRectangle;
00139 break;
00140 case C_DRAW_SECTOR:
00141 pAction = new MHDrawArcSector(":DrawSector", true);
00142 break;
00143 case C_FORK:
00144 pAction = new MHCall(":Fork", true);
00145 break;
00146 case C_GET_AVAILABILITY_STATUS:
00147 pAction = new MHGetAvailabilityStatus;
00148 break;
00149 case C_GET_BOX_SIZE:
00150 pAction = new MHGetBoxSize;
00151 break;
00152 case C_GET_CELL_ITEM:
00153 pAction = new MHGetCellItem;
00154 break;
00155 case C_GET_CURSOR_POSITION:
00156 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00157 break;
00158 case C_GET_ENGINE_SUPPORT:
00159 pAction = new MHGetEngineSupport;
00160 break;
00161 case C_GET_ENTRY_POINT:
00162 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00163 break;
00164 case C_GET_FILL_COLOUR:
00165 pAction = new MHGetFillColour;
00166 break;
00167 case C_GET_FIRST_ITEM:
00168 pAction = new MHGetFirstItem;
00169 break;
00170 case C_GET_HIGHLIGHT_STATUS:
00171 pAction = new MHGetHighlightStatus;
00172 break;
00173 case C_GET_INTERACTION_STATUS:
00174 pAction = new MHGetInteractionStatus;
00175 break;
00176 case C_GET_ITEM_STATUS:
00177 pAction = new MHGetItemStatus;
00178 break;
00179 case C_GET_LABEL:
00180 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00181 break;
00182 case C_GET_LAST_ANCHOR_FIRED:
00183 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00184 break;
00185 case C_GET_LINE_COLOUR:
00186 pAction = new MHGetLineColour;
00187 break;
00188 case C_GET_LINE_STYLE:
00189 pAction = new MHGetLineStyle;
00190 break;
00191 case C_GET_LINE_WIDTH:
00192 pAction = new MHGetLineWidth;
00193 break;
00194 case C_GET_LIST_ITEM:
00195 pAction = new MHGetListItem;
00196 break;
00197 case C_GET_LIST_SIZE:
00198 pAction = new MHGetListSize;
00199 break;
00200 case C_GET_OVERWRITE_MODE:
00201 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00202 break;
00203 case C_GET_PORTION:
00204 pAction = new MHGetPortion;
00205 break;
00206 case C_GET_POSITION:
00207 pAction = new MHGetPosition;
00208 break;
00209 case C_GET_RUNNING_STATUS:
00210 pAction = new MHGetRunningStatus;
00211 break;
00212 case C_GET_SELECTION_STATUS:
00213 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00214 break;
00215 case C_GET_SLIDER_VALUE:
00216 pAction = new MHGetSliderValue;
00217 break;
00218 case C_GET_TEXT_CONTENT:
00219 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00220 break;
00221 case C_GET_TEXT_DATA:
00222 pAction = new MHGetTextData;
00223 break;
00224 case C_GET_TOKEN_POSITION:
00225 pAction = new MHGetTokenPosition;
00226 break;
00227 case C_GET_VOLUME:
00228 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00229 break;
00230 case C_LAUNCH:
00231 pAction = new MHLaunch;
00232 break;
00233 case C_LOCK_SCREEN:
00234 pAction = new MHLockScreen;
00235 break;
00236 case C_MODULO:
00237 pAction = new MHModulo;
00238 break;
00239 case C_MOVE:
00240 pAction = new MHMove;
00241 break;
00242 case C_MOVE_TO:
00243 pAction = new MHMoveTo;
00244 break;
00245 case C_MULTIPLY:
00246 pAction = new MHMultiply;
00247 break;
00248 case C_OPEN_CONNECTION:
00249 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00250 break;
00251 case C_PRELOAD:
00252 pAction = new MHPreload;
00253 break;
00254 case C_PUT_BEFORE:
00255 pAction = new MHPutBefore;
00256 break;
00257 case C_PUT_BEHIND:
00258 pAction = new MHPutBehind;
00259 break;
00260 case C_QUIT:
00261 pAction = new MHQuit;
00262 break;
00263 case C_READ_PERSISTENT:
00264 pAction = new MHPersistent(":ReadPersistent", true);
00265 break;
00266 case C_RUN:
00267 pAction = new MHRun;
00268 break;
00269 case C_SCALE_BITMAP:
00270 pAction = new MHScaleBitmap;
00271 break;
00272 case C_SCALE_VIDEO:
00273 pAction = new MHScaleVideo;
00274 break;
00275 case C_SCROLL_ITEMS:
00276 pAction = new MHScrollItems;
00277 break;
00278 case C_SELECT:
00279 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00280 break;
00281 case C_SELECT_ITEM:
00282 pAction = new MHSelectItem;
00283 break;
00284 case C_SEND_EVENT:
00285 pAction = new MHSendEvent;
00286 break;
00287 case C_SEND_TO_BACK:
00288 pAction = new MHSendToBack;
00289 break;
00290 case C_SET_BOX_SIZE:
00291 pAction = new MHSetBoxSize;
00292 break;
00293 case C_SET_CACHE_PRIORITY:
00294 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00295 break;
00296 case C_SET_COUNTER_END_POSITION:
00297 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00298 break;
00299 case C_SET_COUNTER_POSITION:
00300 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00301 break;
00302 case C_SET_COUNTER_TRIGGER:
00303 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00304 break;
00305 case C_SET_CURSOR_POSITION:
00306 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00307 break;
00308 case C_SET_CURSOR_SHAPE:
00309 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00310 break;
00311 case C_SET_DATA:
00312 pAction = new MHSetData;
00313 break;
00314 case C_SET_ENTRY_POINT:
00315 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00316 break;
00317 case C_SET_FILL_COLOUR:
00318 pAction = new MHSetFillColour;
00319 break;
00320 case C_SET_FIRST_ITEM:
00321 pAction = new MHSetFirstItem;
00322 break;
00323 case C_SET_FONT_REF:
00324 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00325 break;
00326 case C_SET_HIGHLIGHT_STATUS:
00327 pAction = new MHSetHighlightStatus;
00328 break;
00329 case C_SET_INTERACTION_STATUS:
00330 pAction = new MHSetInteractionStatus;
00331 break;
00332 case C_SET_LABEL:
00333 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00334 break;
00335 case C_SET_LINE_COLOUR:
00336 pAction = new MHSetLineColour;
00337 break;
00338 case C_SET_LINE_STYLE:
00339 pAction = new MHSetLineStyle;
00340 break;
00341 case C_SET_LINE_WIDTH:
00342 pAction = new MHSetLineWidth;
00343 break;
00344 case C_SET_OVERWRITE_MODE:
00345 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00346 break;
00347 case C_SET_PALETTE_REF:
00348 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00349 break;
00350 case C_SET_PORTION:
00351 pAction = new MHSetPortion;
00352 break;
00353 case C_SET_POSITION:
00354 pAction = new MHSetPosition;
00355 break;
00356 case C_SET_SLIDER_VALUE:
00357 pAction = new MHSetSliderValue;
00358 break;
00359 case C_SET_SPEED:
00360 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00361 break;
00362 case C_SET_TIMER:
00363 pAction = new MHSetTimer;
00364 break;
00365 case C_SET_TRANSPARENCY:
00366 pAction = new MHSetTransparency;
00367 break;
00368 case C_SET_VARIABLE:
00369 pAction = new MHSetVariable;
00370 break;
00371 case C_SET_VOLUME:
00372 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00373 break;
00374 case C_SPAWN:
00375 pAction = new MHSpawn;
00376 break;
00377 case C_STEP:
00378 pAction = new MHStep;
00379 break;
00380 case C_STOP:
00381 pAction = new MHStop;
00382 break;
00383 case C_STORE_PERSISTENT:
00384 pAction = new MHPersistent(":StorePersistent", false);
00385 break;
00386 case C_SUBTRACT:
00387 pAction = new MHSubtract;
00388 break;
00389 case C_TEST_VARIABLE:
00390 pAction = new MHTestVariable;
00391 break;
00392 case C_TOGGLE:
00393 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00394 break;
00395 case C_TOGGLE_ITEM:
00396 pAction = new MHToggleItem;
00397 break;
00398 case C_TRANSITION_TO:
00399 pAction = new MHTransitionTo;
00400 break;
00401 case C_UNLOAD:
00402 pAction = new MHUnload;
00403 break;
00404 case C_UNLOCK_SCREEN:
00405 pAction = new MHUnlockScreen;
00406 break;
00407
00408 case C_SET_BACKGROUND_COLOUR:
00409 pAction = new MHSetBackgroundColour;
00410 break;
00411 case C_SET_CELL_POSITION:
00412 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00413 break;
00414 case C_SET_INPUT_REGISTER:
00415 pAction = new MHSetInputRegister;
00416 break;
00417 case C_SET_TEXT_COLOUR:
00418 pAction = new MHSetTextColour;
00419 break;
00420 case C_SET_FONT_ATTRIBUTES:
00421 pAction = new MHSetFontAttributes;
00422 break;
00423 case C_SET_VIDEO_DECODE_OFFSET:
00424 pAction = new MHSetVideoDecodeOffset;
00425 break;
00426 case C_GET_VIDEO_DECODE_OFFSET:
00427 pAction = new MHGetVideoDecodeOffset;
00428 break;
00429 case C_GET_FOCUS_POSITION:
00430 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00431 break;
00432 case C_SET_FOCUS_POSITION:
00433 pAction = new MHUnimplementedAction(pElemAction->GetTagNo());
00434 break;
00435 case C_SET_BITMAP_DECODE_OFFSET:
00436 pAction = new MHSetBitmapDecodeOffset;
00437 break;
00438 case C_GET_BITMAP_DECODE_OFFSET:
00439 pAction = new MHGetBitmapDecodeOffset;
00440 break;
00441 case C_SET_SLIDER_PARAMETERS:
00442 pAction = new MHSetSliderParameters;
00443 break;
00444
00445 default:
00446 MHLOG(MHLogWarning, QString("Unknown action %1").arg(pElemAction->GetTagNo()));
00447
00448
00449 pAction = NULL;
00450 }
00451
00452 if (pAction)
00453 {
00454 Append(pAction);
00455 pAction->Initialise(pElemAction, engine);
00456 }
00457 }
00458 }
00459
00460 void MHActionSequence::PrintMe(FILE *fd, int nTabs) const
00461 {
00462 for (int i = 0; i < Size(); i++)
00463 {
00464 GetAt(i)->PrintMe(fd, nTabs);
00465 }
00466 }