GUI Scripting: Getting System CVars: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(correct table)
(Insert image)
Line 6: Line 6:
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.
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]
[[File:HUD adjust screenshot.jpg|thumb|center]]


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

Revision as of 16:38, 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.

HUD adjust screenshot.jpg

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.