diff options
-rw-r--r-- | engines/xeen/dialogs.cpp | 13 | ||||
-rw-r--r-- | engines/xeen/dialogs.h | 15 | ||||
-rw-r--r-- | engines/xeen/dialogs_control_panel.cpp | 226 | ||||
-rw-r--r-- | engines/xeen/events.h | 3 | ||||
-rw-r--r-- | engines/xeen/resources.cpp | 17 | ||||
-rw-r--r-- | engines/xeen/xeen.cpp | 4 | ||||
-rw-r--r-- | engines/xeen/xeen.h | 1 |
7 files changed, 139 insertions, 140 deletions
diff --git a/engines/xeen/dialogs.cpp b/engines/xeen/dialogs.cpp index 938a89b526..72f20d80ad 100644 --- a/engines/xeen/dialogs.cpp +++ b/engines/xeen/dialogs.cpp @@ -47,11 +47,12 @@ void ButtonContainer::restoreButtons() { void ButtonContainer::addButton(const Common::Rect &bounds, int val, SpriteResource *sprites) { - _buttons.push_back(UIButton(bounds, val, sprites, true)); + _buttons.push_back(UIButton(bounds, val, _buttons.size() * 2, sprites, sprites != nullptr)); } -void ButtonContainer::addButton(const Common::Rect &bounds, int val) { - _buttons.push_back(UIButton(bounds, val, nullptr, false)); +void ButtonContainer::addButton(const Common::Rect &bounds, int val, + uint frameNum, SpriteResource *sprites) { + _buttons.push_back(UIButton(bounds, val, frameNum, sprites, sprites != nullptr)); } void ButtonContainer::addPartyButtons(XeenEngine *vm) { @@ -106,7 +107,7 @@ bool ButtonContainer::checkEvents(XeenEngine *vm) { if (btn._draw && btn._value == _buttonValue) { // Found the correct button // Draw button depressed - btn._sprites->draw(0, btnIndex * 2 + 1, + btn._sprites->draw(0, btn._frameNum + 1, Common::Point(btn._bounds.left, btn._bounds.top)); win.setBounds(btn._bounds); win.update(); @@ -116,7 +117,7 @@ bool ButtonContainer::checkEvents(XeenEngine *vm) { events.wait(2); // Redraw button in it's original non-depressed form - btn._sprites->draw(0, btnIndex * 2, + btn._sprites->draw(0, btn._frameNum, Common::Point(btn._bounds.left, btn._bounds.top)); win.setBounds(btn._bounds); win.update(); @@ -134,7 +135,7 @@ void ButtonContainer::drawButtons(XSurface *surface) { for (uint btnIndex = 0; btnIndex < _buttons.size(); ++btnIndex) { UIButton &btn = _buttons[btnIndex]; if (btn._draw) { - btn._sprites->draw(*surface, btnIndex * 2, + btn._sprites->draw(*surface, btn._frameNum, Common::Point(btn._bounds.left, btn._bounds.top)); } } diff --git a/engines/xeen/dialogs.h b/engines/xeen/dialogs.h index d0bf20108b..536bd27e82 100644 --- a/engines/xeen/dialogs.h +++ b/engines/xeen/dialogs.h @@ -39,12 +39,14 @@ public: Common::Rect _bounds; SpriteResource *_sprites; int _value; + uint _frameNum; bool _draw; - UIButton(const Common::Rect &bounds, int value, SpriteResource *sprites, bool draw) : - _bounds(bounds), _value(value), _sprites(sprites), _draw(draw) {} + UIButton(const Common::Rect &bounds, int value, uint frameNum, SpriteResource *sprites, bool draw) : + _bounds(bounds), _value(value), _frameNum(frameNum), + _sprites(sprites), _draw(draw) {} - UIButton() : _value(0), _sprites(nullptr), _draw(false) {} + UIButton() : _value(0), _frameNum(0), _sprites(nullptr), _draw(false) {} }; class ButtonContainer : public Cutscenes { @@ -89,9 +91,10 @@ public: void restoreButtons(); - void addButton(const Common::Rect &bounds, int val, SpriteResource *sprites); - - void addButton(const Common::Rect &bounds, int val); + void addButton(const Common::Rect &bounds, int val, + SpriteResource *sprites = nullptr); + void addButton(const Common::Rect &bounds, int val, + uint frameNum, SpriteResource *sprites = nullptr); void addPartyButtons(XeenEngine *vm); diff --git a/engines/xeen/dialogs_control_panel.cpp b/engines/xeen/dialogs_control_panel.cpp index c66c385c61..3783d45633 100644 --- a/engines/xeen/dialogs_control_panel.cpp +++ b/engines/xeen/dialogs_control_panel.cpp @@ -50,125 +50,120 @@ int ControlPanel::execute() { loadButtons(); int result = 0, debugCtr = 0; - while (!g_vm->shouldQuit()) { - w.open(); + w.open(); - while (!g_vm->shouldQuit()) { - Common::String btnText = getButtonText(); - Common::String text = Common::String::format(Res.CONTROL_PANEL_TEXT, btnText.c_str()); + do { + Common::String btnText = getButtonText(); + Common::String text = Common::String::format(Res.CONTROL_PANEL_TEXT, btnText.c_str()); + drawButtons(&w); + w.writeString(text); + w.writeString("\xB""000\t000\x1"); + w.update(); + + do { + events.updateGameCounter(); + intf.draw3d(false, false); + w.writeString("\r"); drawButtons(&w); w.writeString(text); - w.writeString("\xB""000\t000\x1"); - w.update(); + w.writeString("\v000\t000"); + w.frame(); - do { - events.updateGameCounter(); - intf.draw3d(false); - w.writeString("\r"); - drawButtons(&w); - w.writeString(text); - w.writeString("\v000\t000"); - w.frame(); - - if (_debugFlag) - w.writeString(getTimeText()); - - w3.update(); - w.update(); - - events.pollEventsAndWait(); - checkEvents(_vm); - if (_vm->shouldQuit()) - return 0; - if (!_buttonValue && !events.timeElapsed()) - continue; - - switch (_buttonValue) { - case Common::KEYCODE_q: - if (Confirm::show(g_vm, Res.CONFIRM_QUIT)) { - g_vm->_quitMode = QMODE_QUIT; - result = 1; - } - break; - - case Common::KEYCODE_w: - if (Confirm::show(g_vm, Res.MR_WIZARD)) { - w.close(); - if (!windows[2]._enabled) { - sound.playFX(51); - - if (g_vm->getGameID() == GType_WorldOfXeen) { - map._loadDarkSide = false; - map.load(29); - party._mazeDirection = DIR_EAST; - } else { - map._loadDarkSide = true; - map.load(28); - party._mazeDirection = DIR_SOUTH; - } - party.moveToRunLocation(); - } - - party._gems = 0; - result = 2; - } - break; + if (_debugFlag) + w.writeString(getTimeText()); - case Common::KEYCODE_l: - if (_vm->_mode == MODE_COMBAT) { - ErrorScroll::show(_vm, Res.NO_LOADING_IN_COMBAT); - } else { - // Close dialog and show loading dialog - result = 3; - } - break; + w3.update(); + w.update(); - case Common::KEYCODE_s: - if (_vm->_mode == MODE_COMBAT) { - ErrorScroll::show(_vm, Res.NO_SAVING_IN_COMBAT); + events.pollEventsAndWait(); + checkEvents(_vm); + if (_vm->shouldQuit()) + return 0; + } while (!_buttonValue && !events.timeElapsed()); + + switch (_buttonValue) { + case Common::KEYCODE_q: + if (Confirm::show(g_vm, Res.CONFIRM_QUIT)) { + g_vm->_quitMode = QMODE_QUIT; + result = 1; + } + break; + + case Common::KEYCODE_w: + if (Confirm::show(g_vm, Res.MR_WIZARD)) { + w.close(); + if (!windows[2]._enabled) { + sound.playFX(51); + + if (g_vm->getGameID() == GType_WorldOfXeen) { + map._loadDarkSide = false; + map.load(28); + party._mazeDirection = DIR_EAST; } else { - // Close dialog and show saving dialog - result = 4; + map._loadDarkSide = true; + map.load(29); + party._mazeDirection = DIR_SOUTH; } - break; - - case Common::KEYCODE_e: - // TODO: Toggle sound effects - break; - - case Common::KEYCODE_m: - // TODO: Toggle music - break; - - case Common::KEYCODE_ESCAPE: - result = 1; - break; - - // Goober cheat sequence - case Common::KEYCODE_g: - debugCtr = 1; - break; - case Common::KEYCODE_o: - debugCtr = (debugCtr == 1) ? 2 : 0; - break; - case Common::KEYCODE_b: - debugCtr = (debugCtr == 2) ? 3 : 0; - case Common::KEYCODE_r: - if (debugCtr == 3) - _debugFlag = true; - else - debugCtr = 0; - break; - - default: - break; + party.moveToRunLocation(); } - } while (!result); - } - - } + party._gems = 0; + result = 2; + } + break; + + case Common::KEYCODE_l: + if (_vm->_mode == MODE_COMBAT) { + ErrorScroll::show(_vm, Res.NO_LOADING_IN_COMBAT); + } else { + // Close dialog and show loading dialog + result = 3; + } + break; + + case Common::KEYCODE_s: + if (_vm->_mode == MODE_COMBAT) { + ErrorScroll::show(_vm, Res.NO_SAVING_IN_COMBAT); + } else { + // Close dialog and show saving dialog + result = 4; + } + break; + + case Common::KEYCODE_e: + // TODO: Toggle sound effects + break; + + case Common::KEYCODE_m: + // TODO: Toggle music + break; + + case Common::KEYCODE_ESCAPE: + result = 1; + break; + + // Goober cheat sequence + case Common::KEYCODE_g: + debugCtr = 1; + break; + case Common::KEYCODE_o: + debugCtr = (debugCtr == 1 || debugCtr == 2) ? 2 : 0; + break; + case Common::KEYCODE_b: + debugCtr = (debugCtr == 2) ? 3 : 0; + break; + case Common::KEYCODE_r: + if (debugCtr == 3) + _debugFlag = true; + else + debugCtr = 0; + break; + + default: + break; + } + } while (!result); w.close(); intf.drawParty(true); @@ -185,18 +180,17 @@ int ControlPanel::execute() { void ControlPanel::loadButtons() { _iconSprites.load("cpanel.icn"); - addButton(Common::Rect(214, 56, 244, 69), Common::KEYCODE_f); - addButton(Common::Rect(214, 75, 244, 88), Common::KEYCODE_m); - addButton(Common::Rect(135, 56, 165, 69), Common::KEYCODE_l, &_iconSprites); - addButton(Common::Rect(135, 75, 165, 88), Common::KEYCODE_s); + addButton(Common::Rect(214, 56, 244, 69), Common::KEYCODE_f, 0, &_iconSprites); + addButton(Common::Rect(214, 75, 244, 88), Common::KEYCODE_m, 0, &_iconSprites); + addButton(Common::Rect(135, 56, 165, 69), Common::KEYCODE_l, 0, &_iconSprites); + addButton(Common::Rect(135, 75, 165, 88), Common::KEYCODE_s, 0, &_iconSprites); // For ScummVM we've merged both Save and Save As into a single // save item, so we don't need this one addButton(Common::Rect(), 0); - _buttons.end()->_draw = false; - addButton(Common::Rect(135, 94, 165, 107), Common::KEYCODE_q); - addButton(Common::Rect(175, 113, 205, 126), Common::KEYCODE_w); + addButton(Common::Rect(135, 94, 165, 107), Common::KEYCODE_q, 0, &_iconSprites); + addButton(Common::Rect(175, 113, 205, 126), Common::KEYCODE_w, 0, &_iconSprites); } Common::String ControlPanel::getButtonText() { @@ -215,7 +209,7 @@ Common::String ControlPanel::getTimeText() const { td.tm_hour == 0 || td.tm_hour == 12 ? 12 : (td.tm_hour % 12), td.tm_min, td.tm_sec, (td.tm_hour >= 12) ? 'p' : 'c'); - uint32 playtime = g_vm->_events->playTime(); + uint32 playtime = g_vm->_events->playTime() / GAME_FRAME_RATE; Common::String playtimeStr = Common::String::format("%d:%.2d:%.2d", playtime / 3600, (playtime / 60) % 60, playtime % 60); return Common::String::format( diff --git a/engines/xeen/events.h b/engines/xeen/events.h index e6018f6a87..3ec548dac4 100644 --- a/engines/xeen/events.h +++ b/engines/xeen/events.h @@ -30,7 +30,8 @@ namespace Xeen { -#define GAME_FRAME_RATE (1000 / 18.2) +#define GAME_FRAME_RATE (1000 / 50) +#define GAME_FRAME_TIME 50 class XeenEngine; diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index c30df44bb2..8e23341046 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -1674,20 +1674,21 @@ const char *const Resources::UNABLE_TO_PICK_LOCK = "\x3""c\v010%s was unable to const char *const Resources::CONTROL_PANEL_TEXT = "\x1\xC""00\x3""c\xB""000\t000Control Panel\x3r" - "\xB""022\t045\xC""06E\xC""dfx:\t124\xC""06S\xC""dave:" - "\xB""041\t045\xC""06M\xC""dusic:\t124S\xC""06a\xC""dve:" - "\xB""060\t045\xC""06L\xC""doad:\t124\xC""06Q\xC""duit:" - "\xB""080\t084Mr \xC""06W\xC""dizard:%s\t000"; + "\xB""022\t045\xC""06L\xC""doad:\t124\xC""06E\xC""dfx:" + "\xB""041\t045\xC""06S\xC""dave:\t124\xC""06M\xC""dusic:" + "\xB""060\t045\xC""06Q\xC""duit:" + "\xB""080\t084Mr \xC""06W\xC""dizard:%s\t000\x1"; const char *const Resources::CONTROL_PANEL_BUTTONS = - "\x3""c\xB""022\t062load\t141%s" + "\x3""c\f11" + "\xB""022\t062load\t141%s" "\xB""041\t062save\t141%s" "\xB""060\t062exit" "\xB""079\t102Help\xC""d"; -const char *const Resources::ON = "on"; -const char *const Resources::OFF = "off"; +const char *const Resources::ON = "\f15on\f11"; +const char *const Resources::OFF = "\f32off\f11"; const char *const Resources::CONFIRM_QUIT = "Are you sure you want to quit?"; const char *const Resources::MR_WIZARD = - "Are you sure you want Mr.Wizard''s Help ?"; + "Are you sure you want Mr.Wizard's Help ?"; const char *const Resources::NO_LOADING_IN_COMBAT = "No Loading Allowed in Combat!"; const char *const Resources::NO_SAVING_IN_COMBAT = diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index a8776b5d60..cac44d49a5 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -144,11 +144,11 @@ Common::Error XeenEngine::loadGameState(int slot) { } bool XeenEngine::canLoadGameStateCurrently() { - return true; + return _mode != MODE_COMBAT; } bool XeenEngine::canSaveGameStateCurrently() { - return true; + return _mode != MODE_COMBAT; } void XeenEngine::playGame() { diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h index 40f6d74cc0..610fe8ba4b 100644 --- a/engines/xeen/xeen.h +++ b/engines/xeen/xeen.h @@ -102,7 +102,6 @@ enum QuitMode { struct XeenGameDescription; #define XEEN_SAVEGAME_VERSION 1 -#define GAME_FRAME_TIME 50 class XeenEngine : public Engine { private: |