GUI Scripting: Getting System CVars: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Geep (talk | contribs)
→‎CVars Available Directly: HUD Related: Add "Settings slider range" column to table
Geep (talk | contribs)
 
Line 32: Line 32:
|-
|-
|gui_smallTextSize 1.0
|gui_smallTextSize 1.0
|0.75-1.24, step 0.05
|0.75-1.25, step 0.05
|smallTextSize
|smallTextSize
|gui::smallTextSize
|gui::smallTextSize

Latest revision as of 16:00, 15 January 2024

This page is part of a series. See GUI Scripting Language for overview.

Since CVars are user settings, you usually don’t want to change them in your GUI, just read them.

CVars Available Directly: HUD Related

You can scale the objects shown in TDM’s HUD display. In TDM’s main menu, under Settings/Video/Advanced/, there is the “HUD Size/Opacity” option. If you click on “Adjust” of this, a special screen is brought up (see image). This lets you adjust and preview representative HUD elements with sliders. Slider positions correspond to underlying CVar float values.

These CVars are copied into a global GUI overlay dictionary and can be read directly from there in your GUI code:

Predefined GUI:: Parameters for Heads-Up Display
CVar in console & default value Settings slider range Reference in .script code Reference in GUI code Description seen in menu tool tip
tdm_hud_opacity 0.7 0.0-1.0, step 0.1 HUD_Opacity gui::HUD_Opacity The opacity of the HUD GUIs. [0..1]
gui_iconSize 1.0 0.5-1.8, step 0.1 iconSize gui::iconSize Specifies the size of the icons used by the hud
gui_smallTextSize 1.0 0.75-1.25, step 0.05 smallTextSize gui::smallTextSize Specifies the text size used for inventory and weapons
gui_bigTextSize 1.0 0.5-1.8, step 0.1 bigTextSize gui::bigTextSize Specifies the text size of ingame notifications [like “Objective Completed”]
gui_lightgemSize 1.0 0.5-1.8, step 0.1 lightgemSize gui::lightgemSize Specifies the size of the lightgem
gui_barSize 1.0 0.7-1.3, step 0.1 barSize gui::barSize Specifies the size of the health and breath bar
gui_objectiveTextSize 1.0 0.75-1.4, step 0.1 objectiveTextSize gui::objectiveTextSize Specifies the size of the objectives text

This may be of particular interest if you intend to extend the HUD with your own content, appropriately scaled. For a use case for this, see the 2020 forum post by MirceaKitsune.

CVars Available Via .Script Function

Other CVars you might need can be accessed in an associated script object or other .script file, where, for example, you could create an intermediary wrapper function to call:

float GetShowHud(){
  if(sys.getcvar("g_showhud")=="1")
    return 1;
  return 0;
}

Once acquired in the script function, you can pass the value on with a GUI:: parameter if desired; see GUI Scripting: GUI:: Parameters.

Also, there is the corresponding setcvar function:

sys.setcvar("g_showhud","0");

See [elsewhere] about calling script functions from entities with GUI scripts.

For More