diff --git a/engines/stark/services/services.h b/engines/stark/services/services.h index 5506f4657ac..b1a3fcfe351 100644 --- a/engines/stark/services/services.h +++ b/engines/stark/services/services.h @@ -26,6 +26,8 @@ #include "common/singleton.h" #include "common/scummsys.h" +struct ADGameDescription; + namespace Common { class RandomSource; } @@ -79,6 +81,7 @@ public: GameInterface *gameInterface; UserInterface *userInterface; FontProvider *fontProvider; + const ADGameDescription *gameDescription; }; /** Shortcuts for accessing the services. */ @@ -94,6 +97,7 @@ public: #define StarkGameInterface StarkServices::instance().gameInterface #define StarkUserInterface StarkServices::instance().userInterface #define StarkFontProvider StarkServices::instance().fontProvider +#define StarkGameDescription StarkServices::instance().gameDescription } // End of namespace Stark diff --git a/engines/stark/services/userinterface.cpp b/engines/stark/services/userinterface.cpp index adaab6f01c8..a565a45a63d 100644 --- a/engines/stark/services/userinterface.cpp +++ b/engines/stark/services/userinterface.cpp @@ -64,6 +64,7 @@ UserInterface::~UserInterface() { delete _fmvScreen; delete _diaryIndexScreen; delete _cursor; + delete _mainMenuScreen; } void UserInterface::init() { diff --git a/engines/stark/stark.cpp b/engines/stark/stark.cpp index 35ff43a86cb..a2248b0e021 100644 --- a/engines/stark/stark.cpp +++ b/engines/stark/stark.cpp @@ -138,6 +138,7 @@ Common::Error StarkEngine::run() { services.gameInterface = _gameInterface; services.userInterface = _userInterface; services.fontProvider = _fontProvider; + services.gameDescription = _gameDescription; // Load global resources _resourceProvider->initGlobal(); diff --git a/engines/stark/ui/menu/locationscreen.cpp b/engines/stark/ui/menu/locationscreen.cpp index e6edfcf3ab2..72b411a9a77 100644 --- a/engines/stark/ui/menu/locationscreen.cpp +++ b/engines/stark/ui/menu/locationscreen.cpp @@ -180,6 +180,9 @@ void StaticLocationWidget::onClick() { _soundMouseClick->play(); } + // Ensure the click sound is played completely + while (_soundMouseClick->isPlaying()) {}; + if (_onClick) { (*_onClick)(); } diff --git a/engines/stark/ui/menu/mainmenu.cpp b/engines/stark/ui/menu/mainmenu.cpp index 31bd3d7dea9..2980735a2d2 100644 --- a/engines/stark/ui/menu/mainmenu.cpp +++ b/engines/stark/ui/menu/mainmenu.cpp @@ -1,4 +1,28 @@ +/* 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/mainmenu.h" +#include "engines/stark/services/userinterface.h" +#include "engines/stark/services/resourceprovider.h" namespace Stark { @@ -20,7 +44,7 @@ void MainMenuScreen::open() { _widgets.push_back(new StaticLocationWidget( "NewGame", - nullptr, + CLICK_HANDLER(MainMenuScreen, newGameHandler), MOVE_HANDLER(MainMenuScreen, helpTextHandler<7>))); _widgets.back()->setupSounds(0, 1); @@ -108,4 +132,14 @@ void MainMenuScreen::helpTextHandler(StaticLocationWidget &widget, const Common: } } +void MainMenuScreen::newGameHandler() { + StarkUserInterface->changeScreen(kScreenGame); + + if (isDemo()) { + StarkResourceProvider->requestLocationChange(0x4f, 0x00); + } else { + StarkResourceProvider->requestLocationChange(0x45, 0x00); + } +} + } // End of namespace Stark \ No newline at end of file diff --git a/engines/stark/ui/menu/mainmenu.h b/engines/stark/ui/menu/mainmenu.h index 5483418a255..768788f6c4e 100644 --- a/engines/stark/ui/menu/mainmenu.h +++ b/engines/stark/ui/menu/mainmenu.h @@ -1,7 +1,31 @@ +/* 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_MAIN_MENU_H #define STARK_UI_MENU_MAIN_MENU_H #include "engines/stark/ui/menu/locationscreen.h" +#include "engines/stark/services/services.h" +#include "engines/advancedDetector.h" namespace Stark { @@ -14,11 +38,17 @@ public: virtual ~MainMenuScreen(); // StaticLocationScreen API - void open(); + void open() override; private: template void helpTextHandler(StaticLocationWidget &widget, const Common::Point &mousePos); + + void newGameHandler(); + + bool isDemo() { + return StarkGameDescription->flags & ADGF_DEMO; + } }; } // End of namespace Stark