options: canviat size per zoom i v_sync per vsync
options: moguda la opció de window a la seua seccio
This commit is contained in:
@@ -119,18 +119,18 @@ void Screen::toggleFullscreen() {
|
||||
|
||||
// Cambia el tamaño de la ventana
|
||||
void Screen::setWindowZoom(int zoom) {
|
||||
Options::window.size = zoom;
|
||||
Options::window.zoom = zoom;
|
||||
adjustWindowSize();
|
||||
}
|
||||
|
||||
// Reduce el tamaño de la ventana
|
||||
auto Screen::decWindowSize() -> bool {
|
||||
if (!Options::video.fullscreen) {
|
||||
const int PREVIOUS_ZOOM = Options::window.size;
|
||||
--Options::window.size;
|
||||
Options::window.size = std::max(Options::window.size, 1);
|
||||
const int PREVIOUS_ZOOM = Options::window.zoom;
|
||||
--Options::window.zoom;
|
||||
Options::window.zoom = std::max(Options::window.zoom, 1);
|
||||
|
||||
if (Options::window.size != PREVIOUS_ZOOM) {
|
||||
if (Options::window.zoom != PREVIOUS_ZOOM) {
|
||||
adjustWindowSize();
|
||||
return true;
|
||||
}
|
||||
@@ -142,11 +142,11 @@ auto Screen::decWindowSize() -> bool {
|
||||
// Aumenta el tamaño de la ventana
|
||||
auto Screen::incWindowSize() -> bool {
|
||||
if (!Options::video.fullscreen) {
|
||||
const int PREVIOUS_ZOOM = Options::window.size;
|
||||
++Options::window.size;
|
||||
Options::window.size = std::min(Options::window.size, Options::window.max_size);
|
||||
const int PREVIOUS_ZOOM = Options::window.zoom;
|
||||
++Options::window.zoom;
|
||||
Options::window.zoom = std::min(Options::window.zoom, Options::window.max_zoom);
|
||||
|
||||
if (Options::window.size != PREVIOUS_ZOOM) {
|
||||
if (Options::window.zoom != PREVIOUS_ZOOM) {
|
||||
adjustWindowSize();
|
||||
return true;
|
||||
}
|
||||
@@ -241,8 +241,8 @@ void Screen::initShaders() {
|
||||
void Screen::adjustWindowSize() {
|
||||
if (!Options::video.fullscreen) {
|
||||
// Establece el nuevo tamaño
|
||||
const int WIDTH = param.game.width * Options::window.size;
|
||||
const int HEIGHT = param.game.height * Options::window.size;
|
||||
const int WIDTH = param.game.width * Options::window.zoom;
|
||||
const int HEIGHT = param.game.height * Options::window.zoom;
|
||||
|
||||
int old_width;
|
||||
int old_height;
|
||||
@@ -307,8 +307,8 @@ auto Screen::initSDLVideo() -> bool {
|
||||
}
|
||||
window_ = SDL_CreateWindow(
|
||||
Options::window.caption.c_str(),
|
||||
param.game.width * Options::window.size,
|
||||
param.game.height * Options::window.size,
|
||||
param.game.width * Options::window.zoom,
|
||||
param.game.height * Options::window.zoom,
|
||||
window_flags);
|
||||
|
||||
if (window_ == nullptr) {
|
||||
@@ -335,7 +335,7 @@ auto Screen::initSDLVideo() -> bool {
|
||||
SDL_SetRenderDrawColor(renderer_, 0x00, 0x00, 0x00, 0xFF);
|
||||
SDL_SetRenderLogicalPresentation(renderer_, param.game.width, param.game.height, Options::video.integer_scale ? SDL_LOGICAL_PRESENTATION_INTEGER_SCALE : SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
||||
SDL_SetRenderDrawBlendMode(renderer_, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetRenderVSync(renderer_, Options::video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||
SDL_SetRenderVSync(renderer_, Options::video.vsync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** Video system initialized successfully");
|
||||
return true;
|
||||
@@ -357,13 +357,13 @@ void Screen::getDisplayInfo() {
|
||||
const auto *dm = SDL_GetCurrentDisplayMode(displays[0]);
|
||||
|
||||
// Calcula el máximo factor de zoom que se puede aplicar a la pantalla
|
||||
Options::window.max_size = std::min(dm->w / param.game.width, dm->h / param.game.height);
|
||||
Options::window.size = std::min(Options::window.size, Options::window.max_size);
|
||||
Options::window.max_zoom = std::min(dm->w / param.game.width, dm->h / param.game.height);
|
||||
Options::window.zoom = std::min(Options::window.zoom, Options::window.max_zoom);
|
||||
|
||||
// Muestra información sobre el tamaño de la pantalla y de la ventana de juego
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Current display mode: %dx%d @ %dHz", static_cast<int>(dm->w), static_cast<int>(dm->h), static_cast<int>(dm->refresh_rate));
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Window resolution: %dx%d x%d", static_cast<int>(param.game.width), static_cast<int>(param.game.height), Options::window.size);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Window resolution: %dx%d x%d", static_cast<int>(param.game.width), static_cast<int>(param.game.height), Options::window.zoom);
|
||||
|
||||
Options::video.info = std::to_string(static_cast<int>(dm->w)) + "x" +
|
||||
std::to_string(static_cast<int>(dm->h)) + " @ " +
|
||||
@@ -373,7 +373,7 @@ void Screen::getDisplayInfo() {
|
||||
const int MAX_ZOOM = std::min(dm->w / param.game.width, (dm->h - WINDOWS_DECORATIONS) / param.game.height);
|
||||
|
||||
// Normaliza los valores de zoom
|
||||
Options::window.size = std::min(Options::window.size, MAX_ZOOM);
|
||||
Options::window.zoom = std::min(Options::window.zoom, MAX_ZOOM);
|
||||
|
||||
SDL_free(displays);
|
||||
}
|
||||
@@ -393,13 +393,13 @@ void Screen::toggleIntegerScale() {
|
||||
|
||||
// Alterna entre activar y desactivar el V-Sync
|
||||
void Screen::toggleVSync() {
|
||||
Options::video.v_sync = !Options::video.v_sync;
|
||||
SDL_SetRenderVSync(renderer_, Options::video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||
Options::video.vsync = !Options::video.vsync;
|
||||
SDL_SetRenderVSync(renderer_, Options::video.vsync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||
}
|
||||
|
||||
// Establece el estado del V-Sync
|
||||
void Screen::setVSync(bool enabled) {
|
||||
Options::video.v_sync = enabled;
|
||||
Options::video.vsync = enabled;
|
||||
SDL_SetRenderVSync(renderer_, enabled ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ void Screen::getSingletons() {
|
||||
|
||||
// Aplica los valores de las opciones
|
||||
void Screen::applySettings() {
|
||||
SDL_SetRenderVSync(renderer_, Options::video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||
SDL_SetRenderVSync(renderer_, Options::video.vsync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||
SDL_SetRenderLogicalPresentation(Screen::get()->getRenderer(), param.game.width, param.game.height, Options::video.integer_scale ? SDL_LOGICAL_PRESENTATION_INTEGER_SCALE : SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
||||
setFullscreenMode();
|
||||
adjustWindowSize();
|
||||
|
||||
Reference in New Issue
Block a user