Skip to content

Commit

Permalink
Custom NUGHUD fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlaux committed May 9, 2023
1 parent 0a8c0d0 commit 7af75fb
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 20 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
- _**"Use" Button Timer**_ setting
- _**Teleport Timer**_ setting
- _**Key Pickup Timer**_ setting
- **NUGHUD:**
- Now support custom fonts for numbered Status Bar widgets
- Now allows to relocate the _Level Name_, _Coordinates_ and _FPS_ text lines
- Now allows to specify an alignment for supported text lines
- Reverted X and Y position maximums back to 320 and 200 respectively, and maximum weapon height back to 200

## Changes

Expand All @@ -14,9 +19,6 @@
- **FOV is now changed gradually** in most cases
- **Reduced turning/freelook sensitivity when zoomed in**
- **Weapons are now lowered when zooming in**
- **The _Level Name_, _Coordinates_ and _FPS_ displays can now be relocated with NUGHUD**
- **Text lines supported by NUGHUD can now be given a specific alignment**
- **Reverted NUGHUD X and Y position maximums back to 320 and 200 respectively, and maximum weapon height back to 200**
- **Automap position isn't reset to player position when opening it with Follow Mode off**
- **Adjusted _"Seizure"_ screen wipe's speed** to match _"Melt"_ and _"Fade"_
- **FOV changes are now disabled in Strict Mode only**
Expand Down
24 changes: 23 additions & 1 deletion docs/nughud.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The following widgets are available:
```
nughud_ammo ----- Ammo count for the currently-equipped weapon
nughud_health --- Health count
nughud_arms# ---- Arms number, where # is a number between 2 and 9 (inclusive)
nughud_arms# ---- Arms (weapon) number, where # is a number between 2 and 9 (inclusive)
nughud_frags ---- Frags count, only shown during Deathmatch games
nughud_face ----- Face (Mugshot)
nughud_armor ---- Armor count
Expand Down Expand Up @@ -60,6 +60,28 @@ nughud_frags_y 155
nughud_frags_wide 1
```

**`NUGHUD` supports custom fonts for all numbered widgets.**
Graphics for all characters of a given font must be provided for the font to be used, else the Vanilla font will be used.

The following fonts are available:

```
Tall Numbers, used for the Health, Armor and current-weapon Ammo counts:
NHTNUM# -- Number, where # is a number between 0 and 9 (inclusive)
NHTMINUS - Minus sign
NHTPRCNT - Percent sign
Ammo Numbers, used for the Ammo and Max Ammo counts:
NHAMNUM# - Number, where # is a number between 0 and 9 (inclusive)
Arms Numbers, used for the weapon numbers:
NHW0NUM# - Weapon unavailable, where # is a number between 1 and 9 (inclusive)
NHW1NUM# - Weapon available, where # is a number between 1 and 9 (inclusive)
```

### Text Lines

The following text lines are available:
Expand Down
2 changes: 2 additions & 0 deletions src/m_nughud.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ typedef struct nughud_s {
nughud_textline_t fps;
nughud_patch_t patches[NUMNUGHUDPATCHES];
fixed_t weapheight;
// These determine whether or not a given NUGHUD font should be used
boolean nhtnum, nhamnum, nhwpnum;
} nughud_t;

extern nughud_t nughud;
Expand Down
113 changes: 97 additions & 16 deletions src/st_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ static patch_t *armsbg;
// [Nugget] Increase the range for Alternative Arms display
static patch_t *arms[8][2];

// [Nugget] NUGHUD fonts
static patch_t *nughud_tallnum[10]; // NHTNUM#, from 0 to 9
static patch_t *nughud_tallminus; // NHTMINUS
static patch_t *nughud_tallpercent; // NHTPRCNT
static patch_t *nughud_ammonum[10]; // NHAMNUM#, from 0 to 9
static patch_t *nughud_armsnum[9][2]; // NHW0NUM# and NHW1NUM#, from 1 to 9

// ready-weapon widget
static st_number_t w_ready;

Expand Down Expand Up @@ -1155,6 +1162,62 @@ void ST_loadGraphics(void)
break;
}
have_xdthfaces = i;

