GUI Scripting: Getting System CVars: Difference between revisions
Add "For More" |
|||
Line 70: | Line 70: | ||
See [elsewhere] about calling script functions from entities with GUI scripts. | See [elsewhere] about calling script functions from entities with GUI scripts. | ||
==For More== | |||
* A list of all CVars and their short descriptions can be found in source code Syscvar.cpp. | |||
* [[Adding new Cvars]] | |||
* [[Console Useful Controls]] | |||
* [[Cvars in The Dark Mod]] |
Revision as of 02:45, 6 September 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.
These CVars are copied into a global GUI overlay dictionary and can be read directly from there in your GUI code:
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; }
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
- A list of all CVars and their short descriptions can be found in source code Syscvar.cpp.
- Adding new Cvars
- Console Useful Controls
- Cvars in The Dark Mod