Completado el ciclo para pedir el ID online. Añadido sonido a las notificaciones. Agregado control de versión del fichero de configuración

This commit is contained in:
2022-11-23 16:59:40 +01:00
parent 706ad6f9c0
commit a8b467290f
14 changed files with 95 additions and 130 deletions

View File

@@ -18,7 +18,7 @@ Director::Director(int argc, char *argv[])
section.subsection = SUBSECTION_LOGO_TO_INTRO;
#ifdef DEBUG
section.name = SECTION_PROG_GAME;
section.name = SECTION_PROG_LOGO;
#endif
// Crea e inicializa las opciones del programa
@@ -59,7 +59,7 @@ Director::Director(int argc, char *argv[])
music = JA_LoadMusic(asset->get("title.ogg").c_str());
// Inicializa los servicios online
initOnline();
//initOnline();
}
Director::~Director()
@@ -112,7 +112,10 @@ void Director::initOptions()
// Crea el puntero a la estructura de opciones
options = new options_t;
// Inicializa valores
// Version
options->configVersion = "v1.06.1";
// Opciones dee video
options->gameWidth = GAMECANVAS_WIDTH;
options->gameHeight = GAMECANVAS_HEIGHT;
options->videoMode = 0;
@@ -134,8 +137,8 @@ void Director::initOptions()
options->stats.rooms = 0;
options->stats.items = 0;
// Online
options->online.enabled = false;
// Opciones online
options->online.enabled = true;
options->online.server = "jaildoctor.duckdns.org";
options->online.port = 9911;
#ifdef DEBUG
@@ -188,6 +191,10 @@ bool Director::loadConfig()
// Indicador de éxito en la carga
bool success = true;
// Versión actual del fichero
const std::string configVersion = options->configVersion;
options->configVersion = "";
// Variables para manejar el fichero
std::string line;
std::ifstream file(asset->get("config.txt"));
@@ -234,6 +241,13 @@ bool Director::loadConfig()
saveConfig();
}
// Si la versión de fichero no coincide, crea un fichero nuevo con los valores por defecto
if (configVersion != options->configVersion)
{
initOptions();
saveConfig();
}
// Normaliza los valores
const bool a = options->videoMode == 0;
const bool b = options->videoMode == SDL_WINDOW_FULLSCREEN;
@@ -289,7 +303,10 @@ bool Director::saveConfig()
}
// Escribe en el fichero
file << "## VISUAL OPTIONS\n";
file << "## VERSION\n";
file << "version=" + options->configVersion + "\n";
file << "\n## VISUAL OPTIONS\n";
if (options->videoMode == 0)
{
file << "videoMode=0\n";
@@ -954,7 +971,12 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
// Indicador de éxito en la asignación
bool success = true;
if (var == "videoMode")
if (var == "configVersion")
{
options->configVersion = value;
}
else if (var == "videoMode")
{
if (value == "SDL_WINDOW_FULLSCREEN_DESKTOP")
{
@@ -1512,6 +1534,7 @@ bool Director::setFileList()
asset->add(prefix + "/data/sound/jump22.wav", t_sound);
asset->add(prefix + "/data/sound/jump23.wav", t_sound);
asset->add(prefix + "/data/sound/jump24.wav", t_sound);
asset->add(prefix + "/data/sound/notify.wav", t_sound);
// Logo
asset->add(prefix + "/data/logo/jailgames.png", t_bitmap);