This commit is contained in:
2024-10-10 20:59:39 +02:00
parent d6c3c89872
commit 117b80bdfc
18 changed files with 197 additions and 197 deletions

View File

@@ -27,12 +27,12 @@ void initOptions()
options.video.window.size = 2;
#endif
options.video.filter = ScreenFilter::NEAREST;
options.video.vSync = true;
options.video.v_sync = true;
options.video.shaders = true;
// Opciones de las notificaciones
options.notification.posV = pos_top;
options.notification.posH = pos_left;
options.notification.pos_v = NotifyPosition::TOP;
options.notification.pos_h = NotifyPosition::LEFT;
options.notification.sound = false;
options.notification.color = (Color){48, 48, 48};
@@ -51,12 +51,12 @@ void initOptions()
options.controller.clear();
OptionsController c;
const int numPlayers = 2;
constexpr int numPlayers = 2;
for (int index = 0; index < numPlayers; ++index)
{
c.index = index;
c.playerId = index + 1;
c.deviceType = INPUT_USE_GAMECONTROLLER;
c.player_id = index + 1;
c.device_type = INPUT_USE_GAMECONTROLLER;
c.name = "NO NAME";
c.plugged = false;
@@ -78,11 +78,11 @@ void initOptions()
options.controller.push_back(c);
}
options.controller[0].deviceType = INPUT_USE_ANY; // El primer jugador puede usar tanto el teclado como el primer mando
options.controller[0].device_type = INPUT_USE_ANY; // El primer jugador puede usar tanto el teclado como el primer mando
}
// Carga el fichero de configuración
bool loadOptionsFile(std::string filePath)
bool loadOptionsFile(std::string file_path)
{
// Inicializa las opciones del programa
initOptions();
@@ -91,8 +91,8 @@ bool loadOptionsFile(std::string filePath)
bool success = true;
// Variables para manejar el fichero
const std::string fileName = filePath.substr(filePath.find_last_of("\\/") + 1);
std::ifstream file(filePath);
const std::string fileName = file_path.substr(file_path.find_last_of("\\/") + 1);
std::ifstream file(file_path);
// Si el fichero se puede abrir
if (file.good())
@@ -128,7 +128,7 @@ bool loadOptionsFile(std::string filePath)
// El fichero no existe
else
{ // Crea el fichero con los valores por defecto
saveOptionsFile(filePath);
saveOptionsFile(file_path);
}
// Normaliza los valores
@@ -153,10 +153,10 @@ bool loadOptionsFile(std::string filePath)
}
// Guarda el fichero de configuración
bool saveOptionsFile(std::string filePath)
bool saveOptionsFile(std::string file_path)
{
const std::string fileName = filePath.substr(filePath.find_last_of("\\/") + 1);
std::ofstream file(filePath);
const std::string fileName = file_path.substr(file_path.find_last_of("\\/") + 1);
std::ofstream file(file_path);
if (!file.good())
{
@@ -171,14 +171,14 @@ bool saveOptionsFile(std::string filePath)
#endif
// Opciones de video
const auto valueVideoModeWinow = std::to_string(static_cast<int>(ScreenVideoMode::WINDOW));
const auto valueVideoModeFullscreen = std::to_string(static_cast<int>(ScreenVideoMode::FULLSCREEN));
const auto valueFilterNearest = std::to_string(static_cast<int>(ScreenFilter::NEAREST));
const auto valueFilterLineal = std::to_string(static_cast<int>(ScreenFilter::LINEAL));
const auto value_video_mode_winow = std::to_string(static_cast<int>(ScreenVideoMode::WINDOW));
const auto value_video_mode_fullscreen = std::to_string(static_cast<int>(ScreenVideoMode::FULLSCREEN));
const auto value_filter_nearest = std::to_string(static_cast<int>(ScreenFilter::NEAREST));
const auto value_filter_lineal = std::to_string(static_cast<int>(ScreenFilter::LINEAL));
file << "## VIDEO\n";
file << "## video.mode [" << valueVideoModeWinow << ": window, " << valueVideoModeFullscreen << ": fullscreen]\n";
file << "## video.filter [" << valueFilterNearest << ": nearest, " << valueFilterLineal << ": lineal]\n";
file << "## video.mode [" << value_video_mode_winow << ": window, " << value_video_mode_fullscreen << ": fullscreen]\n";
file << "## video.filter [" << value_filter_nearest << ": nearest, " << value_filter_lineal << ": lineal]\n";
file << "\n";
const auto valueVideoMode = std::to_string(static_cast<int>(options.video.mode));
@@ -190,37 +190,37 @@ bool saveOptionsFile(std::string filePath)
file << "video.filter=" << valueFilter << "\n";
file << "video.shaders=" + boolToString(options.video.shaders) + "\n";
file << "video.vSync=" + boolToString(options.video.vSync) + "\n";
file << "video.v_sync=" + boolToString(options.video.v_sync) + "\n";
// Opciones de notificaciones
file << "\n\n## NOTIFICATION\n";
file << "## notification.posV [pos_top | pos_bottom]\n";
file << "## notification.posH [pos_left | pos_middle | pos_right]\n";
file << "## notification.pos_v [TOP | BOTTOM]\n";
file << "## notification.pos_h [LEFT | MIDDLE | RIGHT]\n";
file << "\n";
if (options.notification.posV == pos_top)
if (options.notification.pos_v == NotifyPosition::TOP)
{
file << "notification.posV=pos_top\n";
file << "notification.pos_v=TOP\n";
}
else
{
file << "notification.posV=pos_bottom\n";
file << "notification.pos_v=BOTTOM\n";
}
if (options.notification.posH == pos_left)
if (options.notification.pos_h == NotifyPosition::LEFT)
{
file << "notification.posH=pos_left\n";
file << "notification.pos_h=LEFT\n";
}
else if (options.notification.posH == pos_middle)
else if (options.notification.pos_h == NotifyPosition::MIDDLE)
{
file << "notification.posH=pos_middle\n";
file << "notification.posH=MIDDLE\n";
}
else
{
file << "notification.posH=pos_right\n";
file << "notification.pos_h=RIGHT\n";
}
file << "notification.sound=" + boolToString(options.notification.sound) + "\n";
@@ -236,12 +236,12 @@ bool saveOptionsFile(std::string filePath)
file << "audio.sound.volume=" + std::to_string(options.audio.sound.volume) + "\n";
// Opciones del juego
const auto valueDifficultyEasy = std::to_string(static_cast<int>(GameDifficulty::EASY));
const auto valueDifficultyNormal = std::to_string(static_cast<int>(GameDifficulty::NORMAL));
const auto valueDifficultyHard = std::to_string(static_cast<int>(GameDifficulty::HARD));
const auto value_difficulty_easy = std::to_string(static_cast<int>(GameDifficulty::EASY));
const auto value_difficulty_normal = std::to_string(static_cast<int>(GameDifficulty::NORMAL));
const auto value_difficulty_hard = std::to_string(static_cast<int>(GameDifficulty::HARD));
file << "\n\n## GAME\n";
file << "## game.language [0: spanish, 1: valencian, 2: english]\n";
file << "## game.difficulty [" << valueDifficultyEasy << ": easy, " << valueDifficultyNormal << ": normal, " << valueDifficultyHard << ": hard]\n";
file << "## game.difficulty [" << value_difficulty_easy << ": easy, " << value_difficulty_normal << ": normal, " << value_difficulty_hard << ": hard]\n";
file << "\n";
file << "game.language=" + std::to_string(options.game.language) + "\n";
@@ -257,7 +257,7 @@ bool saveOptionsFile(std::string filePath)
{
const std::string joyIndex = std::to_string(index + 1);
file << "controller" + joyIndex + ".name=" + options.controller[index].name + "\n";
file << "controller" + joyIndex + ".player=" + std::to_string(options.controller[index].playerId) + "\n";
file << "controller" + joyIndex + ".player=" + std::to_string(options.controller[index].player_id) + "\n";
file << "controller" + joyIndex + ".button.fire_left=" + std::to_string((int)options.controller[index].buttons[0]) + "\n";
file << "controller" + joyIndex + ".button.fire_center=" + std::to_string((int)options.controller[index].buttons[1]) + "\n";
file << "controller" + joyIndex + ".button.fire_right=" + std::to_string((int)options.controller[index].buttons[2]) + "\n";
@@ -309,31 +309,31 @@ bool setOptions(std::string var, std::string value)
options.video.shaders = stringToBool(value);
}
else if (var == "video.vSync")
else if (var == "video.v_sync")
{
options.video.vSync = stringToBool(value);
options.video.v_sync = stringToBool(value);
}
// Opciones de notificaciones
else if (var == "notification.posH")
else if (var == "notification.pos_h")
{
if (value == "pos_left")
if (value == "LEFT")
{
options.notification.posH = pos_left;
options.notification.pos_h = NotifyPosition::LEFT;
}
else if (value == "pos_middle")
else if (value == "MIDDLE")
{
options.notification.posH = pos_middle;
options.notification.pos_h = NotifyPosition::MIDDLE;
}
else
{
options.notification.posH = pos_right;
options.notification.pos_h = NotifyPosition::RIGHT;
}
}
else if (var == "notification.posV")
else if (var == "notification.pos_v")
{
options.notification.posV = value == "pos_top" ? pos_top : pos_bottom;
options.notification.pos_v = value == "TOP" ? NotifyPosition::TOP : NotifyPosition::BOTTOM;
}
else if (var == "notification.sound")
@@ -386,7 +386,7 @@ bool setOptions(std::string var, std::string value)
else if (var == "controller1.player")
{
options.controller[0].playerId = std::max(1, std::min(2, std::stoi(value)));
options.controller[0].player_id = std::max(1, std::min(2, std::stoi(value)));
}
else if (var == "controller1.button.fire_left")
@@ -421,7 +421,7 @@ bool setOptions(std::string var, std::string value)
else if (var == "controller2.player")
{
options.controller[1].playerId = std::max(1, std::min(2, std::stoi(value)));
options.controller[1].player_id = std::max(1, std::min(2, std::stoi(value)));
}
else if (var == "controller2.button.fire_left")