From ace0e5e88f63f34dad94962c95f57f3ec42258ae Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 14 Jun 2014 15:18:24 +0700 Subject: ZVISION: Fix compilation errors with latest scummvm --- engines/zvision/core/console.cpp | 62 ++++++++++++++++++++-------------------- engines/zvision/core/events.cpp | 12 ++++---- engines/zvision/core/menu.h | 2 +- 3 files changed, 38 insertions(+), 38 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 252a4b75ef..ef088f7553 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -22,16 +22,16 @@ #include "common/scummsys.h" -#include "zvision/console.h" +#include "zvision/core/console.h" #include "zvision/zvision.h" -#include "zvision/script_manager.h" -#include "zvision/render_manager.h" -#include "zvision/string_manager.h" -#include "zvision/zork_avi_decoder.h" -#include "zvision/zork_raw.h" -#include "zvision/utility.h" -#include "zvision/cursor.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/strings/string_manager.h" +#include "zvision/video/zork_avi_decoder.h" +#include "zvision/sound/zork_raw.h" +#include "zvision/utility/utility.h" +#include "zvision/cursors/cursor.h" #include "common/system.h" #include "common/file.h" @@ -45,18 +45,18 @@ namespace ZVision { Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { - DCmd_Register("loadimage", WRAP_METHOD(Console, cmdLoadImage)); - DCmd_Register("loadvideo", WRAP_METHOD(Console, cmdLoadVideo)); - DCmd_Register("loadsound", WRAP_METHOD(Console, cmdLoadSound)); - DCmd_Register("raw2wav", WRAP_METHOD(Console, cmdRawToWav)); - DCmd_Register("setrenderstate", WRAP_METHOD(Console, cmdSetRenderState)); - DCmd_Register("generaterendertable", WRAP_METHOD(Console, cmdGenerateRenderTable)); - DCmd_Register("setpanoramafov", WRAP_METHOD(Console, cmdSetPanoramaFoV)); - DCmd_Register("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale)); - DCmd_Register("changelocation", WRAP_METHOD(Console, cmdChangeLocation)); - DCmd_Register("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); - DCmd_Register("parseallscrfiles", WRAP_METHOD(Console, cmdParseAllScrFiles)); - DCmd_Register("rendertext", WRAP_METHOD(Console, cmdRenderText)); + registerCmd("loadimage", WRAP_METHOD(Console, cmdLoadImage)); + registerCmd("loadvideo", WRAP_METHOD(Console, cmdLoadVideo)); + registerCmd("loadsound", WRAP_METHOD(Console, cmdLoadSound)); + registerCmd("raw2wav", WRAP_METHOD(Console, cmdRawToWav)); + registerCmd("setrenderstate", WRAP_METHOD(Console, cmdSetRenderState)); + registerCmd("generaterendertable", WRAP_METHOD(Console, cmdGenerateRenderTable)); + registerCmd("setpanoramafov", WRAP_METHOD(Console, cmdSetPanoramaFoV)); + registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale)); + registerCmd("changelocation", WRAP_METHOD(Console, cmdChangeLocation)); + registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); + registerCmd("parseallscrfiles", WRAP_METHOD(Console, cmdParseAllScrFiles)); + registerCmd("rendertext", WRAP_METHOD(Console, cmdRenderText)); } bool Console::cmdLoadImage(int argc, const char **argv) { @@ -72,7 +72,7 @@ bool Console::cmdLoadImage(int argc, const char **argv) { bool Console::cmdLoadVideo(int argc, const char **argv) { if (argc != 2) { - DebugPrintf("Use loadvideo to load a video to the screen\n"); + debugPrintf("Use loadvideo to load a video to the screen\n"); return true; } @@ -86,7 +86,7 @@ bool Console::cmdLoadVideo(int argc, const char **argv) { bool Console::cmdLoadSound(int argc, const char **argv) { if (!Common::File::exists(argv[1])) { - DebugPrintf("File does not exist\n"); + debugPrintf("File does not exist\n"); return true; } @@ -105,7 +105,7 @@ bool Console::cmdLoadSound(int argc, const char **argv) { Audio::SoundHandle handle; _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false); } else { - DebugPrintf("Use loadsound [ ] to load a sound\n"); + debugPrintf("Use loadsound [ ] to load a sound\n"); return true; } @@ -114,7 +114,7 @@ bool Console::cmdLoadSound(int argc, const char **argv) { bool Console::cmdRawToWav(int argc, const char **argv) { if (argc != 3) { - DebugPrintf("Use raw2wav to dump a .RAW file to .WAV\n"); + debugPrintf("Use raw2wav to dump a .RAW file to .WAV\n"); return true; } @@ -124,7 +124,7 @@ bool Console::cmdRawToWav(int argc, const char **argv) { bool Console::cmdSetRenderState(int argc, const char **argv) { if (argc != 2) { - DebugPrintf("Use setrenderstate to change the current render state\n"); + debugPrintf("Use setrenderstate to change the current render state\n"); return true; } @@ -137,7 +137,7 @@ bool Console::cmdSetRenderState(int argc, const char **argv) { else if (renderState.matchString("flat", true)) _engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT); else - DebugPrintf("Use setrenderstate to change the current render state\n"); + debugPrintf("Use setrenderstate to change the current render state\n"); return true; } @@ -150,7 +150,7 @@ bool Console::cmdGenerateRenderTable(int argc, const char **argv) { bool Console::cmdSetPanoramaFoV(int argc, const char **argv) { if (argc != 2) { - DebugPrintf("Use setpanoramafov to change the current panorama field of view\n"); + debugPrintf("Use setpanoramafov to change the current panorama field of view\n"); return true; } @@ -161,7 +161,7 @@ bool Console::cmdSetPanoramaFoV(int argc, const char **argv) { bool Console::cmdSetPanoramaScale(int argc, const char **argv) { if (argc != 2) { - DebugPrintf("Use setpanoramascale to change the current panorama scale\n"); + debugPrintf("Use setpanoramascale to change the current panorama scale\n"); return true; } @@ -172,7 +172,7 @@ bool Console::cmdSetPanoramaScale(int argc, const char **argv) { bool Console::cmdChangeLocation(int argc, const char **argv) { if (argc != 6) { - DebugPrintf("Use changelocation to change your location\n"); + debugPrintf("Use changelocation to change your location\n"); return true; } @@ -183,7 +183,7 @@ bool Console::cmdChangeLocation(int argc, const char **argv) { bool Console::cmdDumpFile(int argc, const char **argv) { if (argc != 2) { - DebugPrintf("Use dumpfile to dump a file\n"); + debugPrintf("Use dumpfile to dump a file\n"); return true; } @@ -204,7 +204,7 @@ bool Console::cmdParseAllScrFiles(int argc, const char **argv) { bool Console::cmdRenderText(int argc, const char **argv) { if (argc != 7) { - DebugPrintf("Use rendertext <1 or 0: wrap> to render text\n"); + debugPrintf("Use rendertext <1 or 0: wrap> to render text\n"); return true; } diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 189bf007c1..943f8ff279 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -24,12 +24,12 @@ #include "zvision/zvision.h" -#include "zvision/console.h" -#include "zvision/cursor_manager.h" -#include "zvision/render_manager.h" -#include "zvision/script_manager.h" -#include "zvision/rlf_animation.h" -#include "zvision/menu.h" +#include "zvision/core/console.h" +#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/animation/rlf_animation.h" +#include "zvision/core/menu.h" #include "common/events.h" #include "common/system.h" diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h index 7be03f62ef..cc802ee5f5 100644 --- a/engines/zvision/core/menu.h +++ b/engines/zvision/core/menu.h @@ -27,7 +27,7 @@ #include "common/rect.h" #include "zvision/zvision.h" -#include "zvision/script_manager.h" +#include "zvision/scripting/script_manager.h" namespace ZVision { -- cgit v1.2.3 From 23c1b508611d5fa4e7dfc47f8f5ec10a7de177e3 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 2 Jul 2014 19:50:55 +0000 Subject: ZVISION: Reorgonize source files into directories. --- engines/zvision/core/console.cpp | 2 +- engines/zvision/core/menu.cpp | 765 ++++++++++++++++++++++++++++++++ engines/zvision/core/search_manager.cpp | 274 ++++++++++++ engines/zvision/core/search_manager.h | 51 +++ 4 files changed, 1091 insertions(+), 1 deletion(-) create mode 100644 engines/zvision/core/menu.cpp create mode 100644 engines/zvision/core/search_manager.cpp create mode 100644 engines/zvision/core/search_manager.h (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index ef088f7553..aac4e7b2bc 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -27,7 +27,7 @@ #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" -#include "zvision/strings/string_manager.h" +#include "zvision/text/string_manager.h" #include "zvision/video/zork_avi_decoder.h" #include "zvision/sound/zork_raw.h" #include "zvision/utility/utility.h" diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp new file mode 100644 index 0000000000..bf311c4577 --- /dev/null +++ b/engines/zvision/core/menu.cpp @@ -0,0 +1,765 @@ +/* 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 "common/scummsys.h" + +#include "zvision/core/menu.h" + +#include "zvision/graphics/render_manager.h" + + +namespace ZVision { + +enum { + SLOT_START_SLOT = 151, + SLOT_SPELL_1 = 191, + SLOT_USER_CHOSE_THIS_SPELL = 205, + SLOT_REVERSED_SPELLBOOK = 206 +}; + +enum { + menu_MAIN_SAVE = 0, + menu_MAIN_REST = 1, + menu_MAIN_PREF = 2, + menu_MAIN_EXIT = 3 +}; + +menuHandler::menuHandler(ZVision *engine) { + _engine = engine; + menu_bar_flag = 0xFFFF; +} + +menuZgi::menuZgi(ZVision *engine) : + menuHandler(engine) { + menu_mousefocus = -1; + inmenu = false; + scrolled[0] = false; + scrolled[1] = false; + scrolled[2] = false; + scrollPos[0] = 0.0; + scrollPos[1] = 0.0; + scrollPos[2] = 0.0; + mouse_on_item = -1; + + char buf[24]; + for (int i = 1; i < 4; i++) { + sprintf(buf, "gmzau%2.2x1.tga", i); + _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][0], false); + sprintf(buf, "gmzau%2.2x1.tga", i + 0x10); + _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][1], false); + } + for (int i = 0; i < 4; i++) { + sprintf(buf, "gmzmu%2.2x1.tga", i); + _engine->getRenderManager()->readImageToSurface(buf, menubar[i][0], false); + sprintf(buf, "gmznu%2.2x1.tga", i); + _engine->getRenderManager()->readImageToSurface(buf, menubar[i][1], false); + } + + for (int i = 0; i < 50; i++) { + items[i][0] = NULL; + items[i][1] = NULL; + item_id[i] = 0; + } + + for (int i = 0; i < 12; i++) { + magic[i][0] = NULL; + magic[i][1] = NULL; + magic_id[i] = 0; + } +} + +menuZgi::~menuZgi() { + for (int i = 0; i < 3; i++) { + menuback[i][0].free(); + menuback[i][1].free(); + } + for (int i = 0; i < 4; i++) { + menubar[i][0].free(); + menubar[i][1].free(); + } + for (int i = 0; i < 50; i++) { + if (items[i][0]) { + items[i][0]->free(); + delete items[i][0]; + } + if (items[i][1]) { + items[i][1]->free(); + delete items[i][1]; + } + } + for (int i = 0; i < 12; i++) { + if (magic[i][0]) { + magic[i][0]->free(); + delete magic[i][0]; + } + if (magic[i][1]) { + magic[i][1]->free(); + delete magic[i][1]; + } + } +} + +void menuZgi::onMouseUp(const Common::Point &Pos) { + if (Pos.y < 40) { + switch (menu_mousefocus) { + case menu_ITEM: + if (menu_bar_flag & menuBar_Items) { + int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (item_count == 0) + item_count = 20; + + for (int i = 0; i < item_count; i++) { + int itemspace = (600 - 28) / item_count; + + if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, + scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { + int32 mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); + if (mouse_item >= 0 && mouse_item < 0xE0) { + _engine->getScriptManager()->invertory_drop(mouse_item); + _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i)); + _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouse_item); + + redraw = true; + } + } + } + } + break; + + case menu_MAGIC: + if (menu_bar_flag & menuBar_Magic) { + for (int i = 0; i < 12; i++) { + + uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); + if (itemnum != 0) { + if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) + itemnum = 0xEE + i; + else + itemnum = 0xE0 + i; + } + if (itemnum) + if (_engine->getScriptManager()->getStateValue(StateKey_InventoryItem) == 0 || _engine->getScriptManager()->getStateValue(StateKey_InventoryItem) >= 0xE0) + if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, + 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) + _engine->getScriptManager()->setStateValue(SLOT_USER_CHOSE_THIS_SPELL, itemnum); + } + + } + break; + + case menu_MAIN: + + // Exit + if (menu_bar_flag & menuBar_Exit) + if (Common::Rect(320 + 135, + scrollPos[menu_MAIN], + 320 + 135 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + // ifquit(); + } + + // Settings + if (menu_bar_flag & menuBar_Settings) + if (Common::Rect(320 , + scrollPos[menu_MAIN], + 320 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); + } + + // Load + if (menu_bar_flag & menuBar_Restore) + if (Common::Rect(320 - 135, + scrollPos[menu_MAIN], + 320, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); + } + + // Save + if (menu_bar_flag & menuBar_Save) + if (Common::Rect(320 - 135 * 2, + scrollPos[menu_MAIN], + 320 - 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); + } + break; + } + } +} + +void menuZgi::onMouseMove(const Common::Point &Pos) { + if (Pos.y < 40) { + + if (!inmenu) + redraw = true; + inmenu = true; + switch (menu_mousefocus) { + case menu_ITEM: + if (menu_bar_flag & menuBar_Items) { + int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (item_count == 0) + item_count = 20; + else if (item_count > 50) + item_count = 50; + + int last_item = mouse_on_item; + + mouse_on_item = -1; + + for (int i = 0; i < item_count; i++) { + int itemspace = (600 - 28) / item_count; + + if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, + scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { + mouse_on_item = i; + break; + } + } + + if (last_item != mouse_on_item) + if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouse_on_item) || + _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + last_item)) + redraw = true; + } + break; + + case menu_MAGIC: + if (menu_bar_flag & menuBar_Magic) { + int last_item = mouse_on_item; + mouse_on_item = -1; + for (int i = 0; i < 12; i++) { + if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, + 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) { + mouse_on_item = i; + break; + } + } + + if (last_item != mouse_on_item) + if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouse_on_item) || + _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + last_item)) + redraw = true; + + } + break; + + case menu_MAIN: { + int last_item = mouse_on_item; + mouse_on_item = -1; + + // Exit + if (menu_bar_flag & menuBar_Exit) + if (Common::Rect(320 + 135, + scrollPos[menu_MAIN], + 320 + 135 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_EXIT; + } + + // Settings + if (menu_bar_flag & menuBar_Settings) + if (Common::Rect(320 , + scrollPos[menu_MAIN], + 320 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_PREF; + } + + // Load + if (menu_bar_flag & menuBar_Restore) + if (Common::Rect(320 - 135, + scrollPos[menu_MAIN], + 320, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_REST; + } + + // Save + if (menu_bar_flag & menuBar_Save) + if (Common::Rect(320 - 135 * 2, + scrollPos[menu_MAIN], + 320 - 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_SAVE; + } + + if (last_item != mouse_on_item) + redraw = true; + } + break; + + default: + int cur_menu = menu_mousefocus; + if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main + menu_mousefocus = menu_MAIN; + scrolled[menu_MAIN] = false; + scrollPos[menu_MAIN] = menuback[menu_MAIN][1].h - menuback[menu_MAIN][0].h; + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); + } + + if (menu_bar_flag & menuBar_Magic) + if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic + menu_mousefocus = menu_MAGIC; + scrolled[menu_MAGIC] = false; + scrollPos[menu_MAGIC] = 28; + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 3); + } + + if (menu_bar_flag & menuBar_Items) + if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items + menu_mousefocus = menu_ITEM; + scrolled[menu_ITEM] = false; + scrollPos[menu_ITEM] = 28 - 600; + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 1); + } + + if (cur_menu != menu_mousefocus) + clean = true; + + break; + } + } else { + if (inmenu) + clean = true; + inmenu = false; + if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); + menu_mousefocus = -1; + } +} + +void menuZgi::process(uint32 deltatime) { + if (clean) { + _engine->getRenderManager()->clearMenuSurface(); + clean = false; + } + switch (menu_mousefocus) { + case menu_ITEM: + if (menu_bar_flag & menuBar_Items) + if (!scrolled[menu_ITEM]) { + redraw = true; + float scrl = 600.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos [menu_ITEM] += scrl; + + if (scrollPos[menu_ITEM] >= 0) { + scrolled[menu_ITEM] = true; + scrollPos [menu_ITEM] = 0; + } + } + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0); + + int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (item_count == 0) + item_count = 20; + else if (item_count > 50) + item_count = 50; + + + for (int i = 0; i < item_count; i++) { + int itemspace = (600 - 28) / item_count; + + bool inrect = false; + + if (mouse_on_item == i) + inrect = true; + + uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i); + + if (cur_item_id != 0) { + if (item_id[i] != cur_item_id) { + char buf[16]; + sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id); + items[i][0] = _engine->getRenderManager()->loadImage(buf, false); + sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id); + items[i][1] = _engine->getRenderManager()->loadImage(buf, false); + item_id[i] = cur_item_id; + } + + if (inrect) + _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[menu_ITEM] + itemspace * i, 0, 0); + else + _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[menu_ITEM] + itemspace * i, 0, 0); + + } else { + if (items[i][0]) { + items[i][0]->free(); + delete items[i][0]; + items[i][0] = NULL; + } + if (items[i][1]) { + items[i][1]->free(); + delete items[i][1]; + items[i][1] = NULL; + } + item_id[i] = 0; + } + } + + redraw = false; + } + break; + + case menu_MAGIC: + if (menu_bar_flag & menuBar_Magic) + if (!scrolled[menu_MAGIC]) { + redraw = true; + float scrl = 600.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos [menu_MAGIC] += scrl; + + if (scrollPos[menu_MAGIC] >= 600) { + scrolled[menu_MAGIC] = true; + scrollPos [menu_MAGIC] = 600; + } + } + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][0], 640 - scrollPos[menu_MAGIC], 0); + + for (int i = 0; i < 12; i++) { + bool inrect = false; + + if (mouse_on_item == i) + inrect = true; + + uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); + if (cur_item_id) { + if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) + cur_item_id = 0xEE + i; + else + cur_item_id = 0xE0 + i; + } + + if (cur_item_id != 0) { + if (item_id[i] != cur_item_id) { + char buf[16]; + sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id); + magic[i][0] = _engine->getRenderManager()->loadImage(buf, false); + sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id); + magic[i][1] = _engine->getRenderManager()->loadImage(buf, false); + magic_id[i] = cur_item_id; + } + + if (inrect) + _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); + else + _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); + + } else { + if (magic[i][0]) { + magic[i][0]->free(); + delete magic[i][0]; + magic[i][0] = NULL; + } + if (magic[i][1]) { + magic[i][1]->free(); + delete magic[i][1]; + magic[i][1] = NULL; + } + magic_id[i] = 0; + } + } + redraw = false; + } + break; + + case menu_MAIN: + if (!scrolled[menu_MAIN]) { + redraw = true; + float scrl = 32.0 * 2.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos [menu_MAIN] += scrl; + + if (scrollPos[menu_MAIN] >= 0) { + scrolled[menu_MAIN] = true; + scrollPos [menu_MAIN] = 0; + } + } + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]); + + if (menu_bar_flag & menuBar_Exit) { + if (mouse_on_item == menu_MAIN_EXIT) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]); + } + if (menu_bar_flag & menuBar_Settings) { + if (mouse_on_item == menu_MAIN_PREF) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]); + } + if (menu_bar_flag & menuBar_Restore) { + if (mouse_on_item == menu_MAIN_REST) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]); + } + if (menu_bar_flag & menuBar_Save) { + if (mouse_on_item == menu_MAIN_SAVE) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]); + } + redraw = false; + } + break; + default: + if (redraw) { + if (inmenu) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0); + + if (menu_bar_flag & menuBar_Items) + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0); + + if (menu_bar_flag & menuBar_Magic) + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0); + } + redraw = false; + } + break; + } +} + + +menuNem::menuNem(ZVision *engine) : + menuHandler(engine) { + inmenu = false; + scrolled = false; + scrollPos = 0.0; + mouse_on_item = -1; + + char buf[24]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 6; j++) { + sprintf(buf, "butfrm%d%d.tga", i + 1, j); + _engine->getRenderManager()->readImageToSurface(buf, but[i][j], false); + } + + _engine->getRenderManager()->readImageToSurface("bar.tga", menubar, false); + + frm = 0; +} + +menuNem::~menuNem() { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 6; j++) + but[i][j].free(); + + menubar.free(); +} + +static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} }; + +void menuNem::onMouseUp(const Common::Point &Pos) { + if (Pos.y < 40) { + // Exit + if (menu_bar_flag & menuBar_Exit) + if (Common::Rect(buts[3][1], + scrollPos, + buts[3][0] + buts[3][1], + scrollPos + 32).contains(Pos)) { + // ifquit(); + frm = 5; + redraw = true; + } + + // Settings + if (menu_bar_flag & menuBar_Settings) + if (Common::Rect(buts[2][1], + scrollPos, + buts[2][0] + buts[2][1], + scrollPos + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); + frm = 5; + redraw = true; + } + + // Load + if (menu_bar_flag & menuBar_Restore) + if (Common::Rect(buts[1][1], + scrollPos, + buts[1][0] + buts[1][1], + scrollPos + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); + frm = 5; + redraw = true; + } + + // Save + if (menu_bar_flag & menuBar_Save) + if (Common::Rect(buts[0][1], + scrollPos, + buts[0][0] + buts[0][1], + scrollPos + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); + frm = 5; + redraw = true; + } + } +} + +void menuNem::onMouseMove(const Common::Point &Pos) { + if (Pos.y < 40) { + + inmenu = true; + + if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2) + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); + + int last_item = mouse_on_item; + mouse_on_item = -1; + + // Exit + if (menu_bar_flag & menuBar_Exit) + if (Common::Rect(buts[3][1], + scrollPos, + buts[3][0] + buts[3][1], + scrollPos + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_EXIT; + } + + // Settings + if (menu_bar_flag & menuBar_Settings) + if (Common::Rect(buts[2][1], + scrollPos, + buts[2][0] + buts[2][1], + scrollPos + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_PREF; + } + + // Load + if (menu_bar_flag & menuBar_Restore) + if (Common::Rect(buts[1][1], + scrollPos, + buts[1][0] + buts[1][1], + scrollPos + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_REST; + } + + // Save + if (menu_bar_flag & menuBar_Save) + if (Common::Rect(buts[0][1], + scrollPos, + buts[0][0] + buts[0][1], + scrollPos + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_SAVE; + } + + if (last_item != mouse_on_item) { + redraw = true; + frm = 0; + delay = 200; + } + } else { + inmenu = false; + if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); + mouse_on_item = -1; + } +} + +void menuNem::process(uint32 deltatime) { + if (inmenu) { + if (!scrolled) { + float scrl = 32.0 * 2.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos += scrl; + redraw = true; + } + + if (scrollPos >= 0) { + scrolled = true; + scrollPos = 0; + } + + if (mouse_on_item != -1) { + delay -= deltatime; + if (delay <= 0 && frm < 4) { + delay = 200; + frm++; + redraw = true; + } + } + + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); + + if (menu_bar_flag & menuBar_Exit) + if (mouse_on_item == menu_MAIN_EXIT) + _engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos); + + if (menu_bar_flag & menuBar_Settings) + if (mouse_on_item == menu_MAIN_PREF) + _engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos); + + if (menu_bar_flag & menuBar_Restore) + if (mouse_on_item == menu_MAIN_REST) + _engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos); + + if (menu_bar_flag & menuBar_Save) + if (mouse_on_item == menu_MAIN_SAVE) + _engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos); + + redraw = false; + } + } else { + scrolled = false; + if (scrollPos > -32) { + float scrl = 32.0 * 2.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + Common::Rect cl(64, 32 + scrollPos - scrl, 64 + 512, 32 + scrollPos + 1); + _engine->getRenderManager()->clearMenuSurface(cl); + + scrollPos -= scrl; + redraw = true; + } else + scrollPos = -32; + + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); + redraw = false; + } + } +} + + +} // End of namespace ZVision diff --git a/engines/zvision/core/search_manager.cpp b/engines/zvision/core/search_manager.cpp new file mode 100644 index 0000000000..fe99772b9b --- /dev/null +++ b/engines/zvision/core/search_manager.cpp @@ -0,0 +1,274 @@ +/* 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 "common/debug.h" + +#include "zvision/core/search_manager.h" +#include "zvision/archives/zfs_archive.h" +#include "common/fs.h" +#include "common/stream.h" + + +namespace ZVision { + +sManager::sManager(const Common::String &root_path, int depth) { + _root = root_path; + if (_root[_root.size() - 1] == '\\' || _root[_root.size() - 1] == '/') + _root.deleteLastChar(); + + Common::FSNode fs_node(_root); + + list_dir_recursive(dir_list, fs_node, depth); + + for (Common::List::iterator it = dir_list.begin(); it != dir_list.end();) + if (it->size() == _root.size()) + it = dir_list.erase(it); + else if (it->size() > _root.size()) { + *it = Common::String(it->c_str() + _root.size() + 1); + it++; + } else + it++; +} + +sManager::~sManager() { + Common::List::iterator it = archList.begin(); + while (it != archList.end()) { + delete *it; + it++; + } + + archList.clear(); +} + +void sManager::addPatch(const Common::String &src, const Common::String &dst) { + Common::String lw_name = dst; + lw_name.toLowercase(); + + sManager::MatchList::iterator it = files.find(lw_name); + + if (it != files.end()) { + lw_name = src; + lw_name.toLowercase(); + files[lw_name] = it->_value; + } +} + +void sManager::addFile(const Common::String &name, Common::Archive *arch) { + bool addArch = true; + Common::List::iterator it = archList.begin(); + while (it != archList.end()) { + if (*it == arch) { + addArch = false; + break; + } + it++; + } + if (addArch) + archList.push_back(arch); + + Common::String lw_name = name; + lw_name.toLowercase(); + + sManager::Node nod; + nod.name = lw_name; + nod.arch = arch; + + sManager::MatchList::iterator fit = files.find(lw_name); + + if (fit == files.end()) { + files[lw_name] = nod; + } else { + Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name); + if (stream) { + if (stream->size() < 10) + fit->_value.arch = arch; + delete stream; + } else { + files[lw_name] = nod; + } + } +} + +Common::File *sManager::openFile(const Common::String &name) { + Common::String lw_name = name; + lw_name.toLowercase(); + + sManager::MatchList::iterator fit = files.find(lw_name); + + if (fit != files.end()) { + Common::File *tmp = new Common::File(); + tmp->open(fit->_value.name, *fit->_value.arch); + return tmp; + } + return NULL; +} + +bool sManager::openFile(Common::File &file, const Common::String &name) { + Common::String lw_name = name; + lw_name.toLowercase(); + + sManager::MatchList::iterator fit = files.find(lw_name); + + if (fit != files.end()) + return file.open(fit->_value.name, *fit->_value.arch); + return false; +} + +bool sManager::hasFile(const Common::String &name) { + Common::String lw_name = name; + lw_name.toLowercase(); + + sManager::MatchList::iterator fit = files.find(lw_name); + + if (fit != files.end()) + return true; + return false; +} + +void sManager::loadZix(const Common::String &name) { + Common::File file; + file.open(name); + + Common::String line; + + while (!file.eos()) { + line = file.readLine(); + if (line.matchString("----------*", true)) + break; + } + + if (file.eos()) + return; + + Common::Array archives; + + while (!file.eos()) { + line = file.readLine(); + line.trim(); + if (line.matchString("----------*", true)) + break; + else if (line.matchString("DIR:*", true)) { + Common::String path(line.c_str() + 5); + Common::Archive *arc; + char n_path[128]; + strcpy(n_path, path.c_str()); + for (uint i = 0; i < path.size(); i++) + if (n_path[i] == '\\') + n_path[i] = '/'; + + path = Common::String(n_path); + if (path.size() && path[0] == '.') + path.deleteChar(0); + if (path.size() && path[0] == '/') + path.deleteChar(0); + + if (path.matchString("*.zfs", true)) + arc = new ZfsArchive(path); + else { + if (path.size()) { + if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/') + path.deleteLastChar(); + if (path.size()) + for (Common::List::iterator it = dir_list.begin(); it != dir_list.end(); ++it) + if (path.equalsIgnoreCase(*it)) { + path = *it; + break; + } + } + + path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); + + arc = new Common::FSDirectory(path); + } + archives.push_back(arc); + } + } + + if (file.eos()) + return; + + while (!file.eos()) { + line = file.readLine(); + line.trim(); + uint dr = 0; + char buf[32]; + if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) { + if (dr <= archives.size() && dr > 0) { + addFile(Common::String(buf), archives[dr - 1]); + } + } + } +} + +void sManager::addDir(const Common::String &name) { + Common::String path; + for (Common::List::iterator it = dir_list.begin(); it != dir_list.end(); ++it) + if (name.equalsIgnoreCase(*it)) { + path = *it; + break; + } + + if (path.size() == 0) + return; + + path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); + + Common::FSDirectory *dir = new Common::FSDirectory(path); + + Common::ArchiveMemberList list; + dir->listMatchingMembers(list, "*.zfs"); + + + for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { + Common::String flname = (*iter)->getName(); + + ZfsArchive *zfs = new ZfsArchive(Common::String::format("%s/%s", name.c_str(), flname.c_str())); + + Common::ArchiveMemberList zfslist; + zfs->listMembers(zfslist); + + for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) { + Common::String z_name = (*ziter)->getName(); + addFile(z_name, zfs); + } + } + + list.clear(); + dir->listMembers(list); + + for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { + Common::String flname = (*iter)->getName(); + addFile(flname, dir); + } +} + +void sManager::list_dir_recursive(Common::List &_list, const Common::FSNode &fs_node, int depth) { + Common::FSList fs_list; + fs_node.getChildren(fs_list); + + _list.push_back(fs_node.getPath()); + + if (depth > 1) + for (Common::FSList::const_iterator it = fs_list.begin(); it != fs_list.end(); ++it) + list_dir_recursive(_list, *it, depth - 1); +} + +} // End of namespace ZVision diff --git a/engines/zvision/core/search_manager.h b/engines/zvision/core/search_manager.h new file mode 100644 index 0000000000..c768cb8b00 --- /dev/null +++ b/engines/zvision/core/search_manager.h @@ -0,0 +1,51 @@ +#ifndef SEARCH_MANAGER_H_INCLUDED +#define SEARCH_MANAGER_H_INCLUDED + +#include "common/str.h" +#include "common/hash-str.h" +#include "common/hashmap.h" +#include "common/archive.h" +#include "common/file.h" +#include "common/list.h" + +namespace ZVision { + +class sManager { +public: + sManager(const Common::String &root_path, int depth); + ~sManager(); + + void addFile(const Common::String &name, Common::Archive *arch); + void addDir(const Common::String &name); + void addPatch(const Common::String &src, const Common::String &dst); + + Common::File *openFile(const Common::String &name); + bool openFile(Common::File &file, const Common::String &name); + bool hasFile(const Common::String &name); + + void loadZix(const Common::String &name); + +private: + + void list_dir_recursive(Common::List &dir_list, const Common::FSNode &fs_node, int depth); + + struct Node { + Common::String name; + Common::Archive *arch; + }; + + Common::List dir_list; + + typedef Common::HashMap MatchList; + + Common::List archList; + MatchList files; + + Common::String _root; + +private: +}; + +} + +#endif // SEARCH_MANAGER_H_INCLUDED -- cgit v1.2.3 From bbaebdf680179dca103b0ed635e791aa602d610d Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 5 Jul 2014 17:27:08 +0000 Subject: ZVISION: Process events for controls similar to original engine, fix some errors. --- engines/zvision/core/events.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 943f8ff279..c977125f55 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -46,13 +46,15 @@ void ZVision::processEvents() { case Common::EVENT_LBUTTONDOWN: _cursorManager->cursorDown(true); _scriptManager->setStateValue(StateKey_LMouse, 1); - onMouseDown(_event.mouse); + _menu->onMouseDown(_event.mouse); + _scriptManager->addEvent(_event); break; case Common::EVENT_LBUTTONUP: _cursorManager->cursorDown(false); _scriptManager->setStateValue(StateKey_LMouse, 0); - onMouseUp(_event.mouse); + _menu->onMouseUp(_event.mouse); + _scriptManager->addEvent(_event); break; case Common::EVENT_RBUTTONDOWN: @@ -87,10 +89,10 @@ void ZVision::processEvents() { break; } - _scriptManager->onKeyDown(_event.kbd); + _scriptManager->addEvent(_event); break; case Common::EVENT_KEYUP: - _scriptManager->onKeyUp(_event.kbd); + _scriptManager->addEvent(_event); break; default: break; @@ -98,20 +100,6 @@ void ZVision::processEvents() { } } -void ZVision::onMouseDown(const Common::Point &pos) { - _menu->onMouseDown(pos); - - Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); - _scriptManager->onMouseDown(pos, imageCoord); -} - -void ZVision::onMouseUp(const Common::Point &pos) { - _menu->onMouseUp(pos); - - Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); - _scriptManager->onMouseUp(pos, imageCoord); -} - void ZVision::onMouseMove(const Common::Point &pos) { _menu->onMouseMove(pos); Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); -- cgit v1.2.3 From 5a5a32c84a67ce4c8466b069b6bb1c844d014577 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 4 Aug 2014 16:39:14 +0700 Subject: ZVISION: New SaveManager methods for pre-buffering save data --- engines/zvision/core/save_manager.cpp | 23 +++++++++++++++++++++++ engines/zvision/core/save_manager.h | 9 ++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 8ec4f4d628..6e8b6b5ff3 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -67,6 +67,13 @@ void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::Me delete file; } +void SaveManager::saveGameBuffered(uint slot, const Common::String &saveName) { + if (_tempSave) { + saveGame(slot, saveName, _tempSave); + flushSaveBuffer(); + } +} + void SaveManager::autoSave() { Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName()); @@ -231,4 +238,20 @@ Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) { return saveFile; } +void SaveManager::prepareSaveBuffer() { + if (_tempSave) + delete _tempSave; + + _tempSave = new Common::MemoryWriteStreamDynamic; + + _engine->getScriptManager()->serialize(_tempSave); +} + +void SaveManager::flushSaveBuffer() { + if (_tempSave) + delete _tempSave; + + _tempSave = NULL; +} + } // End of namespace ZVision diff --git a/engines/zvision/core/save_manager.h b/engines/zvision/core/save_manager.h index 8ed64a3fdc..c7c1297062 100644 --- a/engines/zvision/core/save_manager.h +++ b/engines/zvision/core/save_manager.h @@ -48,7 +48,8 @@ struct SaveGameHeader { class SaveManager { public: - SaveManager(ZVision *engine) : _engine(engine) {} + SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL) {} + ~SaveManager() { flushSaveBuffer(); } private: ZVision *_engine; @@ -59,6 +60,8 @@ private: SAVE_VERSION = 1 }; + Common::MemoryWriteStreamDynamic *_tempSave; + public: /** * Called every room change. Saves the state of the room just before @@ -76,6 +79,7 @@ public: */ void saveGame(uint slot, const Common::String &saveName); void saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream); + void saveGameBuffered(uint slot, const Common::String &saveName); /** * Loads the state data from the save file that slot references. Uses * ZVision::generateSaveFileName(slot) to get the save file name. @@ -87,6 +91,9 @@ public: Common::SeekableReadStream *getSlotFile(uint slot); bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header); + + void prepareSaveBuffer(); + void flushSaveBuffer(); private: void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName); }; -- cgit v1.2.3 From 4bc319441069101a902ed22f48bec40b7e6c9284 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 22 Oct 2014 11:44:49 +0700 Subject: ZVISION: Implement simple midi support --- engines/zvision/core/midi.cpp | 89 +++++++++++++++++++++++++++++++++++++++++++ engines/zvision/core/midi.h | 59 ++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 engines/zvision/core/midi.cpp create mode 100644 engines/zvision/core/midi.h (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/midi.cpp b/engines/zvision/core/midi.cpp new file mode 100644 index 0000000000..5cc8cd0402 --- /dev/null +++ b/engines/zvision/core/midi.cpp @@ -0,0 +1,89 @@ +/* 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 "common/scummsys.h" + +#include "zvision/core/midi.h" + +namespace ZVision { + +midiManager::midiManager() { + MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB); + _driver = MidiDriver::createMidi(dev); + _driver->open(); +} + +midiManager::~midiManager() { + stop(); + _driver->close(); + delete _driver; +} + +void midiManager::stop() { + for (int8 i = 0; i < 16; i++) + if (_playChannels[i].playing) + noteOff(i); +} + +void midiManager::noteOn(int8 channel, int8 note, int8 velocity) { + assert(channel <= 15); + + _playChannels[channel].playing = true; + _playChannels[channel].note = note; + _driver->send(channel | (velocity << 16) | (note << 8) | 0x90); +} + +void midiManager::noteOff(int8 channel) { + assert(channel <= 15); + + if (_playChannels[channel].playing) { + _playChannels[channel].playing = false; + _driver->send(channel | (_playChannels[channel].note << 8) | 0x80); + } +} + +int8 midiManager::getFreeChannel() { + for (int8 i = 0; i < 16; i++) + if (!_playChannels[i].playing) + return i; + return -1; +} + +void midiManager::setPan(int8 channel, int8 pan) { + assert(channel <= 15); + + _driver->send(channel | (pan << 16) | 0xAB0); +} + +void midiManager::setVolume(int8 channel, int8 volume) { + assert(channel <= 15); + + _driver->send(channel | (volume << 16) | 0x7B0); +} + +void midiManager::setProgram(int8 channel, int8 prog) { + assert(channel <= 15); + + _driver->send(channel | (prog << 8) | 0xC0); +} + +} // End of namespace ZVision diff --git a/engines/zvision/core/midi.h b/engines/zvision/core/midi.h new file mode 100644 index 0000000000..79f8ea3d04 --- /dev/null +++ b/engines/zvision/core/midi.h @@ -0,0 +1,59 @@ +/* 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. + * + */ + +#ifndef ZVISION_MIDI_H +#define ZVISION_MIDI_H + +#include "audio/mididrv.h" + +namespace ZVision { + +class midiManager { +public: + midiManager(); + ~midiManager(); + + void stop(); + void noteOn(int8 channel, int8 noteNumber, int8 velocity); + void noteOff(int8 channel); + void setPan(int8 channel, int8 pan); + void setVolume(int8 channel, int8 volume); + void setProgram(int8 channel, int8 prog); + + int8 getFreeChannel(); + +protected: + + struct chan { + bool playing; + int8 note; + + chan() : playing(false), note(0) {}; + }; + + MidiDriver *_driver; + chan _playChannels[16]; +}; + +} + +#endif -- cgit v1.2.3 From 44eeb4027250a2989a9e34a303383fa8533a7a84 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 8 Nov 2014 13:02:48 +0600 Subject: ZVISION: Implement action:menu_bar_enable --- engines/zvision/core/menu.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h index cc802ee5f5..7e6acf325c 100644 --- a/engines/zvision/core/menu.h +++ b/engines/zvision/core/menu.h @@ -48,6 +48,10 @@ public: virtual void onMouseDown(const Common::Point &Pos) {}; virtual void onMouseUp(const Common::Point &Pos) {}; virtual void process(uint32 deltaTimeInMillis) {}; + + void setEnable(uint16 flags) { + menu_bar_flag = flags; + } protected: uint16 menu_bar_flag; ZVision *_engine; -- cgit v1.2.3 From 42bc6c5daf132b3656f04759aa1fa615fe7b26f6 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:37:57 +0600 Subject: ZVISION: Fix incorrect usage of Common::String::format --- engines/zvision/core/save_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 6e8b6b5ff3..2797b940a0 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -219,9 +219,9 @@ Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) { // Try to load standart save file Common::String filename; if (_engine->getGameId() == GID_GRANDINQUISITOR) - filename.format("inqsav%u.sav", slot); + filename = Common::String::format("inqsav%u.sav", slot); else if (_engine->getGameId() == GID_NEMESIS) - filename.format("nemsav%u.sav", slot); + filename = Common::String::format("nemsav%u.sav", slot); saveFile = _engine->getSearchManager()->openFile(filename); if (saveFile == NULL) { -- cgit v1.2.3 From f55f4af2937f77c3dc9760b000d2e4806477c1a0 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:38:29 +0600 Subject: ZVISION: Fix code style in save_manager.h --- engines/zvision/core/save_manager.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/save_manager.h b/engines/zvision/core/save_manager.h index c7c1297062..5cd61c7aa9 100644 --- a/engines/zvision/core/save_manager.h +++ b/engines/zvision/core/save_manager.h @@ -49,7 +49,9 @@ struct SaveGameHeader { class SaveManager { public: SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL) {} - ~SaveManager() { flushSaveBuffer(); } + ~SaveManager() { + flushSaveBuffer(); + } private: ZVision *_engine; -- cgit v1.2.3 From fcbb3d0307d8423399a41cef8f8cbaec062018db Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:48:32 +0600 Subject: ZVISION: Use ifQuit for menu bars --- engines/zvision/core/menu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp index bf311c4577..57a1983784 100644 --- a/engines/zvision/core/menu.cpp +++ b/engines/zvision/core/menu.cpp @@ -174,7 +174,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) { scrollPos[menu_MAIN], 320 + 135 + 135, scrollPos[menu_MAIN] + 32).contains(Pos)) { - // ifquit(); + _engine->ifQuit(); } // Settings @@ -591,7 +591,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) { scrollPos, buts[3][0] + buts[3][1], scrollPos + 32).contains(Pos)) { - // ifquit(); + _engine->ifQuit(); frm = 5; redraw = true; } -- cgit v1.2.3 From f658a5c8e6a92341efc7ec15ec0f875b1cc7eb93 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 15:34:55 +0600 Subject: ZVISION: Implement methods for get state of menu items --- engines/zvision/core/menu.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h index 7e6acf325c..c2ea822dd9 100644 --- a/engines/zvision/core/menu.h +++ b/engines/zvision/core/menu.h @@ -52,6 +52,9 @@ public: void setEnable(uint16 flags) { menu_bar_flag = flags; } + uint16 getEnable() { + return menu_bar_flag; + } protected: uint16 menu_bar_flag; ZVision *_engine; -- cgit v1.2.3 From 8e112edb1a7d8d1d579a235bda18b58ffcc18b8c Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 15:47:27 +0600 Subject: ZVISION: Implement Easter eggs and debug cheats --- engines/zvision/core/events.cpp | 92 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index c977125f55..97565dd4d7 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -30,6 +30,8 @@ #include "zvision/scripting/script_manager.h" #include "zvision/animation/rlf_animation.h" #include "zvision/core/menu.h" +#include "zvision/utility/win_keys.h" +#include "zvision/sound/zork_raw.h" #include "common/events.h" #include "common/system.h" @@ -40,6 +42,86 @@ namespace ZVision { +void ZVision::cheatCodes(uint8 key) { + pushKeyToCheatBuf(key); + + if (getGameId() == GID_GRANDINQUISITOR) { + + if (checkCode("IMNOTDEAF")) { + // Unknow cheat + showDebugMsg(Common::String::format("IMNOTDEAF cheat or debug, not implemented")); + } + + if (checkCode("3100OPB")) { + showDebugMsg(Common::String::format("Current location: %c%c%c%c", + _scriptManager->getStateValue(StateKey_World), + _scriptManager->getStateValue(StateKey_Room), + _scriptManager->getStateValue(StateKey_Node), + _scriptManager->getStateValue(StateKey_View))); + } + + if (checkCode("KILLMENOW")) { + _scriptManager->changeLocation('g', 'j', 'd', 'e', 0); + _scriptManager->setStateValue(2201, 35); + } + + if (checkCode("MIKESPANTS")) { + _scriptManager->changeLocation('g', 'j', 't', 'm', 0); + } + } else if (getGameId() == GID_NEMESIS) { + + if (checkCode("CHLOE")) { + _scriptManager->changeLocation('t', 'm', '2', 'g', 0); + _scriptManager->setStateValue(224, 1); + } + + if (checkCode("77MASSAVE")) { + showDebugMsg(Common::String::format("Current location: %c%c%c%c", + _scriptManager->getStateValue(StateKey_World), + _scriptManager->getStateValue(StateKey_Room), + _scriptManager->getStateValue(StateKey_Node), + _scriptManager->getStateValue(StateKey_View))); + } + + if (checkCode("IDKFA")) { + _scriptManager->changeLocation('t', 'w', '3', 'f', 0); + _scriptManager->setStateValue(249, 1); + } + + if (checkCode("309NEWDORMA")) { + _scriptManager->changeLocation('g', 'j', 'g', 'j', 0); + } + + if (checkCode("HELLOSAILOR")) { + Location loc = _scriptManager->getCurrentLocation(); + Audio::AudioStream *soundStream; + if (loc.world == 'v' && loc.room == 'b' && loc.node == '1' && loc.view == '0') { + soundStream = makeRawZorkStream("v000hpta.raw", this); + } else { + soundStream = makeRawZorkStream("v000hnta.raw", this); + } + Audio::SoundHandle handle; + _mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream); + } + } + + if (checkCode("FRAME")) + showDebugMsg(Common::String::format("FPS: ???, not implemented")); + + if (checkCode("XYZZY")) + _scriptManager->setStateValue(StateKey_DebugCheats, 1 - _scriptManager->getStateValue(StateKey_DebugCheats)); + + if (checkCode("COMPUTERARCH")) + showDebugMsg(Common::String::format("COMPUTERARCH: var-viewer not implemented")); + + if (_scriptManager->getStateValue(StateKey_DebugCheats) == 1) + if (checkCode("GO????")) + _scriptManager->changeLocation(getBufferedKey(3), + getBufferedKey(2), + getBufferedKey(1), + getBufferedKey(0), 0); +} + void ZVision::processEvents() { while (_eventMan->pollEvent(_event)) { switch (_event.type) { @@ -72,7 +154,7 @@ void ZVision::processEvents() { onMouseMove(_event.mouse); break; - case Common::EVENT_KEYDOWN: + case Common::EVENT_KEYDOWN: { switch (_event.kbd.keycode) { case Common::KEYCODE_d: if (_event.kbd.hasFlags(Common::KBD_CTRL)) { @@ -89,8 +171,14 @@ void ZVision::processEvents() { break; } + uint8 vkKey = VKkey(_event.kbd.keycode); + + _scriptManager->setStateValue(StateKey_KeyPress, vkKey); + _scriptManager->addEvent(_event); - break; + cheatCodes(vkKey); + } + break; case Common::EVENT_KEYUP: _scriptManager->addEvent(_event); break; -- cgit v1.2.3 From c4911135c152b9f7eb082dee1af79d82932e72c0 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 15:50:18 +0600 Subject: ZVISION: Implement keyboard hotkeys --- engines/zvision/core/events.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 97565dd4d7..72e3fa6d34 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -31,6 +31,7 @@ #include "zvision/animation/rlf_animation.h" #include "zvision/core/menu.h" #include "zvision/utility/win_keys.h" +#include "zvision/core/menu.h" #include "zvision/sound/zork_raw.h" #include "common/events.h" @@ -42,6 +43,31 @@ namespace ZVision { +void ZVision::shortKeys(Common::Event event) { + if (event.kbd.hasFlags(Common::KBD_CTRL)) { + switch (event.kbd.keycode) { + case Common::KEYCODE_s: + if (getMenuBarEnable() & menuBar_Save) + _scriptManager->changeLocation('g', 'j', 's', 'e', 0); + break; + case Common::KEYCODE_r: + if (getMenuBarEnable() & menuBar_Restore) + _scriptManager->changeLocation('g', 'j', 'r', 'e', 0); + break; + case Common::KEYCODE_p: + if (getMenuBarEnable() & menuBar_Settings) + _scriptManager->changeLocation('g', 'j', 'p', 'e', 0); + break; + case Common::KEYCODE_q: + if (getMenuBarEnable() & menuBar_Exit) + ifQuit(); + break; + default: + break; + } + } +} + void ZVision::cheatCodes(uint8 key) { pushKeyToCheatBuf(key); @@ -176,6 +202,7 @@ void ZVision::processEvents() { _scriptManager->setStateValue(StateKey_KeyPress, vkKey); _scriptManager->addEvent(_event); + shortKeys(_event); cheatCodes(vkKey); } break; -- cgit v1.2.3 From 1f0bf5ecf2f3eb1c65019d196f7327a0874f93bb Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 15:55:10 +0600 Subject: ZVISION: Implement code for pan from keyboard and mouse --- engines/zvision/core/events.cpp | 46 ++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 72e3fa6d34..38ceb5ceb4 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -189,10 +189,26 @@ void ZVision::processEvents() { _console->onFrame(); } break; + + case Common::KEYCODE_LEFT: + case Common::KEYCODE_RIGHT: + if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA) + _kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ? + -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : + _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; case Common::KEYCODE_q: if (_event.kbd.hasFlags(Common::KBD_CTRL)) quitGame(); break; + + case Common::KEYCODE_UP: + case Common::KEYCODE_DOWN: + if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT) + _kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_UP ? + -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : + _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; + break; + default: break; } @@ -208,6 +224,20 @@ void ZVision::processEvents() { break; case Common::EVENT_KEYUP: _scriptManager->addEvent(_event); + switch (_event.kbd.keycode) { + case Common::KEYCODE_LEFT: + case Common::KEYCODE_RIGHT: + if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA) + _kbdVelocity = 0; + break; + case Common::KEYCODE_UP: + case Common::KEYCODE_DOWN: + if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT) + _kbdVelocity = 0; + break; + default: + break; + } break; default: break; @@ -261,7 +291,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _velocity = (((pos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((pos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; @@ -270,12 +300,12 @@ void ZVision::onMouseMove(const Common::Point &pos) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _velocity = (((pos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((pos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; } else { - _velocity = 0; + _mouseVelocity = 0; } } else if (renderState == RenderTable::TILT) { if (pos.y >= _workingWindow.top && pos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) { @@ -283,7 +313,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _velocity = (((pos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((pos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; @@ -292,18 +322,18 @@ void ZVision::onMouseMove(const Common::Point &pos) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _velocity = (((pos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((pos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; } else { - _velocity = 0; + _mouseVelocity = 0; } } else { - _velocity = 0; + _mouseVelocity = 0; } } else { - _velocity = 0; + _mouseVelocity = 0; } if (!cursorWasChanged) { -- cgit v1.2.3 From 2d7af4bab7e8c298373307d77d4a3e98cab1b575 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 16:00:02 +0600 Subject: ZVISION: Add call of inventory cycling for Nemesis --- engines/zvision/core/events.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 38ceb5ceb4..5f8f8e243f 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -168,7 +168,9 @@ void ZVision::processEvents() { case Common::EVENT_RBUTTONDOWN: _cursorManager->cursorDown(true); _scriptManager->setStateValue(StateKey_RMouse, 1); - // TODO: Inventory logic + + if (getGameId() == GID_NEMESIS) + _scriptManager->invertory_cycle(); break; case Common::EVENT_RBUTTONUP: -- cgit v1.2.3 From f43326a533faec014fb1987f9ba3729127c46487 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 16:06:31 +0600 Subject: ZVISION: Clean of useless code --- engines/zvision/core/events.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 5f8f8e243f..0d38e08b88 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -198,9 +198,6 @@ void ZVision::processEvents() { _kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ? -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; - case Common::KEYCODE_q: - if (_event.kbd.hasFlags(Common::KBD_CTRL)) - quitGame(); break; case Common::KEYCODE_UP: -- cgit v1.2.3 From 5b352da304931bafcfcddbe08461488335c7ad57 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 20 Nov 2014 14:48:24 +0600 Subject: ZVISION: More CamelCase and a bit of comments cleanup --- engines/zvision/core/events.cpp | 2 +- engines/zvision/core/menu.cpp | 282 ++++++++++++++++---------------- engines/zvision/core/menu.h | 34 ++-- engines/zvision/core/midi.cpp | 18 +- engines/zvision/core/midi.h | 6 +- engines/zvision/core/save_manager.cpp | 3 +- engines/zvision/core/search_manager.cpp | 103 ++++++------ engines/zvision/core/search_manager.h | 38 ++++- 8 files changed, 255 insertions(+), 231 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 0d38e08b88..873cdb0df7 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -170,7 +170,7 @@ void ZVision::processEvents() { _scriptManager->setStateValue(StateKey_RMouse, 1); if (getGameId() == GID_NEMESIS) - _scriptManager->invertory_cycle(); + _scriptManager->inventoryCycle(); break; case Common::EVENT_RBUTTONUP: diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp index 57a1983784..5816b3f364 100644 --- a/engines/zvision/core/menu.cpp +++ b/engines/zvision/core/menu.cpp @@ -43,14 +43,14 @@ enum { menu_MAIN_EXIT = 3 }; -menuHandler::menuHandler(ZVision *engine) { +MenuHandler::MenuHandler(ZVision *engine) { _engine = engine; - menu_bar_flag = 0xFFFF; + menuBarFlag = 0xFFFF; } -menuZgi::menuZgi(ZVision *engine) : - menuHandler(engine) { - menu_mousefocus = -1; +MenuZGI::MenuZGI(ZVision *engine) : + MenuHandler(engine) { + menuMouseFocus = -1; inmenu = false; scrolled[0] = false; scrolled[1] = false; @@ -58,7 +58,7 @@ menuZgi::menuZgi(ZVision *engine) : scrollPos[0] = 0.0; scrollPos[1] = 0.0; scrollPos[2] = 0.0; - mouse_on_item = -1; + mouseOnItem = -1; char buf[24]; for (int i = 1; i < 4; i++) { @@ -77,17 +77,17 @@ menuZgi::menuZgi(ZVision *engine) : for (int i = 0; i < 50; i++) { items[i][0] = NULL; items[i][1] = NULL; - item_id[i] = 0; + itemId[i] = 0; } for (int i = 0; i < 12; i++) { magic[i][0] = NULL; magic[i][1] = NULL; - magic_id[i] = 0; + magicId[i] = 0; } } -menuZgi::~menuZgi() { +MenuZGI::~MenuZGI() { for (int i = 0; i < 3; i++) { menuback[i][0].free(); menuback[i][1].free(); @@ -118,25 +118,25 @@ menuZgi::~menuZgi() { } } -void menuZgi::onMouseUp(const Common::Point &Pos) { +void MenuZGI::onMouseUp(const Common::Point &Pos) { if (Pos.y < 40) { - switch (menu_mousefocus) { + switch (menuMouseFocus) { case menu_ITEM: - if (menu_bar_flag & menuBar_Items) { - int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (item_count == 0) - item_count = 20; + if (menuBarFlag & menuBar_Items) { + int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (itemCount == 0) + itemCount = 20; - for (int i = 0; i < item_count; i++) { - int itemspace = (600 - 28) / item_count; + for (int i = 0; i < itemCount; i++) { + int itemspace = (600 - 28) / itemCount; if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { - int32 mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); - if (mouse_item >= 0 && mouse_item < 0xE0) { - _engine->getScriptManager()->invertory_drop(mouse_item); - _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i)); - _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouse_item); + int32 mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); + if (mouseItem >= 0 && mouseItem < 0xE0) { + _engine->getScriptManager()->inventoryDrop(mouseItem); + _engine->getScriptManager()->inventoryAdd(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i)); + _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouseItem); redraw = true; } @@ -146,7 +146,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) { break; case menu_MAGIC: - if (menu_bar_flag & menuBar_Magic) { + if (menuBarFlag & menuBar_Magic) { for (int i = 0; i < 12; i++) { uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); @@ -169,7 +169,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) { case menu_MAIN: // Exit - if (menu_bar_flag & menuBar_Exit) + if (menuBarFlag & menuBar_Exit) if (Common::Rect(320 + 135, scrollPos[menu_MAIN], 320 + 135 + 135, @@ -178,7 +178,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) { } // Settings - if (menu_bar_flag & menuBar_Settings) + if (menuBarFlag & menuBar_Settings) if (Common::Rect(320 , scrollPos[menu_MAIN], 320 + 135, @@ -187,7 +187,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) { } // Load - if (menu_bar_flag & menuBar_Restore) + if (menuBarFlag & menuBar_Restore) if (Common::Rect(320 - 135, scrollPos[menu_MAIN], 320, @@ -196,7 +196,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) { } // Save - if (menu_bar_flag & menuBar_Save) + if (menuBarFlag & menuBar_Save) if (Common::Rect(320 - 135 * 2, scrollPos[menu_MAIN], 320 - 135, @@ -208,133 +208,133 @@ void menuZgi::onMouseUp(const Common::Point &Pos) { } } -void menuZgi::onMouseMove(const Common::Point &Pos) { +void MenuZGI::onMouseMove(const Common::Point &Pos) { if (Pos.y < 40) { if (!inmenu) redraw = true; inmenu = true; - switch (menu_mousefocus) { + switch (menuMouseFocus) { case menu_ITEM: - if (menu_bar_flag & menuBar_Items) { - int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (item_count == 0) - item_count = 20; - else if (item_count > 50) - item_count = 50; + if (menuBarFlag & menuBar_Items) { + int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (itemCount == 0) + itemCount = 20; + else if (itemCount > 50) + itemCount = 50; - int last_item = mouse_on_item; + int lastItem = mouseOnItem; - mouse_on_item = -1; + mouseOnItem = -1; - for (int i = 0; i < item_count; i++) { - int itemspace = (600 - 28) / item_count; + for (int i = 0; i < itemCount; i++) { + int itemspace = (600 - 28) / itemCount; if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { - mouse_on_item = i; + mouseOnItem = i; break; } } - if (last_item != mouse_on_item) - if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouse_on_item) || - _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + last_item)) + if (lastItem != mouseOnItem) + if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouseOnItem) || + _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + lastItem)) redraw = true; } break; case menu_MAGIC: - if (menu_bar_flag & menuBar_Magic) { - int last_item = mouse_on_item; - mouse_on_item = -1; + if (menuBarFlag & menuBar_Magic) { + int lastItem = mouseOnItem; + mouseOnItem = -1; for (int i = 0; i < 12; i++) { if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) { - mouse_on_item = i; + mouseOnItem = i; break; } } - if (last_item != mouse_on_item) - if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouse_on_item) || - _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + last_item)) + if (lastItem != mouseOnItem) + if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouseOnItem) || + _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + lastItem)) redraw = true; } break; case menu_MAIN: { - int last_item = mouse_on_item; - mouse_on_item = -1; + int lastItem = mouseOnItem; + mouseOnItem = -1; // Exit - if (menu_bar_flag & menuBar_Exit) + if (menuBarFlag & menuBar_Exit) if (Common::Rect(320 + 135, scrollPos[menu_MAIN], 320 + 135 + 135, scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_EXIT; + mouseOnItem = menu_MAIN_EXIT; } // Settings - if (menu_bar_flag & menuBar_Settings) + if (menuBarFlag & menuBar_Settings) if (Common::Rect(320 , scrollPos[menu_MAIN], 320 + 135, scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_PREF; + mouseOnItem = menu_MAIN_PREF; } // Load - if (menu_bar_flag & menuBar_Restore) + if (menuBarFlag & menuBar_Restore) if (Common::Rect(320 - 135, scrollPos[menu_MAIN], 320, scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_REST; + mouseOnItem = menu_MAIN_REST; } // Save - if (menu_bar_flag & menuBar_Save) + if (menuBarFlag & menuBar_Save) if (Common::Rect(320 - 135 * 2, scrollPos[menu_MAIN], 320 - 135, scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_SAVE; + mouseOnItem = menu_MAIN_SAVE; } - if (last_item != mouse_on_item) + if (lastItem != mouseOnItem) redraw = true; } break; default: - int cur_menu = menu_mousefocus; + int cur_menu = menuMouseFocus; if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main - menu_mousefocus = menu_MAIN; + menuMouseFocus = menu_MAIN; scrolled[menu_MAIN] = false; scrollPos[menu_MAIN] = menuback[menu_MAIN][1].h - menuback[menu_MAIN][0].h; _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); } - if (menu_bar_flag & menuBar_Magic) + if (menuBarFlag & menuBar_Magic) if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic - menu_mousefocus = menu_MAGIC; + menuMouseFocus = menu_MAGIC; scrolled[menu_MAGIC] = false; scrollPos[menu_MAGIC] = 28; _engine->getScriptManager()->setStateValue(StateKey_MenuState, 3); } - if (menu_bar_flag & menuBar_Items) + if (menuBarFlag & menuBar_Items) if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items - menu_mousefocus = menu_ITEM; + menuMouseFocus = menu_ITEM; scrolled[menu_ITEM] = false; scrollPos[menu_ITEM] = 28 - 600; _engine->getScriptManager()->setStateValue(StateKey_MenuState, 1); } - if (cur_menu != menu_mousefocus) + if (cur_menu != menuMouseFocus) clean = true; break; @@ -345,18 +345,18 @@ void menuZgi::onMouseMove(const Common::Point &Pos) { inmenu = false; if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); - menu_mousefocus = -1; + menuMouseFocus = -1; } } -void menuZgi::process(uint32 deltatime) { +void MenuZGI::process(uint32 deltatime) { if (clean) { _engine->getRenderManager()->clearMenuSurface(); clean = false; } - switch (menu_mousefocus) { + switch (menuMouseFocus) { case menu_ITEM: - if (menu_bar_flag & menuBar_Items) + if (menuBarFlag & menuBar_Items) if (!scrolled[menu_ITEM]) { redraw = true; float scrl = 600.0 * (deltatime / 1000.0); @@ -374,31 +374,31 @@ void menuZgi::process(uint32 deltatime) { if (redraw) { _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0); - int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (item_count == 0) - item_count = 20; - else if (item_count > 50) - item_count = 50; + int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (itemCount == 0) + itemCount = 20; + else if (itemCount > 50) + itemCount = 50; - for (int i = 0; i < item_count; i++) { - int itemspace = (600 - 28) / item_count; + for (int i = 0; i < itemCount; i++) { + int itemspace = (600 - 28) / itemCount; bool inrect = false; - if (mouse_on_item == i) + if (mouseOnItem == i) inrect = true; - uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i); + uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i); - if (cur_item_id != 0) { - if (item_id[i] != cur_item_id) { + if (curItemId != 0) { + if (itemId[i] != curItemId) { char buf[16]; - sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id); + sprintf(buf, "gmzwu%2.2x1.tga", curItemId); items[i][0] = _engine->getRenderManager()->loadImage(buf, false); - sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id); + sprintf(buf, "gmzxu%2.2x1.tga", curItemId); items[i][1] = _engine->getRenderManager()->loadImage(buf, false); - item_id[i] = cur_item_id; + itemId[i] = curItemId; } if (inrect) @@ -417,7 +417,7 @@ void menuZgi::process(uint32 deltatime) { delete items[i][1]; items[i][1] = NULL; } - item_id[i] = 0; + itemId[i] = 0; } } @@ -426,7 +426,7 @@ void menuZgi::process(uint32 deltatime) { break; case menu_MAGIC: - if (menu_bar_flag & menuBar_Magic) + if (menuBarFlag & menuBar_Magic) if (!scrolled[menu_MAGIC]) { redraw = true; float scrl = 600.0 * (deltatime / 1000.0); @@ -447,25 +447,25 @@ void menuZgi::process(uint32 deltatime) { for (int i = 0; i < 12; i++) { bool inrect = false; - if (mouse_on_item == i) + if (mouseOnItem == i) inrect = true; - uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); - if (cur_item_id) { + uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); + if (curItemId) { if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) - cur_item_id = 0xEE + i; + curItemId = 0xEE + i; else - cur_item_id = 0xE0 + i; + curItemId = 0xE0 + i; } - if (cur_item_id != 0) { - if (item_id[i] != cur_item_id) { + if (curItemId != 0) { + if (itemId[i] != curItemId) { char buf[16]; - sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id); + sprintf(buf, "gmzwu%2.2x1.tga", curItemId); magic[i][0] = _engine->getRenderManager()->loadImage(buf, false); - sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id); + sprintf(buf, "gmzxu%2.2x1.tga", curItemId); magic[i][1] = _engine->getRenderManager()->loadImage(buf, false); - magic_id[i] = cur_item_id; + magicId[i] = curItemId; } if (inrect) @@ -484,7 +484,7 @@ void menuZgi::process(uint32 deltatime) { delete magic[i][1]; magic[i][1] = NULL; } - magic_id[i] = 0; + magicId[i] = 0; } } redraw = false; @@ -509,26 +509,26 @@ void menuZgi::process(uint32 deltatime) { if (redraw) { _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]); - if (menu_bar_flag & menuBar_Exit) { - if (mouse_on_item == menu_MAIN_EXIT) + if (menuBarFlag & menuBar_Exit) { + if (mouseOnItem == menu_MAIN_EXIT) _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]); else _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]); } - if (menu_bar_flag & menuBar_Settings) { - if (mouse_on_item == menu_MAIN_PREF) + if (menuBarFlag & menuBar_Settings) { + if (mouseOnItem == menu_MAIN_PREF) _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]); else _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]); } - if (menu_bar_flag & menuBar_Restore) { - if (mouse_on_item == menu_MAIN_REST) + if (menuBarFlag & menuBar_Restore) { + if (mouseOnItem == menu_MAIN_REST) _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]); else _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]); } - if (menu_bar_flag & menuBar_Save) { - if (mouse_on_item == menu_MAIN_SAVE) + if (menuBarFlag & menuBar_Save) { + if (mouseOnItem == menu_MAIN_SAVE) _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]); else _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]); @@ -541,10 +541,10 @@ void menuZgi::process(uint32 deltatime) { if (inmenu) { _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0); - if (menu_bar_flag & menuBar_Items) + if (menuBarFlag & menuBar_Items) _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0); - if (menu_bar_flag & menuBar_Magic) + if (menuBarFlag & menuBar_Magic) _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0); } redraw = false; @@ -554,12 +554,12 @@ void menuZgi::process(uint32 deltatime) { } -menuNem::menuNem(ZVision *engine) : - menuHandler(engine) { +MenuNemesis::MenuNemesis(ZVision *engine) : + MenuHandler(engine) { inmenu = false; scrolled = false; scrollPos = 0.0; - mouse_on_item = -1; + mouseOnItem = -1; char buf[24]; for (int i = 0; i < 4; i++) @@ -573,7 +573,7 @@ menuNem::menuNem(ZVision *engine) : frm = 0; } -menuNem::~menuNem() { +MenuNemesis::~MenuNemesis() { for (int i = 0; i < 4; i++) for (int j = 0; j < 6; j++) but[i][j].free(); @@ -583,10 +583,10 @@ menuNem::~menuNem() { static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} }; -void menuNem::onMouseUp(const Common::Point &Pos) { +void MenuNemesis::onMouseUp(const Common::Point &Pos) { if (Pos.y < 40) { // Exit - if (menu_bar_flag & menuBar_Exit) + if (menuBarFlag & menuBar_Exit) if (Common::Rect(buts[3][1], scrollPos, buts[3][0] + buts[3][1], @@ -597,7 +597,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) { } // Settings - if (menu_bar_flag & menuBar_Settings) + if (menuBarFlag & menuBar_Settings) if (Common::Rect(buts[2][1], scrollPos, buts[2][0] + buts[2][1], @@ -608,7 +608,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) { } // Load - if (menu_bar_flag & menuBar_Restore) + if (menuBarFlag & menuBar_Restore) if (Common::Rect(buts[1][1], scrollPos, buts[1][0] + buts[1][1], @@ -619,7 +619,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) { } // Save - if (menu_bar_flag & menuBar_Save) + if (menuBarFlag & menuBar_Save) if (Common::Rect(buts[0][1], scrollPos, buts[0][0] + buts[0][1], @@ -631,7 +631,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) { } } -void menuNem::onMouseMove(const Common::Point &Pos) { +void MenuNemesis::onMouseMove(const Common::Point &Pos) { if (Pos.y < 40) { inmenu = true; @@ -639,46 +639,46 @@ void menuNem::onMouseMove(const Common::Point &Pos) { if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2) _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); - int last_item = mouse_on_item; - mouse_on_item = -1; + int lastItem = mouseOnItem; + mouseOnItem = -1; // Exit - if (menu_bar_flag & menuBar_Exit) + if (menuBarFlag & menuBar_Exit) if (Common::Rect(buts[3][1], scrollPos, buts[3][0] + buts[3][1], scrollPos + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_EXIT; + mouseOnItem = menu_MAIN_EXIT; } // Settings - if (menu_bar_flag & menuBar_Settings) + if (menuBarFlag & menuBar_Settings) if (Common::Rect(buts[2][1], scrollPos, buts[2][0] + buts[2][1], scrollPos + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_PREF; + mouseOnItem = menu_MAIN_PREF; } // Load - if (menu_bar_flag & menuBar_Restore) + if (menuBarFlag & menuBar_Restore) if (Common::Rect(buts[1][1], scrollPos, buts[1][0] + buts[1][1], scrollPos + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_REST; + mouseOnItem = menu_MAIN_REST; } // Save - if (menu_bar_flag & menuBar_Save) + if (menuBarFlag & menuBar_Save) if (Common::Rect(buts[0][1], scrollPos, buts[0][0] + buts[0][1], scrollPos + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_SAVE; + mouseOnItem = menu_MAIN_SAVE; } - if (last_item != mouse_on_item) { + if (lastItem != mouseOnItem) { redraw = true; frm = 0; delay = 200; @@ -687,11 +687,11 @@ void menuNem::onMouseMove(const Common::Point &Pos) { inmenu = false; if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); - mouse_on_item = -1; + mouseOnItem = -1; } } -void menuNem::process(uint32 deltatime) { +void MenuNemesis::process(uint32 deltatime) { if (inmenu) { if (!scrolled) { float scrl = 32.0 * 2.0 * (deltatime / 1000.0); @@ -708,7 +708,7 @@ void menuNem::process(uint32 deltatime) { scrollPos = 0; } - if (mouse_on_item != -1) { + if (mouseOnItem != -1) { delay -= deltatime; if (delay <= 0 && frm < 4) { delay = 200; @@ -720,20 +720,20 @@ void menuNem::process(uint32 deltatime) { if (redraw) { _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); - if (menu_bar_flag & menuBar_Exit) - if (mouse_on_item == menu_MAIN_EXIT) + if (menuBarFlag & menuBar_Exit) + if (mouseOnItem == menu_MAIN_EXIT) _engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos); - if (menu_bar_flag & menuBar_Settings) - if (mouse_on_item == menu_MAIN_PREF) + if (menuBarFlag & menuBar_Settings) + if (mouseOnItem == menu_MAIN_PREF) _engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos); - if (menu_bar_flag & menuBar_Restore) - if (mouse_on_item == menu_MAIN_REST) + if (menuBarFlag & menuBar_Restore) + if (mouseOnItem == menu_MAIN_REST) _engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos); - if (menu_bar_flag & menuBar_Save) - if (mouse_on_item == menu_MAIN_SAVE) + if (menuBarFlag & menuBar_Save) + if (mouseOnItem == menu_MAIN_SAVE) _engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos); redraw = false; diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h index c2ea822dd9..62683de912 100644 --- a/engines/zvision/core/menu.h +++ b/engines/zvision/core/menu.h @@ -40,30 +40,30 @@ enum menuBar { menuBar_Magic = 0x200 }; -class menuHandler { +class MenuHandler { public: - menuHandler(ZVision *engine); - virtual ~menuHandler() {}; + MenuHandler(ZVision *engine); + virtual ~MenuHandler() {}; virtual void onMouseMove(const Common::Point &Pos) {}; virtual void onMouseDown(const Common::Point &Pos) {}; virtual void onMouseUp(const Common::Point &Pos) {}; virtual void process(uint32 deltaTimeInMillis) {}; void setEnable(uint16 flags) { - menu_bar_flag = flags; + menuBarFlag = flags; } uint16 getEnable() { - return menu_bar_flag; + return menuBarFlag; } protected: - uint16 menu_bar_flag; + uint16 menuBarFlag; ZVision *_engine; }; -class menuZgi: public menuHandler { +class MenuZGI: public MenuHandler { public: - menuZgi(ZVision *engine); - ~menuZgi(); + MenuZGI(ZVision *engine); + ~MenuZGI(); void onMouseMove(const Common::Point &Pos); void onMouseUp(const Common::Point &Pos); void process(uint32 deltaTimeInMillis); @@ -73,15 +73,15 @@ private: Graphics::Surface *items[50][2]; - uint item_id[50]; + uint itemId[50]; Graphics::Surface *magic[12][2]; - uint magic_id[12]; + uint magicId[12]; - int menu_mousefocus; + int menuMouseFocus; bool inmenu; - int mouse_on_item; + int mouseOnItem; bool scrolled[3]; float scrollPos[3]; @@ -97,10 +97,10 @@ private: }; -class menuNem: public menuHandler { +class MenuNemesis: public MenuHandler { public: - menuNem(ZVision *engine); - ~menuNem(); + MenuNemesis(ZVision *engine); + ~MenuNemesis(); void onMouseMove(const Common::Point &Pos); void onMouseUp(const Common::Point &Pos); void process(uint32 deltaTimeInMillis); @@ -110,7 +110,7 @@ private: bool inmenu; - int mouse_on_item; + int mouseOnItem; bool scrolled; float scrollPos; diff --git a/engines/zvision/core/midi.cpp b/engines/zvision/core/midi.cpp index 5cc8cd0402..736be1311d 100644 --- a/engines/zvision/core/midi.cpp +++ b/engines/zvision/core/midi.cpp @@ -26,25 +26,25 @@ namespace ZVision { -midiManager::midiManager() { +MidiManager::MidiManager() { MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB); _driver = MidiDriver::createMidi(dev); _driver->open(); } -midiManager::~midiManager() { +MidiManager::~MidiManager() { stop(); _driver->close(); delete _driver; } -void midiManager::stop() { +void MidiManager::stop() { for (int8 i = 0; i < 16; i++) if (_playChannels[i].playing) noteOff(i); } -void midiManager::noteOn(int8 channel, int8 note, int8 velocity) { +void MidiManager::noteOn(int8 channel, int8 note, int8 velocity) { assert(channel <= 15); _playChannels[channel].playing = true; @@ -52,7 +52,7 @@ void midiManager::noteOn(int8 channel, int8 note, int8 velocity) { _driver->send(channel | (velocity << 16) | (note << 8) | 0x90); } -void midiManager::noteOff(int8 channel) { +void MidiManager::noteOff(int8 channel) { assert(channel <= 15); if (_playChannels[channel].playing) { @@ -61,26 +61,26 @@ void midiManager::noteOff(int8 channel) { } } -int8 midiManager::getFreeChannel() { +int8 MidiManager::getFreeChannel() { for (int8 i = 0; i < 16; i++) if (!_playChannels[i].playing) return i; return -1; } -void midiManager::setPan(int8 channel, int8 pan) { +void MidiManager::setPan(int8 channel, int8 pan) { assert(channel <= 15); _driver->send(channel | (pan << 16) | 0xAB0); } -void midiManager::setVolume(int8 channel, int8 volume) { +void MidiManager::setVolume(int8 channel, int8 volume) { assert(channel <= 15); _driver->send(channel | (volume << 16) | 0x7B0); } -void midiManager::setProgram(int8 channel, int8 prog) { +void MidiManager::setProgram(int8 channel, int8 prog) { assert(channel <= 15); _driver->send(channel | (prog << 8) | 0xC0); diff --git a/engines/zvision/core/midi.h b/engines/zvision/core/midi.h index 79f8ea3d04..a3bac19636 100644 --- a/engines/zvision/core/midi.h +++ b/engines/zvision/core/midi.h @@ -27,10 +27,10 @@ namespace ZVision { -class midiManager { +class MidiManager { public: - midiManager(); - ~midiManager(); + MidiManager(); + ~MidiManager(); void stop(); void noteOn(int8 channel, int8 noteNumber, int8 velocity); diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 2797b940a0..9b36824c3b 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -165,6 +165,7 @@ Common::Error SaveManager::loadGame(const Common::String &saveName) { bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) { uint32 tag = in->readUint32BE(); + // Check if it's original savegame than fill header structure if (tag == MKTAG('Z', 'N', 'S', 'G')) { header.saveYear = 0; header.saveMonth = 0; @@ -216,7 +217,7 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) { Common::SeekableReadStream *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot)); if (saveFile == NULL) { - // Try to load standart save file + // Try to load standard save file Common::String filename; if (_engine->getGameId() == GID_GRANDINQUISITOR) filename = Common::String::format("inqsav%u.sav", slot); diff --git a/engines/zvision/core/search_manager.cpp b/engines/zvision/core/search_manager.cpp index fe99772b9b..8350189566 100644 --- a/engines/zvision/core/search_manager.cpp +++ b/engines/zvision/core/search_manager.cpp @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ + #include "common/debug.h" #include "zvision/core/search_manager.h" @@ -29,18 +30,18 @@ namespace ZVision { -sManager::sManager(const Common::String &root_path, int depth) { - _root = root_path; +SearchManager::SearchManager(const Common::String &rootPath, int depth) { + _root = rootPath; if (_root[_root.size() - 1] == '\\' || _root[_root.size() - 1] == '/') _root.deleteLastChar(); - Common::FSNode fs_node(_root); + Common::FSNode fsNode(_root); - list_dir_recursive(dir_list, fs_node, depth); + listDirRecursive(dirList, fsNode, depth); - for (Common::List::iterator it = dir_list.begin(); it != dir_list.end();) + for (Common::List::iterator it = dirList.begin(); it != dirList.end();) if (it->size() == _root.size()) - it = dir_list.erase(it); + it = dirList.erase(it); else if (it->size() > _root.size()) { *it = Common::String(it->c_str() + _root.size() + 1); it++; @@ -48,7 +49,7 @@ sManager::sManager(const Common::String &root_path, int depth) { it++; } -sManager::~sManager() { +SearchManager::~SearchManager() { Common::List::iterator it = archList.begin(); while (it != archList.end()) { delete *it; @@ -58,20 +59,20 @@ sManager::~sManager() { archList.clear(); } -void sManager::addPatch(const Common::String &src, const Common::String &dst) { - Common::String lw_name = dst; - lw_name.toLowercase(); +void SearchManager::addPatch(const Common::String &src, const Common::String &dst) { + Common::String lowerCaseName = dst; + lowerCaseName.toLowercase(); - sManager::MatchList::iterator it = files.find(lw_name); + SearchManager::MatchList::iterator it = files.find(lowerCaseName); if (it != files.end()) { - lw_name = src; - lw_name.toLowercase(); - files[lw_name] = it->_value; + lowerCaseName = src; + lowerCaseName.toLowercase(); + files[lowerCaseName] = it->_value; } } -void sManager::addFile(const Common::String &name, Common::Archive *arch) { +void SearchManager::addFile(const Common::String &name, Common::Archive *arch) { bool addArch = true; Common::List::iterator it = archList.begin(); while (it != archList.end()) { @@ -84,17 +85,17 @@ void sManager::addFile(const Common::String &name, Common::Archive *arch) { if (addArch) archList.push_back(arch); - Common::String lw_name = name; - lw_name.toLowercase(); + Common::String lowerCaseName = name; + lowerCaseName.toLowercase(); - sManager::Node nod; - nod.name = lw_name; + SearchManager::Node nod; + nod.name = lowerCaseName; nod.arch = arch; - sManager::MatchList::iterator fit = files.find(lw_name); + SearchManager::MatchList::iterator fit = files.find(lowerCaseName); if (fit == files.end()) { - files[lw_name] = nod; + files[lowerCaseName] = nod; } else { Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name); if (stream) { @@ -102,16 +103,16 @@ void sManager::addFile(const Common::String &name, Common::Archive *arch) { fit->_value.arch = arch; delete stream; } else { - files[lw_name] = nod; + files[lowerCaseName] = nod; } } } -Common::File *sManager::openFile(const Common::String &name) { - Common::String lw_name = name; - lw_name.toLowercase(); +Common::File *SearchManager::openFile(const Common::String &name) { + Common::String lowerCaseName = name; + lowerCaseName.toLowercase(); - sManager::MatchList::iterator fit = files.find(lw_name); + SearchManager::MatchList::iterator fit = files.find(lowerCaseName); if (fit != files.end()) { Common::File *tmp = new Common::File(); @@ -121,29 +122,29 @@ Common::File *sManager::openFile(const Common::String &name) { return NULL; } -bool sManager::openFile(Common::File &file, const Common::String &name) { - Common::String lw_name = name; - lw_name.toLowercase(); +bool SearchManager::openFile(Common::File &file, const Common::String &name) { + Common::String lowerCaseName = name; + lowerCaseName.toLowercase(); - sManager::MatchList::iterator fit = files.find(lw_name); + SearchManager::MatchList::iterator fit = files.find(lowerCaseName); if (fit != files.end()) return file.open(fit->_value.name, *fit->_value.arch); return false; } -bool sManager::hasFile(const Common::String &name) { - Common::String lw_name = name; - lw_name.toLowercase(); +bool SearchManager::hasFile(const Common::String &name) { + Common::String lowerCaseName = name; + lowerCaseName.toLowercase(); - sManager::MatchList::iterator fit = files.find(lw_name); + SearchManager::MatchList::iterator fit = files.find(lowerCaseName); if (fit != files.end()) return true; return false; } -void sManager::loadZix(const Common::String &name) { +void SearchManager::loadZix(const Common::String &name) { Common::File file; file.open(name); @@ -168,13 +169,13 @@ void sManager::loadZix(const Common::String &name) { else if (line.matchString("DIR:*", true)) { Common::String path(line.c_str() + 5); Common::Archive *arc; - char n_path[128]; - strcpy(n_path, path.c_str()); + char tempPath[128]; + strcpy(tempPath, path.c_str()); for (uint i = 0; i < path.size(); i++) - if (n_path[i] == '\\') - n_path[i] = '/'; + if (tempPath[i] == '\\') + tempPath[i] = '/'; - path = Common::String(n_path); + path = Common::String(tempPath); if (path.size() && path[0] == '.') path.deleteChar(0); if (path.size() && path[0] == '/') @@ -187,7 +188,7 @@ void sManager::loadZix(const Common::String &name) { if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/') path.deleteLastChar(); if (path.size()) - for (Common::List::iterator it = dir_list.begin(); it != dir_list.end(); ++it) + for (Common::List::iterator it = dirList.begin(); it != dirList.end(); ++it) if (path.equalsIgnoreCase(*it)) { path = *it; break; @@ -218,9 +219,9 @@ void sManager::loadZix(const Common::String &name) { } } -void sManager::addDir(const Common::String &name) { +void SearchManager::addDir(const Common::String &name) { Common::String path; - for (Common::List::iterator it = dir_list.begin(); it != dir_list.end(); ++it) + for (Common::List::iterator it = dirList.begin(); it != dirList.end(); ++it) if (name.equalsIgnoreCase(*it)) { path = *it; break; @@ -246,8 +247,8 @@ void sManager::addDir(const Common::String &name) { zfs->listMembers(zfslist); for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) { - Common::String z_name = (*ziter)->getName(); - addFile(z_name, zfs); + Common::String zfsFileName = (*ziter)->getName(); + addFile(zfsFileName, zfs); } } @@ -260,15 +261,15 @@ void sManager::addDir(const Common::String &name) { } } -void sManager::list_dir_recursive(Common::List &_list, const Common::FSNode &fs_node, int depth) { - Common::FSList fs_list; - fs_node.getChildren(fs_list); +void SearchManager::listDirRecursive(Common::List &_list, const Common::FSNode &fsNode, int depth) { + Common::FSList fsList; + fsNode.getChildren(fsList); - _list.push_back(fs_node.getPath()); + _list.push_back(fsNode.getPath()); if (depth > 1) - for (Common::FSList::const_iterator it = fs_list.begin(); it != fs_list.end(); ++it) - list_dir_recursive(_list, *it, depth - 1); + for (Common::FSList::const_iterator it = fsList.begin(); it != fsList.end(); ++it) + listDirRecursive(_list, *it, depth - 1); } } // End of namespace ZVision diff --git a/engines/zvision/core/search_manager.h b/engines/zvision/core/search_manager.h index c768cb8b00..180102eac6 100644 --- a/engines/zvision/core/search_manager.h +++ b/engines/zvision/core/search_manager.h @@ -1,5 +1,27 @@ -#ifndef SEARCH_MANAGER_H_INCLUDED -#define SEARCH_MANAGER_H_INCLUDED +/* 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. + * + */ + +#ifndef ZVISION_SEARCH_MANAGER_H +#define ZVISION_SEARCH_MANAGER_H #include "common/str.h" #include "common/hash-str.h" @@ -10,10 +32,10 @@ namespace ZVision { -class sManager { +class SearchManager { public: - sManager(const Common::String &root_path, int depth); - ~sManager(); + SearchManager(const Common::String &rootPath, int depth); + ~SearchManager(); void addFile(const Common::String &name, Common::Archive *arch); void addDir(const Common::String &name); @@ -27,14 +49,14 @@ public: private: - void list_dir_recursive(Common::List &dir_list, const Common::FSNode &fs_node, int depth); + void listDirRecursive(Common::List &dirList, const Common::FSNode &fsNode, int depth); struct Node { Common::String name; Common::Archive *arch; }; - Common::List dir_list; + Common::List dirList; typedef Common::HashMap MatchList; @@ -48,4 +70,4 @@ private: } -#endif // SEARCH_MANAGER_H_INCLUDED +#endif // ZVISION_SEARCH_MANAGER_H -- cgit v1.2.3 From 2a4a6df5f2ae89132fd93d26b03599b6cc5c5fb7 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 01:12:35 +0200 Subject: ZVISION: Remove superfluous spacing and reorder some includes --- engines/zvision/core/console.cpp | 1 - engines/zvision/core/events.cpp | 1 - engines/zvision/core/menu.cpp | 4 ---- engines/zvision/core/menu.h | 2 -- engines/zvision/core/save_manager.cpp | 1 - engines/zvision/core/search_manager.cpp | 2 -- 6 files changed, 11 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index aac4e7b2bc..201d1c9360 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -41,7 +41,6 @@ #include "audio/mixer.h" - namespace ZVision { Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 873cdb0df7..e3bcf6f09a 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -40,7 +40,6 @@ #include "engines/util.h" - namespace ZVision { void ZVision::shortKeys(Common::Event event) { diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp index 5816b3f364..c7898a4fbd 100644 --- a/engines/zvision/core/menu.cpp +++ b/engines/zvision/core/menu.cpp @@ -26,7 +26,6 @@ #include "zvision/graphics/render_manager.h" - namespace ZVision { enum { @@ -380,7 +379,6 @@ void MenuZGI::process(uint32 deltatime) { else if (itemCount > 50) itemCount = 50; - for (int i = 0; i < itemCount; i++) { int itemspace = (600 - 28) / itemCount; @@ -553,7 +551,6 @@ void MenuZGI::process(uint32 deltatime) { } } - MenuNemesis::MenuNemesis(ZVision *engine) : MenuHandler(engine) { inmenu = false; @@ -761,5 +758,4 @@ void MenuNemesis::process(uint32 deltatime) { } } - } // End of namespace ZVision diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h index 62683de912..7301323173 100644 --- a/engines/zvision/core/menu.h +++ b/engines/zvision/core/menu.h @@ -70,8 +70,6 @@ public: private: Graphics::Surface menuback[3][2]; Graphics::Surface menubar[4][2]; - - Graphics::Surface *items[50][2]; uint itemId[50]; diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 9b36824c3b..11d3dd391a 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -35,7 +35,6 @@ #include "gui/message.h" - namespace ZVision { const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G'); diff --git a/engines/zvision/core/search_manager.cpp b/engines/zvision/core/search_manager.cpp index 8350189566..1e9643ddbb 100644 --- a/engines/zvision/core/search_manager.cpp +++ b/engines/zvision/core/search_manager.cpp @@ -27,7 +27,6 @@ #include "common/fs.h" #include "common/stream.h" - namespace ZVision { SearchManager::SearchManager(const Common::String &rootPath, int depth) { @@ -237,7 +236,6 @@ void SearchManager::addDir(const Common::String &name) { Common::ArchiveMemberList list; dir->listMatchingMembers(list, "*.zfs"); - for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { Common::String flname = (*iter)->getName(); -- cgit v1.2.3 From 10444ef5683f420f08cfc276349a5771dd0d04e5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 01:42:04 +0200 Subject: ZVISION: Use integers for rectangles in the menu code --- engines/zvision/core/menu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h index 7301323173..ebe0bb50ac 100644 --- a/engines/zvision/core/menu.h +++ b/engines/zvision/core/menu.h @@ -82,7 +82,7 @@ private: int mouseOnItem; bool scrolled[3]; - float scrollPos[3]; + int16 scrollPos[3]; enum { menu_ITEM = 0, @@ -111,7 +111,7 @@ private: int mouseOnItem; bool scrolled; - float scrollPos; + int16 scrollPos; bool redraw; -- cgit v1.2.3 From bb31c435bf6502f4e1f94b3de9f046c054031a98 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 01:43:51 +0200 Subject: ZVISION: Remove more dead code, and move some debugger functions --- engines/zvision/core/console.cpp | 79 ++++++++++++++++++++++++++-------------- engines/zvision/core/console.h | 2 - 2 files changed, 52 insertions(+), 29 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 201d1c9360..f8e28333f1 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -44,7 +44,6 @@ namespace ZVision { Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { - registerCmd("loadimage", WRAP_METHOD(Console, cmdLoadImage)); registerCmd("loadvideo", WRAP_METHOD(Console, cmdLoadVideo)); registerCmd("loadsound", WRAP_METHOD(Console, cmdLoadSound)); registerCmd("raw2wav", WRAP_METHOD(Console, cmdRawToWav)); @@ -55,18 +54,6 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { registerCmd("changelocation", WRAP_METHOD(Console, cmdChangeLocation)); registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); registerCmd("parseallscrfiles", WRAP_METHOD(Console, cmdParseAllScrFiles)); - registerCmd("rendertext", WRAP_METHOD(Console, cmdRenderText)); -} - -bool Console::cmdLoadImage(int argc, const char **argv) { -// if (argc == 4) -// _engine->getRenderManager()->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3])); -// else { -// DebugPrintf("Use loadimage to load an image to the screen\n"); -// return true; -// } - - return true; } bool Console::cmdLoadVideo(int argc, const char **argv) { @@ -117,7 +104,42 @@ bool Console::cmdRawToWav(int argc, const char **argv) { return true; } - convertRawToWav(argv[1], _engine, argv[2]); + Common::File file; + if (!file.open(argv[1])) + return true; + + Audio::AudioStream *audioStream = makeRawZorkStream(argv[1], _engine); + + Common::DumpFile output; + output.open(argv[2]); + + output.writeUint32BE(MKTAG('R', 'I', 'F', 'F')); + output.writeUint32LE(file.size() * 2 + 36); + output.writeUint32BE(MKTAG('W', 'A', 'V', 'E')); + output.writeUint32BE(MKTAG('f', 'm', 't', ' ')); + output.writeUint32LE(16); + output.writeUint16LE(1); + uint16 numChannels; + if (audioStream->isStereo()) { + numChannels = 2; + output.writeUint16LE(2); + } else { + numChannels = 1; + output.writeUint16LE(1); + } + output.writeUint32LE(audioStream->getRate()); + output.writeUint32LE(audioStream->getRate() * numChannels * 2); + output.writeUint16LE(numChannels * 2); + output.writeUint16LE(16); + output.writeUint32BE(MKTAG('d', 'a', 't', 'a')); + output.writeUint32LE(file.size() * 2); + int16 *buffer = new int16[file.size()]; + audioStream->readBuffer(buffer, file.size()); + output.write(buffer, file.size() * 2); + + delete[] buffer; + + return true; } @@ -186,7 +208,22 @@ bool Console::cmdDumpFile(int argc, const char **argv) { return true; } - writeFileContentsToFile(argv[1], argv[1]); + Common::File f; + if (!f.open(argv[1])) { + return true; + } + + byte *buffer = new byte[f.size()]; + f.read(buffer, f.size()); + + Common::DumpFile dumpFile; + dumpFile.open(argv[1]); + + dumpFile.write(buffer, f.size()); + dumpFile.flush(); + dumpFile.close(); + + delete[] buffer; return true; } @@ -201,16 +238,4 @@ bool Console::cmdParseAllScrFiles(int argc, const char **argv) { return true; } -bool Console::cmdRenderText(int argc, const char **argv) { - if (argc != 7) { - debugPrintf("Use rendertext <1 or 0: wrap> to render text\n"); - return true; - } - - //StringManager::TextStyle style = _engine->getStringManager()->getTextStyle(atoi(argv[2])); - //_engine->getRenderManager()->renderTextToWorkingWindow(333, Common::String(argv[1]), style.font, atoi(argv[3]), atoi(argv[4]), style.color, atoi(argv[5]), -1, Graphics::kTextAlignLeft, atoi(argv[6]) == 0 ? false : true); - - return true; -} - } // End of namespace ZVision diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h index 29523c57ee..994e05ba35 100644 --- a/engines/zvision/core/console.h +++ b/engines/zvision/core/console.h @@ -37,7 +37,6 @@ public: private: ZVision *_engine; - bool cmdLoadImage(int argc, const char **argv); bool cmdLoadVideo(int argc, const char **argv); bool cmdLoadSound(int argc, const char **argv); bool cmdRawToWav(int argc, const char **argv); @@ -48,7 +47,6 @@ private: bool cmdChangeLocation(int argc, const char **argv); bool cmdDumpFile(int argc, const char **argv); bool cmdParseAllScrFiles(int argc, const char **argv); - bool cmdRenderText(int argc, const char **argv); }; } // End of namespace ZVision -- cgit v1.2.3 From bbec6c913ac6ad4279e3549fc903b9c6e4521f50 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 01:58:07 +0200 Subject: ZVISION: Document some more cheats for ZGI Thanks to marisa-chan for providing the location of those in pull request #532 --- engines/zvision/core/events.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index e3bcf6f09a..2c0e63bf5c 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -71,9 +71,8 @@ void ZVision::cheatCodes(uint8 key) { pushKeyToCheatBuf(key); if (getGameId() == GID_GRANDINQUISITOR) { - if (checkCode("IMNOTDEAF")) { - // Unknow cheat + // Unknown cheat showDebugMsg(Common::String::format("IMNOTDEAF cheat or debug, not implemented")); } @@ -93,8 +92,12 @@ void ZVision::cheatCodes(uint8 key) { if (checkCode("MIKESPANTS")) { _scriptManager->changeLocation('g', 'j', 't', 'm', 0); } - } else if (getGameId() == GID_NEMESIS) { + // There are 3 more cheats in script files: + // - "EAT ME": gjcr.scr + // - "WHOAMI": hp1e.scr + // - "HUISOK": uh1f.scr + } else if (getGameId() == GID_NEMESIS) { if (checkCode("CHLOE")) { _scriptManager->changeLocation('t', 'm', '2', 'g', 0); _scriptManager->setStateValue(224, 1); -- cgit v1.2.3 From f578a1b3342578594d9940894a525bf3983641ff Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 02:11:50 +0200 Subject: ZVISION: Move the key mapper function --- engines/zvision/core/events.cpp | 106 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 3 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 2c0e63bf5c..52d71c92f6 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -30,8 +30,6 @@ #include "zvision/scripting/script_manager.h" #include "zvision/animation/rlf_animation.h" #include "zvision/core/menu.h" -#include "zvision/utility/win_keys.h" -#include "zvision/core/menu.h" #include "zvision/sound/zork_raw.h" #include "common/events.h" @@ -214,7 +212,7 @@ void ZVision::processEvents() { break; } - uint8 vkKey = VKkey(_event.kbd.keycode); + uint8 vkKey = getZvisionKey(_event.kbd.keycode); _scriptManager->setStateValue(StateKey_KeyPress, vkKey); @@ -342,4 +340,106 @@ void ZVision::onMouseMove(const Common::Point &pos) { } } +uint8 ZVision::getZvisionKey(Common::KeyCode scummKeyCode) { + if (scummKeyCode >= Common::KEYCODE_a && scummKeyCode <= Common::KEYCODE_z) + return 0x41 + scummKeyCode - Common::KEYCODE_a; + if (scummKeyCode >= Common::KEYCODE_0 && scummKeyCode <= Common::KEYCODE_9) + return 0x30 + scummKeyCode - Common::KEYCODE_0; + if (scummKeyCode >= Common::KEYCODE_F1 && scummKeyCode <= Common::KEYCODE_F15) + return 0x70 + scummKeyCode - Common::KEYCODE_F1; + if (scummKeyCode >= Common::KEYCODE_KP0 && scummKeyCode <= Common::KEYCODE_KP9) + return 0x60 + scummKeyCode - Common::KEYCODE_KP0; + + switch (scummKeyCode) { + case Common::KEYCODE_BACKSPACE: + return 0x8; + case Common::KEYCODE_TAB: + return 0x9; + case Common::KEYCODE_CLEAR: + return 0xC; + case Common::KEYCODE_RETURN: + return 0xD; + case Common::KEYCODE_CAPSLOCK: + return 0x14; + case Common::KEYCODE_ESCAPE: + return 0x1B; + case Common::KEYCODE_SPACE: + return 0x20; + case Common::KEYCODE_PAGEUP: + return 0x21; + case Common::KEYCODE_PAGEDOWN: + return 0x22; + case Common::KEYCODE_END: + return 0x23; + case Common::KEYCODE_HOME: + return 0x24; + case Common::KEYCODE_LEFT: + return 0x25; + case Common::KEYCODE_UP: + return 0x26; + case Common::KEYCODE_RIGHT: + return 0x27; + case Common::KEYCODE_DOWN: + return 0x28; + case Common::KEYCODE_PRINT: + return 0x2A; + case Common::KEYCODE_INSERT: + return 0x2D; + case Common::KEYCODE_DELETE: + return 0x2E; + case Common::KEYCODE_HELP: + return 0x2F; + case Common::KEYCODE_KP_MULTIPLY: + return 0x6A; + case Common::KEYCODE_KP_PLUS: + return 0x6B; + case Common::KEYCODE_KP_MINUS: + return 0x6D; + case Common::KEYCODE_KP_PERIOD: + return 0x6E; + case Common::KEYCODE_KP_DIVIDE: + return 0x6F; + case Common::KEYCODE_NUMLOCK: + return 0x90; + case Common::KEYCODE_SCROLLOCK: + return 0x91; + case Common::KEYCODE_LSHIFT: + return 0xA0; + case Common::KEYCODE_RSHIFT: + return 0xA1; + case Common::KEYCODE_LCTRL: + return 0xA2; + case Common::KEYCODE_RCTRL: + return 0xA3; + case Common::KEYCODE_MENU: + return 0xA5; + case Common::KEYCODE_LEFTBRACKET: + return 0xDB; + case Common::KEYCODE_RIGHTBRACKET: + return 0xDD; + case Common::KEYCODE_SEMICOLON: + return 0xBA; + case Common::KEYCODE_BACKSLASH: + return 0xDC; + case Common::KEYCODE_QUOTE: + return 0xDE; + case Common::KEYCODE_SLASH: + return 0xBF; + case Common::KEYCODE_TILDE: + return 0xC0; + case Common::KEYCODE_COMMA: + return 0xBC; + case Common::KEYCODE_PERIOD: + return 0xBE; + case Common::KEYCODE_MINUS: + return 0xBD; + case Common::KEYCODE_PLUS: + return 0xBB; + default: + return 0; + } + + return 0; +} + } // End of namespace ZVision -- cgit v1.2.3 From f2eee1759f922640b08ac3420f50f0a9c05e0588 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 02:16:14 +0200 Subject: ZVISION: Move the ZfsArchive class --- engines/zvision/core/search_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/search_manager.cpp b/engines/zvision/core/search_manager.cpp index 1e9643ddbb..9c5d8fb323 100644 --- a/engines/zvision/core/search_manager.cpp +++ b/engines/zvision/core/search_manager.cpp @@ -21,12 +21,12 @@ */ #include "common/debug.h" - -#include "zvision/core/search_manager.h" -#include "zvision/archives/zfs_archive.h" #include "common/fs.h" #include "common/stream.h" +#include "zvision/core/search_manager.h" +#include "zvision/utility/zfs_archive.h" + namespace ZVision { SearchManager::SearchManager(const Common::String &rootPath, int depth) { -- cgit v1.2.3 From ec1fdeb25ad6b2d9aae69a544f45eb7fc5e189b8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 8 Dec 2014 01:08:27 +0200 Subject: ZVISION: Implement several advanced engine features and ScummVM dialogs The functionality to return to launcher, list saves, delete saves, load games from the launcher and load and save games during runtime has been implemented. Also, ScummVM save/load dialogs have been implemented. Saved games now have three numbers in their file extension, bumping the possible save game slots up to 999 --- engines/zvision/core/save_manager.cpp | 40 ++++++++++++++++++++++++++++++++++- engines/zvision/core/save_manager.h | 1 + 2 files changed, 40 insertions(+), 1 deletion(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 11d3dd391a..20bd39fde5 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -23,22 +23,60 @@ #include "common/scummsys.h" #include "zvision/core/save_manager.h" - #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "common/system.h" +#include "common/translation.h" #include "graphics/surface.h" #include "graphics/thumbnail.h" #include "gui/message.h" +#include "gui/saveload.h" namespace ZVision { const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G'); +bool SaveManager::scummVMSaveLoadDialog(bool isSave) { + GUI::SaveLoadChooser *dialog; + Common::String desc; + int slot; + + if (isSave) { + dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); + + slot = dialog->runModalWithCurrentTarget(); + desc = dialog->getResultString(); + + if (desc.empty()) { + // create our own description for the saved game, the user didnt enter it + desc = dialog->createDefaultSaveDescription(slot); + } + + if (desc.size() > 28) + desc = Common::String(desc.c_str(), 28); + } else { + dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); + slot = dialog->runModalWithCurrentTarget(); + } + + delete dialog; + + if (slot < 0) + return false; + + if (isSave) { + saveGame(slot, desc); + return true; + } else { + Common::ErrorCode result = loadGame(slot).getCode(); + return (result == Common::kNoError); + } +} + void SaveManager::saveGame(uint slot, const Common::String &saveName) { // The games only support 20 slots //assert(slot <= 1 && slot <= 20); diff --git a/engines/zvision/core/save_manager.h b/engines/zvision/core/save_manager.h index 5cd61c7aa9..75841331e7 100644 --- a/engines/zvision/core/save_manager.h +++ b/engines/zvision/core/save_manager.h @@ -96,6 +96,7 @@ public: void prepareSaveBuffer(); void flushSaveBuffer(); + bool scummVMSaveLoadDialog(bool isSave); private: void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName); }; -- cgit v1.2.3 From ea8db1969a7f975103d26f6a6a7eaa54835db7c1 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 9 Dec 2014 19:36:38 +0200 Subject: ZVISION: Fix the 'dumpfile' console command --- engines/zvision/core/console.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index f8e28333f1..e641783338 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -209,7 +209,8 @@ bool Console::cmdDumpFile(int argc, const char **argv) { } Common::File f; - if (!f.open(argv[1])) { + if (!_engine->getSearchManager()->openFile(f, argv[1])) { + warning("File not found: %s", argv[1]); return true; } -- cgit v1.2.3 From 2644d084480d537388cc7f585338ff2bf0490b38 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 11 Dec 2014 13:25:37 +0200 Subject: ZVISION: Add functionality to show the current location. Some cleanup --- engines/zvision/core/console.cpp | 38 ++++++++++++++++---------------------- engines/zvision/core/console.h | 3 +-- 2 files changed, 17 insertions(+), 24 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index e641783338..0f6cbfc96f 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -51,14 +51,13 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { registerCmd("generaterendertable", WRAP_METHOD(Console, cmdGenerateRenderTable)); registerCmd("setpanoramafov", WRAP_METHOD(Console, cmdSetPanoramaFoV)); registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale)); - registerCmd("changelocation", WRAP_METHOD(Console, cmdChangeLocation)); + registerCmd("location", WRAP_METHOD(Console, cmdLocation)); registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); - registerCmd("parseallscrfiles", WRAP_METHOD(Console, cmdParseAllScrFiles)); } bool Console::cmdLoadVideo(int argc, const char **argv) { if (argc != 2) { - debugPrintf("Use loadvideo to load a video to the screen\n"); + debugPrintf("Use %s to load a video to the screen\n", argv[0]); return true; } @@ -91,7 +90,7 @@ bool Console::cmdLoadSound(int argc, const char **argv) { Audio::SoundHandle handle; _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false); } else { - debugPrintf("Use loadsound [ ] to load a sound\n"); + debugPrintf("Use %s [ ] to load a sound\n", argv[0]); return true; } @@ -100,7 +99,7 @@ bool Console::cmdLoadSound(int argc, const char **argv) { bool Console::cmdRawToWav(int argc, const char **argv) { if (argc != 3) { - debugPrintf("Use raw2wav to dump a .RAW file to .WAV\n"); + debugPrintf("Use %s to dump a .RAW file to .WAV\n", argv[0]); return true; } @@ -145,7 +144,7 @@ bool Console::cmdRawToWav(int argc, const char **argv) { bool Console::cmdSetRenderState(int argc, const char **argv) { if (argc != 2) { - debugPrintf("Use setrenderstate to change the current render state\n"); + debugPrintf("Use %s to change the current render state\n", argv[0]); return true; } @@ -158,7 +157,7 @@ bool Console::cmdSetRenderState(int argc, const char **argv) { else if (renderState.matchString("flat", true)) _engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT); else - debugPrintf("Use setrenderstate to change the current render state\n"); + debugPrintf("Use %s to change the current render state\n", argv[0]); return true; } @@ -171,7 +170,7 @@ bool Console::cmdGenerateRenderTable(int argc, const char **argv) { bool Console::cmdSetPanoramaFoV(int argc, const char **argv) { if (argc != 2) { - debugPrintf("Use setpanoramafov to change the current panorama field of view\n"); + debugPrintf("Use %s to change the current panorama field of view\n", argv[0]); return true; } @@ -182,7 +181,7 @@ bool Console::cmdSetPanoramaFoV(int argc, const char **argv) { bool Console::cmdSetPanoramaScale(int argc, const char **argv) { if (argc != 2) { - debugPrintf("Use setpanoramascale to change the current panorama scale\n"); + debugPrintf("Use %s to change the current panorama scale\n", argv[0]); return true; } @@ -191,9 +190,14 @@ bool Console::cmdSetPanoramaScale(int argc, const char **argv) { return true; } -bool Console::cmdChangeLocation(int argc, const char **argv) { +bool Console::cmdLocation(int argc, const char **argv) { + Location curLocation = _engine->getScriptManager()->getCurrentLocation(); + Common::String scrFile = Common::String::format("%c%c%c%c.scr", curLocation.world, curLocation.room, curLocation.node, curLocation.view); + debugPrintf("Current location: world '%c', room '%c', node '%c', view '%c', offset %d, script %s\n", + curLocation.world, curLocation.room, curLocation.node, curLocation.view, curLocation.offset, scrFile.c_str()); + if (argc != 6) { - debugPrintf("Use changelocation to change your location\n"); + debugPrintf("Use %s to change your location\n", argv[0]); return true; } @@ -204,7 +208,7 @@ bool Console::cmdChangeLocation(int argc, const char **argv) { bool Console::cmdDumpFile(int argc, const char **argv) { if (argc != 2) { - debugPrintf("Use dumpfile to dump a file\n"); + debugPrintf("Use %s to dump a file\n", argv[0]); return true; } @@ -229,14 +233,4 @@ bool Console::cmdDumpFile(int argc, const char **argv) { return true; } -bool Console::cmdParseAllScrFiles(int argc, const char **argv) { - Common::ArchiveMemberList list; - SearchMan.listMatchingMembers(list, "*.scr"); - - for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { - } - - return true; -} - } // End of namespace ZVision diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h index 994e05ba35..299bd6127f 100644 --- a/engines/zvision/core/console.h +++ b/engines/zvision/core/console.h @@ -44,9 +44,8 @@ private: bool cmdGenerateRenderTable(int argc, const char **argv); bool cmdSetPanoramaFoV(int argc, const char **argv); bool cmdSetPanoramaScale(int argc, const char **argv); - bool cmdChangeLocation(int argc, const char **argv); + bool cmdLocation(int argc, const char **argv); bool cmdDumpFile(int argc, const char **argv); - bool cmdParseAllScrFiles(int argc, const char **argv); }; } // End of namespace ZVision -- cgit v1.2.3 From 3315522ba1607d68c3402f3d1c8b51b7dc38a7dd Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 13 Dec 2014 15:28:22 +0200 Subject: ZVISION: Move the RLF decoder --- engines/zvision/core/events.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 52d71c92f6..839f919ad6 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -28,7 +28,6 @@ #include "zvision/cursors/cursor_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/scripting/script_manager.h" -#include "zvision/animation/rlf_animation.h" #include "zvision/core/menu.h" #include "zvision/sound/zork_raw.h" -- cgit v1.2.3 From 67bd78a95f6efab6d0da4b3bef1b0cebc79c537c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 15 Dec 2014 03:40:52 +0200 Subject: ZVISION: Prefix class member variables with an underscore This makes the code adhere to our code formatting conventions --- engines/zvision/core/search_manager.cpp | 48 ++++++++++++++++----------------- engines/zvision/core/search_manager.h | 6 ++--- 2 files changed, 27 insertions(+), 27 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/search_manager.cpp b/engines/zvision/core/search_manager.cpp index 9c5d8fb323..1523319c94 100644 --- a/engines/zvision/core/search_manager.cpp +++ b/engines/zvision/core/search_manager.cpp @@ -36,11 +36,11 @@ SearchManager::SearchManager(const Common::String &rootPath, int depth) { Common::FSNode fsNode(_root); - listDirRecursive(dirList, fsNode, depth); + listDirRecursive(_dirList, fsNode, depth); - for (Common::List::iterator it = dirList.begin(); it != dirList.end();) + for (Common::List::iterator it = _dirList.begin(); it != _dirList.end();) if (it->size() == _root.size()) - it = dirList.erase(it); + it = _dirList.erase(it); else if (it->size() > _root.size()) { *it = Common::String(it->c_str() + _root.size() + 1); it++; @@ -49,32 +49,32 @@ SearchManager::SearchManager(const Common::String &rootPath, int depth) { } SearchManager::~SearchManager() { - Common::List::iterator it = archList.begin(); - while (it != archList.end()) { + Common::List::iterator it = _archList.begin(); + while (it != _archList.end()) { delete *it; it++; } - archList.clear(); + _archList.clear(); } void SearchManager::addPatch(const Common::String &src, const Common::String &dst) { Common::String lowerCaseName = dst; lowerCaseName.toLowercase(); - SearchManager::MatchList::iterator it = files.find(lowerCaseName); + SearchManager::MatchList::iterator it = _files.find(lowerCaseName); - if (it != files.end()) { + if (it != _files.end()) { lowerCaseName = src; lowerCaseName.toLowercase(); - files[lowerCaseName] = it->_value; + _files[lowerCaseName] = it->_value; } } void SearchManager::addFile(const Common::String &name, Common::Archive *arch) { bool addArch = true; - Common::List::iterator it = archList.begin(); - while (it != archList.end()) { + Common::List::iterator it = _archList.begin(); + while (it != _archList.end()) { if (*it == arch) { addArch = false; break; @@ -82,7 +82,7 @@ void SearchManager::addFile(const Common::String &name, Common::Archive *arch) { it++; } if (addArch) - archList.push_back(arch); + _archList.push_back(arch); Common::String lowerCaseName = name; lowerCaseName.toLowercase(); @@ -91,10 +91,10 @@ void SearchManager::addFile(const Common::String &name, Common::Archive *arch) { nod.name = lowerCaseName; nod.arch = arch; - SearchManager::MatchList::iterator fit = files.find(lowerCaseName); + SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - if (fit == files.end()) { - files[lowerCaseName] = nod; + if (fit == _files.end()) { + _files[lowerCaseName] = nod; } else { Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name); if (stream) { @@ -102,7 +102,7 @@ void SearchManager::addFile(const Common::String &name, Common::Archive *arch) { fit->_value.arch = arch; delete stream; } else { - files[lowerCaseName] = nod; + _files[lowerCaseName] = nod; } } } @@ -111,9 +111,9 @@ Common::File *SearchManager::openFile(const Common::String &name) { Common::String lowerCaseName = name; lowerCaseName.toLowercase(); - SearchManager::MatchList::iterator fit = files.find(lowerCaseName); + SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - if (fit != files.end()) { + if (fit != _files.end()) { Common::File *tmp = new Common::File(); tmp->open(fit->_value.name, *fit->_value.arch); return tmp; @@ -125,9 +125,9 @@ bool SearchManager::openFile(Common::File &file, const Common::String &name) { Common::String lowerCaseName = name; lowerCaseName.toLowercase(); - SearchManager::MatchList::iterator fit = files.find(lowerCaseName); + SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - if (fit != files.end()) + if (fit != _files.end()) return file.open(fit->_value.name, *fit->_value.arch); return false; } @@ -136,9 +136,9 @@ bool SearchManager::hasFile(const Common::String &name) { Common::String lowerCaseName = name; lowerCaseName.toLowercase(); - SearchManager::MatchList::iterator fit = files.find(lowerCaseName); + SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - if (fit != files.end()) + if (fit != _files.end()) return true; return false; } @@ -187,7 +187,7 @@ void SearchManager::loadZix(const Common::String &name) { if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/') path.deleteLastChar(); if (path.size()) - for (Common::List::iterator it = dirList.begin(); it != dirList.end(); ++it) + for (Common::List::iterator it = _dirList.begin(); it != _dirList.end(); ++it) if (path.equalsIgnoreCase(*it)) { path = *it; break; @@ -220,7 +220,7 @@ void SearchManager::loadZix(const Common::String &name) { void SearchManager::addDir(const Common::String &name) { Common::String path; - for (Common::List::iterator it = dirList.begin(); it != dirList.end(); ++it) + for (Common::List::iterator it = _dirList.begin(); it != _dirList.end(); ++it) if (name.equalsIgnoreCase(*it)) { path = *it; break; diff --git a/engines/zvision/core/search_manager.h b/engines/zvision/core/search_manager.h index 180102eac6..fdd70fd381 100644 --- a/engines/zvision/core/search_manager.h +++ b/engines/zvision/core/search_manager.h @@ -56,12 +56,12 @@ private: Common::Archive *arch; }; - Common::List dirList; + Common::List _dirList; typedef Common::HashMap MatchList; - Common::List archList; - MatchList files; + Common::List _archList; + MatchList _files; Common::String _root; -- cgit v1.2.3 From 4b2b5e686b6ac2105f11983b2072037358d9ad7f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 16 Dec 2014 01:00:50 +0200 Subject: ZVISION: Move the mouse cursor handling code into the graphics code --- engines/zvision/core/console.cpp | 2 +- engines/zvision/core/events.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 0f6cbfc96f..76481a3549 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -31,7 +31,7 @@ #include "zvision/video/zork_avi_decoder.h" #include "zvision/sound/zork_raw.h" #include "zvision/utility/utility.h" -#include "zvision/cursors/cursor.h" +#include "zvision/graphics/cursors/cursor.h" #include "common/system.h" #include "common/file.h" diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 839f919ad6..c66e61a61a 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -25,7 +25,7 @@ #include "zvision/zvision.h" #include "zvision/core/console.h" -#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/scripting/script_manager.h" #include "zvision/core/menu.h" -- cgit v1.2.3 From 2463b4580436b41a46500e53b4868789c9c7b21e Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 16 Dec 2014 01:05:01 +0200 Subject: ZVISION: Move the MIDI code together with the rest of the sound code --- engines/zvision/core/midi.cpp | 89 ------------------------------------------- engines/zvision/core/midi.h | 59 ---------------------------- 2 files changed, 148 deletions(-) delete mode 100644 engines/zvision/core/midi.cpp delete mode 100644 engines/zvision/core/midi.h (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/midi.cpp b/engines/zvision/core/midi.cpp deleted file mode 100644 index 736be1311d..0000000000 --- a/engines/zvision/core/midi.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* 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 "common/scummsys.h" - -#include "zvision/core/midi.h" - -namespace ZVision { - -MidiManager::MidiManager() { - MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB); - _driver = MidiDriver::createMidi(dev); - _driver->open(); -} - -MidiManager::~MidiManager() { - stop(); - _driver->close(); - delete _driver; -} - -void MidiManager::stop() { - for (int8 i = 0; i < 16; i++) - if (_playChannels[i].playing) - noteOff(i); -} - -void MidiManager::noteOn(int8 channel, int8 note, int8 velocity) { - assert(channel <= 15); - - _playChannels[channel].playing = true; - _playChannels[channel].note = note; - _driver->send(channel | (velocity << 16) | (note << 8) | 0x90); -} - -void MidiManager::noteOff(int8 channel) { - assert(channel <= 15); - - if (_playChannels[channel].playing) { - _playChannels[channel].playing = false; - _driver->send(channel | (_playChannels[channel].note << 8) | 0x80); - } -} - -int8 MidiManager::getFreeChannel() { - for (int8 i = 0; i < 16; i++) - if (!_playChannels[i].playing) - return i; - return -1; -} - -void MidiManager::setPan(int8 channel, int8 pan) { - assert(channel <= 15); - - _driver->send(channel | (pan << 16) | 0xAB0); -} - -void MidiManager::setVolume(int8 channel, int8 volume) { - assert(channel <= 15); - - _driver->send(channel | (volume << 16) | 0x7B0); -} - -void MidiManager::setProgram(int8 channel, int8 prog) { - assert(channel <= 15); - - _driver->send(channel | (prog << 8) | 0xC0); -} - -} // End of namespace ZVision diff --git a/engines/zvision/core/midi.h b/engines/zvision/core/midi.h deleted file mode 100644 index a3bac19636..0000000000 --- a/engines/zvision/core/midi.h +++ /dev/null @@ -1,59 +0,0 @@ -/* 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. - * - */ - -#ifndef ZVISION_MIDI_H -#define ZVISION_MIDI_H - -#include "audio/mididrv.h" - -namespace ZVision { - -class MidiManager { -public: - MidiManager(); - ~MidiManager(); - - void stop(); - void noteOn(int8 channel, int8 noteNumber, int8 velocity); - void noteOff(int8 channel); - void setPan(int8 channel, int8 pan); - void setVolume(int8 channel, int8 volume); - void setProgram(int8 channel, int8 prog); - - int8 getFreeChannel(); - -protected: - - struct chan { - bool playing; - int8 note; - - chan() : playing(false), note(0) {}; - }; - - MidiDriver *_driver; - chan _playChannels[16]; -}; - -} - -#endif -- cgit v1.2.3 From d8a961244d99a87c1a01613a971173cc135c246a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 16 Dec 2014 01:14:37 +0200 Subject: ZVISION: Move all the file-related classes together --- engines/zvision/core/search_manager.cpp | 273 -------------------------------- engines/zvision/core/search_manager.h | 73 --------- 2 files changed, 346 deletions(-) delete mode 100644 engines/zvision/core/search_manager.cpp delete mode 100644 engines/zvision/core/search_manager.h (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/search_manager.cpp b/engines/zvision/core/search_manager.cpp deleted file mode 100644 index 1523319c94..0000000000 --- a/engines/zvision/core/search_manager.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/* 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 "common/debug.h" -#include "common/fs.h" -#include "common/stream.h" - -#include "zvision/core/search_manager.h" -#include "zvision/utility/zfs_archive.h" - -namespace ZVision { - -SearchManager::SearchManager(const Common::String &rootPath, int depth) { - _root = rootPath; - if (_root[_root.size() - 1] == '\\' || _root[_root.size() - 1] == '/') - _root.deleteLastChar(); - - Common::FSNode fsNode(_root); - - listDirRecursive(_dirList, fsNode, depth); - - for (Common::List::iterator it = _dirList.begin(); it != _dirList.end();) - if (it->size() == _root.size()) - it = _dirList.erase(it); - else if (it->size() > _root.size()) { - *it = Common::String(it->c_str() + _root.size() + 1); - it++; - } else - it++; -} - -SearchManager::~SearchManager() { - Common::List::iterator it = _archList.begin(); - while (it != _archList.end()) { - delete *it; - it++; - } - - _archList.clear(); -} - -void SearchManager::addPatch(const Common::String &src, const Common::String &dst) { - Common::String lowerCaseName = dst; - lowerCaseName.toLowercase(); - - SearchManager::MatchList::iterator it = _files.find(lowerCaseName); - - if (it != _files.end()) { - lowerCaseName = src; - lowerCaseName.toLowercase(); - _files[lowerCaseName] = it->_value; - } -} - -void SearchManager::addFile(const Common::String &name, Common::Archive *arch) { - bool addArch = true; - Common::List::iterator it = _archList.begin(); - while (it != _archList.end()) { - if (*it == arch) { - addArch = false; - break; - } - it++; - } - if (addArch) - _archList.push_back(arch); - - Common::String lowerCaseName = name; - lowerCaseName.toLowercase(); - - SearchManager::Node nod; - nod.name = lowerCaseName; - nod.arch = arch; - - SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - - if (fit == _files.end()) { - _files[lowerCaseName] = nod; - } else { - Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name); - if (stream) { - if (stream->size() < 10) - fit->_value.arch = arch; - delete stream; - } else { - _files[lowerCaseName] = nod; - } - } -} - -Common::File *SearchManager::openFile(const Common::String &name) { - Common::String lowerCaseName = name; - lowerCaseName.toLowercase(); - - SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - - if (fit != _files.end()) { - Common::File *tmp = new Common::File(); - tmp->open(fit->_value.name, *fit->_value.arch); - return tmp; - } - return NULL; -} - -bool SearchManager::openFile(Common::File &file, const Common::String &name) { - Common::String lowerCaseName = name; - lowerCaseName.toLowercase(); - - SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - - if (fit != _files.end()) - return file.open(fit->_value.name, *fit->_value.arch); - return false; -} - -bool SearchManager::hasFile(const Common::String &name) { - Common::String lowerCaseName = name; - lowerCaseName.toLowercase(); - - SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - - if (fit != _files.end()) - return true; - return false; -} - -void SearchManager::loadZix(const Common::String &name) { - Common::File file; - file.open(name); - - Common::String line; - - while (!file.eos()) { - line = file.readLine(); - if (line.matchString("----------*", true)) - break; - } - - if (file.eos()) - return; - - Common::Array archives; - - while (!file.eos()) { - line = file.readLine(); - line.trim(); - if (line.matchString("----------*", true)) - break; - else if (line.matchString("DIR:*", true)) { - Common::String path(line.c_str() + 5); - Common::Archive *arc; - char tempPath[128]; - strcpy(tempPath, path.c_str()); - for (uint i = 0; i < path.size(); i++) - if (tempPath[i] == '\\') - tempPath[i] = '/'; - - path = Common::String(tempPath); - if (path.size() && path[0] == '.') - path.deleteChar(0); - if (path.size() && path[0] == '/') - path.deleteChar(0); - - if (path.matchString("*.zfs", true)) - arc = new ZfsArchive(path); - else { - if (path.size()) { - if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/') - path.deleteLastChar(); - if (path.size()) - for (Common::List::iterator it = _dirList.begin(); it != _dirList.end(); ++it) - if (path.equalsIgnoreCase(*it)) { - path = *it; - break; - } - } - - path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); - - arc = new Common::FSDirectory(path); - } - archives.push_back(arc); - } - } - - if (file.eos()) - return; - - while (!file.eos()) { - line = file.readLine(); - line.trim(); - uint dr = 0; - char buf[32]; - if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) { - if (dr <= archives.size() && dr > 0) { - addFile(Common::String(buf), archives[dr - 1]); - } - } - } -} - -void SearchManager::addDir(const Common::String &name) { - Common::String path; - for (Common::List::iterator it = _dirList.begin(); it != _dirList.end(); ++it) - if (name.equalsIgnoreCase(*it)) { - path = *it; - break; - } - - if (path.size() == 0) - return; - - path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); - - Common::FSDirectory *dir = new Common::FSDirectory(path); - - Common::ArchiveMemberList list; - dir->listMatchingMembers(list, "*.zfs"); - - for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { - Common::String flname = (*iter)->getName(); - - ZfsArchive *zfs = new ZfsArchive(Common::String::format("%s/%s", name.c_str(), flname.c_str())); - - Common::ArchiveMemberList zfslist; - zfs->listMembers(zfslist); - - for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) { - Common::String zfsFileName = (*ziter)->getName(); - addFile(zfsFileName, zfs); - } - } - - list.clear(); - dir->listMembers(list); - - for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { - Common::String flname = (*iter)->getName(); - addFile(flname, dir); - } -} - -void SearchManager::listDirRecursive(Common::List &_list, const Common::FSNode &fsNode, int depth) { - Common::FSList fsList; - fsNode.getChildren(fsList); - - _list.push_back(fsNode.getPath()); - - if (depth > 1) - for (Common::FSList::const_iterator it = fsList.begin(); it != fsList.end(); ++it) - listDirRecursive(_list, *it, depth - 1); -} - -} // End of namespace ZVision diff --git a/engines/zvision/core/search_manager.h b/engines/zvision/core/search_manager.h deleted file mode 100644 index fdd70fd381..0000000000 --- a/engines/zvision/core/search_manager.h +++ /dev/null @@ -1,73 +0,0 @@ -/* 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. - * - */ - -#ifndef ZVISION_SEARCH_MANAGER_H -#define ZVISION_SEARCH_MANAGER_H - -#include "common/str.h" -#include "common/hash-str.h" -#include "common/hashmap.h" -#include "common/archive.h" -#include "common/file.h" -#include "common/list.h" - -namespace ZVision { - -class SearchManager { -public: - SearchManager(const Common::String &rootPath, int depth); - ~SearchManager(); - - void addFile(const Common::String &name, Common::Archive *arch); - void addDir(const Common::String &name); - void addPatch(const Common::String &src, const Common::String &dst); - - Common::File *openFile(const Common::String &name); - bool openFile(Common::File &file, const Common::String &name); - bool hasFile(const Common::String &name); - - void loadZix(const Common::String &name); - -private: - - void listDirRecursive(Common::List &dirList, const Common::FSNode &fsNode, int depth); - - struct Node { - Common::String name; - Common::Archive *arch; - }; - - Common::List _dirList; - - typedef Common::HashMap MatchList; - - Common::List _archList; - MatchList _files; - - Common::String _root; - -private: -}; - -} - -#endif // ZVISION_SEARCH_MANAGER_H -- cgit v1.2.3 From 7630e3204e3b932d9b43bda7dc4b658405fabf33 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 16 Dec 2014 01:21:57 +0200 Subject: ZVISION: Move all the remaining utility classes into the core --- engines/zvision/core/clock.cpp | 68 ++++++++++++++++++++++++++++++++ engines/zvision/core/clock.h | 84 ++++++++++++++++++++++++++++++++++++++++ engines/zvision/core/console.cpp | 2 +- engines/zvision/core/utility.cpp | 45 +++++++++++++++++++++ engines/zvision/core/utility.h | 47 ++++++++++++++++++++++ 5 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 engines/zvision/core/clock.cpp create mode 100644 engines/zvision/core/clock.h create mode 100644 engines/zvision/core/utility.cpp create mode 100644 engines/zvision/core/utility.h (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/clock.cpp b/engines/zvision/core/clock.cpp new file mode 100644 index 0000000000..1425d550b7 --- /dev/null +++ b/engines/zvision/core/clock.cpp @@ -0,0 +1,68 @@ +/* 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 "common/scummsys.h" + +#include "zvision/core/clock.h" + +#include "common/system.h" + +namespace ZVision { + +Clock::Clock(OSystem *system) + : _system(system), + _lastTime(0), + _deltaTime(0), + _pausedTime(0), + _paused(false) { +} + +void Clock::update() { + uint32 currentTime = _system->getMillis(); + + _deltaTime = (currentTime - _lastTime); + if (_paused) { + _deltaTime -= (currentTime - _pausedTime); + } + + if (_deltaTime < 0) { + _deltaTime = 0; + } + + _lastTime = currentTime; +} + +void Clock::start() { + if (_paused) { + _lastTime = _system->getMillis(); + _paused = false; + } +} + +void Clock::stop() { + if (!_paused) { + _pausedTime = _system->getMillis(); + _paused = true; + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/core/clock.h b/engines/zvision/core/clock.h new file mode 100644 index 0000000000..cbf52be560 --- /dev/null +++ b/engines/zvision/core/clock.h @@ -0,0 +1,84 @@ +/* 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. + * + */ + +#ifndef ZVISION_CLOCK_H +#define ZVISION_CLOCK_H + +#include "common/types.h" + +class OSystem; + +namespace ZVision { + +/* Class for handling frame to frame deltaTime while keeping track of time pauses/un-pauses */ +class Clock { +public: + Clock(OSystem *system); + +private: + OSystem *_system; + uint32 _lastTime; + int32 _deltaTime; + uint32 _pausedTime; + bool _paused; + +public: + /** + * Updates _deltaTime with the difference between the current time and + * when the last update() was called. + */ + void update(); + + /** + * Get the delta time since the last frame. (The time between update() calls) + * + * @return Delta time since the last frame (in milliseconds) + */ + uint32 getDeltaTime() const { + return _deltaTime; + } + + /** + * Get the time from the program starting to the last update() call + * + * @return Time from program start to last update() call (in milliseconds) + */ + uint32 getLastMeasuredTime() { + return _lastTime; + } + + /** + * Pause the clock. Any future delta times will take this pause into account. + * Has no effect if the clock is already paused. + */ + void start(); + + /** + * Un-pause the clock. + * Has no effect if the clock is already un-paused. + */ + void stop(); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 76481a3549..eb4d281813 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -30,7 +30,7 @@ #include "zvision/text/string_manager.h" #include "zvision/video/zork_avi_decoder.h" #include "zvision/sound/zork_raw.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" #include "zvision/graphics/cursors/cursor.h" #include "common/system.h" diff --git a/engines/zvision/core/utility.cpp b/engines/zvision/core/utility.cpp new file mode 100644 index 0000000000..dcbb41171e --- /dev/null +++ b/engines/zvision/core/utility.cpp @@ -0,0 +1,45 @@ +/* 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 "common/scummsys.h" + +#include "zvision/core/utility.h" + +#include "zvision/zvision.h" +#include "zvision/sound/zork_raw.h" + +#include "common/tokenizer.h" +#include "common/file.h" + +namespace ZVision { + +void trimCommentsAndWhiteSpace(Common::String *string) { + for (int i = string->size() - 1; i >= 0; i--) { + if ((*string)[i] == '#') { + string->erase(i); + } + } + + string->trim(); +} + +} // End of namespace ZVision diff --git a/engines/zvision/core/utility.h b/engines/zvision/core/utility.h new file mode 100644 index 0000000000..0ca26b968d --- /dev/null +++ b/engines/zvision/core/utility.h @@ -0,0 +1,47 @@ +/* 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. + * + */ + +#ifndef ZVISION_UTILITY_H +#define ZVISION_UTILITY_H + +#include "common/array.h" + +namespace Common { +class String; +} + +namespace ZVision { + +class ZVision; + +/** + * Removes any line comments using '#' as a sequence start. + * Then removes any trailing and leading 'whitespace' using String::trim() + * Note: String::trim uses isspace() to determine what is whitespace and what is not. + * + * @param string The string to modify. It is modified in place + */ +void trimCommentsAndWhiteSpace(Common::String *string); + +} // End of namespace ZVision + +#endif -- cgit v1.2.3 From 77705752efa00ab7f6c65ff8d99e4d9c3fdc4929 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 16 Dec 2014 01:58:05 +0200 Subject: ZVISION: Move trimCommentsAndWhiteSpace() into the script manager This allows us to remove the last remnants of utility.* --- engines/zvision/core/console.cpp | 1 - engines/zvision/core/utility.cpp | 45 -------------------------------------- engines/zvision/core/utility.h | 47 ---------------------------------------- 3 files changed, 93 deletions(-) delete mode 100644 engines/zvision/core/utility.cpp delete mode 100644 engines/zvision/core/utility.h (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index eb4d281813..4dd10d6f40 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -30,7 +30,6 @@ #include "zvision/text/string_manager.h" #include "zvision/video/zork_avi_decoder.h" #include "zvision/sound/zork_raw.h" -#include "zvision/core/utility.h" #include "zvision/graphics/cursors/cursor.h" #include "common/system.h" diff --git a/engines/zvision/core/utility.cpp b/engines/zvision/core/utility.cpp deleted file mode 100644 index dcbb41171e..0000000000 --- a/engines/zvision/core/utility.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* 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 "common/scummsys.h" - -#include "zvision/core/utility.h" - -#include "zvision/zvision.h" -#include "zvision/sound/zork_raw.h" - -#include "common/tokenizer.h" -#include "common/file.h" - -namespace ZVision { - -void trimCommentsAndWhiteSpace(Common::String *string) { - for (int i = string->size() - 1; i >= 0; i--) { - if ((*string)[i] == '#') { - string->erase(i); - } - } - - string->trim(); -} - -} // End of namespace ZVision diff --git a/engines/zvision/core/utility.h b/engines/zvision/core/utility.h deleted file mode 100644 index 0ca26b968d..0000000000 --- a/engines/zvision/core/utility.h +++ /dev/null @@ -1,47 +0,0 @@ -/* 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. - * - */ - -#ifndef ZVISION_UTILITY_H -#define ZVISION_UTILITY_H - -#include "common/array.h" - -namespace Common { -class String; -} - -namespace ZVision { - -class ZVision; - -/** - * Removes any line comments using '#' as a sequence start. - * Then removes any trailing and leading 'whitespace' using String::trim() - * Note: String::trim uses isspace() to determine what is whitespace and what is not. - * - * @param string The string to modify. It is modified in place - */ -void trimCommentsAndWhiteSpace(Common::String *string); - -} // End of namespace ZVision - -#endif -- cgit v1.2.3 From cd2fc20768a8ed8dc34a316ec91e0643b8c2bddf Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:40:45 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257061) --- engines/zvision/core/menu.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp index c7898a4fbd..e584e8712f 100644 --- a/engines/zvision/core/menu.cpp +++ b/engines/zvision/core/menu.cpp @@ -58,6 +58,8 @@ MenuZGI::MenuZGI(ZVision *engine) : scrollPos[1] = 0.0; scrollPos[2] = 0.0; mouseOnItem = -1; + redraw = false; + clean = false; char buf[24]; for (int i = 1; i < 4; i++) { -- cgit v1.2.3 From 56f7be8ab62315a3439d3f4aad9b85a294eac2c9 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:01:30 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257054) --- engines/zvision/core/menu.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp index e584e8712f..31e0d71370 100644 --- a/engines/zvision/core/menu.cpp +++ b/engines/zvision/core/menu.cpp @@ -559,6 +559,8 @@ MenuNemesis::MenuNemesis(ZVision *engine) : scrolled = false; scrollPos = 0.0; mouseOnItem = -1; + redraw = false; + delay = 0; char buf[24]; for (int i = 0; i < 4; i++) -- cgit v1.2.3 From acb172251aa7401f43308ebcac9f30bef3aa40f5 Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Fri, 19 Dec 2014 11:14:10 -0600 Subject: ZVISION: Large scale variable, function, and class renaming to improve code clarity --- engines/zvision/core/events.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index c66e61a61a..fe357c263b 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -194,7 +194,7 @@ void ZVision::processEvents() { case Common::KEYCODE_LEFT: case Common::KEYCODE_RIGHT: if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA) - _kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ? + _keyboardVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ? -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; break; @@ -202,7 +202,7 @@ void ZVision::processEvents() { case Common::KEYCODE_UP: case Common::KEYCODE_DOWN: if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT) - _kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_UP ? + _keyboardVelocity = (_event.kbd.keycode == Common::KEYCODE_UP ? -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; break; @@ -226,12 +226,12 @@ void ZVision::processEvents() { case Common::KEYCODE_LEFT: case Common::KEYCODE_RIGHT: if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA) - _kbdVelocity = 0; + _keyboardVelocity = 0; break; case Common::KEYCODE_UP: case Common::KEYCODE_DOWN: if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT) - _kbdVelocity = 0; + _keyboardVelocity = 0; break; default: break; -- cgit v1.2.3 From 808a2045b4a3b210f1f2512617fe1be41c5dc460 Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Fri, 19 Dec 2014 11:20:01 -0600 Subject: ZVISION: Fix code mis-alignment created from variable rename --- engines/zvision/core/events.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index fe357c263b..6cf0ae5d0d 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -195,16 +195,16 @@ void ZVision::processEvents() { case Common::KEYCODE_RIGHT: if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA) _keyboardVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ? - -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : - _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; + -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : + _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; break; case Common::KEYCODE_UP: case Common::KEYCODE_DOWN: if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT) _keyboardVelocity = (_event.kbd.keycode == Common::KEYCODE_UP ? - -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : - _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; + -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : + _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; break; default: -- cgit v1.2.3 From 965dafe31b1c1f7c4684c0d2cbdb3461e3fddac8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 21 Dec 2014 23:33:01 +0200 Subject: ZVISION: Implement the "dumpallscripts" console command again --- engines/zvision/core/console.cpp | 40 ++++++++++++++++++++++++++++++++-------- engines/zvision/core/console.h | 1 + 2 files changed, 33 insertions(+), 8 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 4dd10d6f40..0789f8d4fb 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -52,6 +52,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale)); registerCmd("location", WRAP_METHOD(Console, cmdLocation)); registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); + registerCmd("dumpallscripts", WRAP_METHOD(Console, cmdDumpAllScripts)); } bool Console::cmdLoadVideo(int argc, const char **argv) { @@ -205,6 +206,20 @@ bool Console::cmdLocation(int argc, const char **argv) { return true; } +void dumpFile(Common::SeekableReadStream *s, const char *outName) { + byte *buffer = new byte[s->size()]; + s->read(buffer, s->size()); + + Common::DumpFile dumpFile; + dumpFile.open(outName); + + dumpFile.write(buffer, s->size()); + dumpFile.flush(); + dumpFile.close(); + + delete[] buffer; +} + bool Console::cmdDumpFile(int argc, const char **argv) { if (argc != 2) { debugPrintf("Use %s to dump a file\n", argv[0]); @@ -217,17 +232,26 @@ bool Console::cmdDumpFile(int argc, const char **argv) { return true; } - byte *buffer = new byte[f.size()]; - f.read(buffer, f.size()); + dumpFile(&f, argv[1]); - Common::DumpFile dumpFile; - dumpFile.open(argv[1]); + return true; +} - dumpFile.write(buffer, f.size()); - dumpFile.flush(); - dumpFile.close(); +bool Console::cmdDumpAllScripts(int argc, const char **argv) { + Common::String fileName; + Common::SeekableReadStream *in; - delete[] buffer; + SearchManager::MatchList fileList; + _engine->getSearchManager()->listMembersWithExtension(fileList, "scr"); + + for (SearchManager::MatchList::iterator iter = fileList.begin(); iter != fileList.end(); ++iter) { + fileName = iter->_value.name; + debugPrintf("Dumping %s\n", fileName.c_str()); + + in = iter->_value.arch->createReadStreamForMember(iter->_value.name); + dumpFile(in, fileName.c_str()); + delete in; + } return true; } diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h index 299bd6127f..7e27fe8f26 100644 --- a/engines/zvision/core/console.h +++ b/engines/zvision/core/console.h @@ -46,6 +46,7 @@ private: bool cmdSetPanoramaScale(int argc, const char **argv); bool cmdLocation(int argc, const char **argv); bool cmdDumpFile(int argc, const char **argv); + bool cmdDumpAllScripts(int argc, const char **argv); }; } // End of namespace ZVision -- cgit v1.2.3 From dfae161386a2ad9e6828f71e90dd19598ca52f36 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 22 Dec 2014 00:26:53 +0200 Subject: ZVISION: Implement the Venus hint system in Zork: Nemesis --- engines/zvision/core/events.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 6cf0ae5d0d..f0cf3f0789 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -145,6 +145,11 @@ void ZVision::cheatCodes(uint8 key) { getBufferedKey(2), getBufferedKey(1), getBufferedKey(0), 0); + + // Show the Venus screen when "?" or "/" is pressed while inside the temple world + if (_scriptManager->getStateValue(StateKey_VenusEnable) == 1) + if ((checkCode("?") || checkCode("/")) && _scriptManager->getStateValue(StateKey_World) == 't') + _scriptManager->changeLocation('g', 'j', 'h', 'e', 0); } void ZVision::processEvents() { -- cgit v1.2.3 From 41dbbe346c4b46b4b48cdb38687216b1dd254fb4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 22 Dec 2014 00:29:19 +0200 Subject: ZVISION: Also allow the movement when the cursor is within screen edges This matches the behavior of the original in Zork: Nemesis. ZGI already fills the screen horizontally --- engines/zvision/core/events.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index f0cf3f0789..81ad28f29b 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -284,26 +284,30 @@ void ZVision::onMouseMove(const Common::Point &pos) { // | // ^ - if (_workingWindow.contains(pos)) { - cursorWasChanged = _scriptManager->onMouseMove(pos, imageCoord); + // Clip the horizontal mouse position to the working window + Common::Point clippedPos = pos; + clippedPos.x = CLIP(pos.x, _workingWindow.left + 1, _workingWindow.right - 1); + + if (_workingWindow.contains(clippedPos)) { + cursorWasChanged = _scriptManager->onMouseMove(clippedPos, imageCoord); RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState(); if (renderState == RenderTable::PANORAMA) { - if (pos.x >= _workingWindow.left && pos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) { + if (clippedPos.x >= _workingWindow.left && clippedPos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _mouseVelocity = (((pos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((clippedPos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; - } else if (pos.x <= _workingWindow.right && pos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) { + } else if (clippedPos.x <= _workingWindow.right && clippedPos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _mouseVelocity = (((pos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((clippedPos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; @@ -311,21 +315,21 @@ void ZVision::onMouseMove(const Common::Point &pos) { _mouseVelocity = 0; } } else if (renderState == RenderTable::TILT) { - if (pos.y >= _workingWindow.top && pos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) { + if (clippedPos.y >= _workingWindow.top && clippedPos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _mouseVelocity = (((pos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((clippedPos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; - } else if (pos.y <= _workingWindow.bottom && pos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) { + } else if (clippedPos.y <= _workingWindow.bottom && clippedPos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _mouseVelocity = (((pos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((clippedPos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; -- cgit v1.2.3 From b0e6c30ee288130d6b904a6f770044564b0490e6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 22 Dec 2014 00:45:34 +0200 Subject: ZVISION: Fix Venus key code handling in commit dfae161 --- engines/zvision/core/events.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 81ad28f29b..6e8cf1fe4f 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -148,7 +148,7 @@ void ZVision::cheatCodes(uint8 key) { // Show the Venus screen when "?" or "/" is pressed while inside the temple world if (_scriptManager->getStateValue(StateKey_VenusEnable) == 1) - if ((checkCode("?") || checkCode("/")) && _scriptManager->getStateValue(StateKey_World) == 't') + if (getBufferedKey(0) == 0xBF && _scriptManager->getStateValue(StateKey_World) == 't') _scriptManager->changeLocation('g', 'j', 'h', 'e', 0); } -- cgit v1.2.3 From c2d83d287faec2bdfd6fac7d665c156670c7b7f7 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 22 Dec 2014 02:50:34 +0200 Subject: ZVISION: Allow dumping any file type via the new "dumpfiles" command --- engines/zvision/core/console.cpp | 11 ++++++++--- engines/zvision/core/console.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 0789f8d4fb..07d3114ec8 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -52,7 +52,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale)); registerCmd("location", WRAP_METHOD(Console, cmdLocation)); registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); - registerCmd("dumpallscripts", WRAP_METHOD(Console, cmdDumpAllScripts)); + registerCmd("dumpfiles", WRAP_METHOD(Console, cmdDumpFiles)); } bool Console::cmdLoadVideo(int argc, const char **argv) { @@ -237,12 +237,17 @@ bool Console::cmdDumpFile(int argc, const char **argv) { return true; } -bool Console::cmdDumpAllScripts(int argc, const char **argv) { +bool Console::cmdDumpFiles(int argc, const char **argv) { Common::String fileName; Common::SeekableReadStream *in; + if (argc != 2) { + debugPrintf("Use %s to dump all files with a specific extension\n", argv[0]); + return true; + } + SearchManager::MatchList fileList; - _engine->getSearchManager()->listMembersWithExtension(fileList, "scr"); + _engine->getSearchManager()->listMembersWithExtension(fileList, argv[1]); for (SearchManager::MatchList::iterator iter = fileList.begin(); iter != fileList.end(); ++iter) { fileName = iter->_value.name; diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h index 7e27fe8f26..a7bd88ebc3 100644 --- a/engines/zvision/core/console.h +++ b/engines/zvision/core/console.h @@ -46,7 +46,7 @@ private: bool cmdSetPanoramaScale(int argc, const char **argv); bool cmdLocation(int argc, const char **argv); bool cmdDumpFile(int argc, const char **argv); - bool cmdDumpAllScripts(int argc, const char **argv); + bool cmdDumpFiles(int argc, const char **argv); }; } // End of namespace ZVision -- cgit v1.2.3 From 11cb47e89772ea59fc55d2801685d1a3505235a0 Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Tue, 23 Dec 2014 00:25:42 -0600 Subject: ZVISION: Remove unnecessary math --- engines/zvision/core/events.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 6e8cf1fe4f..72e7f33266 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -296,18 +296,20 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (clippedPos.x >= _workingWindow.left && clippedPos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - if (mspeed <= 0) - mspeed = 400 >> 4; _mouseVelocity = (((clippedPos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + if (mspeed <= 0) { + mspeed = 25; + } _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; } else if (clippedPos.x <= _workingWindow.right && clippedPos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - if (mspeed <= 0) - mspeed = 400 >> 4; _mouseVelocity = (((clippedPos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + if (mspeed <= 0) { + mspeed = 25; + } _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; @@ -318,18 +320,20 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (clippedPos.y >= _workingWindow.top && clippedPos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - if (mspeed <= 0) - mspeed = 400 >> 4; _mouseVelocity = (((clippedPos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + if (mspeed <= 0) { + mspeed = 25; + } _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; } else if (clippedPos.y <= _workingWindow.bottom && clippedPos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - if (mspeed <= 0) - mspeed = 400 >> 4; _mouseVelocity = (((clippedPos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + if (mspeed <= 0) { + mspeed = 25; + } _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; -- cgit v1.2.3 From 6548300a4182e1dc805b390678df800b05d07554 Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Tue, 23 Dec 2014 00:27:53 -0600 Subject: ZVISION: Use Common::Rational to simplify fixed point math --- engines/zvision/core/events.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 72e7f33266..ccd7772975 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -296,20 +296,21 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (clippedPos.x >= _workingWindow.left && clippedPos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - _mouseVelocity = (((clippedPos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; if (mspeed <= 0) { mspeed = 25; } + _mouseVelocity = ((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt(); + _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; } else if (clippedPos.x <= _workingWindow.right && clippedPos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - _mouseVelocity = (((clippedPos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; if (mspeed <= 0) { mspeed = 25; } + _mouseVelocity = (Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET)).toInt(); _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; @@ -320,20 +321,20 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (clippedPos.y >= _workingWindow.top && clippedPos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - _mouseVelocity = (((clippedPos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; if (mspeed <= 0) { mspeed = 25; } + _mouseVelocity = ((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - mspeed).toInt(); _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; } else if (clippedPos.y <= _workingWindow.bottom && clippedPos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - _mouseVelocity = (((clippedPos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; if (mspeed <= 0) { mspeed = 25; } + _mouseVelocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET)).toInt(); _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; -- cgit v1.2.3 From 40bd4c485f9ab24e667e66a047214eb7dcef73e8 Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Tue, 23 Dec 2014 00:38:44 -0600 Subject: ZVISION: Clamp the rotation velocity to never be zero Before, if we set the in-game preferences to have very low rotation speed, the velocity ends up always being 0 - 0.99 Hence, when we convert back to an int, everything gets truncated to zero. Therefore, we clamp, in order to ensure the user can always move, no matter which setting they use. --- engines/zvision/core/events.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index ccd7772975..1920ffd769 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -299,7 +299,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (mspeed <= 0) { mspeed = 25; } - _mouseVelocity = ((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt(); + _mouseVelocity = MIN(((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt(), -1); _cursorManager->changeCursor(CursorIndex_Left); @@ -310,7 +310,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (mspeed <= 0) { mspeed = 25; } - _mouseVelocity = (Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET)).toInt(); + _mouseVelocity = MAX((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET)).toInt(), 1); _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; @@ -324,7 +324,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (mspeed <= 0) { mspeed = 25; } - _mouseVelocity = ((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - mspeed).toInt(); + _mouseVelocity = MIN(((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - mspeed).toInt(), -1); _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; @@ -334,7 +334,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (mspeed <= 0) { mspeed = 25; } - _mouseVelocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET)).toInt(); + _mouseVelocity = MAX((Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET)).toInt(), 1); _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; -- cgit v1.2.3 From dbbcf641874ace35b871226664370413de176c37 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 25 Dec 2014 21:17:47 +0200 Subject: ZVISION: Use the search manager to open files in console commands --- engines/zvision/core/console.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 07d3114ec8..c7592c8d9d 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -79,12 +79,14 @@ bool Console::cmdLoadSound(int argc, const char **argv) { Audio::AudioStream *soundStream = makeRawZorkStream(argv[1], _engine); Audio::SoundHandle handle; _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false); - } else if (argc == 4) { int isStereo = atoi(argv[3]); Common::File *file = new Common::File(); - file->open(argv[1]); + if (!_engine->getSearchManager()->openFile(*file, argv[1])) { + warning("File not found: %s", argv[1]); + return true; + } Audio::AudioStream *soundStream = makeRawZorkStream(file, atoi(argv[2]), isStereo == 0 ? false : true); Audio::SoundHandle handle; @@ -104,8 +106,10 @@ bool Console::cmdRawToWav(int argc, const char **argv) { } Common::File file; - if (!file.open(argv[1])) + if (!_engine->getSearchManager()->openFile(file, argv[1])) { + warning("File not found: %s", argv[1]); return true; + } Audio::AudioStream *audioStream = makeRawZorkStream(argv[1], _engine); -- cgit v1.2.3 From 6368a6ea91364f90bcb0d5d9d88826d856181a52 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 25 Dec 2014 22:00:55 +0200 Subject: ZVISION: Move the menu code together with the other scripting code --- engines/zvision/core/events.cpp | 2 +- engines/zvision/core/menu.cpp | 765 ---------------------------------------- engines/zvision/core/menu.h | 125 ------- 3 files changed, 1 insertion(+), 891 deletions(-) delete mode 100644 engines/zvision/core/menu.cpp delete mode 100644 engines/zvision/core/menu.h (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 1920ffd769..89f1595460 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -28,7 +28,7 @@ #include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/scripting/script_manager.h" -#include "zvision/core/menu.h" +#include "zvision/scripting/menu.h" #include "zvision/sound/zork_raw.h" #include "common/events.h" diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp deleted file mode 100644 index 31e0d71370..0000000000 --- a/engines/zvision/core/menu.cpp +++ /dev/null @@ -1,765 +0,0 @@ -/* 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 "common/scummsys.h" - -#include "zvision/core/menu.h" - -#include "zvision/graphics/render_manager.h" - -namespace ZVision { - -enum { - SLOT_START_SLOT = 151, - SLOT_SPELL_1 = 191, - SLOT_USER_CHOSE_THIS_SPELL = 205, - SLOT_REVERSED_SPELLBOOK = 206 -}; - -enum { - menu_MAIN_SAVE = 0, - menu_MAIN_REST = 1, - menu_MAIN_PREF = 2, - menu_MAIN_EXIT = 3 -}; - -MenuHandler::MenuHandler(ZVision *engine) { - _engine = engine; - menuBarFlag = 0xFFFF; -} - -MenuZGI::MenuZGI(ZVision *engine) : - MenuHandler(engine) { - menuMouseFocus = -1; - inmenu = false; - scrolled[0] = false; - scrolled[1] = false; - scrolled[2] = false; - scrollPos[0] = 0.0; - scrollPos[1] = 0.0; - scrollPos[2] = 0.0; - mouseOnItem = -1; - redraw = false; - clean = false; - - char buf[24]; - for (int i = 1; i < 4; i++) { - sprintf(buf, "gmzau%2.2x1.tga", i); - _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][0], false); - sprintf(buf, "gmzau%2.2x1.tga", i + 0x10); - _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][1], false); - } - for (int i = 0; i < 4; i++) { - sprintf(buf, "gmzmu%2.2x1.tga", i); - _engine->getRenderManager()->readImageToSurface(buf, menubar[i][0], false); - sprintf(buf, "gmznu%2.2x1.tga", i); - _engine->getRenderManager()->readImageToSurface(buf, menubar[i][1], false); - } - - for (int i = 0; i < 50; i++) { - items[i][0] = NULL; - items[i][1] = NULL; - itemId[i] = 0; - } - - for (int i = 0; i < 12; i++) { - magic[i][0] = NULL; - magic[i][1] = NULL; - magicId[i] = 0; - } -} - -MenuZGI::~MenuZGI() { - for (int i = 0; i < 3; i++) { - menuback[i][0].free(); - menuback[i][1].free(); - } - for (int i = 0; i < 4; i++) { - menubar[i][0].free(); - menubar[i][1].free(); - } - for (int i = 0; i < 50; i++) { - if (items[i][0]) { - items[i][0]->free(); - delete items[i][0]; - } - if (items[i][1]) { - items[i][1]->free(); - delete items[i][1]; - } - } - for (int i = 0; i < 12; i++) { - if (magic[i][0]) { - magic[i][0]->free(); - delete magic[i][0]; - } - if (magic[i][1]) { - magic[i][1]->free(); - delete magic[i][1]; - } - } -} - -void MenuZGI::onMouseUp(const Common::Point &Pos) { - if (Pos.y < 40) { - switch (menuMouseFocus) { - case menu_ITEM: - if (menuBarFlag & menuBar_Items) { - int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (itemCount == 0) - itemCount = 20; - - for (int i = 0; i < itemCount; i++) { - int itemspace = (600 - 28) / itemCount; - - if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, - scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { - int32 mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); - if (mouseItem >= 0 && mouseItem < 0xE0) { - _engine->getScriptManager()->inventoryDrop(mouseItem); - _engine->getScriptManager()->inventoryAdd(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i)); - _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouseItem); - - redraw = true; - } - } - } - } - break; - - case menu_MAGIC: - if (menuBarFlag & menuBar_Magic) { - for (int i = 0; i < 12; i++) { - - uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); - if (itemnum != 0) { - if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) - itemnum = 0xEE + i; - else - itemnum = 0xE0 + i; - } - if (itemnum) - if (_engine->getScriptManager()->getStateValue(StateKey_InventoryItem) == 0 || _engine->getScriptManager()->getStateValue(StateKey_InventoryItem) >= 0xE0) - if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, - 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) - _engine->getScriptManager()->setStateValue(SLOT_USER_CHOSE_THIS_SPELL, itemnum); - } - - } - break; - - case menu_MAIN: - - // Exit - if (menuBarFlag & menuBar_Exit) - if (Common::Rect(320 + 135, - scrollPos[menu_MAIN], - 320 + 135 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - _engine->ifQuit(); - } - - // Settings - if (menuBarFlag & menuBar_Settings) - if (Common::Rect(320 , - scrollPos[menu_MAIN], - 320 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); - } - - // Load - if (menuBarFlag & menuBar_Restore) - if (Common::Rect(320 - 135, - scrollPos[menu_MAIN], - 320, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); - } - - // Save - if (menuBarFlag & menuBar_Save) - if (Common::Rect(320 - 135 * 2, - scrollPos[menu_MAIN], - 320 - 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); - } - break; - } - } -} - -void MenuZGI::onMouseMove(const Common::Point &Pos) { - if (Pos.y < 40) { - - if (!inmenu) - redraw = true; - inmenu = true; - switch (menuMouseFocus) { - case menu_ITEM: - if (menuBarFlag & menuBar_Items) { - int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (itemCount == 0) - itemCount = 20; - else if (itemCount > 50) - itemCount = 50; - - int lastItem = mouseOnItem; - - mouseOnItem = -1; - - for (int i = 0; i < itemCount; i++) { - int itemspace = (600 - 28) / itemCount; - - if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, - scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { - mouseOnItem = i; - break; - } - } - - if (lastItem != mouseOnItem) - if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouseOnItem) || - _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + lastItem)) - redraw = true; - } - break; - - case menu_MAGIC: - if (menuBarFlag & menuBar_Magic) { - int lastItem = mouseOnItem; - mouseOnItem = -1; - for (int i = 0; i < 12; i++) { - if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, - 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) { - mouseOnItem = i; - break; - } - } - - if (lastItem != mouseOnItem) - if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouseOnItem) || - _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + lastItem)) - redraw = true; - - } - break; - - case menu_MAIN: { - int lastItem = mouseOnItem; - mouseOnItem = -1; - - // Exit - if (menuBarFlag & menuBar_Exit) - if (Common::Rect(320 + 135, - scrollPos[menu_MAIN], - 320 + 135 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_EXIT; - } - - // Settings - if (menuBarFlag & menuBar_Settings) - if (Common::Rect(320 , - scrollPos[menu_MAIN], - 320 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_PREF; - } - - // Load - if (menuBarFlag & menuBar_Restore) - if (Common::Rect(320 - 135, - scrollPos[menu_MAIN], - 320, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_REST; - } - - // Save - if (menuBarFlag & menuBar_Save) - if (Common::Rect(320 - 135 * 2, - scrollPos[menu_MAIN], - 320 - 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_SAVE; - } - - if (lastItem != mouseOnItem) - redraw = true; - } - break; - - default: - int cur_menu = menuMouseFocus; - if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main - menuMouseFocus = menu_MAIN; - scrolled[menu_MAIN] = false; - scrollPos[menu_MAIN] = menuback[menu_MAIN][1].h - menuback[menu_MAIN][0].h; - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); - } - - if (menuBarFlag & menuBar_Magic) - if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic - menuMouseFocus = menu_MAGIC; - scrolled[menu_MAGIC] = false; - scrollPos[menu_MAGIC] = 28; - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 3); - } - - if (menuBarFlag & menuBar_Items) - if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items - menuMouseFocus = menu_ITEM; - scrolled[menu_ITEM] = false; - scrollPos[menu_ITEM] = 28 - 600; - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 1); - } - - if (cur_menu != menuMouseFocus) - clean = true; - - break; - } - } else { - if (inmenu) - clean = true; - inmenu = false; - if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); - menuMouseFocus = -1; - } -} - -void MenuZGI::process(uint32 deltatime) { - if (clean) { - _engine->getRenderManager()->clearMenuSurface(); - clean = false; - } - switch (menuMouseFocus) { - case menu_ITEM: - if (menuBarFlag & menuBar_Items) - if (!scrolled[menu_ITEM]) { - redraw = true; - float scrl = 600.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - scrollPos [menu_ITEM] += scrl; - - if (scrollPos[menu_ITEM] >= 0) { - scrolled[menu_ITEM] = true; - scrollPos [menu_ITEM] = 0; - } - } - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0); - - int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (itemCount == 0) - itemCount = 20; - else if (itemCount > 50) - itemCount = 50; - - for (int i = 0; i < itemCount; i++) { - int itemspace = (600 - 28) / itemCount; - - bool inrect = false; - - if (mouseOnItem == i) - inrect = true; - - uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i); - - if (curItemId != 0) { - if (itemId[i] != curItemId) { - char buf[16]; - sprintf(buf, "gmzwu%2.2x1.tga", curItemId); - items[i][0] = _engine->getRenderManager()->loadImage(buf, false); - sprintf(buf, "gmzxu%2.2x1.tga", curItemId); - items[i][1] = _engine->getRenderManager()->loadImage(buf, false); - itemId[i] = curItemId; - } - - if (inrect) - _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[menu_ITEM] + itemspace * i, 0, 0); - else - _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[menu_ITEM] + itemspace * i, 0, 0); - - } else { - if (items[i][0]) { - items[i][0]->free(); - delete items[i][0]; - items[i][0] = NULL; - } - if (items[i][1]) { - items[i][1]->free(); - delete items[i][1]; - items[i][1] = NULL; - } - itemId[i] = 0; - } - } - - redraw = false; - } - break; - - case menu_MAGIC: - if (menuBarFlag & menuBar_Magic) - if (!scrolled[menu_MAGIC]) { - redraw = true; - float scrl = 600.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - scrollPos [menu_MAGIC] += scrl; - - if (scrollPos[menu_MAGIC] >= 600) { - scrolled[menu_MAGIC] = true; - scrollPos [menu_MAGIC] = 600; - } - } - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][0], 640 - scrollPos[menu_MAGIC], 0); - - for (int i = 0; i < 12; i++) { - bool inrect = false; - - if (mouseOnItem == i) - inrect = true; - - uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); - if (curItemId) { - if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) - curItemId = 0xEE + i; - else - curItemId = 0xE0 + i; - } - - if (curItemId != 0) { - if (itemId[i] != curItemId) { - char buf[16]; - sprintf(buf, "gmzwu%2.2x1.tga", curItemId); - magic[i][0] = _engine->getRenderManager()->loadImage(buf, false); - sprintf(buf, "gmzxu%2.2x1.tga", curItemId); - magic[i][1] = _engine->getRenderManager()->loadImage(buf, false); - magicId[i] = curItemId; - } - - if (inrect) - _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); - else - _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); - - } else { - if (magic[i][0]) { - magic[i][0]->free(); - delete magic[i][0]; - magic[i][0] = NULL; - } - if (magic[i][1]) { - magic[i][1]->free(); - delete magic[i][1]; - magic[i][1] = NULL; - } - magicId[i] = 0; - } - } - redraw = false; - } - break; - - case menu_MAIN: - if (!scrolled[menu_MAIN]) { - redraw = true; - float scrl = 32.0 * 2.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - scrollPos [menu_MAIN] += scrl; - - if (scrollPos[menu_MAIN] >= 0) { - scrolled[menu_MAIN] = true; - scrollPos [menu_MAIN] = 0; - } - } - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]); - - if (menuBarFlag & menuBar_Exit) { - if (mouseOnItem == menu_MAIN_EXIT) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]); - else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]); - } - if (menuBarFlag & menuBar_Settings) { - if (mouseOnItem == menu_MAIN_PREF) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]); - else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]); - } - if (menuBarFlag & menuBar_Restore) { - if (mouseOnItem == menu_MAIN_REST) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]); - else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]); - } - if (menuBarFlag & menuBar_Save) { - if (mouseOnItem == menu_MAIN_SAVE) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]); - else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]); - } - redraw = false; - } - break; - default: - if (redraw) { - if (inmenu) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0); - - if (menuBarFlag & menuBar_Items) - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0); - - if (menuBarFlag & menuBar_Magic) - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0); - } - redraw = false; - } - break; - } -} - -MenuNemesis::MenuNemesis(ZVision *engine) : - MenuHandler(engine) { - inmenu = false; - scrolled = false; - scrollPos = 0.0; - mouseOnItem = -1; - redraw = false; - delay = 0; - - char buf[24]; - for (int i = 0; i < 4; i++) - for (int j = 0; j < 6; j++) { - sprintf(buf, "butfrm%d%d.tga", i + 1, j); - _engine->getRenderManager()->readImageToSurface(buf, but[i][j], false); - } - - _engine->getRenderManager()->readImageToSurface("bar.tga", menubar, false); - - frm = 0; -} - -MenuNemesis::~MenuNemesis() { - for (int i = 0; i < 4; i++) - for (int j = 0; j < 6; j++) - but[i][j].free(); - - menubar.free(); -} - -static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} }; - -void MenuNemesis::onMouseUp(const Common::Point &Pos) { - if (Pos.y < 40) { - // Exit - if (menuBarFlag & menuBar_Exit) - if (Common::Rect(buts[3][1], - scrollPos, - buts[3][0] + buts[3][1], - scrollPos + 32).contains(Pos)) { - _engine->ifQuit(); - frm = 5; - redraw = true; - } - - // Settings - if (menuBarFlag & menuBar_Settings) - if (Common::Rect(buts[2][1], - scrollPos, - buts[2][0] + buts[2][1], - scrollPos + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); - frm = 5; - redraw = true; - } - - // Load - if (menuBarFlag & menuBar_Restore) - if (Common::Rect(buts[1][1], - scrollPos, - buts[1][0] + buts[1][1], - scrollPos + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); - frm = 5; - redraw = true; - } - - // Save - if (menuBarFlag & menuBar_Save) - if (Common::Rect(buts[0][1], - scrollPos, - buts[0][0] + buts[0][1], - scrollPos + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); - frm = 5; - redraw = true; - } - } -} - -void MenuNemesis::onMouseMove(const Common::Point &Pos) { - if (Pos.y < 40) { - - inmenu = true; - - if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2) - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); - - int lastItem = mouseOnItem; - mouseOnItem = -1; - - // Exit - if (menuBarFlag & menuBar_Exit) - if (Common::Rect(buts[3][1], - scrollPos, - buts[3][0] + buts[3][1], - scrollPos + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_EXIT; - } - - // Settings - if (menuBarFlag & menuBar_Settings) - if (Common::Rect(buts[2][1], - scrollPos, - buts[2][0] + buts[2][1], - scrollPos + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_PREF; - } - - // Load - if (menuBarFlag & menuBar_Restore) - if (Common::Rect(buts[1][1], - scrollPos, - buts[1][0] + buts[1][1], - scrollPos + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_REST; - } - - // Save - if (menuBarFlag & menuBar_Save) - if (Common::Rect(buts[0][1], - scrollPos, - buts[0][0] + buts[0][1], - scrollPos + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_SAVE; - } - - if (lastItem != mouseOnItem) { - redraw = true; - frm = 0; - delay = 200; - } - } else { - inmenu = false; - if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); - mouseOnItem = -1; - } -} - -void MenuNemesis::process(uint32 deltatime) { - if (inmenu) { - if (!scrolled) { - float scrl = 32.0 * 2.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - scrollPos += scrl; - redraw = true; - } - - if (scrollPos >= 0) { - scrolled = true; - scrollPos = 0; - } - - if (mouseOnItem != -1) { - delay -= deltatime; - if (delay <= 0 && frm < 4) { - delay = 200; - frm++; - redraw = true; - } - } - - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); - - if (menuBarFlag & menuBar_Exit) - if (mouseOnItem == menu_MAIN_EXIT) - _engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos); - - if (menuBarFlag & menuBar_Settings) - if (mouseOnItem == menu_MAIN_PREF) - _engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos); - - if (menuBarFlag & menuBar_Restore) - if (mouseOnItem == menu_MAIN_REST) - _engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos); - - if (menuBarFlag & menuBar_Save) - if (mouseOnItem == menu_MAIN_SAVE) - _engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos); - - redraw = false; - } - } else { - scrolled = false; - if (scrollPos > -32) { - float scrl = 32.0 * 2.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - Common::Rect cl(64, 32 + scrollPos - scrl, 64 + 512, 32 + scrollPos + 1); - _engine->getRenderManager()->clearMenuSurface(cl); - - scrollPos -= scrl; - redraw = true; - } else - scrollPos = -32; - - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); - redraw = false; - } - } -} - -} // End of namespace ZVision diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h deleted file mode 100644 index ebe0bb50ac..0000000000 --- a/engines/zvision/core/menu.h +++ /dev/null @@ -1,125 +0,0 @@ -/* 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. - * - */ - -#ifndef ZVISION_MENU_H -#define ZVISION_MENU_H - -#include "graphics/surface.h" -#include "common/rect.h" - -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" - -namespace ZVision { - -enum menuBar { - menuBar_Exit = 0x1, - menuBar_Settings = 0x2, - menuBar_Restore = 0x4, - menuBar_Save = 0x8, - menuBar_Items = 0x100, - menuBar_Magic = 0x200 -}; - -class MenuHandler { -public: - MenuHandler(ZVision *engine); - virtual ~MenuHandler() {}; - virtual void onMouseMove(const Common::Point &Pos) {}; - virtual void onMouseDown(const Common::Point &Pos) {}; - virtual void onMouseUp(const Common::Point &Pos) {}; - virtual void process(uint32 deltaTimeInMillis) {}; - - void setEnable(uint16 flags) { - menuBarFlag = flags; - } - uint16 getEnable() { - return menuBarFlag; - } -protected: - uint16 menuBarFlag; - ZVision *_engine; -}; - -class MenuZGI: public MenuHandler { -public: - MenuZGI(ZVision *engine); - ~MenuZGI(); - void onMouseMove(const Common::Point &Pos); - void onMouseUp(const Common::Point &Pos); - void process(uint32 deltaTimeInMillis); -private: - Graphics::Surface menuback[3][2]; - Graphics::Surface menubar[4][2]; - Graphics::Surface *items[50][2]; - uint itemId[50]; - - Graphics::Surface *magic[12][2]; - uint magicId[12]; - - int menuMouseFocus; - bool inmenu; - - int mouseOnItem; - - bool scrolled[3]; - int16 scrollPos[3]; - - enum { - menu_ITEM = 0, - menu_MAGIC = 1, - menu_MAIN = 2 - }; - - bool clean; - bool redraw; - -}; - -class MenuNemesis: public MenuHandler { -public: - MenuNemesis(ZVision *engine); - ~MenuNemesis(); - void onMouseMove(const Common::Point &Pos); - void onMouseUp(const Common::Point &Pos); - void process(uint32 deltaTimeInMillis); -private: - Graphics::Surface but[4][6]; - Graphics::Surface menubar; - - bool inmenu; - - int mouseOnItem; - - bool scrolled; - int16 scrollPos; - - bool redraw; - - int frm; - int16 delay; - -}; - -} - -#endif -- cgit v1.2.3 From 3661bc4cf13ac9bb27e60969b4195acc82fee6c5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 25 Dec 2014 22:11:29 +0200 Subject: ZVISION: Normalize and cleanup all the menu-related enums --- engines/zvision/core/events.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 89f1595460..227cf213dc 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -43,19 +43,19 @@ void ZVision::shortKeys(Common::Event event) { if (event.kbd.hasFlags(Common::KBD_CTRL)) { switch (event.kbd.keycode) { case Common::KEYCODE_s: - if (getMenuBarEnable() & menuBar_Save) + if (getMenuBarEnable() & kMenubarSave) _scriptManager->changeLocation('g', 'j', 's', 'e', 0); break; case Common::KEYCODE_r: - if (getMenuBarEnable() & menuBar_Restore) + if (getMenuBarEnable() & kMenubarRestore) _scriptManager->changeLocation('g', 'j', 'r', 'e', 0); break; case Common::KEYCODE_p: - if (getMenuBarEnable() & menuBar_Settings) + if (getMenuBarEnable() & kMenubarSettings) _scriptManager->changeLocation('g', 'j', 'p', 'e', 0); break; case Common::KEYCODE_q: - if (getMenuBarEnable() & menuBar_Exit) + if (getMenuBarEnable() & kMenubarExit) ifQuit(); break; default: -- cgit v1.2.3 From 00a252fdc561b31379ddc5f568121b8040986add Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 03:58:37 +0200 Subject: ZVISION: Slight cleanup --- engines/zvision/core/save_manager.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 20bd39fde5..b45742154d 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -78,9 +78,6 @@ bool SaveManager::scummVMSaveLoadDialog(bool isSave) { } void SaveManager::saveGame(uint slot, const Common::String &saveName) { - // The games only support 20 slots - //assert(slot <= 1 && slot <= 20); - Common::SaveFileManager *saveFileManager = g_system->getSavefileManager(); Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot)); @@ -124,7 +121,6 @@ void SaveManager::autoSave() { } void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName) { - file->writeUint32BE(SAVEGAME_ID); // Write version @@ -148,9 +144,6 @@ void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::S } Common::Error SaveManager::loadGame(uint slot) { - // The games only support 20 slots - //assert(slot <= 1 && slot <= 20); - Common::SeekableReadStream *saveFile = getSlotFile(slot); if (saveFile == 0) { return Common::kPathDoesNotExist; @@ -226,7 +219,13 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea // Check that the save version isn't newer than this binary if (header.version > SAVE_VERSION) { uint tempVersion = header.version; - GUI::MessageDialog dialog(Common::String::format("This save file uses version %u, but this engine only supports up to version %d. You will need an updated version of the engine to use this save file.", tempVersion, SAVE_VERSION), "OK"); + GUI::MessageDialog dialog( + Common::String::format( + "This save file uses version %u, but this engine only " + "supports up to version %d. You will need an updated version " + "of the engine to use this save file.", tempVersion, SAVE_VERSION + ), + "OK"); dialog.runModal(); } -- cgit v1.2.3 From 4d0ebfaa2285e2741a134db36fb4f5bd0317784d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 04:03:20 +0200 Subject: ZVISION: Move the save manager together with the other file classes --- engines/zvision/core/save_manager.cpp | 294 ---------------------------------- engines/zvision/core/save_manager.h | 106 ------------ 2 files changed, 400 deletions(-) delete mode 100644 engines/zvision/core/save_manager.cpp delete mode 100644 engines/zvision/core/save_manager.h (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp deleted file mode 100644 index b45742154d..0000000000 --- a/engines/zvision/core/save_manager.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/* 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 "common/scummsys.h" - -#include "zvision/core/save_manager.h" -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/graphics/render_manager.h" - -#include "common/system.h" -#include "common/translation.h" - -#include "graphics/surface.h" -#include "graphics/thumbnail.h" - -#include "gui/message.h" -#include "gui/saveload.h" - -namespace ZVision { - -const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G'); - -bool SaveManager::scummVMSaveLoadDialog(bool isSave) { - GUI::SaveLoadChooser *dialog; - Common::String desc; - int slot; - - if (isSave) { - dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); - - slot = dialog->runModalWithCurrentTarget(); - desc = dialog->getResultString(); - - if (desc.empty()) { - // create our own description for the saved game, the user didnt enter it - desc = dialog->createDefaultSaveDescription(slot); - } - - if (desc.size() > 28) - desc = Common::String(desc.c_str(), 28); - } else { - dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); - slot = dialog->runModalWithCurrentTarget(); - } - - delete dialog; - - if (slot < 0) - return false; - - if (isSave) { - saveGame(slot, desc); - return true; - } else { - Common::ErrorCode result = loadGame(slot).getCode(); - return (result == Common::kNoError); - } -} - -void SaveManager::saveGame(uint slot, const Common::String &saveName) { - Common::SaveFileManager *saveFileManager = g_system->getSavefileManager(); - Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot)); - - writeSaveGameHeader(file, saveName); - - _engine->getScriptManager()->serialize(file); - - file->finalize(); - delete file; -} - -void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream) { - Common::SaveFileManager *saveFileManager = g_system->getSavefileManager(); - Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot)); - - writeSaveGameHeader(file, saveName); - - file->write(stream->getData(), stream->size()); - - file->finalize(); - delete file; -} - -void SaveManager::saveGameBuffered(uint slot, const Common::String &saveName) { - if (_tempSave) { - saveGame(slot, saveName, _tempSave); - flushSaveBuffer(); - } -} - -void SaveManager::autoSave() { - Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName()); - - writeSaveGameHeader(file, "auto"); - - _engine->getScriptManager()->serialize(file); - - // Cleanup - file->finalize(); - delete file; -} - -void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName) { - file->writeUint32BE(SAVEGAME_ID); - - // Write version - file->writeByte(SAVE_VERSION); - - // Write savegame name - file->writeString(saveName); - file->writeByte(0); - - // Create a thumbnail and save it - Graphics::saveThumbnail(*file); - - // Write out the save date/time - TimeDate td; - g_system->getTimeAndDate(td); - file->writeSint16LE(td.tm_year + 1900); - file->writeSint16LE(td.tm_mon + 1); - file->writeSint16LE(td.tm_mday); - file->writeSint16LE(td.tm_hour); - file->writeSint16LE(td.tm_min); -} - -Common::Error SaveManager::loadGame(uint slot) { - Common::SeekableReadStream *saveFile = getSlotFile(slot); - if (saveFile == 0) { - return Common::kPathDoesNotExist; - } - - // Read the header - SaveGameHeader header; - if (!readSaveGameHeader(saveFile, header)) { - return Common::kUnknownError; - } - - ScriptManager *scriptManager = _engine->getScriptManager(); - // Update the state table values - scriptManager->deserialize(saveFile); - - delete saveFile; - if (header.thumbnail) - delete header.thumbnail; - - return Common::kNoError; -} - -Common::Error SaveManager::loadGame(const Common::String &saveName) { - Common::File *saveFile = _engine->getSearchManager()->openFile(saveName); - if (saveFile == NULL) { - saveFile = new Common::File; - if (!saveFile->open(saveName)) { - delete saveFile; - return Common::kPathDoesNotExist; - } - } - - // Read the header - SaveGameHeader header; - if (!readSaveGameHeader(saveFile, header)) { - return Common::kUnknownError; - } - - ScriptManager *scriptManager = _engine->getScriptManager(); - // Update the state table values - scriptManager->deserialize(saveFile); - - delete saveFile; - if (header.thumbnail) - delete header.thumbnail; - - return Common::kNoError; -} - -bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) { - uint32 tag = in->readUint32BE(); - // Check if it's original savegame than fill header structure - if (tag == MKTAG('Z', 'N', 'S', 'G')) { - header.saveYear = 0; - header.saveMonth = 0; - header.saveDay = 0; - header.saveHour = 0; - header.saveMinutes = 0; - header.saveName = "Original Save"; - header.thumbnail = NULL; - header.version = SAVE_ORIGINAL; - in->seek(-4, SEEK_CUR); - return true; - } - if (tag != SAVEGAME_ID) { - warning("File is not a ZVision save file. Aborting load"); - return false; - } - - // Read in the version - header.version = in->readByte(); - - // Check that the save version isn't newer than this binary - if (header.version > SAVE_VERSION) { - uint tempVersion = header.version; - GUI::MessageDialog dialog( - Common::String::format( - "This save file uses version %u, but this engine only " - "supports up to version %d. You will need an updated version " - "of the engine to use this save file.", tempVersion, SAVE_VERSION - ), - "OK"); - dialog.runModal(); - } - - // Read in the save name - header.saveName.clear(); - char ch; - while ((ch = (char)in->readByte()) != '\0') - header.saveName += ch; - - // Get the thumbnail - header.thumbnail = Graphics::loadThumbnail(*in); - if (!header.thumbnail) - return false; - - // Read in save date/time - header.saveYear = in->readSint16LE(); - header.saveMonth = in->readSint16LE(); - header.saveDay = in->readSint16LE(); - header.saveHour = in->readSint16LE(); - header.saveMinutes = in->readSint16LE(); - - return true; -} - -Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) { - Common::SeekableReadStream *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot)); - if (saveFile == NULL) { - // Try to load standard save file - Common::String filename; - if (_engine->getGameId() == GID_GRANDINQUISITOR) - filename = Common::String::format("inqsav%u.sav", slot); - else if (_engine->getGameId() == GID_NEMESIS) - filename = Common::String::format("nemsav%u.sav", slot); - - saveFile = _engine->getSearchManager()->openFile(filename); - if (saveFile == NULL) { - Common::File *tmpFile = new Common::File; - if (!tmpFile->open(filename)) { - delete tmpFile; - } else { - saveFile = tmpFile; - } - } - - } - - return saveFile; -} - -void SaveManager::prepareSaveBuffer() { - if (_tempSave) - delete _tempSave; - - _tempSave = new Common::MemoryWriteStreamDynamic; - - _engine->getScriptManager()->serialize(_tempSave); -} - -void SaveManager::flushSaveBuffer() { - if (_tempSave) - delete _tempSave; - - _tempSave = NULL; -} - -} // End of namespace ZVision diff --git a/engines/zvision/core/save_manager.h b/engines/zvision/core/save_manager.h deleted file mode 100644 index 75841331e7..0000000000 --- a/engines/zvision/core/save_manager.h +++ /dev/null @@ -1,106 +0,0 @@ -/* 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. - * - */ - -#ifndef ZVISION_SAVE_MANAGER_H -#define ZVISION_SAVE_MANAGER_H - -#include "common/savefile.h" -#include "common/memstream.h" - -namespace Common { -class String; -} - -namespace Graphics { -struct Surface; -} - -namespace ZVision { - -class ZVision; - -struct SaveGameHeader { - byte version; - Common::String saveName; - Graphics::Surface *thumbnail; - int saveYear, saveMonth, saveDay; - int saveHour, saveMinutes; -}; - -class SaveManager { -public: - SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL) {} - ~SaveManager() { - flushSaveBuffer(); - } - -private: - ZVision *_engine; - static const uint32 SAVEGAME_ID; - - enum { - SAVE_ORIGINAL = 0, - SAVE_VERSION = 1 - }; - - Common::MemoryWriteStreamDynamic *_tempSave; - -public: - /** - * Called every room change. Saves the state of the room just before - * we switched rooms. Uses ZVision::generateAutoSaveFileName() to - * create the save file name. - */ - void autoSave(); - /** - * Copies the data from the last auto-save into a new save file. We - * can't use the current state data because the save menu *IS* a room. - * The file is named using ZVision::generateSaveFileName(slot) - * - * @param slot The save slot this save pertains to. Must be [1, 20] - * @param saveName The internal name for this save. This is NOT the name of the actual save file. - */ - void saveGame(uint slot, const Common::String &saveName); - void saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream); - void saveGameBuffered(uint slot, const Common::String &saveName); - /** - * Loads the state data from the save file that slot references. Uses - * ZVision::generateSaveFileName(slot) to get the save file name. - * - * @param slot The save slot to load. Must be [1, 20] - */ - Common::Error loadGame(uint slot); - Common::Error loadGame(const Common::String &saveName); - - Common::SeekableReadStream *getSlotFile(uint slot); - bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header); - - void prepareSaveBuffer(); - void flushSaveBuffer(); - bool scummVMSaveLoadDialog(bool isSave); -private: - void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName); -}; - -} // End of namespace ZVision - -#endif -- cgit v1.2.3 From 5a72eea2bb102bafb6da112ea90ad1f4af11e1f2 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 12:41:36 +0200 Subject: ZVISION: Move some event/rendering code out of the main engine code --- engines/zvision/core/events.cpp | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 227cf213dc..70fd425949 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -39,6 +39,33 @@ namespace ZVision { +void ZVision::pushKeyToCheatBuf(uint8 key) { + for (int i = 0; i < KEYBUF_SIZE - 1; i++) + _cheatBuffer[i] = _cheatBuffer[i + 1]; + + _cheatBuffer[KEYBUF_SIZE - 1] = key; +} + +bool ZVision::checkCode(const char *code) { + int codeLen = strlen(code); + + if (codeLen > KEYBUF_SIZE) + return false; + + for (int i = 0; i < codeLen; i++) + if (code[i] != _cheatBuffer[KEYBUF_SIZE - codeLen + i] && code[i] != '?') + return false; + + return true; +} + +uint8 ZVision::getBufferedKey(uint8 pos) { + if (pos >= KEYBUF_SIZE) + return 0; + else + return _cheatBuffer[KEYBUF_SIZE - pos - 1]; +} + void ZVision::shortKeys(Common::Event event) { if (event.kbd.hasFlags(Common::KBD_CTRL)) { switch (event.kbd.keycode) { @@ -70,11 +97,11 @@ void ZVision::cheatCodes(uint8 key) { if (getGameId() == GID_GRANDINQUISITOR) { if (checkCode("IMNOTDEAF")) { // Unknown cheat - showDebugMsg(Common::String::format("IMNOTDEAF cheat or debug, not implemented")); + _renderManager->showDebugMsg(Common::String::format("IMNOTDEAF cheat or debug, not implemented")); } if (checkCode("3100OPB")) { - showDebugMsg(Common::String::format("Current location: %c%c%c%c", + _renderManager->showDebugMsg(Common::String::format("Current location: %c%c%c%c", _scriptManager->getStateValue(StateKey_World), _scriptManager->getStateValue(StateKey_Room), _scriptManager->getStateValue(StateKey_Node), @@ -101,7 +128,7 @@ void ZVision::cheatCodes(uint8 key) { } if (checkCode("77MASSAVE")) { - showDebugMsg(Common::String::format("Current location: %c%c%c%c", + _renderManager->showDebugMsg(Common::String::format("Current location: %c%c%c%c", _scriptManager->getStateValue(StateKey_World), _scriptManager->getStateValue(StateKey_Room), _scriptManager->getStateValue(StateKey_Node), @@ -131,13 +158,13 @@ void ZVision::cheatCodes(uint8 key) { } if (checkCode("FRAME")) - showDebugMsg(Common::String::format("FPS: ???, not implemented")); + _renderManager->showDebugMsg(Common::String::format("FPS: ???, not implemented")); if (checkCode("XYZZY")) _scriptManager->setStateValue(StateKey_DebugCheats, 1 - _scriptManager->getStateValue(StateKey_DebugCheats)); if (checkCode("COMPUTERARCH")) - showDebugMsg(Common::String::format("COMPUTERARCH: var-viewer not implemented")); + _renderManager->showDebugMsg(Common::String::format("COMPUTERARCH: var-viewer not implemented")); if (_scriptManager->getStateValue(StateKey_DebugCheats) == 1) if (checkCode("GO????")) -- cgit v1.2.3 From eea1ee445fcac7ecc53e31d258aac697d6b242f1 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 13:14:24 +0200 Subject: ZVISION: Move more graphics code out of the main engine code --- engines/zvision/core/events.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 70fd425949..5f29a6879c 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -30,6 +30,7 @@ #include "zvision/scripting/script_manager.h" #include "zvision/scripting/menu.h" #include "zvision/sound/zork_raw.h" +#include "zvision/text/string_manager.h" #include "common/events.h" #include "common/system.h" @@ -70,19 +71,19 @@ void ZVision::shortKeys(Common::Event event) { if (event.kbd.hasFlags(Common::KBD_CTRL)) { switch (event.kbd.keycode) { case Common::KEYCODE_s: - if (getMenuBarEnable() & kMenubarSave) + if (_menu->getEnable() & kMenubarSave) _scriptManager->changeLocation('g', 'j', 's', 'e', 0); break; case Common::KEYCODE_r: - if (getMenuBarEnable() & kMenubarRestore) + if (_menu->getEnable() & kMenubarRestore) _scriptManager->changeLocation('g', 'j', 'r', 'e', 0); break; case Common::KEYCODE_p: - if (getMenuBarEnable() & kMenubarSettings) + if (_menu->getEnable() & kMenubarSettings) _scriptManager->changeLocation('g', 'j', 'p', 'e', 0); break; case Common::KEYCODE_q: - if (getMenuBarEnable() & kMenubarExit) + if (_menu->getEnable() & kMenubarExit) ifQuit(); break; default: @@ -482,4 +483,12 @@ uint8 ZVision::getZvisionKey(Common::KeyCode scummKeyCode) { return 0; } +bool ZVision::ifQuit() { + if (_renderManager->askQuestion(_stringManager->getTextLine(StringManager::ZVISION_STR_EXITPROMT))) { + quitGame(); + return true; + } + return false; +} + } // End of namespace ZVision -- cgit v1.2.3 From 2becc76d5c16d15d5a7a6733b40f7c59e7391c12 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 19:56:37 +0200 Subject: ZVISION: Correct the script names of the location-specific cheats --- engines/zvision/core/events.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 5f29a6879c..4438474078 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -119,9 +119,9 @@ void ZVision::cheatCodes(uint8 key) { } // There are 3 more cheats in script files: - // - "EAT ME": gjcr.scr - // - "WHOAMI": hp1e.scr - // - "HUISOK": uh1f.scr + // - "WHOAMI": gjcr.scr + // - "HUISOK": hp1e.scr + // - "EAT ME": uh1f.scr } else if (getGameId() == GID_NEMESIS) { if (checkCode("CHLOE")) { _scriptManager->changeLocation('t', 'm', '2', 'g', 0); -- cgit v1.2.3 From f9595b11fc2bef08d84a00b81f9b2884f77897b0 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 23:18:54 +0200 Subject: ZVISION: Add an FPS timer (accessible with F10, or the "FRAME" cheat) --- engines/zvision/core/events.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 4438474078..7804130e2a 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -158,15 +158,18 @@ void ZVision::cheatCodes(uint8 key) { } } - if (checkCode("FRAME")) - _renderManager->showDebugMsg(Common::String::format("FPS: ???, not implemented")); + if (checkCode("FRAME")) { + Common::String fpsStr = Common::String::format("FPS: %d", getFPS()); + _renderManager->showDebugMsg(fpsStr); + } + + if (checkCode("COMPUTERARCH")) + _renderManager->showDebugMsg("COMPUTERARCH: var-viewer not implemented"); + // This cheat essentially toggles the GOxxxx cheat below if (checkCode("XYZZY")) _scriptManager->setStateValue(StateKey_DebugCheats, 1 - _scriptManager->getStateValue(StateKey_DebugCheats)); - if (checkCode("COMPUTERARCH")) - _renderManager->showDebugMsg(Common::String::format("COMPUTERARCH: var-viewer not implemented")); - if (_scriptManager->getStateValue(StateKey_DebugCheats) == 1) if (checkCode("GO????")) _scriptManager->changeLocation(getBufferedKey(3), @@ -240,6 +243,11 @@ void ZVision::processEvents() { _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; break; + case Common::KEYCODE_F10: { + Common::String fpsStr = Common::String::format("FPS: %d", getFPS()); + _renderManager->showDebugMsg(fpsStr); + } + break; default: break; } -- cgit v1.2.3 From c823a6e825a6474c75f1ddecfcb67a602393fae6 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 27 Dec 2014 23:52:18 +0100 Subject: ZVISION: Fix cmdRawToWav on BE systems --- engines/zvision/core/console.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index c7592c8d9d..b5e542d777 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -138,6 +138,10 @@ bool Console::cmdRawToWav(int argc, const char **argv) { output.writeUint32LE(file.size() * 2); int16 *buffer = new int16[file.size()]; audioStream->readBuffer(buffer, file.size()); +#ifndef SCUMM_LITTLE_ENDIAN + for (int i = 0; i < file.size(); ++i) + buffer[i] = TO_LE_16(buffer[i]); +#endif output.write(buffer, file.size() * 2); delete[] buffer; -- cgit v1.2.3 From 535249389a16f780fba51dd2c7ca8e1eddf65de9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 2 Jan 2015 03:59:35 +0200 Subject: ZVISION: Add a new command, "dumpimage", to dump any game image to BMP --- engines/zvision/core/console.cpp | 59 ++++++++++++++++++++++++++++++++++++++++ engines/zvision/core/console.h | 1 + 2 files changed, 60 insertions(+) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index b5e542d777..65821b1702 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -53,6 +53,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { registerCmd("location", WRAP_METHOD(Console, cmdLocation)); registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); registerCmd("dumpfiles", WRAP_METHOD(Console, cmdDumpFiles)); + registerCmd("dumpimage", WRAP_METHOD(Console, cmdDumpImage)); } bool Console::cmdLoadVideo(int argc, const char **argv) { @@ -269,4 +270,62 @@ bool Console::cmdDumpFiles(int argc, const char **argv) { return true; } +bool Console::cmdDumpImage(int argc, const char **argv) { + if (argc != 2) { + debugPrintf("Use %s to dump a ZVision TGA/TGZ image into a regular BMP image\n", argv[0]); + return true; + } + + Common::String fileName = argv[1]; + if (!fileName.hasSuffix(".tga")) { + debugPrintf("%s is not an image file", argv[1]); + } + + Common::File f; + if (!_engine->getSearchManager()->openFile(f, argv[1])) { + warning("File not found: %s", argv[1]); + return true; + } + + Graphics::Surface surface; + _engine->getRenderManager()->readImageToSurface(argv[1], surface, false); + + // Open file + Common::DumpFile out; + + fileName.setChar('b', fileName.size() - 3); + fileName.setChar('m', fileName.size() - 2); + fileName.setChar('p', fileName.size() - 1); + + out.open(fileName); + + // Write BMP header + out.writeByte('B'); + out.writeByte('M'); + out.writeUint32LE(surface.h * surface.pitch + 54); + out.writeUint32LE(0); + out.writeUint32LE(54); + out.writeUint32LE(40); + out.writeUint32LE(surface.w); + out.writeUint32LE(surface.h); + out.writeUint16LE(1); + out.writeUint16LE(16); + out.writeUint32LE(0); + out.writeUint32LE(0); + out.writeUint32LE(0); + out.writeUint32LE(0); + out.writeUint32LE(0); + out.writeUint32LE(0); + + // Write pixel data to BMP + out.write(surface.getPixels(), surface.pitch * surface.h); + + out.flush(); + out.close(); + + surface.free(); + + return true; +} + } // End of namespace ZVision diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h index a7bd88ebc3..ffce87869f 100644 --- a/engines/zvision/core/console.h +++ b/engines/zvision/core/console.h @@ -47,6 +47,7 @@ private: bool cmdLocation(int argc, const char **argv); bool cmdDumpFile(int argc, const char **argv); bool cmdDumpFiles(int argc, const char **argv); + bool cmdDumpImage(int argc, const char **argv); }; } // End of namespace ZVision -- cgit v1.2.3 From c82480461cacab7893053d8e4821b3a6987552c9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 10 Jan 2015 01:36:20 +0200 Subject: ZVISION: Make sure only existing files are dumped --- engines/zvision/core/console.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 65821b1702..f39c06b57e 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -263,7 +263,8 @@ bool Console::cmdDumpFiles(int argc, const char **argv) { debugPrintf("Dumping %s\n", fileName.c_str()); in = iter->_value.arch->createReadStreamForMember(iter->_value.name); - dumpFile(in, fileName.c_str()); + if (in) + dumpFile(in, fileName.c_str()); delete in; } -- cgit v1.2.3 From 3f66f28624812910834600d8a2cecb084dedea9f Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sun, 18 Jan 2015 20:32:55 +0100 Subject: ZVISION: Remove trailing whitespace --- engines/zvision/core/console.cpp | 2 +- engines/zvision/core/events.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index f39c06b57e..e54e986bd7 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -204,7 +204,7 @@ bool Console::cmdLocation(int argc, const char **argv) { Common::String scrFile = Common::String::format("%c%c%c%c.scr", curLocation.world, curLocation.room, curLocation.node, curLocation.view); debugPrintf("Current location: world '%c', room '%c', node '%c', view '%c', offset %d, script %s\n", curLocation.world, curLocation.room, curLocation.node, curLocation.view, curLocation.offset, scrFile.c_str()); - + if (argc != 6) { debugPrintf("Use %s to change your location\n", argv[0]); return true; diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 7804130e2a..4c7d395892 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -336,7 +336,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { mspeed = 25; } _mouseVelocity = MIN(((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt(), -1); - + _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; -- cgit v1.2.3 From 0776709f3175da3ebca69f8a4866d4d98a1e9be9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 21 Jan 2015 00:33:54 +0200 Subject: ZVISION: Do not process cheat codes while in the game menus This prevents the cheat codes from being accidentally triggered when using the save screen, for example --- engines/zvision/core/events.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 4c7d395892..9cf5d04a7a 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -93,6 +93,11 @@ void ZVision::shortKeys(Common::Event event) { } void ZVision::cheatCodes(uint8 key) { + Location loc = _scriptManager->getCurrentLocation(); + // Do not process cheat codes while in the game menus + if (loc.world == 'g' && loc.room == 'j') + return; + pushKeyToCheatBuf(key); if (getGameId() == GID_GRANDINQUISITOR) { @@ -146,7 +151,6 @@ void ZVision::cheatCodes(uint8 key) { } if (checkCode("HELLOSAILOR")) { - Location loc = _scriptManager->getCurrentLocation(); Audio::AudioStream *soundStream; if (loc.world == 'v' && loc.room == 'b' && loc.node == '1' && loc.view == '0') { soundStream = makeRawZorkStream("v000hpta.raw", this); -- cgit v1.2.3 From e66883d5cbae4d92264cd1c2b5784af79d30f152 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 21 Jan 2015 14:06:13 +0200 Subject: ZVISION: Add console commands to manipulate state flags and variables --- engines/zvision/core/console.cpp | 38 ++++++++++++++++++++++++++++++++++++++ engines/zvision/core/console.h | 2 ++ 2 files changed, 40 insertions(+) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index e54e986bd7..f5cacb582c 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -54,6 +54,8 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); registerCmd("dumpfiles", WRAP_METHOD(Console, cmdDumpFiles)); registerCmd("dumpimage", WRAP_METHOD(Console, cmdDumpImage)); + registerCmd("statevalue", WRAP_METHOD(Console, cmdStateValue)); + registerCmd("stateflag", WRAP_METHOD(Console, cmdStateFlag)); } bool Console::cmdLoadVideo(int argc, const char **argv) { @@ -329,4 +331,40 @@ bool Console::cmdDumpImage(int argc, const char **argv) { return true; } +bool Console::cmdStateValue(int argc, const char **argv) { + if (argc < 2) { + debugPrintf("Use %s to show the value of a state variable\n", argv[0]); + debugPrintf("Use %s to set the value of a state variable\n", argv[0]); + return true; + } + + int valueNum = atoi(argv[1]); + int newValue = (argc > 2) ? atoi(argv[2]) : -1; + + if (argc == 2) + debugPrintf("[%d] = %d\n", valueNum, _engine->getScriptManager()->getStateValue(valueNum)); + else if (argc == 3) + _engine->getScriptManager()->setStateValue(valueNum, newValue); + + return true; +} + +bool Console::cmdStateFlag(int argc, const char **argv) { + if (argc < 2) { + debugPrintf("Use %s to show the value of a state flag\n", argv[0]); + debugPrintf("Use %s to set the value of a state flag\n", argv[0]); + return true; + } + + int valueNum = atoi(argv[1]); + int newValue = (argc > 2) ? atoi(argv[2]) : -1; + + if (argc == 2) + debugPrintf("[%d] = %d\n", valueNum, _engine->getScriptManager()->getStateFlag(valueNum)); + else if (argc == 3) + _engine->getScriptManager()->setStateFlag(valueNum, newValue); + + return true; +} + } // End of namespace ZVision diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h index ffce87869f..ac834185a0 100644 --- a/engines/zvision/core/console.h +++ b/engines/zvision/core/console.h @@ -48,6 +48,8 @@ private: bool cmdDumpFile(int argc, const char **argv); bool cmdDumpFiles(int argc, const char **argv); bool cmdDumpImage(int argc, const char **argv); + bool cmdStateValue(int argc, const char **argv); + bool cmdStateFlag(int argc, const char **argv); }; } // End of namespace ZVision -- cgit v1.2.3 From 14914b2a31399ceb6b2e4d7616535e346ee3acd6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 14 Feb 2015 14:45:08 +0200 Subject: ZVISION: Add custom equality operators for game location This makes the location checks more readable --- engines/zvision/core/events.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 9cf5d04a7a..cc1c00b6d0 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -152,7 +152,7 @@ void ZVision::cheatCodes(uint8 key) { if (checkCode("HELLOSAILOR")) { Audio::AudioStream *soundStream; - if (loc.world == 'v' && loc.room == 'b' && loc.node == '1' && loc.view == '0') { + if (loc == "vb10") { soundStream = makeRawZorkStream("v000hpta.raw", this); } else { soundStream = makeRawZorkStream("v000hnta.raw", this); -- cgit v1.2.3