Actualizando las clases comunes a sus ultimas versiones

This commit is contained in:
2022-12-05 09:13:04 +01:00
parent cdb5040b9d
commit 09a205a288
12 changed files with 506 additions and 275 deletions

View File

@@ -40,7 +40,7 @@ Director::Director(std::string path)
input = new Input(asset->get("controllerdb.txt"));
initInput();
screen = new Screen(window, renderer, asset, options, GAME_WIDTH, GAME_HEIGHT);
screen = new Screen(window, renderer, asset, options);
// Inicializa los servicios online
initOnline();
@@ -123,7 +123,14 @@ bool Director::initSDL()
}
// Crea la ventana
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, options->screenWidth * options->windowSize, options->screenHeight * options->windowSize, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
int incW = 0;
int incH = 0;
if (options->borderEnabled)
{
incW = options->borderWidth * 2;
incH = options->borderHeight * 2;
}
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (options->gameWidth + incW) * options->windowSize, (options->gameHeight + incH) * options->windowSize, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
if (window == nullptr)
{
printf("Window could not be created!\nSDL Error: %s\n", SDL_GetError());
@@ -152,7 +159,7 @@ bool Director::initSDL()
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
// Establece el tamaño del buffer de renderizado
SDL_RenderSetLogicalSize(renderer, options->screenWidth, options->screenHeight);
SDL_RenderSetLogicalSize(renderer, options->gameWidth, options->gameHeight);
// Establece el modo de mezcla
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
@@ -314,18 +321,17 @@ void Director::initOptions()
inp.deviceType = INPUT_USE_GAMECONTROLLER;
options->input.push_back(inp);
options->fullScreenMode = 0;
options->videoMode = 0;
options->windowSize = 3;
options->language = ba_BA;
options->difficulty = DIFFICULTY_NORMAL;
options->playerSelected = 0;
options->filter = FILTER_NEAREST;
options->vSync = true;
options->screenWidth = GAME_WIDTH;
options->screenHeight = GAME_HEIGHT;
options->integerScale = true;
options->keepAspect = true;
options->borderSize = 0.0f;
options->borderWidth = 0;
options->borderHeight = 0;
options->borderEnabled = false;
// Online
@@ -381,12 +387,12 @@ bool Director::loadConfigFile()
}
// Normaliza los valores
const bool a = options->fullScreenMode == 0;
const bool b = options->fullScreenMode == SDL_WINDOW_FULLSCREEN;
const bool c = options->fullScreenMode == SDL_WINDOW_FULLSCREEN_DESKTOP;
const bool a = options->videoMode == 0;
const bool b = options->videoMode == SDL_WINDOW_FULLSCREEN;
const bool c = options->videoMode == SDL_WINDOW_FULLSCREEN_DESKTOP;
if (!(a || b || c))
{
options->fullScreenMode = 0;
options->videoMode = 0;
}
if (options->windowSize < 1 || options->windowSize > 4)
@@ -412,17 +418,17 @@ bool Director::saveConfigFile()
// Escribe en el fichero
file << "## VISUAL OPTIONS\n";
if (options->fullScreenMode == 0)
if (options->videoMode == 0)
{
file << "fullScreenMode=0\n";
}
else if (options->fullScreenMode == SDL_WINDOW_FULLSCREEN)
else if (options->videoMode == SDL_WINDOW_FULLSCREEN)
{
file << "fullScreenMode=SDL_WINDOW_FULLSCREEN\n";
}
else if (options->fullScreenMode == SDL_WINDOW_FULLSCREEN_DESKTOP)
else if (options->videoMode == SDL_WINDOW_FULLSCREEN_DESKTOP)
{
file << "fullScreenMode=SDL_WINDOW_FULLSCREEN_DESKTOP\n";
}
@@ -442,9 +448,8 @@ bool Director::saveConfigFile()
file << "integerScale=" + boolToString(options->integerScale) + "\n";
file << "keepAspect=" + boolToString(options->keepAspect) + "\n";
file << "borderEnabled=" + boolToString(options->borderEnabled) + "\n";
file << "borderSize=" + std::to_string(options->borderSize) + "\n";
file << "screenWidth=" + std::to_string(options->screenWidth) + "\n";
file << "screenHeight=" + std::to_string(options->screenHeight) + "\n";
file << "borderWidth=" + std::to_string(options->borderWidth) + "\n";
file << "borderHeight=" + std::to_string(options->borderHeight) + "\n";
file << "\n## OTHER OPTIONS\n";
file << "language=" + std::to_string(options->language) + "\n";
@@ -536,7 +541,7 @@ void Director::initOnline()
// Obten el Jailer ID
if (options->online.jailerID == "")
{ // Jailer ID no definido
screen->showText("No ha especificado ningun Jailer ID");
screen->showNotification("No ha especificado ningun Jailer ID");
std::cout << "No ha especificado ningun Jailer ID" << std::endl;
}
else
@@ -548,16 +553,16 @@ void Director::initOnline()
// Obtiene la información online
if (jscore::initOnlineScore(options->online.gameID))
{
screen->showText(options->online.jailerID + " ha iniciado sesion");
screen->showNotification(options->online.jailerID + " ha iniciado sesion");
std::cout << options->online.jailerID << " ha iniciado sesion" << std::endl;
}
else
{
screen->showText("Fallo al conectar a " + options->online.server);
screen->showNotification("Fallo al conectar a " + options->online.server);
std::cout << "Fallo al conectar a " << options->online.server << std::endl;
options->online.enabled = false;
options->online.enabled = false;
return;
}
@@ -565,7 +570,7 @@ void Director::initOnline()
const int points = jscore::getUserPoints(options->online.gameID, options->online.jailerID);
if (points == 0)
{ // Fallo de conexión o no hay registros
screen->showText("No se ha podido obtener la puntuacion online");
screen->showNotification("No se ha podido obtener la puntuacion online");
std::cout << "No se ha podido obtener la puntuacion online" << std::endl;
}
else
@@ -581,19 +586,19 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
// Indicador de éxito en la asignación
bool success = true;
if (var == "fullScreenMode")
if (var == "videoMode")
{
if (value == "SDL_WINDOW_FULLSCREEN_DESKTOP")
{
options->fullScreenMode = SDL_WINDOW_FULLSCREEN_DESKTOP;
options->videoMode = SDL_WINDOW_FULLSCREEN_DESKTOP;
}
else if (value == "SDL_WINDOW_FULLSCREEN")
{
options->fullScreenMode = SDL_WINDOW_FULLSCREEN;
options->videoMode = SDL_WINDOW_FULLSCREEN;
}
else
{
options->fullScreenMode = 0;
options->videoMode = 0;
}
}
@@ -638,23 +643,14 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
options->borderEnabled = stringToBool(value);
}
else if (var == "borderSize")
else if (var == "borderWidth")
{
options->borderSize = std::stof(value);
if (options->borderSize < 0.0f || options->borderSize > 0.5f)
{
options->borderSize = 0.1f;
}
options->borderWidth = std::stoi(value);
}
else if (var == "screenWidth")
else if (var == "borderHeight")
{
options->screenWidth = std::stoi(value);
}
else if (var == "screenHeight")
{
options->screenHeight = std::stoi(value);
options->borderHeight = std::stoi(value);
}
else if (var == "language")