- [NEW] Habitació de prova de parts
- [NEW] Templates de les parts - [NEW] Mòdul de debug - [NEW] Debug info de la posicio dels actors - [FIX] Al reiniciar partida el heroi estava en posició incorrecta - [NEW] Mòdul de config - [NEW] El joc ja permet canviar zoom i ficar fullscreen - [NEW] F1, F2 i F3 per a zoom i fullscreen - [NEW] Ja es guarda en arxiu de config el zoom, fullscreen, musica i só. - [FIX] Al eixir prematurament del logo de vegades la paleta estava loca - [NEW] Menú de configuració del àudio - [NEW] Menú de pausa dins del joc (es veu peces que falten per arreplegar) - [ONGOING] Comença l'implementació de tecles redefinides
This commit is contained in:
@@ -16,6 +16,10 @@ namespace draw
|
||||
SDL_Texture *sdl_texture = nullptr; // La textura de SDL a la que pintarem la nostra superficie "screen" i que despres volcarem a pantalla
|
||||
|
||||
static int screen_zoom = 1;
|
||||
static bool screen_fullscreen = false;
|
||||
static int screen_width = 320;
|
||||
static int screen_height = 240;
|
||||
std::string screen_title = "";
|
||||
|
||||
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í
|
||||
@@ -36,16 +40,20 @@ namespace draw
|
||||
int num_managed = 0;
|
||||
|
||||
// Inicialització de tot el que fa falta per a carregar gràfics i pintar en pantalla
|
||||
void init(const std::string &titol, const uint16_t width, const uint16_t height, const int zoom)
|
||||
void init(const std::string &titol, const uint16_t width, const uint16_t height, const int zoom, const bool fullscreen)
|
||||
{
|
||||
screen_title = titol;
|
||||
screen_fullscreen = fullscreen;
|
||||
screen_zoom = zoom;
|
||||
screen_width = width;
|
||||
screen_height = height;
|
||||
|
||||
// [TODO] Incloure gestió de pantalla completa
|
||||
|
||||
// Inicialització de les estructures de SDL
|
||||
sdl_window = SDL_CreateWindow(titol.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width * zoom, height * zoom, SDL_WINDOW_SHOWN);
|
||||
sdl_window = SDL_CreateWindow(screen_title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screen_width * screen_zoom, screen_height * screen_zoom, screen_fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_SHOWN);
|
||||
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, 0);
|
||||
sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, width, height);
|
||||
sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height);
|
||||
|
||||
// Establim el tamany "logic", indepndent del tamany de finestra
|
||||
SDL_RenderSetLogicalSize(sdl_renderer, width, height);
|
||||
@@ -97,6 +105,64 @@ namespace draw
|
||||
screen = destination = source = nullptr;
|
||||
}
|
||||
|
||||
void reinit()
|
||||
{
|
||||
// Destruim tot el relacionat amb SDL
|
||||
SDL_DestroyTexture(sdl_texture);
|
||||
SDL_DestroyRenderer(sdl_renderer);
|
||||
SDL_DestroyWindow(sdl_window);
|
||||
|
||||
const int zoom = screen_fullscreen ? 1 : screen_zoom;
|
||||
sdl_window = SDL_CreateWindow(screen_title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screen_width * zoom, screen_height * zoom, screen_fullscreen?SDL_WINDOW_FULLSCREEN_DESKTOP:SDL_WINDOW_SHOWN);
|
||||
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, 0);
|
||||
sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height);
|
||||
|
||||
// Establim el tamany "logic", indepndent del tamany de finestra
|
||||
SDL_RenderSetLogicalSize(sdl_renderer, screen_width, screen_height);
|
||||
}
|
||||
|
||||
void setZoom(const int value)
|
||||
{
|
||||
if (value < 1) return;
|
||||
|
||||
SDL_DisplayMode dm;
|
||||
SDL_GetCurrentDisplayMode(0, &dm);
|
||||
|
||||
if (screen_width*value > dm.w) return;
|
||||
if (screen_height*value > dm.h) return;
|
||||
|
||||
screen_zoom = value;
|
||||
reinit();
|
||||
}
|
||||
|
||||
void incZoom()
|
||||
{
|
||||
setZoom(screen_zoom+1);
|
||||
}
|
||||
|
||||
void decZoom()
|
||||
{
|
||||
setZoom(screen_zoom-1);
|
||||
}
|
||||
|
||||
void toggleFullscreen()
|
||||
{
|
||||
screen_fullscreen = !screen_fullscreen;
|
||||
reinit();
|
||||
}
|
||||
|
||||
void setFullscreen(const bool value)
|
||||
{
|
||||
if (screen_fullscreen == value) return;
|
||||
screen_fullscreen = value;
|
||||
reinit();
|
||||
}
|
||||
|
||||
const bool getFullscreen()
|
||||
{
|
||||
return screen_fullscreen;
|
||||
}
|
||||
|
||||
const int getZoom()
|
||||
{
|
||||
return screen_zoom;
|
||||
|
||||
Reference in New Issue
Block a user