- redo the menu a bit, add in some C++ support code to make it a little bit more flexible

- further tweaks. reduce clutter in custom resolution submenu by moving it to another
- add 'prevmenu' ccmd
This commit is contained in:
Rachael Alexanderson 2018-08-01 11:53:58 -04:00
parent 68bd618aaa
commit bd1e484c1e
5 changed files with 148 additions and 23 deletions

View file

@ -1089,6 +1089,7 @@ set (PCH_SOURCES
menu/messagebox.cpp menu/messagebox.cpp
menu/optionmenu.cpp menu/optionmenu.cpp
menu/playermenu.cpp menu/playermenu.cpp
menu/resolutionmenu.cpp
resourcefiles/ancientzip.cpp resourcefiles/ancientzip.cpp
resourcefiles/file_7z.cpp resourcefiles/file_7z.cpp
resourcefiles/file_grp.cpp resourcefiles/file_grp.cpp

View file

@ -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) void M_Init (void)
{ {
try try
@ -1032,6 +1048,11 @@ CCMD (closemenu)
M_ClearMenus(); M_ClearMenus();
} }
CCMD (prevmenu)
{
M_PreviousMenu();
}
// //
// Toggle messages on/off // Toggle messages on/off
// //

View file

@ -336,6 +336,7 @@ void M_Init (void);
void M_CreateMenus(); void M_CreateMenus();
void M_ActivateMenu(DMenu *menu); void M_ActivateMenu(DMenu *menu);
void M_ClearMenus (); void M_ClearMenus ();
void M_PreviousMenu ();
void M_ParseMenuDefs(); void M_ParseMenuDefs();
void M_StartupSkillMenu(FGameStartup *gs); void M_StartupSkillMenu(FGameStartup *gs);
void M_StartControlPanel (bool makeSound); void M_StartControlPanel (bool makeSound);

View file

@ -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 <x> and <y>.\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;
}
}

View file

@ -1928,36 +1928,45 @@ OptionMenu VideoModeMenu protected
Option "$VIDMNU_SCALEMODE", "vid_scalemode", "ScaleModes" Option "$VIDMNU_SCALEMODE", "vid_scalemode", "ScaleModes"
Slider "$VIDMNU_SCALEFACTOR", "vid_scalefactor", 0.25, 2.0, 0.25, 2 Slider "$VIDMNU_SCALEFACTOR", "vid_scalefactor", 0.25, 2.0, 0.25, 2
SubMenu "Resolution Mode", CustomResolutionMenu StaticText ""
SubMenu "Window Size", CustomWindowSizeMenu 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 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 "Preset Resolution Modes"
StaticText ""
StaticText "4:3 Aspect" StaticText "4:3 Aspect"
Command "320x240", "vid_setscale 320 200" Command "320x240", "menu_resolution_set_custom 320 240"
Command "640x480", "vid_setscale 640 480" Command "640x480", "menu_resolution_set_custom 640 480"
Command "1024x768", "vid_setscale 1024 768" 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" StaticText "16:9 Aspect"
Command "960x540", "vid_setscale 960 540" Command "960x540", "menu_resolution_set_custom 960 540"
Command "1920x1080", "vid_setscale 1920 1080" 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"
OptionMenu CustomWindowSizeMenu protected Command "(1440p HD) 2560x1440", "menu_resolution_set_custom 2560 1440"
{ StaticText ""
Title "Windowed Mode Preset Sizes" StaticText "16:10 Aspect"
Command "320x200", "vid_setsize 320 200" Command "960x600", "menu_resolution_set_custom 960 600"
Command "640x480", "vid_setsize 640 480" Command "1280x800", "menu_resolution_set_custom 1280 800"
Command "960x540", "vid_setsize 960 540" Command "1440x900", "menu_resolution_set_custom 1440 900"
Command "640x480", "vid_setsize 640 480" Command "1680x1050", "menu_resolution_set_custom 1680 1050"
Command "1920x1080", "vid_setsize 1920 1080" Command "1920x1200", "menu_resolution_set_custom 1920 1200"
} }
/*======================================= /*=======================================