{ // [Nugget] NUGHUD fonts
int lump;

nughud.nhtnum = nughud.nhamnum = nughud.nhwpnum = true;

for (i = 0; i < 10; i++) { // Load NHTNUM0 to NHTNUM9
sprintf(namebuf, "NHTNUM%d", i);
if ((lump = (W_CheckNumForName)(namebuf, ns_global)) > -1)
{ nughud_tallnum[i] = (patch_t *) W_CacheLumpNum(lump, PU_STATIC); }
else {
nughud.nhtnum = false;
break;
}
}

// Load NHTMINUS
if (nughud.nhtnum && (lump = (W_CheckNumForName)("NHTMINUS", ns_global)) > -1)
{ nughud_tallminus = (patch_t *) W_CacheLumpNum(lump, PU_STATIC); }
else
{ nughud.nhtnum = false; }

// Load NHTPRCNT
if (nughud.nhtnum && (lump = (W_CheckNumForName)("NHTPRCNT", ns_global)) > -1)
{ nughud_tallpercent = (patch_t *) W_CacheLumpNum(lump, PU_STATIC); }
else
{ nughud.nhtnum = false; }

for (i = 0; i < 10; i++) { // Load NHAMNUM0 to NHAMNUM9
M_snprintf(namebuf, sizeof(namebuf), "NHAMNUM%d", i);
if ((lump = (W_CheckNumForName)(namebuf, ns_global)) > -1)
{ nughud_ammonum[i] = (patch_t *) W_CacheLumpNum(lump, PU_STATIC); }
else {
nughud.nhamnum = false;
break;
}
}

for (i = 0; i < 9; i++) {
sprintf(namebuf, "NHW0NUM%d", i+1); // Load NHW0NUM1 to NHW0NUM9
if ((lump = (W_CheckNumForName)(namebuf, ns_global)) > -1)
{ nughud_armsnum[i][0] = (patch_t *) W_CacheLumpNum(lump, PU_STATIC); }
else {
nughud.nhwpnum = false;
break;
}

sprintf(namebuf, "NHW1NUM%d", i+1); // Load NHW1NUM1 to NHW1NUM9
if ((lump = (W_CheckNumForName)(namebuf, ns_global)) > -1)
{ nughud_armsnum[i][1] = (patch_t *) W_CacheLumpNum(lump, PU_STATIC); }
else {
nughud.nhwpnum = false;
break;
}
}
}
}

void ST_loadData(void)
Expand Down Expand Up @@ -1201,6 +1264,21 @@ void ST_unloadGraphics(void)
Z_ChangeTag(faces[i], PU_CACHE);

// Note: nobody ain't seen no unloading of stminus yet. Dude.

// [Nugget] NUGHUD fonts

for (i = 0; i < 10; i++) {
Z_ChangeTag(nughud_tallnum[i], PU_CACHE);
Z_ChangeTag(nughud_ammonum[i], PU_CACHE);
}

for (i = 0; i < 9; i++) {
Z_ChangeTag(nughud_armsnum[i][0], PU_CACHE);
Z_ChangeTag(nughud_armsnum[i][1], PU_CACHE);
}

Z_ChangeTag(nughud_tallminus, PU_CACHE);
Z_ChangeTag(nughud_tallpercent, PU_CACHE);
}

void ST_unloadData(void)
Expand Down Expand Up @@ -1249,7 +1327,7 @@ void ST_createWidgets(void)
STlib_initNum(&w_ready,
(st_crispyhud ? nughud.ammo.x : ST_AMMOX) + (delta*nughud.ammo.wide),
(st_crispyhud ? nughud.ammo.y : ST_AMMOY),
tallnum,
((st_crispyhud && nughud.nhtnum) ? nughud_tallnum : tallnum),
&plyr->ammo[weaponinfo[plyr->readyweapon].ammo],
&st_statusbaron,
ST_AMMOWIDTH );
Expand All @@ -1261,18 +1339,20 @@ void ST_createWidgets(void)
STlib_initPercent(&w_health,
(st_crispyhud ? nughud.health.x : ST_HEALTHX) + (delta*nughud.health.wide),
(st_crispyhud ? nughud.health.y : ST_HEALTHY),
tallnum,
((st_crispyhud && nughud.nhtnum) ? nughud_tallnum : tallnum),
&st_health,
&st_statusbaron,
tallpercent);
((st_crispyhud && nughud.nhtnum) ? nughud_tallpercent : tallpercent));

