From 19fed32a42d56a06bc809d4eef3afa09ace3c614 Mon Sep 17 00:00:00 2001 From: Douglas Liu Date: Mon, 21 May 2018 12:40:07 +0800 Subject: [PATCH] STARK: Build the Settings and link it with other screens --- engines/stark/module.mk | 1 + engines/stark/services/userinterface.cpp | 6 + engines/stark/services/userinterface.h | 2 + engines/stark/ui/menu/diaryindex.cpp | 6 +- engines/stark/ui/menu/diaryindex.h | 1 + engines/stark/ui/menu/mainmenu.cpp | 6 +- engines/stark/ui/menu/mainmenu.h | 1 + engines/stark/ui/menu/settingsmenu.cpp | 192 +++++++++++++++++++++++ engines/stark/ui/menu/settingsmenu.h | 60 +++++++ engines/stark/ui/screen.h | 3 +- 10 files changed, 275 insertions(+), 3 deletions(-) create mode 100644 engines/stark/ui/menu/settingsmenu.cpp create mode 100644 engines/stark/ui/menu/settingsmenu.h diff --git a/engines/stark/module.mk b/engines/stark/module.mk index 4a6e1aa58d2..0ed796045ab 100644 --- a/engines/stark/module.mk +++ b/engines/stark/module.mk @@ -88,6 +88,7 @@ MODULE_OBJS := \ ui/menu/diaryindex.o \ ui/menu/locationscreen.o \ ui/menu/mainmenu.o \ + ui/menu/settingsmenu.o \ ui/window.o \ ui/world/actionmenu.o \ ui/world/button.o \ diff --git a/engines/stark/services/userinterface.cpp b/engines/stark/services/userinterface.cpp index 0d1b76e6184..e35b617645b 100644 --- a/engines/stark/services/userinterface.cpp +++ b/engines/stark/services/userinterface.cpp @@ -37,6 +37,7 @@ #include "engines/stark/ui/cursor.h" #include "engines/stark/ui/menu/diaryindex.h" #include "engines/stark/ui/menu/mainmenu.h" +#include "engines/stark/ui/menu/settingsmenu.h" #include "engines/stark/ui/world/inventorywindow.h" #include "engines/stark/ui/world/fmvscreen.h" #include "engines/stark/ui/world/gamescreen.h" @@ -49,6 +50,7 @@ UserInterface::UserInterface(Gfx::Driver *gfx) : _cursor(nullptr), _diaryIndexScreen(nullptr), _mainMenuScreen(nullptr), + _settingsMenuScreen(nullptr), _exitGame(false), _fmvScreen(nullptr), _gameScreen(nullptr), @@ -67,6 +69,7 @@ UserInterface::~UserInterface() { delete _diaryIndexScreen; delete _cursor; delete _mainMenuScreen; + delete _settingsMenuScreen; } void UserInterface::init() { @@ -75,6 +78,7 @@ void UserInterface::init() { _mainMenuScreen = new MainMenuScreen(_gfx, _cursor); _gameScreen = new GameScreen(_gfx, _cursor); _diaryIndexScreen = new DiaryIndexScreen(_gfx, _cursor); + _settingsMenuScreen = new SettingsMenuScreen(_gfx, _cursor); _fmvScreen = new FMVScreen(_gfx, _cursor); _prevScreenNameStack.push(Screen::kScreenMainMenu); @@ -180,6 +184,8 @@ Screen *UserInterface::getScreenByName(Screen::Name screenName) const { return _gameScreen; case Screen::kScreenMainMenu: return _mainMenuScreen; + case Screen::kScreenSettingsMenu: + return _settingsMenuScreen; default: error("Unhandled screen name '%d'", screenName); } diff --git a/engines/stark/services/userinterface.h b/engines/stark/services/userinterface.h index 3c558d0cc7c..a6fad7e7945 100644 --- a/engines/stark/services/userinterface.h +++ b/engines/stark/services/userinterface.h @@ -47,6 +47,7 @@ class Driver; class DiaryIndexScreen; class GameScreen; class MainMenuScreen; +class SettingsMenuScreen; class Cursor; class FMVScreen; @@ -151,6 +152,7 @@ private: FMVScreen *_fmvScreen; DiaryIndexScreen *_diaryIndexScreen; MainMenuScreen *_mainMenuScreen; + SettingsMenuScreen *_settingsMenuScreen; Screen *_currentScreen; Common::Stack _prevScreenNameStack; diff --git a/engines/stark/ui/menu/diaryindex.cpp b/engines/stark/ui/menu/diaryindex.cpp index 80347650398..313b09b5411 100644 --- a/engines/stark/ui/menu/diaryindex.cpp +++ b/engines/stark/ui/menu/diaryindex.cpp @@ -62,7 +62,7 @@ void DiaryIndexScreen::open() { _widgets.push_back(new StaticLocationWidget( "Options", - nullptr, + CLICK_HANDLER(DiaryIndexScreen, settingsHandler), MOVE_HANDLER(DiaryIndexScreen, widgetTextColorHandler))); _widgets.push_back(new StaticLocationWidget( @@ -109,6 +109,10 @@ void DiaryIndexScreen::widgetTextColorHandler(StaticLocationWidget &widget, cons } } +void DiaryIndexScreen::settingsHandler() { + StarkUserInterface->changeScreen(Screen::kScreenSettingsMenu); +} + void DiaryIndexScreen::backHandler() { StarkUserInterface->backPrevScreen(); } diff --git a/engines/stark/ui/menu/diaryindex.h b/engines/stark/ui/menu/diaryindex.h index af81174edcb..29d8f8dfb55 100644 --- a/engines/stark/ui/menu/diaryindex.h +++ b/engines/stark/ui/menu/diaryindex.h @@ -41,6 +41,7 @@ public: private: void widgetTextColorHandler(StaticLocationWidget &widget, const Common::Point &mousePos); void backHandler(); + void settingsHandler(); void loadHandler(); void saveHandler(); void quitHandler(); diff --git a/engines/stark/ui/menu/mainmenu.cpp b/engines/stark/ui/menu/mainmenu.cpp index f415bef61db..a564b73e896 100644 --- a/engines/stark/ui/menu/mainmenu.cpp +++ b/engines/stark/ui/menu/mainmenu.cpp @@ -59,7 +59,7 @@ void MainMenuScreen::open() { _widgets.push_back(new StaticLocationWidget( "Options", - nullptr, + CLICK_HANDLER(MainMenuScreen, settingsHandler), MOVE_HANDLER(MainMenuScreen, helpTextHandler<6>))); _widgets.back()->setupSounds(0, 1); @@ -170,6 +170,10 @@ void MainMenuScreen::loadHandler() { // TODO: Link to the load screen } +void MainMenuScreen::settingsHandler() { + StarkUserInterface->changeScreen(Screen::kScreenSettingsMenu); +} + void MainMenuScreen::quitHandler() { StarkUserInterface->notifyShouldExit(); } diff --git a/engines/stark/ui/menu/mainmenu.h b/engines/stark/ui/menu/mainmenu.h index b70d5767817..63f3077edea 100644 --- a/engines/stark/ui/menu/mainmenu.h +++ b/engines/stark/ui/menu/mainmenu.h @@ -47,6 +47,7 @@ private: void newGameHandler(); void loadHandler(); void creditsHandler(); + void settingsHandler(); void quitHandler(); bool isDemo() { diff --git a/engines/stark/ui/menu/settingsmenu.cpp b/engines/stark/ui/menu/settingsmenu.cpp new file mode 100644 index 00000000000..72d86269824 --- /dev/null +++ b/engines/stark/ui/menu/settingsmenu.cpp @@ -0,0 +1,192 @@ +/* ResidualVM - A 3D game interpreter + * + * ResidualVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the AUTHORS + * 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 "engines/stark/ui/menu/settingsmenu.h" +#include "engines/stark/services/services.h" +#include "engines/stark/services/userinterface.h" + +namespace Stark { + +SettingsMenuScreen::SettingsMenuScreen(Gfx::Driver *gfx, Cursor *cursor): + StaticLocationScreen(gfx, cursor, "OptionLocation", Screen::kScreenSettingsMenu) { +} + +SettingsMenuScreen::~SettingsMenuScreen() { +} + +void SettingsMenuScreen::open() { + StaticLocationScreen::open(); + + _widgets.push_back(new StaticLocationWidget( + // This is the background image + "The Longest Journey", + nullptr, + nullptr)); + + _widgets.push_back(new StaticLocationWidget( + "Return", + CLICK_HANDLER(SettingsMenuScreen, backHandler), + nullptr)); + _widgets.back()->setupSounds(3, 4); + + _widgets.push_back(new StaticLocationWidget( + "Back", + CLICK_HANDLER(SettingsMenuScreen, backHandler), + nullptr)); + _widgets.back()->setupSounds(3, 4); + + _widgets.push_back(new StaticLocationWidget( + "GSettings", + nullptr, + nullptr)); + + _widgets.push_back(new StaticLocationWidget( + "AprilHighRes", + nullptr, + MOVE_HANDLER(SettingsMenuScreen, textHandler<5>))); + _widgets.back()->setupSounds(3, 4); + + _widgets.push_back(new StaticLocationWidget( + "HighResHelp", + nullptr, + nullptr)); + _widgets.back()->setVisible(false); + + _widgets.push_back(new StaticLocationWidget( + "Subtitles", + nullptr, + MOVE_HANDLER(SettingsMenuScreen, textHandler<7>))); + _widgets.back()->setupSounds(3, 4); + + _widgets.push_back(new StaticLocationWidget( + "SubtitleHelp", + nullptr, + nullptr)); + _widgets.back()->setVisible(false); + + _widgets.push_back(new StaticLocationWidget( + "SpecialFX", + nullptr, + MOVE_HANDLER(SettingsMenuScreen, textHandler<9>))); + _widgets.back()->setupSounds(3, 4); + + _widgets.push_back(new StaticLocationWidget( + "SpecialFXHelp", + nullptr, + nullptr)); + _widgets.back()->setVisible(false); + + _widgets.push_back(new StaticLocationWidget( + "Shadows", + nullptr, + MOVE_HANDLER(SettingsMenuScreen, textHandler<11>))); + _widgets.back()->setupSounds(3, 4); + + _widgets.push_back(new StaticLocationWidget( + "ShadowsHelp", + nullptr, + nullptr)); + _widgets.back()->setVisible(false); + + _widgets.push_back(new StaticLocationWidget( + "HighResFMV", + nullptr, + MOVE_HANDLER(SettingsMenuScreen, textHandler<13>))); + _widgets.back()->setupSounds(3, 4); + + _widgets.push_back(new StaticLocationWidget( + "FMVHelp", + nullptr, + nullptr)); + _widgets.back()->setVisible(false); + + _widgets.push_back(new StaticLocationWidget( + "VSettings", + nullptr, + nullptr)); + + _widgets.push_back(new StaticLocationWidget( + "Voice", + nullptr, + MOVE_HANDLER(SettingsMenuScreen, textHandler<16>))); + + _widgets.push_back(new StaticLocationWidget( + "VoiceHelp", + nullptr, + nullptr)); + _widgets.back()->setVisible(false); + + _widgets.push_back(new StaticLocationWidget( + "Music", + nullptr, + MOVE_HANDLER(SettingsMenuScreen, textHandler<18>))); + + _widgets.push_back(new StaticLocationWidget( + "MusicHelp", + nullptr, + nullptr)); + _widgets.back()->setVisible(false); + + _widgets.push_back(new StaticLocationWidget( + "Sfx", + nullptr, + MOVE_HANDLER(SettingsMenuScreen, textHandler<20>))); + + _widgets.push_back(new StaticLocationWidget( + "SfxHelp", + nullptr, + nullptr)); + _widgets.back()->setVisible(false); + + if (!isDemo()) { + _widgets.push_back(new StaticLocationWidget( + "AllowFF", + nullptr, + MOVE_HANDLER(SettingsMenuScreen, textHandler<22>))); + _widgets.back()->setupSounds(3, 4); + + _widgets.push_back(new StaticLocationWidget( + "AllowFFHelp", + nullptr, + nullptr)); + _widgets.back()->setVisible(false); + } +} + +template +void SettingsMenuScreen::textHandler(StaticLocationWidget &widget, const Common::Point &mousePos) { + if (widget.isVisible()) { + if (widget.isMouseInside(mousePos)) { + widget.setTextColor(_textColorHovered); + _widgets[N]->setVisible(true); + } else { + widget.setTextColor(_textColorDefault); + _widgets[N]->setVisible(false); + } + } +} + +void SettingsMenuScreen::backHandler() { + StarkUserInterface->backPrevScreen(); +} + +} // End of namespace Stark diff --git a/engines/stark/ui/menu/settingsmenu.h b/engines/stark/ui/menu/settingsmenu.h new file mode 100644 index 00000000000..6bda3da7926 --- /dev/null +++ b/engines/stark/ui/menu/settingsmenu.h @@ -0,0 +1,60 @@ +/* ResidualVM - A 3D game interpreter + * + * ResidualVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the AUTHORS + * 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 STARK_UI_MENU_SETTING_MENU_H +#define STARK_UI_MENU_SETTING_MENU_H + +#include "engines/stark/ui/menu/locationscreen.h" +#include "engines/stark/services/services.h" +#include "engines/advancedDetector.h" + +namespace Stark { + +/** + * The setting menu of the game + */ +class SettingsMenuScreen : public StaticLocationScreen { +public: + SettingsMenuScreen(Gfx::Driver *gfx, Cursor *cursor); + virtual ~SettingsMenuScreen(); + + // StaticLocationScreen API + void open() override; + +private: + template + void textHandler(StaticLocationWidget &widget, const Common::Point &mousePos); + + void backHandler(); + +private: + static const uint32 _textColorHovered = 0xFF961E1E; + static const uint32 _textColorDefault = 0xFF000000; + + bool isDemo() { + return StarkGameDescription->flags & ADGF_DEMO; + } +}; + +} // End of namespace Stark + +#endif // STARK_UI_MENU_SETTING_MENU_H diff --git a/engines/stark/ui/screen.h b/engines/stark/ui/screen.h index d14dc85c693..2f71464637b 100644 --- a/engines/stark/ui/screen.h +++ b/engines/stark/ui/screen.h @@ -39,7 +39,8 @@ public: kScreenMainMenu, kScreenGame, kScreenFMV, - kScreenDiaryIndex + kScreenDiaryIndex, + kScreenSettingsMenu }; explicit Screen(Name name) : _name(name) {};