-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Weapon Help Text & Object Description HUD Elements
Closes #10
- Loading branch information
1 parent
ade89ef
commit 63d9647
Showing
7 changed files
with
410 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
class UZObjectDescription : HUDElement { | ||
|
||
private Service _HHFunc; | ||
|
||
private transient CVar _enabled; | ||
private transient CVar _hlm_required; | ||
|
||
private transient CVar _hlm_hudLevel; | ||
private transient CVar _hlm_posX; | ||
private transient CVar _hlm_posY; | ||
private transient CVar _hlm_scale; | ||
private transient CVar _nhm_hudLevel; | ||
private transient CVar _nhm_posX; | ||
private transient CVar _nhm_posY; | ||
private transient CVar _nhm_scale; | ||
|
||
private transient CVar _nhm_bgRef; | ||
private transient CVar _nhm_bgPosX; | ||
private transient CVar _nhm_bgPosY; | ||
private transient CVar _nhm_bgScale; | ||
private transient CVar _hlm_bgRef; | ||
private transient CVar _hlm_bgPosX; | ||
private transient CVar _hlm_bgPosY; | ||
private transient CVar _hlm_bgScale; | ||
|
||
override void Init(HCStatusbar sb) { | ||
ZLayer = 0; | ||
Namespace = "objectdescription"; | ||
} | ||
|
||
override void Tick(HCStatusbar sb) { | ||
if (!_HHFunc) _HHFunc = ServiceIterator.Find("HHFunc").Next(); | ||
|
||
if (!_enabled) _enabled = CVar.GetCVar("uz_hhx_objectDescription_enabled", sb.CPlayer); | ||
if (!_hlm_required) _hlm_required = CVar.GetCVar("uz_hhx_objectDescription_hlm_required", sb.CPlayer); | ||
if (!_hlm_hudLevel) _hlm_hudLevel = CVar.GetCVar("uz_hhx_objectDescription_hlm_hudLevel", sb.CPlayer); | ||
if (!_hlm_posX) _hlm_posX = CVar.GetCVar("uz_hhx_objectDescription_hlm_posX", sb.CPlayer); | ||
if (!_hlm_posY) _hlm_posY = CVar.GetCVar("uz_hhx_objectDescription_hlm_posY", sb.CPlayer); | ||
if (!_hlm_scale) _hlm_scale = CVar.GetCVar("uz_hhx_objectDescription_hlm_scale", sb.CPlayer); | ||
if (!_nhm_hudLevel) _nhm_hudLevel = CVar.GetCVar("uz_hhx_objectDescription_nhm_hudLevel", sb.CPlayer); | ||
if (!_nhm_posX) _nhm_posX = CVar.GetCVar("uz_hhx_objectDescription_nhm_posX", sb.CPlayer); | ||
if (!_nhm_posY) _nhm_posY = CVar.GetCVar("uz_hhx_objectDescription_nhm_posY", sb.CPlayer); | ||
if (!_nhm_scale) _nhm_scale = CVar.GetCVar("uz_hhx_objectDescription_nhm_scale", sb.CPlayer); | ||
|
||
if (!_nhm_bgRef) _nhm_bgRef = CVar.GetCVar("uz_hhx_objectDescription_bg_nhm_ref", sb.CPlayer); | ||
if (!_nhm_bgPosX) _nhm_bgPosX = CVar.GetCVar("uz_hhx_objectDescription_bg_nhm_posX", sb.CPlayer); | ||
if (!_nhm_bgPosY) _nhm_bgPosY = CVar.GetCVar("uz_hhx_objectDescription_bg_nhm_posY", sb.CPlayer); | ||
if (!_nhm_bgScale) _nhm_bgScale = CVar.GetCVar("uz_hhx_objectDescription_bg_nhm_scale", sb.CPlayer); | ||
if (!_hlm_bgRef) _hlm_bgRef = CVar.GetCVar("uz_hhx_objectDescription_bg_hlm_ref", sb.CPlayer); | ||
if (!_hlm_bgPosX) _hlm_bgPosX = CVar.GetCVar("uz_hhx_objectDescription_bg_hlm_posX", sb.CPlayer); | ||
if (!_hlm_bgPosY) _hlm_bgPosY = CVar.GetCVar("uz_hhx_objectDescription_bg_hlm_posY", sb.CPlayer); | ||
if (!_hlm_bgScale) _hlm_bgScale = CVar.GetCVar("uz_hhx_objectDescription_bg_hlm_scale", sb.CPlayer); | ||
} | ||
|
||
override void DrawHUDStuff(HCStatusbar sb, int state, double ticFrac) { | ||
bool hasHelmet = _HHFunc && _HHFunc.GetIntUI("GetShowHUD", objectArg: sb.hpl); | ||
int hudLevel = hasHelmet ? _hlm_hudLevel.GetInt() : _nhm_hudLevel.GetInt(); | ||
|
||
if ( | ||
!_enabled.GetBool() | ||
|| (!hasHelmet && _hlm_required.GetBool()) | ||
|| HDSpectator(sb.hpl) | ||
|| !(sb.HUDLevel >= hudLevel) | ||
) return; | ||
|
||
if (CheckCommonStuff(sb, state, ticFrac)) { | ||
|
||
int posX = hasHelmet ? _hlm_posX.GetInt() : _nhm_posX.GetInt(); | ||
int posY = hasHelmet ? _hlm_posY.GetInt() : _nhm_posY.GetInt(); | ||
float scale = hasHelmet ? _hlm_scale.GetFloat() : _nhm_scale.GetFloat(); | ||
|
||
string bgRef = hasHelmet ? _hlm_bgRef.GetString() : _nhm_bgRef.GetString(); | ||
int bgPosX = hasHelmet ? _hlm_bgPosX.GetInt() : _nhm_bgPosX.GetInt(); | ||
int bgPosY = hasHelmet ? _hlm_bgPosY.GetInt() : _nhm_bgPosY.GetInt(); | ||
float bgScale = hasHelmet ? _hlm_bgScale.GetFloat() : _nhm_bgScale.GetFloat(); | ||
|
||
string s = sb.hpl.viewstring; | ||
if (s != "") { | ||
sb.drawstring( | ||
sb.pnewsmallfont, | ||
s, | ||
(posX,posY), | ||
sb.DI_SCREEN_CENTER|sb.DI_TEXT_ALIGN_CENTER, | ||
Font.CR_GREY, | ||
0.4, | ||
scale:(scale, scale) | ||
); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.