mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
fix paginated on public lobbies properly
This commit is contained in:
parent
a997fe0a2e
commit
68debf9d54
3 changed files with 17 additions and 9 deletions
|
|
@ -28,7 +28,8 @@ static s32 djui_paginated_get_count(struct DjuiPaginated* paginated) {
|
|||
|
||||
void djui_paginated_update_page_buttons(struct DjuiPaginated* paginated) {
|
||||
s32 count = djui_paginated_get_count(paginated);
|
||||
paginated->startIndex = MIN(paginated->startIndex, count);
|
||||
paginated->startIndex = (MIN(paginated->startIndex, count) / paginated->showCount) * paginated->showCount;
|
||||
if (count != 0 && paginated->startIndex == count) { paginated->startIndex -= paginated->showCount; }
|
||||
|
||||
char pageNumString[32] = { 0 };
|
||||
snprintf(pageNumString, 32, "%d/%d", paginated->startIndex / paginated->showCount + 1, (count - 1) / paginated->showCount + 1);
|
||||
|
|
@ -64,16 +65,21 @@ void djui_paginated_calculate_height(struct DjuiPaginated* paginated) {
|
|||
f32 height = 0;
|
||||
s32 count = 0;
|
||||
|
||||
while (dbc != NULL) {
|
||||
struct DjuiBase* cbase = dbc->base;
|
||||
if (count < paginated->showCount) {
|
||||
if (height != 0) {
|
||||
height += paginated->layout->margin.value;
|
||||
if (paginated->showMaxCount) {
|
||||
height = paginated->showCount * (32 + paginated->layout->margin.value);
|
||||
count = paginated->showCount + 1;
|
||||
} else {
|
||||
while (dbc != NULL) {
|
||||
struct DjuiBase* cbase = dbc->base;
|
||||
if (count < paginated->showCount) {
|
||||
if (height != 0) {
|
||||
height += paginated->layout->margin.value;
|
||||
}
|
||||
height += cbase->height.value;
|
||||
}
|
||||
height += cbase->height.value;
|
||||
count++;
|
||||
dbc = dbc->next;
|
||||
}
|
||||
count++;
|
||||
dbc = dbc->next;
|
||||
}
|
||||
|
||||
if (count <= paginated->showCount) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ struct DjuiPaginated {
|
|||
struct DjuiText* pageNumText;
|
||||
s32 startIndex;
|
||||
s32 showCount;
|
||||
bool showMaxCount;
|
||||
};
|
||||
|
||||
void djui_paginated_update_page_buttons(struct DjuiPaginated* paginated);
|
||||
|
|
|
|||
|
|
@ -226,6 +226,7 @@ void djui_panel_host_mods_create(struct DjuiBase* caller) {
|
|||
}
|
||||
djui_selectionbox_create(body, DLANG(HOST_MODS, CATEGORIES), categoryChoices, numCategories, &sSelectedCategory, djui_panel_on_categories_change);
|
||||
struct DjuiPaginated* paginated = djui_paginated_create(body, 8);
|
||||
paginated->showMaxCount = true;
|
||||
sModLayout = paginated->layout;
|
||||
djui_panel_host_mods_add_mods(&paginated->layout->base);
|
||||
djui_paginated_calculate_height(paginated);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue