Canviades certes opcions a parametres i afegides noves opcions
This commit is contained in:
@@ -28,14 +28,9 @@ void initOptions()
|
||||
#endif
|
||||
options.video.filter = ScreenFilter::NEAREST;
|
||||
options.video.v_sync = true;
|
||||
options.video.integer_scale = true;
|
||||
options.video.shaders = true;
|
||||
|
||||
// Opciones de las notificaciones
|
||||
options.notification.pos_v = NotifyPosition::TOP;
|
||||
options.notification.pos_h = NotifyPosition::LEFT;
|
||||
options.notification.sound = false;
|
||||
options.notification.color = (Color){48, 48, 48};
|
||||
|
||||
// Opciones de audio
|
||||
options.audio.music.enabled = true;
|
||||
options.audio.music.volume = 128;
|
||||
@@ -51,8 +46,8 @@ void initOptions()
|
||||
options.controller.clear();
|
||||
OptionsController c;
|
||||
|
||||
constexpr int numPlayers = 2;
|
||||
for (int index = 0; index < numPlayers; ++index)
|
||||
constexpr int num_players = 2;
|
||||
for (int index = 0; index < num_players; ++index)
|
||||
{
|
||||
c.index = index;
|
||||
c.player_id = index + 1;
|
||||
@@ -91,7 +86,7 @@ bool loadOptionsFile(std::string file_path)
|
||||
bool success = true;
|
||||
|
||||
// Variables para manejar el fichero
|
||||
const std::string fileName = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
const std::string file_name = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
std::ifstream file(file_path);
|
||||
|
||||
// Si el fichero se puede abrir
|
||||
@@ -99,7 +94,7 @@ bool loadOptionsFile(std::string file_path)
|
||||
{
|
||||
// Procesa el fichero linea a linea
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Reading file: " << fileName << std::endl;
|
||||
std::cout << "Reading file: " << file_name << std::endl;
|
||||
#endif
|
||||
std::string line;
|
||||
while (std::getline(file, line))
|
||||
@@ -113,7 +108,7 @@ bool loadOptionsFile(std::string file_path)
|
||||
if (!setOptions(line.substr(0, pos), line.substr(pos + 1, line.length())))
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Warning: file " << fileName << std::endl;
|
||||
std::cout << "Warning: file " << file_name << std::endl;
|
||||
std::cout << "Unknown parameter " << line.substr(0, pos).c_str() << std::endl;
|
||||
#endif
|
||||
success = false;
|
||||
@@ -155,19 +150,19 @@ bool loadOptionsFile(std::string file_path)
|
||||
// Guarda el fichero de configuración
|
||||
bool saveOptionsFile(std::string file_path)
|
||||
{
|
||||
const std::string fileName = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
const std::string file_name = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
std::ofstream file(file_path);
|
||||
|
||||
if (!file.good())
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
std::cout << fileName << " can't be opened" << std::endl;
|
||||
std::cout << file_name << " can't be opened" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Writing file: " << fileName << std::endl;
|
||||
std::cout << "Writing file: " << file_name << std::endl;
|
||||
#endif
|
||||
|
||||
// Opciones de video
|
||||
@@ -189,41 +184,9 @@ bool saveOptionsFile(std::string file_path)
|
||||
const auto valueFilter = std::to_string(static_cast<int>(options.video.filter));
|
||||
file << "video.filter=" << valueFilter << "\n";
|
||||
|
||||
file << "video.shaders=" + boolToString(options.video.shaders) + "\n";
|
||||
file << "video.v_sync=" + boolToString(options.video.v_sync) + "\n";
|
||||
|
||||
// Opciones de notificaciones
|
||||
file << "\n\n## NOTIFICATION\n";
|
||||
file << "## notification.pos_v [TOP | BOTTOM]\n";
|
||||
file << "## notification.pos_h [LEFT | MIDDLE | RIGHT]\n";
|
||||
file << "\n";
|
||||
|
||||
if (options.notification.pos_v == NotifyPosition::TOP)
|
||||
{
|
||||
file << "notification.pos_v=TOP\n";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
file << "notification.pos_v=BOTTOM\n";
|
||||
}
|
||||
|
||||
if (options.notification.pos_h == NotifyPosition::LEFT)
|
||||
{
|
||||
file << "notification.pos_h=LEFT\n";
|
||||
}
|
||||
|
||||
else if (options.notification.pos_h == NotifyPosition::MIDDLE)
|
||||
{
|
||||
file << "notification.posH=MIDDLE\n";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
file << "notification.pos_h=RIGHT\n";
|
||||
}
|
||||
|
||||
file << "notification.sound=" + boolToString(options.notification.sound) + "\n";
|
||||
file << "video.integer_scale=" + boolToString(options.video.integer_scale) + "\n";
|
||||
file << "video.shaders=" + boolToString(options.video.shaders) + "\n";
|
||||
|
||||
// Opciones de audio
|
||||
file << "\n\n## AUDIO\n";
|
||||
@@ -252,8 +215,8 @@ bool saveOptionsFile(std::string file_path)
|
||||
file << "\n\n## CONTROLLERS\n";
|
||||
file << "\n";
|
||||
|
||||
const int numPlayers = 2;
|
||||
for (int index = 0; index < numPlayers; ++index)
|
||||
const int num_players = 2;
|
||||
for (int index = 0; index < num_players; ++index)
|
||||
{
|
||||
const std::string joyIndex = std::to_string(index + 1);
|
||||
file << "controller" + joyIndex + ".name=" + options.controller[index].name + "\n";
|
||||
@@ -264,7 +227,7 @@ bool saveOptionsFile(std::string file_path)
|
||||
file << "controller" + joyIndex + ".button.start=" + std::to_string((int)options.controller[index].buttons[3]) + "\n";
|
||||
file << "controller" + joyIndex + ".button.service=" + std::to_string((int)options.controller[index].buttons[4]) + "\n";
|
||||
|
||||
if (index < numPlayers - 1)
|
||||
if (index < num_players - 1)
|
||||
{
|
||||
file << "\n";
|
||||
}
|
||||
@@ -285,7 +248,6 @@ bool setOptions(std::string var, std::string value)
|
||||
// Opciones de video
|
||||
if (var == "video.mode")
|
||||
{
|
||||
// options.video.mode = value == std::to_string(static_cast<int>(ScreenVideoMode::WINDOW)) ? ScreenVideoMode::WINDOW : ScreenVideoMode::FULLSCREEN;
|
||||
options.video.mode = static_cast<ScreenVideoMode>(std::stoi(value));
|
||||
}
|
||||
|
||||
@@ -300,7 +262,6 @@ bool setOptions(std::string var, std::string value)
|
||||
|
||||
else if (var == "video.filter")
|
||||
{
|
||||
// options.video.filter = value == std::to_string(static_cast<int>(ScreenFilter::NEAREST)) ? ScreenFilter::NEAREST : ScreenFilter::LINEAL;
|
||||
options.video.filter = static_cast<ScreenFilter>(std::stoi(value));
|
||||
}
|
||||
|
||||
@@ -309,38 +270,16 @@ bool setOptions(std::string var, std::string value)
|
||||
options.video.shaders = stringToBool(value);
|
||||
}
|
||||
|
||||
else if (var == "video.integer_scale")
|
||||
{
|
||||
options.video.integer_scale = stringToBool(value);
|
||||
}
|
||||
|
||||
else if (var == "video.v_sync")
|
||||
{
|
||||
options.video.v_sync = stringToBool(value);
|
||||
}
|
||||
|
||||
// Opciones de notificaciones
|
||||
else if (var == "notification.pos_h")
|
||||
{
|
||||
if (value == "LEFT")
|
||||
{
|
||||
options.notification.pos_h = NotifyPosition::LEFT;
|
||||
}
|
||||
else if (value == "MIDDLE")
|
||||
{
|
||||
options.notification.pos_h = NotifyPosition::MIDDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
options.notification.pos_h = NotifyPosition::RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
else if (var == "notification.pos_v")
|
||||
{
|
||||
options.notification.pos_v = value == "TOP" ? NotifyPosition::TOP : NotifyPosition::BOTTOM;
|
||||
}
|
||||
|
||||
else if (var == "notification.sound")
|
||||
{
|
||||
options.notification.sound = stringToBool(value);
|
||||
}
|
||||
|
||||
// Opciones de audio
|
||||
else if (var == "audio.music.enabled")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user