- [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:
@@ -1,6 +1,7 @@
|
||||
#include "config.h"
|
||||
#include "jfile.h"
|
||||
#include <SDL3/SDL.h>
|
||||
#include "jdraw.h"
|
||||
|
||||
namespace config
|
||||
{
|
||||
@@ -88,6 +89,7 @@ namespace config
|
||||
{
|
||||
kiosk_mode = value;
|
||||
file::setConfigValue("kiosk", kiosk_mode ? "yes" : "no");
|
||||
draw::reinit();
|
||||
}
|
||||
|
||||
const bool getKioskMode()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <SDL3/SDL.h>
|
||||
#include "gif.h"
|
||||
#include "jfile.h"
|
||||
#include "config.h"
|
||||
#include <vector>
|
||||
|
||||
namespace draw
|
||||
@@ -24,6 +25,7 @@ namespace draw
|
||||
static int screen_height = 240;
|
||||
std::string screen_title = "";
|
||||
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 *destination = nullptr; // Punter a la actual superficie de destí
|
||||
@@ -207,16 +209,16 @@ namespace draw
|
||||
SDL_DestroyTexture(sdl_texture);
|
||||
SDL_DestroyRenderer(sdl_renderer);
|
||||
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();
|
||||
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);
|
||||
} 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);
|
||||
@@ -225,7 +227,7 @@ namespace draw
|
||||
|
||||
SDL_HideCursor();
|
||||
|
||||
if (screen_fullscreen)
|
||||
if (any_fullscreen)
|
||||
{
|
||||
int w, h;
|
||||
SDL_GetWindowSize(sdl_window, &w, &h);
|
||||
@@ -248,7 +250,7 @@ namespace draw
|
||||
|
||||
void setZoom(const int value)
|
||||
{
|
||||
if (console) return;
|
||||
if (screen_fullscreen || config::getKioskMode() || console) return;
|
||||
if (value < 1) return;
|
||||
const SDL_DisplayMode *dm = SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(sdl_window));
|
||||
|
||||
@@ -261,26 +263,26 @@ namespace draw
|
||||
|
||||
void incZoom()
|
||||
{
|
||||
if (console) return;
|
||||
if (screen_fullscreen || config::getKioskMode() || console) return;
|
||||
setZoom(screen_zoom+1);
|
||||
}
|
||||
|
||||
void decZoom()
|
||||
{
|
||||
if (console) return;
|
||||
if (screen_fullscreen || config::getKioskMode() || console) return;
|
||||
setZoom(screen_zoom-1);
|
||||
}
|
||||
|
||||
void toggleFullscreen()
|
||||
{
|
||||
if (console) return;
|
||||
if (config::getKioskMode() || console) return;
|
||||
screen_fullscreen = !screen_fullscreen;
|
||||
reinit();
|
||||
}
|
||||
|
||||
void setFullscreen(const bool value)
|
||||
{
|
||||
if (console) return;
|
||||
if (config::getKioskMode() || console) return;
|
||||
if (screen_fullscreen == value) return;
|
||||
screen_fullscreen = value;
|
||||
reinit();
|
||||
@@ -763,7 +765,7 @@ bool SaveIndexedAsBMP(const char *filename,
|
||||
// Desbloquejem la textura
|
||||
SDL_UnlockTexture(sdl_texture);
|
||||
|
||||
if (screen_fullscreen)
|
||||
if (any_fullscreen)
|
||||
{
|
||||
SDL_SetRenderDrawColor(sdl_renderer, 0, 0, 0, 255);
|
||||
SDL_RenderClear(sdl_renderer);
|
||||
@@ -774,9 +776,10 @@ bool SaveIndexedAsBMP(const char *filename,
|
||||
|
||||
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);
|
||||
for (int y=0; y<screen_height; ++y)
|
||||
{
|
||||
|
||||
@@ -38,7 +38,8 @@ namespace draw
|
||||
/// @param height es el alt de la finestra "virtual"
|
||||
/// @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 reinit();
|
||||
|
||||
/// @brief Finalització del sistema (tancar coses de SDL, superficies fixes, etc...)
|
||||
void quit();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user