ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

engines/grim/debugger.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "common/config-manager.h"
00024 #include "graphics/renderer.h"
00025 
00026 #include "engines/grim/debugger.h"
00027 #include "engines/grim/md5check.h"
00028 #include "engines/grim/grim.h"
00029 
00030 namespace Grim {
00031 
00032 Debugger::Debugger() :
00033         GUI::Debugger() {
00034 
00035     registerCmd("check_gamedata", WRAP_METHOD(Debugger, cmd_checkFiles));
00036     registerCmd("lua_do", WRAP_METHOD(Debugger, cmd_lua_do));
00037     registerCmd("jump", WRAP_METHOD(Debugger, cmd_jump));
00038     registerCmd("set_renderer", WRAP_METHOD(Debugger, cmd_set_renderer));
00039     registerCmd("save", WRAP_METHOD(Debugger, cmd_save));
00040     registerCmd("load", WRAP_METHOD(Debugger, cmd_load));
00041 }
00042 
00043 Debugger::~Debugger() {
00044 
00045 }
00046 
00047 bool Debugger::cmd_checkFiles(int argc, const char **argv) {
00048     if (MD5Check::checkFiles()) {
00049         debugPrintf("All files are ok.\n");
00050     } else {
00051         debugPrintf("Some files are corrupted or missing.\n");
00052     }
00053 
00054     return true;
00055 }
00056 
00057 bool Debugger::cmd_lua_do(int argc, const char **argv) {
00058     if (argc < 2) {
00059         debugPrintf("Usage: lua_do <lua command>\n");
00060         return true;
00061     }
00062 
00063     Common::String cmd;
00064     for (int i = 1; i < argc; ++i) {
00065         cmd += argv[i];
00066         cmd += " ";
00067     }
00068     cmd.deleteLastChar();
00069     debugPrintf("Executing command: <%s>\n", cmd.c_str());
00070     cmd = Common::String::format("__temp_fn__ = function()\n%s\nend\nstart_script(__temp_fn__)", cmd.c_str());
00071     g_grim->debugLua(cmd);
00072     return true;
00073 }
00074 
00075 bool Debugger::cmd_jump(int argc, const char **argv) {
00076     if (argc < 2) {
00077         debugPrintf("Usage: jump <jump target>\n");
00078         return true;
00079     }
00080     // Escape from Monkey Island keeps the jump script in a separate file, so load it first
00081     if (g_grim->getGameType() == GType_MONKEY4) {
00082         Common::String loadJS = Common::String::format("dofile(\"_jumpscripts.lua\")\n");
00083         g_grim->debugLua(loadJS.c_str());
00084     }
00085 
00086     // Start the jump_script Lua function with the desired target
00087     Common::String cmd = Common::String::format("start_script(jump_script,\"%s\")", argv[1]);
00088     g_grim->debugLua(cmd.c_str());
00089     return true;
00090 }
00091 
00092 bool Debugger::cmd_set_renderer(int argc, const char **argv) {
00093     if (argc < 2) {
00094         debugPrintf("Usage: set_renderer <renderer>\n");
00095         debugPrintf("Where <renderer> is 'software', 'opengl' or 'opengl_shaders'\n");
00096         return true;
00097     }
00098 
00099     Graphics::RendererType renderer = Graphics::parseRendererTypeCode(argv[1]);
00100     if (renderer == Graphics::kRendererTypeDefault) {
00101         debugPrintf("Invalid renderer '%s'\n", argv[1]);
00102         return true;
00103     }
00104 
00105     ConfMan.set("renderer", Graphics::getRendererTypeCode(renderer));
00106     g_grim->changeHardwareState();
00107     return false;
00108 }
00109 
00110 bool Debugger::cmd_save(int argc, const char **argv) {
00111     if (argc < 2) {
00112         debugPrintf("Usage: save <save name>\n");
00113         return true;
00114     }
00115     Common::String file = Common::String::format("%s.gsv", argv[1]);
00116     g_grim->saveGame(file);
00117     return true;
00118 }
00119 
00120 bool Debugger::cmd_load(int argc, const char **argv) {
00121     if (argc < 2) {
00122         debugPrintf("Usage: load <save name>\n");
00123         return true;
00124     }
00125     Common::String file = Common::String::format("%s.gsv", argv[1]);
00126     g_grim->loadGame(file);
00127     return true;
00128 }
00129 
00130 }


Generated on Sat Mar 16 2019 05:01:24 for ResidualVM by doxygen 1.7.1
curved edge   curved edge