From 921f67438b465383c5614cc5171dda8e4ed41474 Mon Sep 17 00:00:00 2001 From: wiidev Date: Sun, 1 Jan 2023 17:00:11 +0000 Subject: [PATCH] Make the channel grid scrollable --- source/GUI/GuiBannerGrid.cpp | 42 +++++++++++++++++++++++++----------- source/GUI/GuiBannerGrid.h | 1 + 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/source/GUI/GuiBannerGrid.cpp b/source/GUI/GuiBannerGrid.cpp index f7d9a7db..358d023e 100644 --- a/source/GUI/GuiBannerGrid.cpp +++ b/source/GUI/GuiBannerGrid.cpp @@ -289,25 +289,43 @@ void GuiBannerGrid::Update(GuiTrigger *t) for(int i = 0; i < MAX_BUTTONS && !AnimationRunning; i++) gridBtn[i]->Update(t); - if(pageNo > 0) - { - btnLeft->Update(t); + if (ticks_to_millisecs(diff_ticks(time, gettime())) < 100) + return; - if((btnLeft->GetState() == STATE_CLICKED) && !AnimationRunning) { - btnLeft->SetState(STATE_DEFAULT); + btnLeft->Update(t); + btnRight->Update(t); + + u32 buttons = t->wpad.btns_h; + u32 buttonsPAD = t->pad.btns_h; + if ((btnLeft->GetState() == STATE_CLICKED) && !AnimationRunning) + { + if (!((buttons & WPAD_BUTTON_A) || (buttons & WPAD_BUTTON_MINUS) || + (buttons & WPAD_CLASSIC_BUTTON_A) || (buttons & WPAD_CLASSIC_BUTTON_MINUS) || + (buttonsPAD & PAD_BUTTON_A) || (buttonsPAD & PAD_TRIGGER_L) || t->Left())) + { + btnLeft->ResetState(); + return; + } + if (pageNo > 0) + { + time = gettime(); fAnimation -= chanWidth * 4.f; pageNo--; UpdateTooltips(); } } - - - if(pageNo < pageCnt-1) + else if ((btnRight->GetState() == STATE_CLICKED) && !AnimationRunning) { - btnRight->Update(t); - - if((btnRight->GetState() == STATE_CLICKED) && !AnimationRunning) { - btnRight->SetState(STATE_DEFAULT); + if (!((buttons & WPAD_BUTTON_A) || (buttons & WPAD_BUTTON_PLUS) || + (buttons & WPAD_CLASSIC_BUTTON_A) || (buttons & WPAD_CLASSIC_BUTTON_PLUS) || + (buttonsPAD & PAD_BUTTON_A) || (buttonsPAD & PAD_TRIGGER_R) || t->Right())) + { + btnRight->ResetState(); + return; + } + if (pageNo < pageCnt - 1) + { + time = gettime(); fAnimation += chanWidth * 4.f; pageNo++; UpdateTooltips(); diff --git a/source/GUI/GuiBannerGrid.h b/source/GUI/GuiBannerGrid.h index 6f765e1e..77987489 100644 --- a/source/GUI/GuiBannerGrid.h +++ b/source/GUI/GuiBannerGrid.h @@ -59,6 +59,7 @@ private: int pageNo; int pageCnt; + u64 time; Vec2f ScreenProps; Texture gridFrameTex;