*Changed the code for CreditsWindow

*Added ButtonsHold and ButtonsPressed functions
*Some cleanups
This commit is contained in:
dimok321 2009-06-01 13:35:43 +00:00
parent 24d98683b3
commit 976ea2041c
6 changed files with 147 additions and 142 deletions

View File

@ -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] = new GuiText(NULL, 20, (GXColor){THEME.settingsTxt_r, THEME.settingsTxt_g, THEME.settingsTxt_b, 0xff});
optionValOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); 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]->SetParent(this);
optionBtn[i]->SetLabel(optionTxt[i], 0); optionBtn[i]->SetLabel(optionTxt[i], 0);
optionBtn[i]->SetLabel(optionVal[i], 1); optionBtn[i]->SetLabel(optionVal[i], 1);
@ -491,12 +491,7 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
scrollbarBoxBtn->Draw(); scrollbarBoxBtn->Draw();
usleep(10000 * scrolldelay); usleep(10000 * scrolldelay);
} }
WPAD_ScanPads(); if (ButtonsHold() == WPAD_BUTTON_A)
u8 cnt, buttons = NULL;
/* Get pressed buttons */
for (cnt = 0; cnt < 4; cnt++)
buttons |= WPAD_ButtonsHeld(cnt);
if (buttons == WPAD_BUTTON_A)
{ {
} }
else else
@ -528,12 +523,7 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
} }
WPAD_ScanPads(); if (ButtonsHold() == WPAD_BUTTON_A)
u8 cnt, buttons = NULL;
/* Get pressed buttons */
for (cnt = 0; cnt < 4; cnt++)
buttons |= WPAD_ButtonsHeld(cnt);
if (buttons == WPAD_BUTTON_A)
{ {
} }
else else

View File

