Skip to content

Commit

Permalink
tr1/ui/widgets/paginator: hide UI for empty text
Browse files Browse the repository at this point in the history
This will automatically hide the paginator UI if the text content is
empty.

Resolves #2097.
lahm86 authored and rr- committed Dec 21, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 0c18450 commit 25e6b41
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/tr1/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr1-4.7...develop) - ××××-××-××
- changed the inventory examine UI to auto-hide if the item description is empty (#2097)
- fixed falling pickup items not being drawn when they land in rare cases (#2088)
- fixed unbinding keys not working for controllers (#2090, regression from 4.6)
- fixed hiding game UI causing the reset progressbar UI element to not show (regression from 4.7)
3 changes: 2 additions & 1 deletion docs/tr1/GAMEFLOW.md
Original file line number Diff line number Diff line change
@@ -325,7 +325,8 @@ Following are each of the properties available within a level.
Players can examine items in the inventory when this text has been
defined. Use <code>\n</code> in the text to create new lines; you can also
use <code>\f</code> to force a page break. Long text will be automatically
wrapped and paginated as necessary.
wrapped and paginated as necessary. If an empty string is defined, the UI
will not be shown and the inventory item simply focussed instead.
</td>
</tr>
<tr valign="top">
5 changes: 4 additions & 1 deletion src/tr1/game/ui/widgets/paginator.c
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ typedef struct {
UI_WIDGET *page_label;
int32_t current_page;
VECTOR *page_content;
bool shown;
} UI_PAGINATOR;

static void M_DoLayout(UI_PAGINATOR *self);
@@ -107,7 +108,7 @@ static void M_Control(UI_PAGINATOR *const self)

static void M_Draw(UI_PAGINATOR *const self)
{
if (self->window->draw != NULL) {
if (self->shown && self->window->draw != NULL) {
self->window->draw(self->window);
}
}
@@ -149,6 +150,8 @@ UI_WIDGET *UI_Paginator_Create(
.free = (UI_WIDGET_FREE)M_Free,
};

self->shown = !String_IsEmpty(text);

self->outer_stack = UI_Stack_Create(
UI_STACK_LAYOUT_VERTICAL, UI_STACK_AUTO_SIZE, UI_STACK_AUTO_SIZE);

0 comments on commit 25e6b41

Please sign in to comment.