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) {
|
void djui_paginated_update_page_buttons(struct DjuiPaginated* paginated) {
|
||||||
s32 count = djui_paginated_get_count(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 };
|
char pageNumString[32] = { 0 };
|
||||||
snprintf(pageNumString, 32, "%d/%d", paginated->startIndex / paginated->showCount + 1, (count - 1) / paginated->showCount + 1);
|
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;
|
f32 height = 0;
|
||||||
s32 count = 0;
|
s32 count = 0;
|
||||||
|
|
||||||
while (dbc != NULL) {
|
if (paginated->showMaxCount) {
|
||||||
struct DjuiBase* cbase = dbc->base;
|
height = paginated->showCount * (32 + paginated->layout->margin.value);
|
||||||
if (count < paginated->showCount) {
|
count = paginated->showCount + 1;
|
||||||
if (height != 0) {
|
} else {
|
||||||
height += paginated->layout->margin.value;
|
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) {
|
if (count <= paginated->showCount) {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ struct DjuiPaginated {
|
||||||
struct DjuiText* pageNumText;
|
struct DjuiText* pageNumText;
|
||||||
s32 startIndex;
|
s32 startIndex;
|
||||||
s32 showCount;
|
s32 showCount;
|
||||||
|
bool showMaxCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
void djui_paginated_update_page_buttons(struct DjuiPaginated* paginated);
|
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);
|
djui_selectionbox_create(body, DLANG(HOST_MODS, CATEGORIES), categoryChoices, numCategories, &sSelectedCategory, djui_panel_on_categories_change);
|
||||||
struct DjuiPaginated* paginated = djui_paginated_create(body, 8);
|
struct DjuiPaginated* paginated = djui_paginated_create(body, 8);
|
||||||
|
paginated->showMaxCount = true;
|
||||||
sModLayout = paginated->layout;
|
sModLayout = paginated->layout;
|
||||||
djui_panel_host_mods_add_mods(&paginated->layout->base);
|
djui_panel_host_mods_add_mods(&paginated->layout->base);
|
||||||
djui_paginated_calculate_height(paginated);
|
djui_paginated_calculate_height(paginated);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue