diff options
author | Paul Gilbert | 2009-12-20 07:10:32 +0000 |
---|---|---|
committer | Paul Gilbert | 2009-12-20 07:10:32 +0000 |
commit | 5c732e00ee61b3661ad3ca8679ff270ace6d7d10 (patch) | |
tree | 0fc3b21950f2705023a837991787a9828c5adc39 | |
parent | b729218bb6f48a7e57cd938f76ca0065983b792e (diff) | |
download | scummvm-rg350-5c732e00ee61b3661ad3ca8679ff270ace6d7d10.tar.gz scummvm-rg350-5c732e00ee61b3661ad3ca8679ff270ace6d7d10.tar.bz2 scummvm-rg350-5c732e00ee61b3661ad3ca8679ff270ace6d7d10.zip |
Started implementation of the original game's cheat mode
svn-id: r46425
-rw-r--r-- | engines/m4/dialogs.cpp | 42 | ||||
-rw-r--r-- | engines/m4/dialogs.h | 5 | ||||
-rw-r--r-- | engines/m4/scene.cpp | 59 | ||||
-rw-r--r-- | engines/m4/scene.h | 9 | ||||
-rw-r--r-- | engines/m4/staticres.cpp | 7 | ||||
-rw-r--r-- | engines/m4/staticres.h | 2 |
6 files changed, 113 insertions, 11 deletions
diff --git a/engines/m4/dialogs.cpp b/engines/m4/dialogs.cpp index 442c31f35d..9adf6c42e5 100644 --- a/engines/m4/dialogs.cpp +++ b/engines/m4/dialogs.cpp @@ -364,18 +364,24 @@ Dialog::Dialog(M4Engine *vm, const char *msgData, const char *title): View(vm, C // Noun command 1 handleNounSuffix(lineP, 1, cmdText + 5); - } else if (matchCommand(cmdText, "NOUN1")) { + } else if (matchCommand(cmdText, "NOUN2")) { // Noun command 2 handleNounSuffix(lineP, 2, cmdText + 5); + } else if (matchCommand(cmdText, "TAB")) { + // Specifies the X offset for the current line + _lines[_lines.size() - 1].xp = atoi(cmdText + 3); + + } else if (matchCommand(cmdText, "UNDER")) { + // Underline command + underline = true; + } else if (matchCommand(cmdText, "VERB")) { // Verb/vocab retrieval int verbId = 1; // TODO: Get correct vocab getVocab(verbId, &lineP); - } else if (matchCommand(cmdText, "UNDER")) { - // Underline command - underline = true; + } else if (matchCommand(cmdText, "ASK")) { // doAsk(); @@ -396,6 +402,27 @@ Dialog::Dialog(M4Engine *vm, const char *msgData, const char *title): View(vm, C draw(); } +Dialog::Dialog(M4Engine *vm, int widthChars, const char **descEntries): View(vm, Common::Rect(0, 0, 0, 0)) { + _vm->_font->setFont(FONT_INTERFACE_MADS); + _widthChars = widthChars * 2; + _dialogWidth = widthChars * (_vm->_font->getMaxWidth() + DIALOG_SPACING) + 10; + _screenType = LAYER_DIALOG; + _lineX = 0; + _widthX = 0; + + while (*descEntries != NULL) { + incLine(); + writeChars(*descEntries); + + int lineWidth = _vm->_font->getWidth(*descEntries, DIALOG_SPACING); + _lines[_lines.size() - 1].xp = (_dialogWidth - 10 - lineWidth) / 2; + ++descEntries; + } + + _lines[0].underline = true; + draw(); +} + Dialog::~Dialog() { _vm->_palette->deleteRange(_palette); delete _palette; @@ -477,7 +504,7 @@ void Dialog::draw() { this->translate(_palette); } -bool Dialog::onEvent(M4EventType eventType, int param1, int x, int y, bool &captureEvents) { +bool Dialog::onEvent(M4EventType eventType, int32 param1, int x, int y, bool &captureEvents) { if (_vm->_mouse->getCursorNum() != CURSOR_ARROW) _vm->_mouse->setCursorNum(CURSOR_ARROW); @@ -491,5 +518,10 @@ bool Dialog::onEvent(M4EventType eventType, int param1, int x, int y, bool &capt return true; } +void Dialog::display(M4Engine *vm, int widthChars, const char **descEntries) { + Dialog *dlg = new Dialog(vm, widthChars, descEntries); + vm->_viewManager->addView(dlg); + vm->_viewManager->moveToFront(dlg); +} } // End of namespace M4 diff --git a/engines/m4/dialogs.h b/engines/m4/dialogs.h index c8b19338f3..057164fe62 100644 --- a/engines/m4/dialogs.h +++ b/engines/m4/dialogs.h @@ -66,9 +66,12 @@ private: void draw(); public: Dialog(M4Engine *vm, const char *msgData, const char *title = NULL); + Dialog(M4Engine *vm, int widthChars, const char **descEntries); virtual ~Dialog(); - bool onEvent(M4EventType eventType, int param1, int x, int y, bool &captureEvents); + static void display(M4Engine *vm, int widthChars, const char **descEntries); + + bool onEvent(M4EventType eventType, int32 param1, int x, int y, bool &captureEvents); }; } // End of namespace M4 diff --git a/engines/m4/scene.cpp b/engines/m4/scene.cpp index 4177825da2..905cb744c3 100644 --- a/engines/m4/scene.cpp +++ b/engines/m4/scene.cpp @@ -34,6 +34,7 @@ #include "m4/font.h" #include "m4/m4_views.h" #include "m4/compression.h" +#include "m4/staticres.h" namespace M4 { @@ -490,7 +491,7 @@ void Scene::onRefresh(RectList *rects, M4Surface *destSurface) { View::onRefresh(rects, destSurface); } -bool Scene::onEvent(M4EventType eventType, int param1, int x, int y, bool &captureEvents) { +bool Scene::onEvent(M4EventType eventType, int32 param1, int x, int y, bool &captureEvents) { //if (_vm->getGameType() != GType_Burger) // return false; @@ -558,7 +559,7 @@ bool Scene::onEvent(M4EventType eventType, int param1, int x, int y, bool &captu _vm->_interfaceView->_inventory.clearSelected(); } else { // ***DEBUG*** - sample dialog display - int idx = _vm->_globals->messageIndexOf(0x277a); + int idx = 3; //_vm->_globals->messageIndexOf(0x277a); const char *msg = _vm->_globals->loadMessage(idx); Dialog *dlg = new Dialog(_vm, msg, "TEST DIALOG"); _vm->_viewManager->addView(dlg); @@ -733,6 +734,7 @@ MadsInterfaceView::MadsInterfaceView(M4Engine *vm): View(vm, Common::Rect(0, MAD _highlightedElement = -1; _topIndex = 0; _selectedObject = -1; + _cheatKeyCtr = 0; _objectSprites = NULL; _objectPalData = NULL; @@ -930,7 +932,7 @@ void MadsInterfaceView::onRefresh(RectList *rects, M4Surface *destSurface) { } } -bool MadsInterfaceView::onEvent(M4EventType eventType, int param1, int x, int y, bool &captureEvents) { +bool MadsInterfaceView::onEvent(M4EventType eventType, int32 param1, int x, int y, bool &captureEvents) { // If the mouse isn't being held down, then reset the repeated scroll timer if (eventType != MEVENT_LEFT_HOLD) _nextScrollerTicks = 0; @@ -1000,6 +1002,12 @@ bool MadsInterfaceView::onEvent(M4EventType eventType, int param1, int x, int y, } return true; + case KEVENT_KEY: + if (_cheatKeyCtr == CHEAT_SEQUENCE_MAX) + handleCheatKey(param1); + handleKeypress(param1); + return true; + default: break; } @@ -1007,4 +1015,49 @@ bool MadsInterfaceView::onEvent(M4EventType eventType, int param1, int x, int y, return false; } +bool MadsInterfaceView::handleCheatKey(int32 keycode) { + switch (keycode) { + case Common::KEYCODE_SPACE: + // TODO: Move player to current destination + return true; + + case Common::KEYCODE_t | (Common::KEYCODE_LALT): + case Common::KEYCODE_t | (Common::KEYCODE_RALT): + { + // Teleport to room + //Scene *sceneView = (Scene *)vm->_viewManager->getView(VIEWID_SCENE); + + + return true; + } + + default: + break; + } + + return false; +} + +const char *CHEAT_SEQUENCE = "widepipe"; + +bool MadsInterfaceView::handleKeypress(int32 keycode) { + int flags = keycode >> 24; + int kc = keycode & 0xffff; + + // Capitalise the letter if necessary + if (_cheatKeyCtr < CHEAT_SEQUENCE_MAX) { + if ((flags == Common::KBD_CTRL) && (kc == CHEAT_SEQUENCE[_cheatKeyCtr])) { + ++_cheatKeyCtr; + if (_cheatKeyCtr == CHEAT_SEQUENCE_MAX) + Dialog::display(_vm, 22, cheatingEnabledDesc); + return true; + } else { + _cheatKeyCtr = 0; + } + } + + return false; +} + + } // End of namespace M4 diff --git a/engines/m4/scene.h b/engines/m4/scene.h index bdd84cdb81..593bbddc07 100644 --- a/engines/m4/scene.h +++ b/engines/m4/scene.h @@ -43,6 +43,8 @@ namespace M4 { #define INTERFACE_HEIGHT 106 #define MADS_SURFACE_HEIGHT 156 +#define CHEAT_SEQUENCE_MAX 8 + enum MADSVerbs { kVerbNone = 0, kVerbLook = 3, @@ -106,7 +108,7 @@ public: void showMADSV2TextBox(char *text, int x, int y, char *faceName); void onRefresh(RectList *rects, M4Surface *destSurface); - bool onEvent(M4EventType eventType, int param1, int x, int y, bool &captureEvents); + bool onEvent(M4EventType eventType, int32 param1, int x, int y, bool &captureEvents); private: int _currentScene; @@ -148,6 +150,7 @@ private: int _highlightedElement; int _topIndex; uint32 _nextScrollerTicks; + int _cheatKeyCtr; // Object display fields int _selectedObject; @@ -156,6 +159,8 @@ private: int _objectFrameNumber; void setFontMode(InterfaceFontMode newMode); + bool handleCheatKey(int32 keycode); + bool handleKeypress(int32 keycode); public: MadsInterfaceView(M4Engine *vm); ~MadsInterfaceView(); @@ -165,7 +170,7 @@ public: void addObjectToInventory(int objectNumber); void onRefresh(RectList *rects, M4Surface *destSurface); - bool onEvent(M4EventType eventType, int param1, int x, int y, bool &captureEvents); + bool onEvent(M4EventType eventType, int32 param1, int x, int y, bool &captureEvents); }; } // End of namespace M4 diff --git a/engines/m4/staticres.cpp b/engines/m4/staticres.cpp index f7da10410b..d376c30bcc 100644 --- a/engines/m4/staticres.cpp +++ b/engines/m4/staticres.cpp @@ -31,4 +31,11 @@ const char *englishMADSArticleList[9] = { NULL, "with", "to", "at", "from", "on", "in", "under", "behind" }; +const char *cheatingEnabledDesc[3] = { + "CHEATING ENABLED", + "(For your convenience).", + NULL +}; + + } // End of namespace M4 diff --git a/engines/m4/staticres.h b/engines/m4/staticres.h index b3cba62e59..754e37db46 100644 --- a/engines/m4/staticres.h +++ b/engines/m4/staticres.h @@ -33,6 +33,8 @@ namespace M4 { extern const char *englishMADSArticleList[9]; +extern const char *cheatingEnabledDesc[3]; + } // End of namespace M4 #endif |