From ee87fdc58ef219eacde1ea7cf2bc153297acc53f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 16 Sep 2010 10:59:40 +0000 Subject: [PATCH] - some layout tweaks for the option menu system, in particular to shorten the sliders if the menu is too wide. - allow specifying the fractional precision for the numbers behind the sliders. - took all HUD related options out of the display options menu and created a seaparate one for them. - added several more display and HUD options to the menu. - created a new 'Miscellaneous options' menu for a few items that should be accessible but don't fit anywhere else. SVN r2795 (trunk) --- src/menu/menudef.cpp | 6 +- src/menu/optionmenu.cpp | 41 ----------- src/menu/optionmenuitems.h | 53 +++++++++++++- wadsrc/static/menudef.txt | 145 ++++++++++++++++++++++++++++++------- 4 files changed, 172 insertions(+), 73 deletions(-) diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index 033ad599ba..8b865cbc62 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -749,13 +749,13 @@ static void ParseOptionMenuBody(FScanner &sc, FOptionMenuDescriptor *desc) sc.MustGetStringName(","); sc.MustGetFloat(); double step = sc.Float; - bool showvalue = true; + int showvalue = 1; if (sc.CheckString(",")) { sc.MustGetNumber(); - showvalue = !!sc.Number; + showvalue = sc.Number; } - FOptionMenuItem *it = new FOptionMenuSliderCVar(text, action, min, max, step, showvalue? 1:-1); + FOptionMenuItem *it = new FOptionMenuSliderCVar(text, action, min, max, step, showvalue); desc->mItems.Push(it); } else if (sc.Compare("screenresolution")) diff --git a/src/menu/optionmenu.cpp b/src/menu/optionmenu.cpp index a64f77431c..5661eec8ec 100644 --- a/src/menu/optionmenu.cpp +++ b/src/menu/optionmenu.cpp @@ -66,47 +66,6 @@ void M_DrawConText (int color, int x, int y, const char *str) TAG_DONE); } -//============================================================================= -// -// Draw a slider. Set fracdigits negative to not display the current value numerically. -// -//============================================================================= - -void M_DrawSlider (int x, int y, double min, double max, double cur,int fracdigits) -{ - double range; - - range = max - min; - double ccur = clamp(cur, min, max) - min; - - if (CleanXfac > CleanXfac_1 || CleanXfac_1 * 320 < screen->GetWidth()) - { - M_DrawConText(CR_WHITE, x, y, "\x10\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x12"); - M_DrawConText(CR_ORANGE, x + int((5 + ((ccur * 78) / range)) * CleanXfac_1), y, "\x13"); - - if (fracdigits >= 0) - { - char textbuf[16]; - mysnprintf(textbuf, countof(textbuf), "%.*f", fracdigits, cur); - screen->DrawText(SmallFont, CR_DARKGRAY, x + (12*8 + 4) * CleanXfac_1, y, textbuf, DTA_CleanNoMove_1, true, TAG_DONE); - } - } - else - { - // On 320x200 we need a shorter slider - M_DrawConText(CR_WHITE, x, y, "\x10\x11\x11\x11\x11\x11\x12"); - M_DrawConText(CR_ORANGE, x + int((5 + ((ccur * 38) / range)) * CleanXfac_1), y, "\x13"); - - if (fracdigits >= 0) - { - char textbuf[16]; - mysnprintf(textbuf, countof(textbuf), "%.*f", fracdigits, cur); - screen->DrawText(SmallFont, CR_DARKGRAY, x + (7*8 + 4) * CleanXfac_1, y, textbuf, DTA_CleanNoMove_1, true, TAG_DONE); - } - } -} - - IMPLEMENT_CLASS(DOptionMenu) diff --git a/src/menu/optionmenuitems.h b/src/menu/optionmenuitems.h index 07a72fb539..e365f60397 100644 --- a/src/menu/optionmenuitems.h +++ b/src/menu/optionmenuitems.h @@ -34,7 +34,6 @@ void M_DrawConText (int color, int x, int y, const char *str); -void M_DrawSlider (int x, int y, double min, double max, double cur,int fracdigits); void M_SetVideoMode(); @@ -551,6 +550,8 @@ class FOptionMenuSliderBase : public FOptionMenuItem double mMin, mMax, mStep; int mShowValue; int mDrawX; + int mSliderShort; + public: FOptionMenuSliderBase(const char *label, double min, double max, double step, int showval) : FOptionMenuItem(label, NAME_None) @@ -560,17 +561,63 @@ public: mStep = step; mShowValue = showval; mDrawX = 0; + mSliderShort = 0; } virtual double GetValue() = 0; virtual void SetValue(double val) = 0; + //============================================================================= + // + // Draw a slider. Set fracdigits negative to not display the current value numerically. + // + //============================================================================= + + void DrawSlider (int x, int y, double min, double max, double cur,int fracdigits, int indent) + { + char textbuf[16]; + double range; + int maxlen = 0; + int right = x + (12*8 + 4) * CleanXfac_1; + + range = max - min; + double ccur = clamp(cur, min, max) - min; + + if (fracdigits >= 0) + { + mysnprintf(textbuf, countof(textbuf), "%.*f", fracdigits, max); + maxlen = SmallFont->StringWidth(textbuf) * CleanXfac_1; + } + + mSliderShort = right + maxlen > screen->GetWidth(); + + if (!mSliderShort) + { + M_DrawConText(CR_WHITE, x, y, "\x10\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x12"); + M_DrawConText(CR_ORANGE, x + int((5 + ((ccur * 78) / range)) * CleanXfac_1), y, "\x13"); + } + else + { + // On 320x200 we need a shorter slider + M_DrawConText(CR_WHITE, x, y, "\x10\x11\x11\x11\x11\x11\x12"); + M_DrawConText(CR_ORANGE, x + int((5 + ((ccur * 38) / range)) * CleanXfac_1), y, "\x13"); + right -= 5*8*CleanXfac_1; + } + + if (fracdigits >= 0 && right + maxlen <= screen->GetWidth()) + { + mysnprintf(textbuf, countof(textbuf), "%.*f", fracdigits, cur); + screen->DrawText(SmallFont, CR_DARKGRAY, right, y, textbuf, DTA_CleanNoMove_1, true, TAG_DONE); + } + } + + //============================================================================= int Draw(FOptionMenuDescriptor *desc, int y, int indent, bool selected) { drawLabel(indent, y, selected? OptionSettings.mFontColorSelection : OptionSettings.mFontColor); mDrawX = indent + CURSORSPACE; - M_DrawSlider (mDrawX, y + OptionSettings.mLabelOffset, mMin, mMax, GetValue(), mShowValue); + DrawSlider (mDrawX, y + OptionSettings.mLabelOffset, mMin, mMax, GetValue(), mShowValue, indent); return indent; } @@ -609,7 +656,7 @@ public: } int slide_left = mDrawX+8*CleanXfac_1; - int slide_right = slide_left + 10*8*CleanXfac_1; // 12 char cells with 8 pixels each. + int slide_right = slide_left + (10*8*CleanXfac_1 >> mSliderShort); // 12 char cells with 8 pixels each. if (type == DMenu::MOUSE_Click) { diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index ee624ed751..875525ec06 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -331,6 +331,8 @@ OptionMenu "OptionsMenu" Submenu "Gameplay Options", "GameplayOptions" Submenu "Compatibility Options", "CompatibilityOptions" Submenu "Automap Options", "AutomapOptions" + Submenu "HUD Options", "HUDOptions" + Submenu "Miscellaneous Options", "MiscOptions" Submenu "Sound Options", "SoundOptions" Submenu "Display Options", "VideoOptions" Submenu "Set video mode", "VideoModeMenu" @@ -615,6 +617,48 @@ OptionValue Contrast 2.0, "Smooth" } +OptionMenu "VideoOptions" +{ + Title "DISPLAY OPTIONS" + + Submenu "Message Options", "MessageOptions" + Submenu "Scoreboard Options", "ScoreboardOptions" + StaticText " " + Slider "Screen size", "screenblocks", 3.0, 12.0, 1.0, 0 + Slider "Brightness", "Gamma", 1.0, 3.0, 0.1 + Option "Vertical Sync", "vid_vsync", "OnOff" + Option "Column render mode", "r_columnmethod", "ColumnMethods" + + StaticText " " + Option "Screen wipe style", "wipetype", "Wipes" + + IfOption(Windows) + { + Option "Show ENDOOM screen", "showendoom", "Endoom" + //Option "DirectDraw palette hack", "vid_palettehack", "OnOff" + //Option "Use attached surfaces", "vid_attachedsurfaces", "OnOff" + } + + Option "Stretch short skies", "r_stretchsky", "OnOff" + Option "Use fuzz effect", "r_drawfuzz", "YesNo" + Slider "Lost Soul translucency", "transsouls", 0.25, 1.0, 0.05, 2 + Option "Use fake contrast", "r_fakecontrast", "Contrast" + Option "Rocket Trails", "cl_rockettrails", "RocketTrailTypes" + Option "Blood Type", "cl_bloodtype", "BloodTypes" + Option "Bullet Puff Type", "cl_pufftype", "PuffTypes" + Slider "Number of particles", "r_maxparticles", 100, 10000, 100, 0 + Option "Show player sprites", "r_drawplayersprites", "OnOff" + Option "Death camera", "r_deathcamera", "OnOff" + Option "Teleporter zoom", "telezoom", "OnOff" + Option "Interpolate monster movement", "nomonsterinterpolation", "NoYes" +} + +//------------------------------------------------------------------------------------------- +// +// HUD menu +// +//------------------------------------------------------------------------------------------- + OptionValue DisplayTagsTypes { 0.0, "None" @@ -654,40 +698,89 @@ OptionValue Crosshairs // will be filled in from the XHAIRS lump } -OptionMenu "VideoOptions" +OptionMenu "HUDOptions" { - Title "DISPLAY OPTIONS" - Submenu "Message Options", "MessageOptions" - Submenu "Scoreboard Options", "ScoreboardOptions" + Title "HUD Options" + Submenu "Alternative HUD", "AltHudOptions" StaticText " " - Slider "Screen size", "screenblocks", 3.0, 12.0, 1.0 - Slider "Brightness", "Gamma", 1.0, 3.0, 0.1 - Option "Vertical Sync", "vid_vsync", "OnOff" - Option "Column render mode", "r_columnmethod", "ColumnMethods" - + Option "Default Crosshair", "crosshair", "Crosshairs" + Option "Force default crosshair", "crosshairforce", "OnOff" + Option "Grow crosshair when picking up items", "crosshairgrow", "OnOff" + ColorPicker "Crosshair color", "crosshaircolor" + Option "Crosshair shows health", "crosshairhealth", "OnOff" + Option "Scale crosshair", "crosshairscale", "OnOff" StaticText " " - Option "Crosshair", "crosshair", "Crosshairs" Option "Display nametags", "displaynametags", "DisplayTagsTypes" Option "Nametag color", "nametagcolor", "TextColors", "displaynametags" Option "Stretch status bar", "st_scale", "OnOff" - Option "Alternative HUD", "hud_althud", "OnOff" - Option "Screen wipe style", "wipetype", "Wipes" +} + +//------------------------------------------------------------------------------------------- +// +// Alternative HUD +// +//------------------------------------------------------------------------------------------- +OptionValue "AMCoordinates" +{ + 0, "Player" + 1, "Map" +} + +OptionMenu "AltHUDOptions" +{ + Title "Alternative HUD" + //Indent 220 + Option "Enable alternative HUD", "hud_althud", "OnOff" + Option "Show secret count", "hud_showsecrets", "OnOff" + Option "Show monster count", "hud_showmonsters", "OnOff" + Option "Show item count", "hud_showitems", "OnOff" + Option "Show stamina and accuracy", "hud_showstats", "OnOff" + Slider "Red ammo display below %", "hud_ammo_red", 0, 100, 1, 0 + Slider "Yellow ammo display below %", "hud_ammo_yellow", 0, 100, 1, 0 + Slider "Red health display below", "hud_health_red", 0, 100, 1, 0 + Slider "Yellow health display below", "hud_health_yellow", 0, 100, 1, 0 + Slider "Green health display below", "hud_health_green", 0, 100, 1, 0 + Slider "Red armor display below", "hud_armor_red", 0, 100, 1, 0 + Slider "Yellow armor display below", "hud_armor_yellow", 0, 100, 1, 0 + Slider "Green armor display below", "hud_armor_green", 0, 100, 1, 0 + StaticText " " + StaticText "Alternative Automap HUD", 1 + option "Map title color", "hudcolor_titl", "TextColors" + option "Hub time color", "hudcolor_time", "TextColors" + option "Map time color", "hudcolor_ltim", "TextColors" + option "Total title color", "hudcolor_ttim", "TextColors" + option "Coordinate color", "hudcolor_xyco", "TextColors" + option "Coordinate mode", "map_point_coordinates", "AMCoordinates" + option "Map title color", "hudcolor_titl", "TextColors" + option "Statistics name color", "hudcolor_statnames", "TextColors" + option "Statistics color", "hudcolor_stats", "TextColors" +} + +//------------------------------------------------------------------------------------------- +// +// Misc menu +// +//------------------------------------------------------------------------------------------- + +OptionMenu "MiscOptions" +{ + Title "Miscellaneous Options" + //Indent 220 IfOption(Windows) { - Option "Show ENDOOM screen", "showendoom", "Endoom" - //Option "DirectDraw palette hack", "vid_palettehack", "OnOff" - //Option "Use attached surfaces", "vid_attachedsurfaces", "OnOff" + Option "Merge left+right Alt/Ctrl/Shift", "k_mergekeys", "OnOff" + Option "Alt-Enter toggles fullscreen", "k_allowfullscreentoggle", "OnOff" + Option "Show IWAD selection dialog", "queryiwad", "OnOff" + StaticText " " } - + Option "Enable cheats from all games", "allcheats", "OnOff" + Option "Enable autosaves", "disableautosave", "OffOn" + Slider "Number of autosaves", "autosavecount", 1, 32, 1, 0 StaticText " " - Option "Stretch short skies", "r_stretchsky", "OnOff" - Option "Use fuzz effect", "r_drawfuzz", "YesNo" - Option "Use fake contrast", "r_fakecontrast", "Contrast" - Option "Rocket Trails", "cl_rockettrails", "RocketTrailTypes" - Option "Blood Type", "cl_bloodtype", "BloodTypes" - Option "Bullet Puff Type", "cl_pufftype", "PuffTypes" - Option "Interpolate monster movement", "nomonsterinterpolation", "NoYes" + Option "Cache nodes", "gl_cachenodes", "OnOff" + Slider "Time threshold for node caching", "gl_cachetime", 0.0, 2.0, 0.1 + SafeCommand "Clear node cache", "clearnodecache" } //------------------------------------------------------------------------------------------- @@ -941,7 +1034,7 @@ OptionValue JumpCrouch OptionMenu GameplayOptions { Title "GAMEPLAY OPTIONS" - Indent 222 + //Indent 222 Option "Teamplay", "teamplay", "OnOff" Slider "Team damage scalar", "teamdamage", 0, 1, 0.05 StaticText " " @@ -1185,9 +1278,9 @@ OptionMenu SoundOptions Option "MIDI device", "snd_mididevice", "MidiDevices" StaticText " " Option "Underwater reverb", "snd_waterreverb", "OnOff" - Slider "Underwater cutoff", "snd_waterlp", 0, 2000, 50 + Slider "Underwater cutoff", "snd_waterlp", 0, 2000, 50, 0 Option "Randomize pitches", "snd_pitched", "OnOff" - Slider "Sound channels", "snd_channels", 8, 256, 8 + Slider "Sound channels", "snd_channels", 8, 256, 8, 0 StaticText " " Command "Restart sound", "snd_reset" StaticText " "