From fe48af7de5207cdc8a3e2ad769f6722b345b2877 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 1 Jan 2015 11:10:26 -1000 Subject: XEEN: Split up menus file into dialogs and dialogs_options --- engines/xeen/dialogs.cpp | 83 +++++++++ engines/xeen/dialogs.h | 78 ++++++++ engines/xeen/dialogs_options.cpp | 343 ++++++++++++++++++++++++++++++++++ engines/xeen/dialogs_options.h | 89 +++++++++ engines/xeen/menus.cpp | 390 --------------------------------------- engines/xeen/menus.h | 133 ------------- engines/xeen/module.mk | 3 +- engines/xeen/xeen.cpp | 2 +- 8 files changed, 596 insertions(+), 525 deletions(-) create mode 100644 engines/xeen/dialogs.cpp create mode 100644 engines/xeen/dialogs.h create mode 100644 engines/xeen/dialogs_options.cpp create mode 100644 engines/xeen/dialogs_options.h delete mode 100644 engines/xeen/menus.cpp delete mode 100644 engines/xeen/menus.h (limited to 'engines') diff --git a/engines/xeen/dialogs.cpp b/engines/xeen/dialogs.cpp new file mode 100644 index 0000000000..1342353b9a --- /dev/null +++ b/engines/xeen/dialogs.cpp @@ -0,0 +1,83 @@ +/* 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 "xeen/dialogs.h" + +namespace Xeen { + +/** + * Saves the current list of buttons + */ +void Dialog::saveButtons() { + _savedButtons.push(_buttons); +} + +/* + * Clears the current list of defined buttons + */ +void Dialog::clearButtons() { + _buttons.clear(); +} + +void Dialog::restoreButtons() { + _buttons = _savedButtons.pop(); +} + +void Dialog::addButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool draw = true) { + _buttons.push_back(DialogButton(bounds, c, sprites, draw)); +} + +void Dialog::checkEvents() { + EventsManager &events = *_vm->_events; + events.pollEventsAndWait(); + + if (events._leftButton) { + // Check whether any button is selected + events.debounceMouse(); + Common::Point pt = events._mousePos; + + for (uint i = 0; i < _buttons.size(); ++i) { + if (_buttons[i]._bounds.contains(pt)) { + _key = _buttons[i]._c; + return; + } + } + } else if (events.isKeyPending()) { + Common::KeyState keyState; + events.getKey(keyState); + if (keyState.ascii >= 32 && keyState.ascii <= 127) { + _key = keyState.ascii; + return; + } + } +} + +/*------------------------------------------------------------------------*/ + +void SettingsBaseDialog::showContents(SpriteResource &title1, bool waitFlag) { + checkEvents(); +} + +/*------------------------------------------------------------------------*/ + +} // End of namespace Xeen diff --git a/engines/xeen/dialogs.h b/engines/xeen/dialogs.h new file mode 100644 index 0000000000..21bf57c8e7 --- /dev/null +++ b/engines/xeen/dialogs.h @@ -0,0 +1,78 @@ +/* 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 XEEN_DIALOGS_H +#define XEEN_DIALOGS_H + +#include "common/array.h" +#include "common/stack.h" +#include "common/rect.h" +#include "xeen/xeen.h" + +namespace Xeen { + +class DialogButton { +public: + Common::Rect _bounds; + SpriteResource *_sprites; + char _c; + bool _draw; + + DialogButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool draw) : + _bounds(bounds), _c(c), _sprites(sprites), _draw(draw) {} + + DialogButton() : _c('\0'), _sprites(nullptr), _draw(false) {} +}; + +class Dialog { +private: + Common::Stack< Common::Array > _savedButtons; +protected: + XeenEngine *_vm; + Common::Array _buttons; + char _key; + + virtual void doScroll(bool drawFlag, bool doFade); + + void checkEvents(); +public: + Dialog(XeenEngine *vm): _vm(vm), _key('\0') {} + + void saveButtons(); + + void clearButtons(); + + void restoreButtons(); + + void addButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool draw); +}; + +class SettingsBaseDialog : public Dialog { +protected: + virtual void showContents(SpriteResource &title1, bool mode); +public: + SettingsBaseDialog(XeenEngine *vm) : Dialog(vm) {} +}; + +} // End of namespace Xeen + +#endif /* XEEN_DIALOGS_H */ diff --git a/engines/xeen/dialogs_options.cpp b/engines/xeen/dialogs_options.cpp new file mode 100644 index 0000000000..e4ebf27b79 --- /dev/null +++ b/engines/xeen/dialogs_options.cpp @@ -0,0 +1,343 @@ +/* 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 "xeen/dialogs_options.h" + +namespace Xeen { + +void OptionsMenu::show(XeenEngine *vm) { + OptionsMenu *menu; + + switch (vm->getGameID()) { + case GType_Clouds: + menu = new CloudsOptionsMenu(vm); + break; + case GType_DarkSide: + menu = new DarkSideOptionsMenu(vm); + break; + case GType_WorldOfXeen: + menu = new WorldOptionsMenu(vm); + break; + default: + error("Unsupported game"); + break; + } + + menu->execute(); + delete menu; +} + +void OptionsMenu::execute() { + SpriteResource special("special.icn"); + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + + File newBright("newbrigh.m"); + _vm->_sound->playMusic(newBright); + + screen._windows[28].setBounds(Common::Rect(72, 25, 248, 175)); + + Common::String title1, title2; + startup(title1, title2); + SpriteResource title1Sprites(title1), title2Sprites(title2); + + bool firstTime = true, doFade = true; + while (!_vm->shouldQuit()) { + setBackground(doFade); + events.setCursor(0); + + if (firstTime) { + firstTime = false; + warning("TODO: Read existing save file"); + } + + showTitles1(title1Sprites); + showTitles2(); + + clearButtons(); + setupButtons(&title2Sprites); + openWindow(); + + while (!_vm->shouldQuit()) { + // Show the dialog with a continually animating background + while (!_vm->shouldQuit() && _key == '\0') + showContents(title1Sprites, true); + if (_vm->shouldQuit()) + return; + + // Handle keypress + switch (toupper(_key)) { + case 'C': + case 'V': + // Show credits + break; + default: + break; + } + _key = '\0'; + } + } +} + +void OptionsMenu::showTitles1(SpriteResource &sprites) { + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + + int frameNum = 0; + while (!_vm->shouldQuit() && !events.isKeyMousePressed()) { + events.updateGameCounter(); + + frameNum = ++frameNum % (_vm->getGameID() == GType_WorldOfXeen ? 5 : 10); + screen.restoreBackground(); + sprites.draw(screen, frameNum); + + events.wait(4, true); + } +} + +void OptionsMenu::showTitles2() { + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + SoundManager &sound = *_vm->_sound; + + File voc("elect.voc"); + SpriteResource titleSprites("title2b.raw"); + SpriteResource kludgeSprites("kludge.int"); + SpriteResource title2Sprites[8] = { + SpriteResource("title2b.int"), SpriteResource("title2c.int"), + SpriteResource("title2d.int"), SpriteResource("title2e.int"), + SpriteResource("title2f.int"), SpriteResource("title2g.int"), + SpriteResource("title2h.int"), SpriteResource("title2i.int"), + }; + + kludgeSprites.draw(screen, 0); + screen.saveBackground(); + sound.playSample(&voc, 0); + + for (int i = 0; i < 30 && !_vm->shouldQuit(); ++i) { + events.updateGameCounter(); + screen.restoreBackground(); + title2Sprites[i / 4].draw(screen, i % 4); + screen._windows[0].update(); + + if (i == 19) + sound.playSample(nullptr, 0); + + while (!_vm->shouldQuit() && events.timeElapsed() < 2) + events.pollEventsAndWait(); + } + + screen.restoreBackground(); + screen._windows[0].update(); +} + +void OptionsMenu::setupButtons(SpriteResource *buttons) { + addButton(Common::Rect(124, 87, 124 + 53, 87 + 10), 'S', buttons, false); + addButton(Common::Rect(126, 98, 126 + 47, 98 + 10), 'L', buttons, false); + addButton(Common::Rect(91, 110, 91 + 118, 110 + 10), 'C', buttons, false); + addButton(Common::Rect(85, 121, 85 + 131, 121 + 10), 'O', buttons, false); +} + +void WorldOptionsMenu::setupButtons(SpriteResource *buttons) { + addButton(Common::Rect(93, 53, 93 + 134, 53 + 20), 'S', buttons, true); + addButton(Common::Rect(93, 78, 93 + 134, 78 + 20), 'L', buttons, true); + addButton(Common::Rect(93, 103, 93 + 134, 103 + 20), 'C', buttons, true); + addButton(Common::Rect(93, 128, 93 + 134, 128 + 20), 'O', buttons, true); +} + +/*------------------------------------------------------------------------*/ + +void CloudsOptionsMenu::startup(Common::String &title1, Common::String &title2) { + title1 = "title1.int"; + title2 = "title1a.int"; +} + +/** +* Draws the scroll in the background +*/ +void Dialog::doScroll(bool drawFlag, bool doFade) { + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + const int SCROLL_L[8] = { 29, 23, 15, 251, 245, 233, 207, 185 }; + const int SCROLL_R[8] = { 165, 171, 198, 218, 228, 245, 264, 281 }; + + saveButtons(); + clearButtons(); + screen.saveBackground(); + + // Load hand vga files + SpriteResource *hand[16]; + for (int i = 0; i < 16; ++i) { + Common::String name = Common::String::format("hand%02u.vga"); + hand[i] = new SpriteResource(name); + } + + // Load marb vga files + SpriteResource *marb[5]; + for (int i = 1; i < 5; ++i) { + Common::String name = Common::String::format("marb%02u.vga"); + marb[i] = new SpriteResource(name); + } + + if (drawFlag) { + for (int i = 22; i > 0; --i) { + events.updateGameCounter(); + screen.restoreBackground(); + + if (i > 0 && i <= 14) { + hand[i - 1]->draw(screen, 0); + } else { + // TODO: Check '800h'.. horizontal reverse maybe? + hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 14], 0)); + marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 14], 0)); + } + + if (i <= 20) { + marb[i / 5]->draw(screen, i % 5); + } + + while (!_vm->shouldQuit() && _vm->_events->timeElapsed() == 0) + _vm->_events->pollEventsAndWait(); + + screen._windows[0].update(); + if (i == 0 && doFade) + screen.fadeIn(2); + } + } else { + for (int i = 0; i < 22 && !events.isKeyMousePressed(); ++i) { + events.updateGameCounter(); + screen.restoreBackground(); + + if (i < 14) { + hand[i]->draw(screen, 0); + } + else { + // TODO: Check '800h'.. horizontal reverse maybe? + hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 7], 0)); + marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 7], 0)); + } + + if (i < 20) { + marb[i / 5]->draw(screen, i % 5); + } + + while (!_vm->shouldQuit() && _vm->_events->timeElapsed() == 0) + _vm->_events->pollEventsAndWait(); + + screen._windows[0].update(); + if (i == 0 && doFade) + screen.fadeIn(2); + } + } + + if (drawFlag) { + hand[0]->draw(screen, 0); + marb[0]->draw(screen, 0); + } else { + screen.restoreBackground(); + } + + screen._windows[0].update(); + restoreButtons(); + + // Free resources + for (int i = 1; i < 5; ++i) + delete marb[i]; + for (int i = 0; i < 16; ++i) + delete hand[i]; +} + +/*------------------------------------------------------------------------*/ + +void DarkSideOptionsMenu::startup(Common::String &title1, Common::String &title2) { + title1 = "title2.int"; + title2 = "title2a.int"; +} + +/** +* Draws the scroll in the background +*/ +void DarkSideOptionsMenu::doScroll(bool drawFlag, bool doFade) { + if (doFade) { + _vm->_screen->fadeIn(2); + } +} + +void WorldOptionsMenu::startup(Common::String &title1, Common::String &title2) { + title1 = "world.int"; + title2 = "start.icn"; + + Screen &screen = *_vm->_screen; + screen.fadeOut(4); + screen.loadPalette("dark.pal"); + _vm->_events->clearEvents(); +} + +void WorldOptionsMenu::setBackground(bool doFade) { + Screen &screen = *_vm->_screen; + screen.loadBackground("world.raw"); + screen.saveBackground(); + + if (doFade) + screen.fadeIn(4); +} + +void WorldOptionsMenu::openWindow() { + _vm->_screen->_windows[28].open(); +} + +void WorldOptionsMenu::showContents(SpriteResource &title1, bool waitFlag) { + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + events.updateGameCounter(); + + // Draw the background frame in a continous cycle + _bgFrame = ++_bgFrame % 5; + title1.draw(screen._windows[0], _bgFrame); + + // Draw the basic frame for the optitons menu and title text + screen._windows[28].frame(); + screen._windows[28].writeString("\x0D\x01\003c\014dMight and Magic Options\n" + "World of Xeen\x02\n" + "\v117Copyright (c) 1993 NWC, Inc.\n" + "All Rights Reserved\x01"); + + for (uint btnIndex = 0; btnIndex < _buttons.size(); ++btnIndex) { + DialogButton &btn = _buttons[btnIndex]; + if (btn._draw) { + btn._sprites->draw(screen._windows[0], btnIndex * 2, + Common::Point(btn._bounds.left, btn._bounds.top)); + } + } + + if (waitFlag) { + screen._windows[0].update(); + + while (!_vm->shouldQuit() && _key == Common::KEYCODE_INVALID && + events.timeElapsed() < 3) { + checkEvents(); + } + } +} + +} // End of namespace Xeen diff --git a/engines/xeen/dialogs_options.h b/engines/xeen/dialogs_options.h new file mode 100644 index 0000000000..591ab5e043 --- /dev/null +++ b/engines/xeen/dialogs_options.h @@ -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. + * + */ + +#ifndef XEEN_DIALOGS_OPTIONS_H +#define XEEN_DIALOGS_OPTIONS_H + +#include "xeen/xeen.h" +#include "xeen/dialogs.h" + +namespace Xeen { + +class OptionsMenu : public SettingsBaseDialog { +private: + void execute(); +protected: + OptionsMenu(XeenEngine *vm) : SettingsBaseDialog(vm) {} +protected: + virtual void startup(Common::String &title1, Common::String &title2) = 0; + + virtual void setBackground(bool doFade) {} + + virtual void showTitles1(SpriteResource &sprites); + + virtual void showTitles2(); + + virtual void setupButtons(SpriteResource *buttons); + + virtual void openWindow() {} +public: + static void show(XeenEngine *vm); +}; + +class CloudsOptionsMenu : public OptionsMenu { +protected: + virtual void startup(Common::String &title1, Common::String &title2); +public: + CloudsOptionsMenu(XeenEngine *vm) : OptionsMenu(vm) {} +}; + +class DarkSideOptionsMenu : public OptionsMenu { +protected: + virtual void startup(Common::String &title1, Common::String &title2); + + virtual void doScroll(bool drawFlag, bool doFade); +public: + DarkSideOptionsMenu(XeenEngine *vm) : OptionsMenu(vm) {} +}; + +class WorldOptionsMenu : public DarkSideOptionsMenu { +private: + int _bgFrame; +protected: + virtual void startup(Common::String &title1, Common::String &title2); + + virtual void setBackground(bool doFade); + + virtual void showTitles2() {} + + virtual void setupButtons(SpriteResource *buttons); + + virtual void openWindow(); + + virtual void showContents(SpriteResource &title1, bool mode); +public: + WorldOptionsMenu(XeenEngine *vm) : DarkSideOptionsMenu(vm), _bgFrame(0) {} +}; + +} // End of namespace Xeen + +#endif /* XEEN_DIALOGS_H */ diff --git a/engines/xeen/menus.cpp b/engines/xeen/menus.cpp deleted file mode 100644 index 92badb9f81..0000000000 --- a/engines/xeen/menus.cpp +++ /dev/null @@ -1,390 +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 "xeen/menus.h" - -namespace Xeen { - -/** - * Saves the current list of buttons - */ -void Dialog::saveButtons() { - _savedButtons.push(_buttons); -} - -/* - * Clears the current list of defined buttons - */ -void Dialog::clearButtons() { - _buttons.clear(); -} - -void Dialog::restoreButtons() { - _buttons = _savedButtons.pop(); -} - -void Dialog::addButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool draw = true) { - _buttons.push_back(DialogButton(bounds, c, sprites, draw)); -} - -void Dialog::checkEvents() { - EventsManager &events = *_vm->_events; - events.pollEventsAndWait(); - - if (events._leftButton) { - // Check whether any button is selected - events.debounceMouse(); - Common::Point pt = events._mousePos; - - for (uint i = 0; i < _buttons.size(); ++i) { - if (_buttons[i]._bounds.contains(pt)) { - _key = _buttons[i]._c; - return; - } - } - } else if (events.isKeyPending()) { - Common::KeyState keyState; - events.getKey(keyState); - if (keyState.ascii >= 32 && keyState.ascii <= 127) { - _key = keyState.ascii; - return; - } - } -} - -/*------------------------------------------------------------------------*/ - -void SettingsBaseDialog::showContents(SpriteResource &title1, bool waitFlag) { - checkEvents(); -} - -/*------------------------------------------------------------------------*/ - -void OptionsMenu::show(XeenEngine *vm) { - OptionsMenu *menu; - - switch (vm->getGameID()) { - case GType_Clouds: - menu = new CloudsOptionsMenu(vm); - break; - case GType_DarkSide: - menu = new DarkSideOptionsMenu(vm); - break; - case GType_WorldOfXeen: - menu = new WorldOptionsMenu(vm); - break; - default: - error("Unsupported game"); - break; - } - - menu->execute(); - delete menu; -} - -void OptionsMenu::execute() { - SpriteResource special("special.icn"); - Screen &screen = *_vm->_screen; - EventsManager &events = *_vm->_events; - - File newBright("newbrigh.m"); - _vm->_sound->playMusic(newBright); - - screen._windows[28].setBounds(Common::Rect(72, 25, 248, 175)); - - Common::String title1, title2; - startup(title1, title2); - SpriteResource title1Sprites(title1), title2Sprites(title2); - - bool firstTime = true, doFade = true; - while (!_vm->shouldQuit()) { - setBackground(doFade); - events.setCursor(0); - - if (firstTime) { - firstTime = false; - warning("TODO: Read existing save file"); - } - - while (!_vm->shouldQuit()) { - showTitles1(title1Sprites); - showTitles2(); - - reopen: - clearButtons(); - setupButtons(&title2Sprites); - openWindow(); - - while (!_vm->shouldQuit()) { - // Show the dialog with a continually animating background - while (!_vm->shouldQuit() && _key == Common::KEYCODE_INVALID) - showContents(title1Sprites, true); - if (_vm->shouldQuit()) - return; - } - } - } -} - -void OptionsMenu::showTitles1(SpriteResource &sprites) { - Screen &screen = *_vm->_screen; - EventsManager &events = *_vm->_events; - - int frameNum = 0; - while (!_vm->shouldQuit() && !events.isKeyMousePressed()) { - events.updateGameCounter(); - - frameNum = ++frameNum % (_vm->getGameID() == GType_WorldOfXeen ? 5 : 10); - screen.restoreBackground(); - sprites.draw(screen, frameNum); - - events.wait(4, true); - } -} - -void OptionsMenu::showTitles2() { - Screen &screen = *_vm->_screen; - EventsManager &events = *_vm->_events; - SoundManager &sound = *_vm->_sound; - - File voc("elect.voc"); - SpriteResource titleSprites("title2b.raw"); - SpriteResource kludgeSprites("kludge.int"); - SpriteResource title2Sprites[8] = { - SpriteResource("title2b.int"), SpriteResource("title2c.int"), - SpriteResource("title2d.int"), SpriteResource("title2e.int"), - SpriteResource("title2f.int"), SpriteResource("title2g.int"), - SpriteResource("title2h.int"), SpriteResource("title2i.int"), - }; - - kludgeSprites.draw(screen, 0); - screen.saveBackground(); - sound.playSample(&voc, 0); - - for (int i = 0; i < 30 && !_vm->shouldQuit(); ++i) { - events.updateGameCounter(); - screen.restoreBackground(); - title2Sprites[i / 4].draw(screen, i % 4); - screen._windows[0].update(); - - if (i == 19) - sound.playSample(nullptr, 0); - - while (!_vm->shouldQuit() && events.timeElapsed() < 2) - events.pollEventsAndWait(); - } - - screen.restoreBackground(); - screen._windows[0].update(); -} - -void OptionsMenu::setupButtons(SpriteResource *buttons) { - addButton(Common::Rect(124, 87, 124 + 53, 87 + 10), 'S', buttons, false); - addButton(Common::Rect(126, 98, 126 + 47, 98 + 10), 'L', buttons, false); - addButton(Common::Rect(91, 110, 91 + 118, 110 + 10), 'C', buttons, false); - addButton(Common::Rect(85, 121, 85 + 131, 121 + 10), 'O', buttons, false); -} - -void WorldOptionsMenu::setupButtons(SpriteResource *buttons) { - addButton(Common::Rect(93, 53, 93 + 134, 53 + 20), 'S', buttons, true); - addButton(Common::Rect(93, 78, 93 + 134, 78 + 20), 'L', buttons, true); - addButton(Common::Rect(93, 103, 93 + 134, 103 + 20), 'C', buttons, true); - addButton(Common::Rect(93, 128, 93 + 134, 128 + 20), 'O', buttons, true); -} - -/*------------------------------------------------------------------------*/ - -void CloudsOptionsMenu::startup(Common::String &title1, Common::String &title2) { - title1 = "title1.int"; - title2 = "title1a.int"; -} - -/** -* Draws the scroll in the background -*/ -void Dialog::doScroll(bool drawFlag, bool doFade) { - Screen &screen = *_vm->_screen; - EventsManager &events = *_vm->_events; - const int SCROLL_L[8] = { 29, 23, 15, 251, 245, 233, 207, 185 }; - const int SCROLL_R[8] = { 165, 171, 198, 218, 228, 245, 264, 281 }; - - saveButtons(); - clearButtons(); - screen.saveBackground(); - - // Load hand vga files - SpriteResource *hand[16]; - for (int i = 0; i < 16; ++i) { - Common::String name = Common::String::format("hand%02u.vga"); - hand[i] = new SpriteResource(name); - } - - // Load marb vga files - SpriteResource *marb[5]; - for (int i = 1; i < 5; ++i) { - Common::String name = Common::String::format("marb%02u.vga"); - marb[i] = new SpriteResource(name); - } - - if (drawFlag) { - for (int i = 22; i > 0; --i) { - events.updateGameCounter(); - screen.restoreBackground(); - - if (i > 0 && i <= 14) { - hand[i - 1]->draw(screen, 0); - } else { - // TODO: Check '800h'.. horizontal reverse maybe? - hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 14], 0)); - marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 14], 0)); - } - - if (i <= 20) { - marb[i / 5]->draw(screen, i % 5); - } - - while (!_vm->shouldQuit() && _vm->_events->timeElapsed() == 0) - _vm->_events->pollEventsAndWait(); - - screen._windows[0].update(); - if (i == 0 && doFade) - screen.fadeIn(2); - } - } else { - for (int i = 0; i < 22 && !events.isKeyMousePressed(); ++i) { - events.updateGameCounter(); - screen.restoreBackground(); - - if (i < 14) { - hand[i]->draw(screen, 0); - } - else { - // TODO: Check '800h'.. horizontal reverse maybe? - hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 7], 0)); - marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 7], 0)); - } - - if (i < 20) { - marb[i / 5]->draw(screen, i % 5); - } - - while (!_vm->shouldQuit() && _vm->_events->timeElapsed() == 0) - _vm->_events->pollEventsAndWait(); - - screen._windows[0].update(); - if (i == 0 && doFade) - screen.fadeIn(2); - } - } - - if (drawFlag) { - hand[0]->draw(screen, 0); - marb[0]->draw(screen, 0); - } else { - screen.restoreBackground(); - } - - screen._windows[0].update(); - restoreButtons(); - - // Free resources - for (int i = 1; i < 5; ++i) - delete marb[i]; - for (int i = 0; i < 16; ++i) - delete hand[i]; -} - -/*------------------------------------------------------------------------*/ - -void DarkSideOptionsMenu::startup(Common::String &title1, Common::String &title2) { - title1 = "title2.int"; - title2 = "title2a.int"; -} - -/** -* Draws the scroll in the background -*/ -void DarkSideOptionsMenu::doScroll(bool drawFlag, bool doFade) { - if (doFade) { - _vm->_screen->fadeIn(2); - } -} - -void WorldOptionsMenu::startup(Common::String &title1, Common::String &title2) { - title1 = "world.int"; - title2 = "start.icn"; - - Screen &screen = *_vm->_screen; - screen.fadeOut(4); - screen.loadPalette("dark.pal"); - _vm->_events->clearEvents(); -} - -void WorldOptionsMenu::setBackground(bool doFade) { - Screen &screen = *_vm->_screen; - screen.loadBackground("world.raw"); - screen.saveBackground(); - - if (doFade) - screen.fadeIn(4); -} - -void WorldOptionsMenu::openWindow() { - _vm->_screen->_windows[28].open(); -} - -void WorldOptionsMenu::showContents(SpriteResource &title1, bool waitFlag) { - Screen &screen = *_vm->_screen; - EventsManager &events = *_vm->_events; - events.updateGameCounter(); - - // Draw the background frame in a continous cycle - _bgFrame = ++_bgFrame % 5; - title1.draw(screen._windows[0], _bgFrame); - - // Draw the basic frame for the optitons menu and title text - screen._windows[28].frame(); - screen._windows[28].writeString("\x0D\x01\003c\014dMight and Magic Options\n" - "World of Xeen\x02\n" - "\v117Copyright (c) 1993 NWC, Inc.\n" - "All Rights Reserved\x01"); - - for (uint btnIndex = 0; btnIndex < _buttons.size(); ++btnIndex) { - DialogButton &btn = _buttons[btnIndex]; - if (btn._draw) { - btn._sprites->draw(screen._windows[0], btnIndex * 2, - Common::Point(btn._bounds.left, btn._bounds.top)); - } - } - - if (waitFlag) { - screen._windows[0].update(); - - while (!_vm->shouldQuit() && _key == Common::KEYCODE_INVALID && - events.timeElapsed() < 3) { - checkEvents(); - } - } -} - -} // End of namespace Xeen diff --git a/engines/xeen/menus.h b/engines/xeen/menus.h deleted file mode 100644 index 65e3553110..0000000000 --- a/engines/xeen/menus.h +++ /dev/null @@ -1,133 +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 XEEN_MENUS_H -#define XEEN_MENUS_H - -#include "common/array.h" -#include "common/stack.h" -#include "common/rect.h" -#include "xeen/xeen.h" - -namespace Xeen { - -class DialogButton { -public: - Common::Rect _bounds; - SpriteResource *_sprites; - char _c; - bool _draw; - - DialogButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool draw) : - _bounds(bounds), _c(c), _sprites(sprites), _draw(draw) {} - - DialogButton() : _c('\0'), _sprites(nullptr), _draw(false) {} -}; - -class Dialog { -private: - Common::Stack< Common::Array > _savedButtons; -protected: - XeenEngine *_vm; - Common::Array _buttons; - char _key; - - virtual void doScroll(bool drawFlag, bool doFade); - - void checkEvents(); -public: - Dialog(XeenEngine *vm): _vm(vm), _key('\0') {} - - void saveButtons(); - - void clearButtons(); - - void restoreButtons(); - - void addButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool draw); -}; - -class SettingsBaseDialog : public Dialog { -protected: - virtual void showContents(SpriteResource &title1, bool mode); -public: - SettingsBaseDialog(XeenEngine *vm) : Dialog(vm) {} -}; -class OptionsMenu : public SettingsBaseDialog { -private: - void execute(); -protected: - OptionsMenu(XeenEngine *vm) : SettingsBaseDialog(vm) {} -protected: - virtual void startup(Common::String &title1, Common::String &title2) = 0; - - virtual void setBackground(bool doFade) {} - - virtual void showTitles1(SpriteResource &sprites); - - virtual void showTitles2(); - - virtual void setupButtons(SpriteResource *buttons); - - virtual void openWindow() {} -public: - static void show(XeenEngine *vm); -}; - -class CloudsOptionsMenu : public OptionsMenu { -protected: - virtual void startup(Common::String &title1, Common::String &title2); -public: - CloudsOptionsMenu(XeenEngine *vm) : OptionsMenu(vm) {} -}; - -class DarkSideOptionsMenu : public OptionsMenu { -protected: - virtual void startup(Common::String &title1, Common::String &title2); - - virtual void doScroll(bool drawFlag, bool doFade); -public: - DarkSideOptionsMenu(XeenEngine *vm) : OptionsMenu(vm) {} -}; - -class WorldOptionsMenu : public DarkSideOptionsMenu { -private: - int _bgFrame; -protected: - virtual void startup(Common::String &title1, Common::String &title2); - - virtual void setBackground(bool doFade); - - virtual void showTitles2() {} - - virtual void setupButtons(SpriteResource *buttons); - - virtual void openWindow(); - - virtual void showContents(SpriteResource &title1, bool mode); -public: - WorldOptionsMenu(XeenEngine *vm) : DarkSideOptionsMenu(vm), _bgFrame(0) {} -}; - -} // End of namespace Xeen - -#endif /* XEEN_MENUS_H */ diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk index 9d7b0ebb70..99eb98174e 100644 --- a/engines/xeen/module.mk +++ b/engines/xeen/module.mk @@ -6,9 +6,10 @@ MODULE_OBJS := \ worldofxeen\worldofxeen_game.o \ debugger.o \ detection.o \ + dialogs.o \ + dialogs_options.o \ events.o \ font.o \ - menus.o \ resdata.o \ resources.o \ screen.o \ diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index 1027572c67..cbdb6f3104 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -28,7 +28,7 @@ #include "graphics/scaler.h" #include "graphics/thumbnail.h" #include "xeen/xeen.h" -#include "xeen/menus.h" +#include "xeen/dialogs_options.h" #include "xeen/resources.h" namespace Xeen { -- cgit v1.2.3