// weapons owned
if (st_crispyhud) {
for (i=0; i<8; i++)
for (i = 0; i < 8; i++)
STlib_initMultIcon(&w_arms[i],
nughud.arms[i].x + (delta*nughud.arms[i].wide),
nughud.arms[i].y,
arms[i], (int *) &plyr->weaponowned[i+1], &st_armson);
(nughud.nhwpnum ? nughud_armsnum[i+1] : arms[i]),
(int *) &plyr->weaponowned[i+1],
&st_armson);
}
else {
for(i=0;i<6;i++) {
Expand All @@ -1292,7 +1372,7 @@ void ST_createWidgets(void)
STlib_initNum(&w_frags,
(st_crispyhud ? nughud.frags.x : ST_FRAGSX) + (delta*nughud.frags.wide),
(st_crispyhud ? nughud.frags.y : ST_FRAGSY),
tallnum,
((st_crispyhud && nughud.nhtnum) ? nughud_tallnum : tallnum),
&st_fragscount,
&st_fragson,
ST_FRAGSWIDTH);
Expand All @@ -1309,9 +1389,10 @@ void ST_createWidgets(void)
STlib_initPercent(&w_armor,
(st_crispyhud ? nughud.armor.x : ST_ARMORX) + (delta*nughud.armor.wide),
(st_crispyhud ? nughud.armor.y : ST_ARMORY),
tallnum,
((st_crispyhud && nughud.nhtnum) ? nughud_tallnum : tallnum),
&st_armor,
&st_statusbaron, tallpercent);
&st_statusbaron,
((st_crispyhud && nughud.nhtnum) ? nughud_tallpercent : tallpercent));

// keyboxes 0-2
STlib_initMultIcon(&w_keyboxes[0],
Expand Down Expand Up @@ -1339,31 +1420,31 @@ void ST_createWidgets(void)
STlib_initNum(&w_ammo[0],
(st_crispyhud ? nughud.ammos[0].x : ST_AMMO0X) + (delta*nughud.ammos[0].wide),
(st_crispyhud ? nughud.ammos[0].y : ST_AMMO0Y),
shortnum,
((st_crispyhud && nughud.nhamnum) ? nughud_ammonum : shortnum),
&plyr->ammo[0],
&st_statusbaron,
ST_AMMO0WIDTH);

STlib_initNum(&w_ammo[1],
(st_crispyhud ? nughud.ammos[1].x : ST_AMMO1X) + (delta*nughud.ammos[1].wide),
(st_crispyhud ? nughud.ammos[1].y : ST_AMMO1Y),
shortnum,
((st_crispyhud && nughud.nhamnum) ? nughud_ammonum : shortnum),
&plyr->ammo[1],
&st_statusbaron,
ST_AMMO1WIDTH);

STlib_initNum(&w_ammo[2],
(st_crispyhud ? nughud.ammos[2].x : ST_AMMO2X) + (delta*nughud.ammos[2].wide),
(st_crispyhud ? nughud.ammos[2].y : ST_AMMO2Y),
shortnum,
((st_crispyhud && nughud.nhamnum) ? nughud_ammonum : shortnum),
&plyr->ammo[2],
&st_statusbaron,
ST_AMMO2WIDTH);

STlib_initNum(&w_ammo[3],
(st_crispyhud ? nughud.ammos[3].x : ST_AMMO3X) + (delta*nughud.ammos[3].wide),
(st_crispyhud ? nughud.ammos[3].y : ST_AMMO3Y),
shortnum,
((st_crispyhud && nughud.nhamnum) ? nughud_ammonum : shortnum),
&plyr->ammo[3],
&st_statusbaron,
ST_AMMO3WIDTH);
Expand All @@ -1372,31 +1453,31 @@ void ST_createWidgets(void)
STlib_initNum(&w_maxammo[0],
(st_crispyhud ? nughud.maxammos[0].x : ST_MAXAMMO0X) + (delta*nughud.maxammos[0].wide),
(st_crispyhud ? nughud.maxammos[0].y : ST_MAXAMMO0Y),
shortnum,
((st_crispyhud && nughud.nhamnum) ? nughud_ammonum : shortnum),
&plyr->maxammo[0],
&st_statusbaron,
ST_MAXAMMO0WIDTH);

STlib_initNum(&w_maxammo[1],
(st_crispyhud ? nughud.maxammos[1].x : ST_MAXAMMO1X) + (delta*nughud.maxammos[1].wide),
(st_crispyhud ? nughud.maxammos[1].y : ST_MAXAMMO1Y),
shortnum,
((st_crispyhud && nughud.nhamnum) ? nughud_ammonum : shortnum),
&plyr->maxammo[1],
&st_statusbaron,
ST_MAXAMMO1WIDTH);

STlib_initNum(&w_maxammo[2],
(st_crispyhud ? nughud.maxammos[2].x : ST_MAXAMMO2X) + (delta*nughud.maxammos[2].wide),
(st_crispyhud ? nughud.maxammos[2].y : ST_MAXAMMO2Y),
shortnum,
((st_crispyhud && nughud.nhamnum) ? nughud_ammonum : shortnum),
&plyr->maxammo[2],
&st_statusbaron,
ST_MAXAMMO2WIDTH);

STlib_initNum(&w_maxammo[3],
(st_crispyhud ? nughud.maxammos[3].x : ST_MAXAMMO3X) + (delta*nughud.maxammos[3].wide),
(st_crispyhud ? nughud.maxammos[3].y : ST_MAXAMMO3Y),
shortnum,
((st_crispyhud && nughud.nhamnum) ? nughud_ammonum : shortnum),
&plyr->maxammo[3],
&st_statusbaron,
ST_MAXAMMO3WIDTH);
Expand Down

0 comments on commit 7af75fb

Please sign in to comment.