forked from jaildesigner-jailgames/jaildoctors_dilemma
commit de moure a un Linux a gastar eines de home
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
#include "options.h"
|
||||
#include "const.h"
|
||||
#include "defines.h"
|
||||
#include "screen.h"
|
||||
#include <fstream> // Para basic_ofstream, basic_ifstream
|
||||
#include <iostream> // Para basic_ostream, operator<<, cout
|
||||
#include <fstream> // Para basic_ofstream, basic_ifstream
|
||||
#include <iostream> // Para basic_ostream, operator<<, cout
|
||||
#include <unordered_map> // Para unordered_map
|
||||
#include <functional> // Para std::function
|
||||
#include <functional> // Para std::function
|
||||
|
||||
// Variables
|
||||
Options options;
|
||||
@@ -149,24 +149,37 @@ bool saveOptionsToFile(const std::string &file_path)
|
||||
}
|
||||
|
||||
// Establece las opciones
|
||||
bool setOptions(const std::string &var, const std::string &value) {
|
||||
bool setOptions(const std::string &var, const std::string &value)
|
||||
{
|
||||
static const std::unordered_map<std::string, std::function<void(std::string)>> optionHandlers = {
|
||||
{"version", [](std::string v) { options.version = v; }},
|
||||
{"keys", [](std::string v) { options.keys = static_cast<ControlScheme>(safeStoi(v, static_cast<int>(ControlScheme::CURSOR))); }},
|
||||
{"video.mode", [](std::string v) { options.video.mode = safeStoi(v, 0); }},
|
||||
{"window.zoom", [](std::string v) { options.window.zoom = safeStoi(v, 1); }},
|
||||
{"video.shaders", [](std::string v) { options.video.shaders = stringToBool(v); }},
|
||||
{"video.vertical_sync", [](std::string v) { options.video.vertical_sync = stringToBool(v); }},
|
||||
{"video.integer_scale", [](std::string v) { options.video.integer_scale = stringToBool(v); }},
|
||||
{"video.keep_aspect", [](std::string v) { options.video.keep_aspect = stringToBool(v); }},
|
||||
{"video.border.enabled", [](std::string v) { options.video.border.enabled = stringToBool(v); }},
|
||||
{"video.border.width", [](std::string v) { options.video.border.width = safeStoi(v, 32); }},
|
||||
{"video.border.height", [](std::string v) { options.video.border.height = safeStoi(v, 24); }},
|
||||
{"video.palette", [](std::string v) { options.video.palette = static_cast<Palette>(safeStoi(v, static_cast<int>(DEFAULT_PALETTE))); }}
|
||||
};
|
||||
|
||||
{"version", [](std::string v)
|
||||
{ options.version = v; }},
|
||||
{"keys", [](std::string v)
|
||||
{ options.keys = static_cast<ControlScheme>(safeStoi(v, static_cast<int>(ControlScheme::CURSOR))); }},
|
||||
{"video.mode", [](std::string v)
|
||||
{ options.video.mode = safeStoi(v, 0); }},
|
||||
{"window.zoom", [](std::string v)
|
||||
{ options.window.zoom = safeStoi(v, 1); }},
|
||||
{"video.shaders", [](std::string v)
|
||||
{ options.video.shaders = stringToBool(v); }},
|
||||
{"video.vertical_sync", [](std::string v)
|
||||
{ options.video.vertical_sync = stringToBool(v); }},
|
||||
{"video.integer_scale", [](std::string v)
|
||||
{ options.video.integer_scale = stringToBool(v); }},
|
||||
{"video.keep_aspect", [](std::string v)
|
||||
{ options.video.keep_aspect = stringToBool(v); }},
|
||||
{"video.border.enabled", [](std::string v)
|
||||
{ options.video.border.enabled = stringToBool(v); }},
|
||||
{"video.border.width", [](std::string v)
|
||||
{ options.video.border.width = safeStoi(v, 32); }},
|
||||
{"video.border.height", [](std::string v)
|
||||
{ options.video.border.height = safeStoi(v, 24); }},
|
||||
{"video.palette", [](std::string v)
|
||||
{ options.video.palette = static_cast<Palette>(safeStoi(v, static_cast<int>(DEFAULT_PALETTE))); }}};
|
||||
|
||||
auto it = optionHandlers.find(var);
|
||||
if (it != optionHandlers.end()) {
|
||||
if (it != optionHandlers.end())
|
||||
{
|
||||
it->second(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user