GUI Scripting: Getting System CVars: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Geep (talk | contribs)
create this article
 
Geep (talk | contribs)
correct table
Line 19: Line 19:
|-
|-
|tdm_hud_opacity 0.7
|tdm_hud_opacity 0.7
|HUD_Opacity
|gui::HUD_Opacity
|The opacity of the HUD GUIs. [0..1]
|-
|gui_iconSize 1.0
|gui_iconSize 1.0
|iconSize
|gui::iconSize
|Specifies the size of the icons used by the hud
|-
|gui_smallTextSize 1.0
|gui_smallTextSize 1.0
|smallTextSize
|gui::smallTextSize
|Specifies the text size used for inventory and weapons
|-
|gui_bigTextSize 1.0
|gui_bigTextSize 1.0
|bigTextSize
|gui::bigTextSize
|Specifies the text size of ingame notifications [like “Objective Completed”]
|-
|gui_lightgemSize 1.0
|gui_lightgemSize 1.0
|lightgemSize
|gui::lightgemSize
|Specifies the size of the lightgem
|-
|gui_barSize 1.0
|gui_barSize 1.0
|barSize
|gui::barSize
|Specifies the size of the health and breath bar
|-
|gui_objectiveTextSize 1.0
|gui_objectiveTextSize 1.0
|-
|HUD_Opacity
|iconSize
|smallTextSize
|bigTextSize
|lightgemSize
|barSize
|objectiveTextSize
|objectiveTextSize
|-
|gui::HUD_Opacity
|gui::iconSize
|gui::smallTextSize
|gui::bigTextSize
|gui::lightgemSize
|gui::barSize
|gui::objectiveTextSize
|gui::objectiveTextSize
|-
|The opacity of the HUD GUIs. [0..1]
|Specifies the size of the icons used by the hud
|Specifies the text size used for inventory and weapons
|Specifies the text size of ingame notifications [like “Objective Completed”]
|Specifies the size of the lightgem
|Specifies the size of the health and breath bar
|Specifies the size of the objectives text
|Specifies the size of the objectives text
|}
|}

Revision as of 16:08, 10 July 2022

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.

[picture]

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 Reference in .script code Reference in GUI code Description seen in menu tool tip
tdm_hud_opacity 0.7 HUD_Opacity gui::HUD_Opacity The opacity of the HUD GUIs. [0..1]
gui_iconSize 1.0 iconSize gui::iconSize Specifies the size of the icons used by the hud
gui_smallTextSize 1.0 smallTextSize gui::smallTextSize Specifies the text size used for inventory and weapons
gui_bigTextSize 1.0 bigTextSize gui::bigTextSize Specifies the text size of ingame notifications [like “Objective Completed”]
gui_lightgemSize 1.0 lightgemSize gui::lightgemSize Specifies the size of the lightgem
gui_barSize 1.0 barSize gui::barSize Specifies the size of the health and breath bar
gui_objectiveTextSize 1.0 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;
}

There is also the corresponding setcvar function:

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

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

Note: a list of all CVars and their short descriptions can be found in source code Syscvar.cpp.