STARK: Remove the StarkGameDescription service

It's not really needed anymore now there is a settings service
This commit is contained in:
Bastien Bouclet 2018-06-02 08:11:57 +02:00
parent 388eafac80
commit a27834fa76
6 changed files with 28 additions and 21 deletions

View File

@ -26,8 +26,6 @@
#include "common/singleton.h" #include "common/singleton.h"
#include "common/scummsys.h" #include "common/scummsys.h"
struct ADGameDescription;
namespace Common { namespace Common {
class RandomSource; class RandomSource;
} }
@ -68,7 +66,6 @@ public:
gameInterface = nullptr; gameInterface = nullptr;
userInterface = nullptr; userInterface = nullptr;
fontProvider = nullptr; fontProvider = nullptr;
gameDescription = nullptr;
settings = nullptr; settings = nullptr;
} }
@ -84,7 +81,6 @@ public:
GameInterface *gameInterface; GameInterface *gameInterface;
UserInterface *userInterface; UserInterface *userInterface;
FontProvider *fontProvider; FontProvider *fontProvider;
const ADGameDescription *gameDescription;
Settings *settings; Settings *settings;
}; };
@ -101,7 +97,6 @@ public:
#define StarkGameInterface StarkServices::instance().gameInterface #define StarkGameInterface StarkServices::instance().gameInterface
#define StarkUserInterface StarkServices::instance().userInterface #define StarkUserInterface StarkServices::instance().userInterface
#define StarkFontProvider StarkServices::instance().fontProvider #define StarkFontProvider StarkServices::instance().fontProvider
#define StarkGameDescription StarkServices::instance().gameDescription
#define StarkSettings StarkServices::instance().settings #define StarkSettings StarkServices::instance().settings
} // End of namespace Stark } // End of namespace Stark

View File

@ -29,10 +29,13 @@
#include "audio/mixer.h" #include "audio/mixer.h"
#include "engines/advancedDetector.h"
namespace Stark { namespace Stark {
Settings::Settings(Audio::Mixer *mixer) : Settings::Settings(Audio::Mixer *mixer, const ADGameDescription *gd) :
_mixer(mixer) { _mixer(mixer),
_isDemo(gd->flags & ADGF_DEMO) {
// Initialize keys // Initialize keys
_boolKey[kHighModel] = "enable_high_resolution_models"; _boolKey[kHighModel] = "enable_high_resolution_models";
_boolKey[kSubtitle] = "subtitles"; _boolKey[kSubtitle] = "subtitles";

View File

@ -26,7 +26,8 @@
#include "common/config-manager.h" #include "common/config-manager.h"
#include "engines/stark/services/services.h" #include "engines/stark/services/services.h"
#include "engines/advancedDetector.h"
struct ADGameDescription;
namespace Audio { namespace Audio {
class Mixer; class Mixer;
@ -56,13 +57,18 @@ public:
kSfx kSfx
}; };
static bool isDemo() { Settings(Audio::Mixer *mixer, const ADGameDescription *gd);
return StarkGameDescription->flags & ADGF_DEMO;
}
explicit Settings(Audio::Mixer *mixer);
~Settings() {} ~Settings() {}
/**
* Is this a demo version of the game?
*
* This is true either for 4-CD or 2-CD style demos
*/
bool isDemo() const {
return _isDemo;
}
/** Get the settings value */ /** Get the settings value */
bool getBoolSetting(BoolSettingIndex index) { return ConfMan.getBool(_boolKey[index]); } bool getBoolSetting(BoolSettingIndex index) { return ConfMan.getBool(_boolKey[index]); }
int getIntSetting(IntSettingIndex index) { return ConfMan.getInt(_intKey[index]); } int getIntSetting(IntSettingIndex index) { return ConfMan.getInt(_intKey[index]); }
@ -81,6 +87,7 @@ public:
private: private:
Audio::Mixer *_mixer; Audio::Mixer *_mixer;
bool _hasLowRes; bool _hasLowRes;
const bool _isDemo;
const char *_boolKey[6]; const char *_boolKey[6];
const char *_intKey[3]; const char *_intKey[3];

View File

@ -121,7 +121,7 @@ Common::Error StarkEngine::run() {
_diary = new Diary(); _diary = new Diary();
_gameInterface = new GameInterface(); _gameInterface = new GameInterface();
_userInterface = new UserInterface(_gfx); _userInterface = new UserInterface(_gfx);
_settings = new Settings(_mixer); _settings = new Settings(_mixer, _gameDescription);
// Setup the public services // Setup the public services
StarkServices &services = StarkServices::instance(); StarkServices &services = StarkServices::instance();
@ -137,7 +137,6 @@ Common::Error StarkEngine::run() {
services.gameInterface = _gameInterface; services.gameInterface = _gameInterface;
services.userInterface = _userInterface; services.userInterface = _userInterface;
services.fontProvider = _fontProvider; services.fontProvider = _fontProvider;
services.gameDescription = _gameDescription;
services.settings = _settings; services.settings = _settings;
// Load global resources // Load global resources

View File

@ -23,9 +23,10 @@
#ifndef STARK_H #ifndef STARK_H
#define STARK_H #define STARK_H
#include "engines/advancedDetector.h"
#include "engines/engine.h" #include "engines/engine.h"
struct ADGameDescription;
namespace Common { namespace Common {
class RandomSource; class RandomSource;
} }
@ -54,21 +55,21 @@ class Settings;
class StarkEngine : public Engine { class StarkEngine : public Engine {
public: public:
StarkEngine(OSystem *syst, const ADGameDescription *gameDesc); StarkEngine(OSystem *syst, const ADGameDescription *gameDesc);
virtual ~StarkEngine(); ~StarkEngine() override;
/** Build a save file name for the specified target and slot */ /** Build a save file name for the specified target and slot */
static Common::String formatSaveName(const char *target, int slot); static Common::String formatSaveName(const char *target, int slot);
protected: protected:
// Engine APIs // Engine APIs
virtual Common::Error run() override; Common::Error run() override;
virtual GUI::Debugger *getDebugger() override { return (GUI::Debugger *)_console; } GUI::Debugger *getDebugger() override { return (GUI::Debugger *)_console; }
bool hasFeature(EngineFeature f) const override; bool hasFeature(EngineFeature f) const override;
bool canLoadGameStateCurrently() override; bool canLoadGameStateCurrently() override;
bool canSaveGameStateCurrently() override; bool canSaveGameStateCurrently() override;
Common::Error loadGameState(int slot) override; Common::Error loadGameState(int slot) override;
Common::Error saveGameState(int slot, const Common::String &desc) override; Common::Error saveGameState(int slot, const Common::String &desc) override;
virtual void pauseEngineIntern(bool pause) override; void pauseEngineIntern(bool pause) override;
private: private:
void mainLoop(); void mainLoop();

View File

@ -27,11 +27,13 @@
#include "engines/stark/services/settings.h" #include "engines/stark/services/settings.h"
#include "common/config-manager.h" #include "common/config-manager.h"
#include "common/translation.h" #include "common/translation.h"
#include "gui/saveload.h" #include "gui/saveload.h"
#include "gui/message.h" #include "gui/message.h"
#include "engines/engine.h"
namespace Stark { namespace Stark {
MainMenuScreen::MainMenuScreen(Gfx::Driver *gfx, Cursor *cursor) : MainMenuScreen::MainMenuScreen(Gfx::Driver *gfx, Cursor *cursor) :