Renombradas las variables de opciones
Actualizado el fichero de configuración
This commit is contained in:
@@ -145,16 +145,22 @@ struct op_audio_t
|
||||
op_sound_t sound; // Opciones para los efectos de sonido
|
||||
};
|
||||
|
||||
// Estructura con todas las opciones de configuración del programa
|
||||
struct options_t
|
||||
// Estructura para las opciones del juego
|
||||
struct op_game_t
|
||||
{
|
||||
Uint8 difficulty; // Dificultad del juego
|
||||
Uint8 playerSelected; // Jugador seleccionado para el modo 1P
|
||||
std::vector<input_t> input; // Modo de control (teclado o mando)
|
||||
Uint8 language; // Idioma usado en el juego
|
||||
bool console; // Indica si ha de mostrar información por la consola de texto
|
||||
op_video_t video; // Opciones relativas a la clase screen
|
||||
op_audio_t audio; // Opciones para el audio
|
||||
};
|
||||
|
||||
// Estructura con todas las opciones de configuración del programa
|
||||
struct options_t
|
||||
{
|
||||
bool console; // Indica si ha de mostrar información por la consola de texto
|
||||
op_game_t game; // Opciones para el propio juego
|
||||
op_video_t video; // Opciones relativas a la clase screen
|
||||
op_audio_t audio; // Opciones para el audio
|
||||
};
|
||||
|
||||
struct param_t
|
||||
|
||||
@@ -56,7 +56,7 @@ Director::Director(int argc, char *argv[])
|
||||
|
||||
// Crea los objetos
|
||||
lang = new Lang(asset);
|
||||
lang->setLang(options->language);
|
||||
lang->setLang(options->game.language);
|
||||
|
||||
input = new Input(asset->get("gamecontrollerdb.txt"));
|
||||
initInput();
|
||||
@@ -397,18 +397,18 @@ void Director::initOptions()
|
||||
options = new options_t;
|
||||
|
||||
// Pone unos valores por defecto para las opciones de control
|
||||
options->input.clear();
|
||||
options->game.input.clear();
|
||||
|
||||
input_t inp;
|
||||
inp.id = 0;
|
||||
inp.name = "KEYBOARD";
|
||||
inp.deviceType = INPUT_USE_KEYBOARD;
|
||||
options->input.push_back(inp);
|
||||
options->game.input.push_back(inp);
|
||||
|
||||
inp.id = 0;
|
||||
inp.name = "GAME CONTROLLER";
|
||||
inp.deviceType = INPUT_USE_GAMECONTROLLER;
|
||||
options->input.push_back(inp);
|
||||
options->game.input.push_back(inp);
|
||||
|
||||
// Opciones de video
|
||||
options->video.mode = 0;
|
||||
@@ -431,9 +431,9 @@ void Director::initOptions()
|
||||
options->audio.sound.volume = 64;
|
||||
|
||||
// Opciones varios
|
||||
options->playerSelected = 0;
|
||||
options->difficulty = DIFFICULTY_NORMAL;
|
||||
options->language = ba_BA;
|
||||
options->game.playerSelected = 0;
|
||||
options->game.difficulty = DIFFICULTY_NORMAL;
|
||||
options->game.language = ba_BA;
|
||||
options->console = false;
|
||||
}
|
||||
|
||||
@@ -569,9 +569,9 @@ bool Director::loadConfigFile()
|
||||
options->video.window.size = 3;
|
||||
}
|
||||
|
||||
if (options->language < 0 || options->language > MAX_LANGUAGES)
|
||||
if (options->game.language < 0 || options->game.language > MAX_LANGUAGES)
|
||||
{
|
||||
options->language = en_UK;
|
||||
options->game.language = en_UK;
|
||||
}
|
||||
|
||||
return success;
|
||||
@@ -602,55 +602,55 @@ bool Director::saveConfigFile()
|
||||
|
||||
// Opciones de video
|
||||
file << "## VIDEO\n";
|
||||
file << "## video mode can be: 0, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP\n";
|
||||
file << "## video.mode [0, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP]\n";
|
||||
file << "## video.filter [FILTER_NEAREST, FILTER_LINEAL]\n";
|
||||
file << "\n";
|
||||
|
||||
if (options->video.mode == 0)
|
||||
{
|
||||
file << "mode=0\n";
|
||||
file << "video.mode=0\n";
|
||||
}
|
||||
|
||||
else if (options->video.mode == SDL_WINDOW_FULLSCREEN)
|
||||
{
|
||||
file << "mode=SDL_WINDOW_FULLSCREEN\n";
|
||||
file << "video.mode=SDL_WINDOW_FULLSCREEN\n";
|
||||
}
|
||||
|
||||
else if (options->video.mode == SDL_WINDOW_FULLSCREEN_DESKTOP)
|
||||
{
|
||||
file << "mode=SDL_WINDOW_FULLSCREEN_DESKTOP\n";
|
||||
file << "video.mode=SDL_WINDOW_FULLSCREEN_DESKTOP\n";
|
||||
}
|
||||
|
||||
file << "window.size=" + std::to_string(options->video.window.size) + "\n";
|
||||
file << "video.window.size=" + std::to_string(options->video.window.size) + "\n";
|
||||
|
||||
file << "## filter can be: FILTER_NEAREST, FILTER_LINEAL\n";
|
||||
if (options->video.filter == FILTER_NEAREST)
|
||||
{
|
||||
file << "filter=FILTER_NEAREST\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
file << "filter=FILTER_LINEAL\n";
|
||||
}
|
||||
options->video.filter == FILTER_NEAREST ? file << "video.filter=FILTER_NEAREST\n" : file << "video.filter=FILTER_LINEAL\n";
|
||||
|
||||
file << "vSync=" + boolToString(options->video.vSync) + "\n";
|
||||
file << "integerScale=" + boolToString(options->video.integerScale) + "\n";
|
||||
file << "keepAspect=" + boolToString(options->video.keepAspect) + "\n";
|
||||
file << "border.enabled=" + boolToString(options->video.border.enabled) + "\n";
|
||||
file << "border.width=" + std::to_string(options->video.border.width) + "\n";
|
||||
file << "border.height=" + std::to_string(options->video.border.height) + "\n";
|
||||
file << "video.shaders=" + boolToString(options->video.shaders) + "\n";
|
||||
file << "video.vSync=" + boolToString(options->video.vSync) + "\n";
|
||||
file << "video.integerScale=" + boolToString(options->video.integerScale) + "\n";
|
||||
file << "video.keepAspect=" + boolToString(options->video.keepAspect) + "\n";
|
||||
file << "video.border.enabled=" + boolToString(options->video.border.enabled) + "\n";
|
||||
file << "video.border.width=" + std::to_string(options->video.border.width) + "\n";
|
||||
file << "video.border.height=" + std::to_string(options->video.border.height) + "\n";
|
||||
|
||||
// Opciones de audio
|
||||
file << "\n## AUDIO\n";
|
||||
file << "music.enabled=" + boolToString(options->audio.music.enabled) + "\n";
|
||||
file << "music.volume=" + std::to_string(options->audio.music.volume) + "\n";
|
||||
file << "sound.enabled=" + boolToString(options->audio.sound.enabled) + "\n";
|
||||
file << "sound.volume=" + std::to_string(options->audio.sound.volume) + "\n";
|
||||
file << "\n\n## AUDIO\n";
|
||||
file << "## volume [0 .. 128]\n";
|
||||
file << "\n";
|
||||
|
||||
file << "audio.music.enabled=" + boolToString(options->audio.music.enabled) + "\n";
|
||||
file << "audio.music.volume=" + std::to_string(options->audio.music.volume) + "\n";
|
||||
file << "audio.sound.enabled=" + boolToString(options->audio.sound.enabled) + "\n";
|
||||
file << "audio.sound.volume=" + std::to_string(options->audio.sound.volume) + "\n";
|
||||
|
||||
// Opciones del juego
|
||||
file << "\n## GAME\n";
|
||||
file << "language=" + std::to_string(options->language) + "\n";
|
||||
file << "difficulty=" + std::to_string(options->difficulty) + "\n";
|
||||
file << "input0=" + std::to_string(options->input[0].deviceType) + "\n";
|
||||
file << "input1=" + std::to_string(options->input[1].deviceType) + "\n";
|
||||
file << "\n\n## GAME\n";
|
||||
file << "\n";
|
||||
|
||||
file << "game.language=" + std::to_string(options->game.language) + "\n";
|
||||
file << "game.difficulty=" + std::to_string(options->game.difficulty) + "\n";
|
||||
file << "game.input0=" + std::to_string(options->game.input[0].deviceType) + "\n";
|
||||
file << "game.input1=" + std::to_string(options->game.input[1].deviceType) + "\n";
|
||||
|
||||
// Cierra el fichero
|
||||
file.close();
|
||||
@@ -760,7 +760,7 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
|
||||
bool success = true;
|
||||
|
||||
// Opciones de video
|
||||
if (var == "mode")
|
||||
if (var == "video.mode")
|
||||
{
|
||||
if (value == "SDL_WINDOW_FULLSCREEN_DESKTOP")
|
||||
{
|
||||
@@ -776,7 +776,7 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
|
||||
}
|
||||
}
|
||||
|
||||
else if (var == "window.size")
|
||||
else if (var == "video.window.size")
|
||||
{
|
||||
options->video.window.size = std::stoi(value);
|
||||
if ((options->video.window.size < 1) || (options->video.window.size > 4))
|
||||
@@ -785,7 +785,7 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
|
||||
}
|
||||
}
|
||||
|
||||
else if (var == "filter")
|
||||
else if (var == "video.filter")
|
||||
{
|
||||
if (value == "FILTER_LINEAL")
|
||||
{
|
||||
@@ -797,81 +797,81 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
|
||||
}
|
||||
}
|
||||
|
||||
else if (var == "vSync")
|
||||
{
|
||||
options->video.vSync = stringToBool(value);
|
||||
}
|
||||
|
||||
else if (var == "integerScale")
|
||||
{
|
||||
options->video.integerScale = stringToBool(value);
|
||||
}
|
||||
|
||||
else if (var == "keepAspect")
|
||||
{
|
||||
options->video.keepAspect = stringToBool(value);
|
||||
}
|
||||
|
||||
else if (var == "border.enabled")
|
||||
{
|
||||
options->video.border.enabled = stringToBool(value);
|
||||
}
|
||||
|
||||
else if (var == "border.width")
|
||||
{
|
||||
options->video.border.width = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "border.height")
|
||||
{
|
||||
options->video.border.height = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "video.shaders")
|
||||
{
|
||||
options->video.shaders = stringToBool(value);
|
||||
}
|
||||
|
||||
else if (var == "video.vSync")
|
||||
{
|
||||
options->video.vSync = stringToBool(value);
|
||||
}
|
||||
|
||||
else if (var == "video.integerScale")
|
||||
{
|
||||
options->video.integerScale = stringToBool(value);
|
||||
}
|
||||
|
||||
else if (var == "video.keepAspect")
|
||||
{
|
||||
options->video.keepAspect = stringToBool(value);
|
||||
}
|
||||
|
||||
else if (var == "video.border.enabled")
|
||||
{
|
||||
options->video.border.enabled = stringToBool(value);
|
||||
}
|
||||
|
||||
else if (var == "video.border.width")
|
||||
{
|
||||
options->video.border.width = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "video.border.height")
|
||||
{
|
||||
options->video.border.height = std::stoi(value);
|
||||
}
|
||||
|
||||
// Opciones de audio
|
||||
else if (var == "music.enabled")
|
||||
else if (var == "audio.music.enabled")
|
||||
{
|
||||
options->audio.music.enabled = stringToBool(value);
|
||||
}
|
||||
|
||||
else if (var == "music.volume")
|
||||
else if (var == "audio.music.volume")
|
||||
{
|
||||
options->audio.music.volume = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "sound.enabled")
|
||||
else if (var == "audio.sound.enabled")
|
||||
{
|
||||
options->audio.sound.enabled = stringToBool(value);
|
||||
}
|
||||
|
||||
else if (var == "sound.volume")
|
||||
else if (var == "audio.sound.volume")
|
||||
{
|
||||
options->audio.sound.volume = std::stoi(value);
|
||||
}
|
||||
|
||||
// Opciones de juego
|
||||
else if (var == "language")
|
||||
else if (var == "game.language")
|
||||
{
|
||||
options->language = std::stoi(value);
|
||||
options->game.language = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "difficulty")
|
||||
else if (var == "game.difficulty")
|
||||
{
|
||||
options->difficulty = std::stoi(value);
|
||||
options->game.difficulty = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "input0")
|
||||
else if (var == "game.input0")
|
||||
{
|
||||
options->input[0].deviceType = std::stoi(value);
|
||||
options->game.input[0].deviceType = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "input1")
|
||||
else if (var == "game.input1")
|
||||
{
|
||||
options->input[1].deviceType = std::stoi(value);
|
||||
options->game.input[1].deviceType = std::stoi(value);
|
||||
}
|
||||
|
||||
// Lineas vacias o que empiezan por comentario
|
||||
|
||||
@@ -20,10 +20,10 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr
|
||||
lastStageReached = currentStage;
|
||||
if (numPlayers == 1)
|
||||
{ // Si solo juega un jugador, permite jugar tanto con teclado como con mando
|
||||
onePlayerControl = options->input[0].deviceType;
|
||||
options->input[0].deviceType = INPUT_USE_ANY;
|
||||
onePlayerControl = options->game.input[0].deviceType;
|
||||
options->game.input[0].deviceType = INPUT_USE_ANY;
|
||||
}
|
||||
difficulty = options->difficulty;
|
||||
difficulty = options->game.difficulty;
|
||||
|
||||
// Crea los objetos
|
||||
fade = new Fade(renderer, param);
|
||||
@@ -62,7 +62,7 @@ Game::~Game()
|
||||
// Restaura el metodo de control
|
||||
if (numPlayers == 1)
|
||||
{
|
||||
options->input[0].deviceType = onePlayerControl;
|
||||
options->game.input[0].deviceType = onePlayerControl;
|
||||
}
|
||||
|
||||
// Elimina todos los objetos contenidos en vectores
|
||||
@@ -182,7 +182,7 @@ void Game::init()
|
||||
// Crea los jugadores
|
||||
if (numPlayers == 1)
|
||||
{
|
||||
Player *player = new Player(PLAY_AREA_CENTER_X - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures[options->playerSelected], playerAnimations);
|
||||
Player *player = new Player(PLAY_AREA_CENTER_X - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures[options->game.playerSelected], playerAnimations);
|
||||
players.push_back(player);
|
||||
}
|
||||
|
||||
@@ -2846,7 +2846,7 @@ void Game::checkGameInput()
|
||||
if (player->isAlive())
|
||||
{
|
||||
// Input a la izquierda
|
||||
if (input->checkInput(input_left, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
||||
if (input->checkInput(input_left, REPEAT_TRUE, options->game.input[i].deviceType, options->game.input[i].id))
|
||||
{
|
||||
player->setInput(input_left);
|
||||
demo.keys.left = 1;
|
||||
@@ -2854,7 +2854,7 @@ void Game::checkGameInput()
|
||||
else
|
||||
{
|
||||
// Input a la derecha
|
||||
if (input->checkInput(input_right, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
||||
if (input->checkInput(input_right, REPEAT_TRUE, options->game.input[i].deviceType, options->game.input[i].id))
|
||||
{
|
||||
player->setInput(input_right);
|
||||
demo.keys.right = 1;
|
||||
@@ -2867,7 +2867,7 @@ void Game::checkGameInput()
|
||||
}
|
||||
}
|
||||
// Comprueba el input de disparar al centro
|
||||
if (input->checkInput(input_fire_center, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
||||
if (input->checkInput(input_fire_center, REPEAT_TRUE, options->game.input[i].deviceType, options->game.input[i].id))
|
||||
{
|
||||
if (player->canFire())
|
||||
{
|
||||
@@ -2883,7 +2883,7 @@ void Game::checkGameInput()
|
||||
}
|
||||
|
||||
// Comprueba el input de disparar a la izquierda
|
||||
if (input->checkInput(input_fire_left, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
||||
if (input->checkInput(input_fire_left, REPEAT_TRUE, options->game.input[i].deviceType, options->game.input[i].id))
|
||||
{
|
||||
if (player->canFire())
|
||||
{
|
||||
@@ -2899,7 +2899,7 @@ void Game::checkGameInput()
|
||||
}
|
||||
|
||||
// Comprueba el input de disparar a la derecha
|
||||
if (input->checkInput(input_fire_right, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
||||
if (input->checkInput(input_fire_right, REPEAT_TRUE, options->game.input[i].deviceType, options->game.input[i].id))
|
||||
{
|
||||
if (player->canFire())
|
||||
{
|
||||
@@ -2915,7 +2915,7 @@ void Game::checkGameInput()
|
||||
}
|
||||
|
||||
// Comprueba el input de pausa
|
||||
if (input->checkInput(input_cancel, REPEAT_FALSE, options->input[i].deviceType, options->input[i].id))
|
||||
if (input->checkInput(input_cancel, REPEAT_FALSE, options->game.input[i].deviceType, options->game.input[i].id))
|
||||
{
|
||||
section->subsection = SUBSECTION_GAME_PAUSE;
|
||||
}
|
||||
|
||||
@@ -79,18 +79,18 @@ void Title::init()
|
||||
demo = true;
|
||||
|
||||
// Pone valores por defecto a las opciones de control
|
||||
options->input.clear();
|
||||
options->game.input.clear();
|
||||
|
||||
input_t i;
|
||||
i.id = 0;
|
||||
i.name = "KEYBOARD";
|
||||
i.deviceType = INPUT_USE_KEYBOARD;
|
||||
options->input.push_back(i);
|
||||
options->game.input.push_back(i);
|
||||
|
||||
i.id = 0;
|
||||
i.name = "GAME CONTROLLER";
|
||||
i.deviceType = INPUT_USE_GAMECONTROLLER;
|
||||
options->input.push_back(i);
|
||||
options->game.input.push_back(i);
|
||||
|
||||
// Comprueba si hay mandos conectados
|
||||
checkInputDevices();
|
||||
@@ -103,9 +103,9 @@ void Title::init()
|
||||
// Si ha encontrado un mando se lo asigna al segundo jugador
|
||||
if (input->gameControllerFound())
|
||||
{
|
||||
options->input[1].id = availableInputDevices[deviceIndex[1]].id;
|
||||
options->input[1].name = availableInputDevices[deviceIndex[1]].name;
|
||||
options->input[1].deviceType = availableInputDevices[deviceIndex[1]].deviceType;
|
||||
options->game.input[1].id = availableInputDevices[deviceIndex[1]].id;
|
||||
options->game.input[1].name = availableInputDevices[deviceIndex[1]].name;
|
||||
options->game.input[1].deviceType = availableInputDevices[deviceIndex[1]].deviceType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,13 +314,13 @@ bool Title::updatePlayerInputs(int numPlayer)
|
||||
deviceIndex[0] = 0;
|
||||
deviceIndex[1] = 0;
|
||||
|
||||
options->input[0].id = -1;
|
||||
options->input[0].name = "KEYBOARD";
|
||||
options->input[0].deviceType = INPUT_USE_KEYBOARD;
|
||||
options->game.input[0].id = -1;
|
||||
options->game.input[0].name = "KEYBOARD";
|
||||
options->game.input[0].deviceType = INPUT_USE_KEYBOARD;
|
||||
|
||||
options->input[1].id = 0;
|
||||
options->input[1].name = "GAME CONTROLLER";
|
||||
options->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
||||
options->game.input[1].id = 0;
|
||||
options->game.input[1].name = "GAME CONTROLLER";
|
||||
options->game.input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -358,8 +358,8 @@ bool Title::updatePlayerInputs(int numPlayer)
|
||||
}
|
||||
|
||||
// Copia el dispositivo marcado por el indice a la variable de opciones de cada jugador
|
||||
options->input[0] = availableInputDevices[deviceIndex[0]];
|
||||
options->input[1] = availableInputDevices[deviceIndex[1]];
|
||||
options->game.input[0] = availableInputDevices[deviceIndex[0]];
|
||||
options->game.input[1] = availableInputDevices[deviceIndex[1]];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user