Skip to content

Commit

Permalink
Merge pull request #73 from UndeadZeratul/develop
Browse files Browse the repository at this point in the history
Add Safety Check to getting font for HUD Elements
  • Loading branch information
UndeadZeratul authored Jan 19, 2024
2 parents c00bb9b + 4ee5eb4 commit ea74449
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 13 deletions.
3 changes: 2 additions & 1 deletion zscript/undeadzeratul/base/BaseCounter.zs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ class BaseCounterHUDElement : HUDElement abstract {

string newFont = _font.GetString();
if (_prevFont != newFont) {
_hudFont = HUDFont.create(Font.FindFont(newFont));
let font = Font.FindFont(newFont);
_hudFont = HUDFont.create(font ? font : Font.FindFont('NewSmallFont'));
_prevFont = newFont;
}
}
Expand Down
3 changes: 2 additions & 1 deletion zscript/undeadzeratul/elements/UZAmmoCounters.zs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class UZAmmoCounters : HUDAmmoCounters {

string newFont = _font.GetString();
if (_prevFont != newFont) {
_hudFont = HUDFont.create(Font.FindFont(newFont));
let font = Font.FindFont(newFont);
_hudFont = HUDFont.create(font ? font : Font.FindFont('NewSmallFont'));
_prevFont = newFont;
}
}
Expand Down
3 changes: 2 additions & 1 deletion zscript/undeadzeratul/elements/UZArmour.zs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ class UZArmour : HUDElement {

string newFont = _font.GetString();
if (_prevFont != newFont) {
_hudFont = HUDFont.create(Font.FindFont(newFont));
let font = Font.FindFont(newFont);
_hudFont = HUDFont.create(font ? font : Font.FindFont('NewSmallFont'));
_prevFont = newFont;
}
}
Expand Down
3 changes: 2 additions & 1 deletion zscript/undeadzeratul/elements/UZCompass.zs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class UZCompass : HUDCompass {

string newFont = _font.GetString();
if (_prevFont != newFont) {
_hudFont = HUDFont.create(Font.FindFont(newFont));
let font = Font.FindFont(newFont);
_hudFont = HUDFont.create(font ? font : Font.FindFont('NewSmallFont'));
_prevFont = newFont;
}
}
Expand Down
3 changes: 2 additions & 1 deletion zscript/undeadzeratul/elements/UZEKG.zs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class UZEKG : HUDEKG {

string newFont = _font.GetString();
if (_prevFont != newFont) {
_hudFont = HUDFont.create(Font.FindFont(newFont));
let font = Font.FindFont(newFont);
_hudFont = HUDFont.create(font ? font : Font.FindFont('NewSmallFont'));
_prevFont = newFont;
}
}
Expand Down
3 changes: 2 additions & 1 deletion zscript/undeadzeratul/elements/UZEncumbrance.zs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class UZEncumbrance : HUDEncumbrance {

string newFont = _font.GetString();
if (_prevFont != newFont) {
_hudFont = HUDFont.create(Font.FindFont(newFont));
let font = Font.FindFont(newFont);
_hudFont = HUDFont.create(font ? font : Font.FindFont('NewSmallFont'));
_prevFont = newFont;
}
}
Expand Down
3 changes: 2 additions & 1 deletion zscript/undeadzeratul/elements/UZInventory.zs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class UZInventory : HUDInventory {

string newFont = _font.GetString();
if (_prevFont != newFont) {
_hudFont = HUDFont.create(Font.FindFont(newFont));
let font = Font.FindFont(newFont);
_hudFont = HUDFont.create(font ? font : Font.FindFont('NewSmallFont'));
_prevFont = newFont;
}
}
Expand Down
3 changes: 2 additions & 1 deletion zscript/undeadzeratul/elements/UZObjectDescription.zs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class UZObjectDescription : HUDElement {

string newFont = _font.GetString();
if (_prevFont != newFont) {
_hudFont = HUDFont.create(Font.FindFont(newFont));
let font = Font.FindFont(newFont);
_hudFont = HUDFont.create(font ? font : Font.FindFont('NewSmallFont'));
_prevFont = newFont;
}
}
Expand Down
3 changes: 2 additions & 1 deletion zscript/undeadzeratul/elements/UZPosition.zs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class UZPosition : HUDPosition {

string newFont = _font.GetString();
if (_prevFont != newFont) {
_hudFont = HUDFont.create(Font.FindFont(newFont));
let font = Font.FindFont(newFont);
_hudFont = HUDFont.create(font ? font : Font.FindFont('NewSmallFont'));
_prevFont = newFont;
}
}
Expand Down
3 changes: 2 additions & 1 deletion zscript/undeadzeratul/elements/UZSquadStatus.zs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ class UZSquadStatus : HUDElement {

string newFont = _font.GetString();
if (_prevFont != newFont) {
_hudFont = HUDFont.create(Font.FindFont(newFont));
let font = Font.FindFont(newFont);
_hudFont = HUDFont.create(font ? font : Font.FindFont('NewSmallFont'));
_prevFont = newFont;
}
}
Expand Down
3 changes: 2 additions & 1 deletion zscript/undeadzeratul/elements/UZWeaponHelp.zs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class UZWeaponHelp : HUDElement {

string newFont = _font.GetString();
if (_prevFont != newFont) {
_hudFont = HUDFont.create(Font.FindFont(newFont));
let font = Font.FindFont(newFont);
_hudFont = HUDFont.create(font ? font : Font.FindFont('NewSmallFont'));
_prevFont = newFont;
}
}
Expand Down
3 changes: 2 additions & 1 deletion zscript/undeadzeratul/elements/UZWeaponStash.zs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class UZWeaponStash : HUDWeaponStash {

string newFont = _font.GetString();
if (_prevFont != newFont) {
_hudFont = HUDFont.create(Font.FindFont(newFont));
let font = Font.FindFont(newFont);
_hudFont = HUDFont.create(font ? font : Font.FindFont('NewSmallFont'));
_prevFont = newFont;
}
}
Expand Down
3 changes: 2 additions & 1 deletion zscript/undeadzeratul/elements/UZWoundCounter.zs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class UZWoundCounter : HUDElement {

string newFont = _font.GetString();
if (_prevFont != newFont) {
_hudFont = HUDFont.create(Font.FindFont(newFont));
let font = Font.FindFont(newFont);
_hudFont = HUDFont.create(font ? font : Font.FindFont('NewSmallFont'));
_prevFont = newFont;
}

Expand Down

0 comments on commit ea74449

Please sign in to comment.