- [FIX] Arreglats els modes fullscreen de consola y kiosk

- [NEW] En kiosk mode se fica en pantalla completa i no deixa canviar-ho
- [FIX] Quan està en pantalla completa, F1 i F2 no cambien el zoom (quan isques estarà com estava abans d'entrar a fullscreen)
This commit is contained in:
2026-03-08 20:06:48 +01:00
parent 942ce2a6ff
commit 2d563a7907
3 changed files with 20 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
#include "config.h" #include "config.h"
#include "jfile.h" #include "jfile.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include "jdraw.h"
namespace config namespace config
{ {
@@ -88,6 +89,7 @@ namespace config
{ {
kiosk_mode = value; kiosk_mode = value;
file::setConfigValue("kiosk", kiosk_mode ? "yes" : "no"); file::setConfigValue("kiosk", kiosk_mode ? "yes" : "no");
draw::reinit();
} }
const bool getKioskMode() const bool getKioskMode()

View File

@@ -2,6 +2,7 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include "gif.h" #include "gif.h"
#include "jfile.h" #include "jfile.h"
#include "config.h"
#include <vector> #include <vector>
namespace draw namespace draw
@@ -24,6 +25,7 @@ namespace draw
static int screen_height = 240; static int screen_height = 240;
std::string screen_title = ""; std::string screen_title = "";
static int screen_mode = SCREEN_MODE_NORMAL; static int screen_mode = SCREEN_MODE_NORMAL;
static bool any_fullscreen = false;
surface *screen = nullptr; // La superficie screen, que representa la pantalla. Se crea i destrueix internament surface *screen = nullptr; // La superficie screen, que representa la pantalla. Se crea i destrueix internament
surface *destination = nullptr; // Punter a la actual superficie de destí surface *destination = nullptr; // Punter a la actual superficie de destí
@@ -207,16 +209,16 @@ namespace draw
SDL_DestroyTexture(sdl_texture); SDL_DestroyTexture(sdl_texture);
SDL_DestroyRenderer(sdl_renderer); SDL_DestroyRenderer(sdl_renderer);
SDL_DestroyWindow(sdl_window); SDL_DestroyWindow(sdl_window);
any_fullscreen = screen_fullscreen || config::getKioskMode() || console;
const int zoom = screen_fullscreen ? 1 : screen_zoom; const int zoom = any_fullscreen ? 1 : screen_zoom;
if (console) { if (any_fullscreen) {
SDL_DisplayID display = SDL_GetPrimaryDisplay(); SDL_DisplayID display = SDL_GetPrimaryDisplay();
const SDL_DisplayMode *mode = SDL_GetDesktopDisplayMode(display); const SDL_DisplayMode *mode = SDL_GetDesktopDisplayMode(display);
screen_fullscreen = true;
sdl_window = SDL_CreateWindow(screen_title.c_str(), mode->w, mode->h, SDL_WINDOW_FULLSCREEN); sdl_window = SDL_CreateWindow(screen_title.c_str(), mode->w, mode->h, SDL_WINDOW_FULLSCREEN);
} else { } else {
sdl_window = SDL_CreateWindow(screen_title.c_str(), screen_width * zoom, screen_height * zoom, screen_fullscreen?SDL_WINDOW_FULLSCREEN:0); sdl_window = SDL_CreateWindow(screen_title.c_str(), screen_width * zoom, screen_height * zoom, 0);
} }
sdl_renderer = SDL_CreateRenderer(sdl_window, nullptr); sdl_renderer = SDL_CreateRenderer(sdl_window, nullptr);
@@ -225,7 +227,7 @@ namespace draw
SDL_HideCursor(); SDL_HideCursor();
if (screen_fullscreen) if (any_fullscreen)
{ {
int w, h; int w, h;
SDL_GetWindowSize(sdl_window, &w, &h); SDL_GetWindowSize(sdl_window, &w, &h);
@@ -248,7 +250,7 @@ namespace draw
void setZoom(const int value) void setZoom(const int value)
{ {
if (console) return; if (screen_fullscreen || config::getKioskMode() || console) return;
if (value < 1) return; if (value < 1) return;
const SDL_DisplayMode *dm = SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(sdl_window)); const SDL_DisplayMode *dm = SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(sdl_window));
@@ -261,26 +263,26 @@ namespace draw
void incZoom() void incZoom()
{ {
if (console) return; if (screen_fullscreen || config::getKioskMode() || console) return;
setZoom(screen_zoom+1); setZoom(screen_zoom+1);
} }
void decZoom() void decZoom()
{ {
if (console) return; if (screen_fullscreen || config::getKioskMode() || console) return;
setZoom(screen_zoom-1); setZoom(screen_zoom-1);
} }
void toggleFullscreen() void toggleFullscreen()
{ {
if (console) return; if (config::getKioskMode() || console) return;
screen_fullscreen = !screen_fullscreen; screen_fullscreen = !screen_fullscreen;
reinit(); reinit();
} }
void setFullscreen(const bool value) void setFullscreen(const bool value)
{ {
if (console) return; if (config::getKioskMode() || console) return;
if (screen_fullscreen == value) return; if (screen_fullscreen == value) return;
screen_fullscreen = value; screen_fullscreen = value;
reinit(); reinit();
@@ -763,7 +765,7 @@ bool SaveIndexedAsBMP(const char *filename,
// Desbloquejem la textura // Desbloquejem la textura
SDL_UnlockTexture(sdl_texture); SDL_UnlockTexture(sdl_texture);
if (screen_fullscreen) if (any_fullscreen)
{ {
SDL_SetRenderDrawColor(sdl_renderer, 0, 0, 0, 255); SDL_SetRenderDrawColor(sdl_renderer, 0, 0, 0, 255);
SDL_RenderClear(sdl_renderer); SDL_RenderClear(sdl_renderer);
@@ -774,9 +776,10 @@ bool SaveIndexedAsBMP(const char *filename,
if (screen_mode & SCREEN_MODE_SCANLINES) if (screen_mode & SCREEN_MODE_SCANLINES)
{ {
if (screen_zoom>=3 || screen_fullscreen)
if (screen_zoom>=3 || any_fullscreen)
{ {
int zoom = screen_fullscreen ? fullscreen_scale : screen_zoom; int zoom = any_fullscreen ? fullscreen_scale : screen_zoom;
SDL_SetRenderDrawBlendMode(sdl_renderer, SDL_BLENDMODE_BLEND); SDL_SetRenderDrawBlendMode(sdl_renderer, SDL_BLENDMODE_BLEND);
for (int y=0; y<screen_height; ++y) for (int y=0; y<screen_height; ++y)
{ {

View File

@@ -38,6 +38,7 @@ namespace draw
/// @param height es el alt de la finestra "virtual" /// @param height es el alt de la finestra "virtual"
/// @param zoom es com de grans son els pixels. /// @param zoom es com de grans son els pixels.
void init(const std::string &titol, const uint16_t width, const uint16_t height, const int zoom, const bool fullscreen=false); void init(const std::string &titol, const uint16_t width, const uint16_t height, const int zoom, const bool fullscreen=false);
void reinit();
/// @brief Finalització del sistema (tancar coses de SDL, superficies fixes, etc...) /// @brief Finalització del sistema (tancar coses de SDL, superficies fixes, etc...)
void quit(); void quit();