GUI Scripting: Getting System CVars: Difference between revisions
Add "For More" |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 14: | Line 14: | ||
|- | |- | ||
|CVar in console & default value | |CVar in console & default value | ||
|Settings slider range | |||
|Reference in .script code | |Reference in .script code | ||
|Reference in GUI code | |Reference in GUI code | ||
Line 19: | Line 20: | ||
|- | |- | ||
|tdm_hud_opacity 0.7 | |tdm_hud_opacity 0.7 | ||
|0.0-1.0, step 0.1 | |||
|HUD_Opacity | |HUD_Opacity | ||
|gui::HUD_Opacity | |gui::HUD_Opacity | ||
Line 24: | Line 26: | ||
|- | |- | ||
|gui_iconSize 1.0 | |gui_iconSize 1.0 | ||
|0.5-1.8, step 0.1 | |||
|iconSize | |iconSize | ||
|gui::iconSize | |gui::iconSize | ||
Line 29: | Line 32: | ||
|- | |- | ||
|gui_smallTextSize 1.0 | |gui_smallTextSize 1.0 | ||
|0.75-1.25, step 0.05 | |||
|smallTextSize | |smallTextSize | ||
|gui::smallTextSize | |gui::smallTextSize | ||
Line 34: | Line 38: | ||
|- | |- | ||
|gui_bigTextSize 1.0 | |gui_bigTextSize 1.0 | ||
|0.5-1.8, step 0.1 | |||
|bigTextSize | |bigTextSize | ||
|gui::bigTextSize | |gui::bigTextSize | ||
Line 39: | Line 44: | ||
|- | |- | ||
|gui_lightgemSize 1.0 | |gui_lightgemSize 1.0 | ||
|0.5-1.8, step 0.1 | |||
|lightgemSize | |lightgemSize | ||
|gui::lightgemSize | |gui::lightgemSize | ||
Line 44: | Line 50: | ||
|- | |- | ||
|gui_barSize 1.0 | |gui_barSize 1.0 | ||
|0.7-1.3, step 0.1 | |||
|barSize | |barSize | ||
|gui::barSize | |gui::barSize | ||
Line 49: | Line 56: | ||
|- | |- | ||
|gui_objectiveTextSize 1.0 | |gui_objectiveTextSize 1.0 | ||
|0.75-1.4, step 0.1 | |||
|objectiveTextSize | |objectiveTextSize | ||
|gui::objectiveTextSize | |gui::objectiveTextSize | ||
Line 72: | Line 80: | ||
==For More== | ==For More== | ||
* A list of all CVars and their short descriptions can be found in source code Syscvar.cpp. | * A list of all CVars and their short descriptions can be found in source code Syscvar.cpp. | ||
* [[Adding new Cvars]] | * [[Adding new Cvars]], which explains | ||
** ways to list and change CVars from the console; | |||
** how to create custom CVars specific to your FM session, with scripting. | |||
* [[Console Useful Controls]] | * [[Console Useful Controls]] | ||
* [[Cvars in The Dark Mod]] | * [[Cvars in The Dark Mod]] | ||
[[Category:CVARS]] | |||
{{GUI|sort=GUI Scripting: CVars}} |
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:
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
- A list of all CVars and their short descriptions can be found in source code Syscvar.cpp.
- Adding new Cvars, which explains
- ways to list and change CVars from the console;
- how to create custom CVars specific to your FM session, with scripting.
- Console Useful Controls
- Cvars in The Dark Mod