Skip to content

Commit

Permalink
feat: Allow disabling resizability of windows (setting in launcher only)
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyV99 authored and connorjclark committed Nov 13, 2023
1 parent 74bbc05 commit 90085dd
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/launcher/launcher_dialog.cpp
Expand Up @@ -517,6 +517,7 @@ std::shared_ptr<GUI::Widget> LauncherDialog::view()
TabRef(name = "ZC Player", Row(framed = true,
Rows<2>(fitParent = true,
CONFIG_CHECKBOX("Fullscreen",App::zelda,"zeldadx","fullscreen",0),
CONFIG_CHECKBOX("Disable Resizing",App::zelda,"gui","disable_window_resizing",0),
CONFIG_CHECKBOX("Cap FPS",App::zelda,"zeldadx","throttlefps",1),
CONFIG_CHECKBOX("Show FPS",App::zelda,"zeldadx","showfps",0),
CONFIG_CHECKBOX("Cont. Heart Beep",App::zelda,"zeldadx","heart_beep",0),
Expand Down Expand Up @@ -581,6 +582,7 @@ std::shared_ptr<GUI::Widget> LauncherDialog::view()
TabRef(name = "ZC Editor", Row(framed = true,
Rows<2>(fitParent = true,
CONFIG_CHECKBOX_I("Fullscreen",App::zquest,"zquest","fullscreen",0,"Exactly stable."),
CONFIG_CHECKBOX("Disable Resizing",App::zquest,"gui","disable_window_resizing",0),
CONFIG_CHECKBOX("Show FPS",App::zquest,"zquest","showfps",0),
CONFIG_CHECKBOX("Disable Sound",App::zquest,"zquest","nosound",0),
CONFIG_CHECKBOX("Animate Combos",App::zquest,"zquest","animation_on",1),
Expand Down
3 changes: 3 additions & 0 deletions src/zc/zelda.cpp
Expand Up @@ -4929,6 +4929,9 @@ int main(int argc, char **argv)
// window_width = resx;
// window_height = resy;

if(zc_get_config("gui","disable_window_resizing",0))
all_set_resize_flag(false);

if(!game_vid_mode(tempmode, wait_ms_on_set_graphics))
{
al_trace("Fatal Error: could not create a window for ZQuest Classic.\n");
Expand Down
3 changes: 3 additions & 0 deletions src/zq/zquest.cpp
Expand Up @@ -27862,6 +27862,9 @@ int32_t main(int32_t argc,char **argv)
large_zoomed_cmd = zc_get_config("ZQ_GUI","zoom_cmd_large",1);
compact_zoomed_cmd = zc_get_config("ZQ_GUI","zoom_cmd_compact",1);

if(zc_get_config("gui","disable_window_resizing",0))
all_set_resize_flag(false);

load_hotkeys();

#ifdef _WIN32
Expand Down
2 changes: 2 additions & 0 deletions third_party/allegro_legacy/include/a5alleg.h
Expand Up @@ -38,6 +38,8 @@ AL_LEGACY_FUNC(int, all_get_scale, (void));
AL_LEGACY_FUNC(void, all_get_display_transform, (int* out_native_width, int* out_native_height, int* out_display_width, int* out_display_height, int* out_offset_x, int* out_offset_y, double* out_scale));
AL_LEGACY_FUNC(void, all_set_fullscreen_flag, (bool fullscreen));
AL_LEGACY_FUNC(bool, all_get_fullscreen_flag, (void));
AL_LEGACY_FUNC(void, all_set_resize_flag, (bool resize));
AL_LEGACY_FUNC(bool, all_get_resize_flag, (void));
AL_LEGACY_FUNC(void, all_set_display_flags, (int flags));
AL_LEGACY_FUNC(int, all_get_display_flags, (void));
AL_LEGACY_FUNC(void, all_set_bitmap_flags, (int flags));
Expand Down
20 changes: 19 additions & 1 deletion third_party/allegro_legacy/src/a5/a5_display.c
Expand Up @@ -49,6 +49,7 @@ static int _a5_display_height = 0;
static int _a5_display_scale = 1;
static bool _a5_display_force_integer_scale = true;
static bool _a5_display_fullscreen = false;
static bool _a5_display_resize = true;
static int _a5_display_flags = 0;
static int _a5_bitmap_flags = ALLEGRO_NO_PRESERVE_TEXTURE;
static volatile int _a5_display_creation_done = 0;
Expand Down Expand Up @@ -90,7 +91,8 @@ static bool _a5_setup_screen(int w, int h)
if (_a5_display_fullscreen) flags |= ALLEGRO_FULLSCREEN;
#endif
#ifndef __EMSCRIPTEN__
else flags |= ALLEGRO_RESIZABLE;
else if(_a5_display_resize) flags |= ALLEGRO_RESIZABLE;
else flags &= ~ALLEGRO_RESIZABLE;
#endif

al_set_new_display_flags(flags);
Expand Down Expand Up @@ -876,6 +878,22 @@ bool all_get_fullscreen_flag()
return _a5_display_fullscreen;
}

// local edit
void all_set_resize_flag(bool resize)
{
_a5_display_resize = resize;
}

// local edit
bool all_get_resize_flag()
{
if (_a5_display)
{
return (al_get_display_flags(_a5_display) & ALLEGRO_RESIZABLE) != 0;
}
return _a5_display_resize;
}

// local edit
void all_set_scale(int scale)
{
Expand Down

0 comments on commit 90085dd

Please sign in to comment.