ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

mainmenu.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "engines/stark/ui/menu/mainmenu.h"
00024 #include "engines/stark/services/userinterface.h"
00025 #include "engines/stark/services/resourceprovider.h"
00026 #include "engines/stark/services/global.h"
00027 #include "engines/stark/services/settings.h"
00028 #include "engines/stark/services/gamemessage.h"
00029 
00030 #include "engines/stark/gfx/renderentry.h"
00031 #include "engines/stark/visual/text.h"
00032 
00033 #include "engines/stark/scene.h"
00034 
00035 #include "common/config-manager.h"
00036 
00037 namespace Stark {
00038 
00039 MainMenuScreen::MainMenuScreen(Gfx::Driver *gfx, Cursor *cursor) :
00040         StaticLocationScreen(gfx, cursor, "MainMenuLocation", Screen::kScreenMainMenu) {
00041 }
00042 
00043 MainMenuScreen::~MainMenuScreen() {
00044 }
00045 
00046 void MainMenuScreen::open() {
00047     StaticLocationScreen::open();
00048 
00049     _widgets.push_back(new StaticLocationWidget(
00050             "BGImage",
00051             nullptr,
00052             nullptr));
00053 
00054     _widgets.push_back(new StaticLocationWidget(
00055             "NewGame",
00056             CLICK_HANDLER(MainMenuScreen, newGameHandler),
00057             MOVE_HANDLER(MainMenuScreen, helpTextHandler<kNewGame>)));
00058     _widgets.back()->setupSounds(0, 1);
00059 
00060     _widgets.push_back(new StaticLocationWidget(
00061             "Continue",
00062             CLICK_HANDLER(MainMenuScreen, loadHandler),
00063             MOVE_HANDLER(MainMenuScreen, helpTextHandler<kContinue>)));
00064     _widgets.back()->setupSounds(0, 1);
00065 
00066     _widgets.push_back(new StaticLocationWidget(
00067             "Options",
00068             CLICK_HANDLER(MainMenuScreen, settingsHandler),
00069             MOVE_HANDLER(MainMenuScreen, helpTextHandler<kOption>)));
00070     _widgets.back()->setupSounds(0, 1);
00071 
00072     _widgets.push_back(new StaticLocationWidget(
00073             "Box",
00074             CLICK_HANDLER(MainMenuScreen, boxHandler),
00075             MOVE_HANDLER(MainMenuScreen, helpTextHandler<kBox>)));
00076     _widgets.back()->setupSounds(0, 1);
00077 
00078     _widgets.push_back(new StaticLocationWidget(
00079             "Quit",
00080             CLICK_HANDLER(MainMenuScreen, quitHandler),
00081             MOVE_HANDLER(MainMenuScreen, helpTextHandler<kQuit>)));
00082     _widgets.back()->setupSounds(0, 1);
00083 
00084     _widgets.push_back(new StaticLocationWidget(
00085             "OptionHelp",
00086             nullptr,
00087             nullptr));
00088     _widgets.back()->setVisible(false);
00089 
00090     _widgets.push_back(new StaticLocationWidget(
00091             "BeginHelp",
00092             nullptr,
00093             nullptr));
00094     _widgets.back()->setVisible(false);
00095 
00096     _widgets.push_back(new StaticLocationWidget(
00097             "ContinueHelp",
00098             nullptr,
00099             nullptr));
00100     _widgets.back()->setVisible(false);
00101 
00102     _widgets.push_back(new StaticLocationWidget(
00103             "BoxHelp",
00104             nullptr,
00105             nullptr));
00106     _widgets.back()->setVisible(false);
00107 
00108     _widgets.push_back(new StaticLocationWidget(
00109             "QuitHelp",
00110             nullptr,
00111             nullptr));
00112     _widgets.back()->setVisible(false);
00113 
00114     _widgets.push_back(new StaticLocationWidget(
00115             "Credits",
00116             CLICK_HANDLER(MainMenuScreen, creditsHandler),
00117             MOVE_HANDLER(MainMenuScreen, helpTextHandler<kCredits>)));
00118     _widgets.back()->setupSounds(0, 1);
00119 
00120     _widgets.push_back(new StaticLocationWidget(
00121             "CreditHelp",
00122             nullptr,
00123             nullptr));
00124     _widgets.back()->setVisible(false);
00125 
00126     _widgets.push_back(new VersionInfoText());
00127 }
00128 
00129 template<MainMenuScreen::HelpTextIndex N>
00130 void MainMenuScreen::helpTextHandler(StaticLocationWidget &widget, const Common::Point &mousePos) {
00131     if (widget.isVisible()) {
00132         _widgets[N]->setVisible(widget.isMouseInside(mousePos));
00133     }
00134 }
00135 
00136 void MainMenuScreen::creditsHandler() {
00137     if (!StarkSettings->isDemo()) {
00138         waitForSoundsToComplete();
00139         StarkUserInterface->requestFMVPlayback("0e02.bbb");
00140     }
00141 }
00142 
00143 void MainMenuScreen::newGameHandler() {
00144     waitForSoundsToComplete();
00145 
00146     StarkUserInterface->changeScreen(kScreenGame);
00147 
00148     StarkResourceProvider->initGlobal();
00149 
00150     if (ConfMan.hasKey("startup_chapter")) {
00151         StarkGlobal->setCurrentChapter(ConfMan.getInt("startup_chapter"));
00152     } else {
00153         StarkGlobal->setCurrentChapter(0);
00154     }
00155 
00156     if (ConfMan.hasKey("startup_level") && ConfMan.hasKey("startup_location")) {
00157         uint levelIndex = strtol(ConfMan.get("startup_level").c_str(), nullptr, 16);
00158         uint locationIndex = strtol(ConfMan.get("startup_location").c_str(), nullptr, 16);
00159         StarkResourceProvider->requestLocationChange(levelIndex, locationIndex);
00160     } else {
00161         if (StarkSettings->isDemo()) {
00162             StarkResourceProvider->requestLocationChange(0x4f, 0x00);
00163         } else {
00164             // Start us up at the house of all worlds
00165             StarkResourceProvider->requestLocationChange(0x45, 0x00);
00166         }
00167     }
00168 }
00169 
00170 void MainMenuScreen::loadHandler() {
00171     StarkUserInterface->changeScreen(Screen::kScreenLoadMenu);
00172 }
00173 
00174 void MainMenuScreen::settingsHandler() {
00175     StarkUserInterface->changeScreen(Screen::kScreenSettingsMenu);
00176 }
00177 
00178 void MainMenuScreen::boxHandler() {
00179     if (!StarkSettings->isDemo() && StarkSettings->hasBookOfSecrets()) {
00180         StarkUserInterface->changeScreen(kScreenGame);
00181         StarkResourceProvider->initGlobal();
00182         StarkResourceProvider->requestLocationChange(0x7c, 0x00);
00183     }
00184 }
00185 
00186 void MainMenuScreen::quitHandler() {
00187     StarkUserInterface->confirm(GameMessage::kQuitGamePrompt, StarkUserInterface,
00188                                 &UserInterface::notifyShouldExit);
00189 }
00190 
00191 VersionInfoText::VersionInfoText() :
00192         StaticLocationWidget("VERSION INFO", nullptr, nullptr) {
00193     Common::String text = _copyrightSymbol + Common::String("1999 Funcom");
00194     _renderEntry->getText()->setText(text);
00195     _renderEntry->setPosition(Common::Point(_posX, _posY));
00196 }
00197 
00198 } // End of namespace Stark


Generated on Sat Apr 20 2019 05:03:10 for ResidualVM by doxygen 1.7.1
curved edge   curved edge