complete overhaul of the HU widgets system (i.e. hu_lib.*) (#1178)

* stuff compiles, but crashes

* stuff runs, kind of

* stuff works, mostly

* add back support for centered player messages

* pointers!

* more stuff working

* some aesthetics

* some more minor stuff

* some more clean-up

* some optimizations

* some more minor stuff

* update woofhud.md

* some rearrangements, comments

* make the "space" character 5 px wide

* build the w_title widget a bot earlier

* nicer

* fix some more minor alignment issues
This commit is contained in:
Fabian Greffrath 2023-08-21 09:01:10 +02:00 committed by GitHub
parent 77af6e50f6
commit 19c25e94c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 766 additions and 1056 deletions

View File

@ -17,6 +17,8 @@ The following lines start with the name of the HUD widget which is to be positio
Possible values for the HUD widget names:
* "title" or "levelname"
* "message" (new in Woof! 12.0.0)
* "secret" (new in Woof! 12.0.0)
* "armor"
* "health"
* "ammo"
@ -100,6 +102,7 @@ The "title" widget is only visible if the Automap is enabled. The "monsec", "stt
A centered widget does not allow for any other left or right aligned widget on the same line.
HUD modes without a paragraph remain unchanged. Widgets which are not mentioned in a paragraph will *never* be visible in the respective HUD mode. So, it is a good idea to *always* include the five widgets which make up the `hud 0` paragraph in the example above in *any* other paragraph.
The Vanilla Doom widgets (i.e. "title", "message", "secret"), however, will *always* be visible, whether they are explicitly mentioned in a paragraph or not (new in Woof! 12.0.0).
It is currently impossible to use the WOOFHUD lump to modify the appearance of the Status Bar or the Crispy HUD. However, when using the Crispy HUD or the Automap, the visible widgets will align corresponding to the last active HUD mode.

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
//
// Copyright (C) 1999 by
// id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
// Copyright (C) 2023 Fabian Greffrath
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -19,203 +20,101 @@
#ifndef __HULIB__
#define __HULIB__
// We are referring to patches.
#include "r_defs.h"
#include "v_video.h" //jff 2/16/52 include color range defs
#include "v_video.h" //jff 2/16/52 include color range defs
#define CR_ORIG (-1) // [FG] reset to original color
// background and foreground screen numbers
// different from other modules.
#define BG 1
#define FG 0
#define BG 1
#define FG 0
// font stuff
// #define HU_CHARERASE KEY_BACKSPACE // not used // phares
#define HU_MAXLINELENGTH 80
#define HU_MAXLINES 4
#define HU_MAXLINELENGTH 80
#define HU_REFRESHSPACING 8 /*jff 2/26/98 space lines in text refresh widget*/
//jff 2/26/98 maximum number of messages allowed in refresh list
#define HU_MAXMESSAGES 8
//
// Typedefs of widgets
//
// Text Line widget
// (parent of Scrolling Text and Input Text widgets)
typedef struct
{
// left-justified position of scrolling text window
int x;
int y;
patch_t ***f; // font
char *cr; //jff 2/16/52 output color range
// killough 1/23/98: Support multiple lines:
#define MAXLINES 25
int linelen;
char l[HU_MAXLINELENGTH*MAXLINES+1]; // line of text
int len; // current line length
// whether this line needs to be udpated
int needsupdate;
int width;
boolean visible;
void (*builder) (void);
} hu_textline_t;
typedef enum {
align_topleft,
align_topleft_exclusive,
align_topright,
align_topcenter,
align_bottomleft,
align_bottomright,
align_bottomcenter,
// [FG] h_align / v_align
align_direct,
// [FG] h_align
align_left,
align_right,
align_center,
// [FG] v_align
align_top,
align_bottom,
num_aligns,
} align_t;
typedef struct {
hu_textline_t *line;
align_t align;
int x, y;
} widget_t;
// [FG] a single line of information
//jff 2/26/98 new widget to display last hud_msg_lines of messages
// Message refresh window widget
typedef struct
{
hu_textline_t l[HU_MAXMESSAGES]; // text lines to draw
int nl; // height in lines
int cl; // current line number
int pos; // current line x
char line[HU_MAXLINELENGTH];
// [FG] length in chars
int len;
// [FG] length in chars
int width;
} hu_line_t;
// [FG] an array of lines with common properties
typedef struct hu_multiline_s
{
hu_line_t *lines[HU_MAXMESSAGES]; // text lines to draw
int numlines; // number of lines
int curline; // current line number
patch_t ***font; // font
char *cr; //jff 2/16/52 output color range
boolean drawcursor;
// pointer to boolean stating whether to update window
boolean* on;
boolean laston; // last value of *->on.
boolean *on;
} hu_mtext_t;
void (*builder)(void);
boolean built;
//
// Widget creation, access, and update routines
//
} hu_multiline_t;
// initializes heads-up widget library
void HUlib_init(void);
// [FG] configured alignment and coordinates for multilines
//
// textline code
//
typedef struct hu_widget_s
{
hu_multiline_t *multiline;
// clear a line of text
void HUlib_clearTextLine(hu_textline_t *t);
align_t h_align, v_align;
void HUlib_initTextLine
(
hu_textline_t *t,
int x,
int y,
patch_t ***f,
char *cr, //jff 2/16/98 add color range parameter
void (*builder)(void)
);
// [FG] align_direct
int x, y;
// returns success
boolean HUlib_addCharToTextLine(hu_textline_t *t, char ch);
void HUlib_addStringToTextLine(hu_textline_t *t, char *s);
} hu_widget_t;
// draws tline
void HUlib_drawTextLine(hu_textline_t *l, align_t align, boolean drawcursor);
void HUlib_resetAlignOffsets();
void HUlib_setMargins (void);
void HUlib_set_margins (void);
void HUlib_reset_align_offsets (void);
// erases text line
void HUlib_eraseTextLine(hu_textline_t *l);
void HUlib_clear_line (hu_line_t *const l);
void HUlib_clear_cur_line (hu_multiline_t *const m);
void HUlib_add_string_to_cur_line (hu_multiline_t *const m, const char *s);
void HUlib_add_strings_to_cur_line (hu_multiline_t *const m, const char *prefix, const char *msg);
//
// Scrolling Text window widget routines
//
void HUlib_draw_widget (const hu_widget_t *const w);
// initialize an stext widget
void HUlib_initSText
( hu_mtext_t* s,
int x,
int y,
int h,
patch_t ***font,
char *cr, //jff 2/16/98 add color range parameter
boolean* on );
void HUlib_init_multiline (hu_multiline_t *const m, int nl, patch_t ***f, char *cr, boolean *on, void (*builder)(void));
// add a text message to an stext widget
void HUlib_addMessageToSText
( hu_mtext_t* s,
char* prefix,
char* msg );
// draws stext
void HUlib_drawSText(hu_mtext_t* s, align_t align);
// erases all stext lines
void HUlib_eraseSText(hu_mtext_t* s);
//jff 2/26/98 message refresh widget
// initialize refresh text widget
void HUlib_initMText
( hu_mtext_t *m,
int x,
int y,
patch_t ***font,
char *cr,
boolean *on
);
//jff 2/26/98 message refresh widget
// add a text message to refresh text widget
void HUlib_addMessageToMText
( hu_mtext_t* m,
char* prefix,
char* msg );
//jff 2/26/98 message refresh widget
// draws mtext
void HUlib_drawMText(hu_mtext_t* m, align_t align);
//jff 4/28/98 erases behind message list
void HUlib_eraseMText(hu_mtext_t* m);
// Input Text Line widget routines
void HUlib_initIText
( hu_mtext_t* it,
int x,
int y,
patch_t ***font,
char *cr, //jff 2/16/98 add color range parameter
boolean* on );
// resets line and left margin
void HUlib_resetIText(hu_mtext_t* it);
// whether eaten
boolean HUlib_keyInIText
( hu_mtext_t* it,
unsigned char ch );
void HUlib_drawIText(hu_mtext_t* it, align_t align);
// erases all itext lines
void HUlib_eraseIText(hu_mtext_t* it);
boolean HUlib_add_key_to_line (hu_line_t *const l, unsigned char ch);
boolean HUlib_add_key_to_cur_line (hu_multiline_t *const m, unsigned char ch);
#endif
//----------------------------------------------------------------------------
//
// $Log: hu_lib.h,v $

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
// Copyright (C) 1999 by
// id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
// Copyright (C) 2023 Fabian Greffrath
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -47,7 +48,7 @@ extern patch_t **hu_font;
//
void HU_Init(void);
void HU_Start(void);
void HU_disableAllWidgets (void);
void HU_disable_all_widgets (void);
boolean HU_Responder(event_t* ev);

View File

@ -236,7 +236,7 @@ extern int mapcolor_frnd; // friends colors // killough 8/8/98
extern int map_point_coordinates; // killough 10/98
extern char *chat_macros[]; // chat macros
extern const char *shiftxform;
extern const char shiftxform[];
extern int map_secret_after; //secrets do not appear til after bagged
extern default_t defaults[];
@ -5756,7 +5756,7 @@ boolean M_Responder (event_t* ev)
{
hud_displayed = 1; //jff 3/3/98 turn hud on
hud_active = (hud_active + 1) % 3; // cycle hud_active
HU_disableAllWidgets();
HU_disable_all_widgets();
}
return true;
}

View File

@ -542,7 +542,7 @@ void R_ExecuteSetViewSize (void)
}
}
HU_disableAllWidgets();
HU_disable_all_widgets();
// [crispy] forcefully initialize the status bar backing screen
ST_refreshBackground(true);