QDENGINE: Get rid of qdGameConfig completely

Signed-off-by: kunxl-gg <tiwari.25@iitj.ac.in>
This commit is contained in:
kunxl-gg 2024-08-26 01:39:45 +05:30 committed by Eugene Sandulenko
parent 7f8344d28a
commit 88e92ae05f
3 changed files with 0 additions and 389 deletions

View File

@ -170,8 +170,6 @@ int QDEngineEngine::engineMain() {
grD->showMouse(); // FIXME HACK
qdGameConfig::get_config().load();
SplashScreen sp;
if (ConfMan.getBool("splash_enabled")) {
sp.create(IDB_SPLASH);

View File

@ -19,22 +19,13 @@
*
*/
#include "common/archive.h"
#include "common/formats/ini-file.h"
#include "qdengine/qd_fwd.h"
#include "qdengine/qdcore/qd_setup.h"
#include "qdengine/system/graphics/gr_dispatcher.h"
#include "qdengine/system/sound/snd_dispatcher.h"
#include "qdengine/qdcore/qd_game_scene.h"
#include "qdengine/qdcore/util/plaympp_api.h"
namespace QDEngine {
const char *const qdGameConfig::_ini_name = "qd_game.ini";
qdGameConfig qdGameConfig::_config;
bool enumerateIniSections(const char *fname, Common::INIFile::SectionList &sectionList) {
Common::INIFile ini;
@ -74,185 +65,4 @@ void putIniKey(const char *fname, const char *section, const char *key, const ch
warning("STUB: putIniKey");
}
qdGameConfig::qdGameConfig() {
_screen_sx = 640;
_screen_sy = 480;
_bits_per_pixel = 2;
_debug_draw = false;
_debug_show_grid = false;
_fullscreen = true;
_triggers_debug = false;
_driver_id = 1;
_show_fps = false;
_force_full_redraw = false;
_enable_sound = true;
_sound_volume = 255;
_enable_music = true;
_music_volume = 255;
_logic_period = 25;
_logic_synchro_by_clock = 1;
_game_speed = 1.0f;
_is_splash_enabled = true;
_splash_time = 3000;
_enable_profiler = false;
_locale = "Russian";
_minigame_read_only_ini = false;
}
void qdGameConfig::set_pixel_format(int pf) {
switch (pf) {
case GR_ARGB1555:
_bits_per_pixel = 0;
break;
case GR_RGB565:
_bits_per_pixel = 1;
break;
case GR_RGB888:
_bits_per_pixel = 2;
break;
case GR_ARGB8888:
_bits_per_pixel = 3;
break;
}
}
int qdGameConfig::bits_per_pixel() const {
switch (_bits_per_pixel) {
case 0:
return 15;
case 1:
return 16;
case 2:
return 24;
case 3:
return 32;
}
return 24;
}
void qdGameConfig::set_bits_per_pixel(int bpp) {
switch (bpp) {
case 15:
_bits_per_pixel = 0;
break;
case 16:
_bits_per_pixel = 1;
break;
case 24:
_bits_per_pixel = 2;
break;
case 32:
_bits_per_pixel = 3;
break;
}
}
int qdGameConfig::pixel_format() const {
switch (bits_per_pixel()) {
case 15:
return GR_ARGB1555;
case 16:
return GR_RGB565;
case 24:
return GR_RGB888;
case 32:
return GR_ARGB8888;
}
return GR_RGB888;
}
void qdGameConfig::load() {
const char *p = 0;
p = getIniKey(_ini_name, "graphics", "color_depth");
if (strlen(p)) _bits_per_pixel = atoi(p);
p = getIniKey(_ini_name, "graphics", "fullscreen");
if (strlen(p)) _fullscreen = (atoi(p)) > 0;
p = getIniKey(_ini_name, "graphics", "driver");
if (strlen(p)) _driver_id = atoi(p);
p = getIniKey(_ini_name, "game", "logic_period");
if (strlen(p)) _logic_period = atoi(p);
p = getIniKey(_ini_name, "game", "synchro_by_clock");
if (strlen(p)) _logic_synchro_by_clock = atoi(p);
p = getIniKey(_ini_name, "game", "game_speed");
if (strlen(p)) _game_speed = atof(p);
p = getIniKey(_ini_name, "game", "locale");
if (strlen(p)) _locale = p;
p = getIniKey(_ini_name, "game", "fps_period");
if (strlen(p)) qdGameScene::fps_counter()->set_period(atoi(p));
if (atoi(getIniKey(_ini_name, "debug", "full_redraw")))
_force_full_redraw = true;
if (atoi(getIniKey(_ini_name, "debug", "enable_profiler")))
_enable_profiler = true;
p = getIniKey(_ini_name, "debug", "triggers_log_file");
if (strlen(p)) _profiler_file = p;
if (atoi(getIniKey(_ini_name, "debug", "triggers_debug")))
_triggers_debug = true;
p = getIniKey(_ini_name, "sound", "enable_sound");
if (strlen(p)) _enable_sound = (atoi(p) > 0);
p = getIniKey(_ini_name, "sound", "sound_volume");
if (strlen(p)) _sound_volume = atoi(p);
p = getIniKey(_ini_name, "sound", "enable_music");
if (strlen(p)) _enable_music = (atoi(p) > 0);
p = getIniKey(_ini_name, "sound", "music_volume");
if (strlen(p)) _music_volume = atoi(p);
p = getIniKey(_ini_name, "minigame", "read_only_ini");
if (strlen(p)) _minigame_read_only_ini = (atoi(p) > 0);
}
void qdGameConfig::save() {
putIniKey(_ini_name, "graphics", "color_depth", _bits_per_pixel);
putIniKey(_ini_name, "graphics", "fullscreen", _fullscreen);
putIniKey(_ini_name, "graphics", "driver", _driver_id);
putIniKey(_ini_name, "sound", "enable_sound", _enable_sound);
putIniKey(_ini_name, "sound", "sound_volume", _sound_volume);
putIniKey(_ini_name, "sound", "enable_music", _enable_music);
putIniKey(_ini_name, "sound", "music_volume", _music_volume);
}
bool qdGameConfig::update_sound_settings() const {
#ifndef __QD_SYSLIB__
if (sndDispatcher * dp = sndDispatcher::get_dispatcher()) {
dp->set_volume(_sound_volume);
if (_enable_sound) dp->enable();
else dp->disable();
return true;
}
#endif
return false;
}
bool qdGameConfig::update_music_settings() const {
mpegPlayer::instance().set_volume(_music_volume);
if (_enable_music) mpegPlayer::instance().enable();
else mpegPlayer::instance().disable();
return true;
}
} // namespace QDEngine

View File

@ -26,203 +26,6 @@
namespace QDEngine {
//! Настройки.
class qdGameConfig {
public:
qdGameConfig();
~qdGameConfig() { }
int screen_sx() const {
return _screen_sx;
}
int screen_sy() const {
return _screen_sy;
}
int driver_ID() const {
return _driver_id;
}
void set_driver_ID(int id) {
_driver_id = id;
}
void set_screen_size(int sx, int sy) {
_screen_sx = sx;
_screen_sy = sy;
}
int pixel_format() const;
void set_pixel_format(int pf);
int bits_per_pixel() const;
void set_bits_per_pixel(int bpp);
bool debug_draw() const {
return _debug_draw;
}
void toggle_debug_draw() {
_debug_draw = !_debug_draw;
}
bool debug_show_grid() const {
return _debug_show_grid;
}
void toggle_show_grid() {
_debug_show_grid = !_debug_show_grid;
}
bool force_full_redraw() const {
return _force_full_redraw;
}
void toggle_full_redraw() {
_force_full_redraw = !_force_full_redraw;
}
bool fullscreen() const {
return _fullscreen;
}
void toggle_fullscreen() {
_fullscreen = !_fullscreen;
}
const char *locale() const {
return _locale.c_str();
}
void load();
void save();
static qdGameConfig &get_config() {
return _config;
}
static void set_config(const qdGameConfig &s) {
_config = s;
}
static const char *ini_name() {
return _ini_name;
}
bool triggers_debug() const {
return _triggers_debug;
}
void toggle_triggers_debug(bool v) {
_triggers_debug = v;
}
bool show_fps() const {
return _show_fps;
}
void toggle_fps() {
_show_fps = !_show_fps;
}
bool is_sound_enabled() const {
return _enable_sound;
}
void toggle_sound(bool state) {
_enable_sound = state;
}
uint32 sound_volume() const {
return _sound_volume;
}
void set_sound_volume(uint32 vol) {
_sound_volume = vol;
}
bool update_sound_settings() const;
bool is_music_enabled() const {
return _enable_music;
}
void toggle_music(bool state) {
_enable_music = state;
}
uint32 music_volume() const {
return _music_volume;
}
void set_music_volume(uint32 vol) {
_music_volume = vol;
}
bool update_music_settings() const;
int logic_period() const {
return _logic_period;
}
int logic_synchro_by_clock() const {
return _logic_synchro_by_clock;
}
float game_speed() const {
return _game_speed;
}
void set_game_speed(float speed) {
_game_speed = speed;
}
bool is_splash_enabled() const {
return _is_splash_enabled;
}
int splash_time() const {
return _splash_time;
}
bool is_profiler_enabled() const {
return _enable_profiler;
}
void toggle_profiler(bool state) {
_enable_profiler = state;
}
const char *profiler_file() const {
return _profiler_file.c_str();
}
void set_profiler_file(const char *fname) {
_profiler_file = fname;
}
bool minigame_read_only_ini() const {
return _minigame_read_only_ini;
}
private:
int _bits_per_pixel;
bool _fullscreen;
int _driver_id;
int _screen_sx;
int _screen_sy;
bool _enable_sound;
uint32 _sound_volume;
bool _enable_music;
uint32 _music_volume;
bool _debug_draw;
bool _debug_show_grid;
bool _triggers_debug;
bool _show_fps;
bool _force_full_redraw;
int _logic_period;
int _logic_synchro_by_clock;
float _game_speed;
bool _is_splash_enabled;
int _splash_time;
bool _enable_profiler;
Common::String _profiler_file;
Common::String _locale;
bool _minigame_read_only_ini;
static qdGameConfig _config;
static const char *const _ini_name;
};
const char *getIniKey(const char *fname, const char *section, const char *key);
void putIniKey(const char *fname, const char *section, const char *key, int val);
void putIniKey(const char *fname, const char *section, const char *key, const char *val);