[Scummvm-cvs-logs] scummvm master -> 3661bc4cf13ac9bb27e60969b4195acc82fee6c5
bluegr
bluegr at gmail.com
Thu Dec 25 21:13:06 CET 2014
This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
06fbca1e81 ZVISION: Remove dead code
dbbcf64187 ZVISION: Use the search manager to open files in console commands
11cf9b53ba ZVISION: Remove dead code, and fix bad usage of assert()
6c451c9cf4 ZVISION: Document where MIDI commands are used
6368a6ea91 ZVISION: Move the menu code together with the other scripting code
3661bc4cf1 ZVISION: Normalize and cleanup all the menu-related enums
Commit: 06fbca1e8109bdd3d1fdf72fc1056cbf658659e5
https://github.com/scummvm/scummvm/commit/06fbca1e8109bdd3d1fdf72fc1056cbf658659e5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-25T20:10:24+02:00
Commit Message:
ZVISION: Remove dead code
Changed paths:
engines/zvision/scripting/sidefx/animation_node.cpp
engines/zvision/scripting/sidefx/animation_node.h
diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp
index 97c6eee..b966aa9 100644
--- a/engines/zvision/scripting/sidefx/animation_node.cpp
+++ b/engines/zvision/scripting/sidefx/animation_node.cpp
@@ -206,8 +206,4 @@ bool AnimationNode::stop() {
return false;
}
-int32 AnimationNode::getFrameDelay() {
- return _frmDelay;
-}
-
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/animation_node.h b/engines/zvision/scripting/sidefx/animation_node.h
index 74941aa..368f029 100644
--- a/engines/zvision/scripting/sidefx/animation_node.h
+++ b/engines/zvision/scripting/sidefx/animation_node.h
@@ -72,8 +72,6 @@ public:
void addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops = 1);
bool stop();
-
- int32 getFrameDelay();
};
} // End of namespace ZVision
Commit: dbbcf641874ace35b871226664370413de176c37
https://github.com/scummvm/scummvm/commit/dbbcf641874ace35b871226664370413de176c37
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-25T21:17:47+02:00
Commit Message:
ZVISION: Use the search manager to open files in console commands
Changed paths:
engines/zvision/core/console.cpp
diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp
index 07d3114..c7592c8 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);
Commit: 11cf9b53ba138b5e069d7ffbd6af7f36b26a9add
https://github.com/scummvm/scummvm/commit/11cf9b53ba138b5e069d7ffbd6af7f36b26a9add
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-25T21:19:19+02:00
Commit Message:
ZVISION: Remove dead code, and fix bad usage of assert()
Since some compilers, like MSVC, strip out asserts in non-debug builds,
it's a bad idea to perform active commands within assert() statements.
In this particular case, the engine would attempt to open a file in an
assert statement
Changed paths:
engines/zvision/sound/zork_raw.cpp
engines/zvision/sound/zork_raw.h
diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp
index b2c88b3..6d1980b 100644
--- a/engines/zvision/sound/zork_raw.cpp
+++ b/engines/zvision/sound/zork_raw.cpp
@@ -213,7 +213,6 @@ RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag dis
}
int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
-
int32 bytesRead = _streamReader.readBuffer(buffer, _stream.get(), numSamples);
if (_stream->eos())
@@ -241,16 +240,10 @@ Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stre
return new RawZorkStream(rate, stereo, disposeAfterUse, stream);
}
-Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
- int rate,
- bool stereo,
- DisposeAfterUse::Flag disposeAfterUse) {
- return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, stereo, DisposeAfterUse::YES);
-}
-
Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
Common::File *file = new Common::File();
- assert(engine->getSearchManager()->openFile(*file, filePath));
+ if (!engine->getSearchManager()->openFile(*file, filePath))
+ error("File not found: %s", filePath.c_str());
// Get the file name
Common::StringTokenizer tokenizer(filePath, "/\\");
diff --git a/engines/zvision/sound/zork_raw.h b/engines/zvision/sound/zork_raw.h
index 0b408d8..892bad4 100644
--- a/engines/zvision/sound/zork_raw.h
+++ b/engines/zvision/sound/zork_raw.h
@@ -123,20 +123,6 @@ public:
};
/**
- * Creates an audio stream, which plays from the given buffer.
- *
- * @param buffer Buffer to play from.
- * @param size Size of the buffer in bytes.
- * @param rate Rate of the sound data.
- * @param dispose AfterUse Whether to free the buffer after use (with free!).
- * @return The new SeekableAudioStream (or 0 on failure).
- */
-Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
- int rate,
- bool stereo,
- DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
-
-/**
* Creates an audio stream, which plays from the given stream.
*
* @param stream Stream object to play from.
Commit: 6c451c9cf481dcaa6261c34773b79689386ded42
https://github.com/scummvm/scummvm/commit/6c451c9cf481dcaa6261c34773b79689386ded42
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-25T21:48:59+02:00
Commit Message:
ZVISION: Document where MIDI commands are used
Changed paths:
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/sidefx/music_node.h
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 89b311e..be20797 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -477,7 +477,9 @@ ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &l
sscanf(line.c_str(), "%u %24s %u %u", &type, fileNameBuffer, &loop, &volume);
- // type 4 are midi sound effect files
+ // Type 4 actions are MIDI commands, not files. These are only used by
+ // Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well
+ // as vr)
if (type == 4) {
_midi = true;
int note;
diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h
index 8f4a46f..3f1ca5c 100644
--- a/engines/zvision/scripting/sidefx/music_node.h
+++ b/engines/zvision/scripting/sidefx/music_node.h
@@ -91,6 +91,7 @@ private:
bool _loaded;
};
+// Only used by Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well as vr)
class MusicMidiNode : public MusicNodeBASE {
public:
MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume);
Commit: 6368a6ea91364f90bcb0d5d9d88826d856181a52
https://github.com/scummvm/scummvm/commit/6368a6ea91364f90bcb0d5d9d88826d856181a52
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-25T22:00:55+02:00
Commit Message:
ZVISION: Move the menu code together with the other scripting code
Changed paths:
A engines/zvision/scripting/menu.cpp
A engines/zvision/scripting/menu.h
R engines/zvision/core/menu.cpp
R engines/zvision/core/menu.h
engines/zvision/core/events.cpp
engines/zvision/module.mk
engines/zvision/zvision.cpp
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index 1920ffd..89f1595 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 31e0d71..0000000
--- 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 ebe0bb5..0000000
--- 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
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 3ea31ab..6955d62 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -4,7 +4,6 @@ MODULE_OBJS := \
core/console.o \
core/clock.o \
core/events.o \
- core/menu.o \
core/save_manager.o \
detection.o \
file/lzss_read_stream.o \
@@ -30,6 +29,7 @@ MODULE_OBJS := \
scripting/controls/slot_control.o \
scripting/controls/titler_control.o \
scripting/inventory.o \
+ scripting/menu.o \
scripting/scr_file_handling.o \
scripting/script_manager.o \
scripting/sidefx/animation_node.o \
diff --git a/engines/zvision/scripting/menu.cpp b/engines/zvision/scripting/menu.cpp
new file mode 100644
index 0000000..fa5e24f
--- /dev/null
+++ b/engines/zvision/scripting/menu.cpp
@@ -0,0 +1,762 @@
+/* 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 "zvision/graphics/render_manager.h"
+#include "zvision/scripting/menu.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/scripting/menu.h b/engines/zvision/scripting/menu.h
new file mode 100644
index 0000000..ebe0bb5
--- /dev/null
+++ b/engines/zvision/scripting/menu.h
@@ -0,0 +1,125 @@
+/* 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
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index db96884..f692969 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -30,7 +30,7 @@
#include "zvision/core/save_manager.h"
#include "zvision/text/string_manager.h"
#include "zvision/detection.h"
-#include "zvision/core/menu.h"
+#include "zvision/scripting/menu.h"
#include "zvision/file/search_manager.h"
#include "zvision/text/text.h"
#include "zvision/text/truetype_font.h"
Commit: 3661bc4cf13ac9bb27e60969b4195acc82fee6c5
https://github.com/scummvm/scummvm/commit/3661bc4cf13ac9bb27e60969b4195acc82fee6c5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-25T22:11:29+02:00
Commit Message:
ZVISION: Normalize and cleanup all the menu-related enums
Changed paths:
engines/zvision/core/events.cpp
engines/zvision/scripting/menu.cpp
engines/zvision/scripting/menu.h
engines/zvision/scripting/script_manager.h
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index 89f1595..227cf21 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:
diff --git a/engines/zvision/scripting/menu.cpp b/engines/zvision/scripting/menu.cpp
index fa5e24f..16aa57e 100644
--- a/engines/zvision/scripting/menu.cpp
+++ b/engines/zvision/scripting/menu.cpp
@@ -26,17 +26,16 @@
namespace ZVision {
enum {
- SLOT_START_SLOT = 151,
- SLOT_SPELL_1 = 191,
- SLOT_USER_CHOSE_THIS_SPELL = 205,
- SLOT_REVERSED_SPELLBOOK = 206
+ kMainMenuSave = 0,
+ kMainMenuLoad = 1,
+ kMainMenuPrefs = 2,
+ kMainMenuExit = 3
};
enum {
- menu_MAIN_SAVE = 0,
- menu_MAIN_REST = 1,
- menu_MAIN_PREF = 2,
- menu_MAIN_EXIT = 3
+ kMenuItem = 0,
+ kMenuMagic = 1,
+ kMenuMain = 2
};
MenuHandler::MenuHandler(ZVision *engine) {
@@ -119,8 +118,8 @@ MenuZGI::~MenuZGI() {
void MenuZGI::onMouseUp(const Common::Point &Pos) {
if (Pos.y < 40) {
switch (menuMouseFocus) {
- case menu_ITEM:
- if (menuBarFlag & menuBar_Items) {
+ case kMenuItem:
+ if (menuBarFlag & kMenubarItems) {
int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
if (itemCount == 0)
itemCount = 20;
@@ -128,13 +127,13 @@ void MenuZGI::onMouseUp(const Common::Point &Pos) {
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)) {
+ if (Common::Rect(scrollPos[kMenuItem] + itemspace * i, 0,
+ scrollPos[kMenuItem] + 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);
+ _engine->getScriptManager()->inventoryAdd(_engine->getScriptManager()->getStateValue(StateKey_Inv_StartSlot + i));
+ _engine->getScriptManager()->setStateValue(StateKey_Inv_StartSlot + i, mouseItem);
redraw = true;
}
@@ -143,62 +142,62 @@ void MenuZGI::onMouseUp(const Common::Point &Pos) {
}
break;
- case menu_MAGIC:
- if (menuBarFlag & menuBar_Magic) {
+ case kMenuMagic:
+ if (menuBarFlag & kMenubarMagic) {
for (int i = 0; i < 12; i++) {
- uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i);
+ uint itemnum = _engine->getScriptManager()->getStateValue(StateKey_Spell_1 + i);
if (itemnum != 0) {
- if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1)
+ if (_engine->getScriptManager()->getStateValue(StateKey_Reversed_Spellbooc) == 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);
+ if (Common::Rect(668 + 47 * i - scrollPos[kMenuMagic], 0,
+ 668 + 47 * i - scrollPos[kMenuMagic] + 28, 32).contains(Pos))
+ _engine->getScriptManager()->setStateValue(StateKey_Active_Spell, itemnum);
}
}
break;
- case menu_MAIN:
+ case kMenuMain:
// Exit
- if (menuBarFlag & menuBar_Exit)
+ if (menuBarFlag & kMenubarExit)
if (Common::Rect(320 + 135,
- scrollPos[menu_MAIN],
+ scrollPos[kMenuMain],
320 + 135 + 135,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
_engine->ifQuit();
}
// Settings
- if (menuBarFlag & menuBar_Settings)
+ if (menuBarFlag & kMenubarSettings)
if (Common::Rect(320 ,
- scrollPos[menu_MAIN],
+ scrollPos[kMenuMain],
320 + 135,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
_engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0);
}
// Load
- if (menuBarFlag & menuBar_Restore)
+ if (menuBarFlag & kMenubarRestore)
if (Common::Rect(320 - 135,
- scrollPos[menu_MAIN],
+ scrollPos[kMenuMain],
320,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
_engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0);
}
// Save
- if (menuBarFlag & menuBar_Save)
+ if (menuBarFlag & kMenubarSave)
if (Common::Rect(320 - 135 * 2,
- scrollPos[menu_MAIN],
+ scrollPos[kMenuMain],
320 - 135,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
_engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0);
}
break;
@@ -213,8 +212,8 @@ void MenuZGI::onMouseMove(const Common::Point &Pos) {
redraw = true;
inmenu = true;
switch (menuMouseFocus) {
- case menu_ITEM:
- if (menuBarFlag & menuBar_Items) {
+ case kMenuItem:
+ if (menuBarFlag & kMenubarItems) {
int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
if (itemCount == 0)
itemCount = 20;
@@ -228,78 +227,78 @@ void MenuZGI::onMouseMove(const Common::Point &Pos) {
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)) {
+ if (Common::Rect(scrollPos[kMenuItem] + itemspace * i, 0,
+ scrollPos[kMenuItem] + 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))
+ if (_engine->getScriptManager()->getStateValue(StateKey_Inv_StartSlot + mouseOnItem) ||
+ _engine->getScriptManager()->getStateValue(StateKey_Inv_StartSlot + lastItem))
redraw = true;
}
break;
- case menu_MAGIC:
- if (menuBarFlag & menuBar_Magic) {
+ case kMenuMagic:
+ if (menuBarFlag & kMenubarMagic) {
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)) {
+ if (Common::Rect(668 + 47 * i - scrollPos[kMenuMagic], 0,
+ 668 + 47 * i - scrollPos[kMenuMagic] + 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))
+ if (_engine->getScriptManager()->getStateValue(StateKey_Spell_1 + mouseOnItem) ||
+ _engine->getScriptManager()->getStateValue(StateKey_Spell_1 + lastItem))
redraw = true;
}
break;
- case menu_MAIN: {
+ case kMenuMain: {
int lastItem = mouseOnItem;
mouseOnItem = -1;
// Exit
- if (menuBarFlag & menuBar_Exit)
+ if (menuBarFlag & kMenubarExit)
if (Common::Rect(320 + 135,
- scrollPos[menu_MAIN],
+ scrollPos[kMenuMain],
320 + 135 + 135,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
- mouseOnItem = menu_MAIN_EXIT;
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
+ mouseOnItem = kMainMenuExit;
}
// Settings
- if (menuBarFlag & menuBar_Settings)
+ if (menuBarFlag & kMenubarSettings)
if (Common::Rect(320 ,
- scrollPos[menu_MAIN],
+ scrollPos[kMenuMain],
320 + 135,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
- mouseOnItem = menu_MAIN_PREF;
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
+ mouseOnItem = kMainMenuPrefs;
}
// Load
- if (menuBarFlag & menuBar_Restore)
+ if (menuBarFlag & kMenubarRestore)
if (Common::Rect(320 - 135,
- scrollPos[menu_MAIN],
+ scrollPos[kMenuMain],
320,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
- mouseOnItem = menu_MAIN_REST;
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
+ mouseOnItem = kMainMenuLoad;
}
// Save
- if (menuBarFlag & menuBar_Save)
+ if (menuBarFlag & kMenubarSave)
if (Common::Rect(320 - 135 * 2,
- scrollPos[menu_MAIN],
+ scrollPos[kMenuMain],
320 - 135,
- scrollPos[menu_MAIN] + 32).contains(Pos)) {
- mouseOnItem = menu_MAIN_SAVE;
+ scrollPos[kMenuMain] + 32).contains(Pos)) {
+ mouseOnItem = kMainMenuSave;
}
if (lastItem != mouseOnItem)
@@ -310,25 +309,25 @@ void MenuZGI::onMouseMove(const Common::Point &Pos) {
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;
+ menuMouseFocus = kMenuMain;
+ scrolled[kMenuMain] = false;
+ scrollPos[kMenuMain] = menuback[kMenuMain][1].h - menuback[kMenuMain][0].h;
_engine->getScriptManager()->setStateValue(StateKey_MenuState, 2);
}
- if (menuBarFlag & menuBar_Magic)
+ if (menuBarFlag & kMenubarMagic)
if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic
- menuMouseFocus = menu_MAGIC;
- scrolled[menu_MAGIC] = false;
- scrollPos[menu_MAGIC] = 28;
+ menuMouseFocus = kMenuMagic;
+ scrolled[kMenuMagic] = false;
+ scrollPos[kMenuMagic] = 28;
_engine->getScriptManager()->setStateValue(StateKey_MenuState, 3);
}
- if (menuBarFlag & menuBar_Items)
+ if (menuBarFlag & kMenubarItems)
if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items
- menuMouseFocus = menu_ITEM;
- scrolled[menu_ITEM] = false;
- scrollPos[menu_ITEM] = 28 - 600;
+ menuMouseFocus = kMenuItem;
+ scrolled[kMenuItem] = false;
+ scrollPos[kMenuItem] = 28 - 600;
_engine->getScriptManager()->setStateValue(StateKey_MenuState, 1);
}
@@ -353,24 +352,24 @@ void MenuZGI::process(uint32 deltatime) {
clean = false;
}
switch (menuMouseFocus) {
- case menu_ITEM:
- if (menuBarFlag & menuBar_Items)
- if (!scrolled[menu_ITEM]) {
+ case kMenuItem:
+ if (menuBarFlag & kMenubarItems)
+ if (!scrolled[kMenuItem]) {
redraw = true;
float scrl = 600.0 * (deltatime / 1000.0);
if (scrl == 0)
scrl = 1.0;
- scrollPos [menu_ITEM] += scrl;
+ scrollPos [kMenuItem] += scrl;
- if (scrollPos[menu_ITEM] >= 0) {
- scrolled[menu_ITEM] = true;
- scrollPos [menu_ITEM] = 0;
+ if (scrollPos[kMenuItem] >= 0) {
+ scrolled[kMenuItem] = true;
+ scrollPos [kMenuItem] = 0;
}
}
if (redraw) {
- _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0);
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuItem][0], scrollPos[kMenuItem], 0);
int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots);
if (itemCount == 0)
@@ -386,7 +385,7 @@ void MenuZGI::process(uint32 deltatime) {
if (mouseOnItem == i)
inrect = true;
- uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i);
+ uint curItemId = _engine->getScriptManager()->getStateValue(StateKey_Inv_StartSlot + i);
if (curItemId != 0) {
if (itemId[i] != curItemId) {
@@ -399,9 +398,9 @@ void MenuZGI::process(uint32 deltatime) {
}
if (inrect)
- _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[menu_ITEM] + itemspace * i, 0, 0);
+ _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[kMenuItem] + itemspace * i, 0, 0);
else
- _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[menu_ITEM] + itemspace * i, 0, 0);
+ _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[kMenuItem] + itemspace * i, 0, 0);
} else {
if (items[i][0]) {
@@ -422,24 +421,24 @@ void MenuZGI::process(uint32 deltatime) {
}
break;
- case menu_MAGIC:
- if (menuBarFlag & menuBar_Magic)
- if (!scrolled[menu_MAGIC]) {
+ case kMenuMagic:
+ if (menuBarFlag & kMenubarMagic)
+ if (!scrolled[kMenuMagic]) {
redraw = true;
float scrl = 600.0 * (deltatime / 1000.0);
if (scrl == 0)
scrl = 1.0;
- scrollPos [menu_MAGIC] += scrl;
+ scrollPos [kMenuMagic] += scrl;
- if (scrollPos[menu_MAGIC] >= 600) {
- scrolled[menu_MAGIC] = true;
- scrollPos [menu_MAGIC] = 600;
+ if (scrollPos[kMenuMagic] >= 600) {
+ scrolled[kMenuMagic] = true;
+ scrollPos [kMenuMagic] = 600;
}
}
if (redraw) {
- _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][0], 640 - scrollPos[menu_MAGIC], 0);
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMagic][0], 640 - scrollPos[kMenuMagic], 0);
for (int i = 0; i < 12; i++) {
bool inrect = false;
@@ -447,9 +446,9 @@ void MenuZGI::process(uint32 deltatime) {
if (mouseOnItem == i)
inrect = true;
- uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i);
+ uint curItemId = _engine->getScriptManager()->getStateValue(StateKey_Spell_1 + i);
if (curItemId) {
- if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1)
+ if (_engine->getScriptManager()->getStateValue(StateKey_Reversed_Spellbooc) == 1)
curItemId = 0xEE + i;
else
curItemId = 0xE0 + i;
@@ -466,9 +465,9 @@ void MenuZGI::process(uint32 deltatime) {
}
if (inrect)
- _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0);
+ _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[kMenuMagic], 0, 0);
else
- _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0);
+ _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[kMenuMagic], 0, 0);
} else {
if (magic[i][0]) {
@@ -488,47 +487,47 @@ void MenuZGI::process(uint32 deltatime) {
}
break;
- case menu_MAIN:
- if (!scrolled[menu_MAIN]) {
+ case kMenuMain:
+ if (!scrolled[kMenuMain]) {
redraw = true;
float scrl = 32.0 * 2.0 * (deltatime / 1000.0);
if (scrl == 0)
scrl = 1.0;
- scrollPos [menu_MAIN] += scrl;
+ scrollPos [kMenuMain] += scrl;
- if (scrollPos[menu_MAIN] >= 0) {
- scrolled[menu_MAIN] = true;
- scrollPos [menu_MAIN] = 0;
+ if (scrollPos[kMenuMain] >= 0) {
+ scrolled[kMenuMain] = true;
+ scrollPos [kMenuMain] = 0;
}
}
if (redraw) {
- _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]);
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMain][0], 30, scrollPos[kMenuMain]);
- if (menuBarFlag & menuBar_Exit) {
- if (mouseOnItem == menu_MAIN_EXIT)
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]);
+ if (menuBarFlag & kMenubarExit) {
+ if (mouseOnItem == kMainMenuExit)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuExit][1], 320 + 135, scrollPos[kMenuMain]);
else
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]);
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuExit][0], 320 + 135, scrollPos[kMenuMain]);
}
- if (menuBarFlag & menuBar_Settings) {
- if (mouseOnItem == menu_MAIN_PREF)
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]);
+ if (menuBarFlag & kMenubarSettings) {
+ if (mouseOnItem == kMainMenuPrefs)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuPrefs][1], 320, scrollPos[kMenuMain]);
else
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]);
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuPrefs][0], 320, scrollPos[kMenuMain]);
}
- if (menuBarFlag & menuBar_Restore) {
- if (mouseOnItem == menu_MAIN_REST)
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]);
+ if (menuBarFlag & kMenubarRestore) {
+ if (mouseOnItem == kMainMenuLoad)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuLoad][1], 320 - 135, scrollPos[kMenuMain]);
else
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]);
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuLoad][0], 320 - 135, scrollPos[kMenuMain]);
}
- if (menuBarFlag & menuBar_Save) {
- if (mouseOnItem == menu_MAIN_SAVE)
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]);
+ if (menuBarFlag & kMenubarSave) {
+ if (mouseOnItem == kMainMenuSave)
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuSave][1], 320 - 135 * 2, scrollPos[kMenuMain]);
else
- _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]);
+ _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuSave][0], 320 - 135 * 2, scrollPos[kMenuMain]);
}
redraw = false;
}
@@ -536,13 +535,13 @@ void MenuZGI::process(uint32 deltatime) {
default:
if (redraw) {
if (inmenu) {
- _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0);
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMain][1], 30, 0);
- if (menuBarFlag & menuBar_Items)
- _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0);
+ if (menuBarFlag & kMenubarItems)
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuItem][1], 0, 0);
- if (menuBarFlag & menuBar_Magic)
- _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0);
+ if (menuBarFlag & kMenubarMagic)
+ _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMagic][1], 640 - 28, 0);
}
redraw = false;
}
@@ -584,7 +583,7 @@ 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 (menuBarFlag & kMenubarExit)
if (Common::Rect(buts[3][1],
scrollPos,
buts[3][0] + buts[3][1],
@@ -595,7 +594,7 @@ void MenuNemesis::onMouseUp(const Common::Point &Pos) {
}
// Settings
- if (menuBarFlag & menuBar_Settings)
+ if (menuBarFlag & kMenubarSettings)
if (Common::Rect(buts[2][1],
scrollPos,
buts[2][0] + buts[2][1],
@@ -606,7 +605,7 @@ void MenuNemesis::onMouseUp(const Common::Point &Pos) {
}
// Load
- if (menuBarFlag & menuBar_Restore)
+ if (menuBarFlag & kMenubarRestore)
if (Common::Rect(buts[1][1],
scrollPos,
buts[1][0] + buts[1][1],
@@ -617,7 +616,7 @@ void MenuNemesis::onMouseUp(const Common::Point &Pos) {
}
// Save
- if (menuBarFlag & menuBar_Save)
+ if (menuBarFlag & kMenubarSave)
if (Common::Rect(buts[0][1],
scrollPos,
buts[0][0] + buts[0][1],
@@ -641,39 +640,39 @@ void MenuNemesis::onMouseMove(const Common::Point &Pos) {
mouseOnItem = -1;
// Exit
- if (menuBarFlag & menuBar_Exit)
+ if (menuBarFlag & kMenubarExit)
if (Common::Rect(buts[3][1],
scrollPos,
buts[3][0] + buts[3][1],
scrollPos + 32).contains(Pos)) {
- mouseOnItem = menu_MAIN_EXIT;
+ mouseOnItem = kMainMenuExit;
}
// Settings
- if (menuBarFlag & menuBar_Settings)
+ if (menuBarFlag & kMenubarSettings)
if (Common::Rect(buts[2][1],
scrollPos,
buts[2][0] + buts[2][1],
scrollPos + 32).contains(Pos)) {
- mouseOnItem = menu_MAIN_PREF;
+ mouseOnItem = kMainMenuPrefs;
}
// Load
- if (menuBarFlag & menuBar_Restore)
+ if (menuBarFlag & kMenubarRestore)
if (Common::Rect(buts[1][1],
scrollPos,
buts[1][0] + buts[1][1],
scrollPos + 32).contains(Pos)) {
- mouseOnItem = menu_MAIN_REST;
+ mouseOnItem = kMainMenuLoad;
}
// Save
- if (menuBarFlag & menuBar_Save)
+ if (menuBarFlag & kMenubarSave)
if (Common::Rect(buts[0][1],
scrollPos,
buts[0][0] + buts[0][1],
scrollPos + 32).contains(Pos)) {
- mouseOnItem = menu_MAIN_SAVE;
+ mouseOnItem = kMainMenuSave;
}
if (lastItem != mouseOnItem) {
@@ -718,20 +717,20 @@ void MenuNemesis::process(uint32 deltatime) {
if (redraw) {
_engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos);
- if (menuBarFlag & menuBar_Exit)
- if (mouseOnItem == menu_MAIN_EXIT)
+ if (menuBarFlag & kMenubarExit)
+ if (mouseOnItem == kMainMenuExit)
_engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos);
- if (menuBarFlag & menuBar_Settings)
- if (mouseOnItem == menu_MAIN_PREF)
+ if (menuBarFlag & kMenubarSettings)
+ if (mouseOnItem == kMainMenuPrefs)
_engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos);
- if (menuBarFlag & menuBar_Restore)
- if (mouseOnItem == menu_MAIN_REST)
+ if (menuBarFlag & kMenubarRestore)
+ if (mouseOnItem == kMainMenuLoad)
_engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos);
- if (menuBarFlag & menuBar_Save)
- if (mouseOnItem == menu_MAIN_SAVE)
+ if (menuBarFlag & kMenubarSave)
+ if (mouseOnItem == kMainMenuSave)
_engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos);
redraw = false;
diff --git a/engines/zvision/scripting/menu.h b/engines/zvision/scripting/menu.h
index ebe0bb5..a885879 100644
--- a/engines/zvision/scripting/menu.h
+++ b/engines/zvision/scripting/menu.h
@@ -32,12 +32,12 @@
namespace ZVision {
enum menuBar {
- menuBar_Exit = 0x1,
- menuBar_Settings = 0x2,
- menuBar_Restore = 0x4,
- menuBar_Save = 0x8,
- menuBar_Items = 0x100,
- menuBar_Magic = 0x200
+ kMenubarExit = 0x1,
+ kMenubarSettings = 0x2,
+ kMenubarRestore = 0x4,
+ kMenubarSave = 0x8,
+ kMenubarItems = 0x100,
+ kMenubarMagic = 0x200
};
class MenuHandler {
@@ -84,12 +84,6 @@ private:
bool scrolled[3];
int16 scrollPos[3];
- enum {
- menu_ITEM = 0,
- menu_MAGIC = 1,
- menu_MAIN = 2
- };
-
bool clean;
bool redraw;
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index c5ade08..9f0f2f6 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -94,7 +94,12 @@ enum StateKey {
StateKey_Inv_Cnt_Slot = 100,
StateKey_Inv_1_Slot = 101,
StateKey_Inv_49_Slot = 149,
- StateKey_Inv_TotalSlots = 150
+ // ZGI only
+ StateKey_Inv_TotalSlots = 150,
+ StateKey_Inv_StartSlot = 151,
+ StateKey_Spell_1 = 191,
+ StateKey_Active_Spell = 205,
+ StateKey_Reversed_Spellbooc = 206
};
struct Location {
More information about the Scummvm-git-logs
mailing list