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

View File

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