mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-01-03 14:11:10 +00:00
DJUI paginated element fixes
This commit is contained in:
parent
f13541a033
commit
c2eac34c4c
8 changed files with 40 additions and 25 deletions
|
@ -37,7 +37,9 @@ local sKnockbackActions = {
|
|||
ACT_BACKWARD_WATER_KB, ACT_BACKWARD_WATER_KB, ACT_BACKWARD_WATER_KB,
|
||||
|
||||
ACT_LEDGE_GRAB, ACT_LEDGE_CLIMB_SLOW_1, ACT_LEDGE_CLIMB_SLOW_2, ACT_LEDGE_CLIMB_DOWN, ACT_LEDGE_CLIMB_FAST,
|
||||
ACT_GROUND_BONK, ACT_SOFT_BONK
|
||||
ACT_GROUND_BONK, ACT_SOFT_BONK,
|
||||
|
||||
ACT_STOP_CROUCHING, ACT_STOMACH_SLIDE_STOP,
|
||||
}
|
||||
------------
|
||||
-- hammer --
|
||||
|
|
|
@ -3245,7 +3245,10 @@ void print_hud_course_complete_coins(s16 x, s16 y) {
|
|||
void play_star_fanfare_and_flash_hud(s32 arg, u8 starNum) {
|
||||
if (gHudDisplay.coins == gCourseCompleteCoins && (gCurrCourseStarFlags & starNum) == 0 && gHudFlash == 0) {
|
||||
gCurrCourseStarFlags |= starNum; // SM74 was spamming fanfare without this line
|
||||
play_star_fanfare();
|
||||
if (gFanFareDebounce <= 0) {
|
||||
gFanFareDebounce = 30 * 5;
|
||||
play_star_fanfare();
|
||||
}
|
||||
gHudFlash = arg;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
struct SavedWarpValues gReceiveWarp = { 0 };
|
||||
extern s8 sReceivedLoadedActNum;
|
||||
u8 gRejectInstantWarp = 0;
|
||||
u16 gFanFareDebounce = 0;
|
||||
|
||||
s16 gChangeLevel = -1;
|
||||
s16 gChangeLevelTransition = -1;
|
||||
|
@ -1612,6 +1613,8 @@ s32 update_level(void) {
|
|||
sFirstCastleGroundsMenu = false;
|
||||
}
|
||||
|
||||
if (gFanFareDebounce > 0) { gFanFareDebounce--; }
|
||||
|
||||
s32 changeLevel = 0;
|
||||
|
||||
if (gChangeLevel != -1) {
|
||||
|
|
|
@ -103,6 +103,7 @@ struct SavedWarpValues {
|
|||
extern struct WarpDest sWarpDest;
|
||||
extern s8 sWarpCheckpointActive;
|
||||
extern u8 gRejectInstantWarp;
|
||||
extern u16 gFanFareDebounce;
|
||||
|
||||
extern s16 D_80339EE0;
|
||||
extern s16 sDelayedWarpOp;
|
||||
|
|
|
@ -62,7 +62,6 @@ static f32 djui_cursor_base_distance(struct DjuiBase* base, f32 xScale, f32 ySca
|
|||
|
||||
static void djui_cursor_move_check(s8 xDir, s8 yDir, struct DjuiBase** pick, struct DjuiBase* base) {
|
||||
if (!base->visible) { return; }
|
||||
if (!base->enabled) { return; }
|
||||
|
||||
if (base->interactable != NULL) {
|
||||
f32 x1, y1, x2, y2;
|
||||
|
|
|
@ -23,33 +23,35 @@ static s32 djui_paginated_get_count(struct DjuiPaginated* paginated) {
|
|||
return count;
|
||||
}
|
||||
|
||||
static void djui_paginated_prev(struct DjuiBase* base) {
|
||||
struct DjuiPaginated* paginated = (struct DjuiPaginated*)base->parent;
|
||||
paginated->startIndex -= paginated->showCount;
|
||||
void djui_paginated_update_page_buttons(struct DjuiPaginated* paginated) {
|
||||
s32 count = djui_paginated_get_count(paginated);
|
||||
char pageNumString[32] = { 0 };
|
||||
snprintf(pageNumString, 32, "%d/%d", paginated->startIndex / paginated->showCount + 1, count / paginated->showCount + 1);
|
||||
djui_text_set_text(sPageNumText, pageNumString);
|
||||
djui_base_set_visible(&sPageNumText->base, (count > paginated->showCount));
|
||||
|
||||
djui_base_set_enabled(&sPrevButton->base, (paginated->startIndex > 0));
|
||||
djui_base_set_enabled(&sNextButton->base, true);
|
||||
djui_base_set_enabled(&sNextButton->base, ((paginated->startIndex + paginated->showCount) < count));
|
||||
}
|
||||
|
||||
char pageNumString[32] = { 0 };
|
||||
snprintf(pageNumString, 32, "%d/%d", paginated->startIndex / paginated->showCount + 1, djui_paginated_get_count(paginated) / paginated->showCount + 1);
|
||||
djui_text_set_text(sPageNumText, pageNumString);
|
||||
static void djui_paginated_prev(struct DjuiBase* base) {
|
||||
struct DjuiPaginated* paginated = (struct DjuiPaginated*)base->parent;
|
||||
|
||||
paginated->startIndex -= paginated->showCount;
|
||||
if (paginated->startIndex < 0) { paginated->startIndex = 0; }
|
||||
|
||||
djui_paginated_update_page_buttons(paginated);
|
||||
}
|
||||
|
||||
static void djui_paginated_next(struct DjuiBase* base) {
|
||||
struct DjuiPaginated* paginated = (struct DjuiPaginated*)base->parent;
|
||||
paginated->startIndex += paginated->showCount;
|
||||
|
||||
s32 count = djui_paginated_get_count(paginated);
|
||||
|
||||
djui_base_set_enabled(&sNextButton->base, (paginated->startIndex < count - 8));
|
||||
djui_base_set_enabled(&sPrevButton->base, true);
|
||||
|
||||
char pageNumString[32] = { 0 };
|
||||
snprintf(pageNumString, 32, "%d/%d", paginated->startIndex / paginated->showCount + 1, count / paginated->showCount + 1);
|
||||
djui_text_set_text(sPageNumText, pageNumString);
|
||||
|
||||
paginated->startIndex += paginated->showCount;
|
||||
if (paginated->startIndex >= count) { paginated->startIndex -= paginated->showCount; }
|
||||
|
||||
djui_paginated_update_page_buttons(paginated);
|
||||
|
||||
}
|
||||
|
||||
void djui_paginated_calculate_height(struct DjuiPaginated* paginated) {
|
||||
|
@ -81,10 +83,7 @@ void djui_paginated_calculate_height(struct DjuiPaginated* paginated) {
|
|||
}
|
||||
|
||||
djui_base_set_size(&paginated->base, paginated->base.width.value, height);
|
||||
|
||||
char pageNumString[32] = { 0 };
|
||||
snprintf(pageNumString, 32, "%d/%d", paginated->startIndex / paginated->showCount + 1, count / paginated->showCount + 1);
|
||||
djui_text_set_text(sPageNumText, pageNumString);
|
||||
djui_paginated_update_page_buttons(paginated);
|
||||
}
|
||||
|
||||
bool djui_paginated_render(struct DjuiBase* base) {
|
||||
|
@ -158,5 +157,7 @@ struct DjuiPaginated* djui_paginated_create(struct DjuiBase* parent, u32 showCou
|
|||
djui_base_set_size(&sNextButton->base, 128, 32);
|
||||
paginated->nextButton = sNextButton;
|
||||
|
||||
djui_paginated_update_page_buttons(paginated);
|
||||
|
||||
return paginated;
|
||||
}
|
||||
|
|
|
@ -10,5 +10,6 @@ struct DjuiPaginated {
|
|||
s32 showCount;
|
||||
};
|
||||
|
||||
void djui_paginated_update_page_buttons(struct DjuiPaginated* paginated);
|
||||
void djui_paginated_calculate_height(struct DjuiPaginated* paginated);
|
||||
struct DjuiPaginated* djui_paginated_create(struct DjuiBase* parent, u32 showCount);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#define DJUI_DESC_PANEL_WIDTH (410.0f + (16 * 2.0f))
|
||||
|
||||
static struct DjuiPaginated* sLobbyPaginated = NULL;
|
||||
static struct DjuiFlowLayout* sLobbyLayout = NULL;
|
||||
static struct DjuiButton* sRefreshButton = NULL;
|
||||
static struct DjuiThreePanel* sDescriptionPanel = NULL;
|
||||
|
@ -90,6 +91,7 @@ void djui_panel_join_query(uint64_t aLobbyId, UNUSED uint64_t aOwnerId, uint16_t
|
|||
struct DjuiBase* layoutBase = &sLobbyLayout->base;
|
||||
struct DjuiLobbyEntry* entry = djui_lobby_entry_create(layoutBase, (char*)aHostName, (char*)mode, playerText, (char*)aDescription, djui_panel_join_lobby, djui_lobby_on_hover, djui_lobby_on_hover_end);
|
||||
entry->base.tag = (s64)aLobbyId;
|
||||
djui_paginated_update_page_buttons(sLobbyPaginated);
|
||||
}
|
||||
|
||||
void djui_panel_join_query_finish(void) {
|
||||
|
@ -103,6 +105,7 @@ void djui_panel_join_query_finish(void) {
|
|||
djui_base_set_size(&text->base, 1, 1);
|
||||
djui_text_set_alignment(text, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
}
|
||||
djui_paginated_update_page_buttons(sLobbyPaginated);
|
||||
}
|
||||
|
||||
void djui_panel_join_lobbies_on_destroy(UNUSED struct DjuiBase* caller) {
|
||||
|
@ -110,6 +113,7 @@ void djui_panel_join_lobbies_on_destroy(UNUSED struct DjuiBase* caller) {
|
|||
sPassword = NULL;
|
||||
sRefreshButton = NULL;
|
||||
sLobbyLayout = NULL;
|
||||
sLobbyPaginated = NULL;
|
||||
|
||||
if (sDescriptionPanel != NULL) {
|
||||
djui_base_destroy(&sDescriptionPanel->base);
|
||||
|
@ -121,6 +125,7 @@ void djui_panel_join_lobbies_refresh(UNUSED struct DjuiBase* caller) {
|
|||
djui_base_destroy_children(&sLobbyLayout->base);
|
||||
djui_text_set_text(sRefreshButton->text, DLANG(LOBBIES, REFRESHING));
|
||||
djui_base_set_enabled(&sRefreshButton->base, false);
|
||||
djui_paginated_update_page_buttons(sLobbyPaginated);
|
||||
ns_coopnet_query(djui_panel_join_query, djui_panel_join_query_finish, sPassword);
|
||||
}
|
||||
|
||||
|
@ -135,8 +140,8 @@ void djui_panel_join_lobbies_create(struct DjuiBase* caller, const char* passwor
|
|||
struct DjuiThreePanel* panel = djui_panel_menu_create(private ? DLANG(LOBBIES, PRIVATE_LOBBIES) : DLANG(LOBBIES, PUBLIC_LOBBIES));
|
||||
struct DjuiBase* body = djui_three_panel_get_body(panel);
|
||||
{
|
||||
struct DjuiPaginated* paginated = djui_paginated_create(body, 8);
|
||||
sLobbyLayout = paginated->layout;
|
||||
sLobbyPaginated = djui_paginated_create(body, 8);
|
||||
sLobbyLayout = sLobbyPaginated->layout;
|
||||
djui_flow_layout_set_margin(sLobbyLayout, 4);
|
||||
|
||||
bool querying = ns_coopnet_query(djui_panel_join_query, djui_panel_join_query_finish, password);
|
||||
|
|
Loading…
Reference in a new issue