diff options
author | Nicola Mettifogo | 2008-07-25 06:35:02 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2008-07-25 06:35:02 +0000 |
commit | 884a6b1dfb465990757c9ea3619d874a0c8c208c (patch) | |
tree | 5465df115b32af87e3b86511d59873b1ba442f82 /engines/parallaction | |
parent | d1a6b175f5ef7f64435477775015730657195a11 (diff) | |
download | scummvm-rg350-884a6b1dfb465990757c9ea3619d874a0c8c208c.tar.gz scummvm-rg350-884a6b1dfb465990757c9ea3619d874a0c8c208c.tar.bz2 scummvm-rg350-884a6b1dfb465990757c9ea3619d874a0c8c208c.zip |
Converted BRA to work with the new menu approach. It is not yet well plugged-in as in NS, but it suffices for the moment.
svn-id: r33272
Diffstat (limited to 'engines/parallaction')
-rw-r--r-- | engines/parallaction/gui.cpp | 92 | ||||
-rw-r--r-- | engines/parallaction/gui.h | 93 | ||||
-rw-r--r-- | engines/parallaction/gui_br.cpp | 333 | ||||
-rw-r--r-- | engines/parallaction/gui_ns.cpp | 232 | ||||
-rw-r--r-- | engines/parallaction/module.mk | 1 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 10 | ||||
-rw-r--r-- | engines/parallaction/parallaction_br.cpp | 18 |
7 files changed, 464 insertions, 315 deletions
diff --git a/engines/parallaction/gui.cpp b/engines/parallaction/gui.cpp new file mode 100644 index 0000000000..2dbe64fcf6 --- /dev/null +++ b/engines/parallaction/gui.cpp @@ -0,0 +1,92 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +#include "parallaction/gui.h" + +namespace Parallaction { + +bool MenuInputHelper::run() { + if (_newState == 0) { + debugC(3, kDebugExec, "MenuInputHelper has set NULL state"); + return false; + } + + if (_newState != _state) { + debugC(3, kDebugExec, "MenuInputHelper changing state to '%s'", _newState->_name.c_str()); + + _newState->enter(); + _state = _newState; + } + + _newState = _state->run(); + + return true; +} + +MenuInputHelper::~MenuInputHelper() { + StateMap::iterator b = _map.begin(); + for ( ; b != _map.end(); b++) { + delete b->_value; + } + _map.clear(); +} + + +void Parallaction::runGuiFrame() { + if (_input->_inputMode != Input::kInputModeMenu) { + return; + } + + if (!_menuHelper) { + error("No menu helper defined!"); + } + + bool res = _menuHelper->run(); + + if (!res) { + cleanupGui(); + _input->_inputMode = Input::kInputModeGame; + } + +} + +void Parallaction::cleanupGui() { + delete _menuHelper; + _menuHelper = 0; +} + +void Parallaction::setInternLanguage(uint id) { + //TODO: assert id! + + _language = id; + _disk->setLanguage(id); +} + +uint Parallaction::getInternLanguage() { + return _language; +} + + +} // namespace Parallaction diff --git a/engines/parallaction/gui.h b/engines/parallaction/gui.h new file mode 100644 index 0000000000..dc6d1bc71b --- /dev/null +++ b/engines/parallaction/gui.h @@ -0,0 +1,93 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +#ifndef PARALLACTION_GUI_H +#define PARALLACTION_GUI_H + +#include "common/system.h" +#include "common/hashmap.h" + +#include "parallaction/input.h" +#include "parallaction/parallaction.h" +#include "parallaction/sound.h" + + +namespace Parallaction { + +class MenuInputState; + +class MenuInputHelper { + typedef Common::HashMap<Common::String, MenuInputState*> StateMap; + + StateMap _map; + MenuInputState *_state; + MenuInputState *_newState; + +public: + MenuInputHelper() : _state(0) { + } + + ~MenuInputHelper(); + + void setState(const Common::String &name) { + // bootstrap routine + _newState = getState(name); + assert(_newState); + } + + void addState(const Common::String &name, MenuInputState *state) { + _map.setVal(name, state); + } + + MenuInputState *getState(const Common::String &name) { + return _map[name]; + } + + bool run(); +}; + +class MenuInputState { + +protected: + MenuInputHelper *_helper; + +public: + MenuInputState(const Common::String &name, MenuInputHelper *helper) : _helper(helper), _name(name) { + debugC(3, kDebugExec, "MenuInputState(%s)", name.c_str()); + _helper->addState(name, this); + } + + Common::String _name; + + virtual ~MenuInputState() { } + + virtual MenuInputState* run() = 0; + virtual void enter() = 0; +}; + + +} // namespace Parallaction + +#endif diff --git a/engines/parallaction/gui_br.cpp b/engines/parallaction/gui_br.cpp index 0be070e345..2a82eca041 100644 --- a/engines/parallaction/gui_br.cpp +++ b/engines/parallaction/gui_br.cpp @@ -25,184 +25,267 @@ #include "common/system.h" - +#include "parallaction/gui.h" #include "parallaction/input.h" #include "parallaction/parallaction.h" namespace Parallaction { -enum MenuOptions { - kMenuPart0 = 0, - kMenuPart1 = 1, - kMenuPart2 = 2, - kMenuPart3 = 3, - kMenuPart4 = 4, - kMenuLoadGame = 5, - kMenuQuit = 6 -}; - +class SplashInputState_BR : public MenuInputState { +protected: + Common::String _slideName; + uint32 _timeOut; + Common::String _nextState; + uint32 _startTime; + Palette blackPal; + Palette pal; -void Parallaction_br::guiStart() { + Parallaction_br *_vm; + int _fadeSteps; - // TODO: load progress value from special save game - _progress = 3; +public: + SplashInputState_BR(Parallaction_br *vm, const Common::String &name, MenuInputHelper *helper) : MenuInputState(name, helper), _vm(vm) { + } - int option = guiShowMenu(); - switch (option) { - case kMenuQuit: - _engineFlags |= kEngineQuit; - break; + virtual MenuInputState* run() { + if (_fadeSteps > 0) { + pal.fadeTo(blackPal, 1); + _vm->_gfx->setPalette(pal); + _fadeSteps--; + // TODO: properly implement timers to avoid delay calls + _vm->_system->delayMillis(20); + return this; + } - case kMenuLoadGame: - warning("loadgame not yet implemented"); - break; + if (_fadeSteps == 0) { + _vm->freeBackground(); + return _helper->getState(_nextState); + } - default: - _part = option; - _disk->selectArchive(_partNames[_part]); - startPart(); + uint32 curTime = _vm->_system->getMillis(); + if (curTime - _startTime > _timeOut) { + _fadeSteps = 64; + pal.clone(_vm->_gfx->_backgroundInfo.palette); + } + return this; } -} -void Parallaction_br::guiSplash(const char *name) { + virtual void enter() { + _vm->_gfx->clearScreen(); + _vm->_gfx->setBackground(kBackgroundSlide, _slideName.c_str(), 0, 0); + _vm->_gfx->_backgroundInfo.x = (_vm->_screenWidth - _vm->_gfx->_backgroundInfo.width) >> 1; + _vm->_gfx->_backgroundInfo.y = (_vm->_screenHeight - _vm->_gfx->_backgroundInfo.height) >> 1; + _vm->_input->setMouseState(MOUSE_DISABLED); - _gfx->clearScreen(); - _gfx->setBackground(kBackgroundSlide, name, 0, 0); - _gfx->_backgroundInfo.x = (_screenWidth - _gfx->_backgroundInfo.width) >> 1; - _gfx->_backgroundInfo.y = (_screenHeight - _gfx->_backgroundInfo.height) >> 1; - _gfx->updateScreen(); - _system->delayMillis(600); + _startTime = g_system->getMillis(); + _fadeSteps = -1; + } +}; - Palette blackPal; - Palette pal(_gfx->_backgroundInfo.palette); - for (uint i = 0; i < 64; i++) { - pal.fadeTo(blackPal, 1); - _gfx->setPalette(pal); - _gfx->updateScreen(); - _system->delayMillis(20); +class SplashInputState0_BR : public SplashInputState_BR { + +public: + SplashInputState0_BR(Parallaction_br *vm, MenuInputHelper *helper) : SplashInputState_BR(vm, "intro0", helper) { + _slideName = "dyna"; + _timeOut = 600; + _nextState = "intro1"; } +}; -} +class SplashInputState1_BR : public SplashInputState_BR { -#define MENUITEMS_X 250 -#define MENUITEMS_Y 200 +public: + SplashInputState1_BR(Parallaction_br *vm, MenuInputHelper *helper) : SplashInputState_BR(vm, "intro1", helper) { + _slideName = "core"; + _timeOut = 600; + _nextState = "mainmenu"; + } +}; -#define MENUITEM_WIDTH 190 -#define MENUITEM_HEIGHT 18 +class MainMenuInputState_BR : public MenuInputState { + Parallaction_br *_vm; -Frames* Parallaction_br::guiRenderMenuItem(const char *text) { - // this builds a surface containing two copies of the text. - // one is in normal color, the other is inverted. - // the two 'frames' are used to display selected/unselected menu items + #define MENUITEMS_X 250 + #define MENUITEMS_Y 200 - Graphics::Surface *surf = new Graphics::Surface; - surf->create(MENUITEM_WIDTH, MENUITEM_HEIGHT*2, 1); + #define MENUITEM_WIDTH 190 + #define MENUITEM_HEIGHT 18 - // build first frame to be displayed when item is not selected - if (getPlatform() == Common::kPlatformPC) { - _menuFont->setColor(0); - } else { - _menuFont->setColor(7); - } - _menuFont->drawString((byte*)surf->getBasePtr(5, 2), MENUITEM_WIDTH, text); + Frames* renderMenuItem(const char *text) { + // this builds a surface containing two copies of the text. + // one is in normal color, the other is inverted. + // the two 'frames' are used to display selected/unselected menu items - // build second frame to be displayed when item is selected - _menuFont->drawString((byte*)surf->getBasePtr(5, 2 + MENUITEM_HEIGHT), MENUITEM_WIDTH, text); - byte *s = (byte*)surf->getBasePtr(0, MENUITEM_HEIGHT); - for (int i = 0; i < surf->w * MENUITEM_HEIGHT; i++) { - *s++ ^= 0xD; - } + Graphics::Surface *surf = new Graphics::Surface; + surf->create(MENUITEM_WIDTH, MENUITEM_HEIGHT*2, 1); - // wrap the surface into the suitable Frames adapter - return new SurfaceToMultiFrames(2, MENUITEM_WIDTH, MENUITEM_HEIGHT, surf); -} + // build first frame to be displayed when item is not selected + if (_vm->getPlatform() == Common::kPlatformPC) { + _vm->_menuFont->setColor(0); + } else { + _vm->_menuFont->setColor(7); + } + _vm->_menuFont->drawString((byte*)surf->getBasePtr(5, 2), MENUITEM_WIDTH, text); + + // build second frame to be displayed when item is selected + _vm->_menuFont->drawString((byte*)surf->getBasePtr(5, 2 + MENUITEM_HEIGHT), MENUITEM_WIDTH, text); + byte *s = (byte*)surf->getBasePtr(0, MENUITEM_HEIGHT); + for (int i = 0; i < surf->w * MENUITEM_HEIGHT; i++) { + *s++ ^= 0xD; + } + // wrap the surface into the suitable Frames adapter + return new SurfaceToMultiFrames(2, MENUITEM_WIDTH, MENUITEM_HEIGHT, surf); + } -int Parallaction_br::guiShowMenu() { - // TODO: filter menu entries according to progress in game + enum MenuOptions { + kMenuPart0 = 0, + kMenuPart1 = 1, + kMenuPart2 = 2, + kMenuPart3 = 3, + kMenuPart4 = 4, + kMenuLoadGame = 5, + kMenuQuit = 6 + }; #define NUM_MENULINES 7 GfxObj *_lines[NUM_MENULINES]; - const char *menuStrings[NUM_MENULINES] = { - "SEE INTRO", - "NEW GAME", - "SAVED GAME", - "EXIT TO DOS", - "PART 2", - "PART 3", - "PART 4" - }; + static const char *_menuStrings[NUM_MENULINES]; + static const MenuOptions _options[NUM_MENULINES]; - MenuOptions options[NUM_MENULINES] = { - kMenuPart0, - kMenuPart1, - kMenuLoadGame, - kMenuQuit, - kMenuPart2, - kMenuPart3, - kMenuPart4 - }; + int _availItems; + int _selection; - _gfx->clearScreen(); - _gfx->setBackground(kBackgroundSlide, "tbra", 0, 0); - if (getPlatform() == Common::kPlatformPC) { - _gfx->_backgroundInfo.x = 20; - _gfx->_backgroundInfo.y = 50; + void cleanup() { + _vm->_system->showMouse(false); + _vm->hideDialogueStuff(); + + for (int i = 0; i < _availItems; i++) { + delete _lines[i]; + } } - int availItems = 4 + _progress; + void performChoice(int selectedItem) { + switch (selectedItem) { + case kMenuQuit: + _engineFlags |= kEngineQuit; + break; - // TODO: keep track of and destroy menu item frames/surfaces + case kMenuLoadGame: + warning("loadgame not yet implemented"); + break; - int i; - for (i = 0; i < availItems; i++) { - _lines[i] = new GfxObj(0, guiRenderMenuItem(menuStrings[i]), "MenuItem"); - uint id = _gfx->setItem(_lines[i], MENUITEMS_X, MENUITEMS_Y + MENUITEM_HEIGHT * i, 0xFF); - _gfx->setItemFrame(id, 0); + default: + _vm->startPart(selectedItem); + } } - int selectedItem = -1; - - setMousePointer(0); - - uint32 event; - Common::Point p; - while (true) { +public: + MainMenuInputState_BR(Parallaction_br *vm, MenuInputHelper *helper) : MenuInputState("mainmenu", helper), _vm(vm) { + } - _input->readInput(); + virtual MenuInputState* run() { - event = _input->getLastButtonEvent(); - if ((event == kMouseLeftUp) && selectedItem >= 0) - break; + int event = _vm->_input->getLastButtonEvent(); + if ((event == kMouseLeftUp) && _selection >= 0) { + cleanup(); + performChoice(_options[_selection]); + return 0; + } - _input->getCursorPos(p); + Common::Point p; + _vm->_input->getCursorPos(p); if ((p.x > MENUITEMS_X) && (p.x < (MENUITEMS_X+MENUITEM_WIDTH)) && (p.y > MENUITEMS_Y)) { - selectedItem = (p.y - MENUITEMS_Y) / MENUITEM_HEIGHT; + _selection = (p.y - MENUITEMS_Y) / MENUITEM_HEIGHT; - if (!(selectedItem < availItems)) - selectedItem = -1; + if (!(_selection < _availItems)) + _selection = -1; } else - selectedItem = -1; + _selection = -1; - for (i = 0; i < availItems; i++) { - _gfx->setItemFrame(i, selectedItem == i ? 1 : 0); + for (int i = 0; i < _availItems; i++) { + _vm->_gfx->setItemFrame(i, _selection == i ? 1 : 0); } - _gfx->updateScreen(); - _system->delayMillis(20); + + return this; } - _system->showMouse(false); - hideDialogueStuff(); + virtual void enter() { + _vm->_gfx->clearScreen(); + _vm->_gfx->setBackground(kBackgroundSlide, "tbra", 0, 0); + if (_vm->getPlatform() == Common::kPlatformPC) { + _vm->_gfx->_backgroundInfo.x = 20; + _vm->_gfx->_backgroundInfo.y = 50; + } + + // TODO: load progress from savefile + int progress = 3; + _availItems = 4 + progress; - for (i = 0; i < availItems; i++) { - delete _lines[i]; + // TODO: keep track of and destroy menu item frames/surfaces + int i; + for (i = 0; i < _availItems; i++) { + _lines[i] = new GfxObj(0, renderMenuItem(_menuStrings[i]), "MenuItem"); + uint id = _vm->_gfx->setItem(_lines[i], MENUITEMS_X, MENUITEMS_Y + MENUITEM_HEIGHT * i, 0xFF); + _vm->_gfx->setItemFrame(id, 0); + } + _selection = -1; + _vm->setArrowCursor(); + _vm->_input->setMouseState(MOUSE_ENABLED_SHOW); } - return options[selectedItem]; +}; + +const char *MainMenuInputState_BR::_menuStrings[NUM_MENULINES] = { + "SEE INTRO", + "NEW GAME", + "SAVED GAME", + "EXIT TO DOS", + "PART 2", + "PART 3", + "PART 4" +}; + +const MainMenuInputState_BR::MenuOptions MainMenuInputState_BR::_options[NUM_MENULINES] = { + kMenuPart0, + kMenuPart1, + kMenuLoadGame, + kMenuQuit, + kMenuPart2, + kMenuPart3, + kMenuPart4 +}; + + + + + + + +void Parallaction_br::startGui() { + _menuHelper = new MenuInputHelper; + new SplashInputState0_BR(this, _menuHelper); + new SplashInputState1_BR(this, _menuHelper); + new MainMenuInputState_BR(this, _menuHelper); + + _menuHelper->setState("intro0"); + _input->_inputMode = Input::kInputModeMenu; + + do { + _input->readInput(); + if (!_menuHelper->run()) break; + _gfx->beginFrame(); + _gfx->updateScreen(); + } while (true); + + delete _menuHelper; + _menuHelper = 0; } + + } // namespace Parallaction diff --git a/engines/parallaction/gui_ns.cpp b/engines/parallaction/gui_ns.cpp index ce68df46e2..815c27bd1c 100644 --- a/engines/parallaction/gui_ns.cpp +++ b/engines/parallaction/gui_ns.cpp @@ -26,6 +26,7 @@ #include "common/system.h" #include "common/hashmap.h" +#include "parallaction/gui.h" #include "parallaction/input.h" #include "parallaction/parallaction.h" #include "parallaction/sound.h" @@ -33,86 +34,7 @@ namespace Parallaction { - -class MenuInputState; - -class MenuInputHelper { - typedef Common::HashMap<Common::String, MenuInputState*> StateMap; - - StateMap _map; - MenuInputState *_state; - MenuInputState *_newState; - -public: - MenuInputHelper() : _state(0) { - } - - ~MenuInputHelper(); - - void setState(const Common::String &name) { - // bootstrap routine - _newState = getState(name); - assert(_newState); - } - - void addState(const Common::String &name, MenuInputState *state) { - _map.setVal(name, state); - } - - MenuInputState *getState(const Common::String &name) { - return _map[name]; - } - - bool run(); -}; - -class MenuInputState { - -protected: - MenuInputHelper *_helper; - -public: - MenuInputState(const Common::String &name, MenuInputHelper *helper) : _helper(helper), _name(name) { - debugC(3, kDebugExec, "MenuInputState(%s)", name.c_str()); - _helper->addState(name, this); - } - - Common::String _name; - - virtual ~MenuInputState() { } - - virtual MenuInputState* run() = 0; - virtual void enter() = 0; -}; - -bool MenuInputHelper::run() { - if (_newState == 0) { - debugC(3, kDebugExec, "MenuInputHelper has set NULL state"); - return false; - } - - if (_newState != _state) { - debugC(3, kDebugExec, "MenuInputHelper changing state to '%s'", _newState->_name.c_str()); - - _newState->enter(); - _state = _newState; - } - - _newState = _state->run(); - - return true; -} - -MenuInputHelper::~MenuInputHelper() { - StateMap::iterator b = _map.begin(); - for ( ; b != _map.end(); b++) { - delete b->_value; - } - _map.clear(); -} - - -class SplashInputState : public MenuInputState { +class SplashInputState_NS : public MenuInputState { protected: Common::String _slideName; uint32 _timeOut; @@ -122,7 +44,7 @@ protected: Parallaction_ns *_vm; public: - SplashInputState(Parallaction_ns *vm, const Common::String &name, MenuInputHelper *helper) : MenuInputState(name, helper), _vm(vm) { + SplashInputState_NS(Parallaction_ns *vm, const Common::String &name, MenuInputHelper *helper) : MenuInputState(name, helper), _vm(vm) { } virtual MenuInputState* run() { @@ -141,20 +63,20 @@ public: } }; -class SplashInputState0 : public SplashInputState { +class SplashInputState0_NS : public SplashInputState_NS { public: - SplashInputState0(Parallaction_ns *vm, MenuInputHelper *helper) : SplashInputState(vm, "intro0", helper) { + SplashInputState0_NS(Parallaction_ns *vm, MenuInputHelper *helper) : SplashInputState_NS(vm, "intro0", helper) { _slideName = "intro"; _timeOut = 2000; _nextState = "intro1"; } }; -class SplashInputState1 : public SplashInputState { +class SplashInputState1_NS : public SplashInputState_NS { public: - SplashInputState1(Parallaction_ns *vm, MenuInputHelper *helper) : SplashInputState(vm, "intro1", helper) { + SplashInputState1_NS(Parallaction_ns *vm, MenuInputHelper *helper) : SplashInputState_NS(vm, "intro1", helper) { _slideName = "minintro"; _timeOut = 2000; _nextState = "chooselanguage"; @@ -162,7 +84,7 @@ public: }; -class ChooseLanguageInputState : public MenuInputState { +class ChooseLanguageInputState_NS : public MenuInputState { #define BLOCK_WIDTH 16 #define BLOCK_HEIGHT 24 @@ -192,7 +114,7 @@ class ChooseLanguageInputState : public MenuInputState { Parallaction_ns *_vm; public: - ChooseLanguageInputState(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("chooselanguage", helper), _vm(vm) { + ChooseLanguageInputState_NS(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("chooselanguage", helper), _vm(vm) { _allowChoice = false; _nextState = "selectgame"; @@ -260,21 +182,21 @@ public: } }; -const Common::Rect ChooseLanguageInputState::_dosLanguageSelectBlocks[4] = { +const Common::Rect ChooseLanguageInputState_NS::_dosLanguageSelectBlocks[4] = { Common::Rect( 80, 110, 128, 180 ), // Italian Common::Rect( 129, 85, 177, 155 ), // French Common::Rect( 178, 60, 226, 130 ), // English Common::Rect( 227, 35, 275, 105 ) // German }; -const Common::Rect ChooseLanguageInputState::_amigaLanguageSelectBlocks[4] = { +const Common::Rect ChooseLanguageInputState_NS::_amigaLanguageSelectBlocks[4] = { Common::Rect( -1, -1, -1, -1 ), // Italian: not supported by Amiga multi-lingual version Common::Rect( 129, 85, 177, 155 ), // French Common::Rect( 178, 60, 226, 130 ), // English Common::Rect( 227, 35, 275, 105 ) // German }; -class SelectGameInputState : public MenuInputState { +class SelectGameInputState_NS : public MenuInputState { int _choice, _oldChoice; Common::String _nextState[2]; @@ -287,7 +209,7 @@ class SelectGameInputState : public MenuInputState { static const char *loadGameMsg[4]; public: - SelectGameInputState(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("selectgame", helper), _vm(vm) { + SelectGameInputState_NS(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("selectgame", helper), _vm(vm) { _choice = 0; _oldChoice = -1; @@ -331,14 +253,14 @@ public: }; -const char *SelectGameInputState::newGameMsg[4] = { +const char *SelectGameInputState_NS::newGameMsg[4] = { "NUOVO GIOCO", "NEUF JEU", "NEW GAME", "NEUES SPIEL" }; -const char *SelectGameInputState::loadGameMsg[4] = { +const char *SelectGameInputState_NS::loadGameMsg[4] = { "GIOCO SALVATO", "JEU SAUVE'", "SAVED GAME", @@ -347,12 +269,12 @@ const char *SelectGameInputState::loadGameMsg[4] = { -class LoadGameInputState : public MenuInputState { +class LoadGameInputState_NS : public MenuInputState { bool _result; Parallaction_ns *_vm; public: - LoadGameInputState(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("loadgame", helper), _vm(vm) { } + LoadGameInputState_NS(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("loadgame", helper), _vm(vm) { } virtual MenuInputState* run() { if (!_result) { @@ -368,13 +290,13 @@ public: -class NewGameInputState : public MenuInputState { +class NewGameInputState_NS : public MenuInputState { Parallaction_ns *_vm; static const char *introMsg3[4]; public: - NewGameInputState(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("newgame", helper), _vm(vm) { + NewGameInputState_NS(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("newgame", helper), _vm(vm) { } virtual MenuInputState* run() { @@ -412,7 +334,7 @@ public: } }; -const char *NewGameInputState::introMsg3[4] = { +const char *NewGameInputState_NS::introMsg3[4] = { "PRESS LEFT MOUSE BUTTON", "TO SEE INTRO", "PRESS RIGHT MOUSE BUTTON", @@ -421,11 +343,11 @@ const char *NewGameInputState::introMsg3[4] = { -class StartDemoInputState : public MenuInputState { +class StartDemoInputState_NS : public MenuInputState { Parallaction_ns *_vm; public: - StartDemoInputState(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("startdemo", helper), _vm(vm) { + StartDemoInputState_NS(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("startdemo", helper), _vm(vm) { } virtual MenuInputState* run() { @@ -438,7 +360,7 @@ public: } }; -class SelectCharacterInputState : public MenuInputState { +class SelectCharacterInputState_NS : public MenuInputState { #define PASSWORD_LEN 6 @@ -502,12 +424,12 @@ class SelectCharacterInputState : public MenuInputState { public: - SelectCharacterInputState(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("selectcharacter", helper), _vm(vm) { + SelectCharacterInputState_NS(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("selectcharacter", helper), _vm(vm) { _keys = (_vm->getPlatform() == Common::kPlatformAmiga && (_vm->getFeatures() & GF_LANG_MULT)) ? _amigaKeys : _pcKeys; _block.create(BLOCK_WIDTH, BLOCK_HEIGHT, 1); } - ~SelectCharacterInputState() { + ~SelectCharacterInputState_NS() { _block.free(); _emptySlots.free(); } @@ -639,40 +561,40 @@ public: } }; -const char *SelectCharacterInputState::introMsg1[4] = { +const char *SelectCharacterInputState_NS::introMsg1[4] = { "INSERISCI IL CODICE", "ENTREZ CODE", "ENTER CODE", "GIB DEN KODE EIN" }; -const char *SelectCharacterInputState::introMsg2[4] = { +const char *SelectCharacterInputState_NS::introMsg2[4] = { "CODICE ERRATO", "CODE ERRONE", "WRONG CODE", "GIB DEN KODE EIN" }; -const uint16 SelectCharacterInputState::_amigaKeys[][PASSWORD_LEN] = { +const uint16 SelectCharacterInputState_NS::_amigaKeys[][PASSWORD_LEN] = { { 5, 3, 6, 2, 2, 7 }, // dino { 0, 3, 6, 2, 2, 6 }, // donna { 1, 3 ,7, 2, 4, 6 } // dough }; -const uint16 SelectCharacterInputState::_pcKeys[][PASSWORD_LEN] = { +const uint16 SelectCharacterInputState_NS::_pcKeys[][PASSWORD_LEN] = { { 5, 3, 6, 1, 4, 7 }, // dino { 0, 2, 8, 5, 5, 1 }, // donna { 1, 7 ,7, 2, 2, 6 } // dough }; -const char *SelectCharacterInputState::_charStartLocation[] = { +const char *SelectCharacterInputState_NS::_charStartLocation[] = { "test.dino", "test.donna", "test.dough" }; -const Common::Rect SelectCharacterInputState::codeSelectBlocks[9] = { +const Common::Rect SelectCharacterInputState_NS::codeSelectBlocks[9] = { Common::Rect( 111, 129, 127, 153 ), // na Common::Rect( 128, 120, 144, 144 ), // wa Common::Rect( 145, 111, 161, 135 ), // ra @@ -684,7 +606,7 @@ const Common::Rect SelectCharacterInputState::codeSelectBlocks[9] = { Common::Rect( 247, 57, 263, 81 ) // ka }; -const Common::Rect SelectCharacterInputState::codeTrueBlocks[9] = { +const Common::Rect SelectCharacterInputState_NS::codeTrueBlocks[9] = { Common::Rect( 112, 130, 128, 154 ), Common::Rect( 129, 121, 145, 145 ), Common::Rect( 146, 112, 162, 136 ), @@ -697,7 +619,7 @@ const Common::Rect SelectCharacterInputState::codeTrueBlocks[9] = { }; -class ShowCreditsInputState : public MenuInputState { +class ShowCreditsInputState_NS : public MenuInputState { Parallaction_ns *_vm; int _current; uint32 _startTime; @@ -710,7 +632,7 @@ class ShowCreditsInputState : public MenuInputState { static const Credit _credits[6]; public: - ShowCreditsInputState(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("showcredits", helper), _vm(vm) { + ShowCreditsInputState_NS(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("showcredits", helper), _vm(vm) { } void drawCurrentLabel() { @@ -753,7 +675,7 @@ public: } }; -const ShowCreditsInputState::Credit ShowCreditsInputState::_credits[6] = { +const ShowCreditsInputState_NS::Credit ShowCreditsInputState_NS::_credits[6] = { {"Music and Sound Effects", "MARCO CAPRELLI"}, {"PC Version", "RICCARDO BALLARINO"}, {"Project Manager", "LOVRANO CANEPA"}, @@ -762,12 +684,12 @@ const ShowCreditsInputState::Credit ShowCreditsInputState::_credits[6] = { {"Copyright 1992 Euclidea s.r.l ITALY", "All rights reserved"} }; -class EndIntroInputState : public MenuInputState { +class EndIntroInputState_NS : public MenuInputState { Parallaction_ns *_vm; bool _isDemo; public: - EndIntroInputState(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("endintro", helper), _vm(vm) { + EndIntroInputState_NS(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("endintro", helper), _vm(vm) { _isDemo = (_vm->getFeatures() & GF_DEMO) != 0; } @@ -799,7 +721,7 @@ public: }; -class EndPartInputState : public MenuInputState { +class EndPartInputState_NS : public MenuInputState { Parallaction_ns *_vm; bool _allPartsComplete; @@ -816,7 +738,7 @@ class EndPartInputState : public MenuInputState { public: - EndPartInputState(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("endpart", helper), _vm(vm) { + EndPartInputState_NS(Parallaction_ns *vm, MenuInputHelper *helper) : MenuInputState("endpart", helper), _vm(vm) { } virtual MenuInputState* run() { @@ -860,15 +782,15 @@ public: }; // part completion messages -const char *EndPartInputState::endMsg0[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"}; -const char *EndPartInputState::endMsg1[] = {"HAI FINITO QUESTA PARTE", "TU AS COMPLETE' CETTE AVENTURE", "YOU HAVE COMPLETED THIS PART", "DU HAST EIN ABENTEUER ERFOLGREICH"}; -const char *EndPartInputState::endMsg2[] = {"ORA COMPLETA IL RESTO ", "AVEC SUCCES.", "NOW GO ON WITH THE REST OF", "ZU ENDE GEFUHRT"}; -const char *EndPartInputState::endMsg3[] = {"DELL' AVVENTURA", "CONTINUE AVEC LES AUTRES", "THIS ADVENTURE", "MACH' MIT DEN ANDEREN WEITER"}; +const char *EndPartInputState_NS::endMsg0[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"}; +const char *EndPartInputState_NS::endMsg1[] = {"HAI FINITO QUESTA PARTE", "TU AS COMPLETE' CETTE AVENTURE", "YOU HAVE COMPLETED THIS PART", "DU HAST EIN ABENTEUER ERFOLGREICH"}; +const char *EndPartInputState_NS::endMsg2[] = {"ORA COMPLETA IL RESTO ", "AVEC SUCCES.", "NOW GO ON WITH THE REST OF", "ZU ENDE GEFUHRT"}; +const char *EndPartInputState_NS::endMsg3[] = {"DELL' AVVENTURA", "CONTINUE AVEC LES AUTRES", "THIS ADVENTURE", "MACH' MIT DEN ANDEREN WEITER"}; // game completion messages -const char *EndPartInputState::endMsg4[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"}; -const char *EndPartInputState::endMsg5[] = {"HAI FINITO LE TRE PARTI", "TU AS COMPLETE' LES TROIS PARTIES", "YOU HAVE COMPLETED THE THREE PARTS", "DU HAST DREI ABENTEURE ERFOLGREICH"}; -const char *EndPartInputState::endMsg6[] = {"DELL' AVVENTURA", "DE L'AVENTURE", "OF THIS ADVENTURE", "ZU ENDE GEFUHRT"}; -const char *EndPartInputState::endMsg7[] = {"ED ORA IL GRAN FINALE ", "ET MAINTENANT LE GRAND FINAL", "NOW THE GREAT FINAL", "UND YETZT DER GROSSE SCHLUSS!"}; +const char *EndPartInputState_NS::endMsg4[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"}; +const char *EndPartInputState_NS::endMsg5[] = {"HAI FINITO LE TRE PARTI", "TU AS COMPLETE' LES TROIS PARTIES", "YOU HAVE COMPLETED THE THREE PARTS", "DU HAST DREI ABENTEURE ERFOLGREICH"}; +const char *EndPartInputState_NS::endMsg6[] = {"DELL' AVVENTURA", "DE L'AVENTURE", "OF THIS ADVENTURE", "ZU ENDE GEFUHRT"}; +const char *EndPartInputState_NS::endMsg7[] = {"ED ORA IL GRAN FINALE ", "ET MAINTENANT LE GRAND FINAL", "NOW THE GREAT FINAL", "UND YETZT DER GROSSE SCHLUSS!"}; void Parallaction_ns::startGui() { _disk->selectArchive((getFeatures() & GF_DEMO) ? "disk0" : "disk1"); @@ -876,14 +798,14 @@ void Parallaction_ns::startGui() { _menuHelper = new MenuInputHelper; assert(_menuHelper); - new SelectGameInputState(this, _menuHelper); - new LoadGameInputState(this, _menuHelper); - new NewGameInputState(this, _menuHelper); - new StartDemoInputState(this, _menuHelper); - new SelectCharacterInputState(this, _menuHelper); - new ChooseLanguageInputState(this, _menuHelper); - new SplashInputState1(this, _menuHelper); - new SplashInputState0(this, _menuHelper); + new SelectGameInputState_NS(this, _menuHelper); + new LoadGameInputState_NS(this, _menuHelper); + new NewGameInputState_NS(this, _menuHelper); + new StartDemoInputState_NS(this, _menuHelper); + new SelectCharacterInputState_NS(this, _menuHelper); + new ChooseLanguageInputState_NS(this, _menuHelper); + new SplashInputState1_NS(this, _menuHelper); + new SplashInputState0_NS(this, _menuHelper); _menuHelper->setState("intro0"); _input->_inputMode = Input::kInputModeMenu; @@ -893,9 +815,9 @@ void Parallaction_ns::startCreditSequence() { _menuHelper = new MenuInputHelper; assert(_menuHelper); - new ShowCreditsInputState(this, _menuHelper); - new EndIntroInputState(this, _menuHelper); - new SelectCharacterInputState(this, _menuHelper); + new ShowCreditsInputState_NS(this, _menuHelper); + new EndIntroInputState_NS(this, _menuHelper); + new SelectCharacterInputState_NS(this, _menuHelper); _menuHelper->setState("showcredits"); _input->_inputMode = Input::kInputModeMenu; @@ -905,46 +827,12 @@ void Parallaction_ns::startEndPartSequence() { _menuHelper = new MenuInputHelper; assert(_menuHelper); - new EndPartInputState(this, _menuHelper); - new SelectCharacterInputState(this, _menuHelper); + new EndPartInputState_NS(this, _menuHelper); + new SelectCharacterInputState_NS(this, _menuHelper); _menuHelper->setState("endpart"); _input->_inputMode = Input::kInputModeMenu; } -void Parallaction::runGuiFrame() { - if (_input->_inputMode != Input::kInputModeMenu) { - return; - } - - if (!_menuHelper) { - error("No menu helper defined!"); - } - - bool res = _menuHelper->run(); - - if (!res) { - cleanupGui(); - _input->_inputMode = Input::kInputModeGame; - } - -} - -void Parallaction::cleanupGui() { - delete _menuHelper; - _menuHelper = 0; -} - -void Parallaction::setInternLanguage(uint id) { - //TODO: assert id! - - _language = id; - _disk->setLanguage(id); -} - -uint Parallaction::getInternLanguage() { - return _language; -} - } // namespace Parallaction diff --git a/engines/parallaction/module.mk b/engines/parallaction/module.mk index fb867f5285..9d44422541 100644 --- a/engines/parallaction/module.mk +++ b/engines/parallaction/module.mk @@ -14,6 +14,7 @@ MODULE_OBJS := \ font.o \ gfxbase.o \ graphics.o \ + gui.o \ gui_br.o \ gui_ns.o \ input.o \ diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 0b1fa53e67..523ec06a61 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -638,7 +638,8 @@ public: int32 _counters[32]; uint32 _zoneFlags[NUM_LOCATIONS][NUM_ZONES]; - + void startPart(uint part); + void setArrowCursor(); private: LocationParser_br *_locationParser; ProgramParser_br *_programParser; @@ -647,7 +648,6 @@ private: void initFonts(); void freeFonts(); - void setArrowCursor(); void setInventoryCursor(int pos); void changeLocation(char *location); @@ -655,7 +655,6 @@ private: void initPart(); void freePart(); - void startPart(); void setMousePointer(int16 index); void initCursors(); @@ -668,10 +667,7 @@ private: static const char *_partNames[]; - void guiStart(); - int guiShowMenu(); - void guiSplash(const char *name); - Frames* guiRenderMenuItem(const char *text); + void startGui(); static const Callable _dosCallables[6]; diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp index 9e2a0f10f1..494544fb03 100644 --- a/engines/parallaction/parallaction_br.cpp +++ b/engines/parallaction/parallaction_br.cpp @@ -109,16 +109,10 @@ void Parallaction_br::callFunction(uint index, void* parm) { int Parallaction_br::go() { - guiSplash("dyna"); - guiSplash("core"); + startGui(); while ((_engineFlags & kEngineQuit) == 0) { - guiStart(); - - if (_engineFlags & kEngineQuit) - return 0; - // initCharacter(); _input->_inputMode = Input::kInputModeGame; @@ -195,7 +189,9 @@ void Parallaction_br::freePart() { _countersNames = 0; } -void Parallaction_br::startPart() { +void Parallaction_br::startPart(uint part) { + _part = part; + _disk->selectArchive(_partNames[_part]); initPart(); @@ -320,9 +316,9 @@ void Parallaction_br::changeCharacter(const char *name) { void Parallaction_br::setArrowCursor() { - - - + // TODO: choose the pointer depending on the active character + // For now, defaults to 0, that corresponds to the default in the original + setMousePointer(0); } void Parallaction_br::setInventoryCursor(int pos) { |