@ -411,12 +411,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
scrollbarBoxBtn->Draw(); scrollbarBoxBtn->Draw();
usleep(10000 * scrolldelay); usleep(10000 * scrolldelay);
} }
WPAD_ScanPads(); if (ButtonsHold() == WPAD_BUTTON_A)
u8 cnt, buttons = NULL;
/* Get pressed buttons */
for (cnt = 0; cnt < 4; cnt++)
buttons |= WPAD_ButtonsHeld(cnt);
if (buttons == WPAD_BUTTON_A)
{ {
} }
else else
@ -446,12 +441,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
scrollbarBoxBtn->Draw(); scrollbarBoxBtn->Draw();
usleep(10000 * scrolldelay); usleep(10000 * scrolldelay);
} }
WPAD_ScanPads(); if (ButtonsHold() == WPAD_BUTTON_A)
u8 cnt, buttons = NULL;
/* Get pressed buttons */
for (cnt = 0; cnt < 4; cnt++)
buttons |= WPAD_ButtonsHeld(cnt);
if (buttons == WPAD_BUTTON_A)
{ {
} }
else else
@ -459,8 +449,6 @@ void GuiGameBrowser::Update(GuiTrigger * t)
arrowUpBtn->ResetState(); arrowUpBtn->ResetState();
} }
} }
WPAD_ScanPads();
u8 cnt, buttons = NULL;/////////////////////////////////////////////////////scroll by holding B and tilt wiimote
int position1 = 0; int position1 = 0;
@ -471,10 +459,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
position2 = position1; position2 = position1;
} }
for (cnt = 0; cnt < 4; cnt++) if (ButtonsHold() == WPAD_BUTTON_B && position1 > 0)
buttons |= WPAD_ButtonsHeld(cnt);
if (buttons == WPAD_BUTTON_B && position1 > 0)
{ {
scrollbarBoxBtn->ScrollIsOn(1); scrollbarBoxBtn->ScrollIsOn(1);
if (position2 > position1) if (position2 > position1)
@ -524,7 +509,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
} }
} }
else if (!buttons) else if(ButtonsHold() != WPAD_BUTTON_B)
{ {
scrollbarBoxBtn->ScrollIsOn(0); scrollbarBoxBtn->ScrollIsOn(0);
position2 = 0; position2 = 0;

View File

@ -346,10 +346,8 @@ void GuiGameCarousel::Update(GuiTrigger * t)
return; // skip navigation return; // skip navigation
if (t->Left() || btnLeft->GetState() == STATE_CLICKED) { if (t->Left() || btnLeft->GetState() == STATE_CLICKED) {
WPAD_ScanPads();
u16 buttons = 0; u16 buttons = ButtonsHold();
for(int i=0; i<4; i++)
buttons |= WPAD_ButtonsHeld(i);
if(!((buttons & WPAD_BUTTON_A) || (buttons & WPAD_BUTTON_MINUS) || t->Left())) { if(!((buttons & WPAD_BUTTON_A) || (buttons & WPAD_BUTTON_MINUS) || t->Left())) {
btnLeft->ResetState(); btnLeft->ResetState();
speed = SHIFT_SPEED; speed = SHIFT_SPEED;
@ -380,10 +378,8 @@ void GuiGameCarousel::Update(GuiTrigger * t)
} }
else if(t->Right() || btnRight->GetState() == STATE_CLICKED) { else if(t->Right() || btnRight->GetState() == STATE_CLICKED) {
WPAD_ScanPads();
u16 buttons = 0; u16 buttons = ButtonsHold();
for(int i=0; i<4; i++)
buttons |= WPAD_ButtonsHeld(i);
if(!((buttons & WPAD_BUTTON_A) || (buttons & WPAD_BUTTON_PLUS) || t->Right())) { if(!((buttons & WPAD_BUTTON_A) || (buttons & WPAD_BUTTON_PLUS) || t->Right())) {
btnRight->ResetState(); btnRight->ResetState();
speed=SHIFT_SPEED; speed=SHIFT_SPEED;

View File

@ -50,20 +50,17 @@ extern FreeTypeGX *fontClock; //CLOCK
static GuiImage * coverImg = NULL; static GuiImage * coverImg = NULL;
static GuiImageData * cover = NULL; static GuiImageData * cover = NULL;
//char GamesHDD[320][14];
static struct discHdr *gameList = NULL; static struct discHdr *gameList = NULL;
static GuiImageData * pointer[4]; static GuiImageData * pointer[4];
static GuiImage * bgImg = NULL; static GuiImage * bgImg = NULL;
static GuiButton * btnLogo = NULL;
static GuiImageData * background = NULL; static GuiImageData * background = NULL;
static GuiText prTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); 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 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 sizeTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
static GuiText *GameIDTxt = NULL; static GuiText * GameIDTxt = NULL;
static GuiText *GameRegionTxt = NULL; static GuiText * GameRegionTxt = NULL;
static GuiSound * bgMusic = NULL; static GuiSound * bgMusic = NULL;
static wbfs_t *hdd = NULL; static wbfs_t * hdd = NULL;
static u32 gameCnt = 0; static u32 gameCnt = 0;
static s32 gameSelected = 0, gameStart = 0; static s32 gameSelected = 0, gameStart = 0;
static GuiWindow * mainWindow = NULL; static GuiWindow * mainWindow = NULL;
@ -168,14 +165,11 @@ HaltGui()
* WindowCredits * WindowCredits
* Display credits * Display credits
***************************************************************************/ ***************************************************************************/
static void WindowCredits(void * ptr) void WindowCredits()
{ {
int angle = 0; int angle = 0;
GuiSound * creditsMusic = NULL; GuiSound * creditsMusic = NULL;
if(btnLogo->GetState() != STATE_CLICKED) {
return;
}
s32 thetimeofbg = bgMusic->GetPlayTime(); s32 thetimeofbg = bgMusic->GetPlayTime();
StopOgg(); StopOgg();
@ -184,8 +178,6 @@ static void WindowCredits(void * ptr)
creditsMusic->SetLoop(1); creditsMusic->SetLoop(1);
creditsMusic->Play(); creditsMusic->Play();
btnLogo->ResetState();
bool exit = false; bool exit = false;
int i = 0; int i = 0;
int y = 20; int y = 20;
@ -330,48 +322,40 @@ static void WindowCredits(void * ptr)
creditsWindow.Append(&creditsWindowBox); creditsWindow.Append(&creditsWindowBox);
creditsWindow.Append(&starImg); creditsWindow.Append(&starImg);
creditsWindow.SetEffect(EFFECT_FADE, 30);
HaltGui();
mainWindow->SetState(STATE_DISABLED);
mainWindow->Append(&creditsWindow);
ResumeGui();
while(!exit) while(!exit)
{ {
creditsWindow.Draw(); angle++;
if(angle > 360)
angle ++; angle = 0;
angle = int(angle) % 360;
usleep(12000); usleep(12000);
starImg.SetAngle(angle); starImg.SetAngle(angle);
if(ButtonsPressed() != 0)
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; 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(); creditsMusic->Stop();
for(i=0; i < numEntries; i++)
delete txt[i];
delete creditsMusic; 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)) { if(!strcmp("", CFG.oggload_path) || !strcmp("notset", CFG.ogg_path)) {
bgMusic->Play(); bgMusic->Play();
} else { } else {
@ -4559,16 +4543,16 @@ static int MenuSettings()
GuiImage logoImg(&logo); GuiImage logoImg(&logo);
GuiImageData logoOver(credits_button_over_png); GuiImageData logoOver(credits_button_over_png);
GuiImage logoImgOver(&logoOver); GuiImage logoImgOver(&logoOver);
btnLogo = new GuiButton(logoImg.GetWidth(), logoImg.GetHeight());
btnLogo->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); GuiButton btnLogo(logoImg.GetWidth(), logoImg.GetHeight());
btnLogo->SetPosition(0, -35); btnLogo.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
btnLogo->SetImage(&logoImg); btnLogo.SetPosition(0, -35);
btnLogo->SetImageOver(&logoImgOver); btnLogo.SetImage(&logoImg);
btnLogo->SetEffectGrow(); btnLogo.SetImageOver(&logoImgOver);
btnLogo->SetSoundOver(&btnSoundOver); btnLogo.SetEffectGrow();
btnLogo->SetSoundClick(&btnClick); btnLogo.SetSoundOver(&btnSoundOver);
btnLogo->SetTrigger(&trigA); btnLogo.SetSoundClick(&btnClick);
btnLogo->SetUpdateCallback(WindowCredits); btnLogo.SetTrigger(&trigA);
customOptionList options2(9); customOptionList options2(9);
GuiCustomOptionBrowser optionBrowser2(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 0, 150); 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(&backBtn);
w.Append(&lockBtn); w.Append(&lockBtn);
w.Append(&updateBtn); w.Append(&updateBtn);
w.Append(btnLogo); w.Append(&btnLogo);
w.Append(&homo); w.Append(&homo);
//set triggers for tabs //set triggers for tabs
page1Btn.RemoveTrigger(1); page1Btn.RemoveTrigger(1);
@ -5036,7 +5020,7 @@ static int MenuSettings()
w.Append(&backBtn); w.Append(&backBtn);
w.Append(&lockBtn); w.Append(&lockBtn);
w.Append(&updateBtn); w.Append(&updateBtn);
w.Append(btnLogo); w.Append(&btnLogo);
mainWindow->Append(&optionBrowser2); mainWindow->Append(&optionBrowser2);
mainWindow->Append(&page1Btn); mainWindow->Append(&page1Btn);
@ -5306,7 +5290,7 @@ static int MenuSettings()
mainWindow->Remove(&page2Btn); mainWindow->Remove(&page2Btn);
mainWindow->Remove(&tabBtn); mainWindow->Remove(&tabBtn);
mainWindow->Remove(&page3Btn); mainWindow->Remove(&page3Btn);
w.Remove(btnLogo); w.Remove(&btnLogo);
w.Remove(&backBtn); w.Remove(&backBtn);
w.Remove(&lockBtn); w.Remove(&lockBtn);
w.Remove(&updateBtn); w.Remove(&updateBtn);
@ -5322,13 +5306,36 @@ static int MenuSettings()
w.Append(&backBtn); w.Append(&backBtn);
w.Append(&lockBtn); w.Append(&lockBtn);
w.Append(&updateBtn); w.Append(&updateBtn);
w.Append(btnLogo); w.Append(&btnLogo);
} else { } else {
WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtousethatoption, LANGUAGE.ok, 0,0,0); WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtousethatoption, LANGUAGE.ok, 0,0,0);
} }
updateBtn.ResetState(); 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(lockBtn.GetState() == STATE_CLICKED)
{ {
if (!strcmp("", Settings.unlockCode)) if (!strcmp("", Settings.unlockCode))
@ -5443,8 +5450,6 @@ static int MenuSettings()
} }
} }
HaltGui(); HaltGui();
delete btnLogo;
btnLogo = NULL;
mainWindow->Remove(&optionBrowser2); mainWindow->Remove(&optionBrowser2);
mainWindow->Remove(&w); mainWindow->Remove(&w);
ResumeGui(); ResumeGui();
@ -6304,16 +6309,16 @@ int MainMenu(int menu)
delete background; delete background;
delete bgImg; delete bgImg;
delete mainWindow; delete mainWindow;
mainWindow = NULL;
delete pointer[0]; delete pointer[0];
delete pointer[1]; delete pointer[1];
delete pointer[2]; delete pointer[2];
delete pointer[3]; delete pointer[3];
delete GameRegionTxt;
delete GameIDTxt;
delete cover; delete cover;
delete coverImg; delete coverImg;
mainWindow = NULL;
ExitApp(); ExitApp();
struct discHdr *header = &gameList[gameSelected]; struct discHdr *header = &gameList[gameSelected];

View File

@ -43,31 +43,59 @@ void Wpad_Disconnect(void)
WPAD_Shutdown(); WPAD_Shutdown();
} }
u32 Wpad_GetButtons(void) u32 ButtonsHold(void) {
{
u32 buttons = 0, cnt;
/* Scan pads */ int i;
WPAD_ScanPads();
/* Get pressed buttons */
for (cnt = 0; cnt < MAX_WIIMOTES; cnt++)
buttons |= WPAD_ButtonsDown(cnt);
return buttons;
}
u32 Wpad_WaitButtons(void)
{
u32 buttons = 0; u32 buttons = 0;
/* Wait for button pressing */ WPAD_ScanPads();
while (!buttons) { PAD_ScanPads();
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)
)
*/
}

View File

@ -2,6 +2,7 @@
#define _WPAD_H_ #define _WPAD_H_
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include <ogc/pad.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
@ -11,8 +12,8 @@ extern "C"
/* Prototypes */ /* Prototypes */
s32 Wpad_Init(void); s32 Wpad_Init(void);
void Wpad_Disconnect(void); void Wpad_Disconnect(void);
u32 Wpad_GetButtons(void); u32 ButtonsPressed(void);
u32 Wpad_WaitButtons(void); u32 ButtonsHold(void);
#ifdef __cplusplus #ifdef __cplusplus
} }