[Scummvm-cvs-logs] SF.net SVN: scummvm:[46425] scummvm/trunk/engines/m4
dreammaster at users.sourceforge.net
dreammaster at users.sourceforge.net
Sun Dec 20 08:10:33 CET 2009
Revision: 46425
http://scummvm.svn.sourceforge.net/scummvm/?rev=46425&view=rev
Author: dreammaster
Date: 2009-12-20 07:10:32 +0000 (Sun, 20 Dec 2009)
Log Message:
-----------
Started implementation of the original game's cheat mode
Modified Paths:
--------------
scummvm/trunk/engines/m4/dialogs.cpp
scummvm/trunk/engines/m4/dialogs.h
scummvm/trunk/engines/m4/scene.cpp
scummvm/trunk/engines/m4/scene.h
scummvm/trunk/engines/m4/staticres.cpp
scummvm/trunk/engines/m4/staticres.h
Modified: scummvm/trunk/engines/m4/dialogs.cpp
===================================================================
--- scummvm/trunk/engines/m4/dialogs.cpp 2009-12-20 07:09:40 UTC (rev 46424)
+++ scummvm/trunk/engines/m4/dialogs.cpp 2009-12-20 07:10:32 UTC (rev 46425)
@@ -364,19 +364,25 @@
// 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();
} else if (matchCommand(cmdText, "INDEX")) {
@@ -396,6 +402,27 @@
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 @@
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 @@
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
Modified: scummvm/trunk/engines/m4/dialogs.h
===================================================================
--- scummvm/trunk/engines/m4/dialogs.h 2009-12-20 07:09:40 UTC (rev 46424)
+++ scummvm/trunk/engines/m4/dialogs.h 2009-12-20 07:10:32 UTC (rev 46425)
@@ -66,9 +66,12 @@
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
Modified: scummvm/trunk/engines/m4/scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/scene.cpp 2009-12-20 07:09:40 UTC (rev 46424)
+++ scummvm/trunk/engines/m4/scene.cpp 2009-12-20 07:10:32 UTC (rev 46425)
@@ -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 @@
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 @@
_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 @@
_highlightedElement = -1;
_topIndex = 0;
_selectedObject = -1;
+ _cheatKeyCtr = 0;
_objectSprites = NULL;
_objectPalData = NULL;
@@ -930,7 +932,7 @@
}
}
-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 @@
}
return true;
+ case KEVENT_KEY:
+ if (_cheatKeyCtr == CHEAT_SEQUENCE_MAX)
+ handleCheatKey(param1);
+ handleKeypress(param1);
+ return true;
+
default:
break;
}
@@ -1007,4 +1015,49 @@
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
Modified: scummvm/trunk/engines/m4/scene.h
===================================================================
--- scummvm/trunk/engines/m4/scene.h 2009-12-20 07:09:40 UTC (rev 46424)
+++ scummvm/trunk/engines/m4/scene.h 2009-12-20 07:10:32 UTC (rev 46425)
@@ -43,6 +43,8 @@
#define INTERFACE_HEIGHT 106
#define MADS_SURFACE_HEIGHT 156
+#define CHEAT_SEQUENCE_MAX 8
+
enum MADSVerbs {
kVerbNone = 0,
kVerbLook = 3,
@@ -106,7 +108,7 @@
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 @@
int _highlightedElement;
int _topIndex;
uint32 _nextScrollerTicks;
+ int _cheatKeyCtr;
// Object display fields
int _selectedObject;
@@ -156,6 +159,8 @@
int _objectFrameNumber;
void setFontMode(InterfaceFontMode newMode);
+ bool handleCheatKey(int32 keycode);
+ bool handleKeypress(int32 keycode);
public:
MadsInterfaceView(M4Engine *vm);
~MadsInterfaceView();
@@ -165,7 +170,7 @@
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
Modified: scummvm/trunk/engines/m4/staticres.cpp
===================================================================
--- scummvm/trunk/engines/m4/staticres.cpp 2009-12-20 07:09:40 UTC (rev 46424)
+++ scummvm/trunk/engines/m4/staticres.cpp 2009-12-20 07:10:32 UTC (rev 46425)
@@ -31,4 +31,11 @@
NULL, "with", "to", "at", "from", "on", "in", "under", "behind"
};
+const char *cheatingEnabledDesc[3] = {
+ "CHEATING ENABLED",
+ "(For your convenience).",
+ NULL
+};
+
+
} // End of namespace M4
Modified: scummvm/trunk/engines/m4/staticres.h
===================================================================
--- scummvm/trunk/engines/m4/staticres.h 2009-12-20 07:09:40 UTC (rev 46424)
+++ scummvm/trunk/engines/m4/staticres.h 2009-12-20 07:10:32 UTC (rev 46425)
@@ -33,6 +33,8 @@
extern const char *englishMADSArticleList[9];
+extern const char *cheatingEnabledDesc[3];
+
} // End of namespace M4
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list