@@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2323#include " PicButton.h"
2424#include " Slider.h"
2525#include " CheckBox.h"
26+ #include " YesNoMessageBox.h"
2627
2728#define ART_BANNER " gfx/shell/head_vidoptions"
2829#define ART_GAMMA " gfx/shell/gamma"
@@ -61,6 +62,8 @@ class CMenuVidOptions : public CMenuFramework
6162 CMenuCheckBox overbright;
6263 CMenuCheckBox filtering;
6364 CMenuCheckBox detailtex;
65+ CMenuCheckBox hudscale;
66+ CMenuYesNoMessageBox msgBox;
6467
6568 HIMAGE hTestImage;
6669};
@@ -102,6 +105,7 @@ void CMenuVidOptions::SaveAndPopMenu( void )
102105 swwater.WriteCvar ();
103106 overbright.WriteCvar ();
104107 filtering.WriteCvar ();
108+ hudscale.WriteCvar ();
105109 // gamma and brightness is already written
106110
107111 CMenuFramework::SaveAndPopMenu ();
@@ -216,6 +220,50 @@ void CMenuVidOptions::_Init( void )
216220 filtering.SetCoord ( 72 , height );
217221 height += 50 ;
218222
223+ hudscale.szName = L ( " Auto scale HUD" );
224+ hudscale.SetCoord ( 72 , height );
225+ height += 50 ;
226+
227+ msgBox.SetMessage ( L ( " ^1WARNING: This is an experimental option and turning it on might break mods!^7\n\n Reload the game or reconnect to the server to apply the settings." ));
228+ msgBox.onNegative .pExtra = &hudscale;
229+ SET_EVENT_MULTI ( msgBox.onNegative ,
230+ {
231+ CMenuCheckBox *cb = (CMenuCheckBox *)pExtra;
232+
233+ cb->bChecked = false ;
234+ cb->SetCvarValue ( 0 .0f );
235+ });
236+
237+ SET_EVENT_MULTI ( hudscale.onChanged ,
238+ {
239+ CMenuCheckBox *cb = (CMenuCheckBox *)pSelf;
240+ CMenuVidOptions *parent = (CMenuVidOptions *)pSelf->Parent ();
241+
242+ if ( EngFuncs::ClientInGame ( ))
243+ {
244+ // bring up warning message box
245+ // FIXME: try to save the game, apply the settings, and then load it back. This will be useful when changing resolution too.
246+ parent->msgBox .Show ();
247+ }
248+ });
249+
250+ SET_EVENT_MULTI ( hudscale.onCvarWrite ,
251+ {
252+ CMenuCheckBox *cb = (CMenuCheckBox *)pSelf;
253+
254+ if ( cb->bChecked )
255+ {
256+ // automatically scale HUD as if we have 1024x768 screen
257+ // (saving aspect ratio)
258+ // FIXME: allow configuring this value?
259+ EngFuncs::CvarSetValue ( cb->CvarName (), 1024 .0f );
260+ }
261+ else
262+ {
263+ EngFuncs::CvarSetValue ( cb->CvarName (), 0 .0f );
264+ }
265+ });
266+
219267 AddItem ( banner );
220268 AddItem ( done );
221269#if LEGACY_VIEWSIZE
@@ -228,6 +276,7 @@ void CMenuVidOptions::_Init( void )
228276 AddItem ( swwater );
229277 AddItem ( overbright );
230278 AddItem ( filtering );
279+ AddItem ( hudscale );
231280 AddItem ( testImage );
232281
233282#if LEGACY_VIEWSIZE
@@ -242,6 +291,7 @@ void CMenuVidOptions::_Init( void )
242291 vbo.LinkCvar ( " gl_vbo" );
243292 overbright.LinkCvar ( " gl_overbright" );
244293 // skip filtering.LinkCvar, different names in ref_gl and ref_soft
294+ hudscale.LinkCvar ( " hud_scale" );
245295}
246296
247297void CMenuVidOptions::_VidInit ()
0 commit comments