From 7ce2045ae03f65714556dda02acf98348ee8a0dc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 24 Oct 2019 00:53:11 +0200 Subject: GRIFFON: Synchronize sound settings --- engines/griffon/config.cpp | 93 +++++++++------------------------------------ engines/griffon/config.h | 7 ---- engines/griffon/dialogs.cpp | 3 -- engines/griffon/griffon.cpp | 10 ++++- engines/griffon/griffon.h | 1 + 5 files changed, 29 insertions(+), 85 deletions(-) (limited to 'engines/griffon') diff --git a/engines/griffon/config.cpp b/engines/griffon/config.cpp index 83e1e8525e..5e6d442c3b 100644 --- a/engines/griffon/config.cpp +++ b/engines/griffon/config.cpp @@ -34,16 +34,12 @@ * */ - #include "griffon/config.h" +#include "common/config-manager.h" namespace Griffon { -CONFIG config = { - 320, 240, 16, false, 0, 0, true, 127, true, 127 -}; - -char config_ini[64] = "config.ini"; +CONFIG config; #define PRINT(A,B) \ do { \ @@ -60,81 +56,30 @@ char config_ini[64] = "config.ini"; } while(0) void config_load(CONFIG *config) { -#if 0 - char line[128]; - char arg[128]; - - FILE *fp = fopen(config_ini, "r"); - if (fp) { - while (fgets(line, sizeof(line), fp) != NULL) { - sscanf(line, "%s", arg); // eliminate eol and eof by this + bool mute = false; + if (ConfMan.hasKey("mute")) + mute = ConfMan.getBool("mute"); - if (strcmp(arg, "SCR_WIDTH:") == 0) { - fgets(line, sizeof(line), fp); - sscanf(line, "%i", &config->scr_width); - } else if (strcmp(arg, "SCR_HEIGHT:") == 0) { - fgets(line, sizeof(line), fp); - sscanf(line, "%i", &config->scr_height); - } else if (strcmp(arg, "SCR_BITS:") == 0) { - fgets(line, sizeof(line), fp); - sscanf(line, "%i", &config->scr_bpp); - } else if (strcmp(arg, "HWACCEL:YES") == 0) { - config->hwaccel = true; - } else if (strcmp(arg, "HWACCEL:NO") == 0) { - config->hwaccel = false; - } else if (strcmp(arg, "HWSURFACE:YES") == 0) { - config->hwsurface = true; - } else if (strcmp(arg, "HWSURFACE:NO") == 0) { - config->hwsurface = false; - } else if (strcmp(arg, "FULLSCREEN:YES") == 0) { - config->fullscreen = true; - } else if (strcmp(arg, "FULLSCREEN:NO") == 0) { - config->fullscreen = false; - } else if (strcmp(arg, "MUSIC:YES") == 0) { - config->music = true; - } else if (strcmp(arg, "MUSIC:NO") == 0) { - config->music = false; - } else if (strcmp(arg, "SNDEFFECTS:YES") == 0) { - config->effects = true; - } else if (strcmp(arg, "SNDEFFECTS:NO") == 0) { - config->effects = false; - } else if (strcmp(arg, "opmusicvol:") == 0) { - fgets(line, sizeof(line), fp); - sscanf(line, "%i", &config->musicvol); - } else if (strcmp(arg, "opeffectsvol:") == 0) { - fgets(line, sizeof(line), fp); - sscanf(line, "%i", &config->effectsvol); - } - } + config->music = mute; + config->effects = mute; - fclose(fp); + if (!mute) { + config->music = !ConfMan.getBool("music_mute"); + config->effects = !ConfMan.getBool("sfx_mute"); } -#endif + + config->musicvol = ConfMan.getInt("music_volume"); + config->effectsvol = ConfMan.getInt("sfx_volume"); } void config_save(CONFIG *config) { -#if 0 - FILE *fp = fopen(config_ini, "w"); + ConfMan.setBool("mute", !(config->music || config->effectsvol)); + ConfMan.setBool("music_mute", !config->music); + ConfMan.setBool("sfx_mute", !config->effects); + ConfMan.setInt("music_volume", config->musicvol); + ConfMan.setInt("sfx_volume", config->effectsvol); - if (fp) { - PRINT("%s", "SCR_WIDTH:"); - PRINT("%i", config->scr_width); - PRINT("%s", "SCR_HEIGHT:"); - PRINT("%i", config->scr_height); - PRINT("%s", "SCR_BITS:"); - PRINT("%i", config->scr_bpp); - PRINT("%s", config->hwaccel ? "HWACCEL:YES" : "HWACCEL:NO"); - PRINT("%s", config->hwsurface ? "HWSURFACE:YES" : "HWSURFACE:NO"); - PRINT("%s", config->fullscreen ? "FULLSCREEN:YES" : "FULLSCREEN:NO"); - PRINT("%s", config->music ? "MUSIC:YES" : "MUSIC:NO"); - PRINT("%s", config->effects ? "SNDEFFECTS:YES" : "SNDEFFECTS:NO"); - PRINT("%s", "opmusicvol:"); - PRINT("%i", config->musicvol); - PRINT("%s", "opeffectsvol:"); - PRINT("%i", config->effectsvol); - fclose(fp); - } -#endif + ConfMan.flushToDisk(); } } // end of namespace Griffon diff --git a/engines/griffon/config.h b/engines/griffon/config.h index 187ff2823a..686b8efa7f 100644 --- a/engines/griffon/config.h +++ b/engines/griffon/config.h @@ -40,12 +40,6 @@ namespace Griffon { struct CONFIG { - int scr_width; - int scr_height; - int scr_bpp; - bool fullscreen; - int hwaccel; - int hwsurface; // Unused bool music; int musicvol; bool effects; @@ -53,7 +47,6 @@ struct CONFIG { }; extern CONFIG config; -extern char config_ini[]; void config_load(CONFIG *config); void config_save(CONFIG *config); diff --git a/engines/griffon/dialogs.cpp b/engines/griffon/dialogs.cpp index 4031da742f..8e2030559f 100644 --- a/engines/griffon/dialogs.cpp +++ b/engines/griffon/dialogs.cpp @@ -223,9 +223,6 @@ void GriffonEngine::configMenu() { int ticks1 = _ticks; - config.musicvol = ConfMan.getInt("music_volume"); - config.effectsvol = ConfMan.getInt("sfx_volume"); - do { _videobuffer->fillRect(Common::Rect(0, 0, _videobuffer->w, _videobuffer->h), 0); diff --git a/engines/griffon/griffon.cpp b/engines/griffon/griffon.cpp index d954269475..33d1134d11 100644 --- a/engines/griffon/griffon.cpp +++ b/engines/griffon/griffon.cpp @@ -32,6 +32,7 @@ #include "engines/util.h" #include "griffon/griffon.h" +#include "griffon/config.h" #include "griffon/console.h" namespace Griffon { @@ -51,14 +52,21 @@ GriffonEngine::GriffonEngine(OSystem *syst) : Engine(syst) { _menuchannel = -1; _loopseta = 0; - clouddeg = 0.0f; + + // Synchronize the sound settings from ScummVM + syncSoundSettings(); + config_load(&config); } GriffonEngine::~GriffonEngine() { delete _rnd; } +void GriffonEngine::syncSoundSettings() { + Engine::syncSoundSettings(); +} + Common::Error GriffonEngine::run() { initGraphics(320, 240, new Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); diff --git a/engines/griffon/griffon.h b/engines/griffon/griffon.h index 55fedeb410..0a8c06a773 100644 --- a/engines/griffon/griffon.h +++ b/engines/griffon/griffon.h @@ -286,6 +286,7 @@ public: ~GriffonEngine(); virtual Common::Error run(); + virtual void syncSoundSettings(); private: Common::RandomSource *_rnd; -- cgit v1.2.3