Los datos se guardan en la carpeta de sistema
This commit is contained in:
@@ -385,8 +385,11 @@ void Game::init()
|
||||
// Carga los recursos necesarios para la sección 'Game'
|
||||
void Game::loadMedia()
|
||||
{
|
||||
std::cout << std::endl
|
||||
<< "** LOADING RESOURCES FOR GAME SECTION" << std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << std::endl
|
||||
<< "** LOADING RESOURCES FOR GAME SECTION" << std::endl;
|
||||
}
|
||||
|
||||
// Carga ficheros
|
||||
loadScoreFile();
|
||||
@@ -573,8 +576,11 @@ void Game::loadMedia()
|
||||
// Musicas
|
||||
gameMusic = JA_LoadMusic(asset->get("playing.ogg").c_str());
|
||||
|
||||
std::cout << "** RESOURCES FOR GAME SECTION LOADED" << std::endl
|
||||
<< std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "** RESOURCES FOR GAME SECTION LOADED" << std::endl
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Carga el fichero de puntos
|
||||
@@ -589,13 +595,19 @@ bool Game::loadScoreFile()
|
||||
// El fichero no existe
|
||||
if (file == nullptr)
|
||||
{
|
||||
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
|
||||
}
|
||||
|
||||
// Creamos el fichero para escritura
|
||||
file = SDL_RWFromFile(p.c_str(), "w+b");
|
||||
if (file != nullptr)
|
||||
{
|
||||
std::cout << "New file (" << filename.c_str() << ") created!" << std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "New file (" << filename.c_str() << ") created!" << std::endl;
|
||||
}
|
||||
|
||||
// Inicializamos los datos
|
||||
for (int i = 0; i < TOTAL_SCORE_DATA; ++i)
|
||||
@@ -609,7 +621,10 @@ bool Game::loadScoreFile()
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: Unable to create file " << filename.c_str() << std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "Error: Unable to create file " << filename.c_str() << std::endl;
|
||||
}
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
@@ -617,7 +632,10 @@ bool Game::loadScoreFile()
|
||||
else
|
||||
{
|
||||
// Cargamos los datos
|
||||
std::cout << "Reading file " << filename.c_str() << std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "Reading file " << filename.c_str() << std::endl;
|
||||
}
|
||||
for (int i = 0; i < TOTAL_SCORE_DATA; ++i)
|
||||
SDL_RWread(file, &scoreDataFile[i], sizeof(Uint32), 1);
|
||||
|
||||
@@ -655,13 +673,19 @@ bool Game::loadDemoFile()
|
||||
// El fichero no existe
|
||||
if (file == nullptr)
|
||||
{
|
||||
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
|
||||
}
|
||||
|
||||
// Creamos el fichero para escritura
|
||||
file = SDL_RWFromFile(p.c_str(), "w+b");
|
||||
if (file != nullptr)
|
||||
{
|
||||
std::cout << "New file (" << filename.c_str() << ") created!" << std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "New file (" << filename.c_str() << ") created!" << std::endl;
|
||||
}
|
||||
|
||||
// Inicializamos los datos
|
||||
for (int i = 0; i < TOTAL_DEMO_DATA; ++i)
|
||||
@@ -681,7 +705,10 @@ bool Game::loadDemoFile()
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: Unable to create file " << filename.c_str() << std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "Error: Unable to create file " << filename.c_str() << std::endl;
|
||||
}
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
@@ -689,7 +716,10 @@ bool Game::loadDemoFile()
|
||||
else
|
||||
{
|
||||
// Cargamos los datos
|
||||
std::cout << "Reading file " << filename.c_str() << std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "Reading file " << filename.c_str() << std::endl;
|
||||
}
|
||||
for (int i = 0; i < TOTAL_DEMO_DATA; ++i)
|
||||
SDL_RWread(file, &demo.dataFile[i], sizeof(demoKeys_t), 1);
|
||||
|
||||
@@ -715,14 +745,20 @@ bool Game::saveScoreFile()
|
||||
SDL_RWwrite(file, &scoreDataFile[i], sizeof(Uint32), 1);
|
||||
}
|
||||
|
||||
std::cout << "Writing file " << filename.c_str() << std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "Writing file " << filename.c_str() << std::endl;
|
||||
}
|
||||
|
||||
// Cerramos el fichero
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: Unable to save " << filename.c_str() << " file! " << SDL_GetError() << std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "Error: Unable to save " << filename.c_str() << " file! " << SDL_GetError() << std::endl;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
@@ -771,14 +807,20 @@ bool Game::saveDemoFile()
|
||||
SDL_RWwrite(file, &demo.dataFile[i], sizeof(demoKeys_t), 1);
|
||||
}
|
||||
|
||||
std::cout << "Writing file " << filename.c_str() << std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "Writing file " << filename.c_str() << std::endl;
|
||||
}
|
||||
|
||||
// Cerramos el fichero
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: Unable to save " << filename.c_str() << " file! " << SDL_GetError() << std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "Error: Unable to save " << filename.c_str() << " file! " << SDL_GetError() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
return success;
|
||||
@@ -3851,7 +3893,10 @@ void Game::loadAnimations(std::string filePath, std::vector<std::string> *buffer
|
||||
|
||||
if (file)
|
||||
{
|
||||
std::cout << "Animation loaded: " << filePath.substr(filePath.find_last_of("\\/") + 1).c_str() << std::endl;
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << "Animation loaded: " << filePath.substr(filePath.find_last_of("\\/") + 1).c_str() << std::endl;
|
||||
}
|
||||
while (std::getline(file, line))
|
||||
{
|
||||
buffer->push_back(line);
|
||||
|
||||
Reference in New Issue
Block a user