Guardado de las opciones de las notificaciones

This commit is contained in:
2022-11-24 12:55:34 +01:00
parent ba19dcb904
commit 3817a01712
5 changed files with 193 additions and 35 deletions

View File

@@ -59,7 +59,7 @@ Director::Director(int argc, char *argv[])
music = JA_LoadMusic(asset->get("title.ogg").c_str());
// Inicializa los servicios online
//initOnline();
// initOnline();
}
Director::~Director()
@@ -147,6 +147,12 @@ void Director::initOptions()
options->online.gameID = "jaildoctors_dilemma";
#endif
options->online.jailerID = "";
// Opciones de las notificaciones
options->notifications.posV = pos_top;
options->notifications.posH = pos_left;
options->notifications.sound = true;
options->notifications.color = {64, 64, 64};
}
// Comprueba los parametros del programa
@@ -346,6 +352,33 @@ bool Director::saveConfig()
file << "port=" + std::to_string(options->online.port) + "\n";
file << "jailerID=" + options->online.jailerID + "\n";
file << "\n## NOTIFICATION OPTIONS\n";
file << "## notifications.posV = pos_top | pos_bottom\n";
if (options->notifications.posV == pos_top)
{
file << "notifications.posV=pos_top\n";
}
else
{
file << "notifications.posV=pos_bottom\n";
}
file << "## notifications.posH = pos_left | pos_middle | pos_right\n";
if (options->notifications.posH == pos_left)
{
file << "notifications.posH=pos_left\n";
}
else if (options->notifications.posH == pos_middle)
{
file << "notifications.posH=pos_middle\n";
}
else
{
file << "notifications.posH=pos_right\n";
}
file << "notifications.sound=" + boolToString(options->notifications.sound) + "\n";
// Cierra el fichero
file.close();
@@ -1081,6 +1114,39 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
options->online.jailerID = value;
}
else if (var == "notifications.posH")
{
if (value == "pos_left")
{
options->notifications.posH = pos_left;
}
else if (value == "pos_middle")
{
options->notifications.posH = pos_middle;
}
else
{
options->notifications.posH = pos_right;
}
}
else if (var == "notifications.posV")
{
if (value == "pos_top")
{
options->notifications.posV = pos_top;
}
else
{
options->notifications.posV = pos_bottom;
}
}
else if (var == "notifications.sound")
{
options->notifications.sound = stringToBool(value);
}
else if (var == "" || var.substr(0, 1) == "#")
{
}