Añadidos modos en pantalla completa para el escalado entero y mantener la relación de aspecto

This commit is contained in:
2021-09-15 11:48:57 +02:00
parent 3f165be114
commit 454791fe96
5 changed files with 99 additions and 62 deletions

View File

@@ -51,15 +51,16 @@ Director::Director(std::string path)
// Crea el objeto para dibujar en pantalla (Requiere initSDL)
mScreen = new Screen(mWindow, mRenderer, mOptions);
// Inicializa JailAudio
initJailAudio();
// Aplica las opciones
SDL_SetWindowFullscreen(mWindow, mOptions->fullScreenMode);
//SDL_SetWindowFullscreen(mWindow, mOptions->fullScreenMode);
//SDL_SetWindowSize(mWindow, REAL_SCREEN_WIDTH * mOptions->windowSize, REAL_SCREEN_HEIGHT * mOptions->windowSize);
mLang->setLang(mOptions->language);
#ifdef __MIPSEL__
DIR *dir = opendir("/media/data/local/home/.coffee_crisis");
if (dir)
@@ -165,7 +166,7 @@ bool Director::initSDL()
// Inicia el generador de numeros aleatorios
std::srand(static_cast<unsigned int>(SDL_GetTicks()));
// Establece el filtro de la textura a nearest
// Establece el filtro de la textura
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(mOptions->filter).c_str()))
{
printf("Warning: Nearest texture filtering not enabled!\n");
@@ -368,9 +369,10 @@ bool Director::loadConfigFile()
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
mOptions->filter = FILTER_NEAREST;
mOptions->vSync = true;
mOptions->screenWidth = 2560/4;
mOptions->screenHeight = 1600/4;
mOptions->integerScale = false;
mOptions->screenWidth = SCREEN_WIDTH;
mOptions->screenHeight = SCREEN_HEIGHT;
mOptions->integerScale = true;
mOptions->keepAspect = true;
// Indicador de éxito en la carga
bool success = true;
@@ -402,6 +404,7 @@ bool Director::loadConfigFile()
SDL_RWwrite(file, &mOptions->screenWidth, sizeof(mOptions->screenWidth), 1);
SDL_RWwrite(file, &mOptions->screenHeight, sizeof(mOptions->screenHeight), 1);
SDL_RWwrite(file, &mOptions->integerScale, sizeof(mOptions->integerScale), 1);
SDL_RWwrite(file, &mOptions->keepAspect, sizeof(mOptions->keepAspect), 1);
// Cierra el fichero
SDL_RWclose(file);
@@ -428,6 +431,7 @@ bool Director::loadConfigFile()
SDL_RWread(file, &mOptions->screenWidth, sizeof(mOptions->screenWidth), 1);
SDL_RWread(file, &mOptions->screenHeight, sizeof(mOptions->screenHeight), 1);
SDL_RWread(file, &mOptions->integerScale, sizeof(mOptions->integerScale), 1);
SDL_RWread(file, &mOptions->keepAspect, sizeof(mOptions->keepAspect), 1);
// Normaliza los valores
if (!((mOptions->fullScreenMode == 0) ||
@@ -467,6 +471,7 @@ bool Director::saveConfigFile()
SDL_RWwrite(file, &mOptions->screenWidth, sizeof(mOptions->screenWidth), 1);
SDL_RWwrite(file, &mOptions->screenHeight, sizeof(mOptions->screenHeight), 1);
SDL_RWwrite(file, &mOptions->integerScale, sizeof(mOptions->integerScale), 1);
SDL_RWwrite(file, &mOptions->keepAspect, sizeof(mOptions->keepAspect), 1);
printf("Writing file %s\n", filename.c_str());