forked from mirrors/principia
Allow toggling fullscreen with F11
This commit is contained in:
parent
8773e540f3
commit
67fad00960
7 changed files with 18 additions and 24 deletions
|
|
@ -9,6 +9,8 @@
|
|||
#include "soundmanager.hh"
|
||||
#include "game.hh"
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
p_text *pscreen::text_username;
|
||||
game_message *pscreen::message;
|
||||
game_graph pscreen::fps_graph("FPS");
|
||||
|
|
@ -239,6 +241,17 @@ pscreen::handle_input(tms::event *ev, int action)
|
|||
++ snd_counter;
|
||||
}
|
||||
break;
|
||||
|
||||
case TMS_KEY_F11:
|
||||
uint32_t flags = SDL_GetWindowFlags(_tms._window);
|
||||
|
||||
if (flags & SDL_WINDOW_FULLSCREEN_DESKTOP)
|
||||
SDL_SetWindowFullscreen(_tms._window, 0);
|
||||
else
|
||||
SDL_SetWindowFullscreen(_tms._window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
|
||||
settings["window_fullscreen"]->v.b = (flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == 0;
|
||||
break;
|
||||
}
|
||||
} else if (ev->type == TMS_EV_POINTER_UP) {
|
||||
#ifndef NO_UI
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ _settings::init()
|
|||
this->add("window_width", S_INT32, _tms.window_width);
|
||||
this->add("window_height", S_INT32, _tms.window_height);
|
||||
this->add("window_maximized", S_BOOL, 0);
|
||||
this->add("window_fullscreen", S_BOOL, false);
|
||||
|
||||
// False for now to allow for resetting the screensize if resizing somehow breaks it.
|
||||
this->add("autosave_screensize",S_BOOL, false);
|
||||
|
|
|
|||
|
|
@ -362,6 +362,9 @@ tbackend_init_surface()
|
|||
if (settings["window_maximized"]->v.b)
|
||||
flags |= SDL_WINDOW_MAXIMIZED;
|
||||
|
||||
if (settings["window_fullscreen"]->v.b)
|
||||
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
|
||||
tms_infof("Creating window..."); \
|
||||
_window = SDL_CreateWindow("Principia", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||
_tms.window_width, _tms.window_height, flags);
|
||||
|
|
@ -644,14 +647,3 @@ const char *tbackend_get_storage_path(void)
|
|||
}
|
||||
return _storage_path;
|
||||
}
|
||||
|
||||
void
|
||||
tbackend_toggle_fullscreen(void)
|
||||
{
|
||||
uint32_t flags = SDL_GetWindowFlags(_window);
|
||||
|
||||
if (flags & SDL_WINDOW_FULLSCREEN)
|
||||
SDL_SetWindowFullscreen(_window, SDL_FALSE);
|
||||
else
|
||||
SDL_SetWindowFullscreen(_window, SDL_TRUE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -264,9 +264,3 @@ const char *tbackend_get_storage_path(void)
|
|||
}
|
||||
return _storage_path;
|
||||
}
|
||||
|
||||
void
|
||||
tbackend_toggle_fullscreen(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,14 +30,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct tms_context;
|
||||
|
||||
int tbackend_init_surface(void);
|
||||
|
||||
const char *tbackend_get_storage_path();
|
||||
|
||||
void tbackend_toggle_fullscreen(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
#define GL_ETC1_RGB8_OES 0x8D64
|
||||
|
||||
struct tms_context;
|
||||
|
||||
struct tms_texture {
|
||||
char *filename;
|
||||
unsigned char *data;
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ extern struct tms_singleton {
|
|||
int dt_count;
|
||||
uint64_t last_time;
|
||||
|
||||
void *_window;
|
||||
SDL_Window *_window;
|
||||
} _tms;
|
||||
|
||||
int tms_init(void);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue