Skip to content

Commit

Permalink
NUGHUD graphic offsets changes
Browse files Browse the repository at this point in the history
- Replaced `ignore_offsets` with `patch_offsets`, exclusive for Patches

- Ammo and Armor icons graphic offsets are ignored if using fallbacks, and applied if using exclusive graphics
  • Loading branch information
MrAlaux committed Oct 28, 2023
1 parent ce89f3e commit b418ce5
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- **NUGHUD:**
- Ammo icon;
- Toggle to ignore patch offsets.
- Toggle to apply patch offsets.
- **_Direct Vertical Aiming_ for melee attacks**
- **_Disable Melee Snapping_ setting**

Expand Down
8 changes: 3 additions & 5 deletions docs/nughud.lmp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
; Default NUGHUD

; - Widgets -

; Ammo count
nughud_ammo_x 44
nughud_ammo_y 171
Expand Down Expand Up @@ -200,7 +198,7 @@ nughud_secret_wide 0
nughud_secret_align 0

; Example Patch
; (All other patches up to and including patch8 have the same properties)
; (All other Patches up to and including patch8 have the same properties)
nughud_patch1_x 0
nughud_patch1_y 0
nughud_patch1_wide 0
Expand All @@ -211,8 +209,8 @@ nughud_patch1_name ""
; Draw percentage signs
nughud_percents 1

; Ignore offsets when drawing patches
nughud_ignore_offsets 1
; Apply graphic offsets when drawing Patches
nughud_patch_offsets 1

; Upwards offset to apply to weapon sprites
nughud_weapheight 0
15 changes: 9 additions & 6 deletions docs/nughud.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ The following widgets are available:
| `nughud_secret` | No | Yes | Secret Message display |

**The _Ammo_ and _Armor icons_ can also be aligned vertically** by means of the `_vlign` property, with the following possible values:
- `-1` for top alignment;
- ` 1` for top alignment;
- ` 0` for center alignment;
- ` 1` for bottom alignment.
- `-1` for bottom alignment.
Additionally, **the offsets of the graphics used by these icons will be ignored, unless a custom font is being used** (see details below).

There are some additional boolean properties (value of `0` or `1`) for some specific widgets:
There are some additional toggles (value of `0` or `1`) for some specific widgets:

- `nughud_percents`: Toggle drawing of percentage signs for the _Health_ and _Armor_ counts.
- `nughud_ammoicon_big`: Toggle usage of big ammo pickup sprites for the _Armor icon_.
Expand Down Expand Up @@ -160,7 +161,11 @@ Up to 8 patches can be drawn. They are drawn in increasing order; `patch1` is dr
Aside from the shared properties, **patches make use of an additional property, `_name`, that determines the name of the graphic lump to be used**, which can either be a sprite (i.e. a lump between `S_START` and `S_END` markers, like `MEDIA0`) or a graphic (like `STBAR`).
**Custom lumps CAN be used** (for example, a graphic called `NEWPATCH`). The names used in the `NUGHUD` lump MUST be enclosed between quotation marks.

Patches are alignable, both horizontally and vertically, and can be disabled by simply not providing any graphic.
**Patches are alignable**, both horizontally and vertically, and can be disabled by simply not providing any graphic.

**There is an additional toggle, `nughud_patch_offsets`, that determines whether or not to apply graphic offsets when drawing Patches.**
Disabling this is useful when using non-exclusive graphics (e.g. ammo pickup sprites), whose offsets may differ across PWADs.
Otherwise, enabling it is useful when using exclusive graphics, whose offsets are determined by the HUD maker, to allow precise positioning.

#### Example

Expand All @@ -183,8 +188,6 @@ nughud_patch2_name "STARMS"

### Miscellaneous

**There is an additional toggle, `nughud_ignore_offsets`, to ignore patch offsets when drawing Patches and *Ammo*/*Armor* icon graphics.**

**There is an additional fixed-point property, `nughud_weapheight`, to increase the height at which weapon sprites are drawn**.
It can be any value between `0` and `200` (inclusive).

Expand Down
2 changes: 1 addition & 1 deletion src/m_nughud.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ default_t nughud_defaults[] = {
PATCH( "nughud_patch8", 7 ),

TOGGLE( "nughud_percents", nughud.percents, 1 ),
TOGGLE( "nughud_ignore_offsets", nughud.ignore_offsets, 0 ),
TOGGLE( "nughud_patch_offsets", nughud.patch_offsets, 1 ),
{ "nughud_weapheight", (config_t *)&nughud.weapheight, NULL, { 0 }, { 0, 200 }, number },

{ NULL } // last entry
Expand Down
2 changes: 1 addition & 1 deletion src/m_nughud.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ typedef struct nughud_s {
nughud_alignable_t secret;
nughud_vlignable_t patches[NUMNUGHUDPATCHES];
char *patchnames[NUMNUGHUDPATCHES];
boolean patch_offsets;

boolean percents;
boolean ignore_offsets;
fixed_t weapheight;
} nughud_t;

Expand Down
20 changes: 15 additions & 5 deletions src/st_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ void ST_doPaletteStuff(void)
}

// [Nugget] NUGHUD
static void NughudDrawPatch(nughud_vlignable_t *widget, patch_t *patch)
static void NughudDrawPatch(nughud_vlignable_t *widget, patch_t *patch, boolean no_offsets)
{
int x, y;

Expand All @@ -895,7 +895,7 @@ static void NughudDrawPatch(nughud_vlignable_t *widget, patch_t *patch)
- ((widget->vlign == -1) ? SHORT(patch->height) :
(widget->vlign == 0) ? SHORT(patch->height)/2 : 0);

if (nughud.ignore_offsets) {
if (no_offsets) {
x += SHORT(patch->leftoffset);
y += SHORT(patch->topoffset);
}
Expand Down Expand Up @@ -925,21 +925,28 @@ void ST_drawWidgets(void)
{
if (nughud_patchlump[i] >= 0)
{
NughudDrawPatch(&nughud.patches[i], W_CacheLumpNum(nughud_patchlump[i], PU_STATIC));
NughudDrawPatch(
&nughud.patches[i],
W_CacheLumpNum(nughud_patchlump[i], PU_STATIC),
!nughud.patch_offsets
);
}
}

if (nughud.ammoicon.x > -1 && weaponinfo[w_ready.data].ammo != am_noammo)
{
patch_t *patch;
int lump;
boolean no_offsets = false;

if (nhammo[0])
{ patch = nhammo[BETWEEN(0, 3, weaponinfo[w_ready.data].ammo)]; }
else {
char namebuf[32];
boolean big = nughud.ammoicon_big;

no_offsets = true;

switch (BETWEEN(0, 3, weaponinfo[w_ready.data].ammo))
{
case 0: sprintf(namebuf, big ? "AMMOA0" : "CLIPA0"); break;
Expand All @@ -954,19 +961,22 @@ void ST_drawWidgets(void)
{ patch = NULL; }
}

if (patch) { NughudDrawPatch(&nughud.ammoicon, patch); }
if (patch) { NughudDrawPatch(&nughud.ammoicon, patch, no_offsets); }
}

if (nughud.armoricon.x > -1)
{
patch_t *patch;
int lump;
boolean no_offsets = false;

if (nharmor[0])
{ patch = nharmor[BETWEEN(0, 2, plyr->armortype)]; }
else {
char namebuf[32];

no_offsets = true;

switch (BETWEEN(0, 2, plyr->armortype))
{
case 0: sprintf(namebuf, "BON2A0"); break;
Expand All @@ -980,7 +990,7 @@ void ST_drawWidgets(void)
{ patch = NULL; }
}

if (patch) { NughudDrawPatch(&nughud.armoricon, patch); }
if (patch) { NughudDrawPatch(&nughud.armoricon, patch, no_offsets); }
}
}

Expand Down

0 comments on commit b418ce5

Please sign in to comment.