From 6c354bccf253118d459f92f16d8f702ae07806fb Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Feb 2014 17:25:30 -0500 Subject: MADS: Implemented more logic for dialog display --- engines/mads/debugger.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 engines/mads/debugger.cpp (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp new file mode 100644 index 0000000000..ceaeeaa5dd --- /dev/null +++ b/engines/mads/debugger.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "mads/mads.h" +#include "mads/debugger.h" + +namespace MADS { + +Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) { + DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); +} +/* +static int strToInt(const char *s) { + if (!*s) + // No string at all + return 0; + else if (toupper(s[strlen(s) - 1]) != 'H') + // Standard decimal string + return atoi(s); + + // Hexadecimal string + uint tmp = 0; + int read = sscanf(s, "%xh", &tmp); + if (read < 1) + error("strToInt failed on string \"%s\"", s); + return (int)tmp; +} +*/ + +} // End of namespace MADS -- cgit v1.2.3 From 9e356dd945863a4c4dfa89f2a94dd1a56c2d03a6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 3 Mar 2014 23:40:23 -0500 Subject: MADS: Implemented extra message and dirty area classes --- engines/mads/debugger.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index ceaeeaa5dd..34b12c1680 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -26,6 +26,8 @@ namespace MADS { Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) { + _showMousePos = false; + DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); } /* @@ -46,4 +48,14 @@ static int strToInt(const char *s) { } */ +bool Debugger::Cmd_Mouse(int argc, const char **argv) { + if (argc < 2) { + DebugPrintf("Format: mouse [ on | off ]\n"); + } else { + _showMousePos = strcmp(argv[1], "on") == 0; + } + + return true; +} + } // End of namespace MADS -- cgit v1.2.3 From a22318959989caf91916ba792f80103afe71092a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Mar 2014 14:26:50 -0400 Subject: MADS: Added extra debugger commands --- engines/mads/debugger.cpp | 104 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 2 deletions(-) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index 34b12c1680..3bc4ed2c16 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -20,6 +20,7 @@ * */ +#include "common/file.h" #include "mads/mads.h" #include "mads/debugger.h" @@ -29,8 +30,15 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) { _showMousePos = false; DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); + DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_Mouse)); + DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_LoadScene)); + DCmd_Register("show_hotspots", WRAP_METHOD(Debugger, Cmd_ShowHotSpots)); + DCmd_Register("list_hotspots", WRAP_METHOD(Debugger, Cmd_ListHotSpots)); + DCmd_Register("play_sound", WRAP_METHOD(Debugger, Cmd_PlaySound)); + DCmd_Register("show_codes", WRAP_METHOD(Debugger, Cmd_ShowCodes)); + DCmd_Register("dump_file", WRAP_METHOD(Debugger, Cmd_DumpFile)); } -/* + static int strToInt(const char *s) { if (!*s) // No string at all @@ -46,7 +54,6 @@ static int strToInt(const char *s) { error("strToInt failed on string \"%s\"", s); return (int)tmp; } -*/ bool Debugger::Cmd_Mouse(int argc, const char **argv) { if (argc < 2) { @@ -58,4 +65,97 @@ bool Debugger::Cmd_Mouse(int argc, const char **argv) { return true; } +bool Debugger::Cmd_LoadScene(int argc, const char **argv) { + if (argc != 2) { + DebugPrintf("Usage: %s \n", argv[0]); + return true; + } else { + _vm->_game->_scene._nextSceneId = strToInt(argv[1]); + return false; + } +} + +bool Debugger::Cmd_ShowHotSpots(int argc, const char **argv) { + Scene &scene = _vm->_game->_scene; + + // hotspots + byte hotspotCol = _vm->getRandomNumber(255); + for (uint i = 0; i < scene._hotspots.size(); i++) { + scene._backgroundSurface.frameRect(scene._hotspots[i]._bounds, hotspotCol); + } + + // Dynamic hotspots (red) + hotspotCol = _vm->getRandomNumber(255); + for (uint i = 0; i < scene._dynamicHotspots.size(); i++) { + scene._backgroundSurface.frameRect(scene._dynamicHotspots[i]._bounds, hotspotCol); + } + + scene._spriteSlots.fullRefresh(); + return false; +} + +bool Debugger::Cmd_ListHotSpots(int argc, const char **argv) { + Hotspots &hotspots = _vm->_game->_scene._hotspots; + + DebugPrintf("%d hotspots present\n", hotspots.size()); + + for (uint index = 0; index < hotspots.size(); ++index) { + DebugPrintf("(%d): %p x1 = %d; y1 = %d; x2 = %d; y2 = %d\n", + index, (void *)&hotspots[index], + hotspots[index]._bounds.left, hotspots[index]._bounds.top, + hotspots[index]._bounds.right, hotspots[index]._bounds.bottom); + } + + return true; +} + +bool Debugger::Cmd_PlaySound(int argc, const char **argv) { + if (argc < 2) { + DebugPrintf("Usage: %s \n", argv[0]); + } else { + int commandId = strToInt(argv[1]); + int param = (argc >= 3) ? strToInt(argv[2]) : 0; + + _vm->_sound->command(commandId, param); + } + + return false; +} + +bool Debugger::Cmd_ShowCodes(int argc, const char **argv) { + Scene &scene = _vm->_game->_scene; + + scene._depthSurface.copyTo(&scene._backgroundSurface); + scene._spriteSlots.fullRefresh(); + + return false; +} + +bool Debugger::Cmd_DumpFile(int argc, const char **argv) { + if (argc != 2) { + DebugPrintf("Usage: %s \n", argv[0]); + } else { + Common::DumpFile outFile; + Common::File inFile; + + if (!inFile.open(argv[1])) { + DebugPrintf("Specified resource does not exist\n"); + } else { + outFile.open(argv[1]); + byte *data = new byte[inFile.size()]; + + inFile.read(data, inFile.size()); + outFile.write(data, inFile.size()); + + delete[] data; + inFile.close(); + outFile.close(); + + DebugPrintf("File written successfully.\n"); + } + } + + return true; +} + } // End of namespace MADS -- cgit v1.2.3 From addb3e2900ee417fb71a75f9afae08b00007daa5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 29 Mar 2014 13:38:52 -0400 Subject: MADS: Minor renamings and added display of walk nodes to debugger --- engines/mads/debugger.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index 3bc4ed2c16..58bf8388e4 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -125,9 +125,19 @@ bool Debugger::Cmd_PlaySound(int argc, const char **argv) { bool Debugger::Cmd_ShowCodes(int argc, const char **argv) { Scene &scene = _vm->_game->_scene; + // Copy the depth/walk surface to the background and flag for screen refresh scene._depthSurface.copyTo(&scene._backgroundSurface); scene._spriteSlots.fullRefresh(); + // Draw the locations of scene nodes onto the background + int color = _vm->getRandomNumber(255); + for (int i = 0; i < (int)scene._sceneInfo->_nodes.size(); ++i) { + Common::Point &pt = scene._sceneInfo->_nodes[i]._walkPos; + + scene._backgroundSurface.hLine(pt.x - 2, pt.y, pt.x + 2, color); + scene._backgroundSurface.vLine(pt.x, pt.y - 2, pt.y + 2, color); + } + return false; } -- cgit v1.2.3 From 88dcc7e0d64d3cc1c0963d90dcaad7ea112420df Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 5 Apr 2014 23:36:10 +0200 Subject: MADS: Add debugger command to display quotes --- engines/mads/debugger.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index 58bf8388e4..276340f240 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -37,6 +37,7 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) { DCmd_Register("play_sound", WRAP_METHOD(Debugger, Cmd_PlaySound)); DCmd_Register("show_codes", WRAP_METHOD(Debugger, Cmd_ShowCodes)); DCmd_Register("dump_file", WRAP_METHOD(Debugger, Cmd_DumpFile)); + DCmd_Register("show_quote", WRAP_METHOD(Debugger, Cmd_ShowQuote)); } static int strToInt(const char *s) { @@ -168,4 +169,13 @@ bool Debugger::Cmd_DumpFile(int argc, const char **argv) { return true; } +bool Debugger::Cmd_ShowQuote(int argc, const char **argv) { + if (argc != 2) + DebugPrintf("Usage: %s \n", argv[0]); + else + DebugPrintf("%s", _vm->_game->getQuote(strToInt(argv[1])).c_str()); + + return true; +} + } // End of namespace MADS -- cgit v1.2.3 From dbbfdeec8fb2d042844cee67c91c7d639f2a8eaa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 10 Apr 2014 20:04:58 -0400 Subject: MADS: Added an item command to the debugger --- engines/mads/debugger.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index 276340f240..7d66b56989 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -38,6 +38,7 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) { DCmd_Register("show_codes", WRAP_METHOD(Debugger, Cmd_ShowCodes)); DCmd_Register("dump_file", WRAP_METHOD(Debugger, Cmd_DumpFile)); DCmd_Register("show_quote", WRAP_METHOD(Debugger, Cmd_ShowQuote)); + DCmd_Register("item", WRAP_METHOD(Debugger, Cmd_Item)); } static int strToInt(const char *s) { @@ -178,4 +179,21 @@ bool Debugger::Cmd_ShowQuote(int argc, const char **argv) { return true; } +bool Debugger::Cmd_Item(int argc, const char **argv) { + InventoryObjects &objects = _vm->_game->_objects; + + if (argc != 2) { + DebugPrintf("Usage: %s \n", argv[0]); + return true; + } else { + int objectId = strToInt(argv[1]); + + if (!objects.isInInventory(objectId)) + objects.addToInventory(objectId); + + DebugPrintf("Item added.\n"); + return false; + } +} + } // End of namespace MADS -- cgit v1.2.3 From 15658397d418833d7839e1c85e3093c1fc79fdcf Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 27 Apr 2014 20:55:09 +0300 Subject: MADS: Show the current scene when using "scene" without params --- engines/mads/debugger.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index 7d66b56989..a6192b2a34 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -69,6 +69,7 @@ bool Debugger::Cmd_Mouse(int argc, const char **argv) { bool Debugger::Cmd_LoadScene(int argc, const char **argv) { if (argc != 2) { + DebugPrintf("Current scene is: %d\n", _vm->_game->_scene._currentSceneId); DebugPrintf("Usage: %s \n", argv[0]); return true; } else { -- cgit v1.2.3 From 6c9075eb2539aa4264ce4298772437caec55b256 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 27 Apr 2014 22:56:15 +0300 Subject: MADS: Implement the audio player This is used for all digital samples, plus voices in talkie versions. Currently, it's only hooked to the "play_audio" debugger command --- engines/mads/debugger.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index a6192b2a34..80a8cb748e 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -35,6 +35,7 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) { DCmd_Register("show_hotspots", WRAP_METHOD(Debugger, Cmd_ShowHotSpots)); DCmd_Register("list_hotspots", WRAP_METHOD(Debugger, Cmd_ListHotSpots)); DCmd_Register("play_sound", WRAP_METHOD(Debugger, Cmd_PlaySound)); + DCmd_Register("play_audio", WRAP_METHOD(Debugger, Cmd_PlayAudio)); DCmd_Register("show_codes", WRAP_METHOD(Debugger, Cmd_ShowCodes)); DCmd_Register("dump_file", WRAP_METHOD(Debugger, Cmd_DumpFile)); DCmd_Register("show_quote", WRAP_METHOD(Debugger, Cmd_ShowQuote)); @@ -125,6 +126,24 @@ bool Debugger::Cmd_PlaySound(int argc, const char **argv) { return false; } +bool Debugger::Cmd_PlayAudio(int argc, const char **argv) { + if (argc < 2) { + DebugPrintf("Usage: %s \n", argv[0]); + DebugPrintf("If the sound group isn't defined, the default one will be used\n"); + } else { + int index = strToInt(argv[1]); + Common::String soundGroup = (argc >= 3) ? argv[2] : ""; + if (argc >= 3) + _vm->_audio->setSoundGroup(argv[2]); + else + _vm->_audio->setDefaultSoundGroup(); + + _vm->_audio->playSound(index); + } + + return true; +} + bool Debugger::Cmd_ShowCodes(int argc, const char **argv) { Scene &scene = _vm->_game->_scene; -- cgit v1.2.3 From b7dd01fdefd910c3c0f6291145ceab4060ae1a70 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 8 May 2014 11:43:23 +0300 Subject: MADS: Remove trailing whitespace --- engines/mads/debugger.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index 80a8cb748e..3594c83d36 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -175,7 +175,7 @@ bool Debugger::Cmd_DumpFile(int argc, const char **argv) { } else { outFile.open(argv[1]); byte *data = new byte[inFile.size()]; - + inFile.read(data, inFile.size()); outFile.write(data, inFile.size()); @@ -186,7 +186,7 @@ bool Debugger::Cmd_DumpFile(int argc, const char **argv) { DebugPrintf("File written successfully.\n"); } } - + return true; } -- cgit v1.2.3 From 9fcebd296a1828831e052fbd55181363e252bbaa Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 15 May 2014 09:46:29 +0300 Subject: MADS: Some bugfixes to the debug console --- engines/mads/debugger.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index 3594c83d36..e3ddf02a5a 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -30,7 +30,7 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) { _showMousePos = false; DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); - DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_Mouse)); + DCmd_Register("mouse", WRAP_METHOD(Debugger, Cmd_Mouse)); DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_LoadScene)); DCmd_Register("show_hotspots", WRAP_METHOD(Debugger, Cmd_ShowHotSpots)); DCmd_Register("list_hotspots", WRAP_METHOD(Debugger, Cmd_ListHotSpots)); @@ -60,7 +60,7 @@ static int strToInt(const char *s) { bool Debugger::Cmd_Mouse(int argc, const char **argv) { if (argc < 2) { - DebugPrintf("Format: mouse [ on | off ]\n"); + DebugPrintf("Usage: %s [ on | off ]\n", argv[0]); } else { _showMousePos = strcmp(argv[1], "on") == 0; } @@ -178,6 +178,7 @@ bool Debugger::Cmd_DumpFile(int argc, const char **argv) { inFile.read(data, inFile.size()); outFile.write(data, inFile.size()); + outFile.flush(); delete[] data; inFile.close(); -- cgit v1.2.3 From e409f4dedd989b49184a865f59dc152e85303489 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 20 May 2014 05:43:49 +0300 Subject: MADS: Add debugger commands for the game vocab --- engines/mads/debugger.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index e3ddf02a5a..8baafddc69 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -39,6 +39,8 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) { DCmd_Register("show_codes", WRAP_METHOD(Debugger, Cmd_ShowCodes)); DCmd_Register("dump_file", WRAP_METHOD(Debugger, Cmd_DumpFile)); DCmd_Register("show_quote", WRAP_METHOD(Debugger, Cmd_ShowQuote)); + DCmd_Register("show_vocab", WRAP_METHOD(Debugger, Cmd_ShowVocab)); + DCmd_Register("dump_vocab", WRAP_METHOD(Debugger, Cmd_DumpVocab)); DCmd_Register("item", WRAP_METHOD(Debugger, Cmd_Item)); } @@ -200,6 +202,46 @@ bool Debugger::Cmd_ShowQuote(int argc, const char **argv) { return true; } +bool Debugger::Cmd_ShowVocab(int argc, const char **argv) { + if (argc != 2) { + for (uint32 i = 0; i < _vm->_game->_scene.getVocabStringsCount(); i++) { + DebugPrintf("%03d: '%s'\n", i, _vm->_game->_scene.getVocab(i + 1).c_str()); + } + } else { + int vocabId = strToInt(argv[1]); + DebugPrintf("%03d: '%s'\n", vocabId, _vm->_game->_scene.getVocab(vocabId + 1).c_str()); + } + + return true; +} + +bool Debugger::Cmd_DumpVocab(int argc, const char **argv) { + Common::DumpFile outFile; + outFile.open("vocab.txt"); + + for (uint32 i = 0; i < _vm->_game->_scene.getVocabStringsCount(); i++) { + Common::String curId = Common::String::format("%x", i + 1); + Common::String curVocab = _vm->_game->_scene.getVocab(i + 1); + curVocab.toUppercase(); + + for (uint j = 0; j < curVocab.size(); j++) { + if (curVocab[j] == ' ' || curVocab[j] == '-') + curVocab.setChar('_', j); + } + + Common::String cur = "\tNOUN_" + curVocab + " = 0x" + curId + ",\n"; + + outFile.writeString(cur.c_str()); + } + + outFile.flush(); + outFile.close(); + + DebugPrintf("Game vocab dumped\n"); + + return true; +} + bool Debugger::Cmd_Item(int argc, const char **argv) { InventoryObjects &objects = _vm->_game->_objects; -- cgit v1.2.3 From 5a87fd42f06eae1f19671ea6e32b9f5bd6b1f60d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 20 May 2014 07:31:56 +0300 Subject: MADS: Add more debugger commands for items --- engines/mads/debugger.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index 8baafddc69..0b69ee81fb 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -41,6 +41,8 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) { DCmd_Register("show_quote", WRAP_METHOD(Debugger, Cmd_ShowQuote)); DCmd_Register("show_vocab", WRAP_METHOD(Debugger, Cmd_ShowVocab)); DCmd_Register("dump_vocab", WRAP_METHOD(Debugger, Cmd_DumpVocab)); + DCmd_Register("show_item", WRAP_METHOD(Debugger, Cmd_ShowItem)); + DCmd_Register("dump_items", WRAP_METHOD(Debugger, Cmd_DumpItems)); DCmd_Register("item", WRAP_METHOD(Debugger, Cmd_Item)); } @@ -242,6 +244,52 @@ bool Debugger::Cmd_DumpVocab(int argc, const char **argv) { return true; } +bool Debugger::Cmd_ShowItem(int argc, const char **argv) { + InventoryObjects &objects = _vm->_game->_objects; + + if (argc != 2) { + for (uint32 i = 0; i < objects.size(); i++) { + Common::String desc = _vm->_game->_scene.getVocab(objects[i]._descId); + DebugPrintf("%03d: '%s'\n", i, desc.c_str()); + } + } else { + int vocabId = strToInt(argv[1]); + Common::String desc = _vm->_game->_scene.getVocab(objects[vocabId]._descId); + DebugPrintf("%03d: '%s'\n", vocabId, desc.c_str()); + } + + return true; +} + +bool Debugger::Cmd_DumpItems(int argc, const char **argv) { + InventoryObjects &objects = _vm->_game->_objects; + + Common::DumpFile outFile; + outFile.open("items.txt"); + + for (uint32 i = 0; i < objects.size(); i++) { + Common::String curId = Common::String::format("%d", i); + Common::String desc = _vm->_game->_scene.getVocab(objects[i]._descId); + desc.toUppercase(); + + for (uint j = 0; j < desc.size(); j++) { + if (desc[j] == ' ' || desc[j] == '-') + desc.setChar('_', j); + } + + Common::String cur = "\tOBJ_" + desc + " = " + curId + ",\n"; + + outFile.writeString(cur.c_str()); + } + + outFile.flush(); + outFile.close(); + + DebugPrintf("Game items dumped\n"); + + return true; +} + bool Debugger::Cmd_Item(int argc, const char **argv) { InventoryObjects &objects = _vm->_game->_objects; -- cgit v1.2.3 From eb7d018b4acc4c0d0614ed185b632c618636d727 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 20 May 2014 14:31:10 +0300 Subject: MADS: Add a debug command to show messages --- engines/mads/debugger.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index 0b69ee81fb..9f5735f318 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -41,6 +41,7 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) { DCmd_Register("show_quote", WRAP_METHOD(Debugger, Cmd_ShowQuote)); DCmd_Register("show_vocab", WRAP_METHOD(Debugger, Cmd_ShowVocab)); DCmd_Register("dump_vocab", WRAP_METHOD(Debugger, Cmd_DumpVocab)); + DCmd_Register("show_message", WRAP_METHOD(Debugger, Cmd_ShowMessage)); DCmd_Register("show_item", WRAP_METHOD(Debugger, Cmd_ShowItem)); DCmd_Register("dump_items", WRAP_METHOD(Debugger, Cmd_DumpItems)); DCmd_Register("item", WRAP_METHOD(Debugger, Cmd_Item)); @@ -244,6 +245,21 @@ bool Debugger::Cmd_DumpVocab(int argc, const char **argv) { return true; } +bool Debugger::Cmd_ShowMessage(int argc, const char **argv) { + if (argc != 2) { + DebugPrintf("Usage: %s \n", argv[0]); + } else { + int messageId = strToInt(argv[1]); + Common::StringArray msg = _vm->_game->getMessage(messageId); + for (uint idx = 0; idx < msg.size(); ++idx) { + Common::String srcLine = msg[idx]; + DebugPrintf("%s\n", srcLine.c_str()); + } + } + + return true; +} + bool Debugger::Cmd_ShowItem(int argc, const char **argv) { InventoryObjects &objects = _vm->_game->_objects; -- cgit v1.2.3 From daa8d57a866e2866369e432cf1d624179edc8875 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 May 2014 02:04:07 +0200 Subject: ALL: Rename Debugger::DebugPrintf to Debugger::debugPrintf. --- engines/mads/debugger.cpp | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index 9f5735f318..798cd004b4 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -65,7 +65,7 @@ static int strToInt(const char *s) { bool Debugger::Cmd_Mouse(int argc, const char **argv) { if (argc < 2) { - DebugPrintf("Usage: %s [ on | off ]\n", argv[0]); + debugPrintf("Usage: %s [ on | off ]\n", argv[0]); } else { _showMousePos = strcmp(argv[1], "on") == 0; } @@ -75,8 +75,8 @@ bool Debugger::Cmd_Mouse(int argc, const char **argv) { bool Debugger::Cmd_LoadScene(int argc, const char **argv) { if (argc != 2) { - DebugPrintf("Current scene is: %d\n", _vm->_game->_scene._currentSceneId); - DebugPrintf("Usage: %s \n", argv[0]); + debugPrintf("Current scene is: %d\n", _vm->_game->_scene._currentSceneId); + debugPrintf("Usage: %s \n", argv[0]); return true; } else { _vm->_game->_scene._nextSceneId = strToInt(argv[1]); @@ -106,10 +106,10 @@ bool Debugger::Cmd_ShowHotSpots(int argc, const char **argv) { bool Debugger::Cmd_ListHotSpots(int argc, const char **argv) { Hotspots &hotspots = _vm->_game->_scene._hotspots; - DebugPrintf("%d hotspots present\n", hotspots.size()); + debugPrintf("%d hotspots present\n", hotspots.size()); for (uint index = 0; index < hotspots.size(); ++index) { - DebugPrintf("(%d): %p x1 = %d; y1 = %d; x2 = %d; y2 = %d\n", + debugPrintf("(%d): %p x1 = %d; y1 = %d; x2 = %d; y2 = %d\n", index, (void *)&hotspots[index], hotspots[index]._bounds.left, hotspots[index]._bounds.top, hotspots[index]._bounds.right, hotspots[index]._bounds.bottom); @@ -120,7 +120,7 @@ bool Debugger::Cmd_ListHotSpots(int argc, const char **argv) { bool Debugger::Cmd_PlaySound(int argc, const char **argv) { if (argc < 2) { - DebugPrintf("Usage: %s \n", argv[0]); + debugPrintf("Usage: %s \n", argv[0]); } else { int commandId = strToInt(argv[1]); int param = (argc >= 3) ? strToInt(argv[2]) : 0; @@ -133,8 +133,8 @@ bool Debugger::Cmd_PlaySound(int argc, const char **argv) { bool Debugger::Cmd_PlayAudio(int argc, const char **argv) { if (argc < 2) { - DebugPrintf("Usage: %s \n", argv[0]); - DebugPrintf("If the sound group isn't defined, the default one will be used\n"); + debugPrintf("Usage: %s \n", argv[0]); + debugPrintf("If the sound group isn't defined, the default one will be used\n"); } else { int index = strToInt(argv[1]); Common::String soundGroup = (argc >= 3) ? argv[2] : ""; @@ -170,13 +170,13 @@ bool Debugger::Cmd_ShowCodes(int argc, const char **argv) { bool Debugger::Cmd_DumpFile(int argc, const char **argv) { if (argc != 2) { - DebugPrintf("Usage: %s \n", argv[0]); + debugPrintf("Usage: %s \n", argv[0]); } else { Common::DumpFile outFile; Common::File inFile; if (!inFile.open(argv[1])) { - DebugPrintf("Specified resource does not exist\n"); + debugPrintf("Specified resource does not exist\n"); } else { outFile.open(argv[1]); byte *data = new byte[inFile.size()]; @@ -189,7 +189,7 @@ bool Debugger::Cmd_DumpFile(int argc, const char **argv) { inFile.close(); outFile.close(); - DebugPrintf("File written successfully.\n"); + debugPrintf("File written successfully.\n"); } } @@ -198,9 +198,9 @@ bool Debugger::Cmd_DumpFile(int argc, const char **argv) { bool Debugger::Cmd_ShowQuote(int argc, const char **argv) { if (argc != 2) - DebugPrintf("Usage: %s \n", argv[0]); + debugPrintf("Usage: %s \n", argv[0]); else - DebugPrintf("%s", _vm->_game->getQuote(strToInt(argv[1])).c_str()); + debugPrintf("%s", _vm->_game->getQuote(strToInt(argv[1])).c_str()); return true; } @@ -208,11 +208,11 @@ bool Debugger::Cmd_ShowQuote(int argc, const char **argv) { bool Debugger::Cmd_ShowVocab(int argc, const char **argv) { if (argc != 2) { for (uint32 i = 0; i < _vm->_game->_scene.getVocabStringsCount(); i++) { - DebugPrintf("%03d: '%s'\n", i, _vm->_game->_scene.getVocab(i + 1).c_str()); + debugPrintf("%03d: '%s'\n", i, _vm->_game->_scene.getVocab(i + 1).c_str()); } } else { int vocabId = strToInt(argv[1]); - DebugPrintf("%03d: '%s'\n", vocabId, _vm->_game->_scene.getVocab(vocabId + 1).c_str()); + debugPrintf("%03d: '%s'\n", vocabId, _vm->_game->_scene.getVocab(vocabId + 1).c_str()); } return true; @@ -240,20 +240,20 @@ bool Debugger::Cmd_DumpVocab(int argc, const char **argv) { outFile.flush(); outFile.close(); - DebugPrintf("Game vocab dumped\n"); + debugPrintf("Game vocab dumped\n"); return true; } bool Debugger::Cmd_ShowMessage(int argc, const char **argv) { if (argc != 2) { - DebugPrintf("Usage: %s \n", argv[0]); + debugPrintf("Usage: %s \n", argv[0]); } else { int messageId = strToInt(argv[1]); Common::StringArray msg = _vm->_game->getMessage(messageId); for (uint idx = 0; idx < msg.size(); ++idx) { Common::String srcLine = msg[idx]; - DebugPrintf("%s\n", srcLine.c_str()); + debugPrintf("%s\n", srcLine.c_str()); } } @@ -266,12 +266,12 @@ bool Debugger::Cmd_ShowItem(int argc, const char **argv) { if (argc != 2) { for (uint32 i = 0; i < objects.size(); i++) { Common::String desc = _vm->_game->_scene.getVocab(objects[i]._descId); - DebugPrintf("%03d: '%s'\n", i, desc.c_str()); + debugPrintf("%03d: '%s'\n", i, desc.c_str()); } } else { int vocabId = strToInt(argv[1]); Common::String desc = _vm->_game->_scene.getVocab(objects[vocabId]._descId); - DebugPrintf("%03d: '%s'\n", vocabId, desc.c_str()); + debugPrintf("%03d: '%s'\n", vocabId, desc.c_str()); } return true; @@ -301,7 +301,7 @@ bool Debugger::Cmd_DumpItems(int argc, const char **argv) { outFile.flush(); outFile.close(); - DebugPrintf("Game items dumped\n"); + debugPrintf("Game items dumped\n"); return true; } @@ -310,7 +310,7 @@ bool Debugger::Cmd_Item(int argc, const char **argv) { InventoryObjects &objects = _vm->_game->_objects; if (argc != 2) { - DebugPrintf("Usage: %s \n", argv[0]); + debugPrintf("Usage: %s \n", argv[0]); return true; } else { int objectId = strToInt(argv[1]); @@ -318,7 +318,7 @@ bool Debugger::Cmd_Item(int argc, const char **argv) { if (!objects.isInInventory(objectId)) objects.addToInventory(objectId); - DebugPrintf("Item added.\n"); + debugPrintf("Item added.\n"); return false; } } -- cgit v1.2.3 From ae4ffe01f0e4354938714c546034cd0f9806bfc3 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 May 2014 02:04:08 +0200 Subject: ALL: Rename Debugger::DCmd_Register to Debugger::registerCmd. --- engines/mads/debugger.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index 798cd004b4..e82b39f8c2 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -29,22 +29,22 @@ namespace MADS { Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) { _showMousePos = false; - DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); - DCmd_Register("mouse", WRAP_METHOD(Debugger, Cmd_Mouse)); - DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_LoadScene)); - DCmd_Register("show_hotspots", WRAP_METHOD(Debugger, Cmd_ShowHotSpots)); - DCmd_Register("list_hotspots", WRAP_METHOD(Debugger, Cmd_ListHotSpots)); - DCmd_Register("play_sound", WRAP_METHOD(Debugger, Cmd_PlaySound)); - DCmd_Register("play_audio", WRAP_METHOD(Debugger, Cmd_PlayAudio)); - DCmd_Register("show_codes", WRAP_METHOD(Debugger, Cmd_ShowCodes)); - DCmd_Register("dump_file", WRAP_METHOD(Debugger, Cmd_DumpFile)); - DCmd_Register("show_quote", WRAP_METHOD(Debugger, Cmd_ShowQuote)); - DCmd_Register("show_vocab", WRAP_METHOD(Debugger, Cmd_ShowVocab)); - DCmd_Register("dump_vocab", WRAP_METHOD(Debugger, Cmd_DumpVocab)); - DCmd_Register("show_message", WRAP_METHOD(Debugger, Cmd_ShowMessage)); - DCmd_Register("show_item", WRAP_METHOD(Debugger, Cmd_ShowItem)); - DCmd_Register("dump_items", WRAP_METHOD(Debugger, Cmd_DumpItems)); - DCmd_Register("item", WRAP_METHOD(Debugger, Cmd_Item)); + registerCmd("continue", WRAP_METHOD(Debugger, Cmd_Exit)); + registerCmd("mouse", WRAP_METHOD(Debugger, Cmd_Mouse)); + registerCmd("scene", WRAP_METHOD(Debugger, Cmd_LoadScene)); + registerCmd("show_hotspots", WRAP_METHOD(Debugger, Cmd_ShowHotSpots)); + registerCmd("list_hotspots", WRAP_METHOD(Debugger, Cmd_ListHotSpots)); + registerCmd("play_sound", WRAP_METHOD(Debugger, Cmd_PlaySound)); + registerCmd("play_audio", WRAP_METHOD(Debugger, Cmd_PlayAudio)); + registerCmd("show_codes", WRAP_METHOD(Debugger, Cmd_ShowCodes)); + registerCmd("dump_file", WRAP_METHOD(Debugger, Cmd_DumpFile)); + registerCmd("show_quote", WRAP_METHOD(Debugger, Cmd_ShowQuote)); + registerCmd("show_vocab", WRAP_METHOD(Debugger, Cmd_ShowVocab)); + registerCmd("dump_vocab", WRAP_METHOD(Debugger, Cmd_DumpVocab)); + registerCmd("show_message", WRAP_METHOD(Debugger, Cmd_ShowMessage)); + registerCmd("show_item", WRAP_METHOD(Debugger, Cmd_ShowItem)); + registerCmd("dump_items", WRAP_METHOD(Debugger, Cmd_DumpItems)); + registerCmd("item", WRAP_METHOD(Debugger, Cmd_Item)); } static int strToInt(const char *s) { -- cgit v1.2.3 From 30d64edac449cde1f1c387b817ec33446ddd4698 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 May 2014 02:04:08 +0200 Subject: ALL: Make Debugger command function names conform to our guidelines. --- engines/mads/debugger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index e82b39f8c2..f301b6c392 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -29,7 +29,7 @@ namespace MADS { Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) { _showMousePos = false; - registerCmd("continue", WRAP_METHOD(Debugger, Cmd_Exit)); + registerCmd("continue", WRAP_METHOD(Debugger, cmdExit)); registerCmd("mouse", WRAP_METHOD(Debugger, Cmd_Mouse)); registerCmd("scene", WRAP_METHOD(Debugger, Cmd_LoadScene)); registerCmd("show_hotspots", WRAP_METHOD(Debugger, Cmd_ShowHotSpots)); -- cgit v1.2.3 From 2168d43d5d8c66cc4316e2bd0450ef108b27fda5 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 28 May 2014 23:25:49 +0200 Subject: MADS: Janitorial - Trim more trailing whitespace --- engines/mads/debugger.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/debugger.cpp') diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index f301b6c392..1ff42c5e2b 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -233,7 +233,7 @@ bool Debugger::Cmd_DumpVocab(int argc, const char **argv) { } Common::String cur = "\tNOUN_" + curVocab + " = 0x" + curId + ",\n"; - + outFile.writeString(cur.c_str()); } @@ -294,7 +294,7 @@ bool Debugger::Cmd_DumpItems(int argc, const char **argv) { } Common::String cur = "\tOBJ_" + desc + " = " + curId + ",\n"; - + outFile.writeString(cur.c_str()); } -- cgit v1.2.3