options menu completed

This commit is contained in:
2021-08-29 13:35:19 +02:00
parent 697e5d796f
commit 88e5303d28
9 changed files with 167 additions and 73 deletions

View File

@@ -2,6 +2,7 @@
#include "utils.h"
#include "director.h"
#include <iostream>
#include <string>
#ifdef __MIPSEL__
#include <sys/stat.h>
#include <dirent.h>
@@ -31,13 +32,10 @@ Director::Director(std::string path)
mOptions->fullScreenMode = 0;
mOptions->windowSize = 3;
mOptions->language = en_UK;
mOptions->fullScreenMode = 0;
mOptions->windowSize = 3;
mOptions->language = en_UK;
mOptions->difficulty = 0;
mOptions->difficulty = DIFFICULTY_NORMAL;
mOptions->player1Input = INPUT_USE_KEYBOARD;
mOptions->player2Input = INPUT_USE_GAMECONTROLLER;
mOptions->filter = 0;
mOptions->filter = FILTER_NEAREST;
mOptions->vSync = true;
}
@@ -155,7 +153,7 @@ bool Director::initSDL()
else
{
// Establece el filtro de la textura a nearest
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"))
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(mOptions->filter).c_str()))
{
printf("Warning: Nearest texture filtering not enabled!\n");
}
@@ -169,8 +167,12 @@ bool Director::initSDL()
}
else
{
// Crea un renderizador para la ventana con vsync
mRenderer = SDL_CreateRenderer(mWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
// Crea un renderizador para la ventana. El vsync se activa en funcion de las opciones
if (mOptions->vSync)
mRenderer = SDL_CreateRenderer(mWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
else
mRenderer = SDL_CreateRenderer(mWindow, -1, SDL_RENDERER_ACCELERATED);
if (mRenderer == NULL)
{
printf("Renderer could not be created!\nSDL Error: %s\n", SDL_GetError());
@@ -420,7 +422,7 @@ bool Director::loadConfigFile()
mOptions->difficulty = DIFFICULTY_NORMAL;
mOptions->player1Input = INPUT_USE_KEYBOARD;
mOptions->player2Input = INPUT_USE_GAMECONTROLLER;
mOptions->filter = 0;
mOptions->filter = FILTER_NEAREST;
mOptions->vSync = true;
// Indicador de éxito en la carga