Cambiado el tamaño del borde de porcentaje a valor absoluto en pixeles

This commit is contained in:
2022-11-29 18:45:25 +01:00
parent 4a430c0d5b
commit c59739c7ba
4 changed files with 27 additions and 16 deletions

View File

@@ -16,8 +16,8 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
gameCanvasWidth = options->gameWidth; gameCanvasWidth = options->gameWidth;
gameCanvasHeight = options->gameHeight; gameCanvasHeight = options->gameHeight;
borderWidth = options->gameWidth * options->borderSize; borderWidth = options->borderWidth * 2;
borderHeight = options->gameHeight * options->borderSize; borderHeight = options->borderHeight * 2;
notificationLogicalWidth = gameCanvasWidth; notificationLogicalWidth = gameCanvasWidth;
notificationLogicalHeight = gameCanvasHeight; notificationLogicalHeight = gameCanvasHeight;
@@ -203,9 +203,15 @@ void Screen::setBlendMode(SDL_BlendMode blendMode)
} }
// Establece el tamaño del borde // Establece el tamaño del borde
void Screen::setBorderSize(float s) void Screen::setBorderWidth(int s)
{ {
options->borderSize = s; options->borderWidth = s;
}
// Establece el tamaño del borde
void Screen::setBorderHeight(int s)
{
options->borderHeight = s;
} }
// Establece si se ha de ver el borde en el modo ventana // Establece si se ha de ver el borde en el modo ventana

View File

@@ -101,7 +101,8 @@ public:
void setBlendMode(SDL_BlendMode blendMode); void setBlendMode(SDL_BlendMode blendMode);
// Establece el tamaño del borde // Establece el tamaño del borde
void setBorderSize(float s); void setBorderWidth(int s);
void setBorderHeight(int s);
// Establece si se ha de ver el borde en el modo ventana // Establece si se ha de ver el borde en el modo ventana
void setBorderEnabled(bool value); void setBorderEnabled(bool value);

View File

@@ -136,7 +136,8 @@ struct options_t
bool integerScale; // Indica si el escalado de la imagen ha de ser entero en el modo a pantalla completa bool integerScale; // Indica si el escalado de la imagen ha de ser entero en el modo a pantalla completa
bool keepAspect; // Indica si se ha de mantener la relación de aspecto al poner el modo a pantalla completa bool keepAspect; // Indica si se ha de mantener la relación de aspecto al poner el modo a pantalla completa
bool borderEnabled; // Indica si ha de mostrar el borde en el modo de ventana bool borderEnabled; // Indica si ha de mostrar el borde en el modo de ventana
float borderSize; // Porcentaje de borde que se añade a lo ventana int borderWidth; // Cantidad de pixels que se añade en el borde de la ventana
int borderHeight; // Cantidad de pixels que se añade en el borde de la ventana
palette_e palette; // Paleta de colores a usar en el juego palette_e palette; // Paleta de colores a usar en el juego
bool console; // Indica si ha de mostrar información por la consola de texto bool console; // Indica si ha de mostrar información por la consola de texto
cheat_t cheat; // Contiene trucos y ventajas para el juego cheat_t cheat; // Contiene trucos y ventajas para el juego

View File

@@ -125,7 +125,8 @@ void Director::initOptions()
options->integerScale = true; options->integerScale = true;
options->keepAspect = true; options->keepAspect = true;
options->borderEnabled = true; options->borderEnabled = true;
options->borderSize = 0.2f; options->borderWidth = 32;
options->borderHeight = 24;
options->palette = p_zxspectrum; options->palette = p_zxspectrum;
// Estos valores no se guardan en el fichero de configuraci´ón // Estos valores no se guardan en el fichero de configuraci´ón
@@ -358,7 +359,8 @@ bool Director::saveConfig()
file << "integerScale=" + boolToString(options->integerScale) + "\n"; file << "integerScale=" + boolToString(options->integerScale) + "\n";
file << "keepAspect=" + boolToString(options->keepAspect) + "\n"; file << "keepAspect=" + boolToString(options->keepAspect) + "\n";
file << "borderEnabled=" + boolToString(options->borderEnabled) + "\n"; file << "borderEnabled=" + boolToString(options->borderEnabled) + "\n";
file << "borderSize=" + std::to_string(options->borderSize) + "\n"; file << "borderWidth=" + std::to_string(options->borderWidth) + "\n";
file << "borderHeight=" + std::to_string(options->borderHeight) + "\n";
file << "palette=" + std::to_string(options->palette) + "\n"; file << "palette=" + std::to_string(options->palette) + "\n";
file << "\n## ONLINE OPTIONS\n"; file << "\n## ONLINE OPTIONS\n";
@@ -1097,13 +1099,14 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
options->borderEnabled = stringToBool(value); options->borderEnabled = stringToBool(value);
} }
else if (var == "borderSize") else if (var == "borderWidth")
{ {
options->borderSize = std::stof(value); options->borderWidth = std::stoi(value);
if (options->borderSize < 0.0f || options->borderSize > 0.5f)
{
options->borderSize = 0.1f;
} }
else if (var == "borderHeight")
{
options->borderHeight = std::stoi(value);
} }
else if (var == "palette") else if (var == "palette")
@@ -1278,8 +1281,8 @@ bool Director::initSDL()
int incH = 0; int incH = 0;
if (options->borderEnabled) if (options->borderEnabled)
{ {
incW = options->gameWidth * options->borderSize; incW = options->borderWidth * 2;
incH = options->gameHeight * options->borderSize; 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); 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);