- added handling for changing the screen size (dragging the window borders / change scale factor)

This commit is contained in:
Christoph Oelckers 2020-01-01 09:49:06 +01:00
parent 3d47652d08
commit bcb48d8441
14 changed files with 49 additions and 1 deletions

View file

@ -1926,6 +1926,11 @@ void GameInterface::FreeGameData()
ShutDown(); ShutDown();
} }
void GameInterface::UpdateScreenSize()
{
viewResizeView(gViewSize);
}
::GameInterface* CreateInterface() ::GameInterface* CreateInterface()
{ {

View file

@ -84,6 +84,7 @@ struct GameInterface : ::GameInterface
{ {
void faketimerhandler() override; void faketimerhandler() override;
int app_main() override; int app_main() override;
void UpdateScreenSize() override;
void FreeGameData() override; void FreeGameData() override;
bool validate_hud(int) override; bool validate_hud(int) override;
void set_hud_layout(int size) override; void set_hud_layout(int size) override;

View file

@ -105,6 +105,7 @@ struct GameInterface
virtual ~GameInterface() {} virtual ~GameInterface() {}
virtual void faketimerhandler() {} // This is a remnant of older versions, but Blood backend has not updated yet. virtual void faketimerhandler() {} // This is a remnant of older versions, but Blood backend has not updated yet.
virtual int app_main() = 0; virtual int app_main() = 0;
virtual void UpdateScreenSize() {}
virtual void FreeGameData() {} virtual void FreeGameData() {}
virtual bool validate_hud(int) = 0; virtual bool validate_hud(int) = 0;
virtual void set_hud_layout(int size) = 0; virtual void set_hud_layout(int size) = 0;

View file

@ -67,6 +67,22 @@ void I_StartTic();
int32_t handleevents(void) int32_t handleevents(void)
{ {
// fullscreen toggle has been requested
if (setmodeneeded)
{
setmodeneeded = false;
screen->ToggleFullscreen(fullscreen);
V_OutputResized(screen->GetWidth(), screen->GetHeight());
}
// change the view size if needed
if (setsizeneeded)
{
videoSetGameMode(vid_fullscreen, SCREENWIDTH, SCREENHEIGHT, 32, 1);
if (gi) gi->UpdateScreenSize();
setsizeneeded = false;
}
timerUpdateClock(); timerUpdateClock();
// The mouse wheel is not a real key so in order to be "pressed" it may only be cleared at the end of the tic (or the start of the next.) // The mouse wheel is not a real key so in order to be "pressed" it may only be cleared at the end of the tic (or the start of the next.)

View file

@ -515,7 +515,7 @@ void V_UpdateModeSize (int width, int height)
void V_OutputResized (int width, int height) void V_OutputResized (int width, int height)
{ {
V_UpdateModeSize(width, height); V_UpdateModeSize(width, height);
// setsizeneeded = true; setsizeneeded = true;
C_NewModeAdjust(); C_NewModeAdjust();
} }

View file

@ -434,6 +434,8 @@ void ScaleWithAspect(int &w, int &h, int Width, int Height);
int GetUIScale(int altval); int GetUIScale(int altval);
int GetConScale(int altval); int GetConScale(int altval);
extern bool setsizeneeded, setmodeneeded;
EXTERN_CVAR(Int, uiscale); EXTERN_CVAR(Int, uiscale);
EXTERN_CVAR(Int, con_scaletext); EXTERN_CVAR(Int, con_scaletext);
EXTERN_CVAR(Int, con_scale); EXTERN_CVAR(Int, con_scale);

View file

@ -143,6 +143,7 @@ static inline int32_t G_DefaultActorHealth(int spriteNum)
struct GameInterface : ::GameInterface struct GameInterface : ::GameInterface
{ {
int app_main() override; int app_main() override;
void UpdateScreenSize() override;
void FreeGameData() override; void FreeGameData() override;
bool validate_hud(int) override; bool validate_hud(int) override;
void set_hud_layout(int size) override; void set_hud_layout(int size) override;

View file

@ -6441,6 +6441,11 @@ void GameInterface::FreeGameData()
G_Cleanup(); G_Cleanup();
} }
void GameInterface::UpdateScreenSize()
{
G_UpdateScreenArea();
}
::GameInterface* CreateInterface() ::GameInterface* CreateInterface()
{ {
return new GameInterface; return new GameInterface;

View file

@ -3286,6 +3286,11 @@ bool GameInterface::CanSave()
return !bRecord && !bPlayback && !bPause && !bInDemo && nTotalPlayers == 1; return !bRecord && !bPlayback && !bPause && !bInDemo && nTotalPlayers == 1;
} }
void GameInterface::UpdateScreenSize()
{
Powerslave::UpdateScreenSize();
}
::GameInterface* CreateInterface() ::GameInterface* CreateInterface()
{ {

View file

@ -273,6 +273,7 @@ void G_DoAutoload(const char* dirname);
struct GameInterface : ::GameInterface struct GameInterface : ::GameInterface
{ {
int app_main() override; int app_main() override;
void UpdateScreenSize() override;
bool validate_hud(int) override { return true; } bool validate_hud(int) override { return true; }
void set_hud_layout(int size) override {} void set_hud_layout(int size) override {}
void set_hud_scale(int size) override {} void set_hud_scale(int size) override {}

View file

@ -146,6 +146,7 @@ static inline int32_t G_DefaultActorHealth(int spriteNum)
struct GameInterface : ::GameInterface struct GameInterface : ::GameInterface
{ {
int app_main() override; int app_main() override;
void UpdateScreenSize() override;
void FreeGameData() override; void FreeGameData() override;
bool validate_hud(int) override; bool validate_hud(int) override;
void set_hud_layout(int size) override; void set_hud_layout(int size) override;

View file

@ -7888,6 +7888,11 @@ void GameInterface::FreeGameData()
G_Cleanup(); G_Cleanup();
} }
void GameInterface::UpdateScreenSize()
{
G_UpdateScreenArea();
}
::GameInterface* CreateInterface() ::GameInterface* CreateInterface()
{ {
return new GameInterface; return new GameInterface;

View file

@ -3958,6 +3958,10 @@ void GameInterface::FreeGameData()
TerminateLevel(); TerminateLevel();
} }
void GameInterface::UpdateScreenSize()
{
SetupAspectRatio();
}
#if 0 // the message input needs to be moved out of the game code! #if 0 // the message input needs to be moved out of the game code!

View file

@ -2430,6 +2430,7 @@ void LoadSaveMsg(const char *msg);
struct GameInterface : ::GameInterface struct GameInterface : ::GameInterface
{ {
int app_main() override; int app_main() override;
void UpdateScreenSize() override;
void FreeGameData() override; void FreeGameData() override;
bool validate_hud(int) override; bool validate_hud(int) override;
void set_hud_layout(int size) override; void set_hud_layout(int size) override;