mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-12-23 10:21:55 +01:00
*Changed the code for CreditsWindow
*Added ButtonsHold and ButtonsPressed functions *Some cleanups
This commit is contained in:
parent
24d98683b3
commit
976ea2041c
@ -196,7 +196,7 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, customOptionList *
|
||||
optionValOver[i] = new GuiText(NULL, 20, (GXColor){THEME.settingsTxt_r, THEME.settingsTxt_g, THEME.settingsTxt_b, 0xff});
|
||||
optionValOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||
|
||||
optionBtn[i] = new GuiButton(width,GAMESELECTSIZE);//(width-28,GAMESELECTSIZE);
|
||||
optionBtn[i] = new GuiButton(width-28,GAMESELECTSIZE);
|
||||
optionBtn[i]->SetParent(this);
|
||||
optionBtn[i]->SetLabel(optionTxt[i], 0);
|
||||
optionBtn[i]->SetLabel(optionVal[i], 1);
|
||||
@ -491,12 +491,7 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
|
||||
scrollbarBoxBtn->Draw();
|
||||
usleep(10000 * scrolldelay);
|
||||
}
|
||||
WPAD_ScanPads();
|
||||
u8 cnt, buttons = NULL;
|
||||
/* Get pressed buttons */
|
||||
for (cnt = 0; cnt < 4; cnt++)
|
||||
buttons |= WPAD_ButtonsHeld(cnt);
|
||||
if (buttons == WPAD_BUTTON_A)
|
||||
if (ButtonsHold() == WPAD_BUTTON_A)
|
||||
{
|
||||
}
|
||||
else
|
||||
@ -528,12 +523,7 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
|
||||
|
||||
|
||||
}
|
||||
WPAD_ScanPads();
|
||||
u8 cnt, buttons = NULL;
|
||||
/* Get pressed buttons */
|
||||
for (cnt = 0; cnt < 4; cnt++)
|
||||
buttons |= WPAD_ButtonsHeld(cnt);
|
||||
if (buttons == WPAD_BUTTON_A)
|
||||
if (ButtonsHold() == WPAD_BUTTON_A)
|
||||
{
|
||||
}
|
||||
else
|
||||
|
@ -411,12 +411,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
|
||||
scrollbarBoxBtn->Draw();
|
||||
usleep(10000 * scrolldelay);
|
||||
}
|
||||
WPAD_ScanPads();
|
||||
u8 cnt, buttons = NULL;
|
||||
/* Get pressed buttons */
|
||||
for (cnt = 0; cnt < 4; cnt++)
|
||||
buttons |= WPAD_ButtonsHeld(cnt);
|
||||
if (buttons == WPAD_BUTTON_A)
|
||||
if (ButtonsHold() == WPAD_BUTTON_A)
|
||||
{
|
||||
}
|
||||
else
|
||||
@ -446,12 +441,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
|
||||
scrollbarBoxBtn->Draw();
|
||||
usleep(10000 * scrolldelay);
|
||||
}
|
||||
WPAD_ScanPads();
|
||||
u8 cnt, buttons = NULL;
|
||||
/* Get pressed buttons */
|
||||
for (cnt = 0; cnt < 4; cnt++)
|
||||
buttons |= WPAD_ButtonsHeld(cnt);
|
||||
if (buttons == WPAD_BUTTON_A)
|
||||
if (ButtonsHold() == WPAD_BUTTON_A)
|
||||
{
|
||||
}
|
||||
else
|
||||
@ -459,8 +449,6 @@ void GuiGameBrowser::Update(GuiTrigger * t)
|
||||
arrowUpBtn->ResetState();
|
||||
}
|
||||
}
|
||||
WPAD_ScanPads();
|
||||
u8 cnt, buttons = NULL;/////////////////////////////////////////////////////scroll by holding B and tilt wiimote
|
||||
int position1 = 0;
|
||||
|
||||
|
||||
@ -471,10 +459,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
|
||||
position2 = position1;
|
||||
}
|
||||
|
||||
for (cnt = 0; cnt < 4; cnt++)
|
||||
buttons |= WPAD_ButtonsHeld(cnt);
|
||||
|
||||
if (buttons == WPAD_BUTTON_B && position1 > 0)
|
||||
if (ButtonsHold() == WPAD_BUTTON_B && position1 > 0)
|
||||
{
|
||||
scrollbarBoxBtn->ScrollIsOn(1);
|
||||
if (position2 > position1)
|
||||
@ -524,7 +509,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
|
||||
}
|
||||
|
||||
}
|
||||
else if (!buttons)
|
||||
else if(ButtonsHold() != WPAD_BUTTON_B)
|
||||
{
|
||||
scrollbarBoxBtn->ScrollIsOn(0);
|
||||
position2 = 0;
|
||||
|
@ -346,10 +346,8 @@ void GuiGameCarousel::Update(GuiTrigger * t)
|
||||
return; // skip navigation
|
||||
|
||||
if (t->Left() || btnLeft->GetState() == STATE_CLICKED) {
|
||||
WPAD_ScanPads();
|
||||
u16 buttons = 0;
|
||||
for(int i=0; i<4; i++)
|
||||
buttons |= WPAD_ButtonsHeld(i);
|
||||
|
||||
u16 buttons = ButtonsHold();
|
||||
if(!((buttons & WPAD_BUTTON_A) || (buttons & WPAD_BUTTON_MINUS) || t->Left())) {
|
||||
btnLeft->ResetState();
|
||||
speed = SHIFT_SPEED;
|
||||
@ -380,10 +378,8 @@ void GuiGameCarousel::Update(GuiTrigger * t)
|
||||
}
|
||||
|
||||
else if(t->Right() || btnRight->GetState() == STATE_CLICKED) {
|
||||
WPAD_ScanPads();
|
||||
u16 buttons = 0;
|
||||
for(int i=0; i<4; i++)
|
||||
buttons |= WPAD_ButtonsHeld(i);
|
||||
|
||||
u16 buttons = ButtonsHold();
|
||||
if(!((buttons & WPAD_BUTTON_A) || (buttons & WPAD_BUTTON_PLUS) || t->Right())) {
|
||||
btnRight->ResetState();
|
||||
speed=SHIFT_SPEED;
|
||||
|
141
source/menu.cpp
141
source/menu.cpp
@ -50,20 +50,17 @@ extern FreeTypeGX *fontClock; //CLOCK
|
||||
static GuiImage * coverImg = NULL;
|
||||
static GuiImageData * cover = NULL;
|
||||
|
||||
//char GamesHDD[320][14];
|
||||
|
||||
static struct discHdr *gameList = NULL;
|
||||
static GuiImageData * pointer[4];
|
||||
static GuiImage * bgImg = NULL;
|
||||
static GuiButton * btnLogo = NULL;
|
||||
static GuiImageData * background = NULL;
|
||||
static GuiText prTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||
static GuiText timeTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||
static GuiText sizeTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||
static GuiText *GameIDTxt = NULL;
|
||||
static GuiText *GameRegionTxt = NULL;
|
||||
static GuiText * GameIDTxt = NULL;
|
||||
static GuiText * GameRegionTxt = NULL;
|
||||
static GuiSound * bgMusic = NULL;
|
||||
static wbfs_t *hdd = NULL;
|
||||
static wbfs_t * hdd = NULL;
|
||||
static u32 gameCnt = 0;
|
||||
static s32 gameSelected = 0, gameStart = 0;
|
||||
static GuiWindow * mainWindow = NULL;
|
||||
@ -168,14 +165,11 @@ HaltGui()
|
||||
* WindowCredits
|
||||
* Display credits
|
||||
***************************************************************************/
|
||||
static void WindowCredits(void * ptr)
|
||||
void WindowCredits()
|
||||
{
|
||||
int angle = 0;
|
||||
GuiSound * creditsMusic = NULL;
|
||||
|
||||
if(btnLogo->GetState() != STATE_CLICKED) {
|
||||
return;
|
||||
}
|
||||
s32 thetimeofbg = bgMusic->GetPlayTime();
|
||||
StopOgg();
|
||||
|
||||
@ -184,8 +178,6 @@ static void WindowCredits(void * ptr)
|
||||
creditsMusic->SetLoop(1);
|
||||
creditsMusic->Play();
|
||||
|
||||
btnLogo->ResetState();
|
||||
|
||||
bool exit = false;
|
||||
int i = 0;
|
||||
int y = 20;
|
||||
@ -330,48 +322,40 @@ static void WindowCredits(void * ptr)
|
||||
creditsWindow.Append(&creditsWindowBox);
|
||||
creditsWindow.Append(&starImg);
|
||||
|
||||
creditsWindow.SetEffect(EFFECT_FADE, 30);
|
||||
|
||||
HaltGui();
|
||||
mainWindow->SetState(STATE_DISABLED);
|
||||
mainWindow->Append(&creditsWindow);
|
||||
ResumeGui();
|
||||
|
||||
while(!exit)
|
||||
{
|
||||
creditsWindow.Draw();
|
||||
|
||||
angle ++;
|
||||
angle = int(angle) % 360;
|
||||
usleep(12000);
|
||||
angle++;
|
||||
if(angle > 360)
|
||||
angle = 0;
|
||||
usleep(12000);
|
||||
starImg.SetAngle(angle);
|
||||
if(ButtonsPressed() != 0)
|
||||
exit = true;
|
||||
|
||||
for(i=3; i >= 0; i--)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
if(userInput[i].wpad.ir.valid)
|
||||
Menu_DrawImg(userInput[i].wpad.ir.x-48, userInput[i].wpad.ir.y-48, 200.0,
|
||||
96, 96, pointer[i]->GetImage(), userInput[i].wpad.ir.angle, CFG.widescreen? 0.8 : 1, 1, 255);
|
||||
if(Settings.rumble == RumbleOn){
|
||||
DoRumble(i);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Menu_Render();
|
||||
|
||||
for(i=0; i < 4; i++)
|
||||
{
|
||||
if(userInput[i].wpad.btns_d || userInput[i].pad.btns_d)
|
||||
exit = true;
|
||||
}
|
||||
}
|
||||
|
||||
// clear buttons pressed
|
||||
for(i=0; i < 4; i++)
|
||||
{
|
||||
userInput[i].wpad.btns_d = 0;
|
||||
userInput[i].pad.btns_d = 0;
|
||||
}
|
||||
creditsMusic->Stop();
|
||||
for(i=0; i < numEntries; i++)
|
||||
delete txt[i];
|
||||
|
||||
delete creditsMusic;
|
||||
|
||||
creditsWindow.SetEffect(EFFECT_FADE, -30);
|
||||
while(creditsWindow.GetEffect() > 0) usleep(50);
|
||||
HaltGui();
|
||||
mainWindow->Remove(&creditsWindow);
|
||||
mainWindow->SetState(STATE_DEFAULT);
|
||||
for(i=0; i < numEntries; i++) {
|
||||
delete txt[i];
|
||||
txt[i] = NULL;
|
||||
}
|
||||
ResumeGui();
|
||||
|
||||
if(!strcmp("", CFG.oggload_path) || !strcmp("notset", CFG.ogg_path)) {
|
||||
bgMusic->Play();
|
||||
} else {
|
||||
@ -4559,16 +4543,16 @@ static int MenuSettings()
|
||||
GuiImage logoImg(&logo);
|
||||
GuiImageData logoOver(credits_button_over_png);
|
||||
GuiImage logoImgOver(&logoOver);
|
||||
btnLogo = new GuiButton(logoImg.GetWidth(), logoImg.GetHeight());
|
||||
btnLogo->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
|
||||
btnLogo->SetPosition(0, -35);
|
||||
btnLogo->SetImage(&logoImg);
|
||||
btnLogo->SetImageOver(&logoImgOver);
|
||||
btnLogo->SetEffectGrow();
|
||||
btnLogo->SetSoundOver(&btnSoundOver);
|
||||
btnLogo->SetSoundClick(&btnClick);
|
||||
btnLogo->SetTrigger(&trigA);
|
||||
btnLogo->SetUpdateCallback(WindowCredits);
|
||||
|
||||
GuiButton btnLogo(logoImg.GetWidth(), logoImg.GetHeight());
|
||||
btnLogo.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
|
||||
btnLogo.SetPosition(0, -35);
|
||||
btnLogo.SetImage(&logoImg);
|
||||
btnLogo.SetImageOver(&logoImgOver);
|
||||
btnLogo.SetEffectGrow();
|
||||
btnLogo.SetSoundOver(&btnSoundOver);
|
||||
btnLogo.SetSoundClick(&btnClick);
|
||||
btnLogo.SetTrigger(&trigA);
|
||||
|
||||
customOptionList options2(9);
|
||||
GuiCustomOptionBrowser optionBrowser2(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 0, 150);
|
||||
@ -4601,7 +4585,7 @@ static int MenuSettings()
|
||||
w.Append(&backBtn);
|
||||
w.Append(&lockBtn);
|
||||
w.Append(&updateBtn);
|
||||
w.Append(btnLogo);
|
||||
w.Append(&btnLogo);
|
||||
w.Append(&homo);
|
||||
//set triggers for tabs
|
||||
page1Btn.RemoveTrigger(1);
|
||||
@ -5036,7 +5020,7 @@ static int MenuSettings()
|
||||
w.Append(&backBtn);
|
||||
w.Append(&lockBtn);
|
||||
w.Append(&updateBtn);
|
||||
w.Append(btnLogo);
|
||||
w.Append(&btnLogo);
|
||||
|
||||
mainWindow->Append(&optionBrowser2);
|
||||
mainWindow->Append(&page1Btn);
|
||||
@ -5306,7 +5290,7 @@ static int MenuSettings()
|
||||
mainWindow->Remove(&page2Btn);
|
||||
mainWindow->Remove(&tabBtn);
|
||||
mainWindow->Remove(&page3Btn);
|
||||
w.Remove(btnLogo);
|
||||
w.Remove(&btnLogo);
|
||||
w.Remove(&backBtn);
|
||||
w.Remove(&lockBtn);
|
||||
w.Remove(&updateBtn);
|
||||
@ -5322,13 +5306,36 @@ static int MenuSettings()
|
||||
w.Append(&backBtn);
|
||||
w.Append(&lockBtn);
|
||||
w.Append(&updateBtn);
|
||||
w.Append(btnLogo);
|
||||
w.Append(&btnLogo);
|
||||
} else {
|
||||
WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtousethatoption, LANGUAGE.ok, 0,0,0);
|
||||
}
|
||||
updateBtn.ResetState();
|
||||
}
|
||||
|
||||
if(btnLogo.GetState() == STATE_CLICKED) {
|
||||
mainWindow->Remove(&optionBrowser2);
|
||||
mainWindow->Remove(&page1Btn);
|
||||
mainWindow->Remove(&page2Btn);
|
||||
mainWindow->Remove(&tabBtn);
|
||||
mainWindow->Remove(&page3Btn);
|
||||
w.Remove(&btnLogo);
|
||||
w.Remove(&backBtn);
|
||||
w.Remove(&lockBtn);
|
||||
w.Remove(&updateBtn);
|
||||
WindowCredits();
|
||||
mainWindow->Append(&optionBrowser2);
|
||||
mainWindow->Append(&page1Btn);
|
||||
mainWindow->Append(&page2Btn);
|
||||
mainWindow->Append(&tabBtn);
|
||||
mainWindow->Append(&page3Btn);
|
||||
w.Append(&backBtn);
|
||||
w.Append(&lockBtn);
|
||||
w.Append(&updateBtn);
|
||||
w.Append(&btnLogo);
|
||||
btnLogo.ResetState();
|
||||
}
|
||||
|
||||
if(lockBtn.GetState() == STATE_CLICKED)
|
||||
{
|
||||
if (!strcmp("", Settings.unlockCode))
|
||||
@ -5443,8 +5450,6 @@ static int MenuSettings()
|
||||
}
|
||||
}
|
||||
HaltGui();
|
||||
delete btnLogo;
|
||||
btnLogo = NULL;
|
||||
mainWindow->Remove(&optionBrowser2);
|
||||
mainWindow->Remove(&w);
|
||||
ResumeGui();
|
||||
@ -6304,16 +6309,16 @@ int MainMenu(int menu)
|
||||
delete background;
|
||||
delete bgImg;
|
||||
delete mainWindow;
|
||||
delete pointer[0];
|
||||
delete pointer[1];
|
||||
delete pointer[2];
|
||||
delete pointer[3];
|
||||
|
||||
mainWindow = NULL;
|
||||
delete pointer[0];
|
||||
delete pointer[1];
|
||||
delete pointer[2];
|
||||
delete pointer[3];
|
||||
delete GameRegionTxt;
|
||||
delete GameIDTxt;
|
||||
delete cover;
|
||||
delete coverImg;
|
||||
|
||||
mainWindow = NULL;
|
||||
|
||||
ExitApp();
|
||||
|
||||
struct discHdr *header = &gameList[gameSelected];
|
||||
@ -6346,7 +6351,7 @@ int MainMenu(int menu)
|
||||
break;
|
||||
|
||||
case eng:
|
||||
configbytes[0] = 0x01;
|
||||
configbytes[0] = 0x01;
|
||||
break;
|
||||
|
||||
case ger:
|
||||
|
@ -43,31 +43,59 @@ void Wpad_Disconnect(void)
|
||||
WPAD_Shutdown();
|
||||
}
|
||||
|
||||
u32 Wpad_GetButtons(void)
|
||||
{
|
||||
u32 buttons = 0, cnt;
|
||||
u32 ButtonsHold(void) {
|
||||
|
||||
/* Scan pads */
|
||||
WPAD_ScanPads();
|
||||
int i;
|
||||
u32 buttons = 0;
|
||||
|
||||
/* Get pressed buttons */
|
||||
for (cnt = 0; cnt < MAX_WIIMOTES; cnt++)
|
||||
buttons |= WPAD_ButtonsDown(cnt);
|
||||
WPAD_ScanPads();
|
||||
PAD_ScanPads();
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
u32 Wpad_WaitButtons(void)
|
||||
{
|
||||
u32 buttons = 0;
|
||||
|
||||
/* Wait for button pressing */
|
||||
while (!buttons) {
|
||||
buttons = Wpad_GetButtons();
|
||||
VIDEO_WaitVSync();
|
||||
for(i=3; i >= 0; i--)
|
||||
{
|
||||
buttons |= PAD_ButtonsHeld(i);
|
||||
buttons |= WPAD_ButtonsHeld(i);
|
||||
}
|
||||
|
||||
return buttons;
|
||||
return buttons;
|
||||
}
|
||||
|
||||
u32 ButtonsPressed(void) {
|
||||
|
||||
int i;
|
||||
u32 buttons = 0;
|
||||
|
||||
WPAD_ScanPads();
|
||||
PAD_ScanPads();
|
||||
|
||||
for(i=3; i >= 0; i--)
|
||||
{
|
||||
buttons |= PAD_ButtonsDown(i);
|
||||
buttons |= WPAD_ButtonsDown(i);
|
||||
}
|
||||
return buttons;
|
||||
|
||||
/* Don't remove this commented out code it might be useful for checking which buttons were pressed/hold
|
||||
|
||||
if(buttons & (PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT | PAD_BUTTON_DOWN | PAD_BUTTON_UP
|
||||
| PAD_BUTTON_A | PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_Y | PAD_BUTTON_MENU
|
||||
| PAD_BUTTON_START | WPAD_BUTTON_2 | WPAD_BUTTON_1
|
||||
| WPAD_BUTTON_B | WPAD_BUTTON_A | WPAD_BUTTON_MINUS
|
||||
| WPAD_BUTTON_HOME | WPAD_BUTTON_LEFT | WPAD_BUTTON_RIGHT
|
||||
| WPAD_BUTTON_DOWN | WPAD_BUTTON_UP | WPAD_BUTTON_PLUS
|
||||
| WPAD_NUNCHUK_BUTTON_Z | WPAD_NUNCHUK_BUTTON_C
|
||||
| WPAD_CLASSIC_BUTTON_UP | WPAD_CLASSIC_BUTTON_LEFT
|
||||
| WPAD_CLASSIC_BUTTON_ZR | WPAD_CLASSIC_BUTTON_X
|
||||
| WPAD_CLASSIC_BUTTON_A | WPAD_CLASSIC_BUTTON_Y
|
||||
| WPAD_CLASSIC_BUTTON_B | WPAD_CLASSIC_BUTTON_ZL
|
||||
| WPAD_CLASSIC_BUTTON_FULL_R | WPAD_CLASSIC_BUTTON_PLUS
|
||||
| WPAD_CLASSIC_BUTTON_HOME | WPAD_CLASSIC_BUTTON_MINUS
|
||||
| WPAD_CLASSIC_BUTTON_FULL_L | WPAD_CLASSIC_BUTTON_DOWN
|
||||
| WPAD_CLASSIC_BUTTON_RIGHT | WPAD_GUITAR_HERO_3_BUTTON_STRUM_UP
|
||||
| WPAD_GUITAR_HERO_3_BUTTON_YELLOW | WPAD_GUITAR_HERO_3_BUTTON_GREEN
|
||||
| WPAD_GUITAR_HERO_3_BUTTON_BLUE | WPAD_GUITAR_HERO_3_BUTTON_RED
|
||||
| WPAD_GUITAR_HERO_3_BUTTON_ORANGE | WPAD_GUITAR_HERO_3_BUTTON_PLUS
|
||||
| WPAD_GUITAR_HERO_3_BUTTON_MINUS | WPAD_GUITAR_HERO_3_BUTTON_STRUM_DOWN)
|
||||
)
|
||||
*/
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define _WPAD_H_
|
||||
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <ogc/pad.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@ -11,8 +12,8 @@ extern "C"
|
||||
/* Prototypes */
|
||||
s32 Wpad_Init(void);
|
||||
void Wpad_Disconnect(void);
|
||||
u32 Wpad_GetButtons(void);
|
||||
u32 Wpad_WaitButtons(void);
|
||||
u32 ButtonsPressed(void);
|
||||
u32 ButtonsHold(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user