Modificado unLoadMedia por saveConfig

This commit is contained in:
2022-08-09 17:16:12 +02:00
parent d7bd5a8ab1
commit 63bf42880e
2 changed files with 19 additions and 68 deletions

View File

@@ -246,7 +246,7 @@ bool Director::loadConfig()
{
// Indicador de éxito en la carga
bool success = true;
const std::string p = asset->get("config-bin").c_str();
const std::string p = asset->get("config.bin").c_str();
const std::string filename = p.substr(p.find_last_of("\\/") + 1);
// Abre el fichero con la configuracion de las opciones para leer en binario
@@ -297,80 +297,31 @@ bool Director::loadConfig()
return success;
}
// Descrga los recursos necesarios
bool Director::unLoadMedia(Uint8 section)
// Guarda el fichero de configuración
bool Director::saveConfig()
{
// Indicador de éxito en la carga
bool success = true;
std::string p;
const std::string p = asset->get("config.bin");
const std::string filename = p.substr(p.find_last_of("\\/") + 1);
switch (section)
// Abre el fichero de puntuación para escribir
SDL_RWops *file = SDL_RWFromFile(p.c_str(), "w+b");
if (file != NULL)
{
case GAME_SECTION_INIT:
{
p = asset->get("config-bin");
std::string filename = p.substr(p.find_last_of("\\/") + 1);
// Guardamos los datos
SDL_RWwrite(file, &options.fullScreenMode, sizeof(Uint32), 1);
SDL_RWwrite(file, &options.windowSize, sizeof(Uint8), 1);
// Abre el fichero de puntuación para escribir
SDL_RWops *file = SDL_RWFromFile(p.c_str(), "w+b");
printf("Writing file %s\n", filename.c_str());
if (file != NULL)
{
// Guardamos los datos
SDL_RWwrite(file, &options.fullScreenMode, sizeof(Uint32), 1);
SDL_RWwrite(file, &options.windowSize, sizeof(Uint8), 1);
printf("Writing file %s\n", filename.c_str());
// Cerramos el fichero
SDL_RWclose(file);
}
else
{
printf("Error: Unable to save %s file! %s\n", filename.c_str(), SDL_GetError());
}
// Cerramos el fichero
SDL_RWclose(file);
}
break;
case GAME_SECTION_TITLE:
else
{
}
break;
case GAME_SECTION_PLAYING:
{
}
break;
case GAME_SECTION_GAME_OVER_SCREEN:
{
}
break;
case GAME_SECTION_INTRO:
{
}
break;
case GAME_SECTION_DEMO:
{
}
break;
case GAME_SECTION_INSTRUCTIONS:
{
}
break;
case GAME_SECTION_LOGO:
{
}
break;
default:
{
}
break;
printf("Error: Unable to save %s file! %s\n", filename.c_str(), SDL_GetError());
}
return success;

View File

@@ -87,8 +87,8 @@ private:
// Carga el fichero de configuración
bool loadConfig();
// Descrga los recursos necesarios
bool unLoadMedia(Uint8 section);
// Guarda el fichero de configuración
bool saveConfig();
// Obtiene el valor de la variable
Uint8 getGameSection();