diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 993952e8d..021661d31 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1089,6 +1089,7 @@ set (PCH_SOURCES menu/messagebox.cpp menu/optionmenu.cpp menu/playermenu.cpp + menu/resolutionmenu.cpp resourcefiles/ancientzip.cpp resourcefiles/file_7z.cpp resourcefiles/file_grp.cpp diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 7d4ec43ae..0613ec255 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -853,6 +853,22 @@ void M_ClearMenus() // //============================================================================= +void M_PreviousMenu() +{ + if (CurrentMenu != nullptr) + { + DMenu* parent = CurrentMenu->mParentMenu; + CurrentMenu->Destroy(); + CurrentMenu = parent; + } +} + +//============================================================================= +// +// +// +//============================================================================= + void M_Init (void) { try @@ -1032,6 +1048,11 @@ CCMD (closemenu) M_ClearMenus(); } +CCMD (prevmenu) +{ + M_PreviousMenu(); +} + // // Toggle messages on/off // diff --git a/src/menu/menu.h b/src/menu/menu.h index b17233702..2091bd823 100644 --- a/src/menu/menu.h +++ b/src/menu/menu.h @@ -336,6 +336,7 @@ void M_Init (void); void M_CreateMenus(); void M_ActivateMenu(DMenu *menu); void M_ClearMenus (); +void M_PreviousMenu (); void M_ParseMenuDefs(); void M_StartupSkillMenu(FGameStartup *gs); void M_StartControlPanel (bool makeSound); diff --git a/src/menu/resolutionmenu.cpp b/src/menu/resolutionmenu.cpp new file mode 100644 index 000000000..0f05c1a20 --- /dev/null +++ b/src/menu/resolutionmenu.cpp @@ -0,0 +1,93 @@ +/* +** resolutionmenu.cpp +** Basic Custom Resolution Selector for the Menu +** +**--------------------------------------------------------------------------- +** Copyright 2018 Rachael Alexanderson +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +#include "doomdef.h" +#include "doomstat.h" +#include "c_dispatch.h" +#include "c_cvars.h" +#include "v_video.h" +#include "menu/menu.h" + +CVAR(Int, menu_resolution_custom_width, 640, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Int, menu_resolution_custom_height, 480, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) + +EXTERN_CVAR(Bool, fullscreen) +EXTERN_CVAR(Bool, win_maximized) +EXTERN_CVAR(Bool, vid_scale_customlinear) +EXTERN_CVAR(Bool, vid_scale_customstretched) +EXTERN_CVAR(Int, vid_scale_customwidth) +EXTERN_CVAR(Int, vid_scale_customheight) +EXTERN_CVAR(Int, vid_scalemode) +EXTERN_CVAR(Float, vid_scalefactor) + +CCMD (menu_resolution_set_custom) +{ + if (argv.argc() > 2) + { + menu_resolution_custom_width = atoi(argv[1]); + menu_resolution_custom_height = atoi(argv[2]); + } + else + { + Printf("This command is not meant to be used outside the menu! But if you want to use it, please specify and .\n"); + } + M_PreviousMenu(); +} + +CCMD (menu_resolution_commit_changes) +{ + int do_fullscreen = fullscreen; + if (argv.argc() > 1) + { + do_fullscreen = atoi(argv[1]); + } + + if (do_fullscreen == false) + { + vid_scalemode = vid_scale_customlinear; + vid_scalefactor = 1.; + screen->SetWindowSize(menu_resolution_custom_width, menu_resolution_custom_height); + V_OutputResized(screen->GetClientWidth(), screen->GetClientHeight()); + } + else + { + fullscreen = true; + vid_scalemode = 5; + vid_scale_customwidth = menu_resolution_custom_width; + vid_scale_customheight = menu_resolution_custom_height; + vid_scale_customstretched = false; + } +} + + diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 9ad888ea5..81fe8f77f 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1927,37 +1927,46 @@ OptionMenu VideoModeMenu protected Option "$VIDMNU_CROPASPECT", "vid_cropaspect", "CropAspect" Option "$VIDMNU_SCALEMODE", "vid_scalemode", "ScaleModes" Slider "$VIDMNU_SCALEFACTOR", "vid_scalefactor", 0.25, 2.0, 0.25, 2 - - SubMenu "Resolution Mode", CustomResolutionMenu - SubMenu "Window Size", CustomWindowSizeMenu + + StaticText "" + StaticText "Custom Resolution Mode" + TextField "Custom Width", menu_resolution_custom_width + TextField "Custom Height", menu_resolution_custom_height + Option "Use Linear Scaling (Fullscreen)", "vid_scale_customlinear", "YesNo" + StaticText "" + Command "Apply Changes (Windowed)", "menu_resolution_commit_changes 0" + Command "Apply Changes (Fullscreen)", "menu_resolution_commit_changes 1" + StaticText "" + + SubMenu "Choose Resolution Preset", CustomResolutionMenu } OptionMenu CustomResolutionMenu protected { - Title "Resolution Mode" + Title "Custom Resolution Presets" - StaticText "Custom Resolution Mode" - TextField "Custom Width", vid_scale_customwidth - TextField "Custom Height", vid_scale_customheight - StaticText "" StaticText "Preset Resolution Modes" + StaticText "" StaticText "4:3 Aspect" - Command "320x240", "vid_setscale 320 200" - Command "640x480", "vid_setscale 640 480" - Command "1024x768", "vid_setscale 1024 768" + Command "320x240", "menu_resolution_set_custom 320 240" + Command "640x480", "menu_resolution_set_custom 640 480" + Command "1024x768", "menu_resolution_set_custom 1024 768" + Command "1280x960", "menu_resolution_set_custom 1280 960" + Command "1600x1200", "menu_resolution_set_custom 1600 1200" + StaticText "" StaticText "16:9 Aspect" - Command "960x540", "vid_setscale 960 540" - Command "1920x1080", "vid_setscale 1920 1080" -} - -OptionMenu CustomWindowSizeMenu protected -{ - Title "Windowed Mode Preset Sizes" - Command "320x200", "vid_setsize 320 200" - Command "640x480", "vid_setsize 640 480" - Command "960x540", "vid_setsize 960 540" - Command "640x480", "vid_setsize 640 480" - Command "1920x1080", "vid_setsize 1920 1080" + Command "960x540", "menu_resolution_set_custom 960 540" + Command "(720p HD) 1280x720", "menu_resolution_set_custom 1280 720" + Command "1366x768", "menu_resolution_set_custom 1366 768" + Command "(1080p HD) 1920x1080", "menu_resolution_set_custom 1920 1080" + Command "(1440p HD) 2560x1440", "menu_resolution_set_custom 2560 1440" + StaticText "" + StaticText "16:10 Aspect" + Command "960x600", "menu_resolution_set_custom 960 600" + Command "1280x800", "menu_resolution_set_custom 1280 800" + Command "1440x900", "menu_resolution_set_custom 1440 900" + Command "1680x1050", "menu_resolution_set_custom 1680 1050" + Command "1920x1200", "menu_resolution_set_custom 1920 1200" } /*=======================================