From e60695332e9d044b558ce5535f94cf42d1459b0f Mon Sep 17 00:00:00 2001 From: giantpune Date: Mon, 25 May 2009 12:10:34 +0000 Subject: [PATCH] added grid display (still has mucho buggos so don't make issues of them) added azerty keyboard and other small stuff. --- gui.pnproj | 2 +- source/cfg.c | 10 + source/cfg.h | 8 + source/filelist.h | 3 + source/images/arrangeList_gray.png | Bin 0 -> 1560 bytes source/libwiigui/gui_gamegrid.cpp | 625 +++++++++++++++++++++++++++++ source/libwiigui/gui_gamegrid.h | 108 +++++ source/libwiigui/gui_keyboard.cpp | 66 ++- source/menu.cpp | 153 ++++++- 9 files changed, 949 insertions(+), 26 deletions(-) create mode 100644 source/images/arrangeList_gray.png create mode 100644 source/libwiigui/gui_gamegrid.cpp create mode 100644 source/libwiigui/gui_gamegrid.h diff --git a/gui.pnproj b/gui.pnproj index 8afde869..66b2d8d6 100644 --- a/gui.pnproj +++ b/gui.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/source/cfg.c b/source/cfg.c index 992b0c25..062e0753 100644 --- a/source/cfg.c +++ b/source/cfg.c @@ -57,6 +57,7 @@ u8 wsprompt = 0; u8 keyset = 0; u8 favorite = 0; u16 count = 0; +u8 listDisplay = 0; #define TITLE_MAX 65 @@ -869,6 +870,13 @@ void global_cfg_set(char *name, char *val) } return; } + else if (strcmp(name, "gameDisplay") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.gameDisplay = i; + } + return; + } } // split line to part1 delimiter part2 @@ -1079,6 +1087,7 @@ bool cfg_save_global()// save global settings } fprintf(f, "ogg_path = %s\n ", CFG.ogg_path); fprintf(f, "wiilight = %d\n ", Settings.wiilight); + fprintf(f, "gameDisplay = %d\n ", Settings.gameDisplay); fclose(f); return true; } @@ -1265,6 +1274,7 @@ bool cfg_load_global() Settings.wsprompt = off; Settings.keyset = us; Settings.hddinfo = hr12; + Settings.gameDisplay = list; Settings.sinfo = ((THEME.showID) ? GameID : Neither); Settings.rumble = RumbleOn; if (THEME.showRegion) diff --git a/source/cfg.h b/source/cfg.h index 3ef38f44..907a1f54 100644 --- a/source/cfg.h +++ b/source/cfg.h @@ -157,6 +157,7 @@ extern u8 sort; extern u8 fave; extern u8 wsprompt; extern u8 keyset; +extern u8 gameDisplay; struct Game_CFG { @@ -277,6 +278,12 @@ enum { us, dvorak, euro, + azerty, +}; +enum { + list, + grid, + carousel, }; struct SSettings { @@ -301,6 +308,7 @@ struct SSettings { int sort; int fave; int wiilight; + int gameDisplay; }; void CFG_LoadGlobal(void); diff --git a/source/filelist.h b/source/filelist.h index 4f2c6b71..b5e972ba 100644 --- a/source/filelist.h +++ b/source/filelist.h @@ -281,6 +281,9 @@ extern const u32 playCountIcon_gray_png_size; extern const u8 arrangeGrid_gray_png[]; extern const u32 arrangeGrid_gray_png_size; +extern const u8 arrangeList_gray_png[]; +extern const u32 arrangeList_gray_png_size; + extern const u8 arrangeCarosselle_gray_png[]; extern const u32 arrangeCarosselle_gray_png_size; diff --git a/source/images/arrangeList_gray.png b/source/images/arrangeList_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..6ddeecf35b4a5cedaf041fbedeea74010bb881bb GIT binary patch literal 1560 zcmV+z2Iu*SP)U8P*7-ZbZ>KLZ*U+lnSp_Ufq@}0xwybFAi#%#fq@|}KQEO56)-X|e7nZL z$iTqBa9P*U#mSX{G{Bl%P*lRez;J+pfx##xwK$o9f#C}S14DXwNkIt%17i#W1A|CX zc0maP17iUL1A|C*NRTrF17iyV0~1e4YDEbH0|SF|enDkXW_m`6f}y3QrGjHhep0GJ zaAk2xYHqQDXI^rCQ9*uDVo7QW0|Nup4h9AW240u^5(W3f%sd4n162kpgNVo|1qcff zJ_s=cNG>fZg9jx8g8+j9g8_pBLjXe}Lp{R+hNBE`7{wV~7)u#fFy3PlV+vxLz;uCG zm^qSpA@ds+OO_6nTdaDlt*rOhEZL^9ePa)2-_4=K(Z%tFGm-NGmm}8}ZcXk5JW@PU zd4+f<@d@)yL(o<5icqT158+-B6_LH7;i6x}CW#w~Uy-Pgl#@Irl`kzV zeL|*8R$ca%T%Wv){2zs_iiJvgN^h0dsuZZ2sQy$tsNSU!s;Q*;LF<6_B%M@UD?LHI zSNcZ`78uqV#TeU~$eS{ozBIdFzSClfs*^S+dw;4dus<{M;#|MXC)T}S9v!D zcV!QCPhBq)ZyO(X-(bH4|NMaZz==UigLj2o41F2S6d@OB6%`R(5i>J(Puzn9wnW{e zu;hl6HK{k#IWjCVGqdJqU(99Cv(K+6*i`tgSi2;vbXD1#3jNBGs$DgVwO(~o>mN4i zHPtkqZIx>)Y(Ls5-Br|mx>vQYvH$Kwn@O`L|D75??eGkZnfg$5<;Xeg_o%+-I&+-3%01W^SH2RkDT>t<8AY({UO#lFTB>(_`g8%^e z{{R4h=>PzAFaQARU;qF*m;eA5Z<1fdMgRZ;dPzhq z3DNOU(2#~MH9?!*=5@vib_+@P5zqrj zu5sxAy96}FS01P>HPpHY=h*WUfd_VL4sW6z-z_=EE<+>)Li!&$^Xmf#;rxO> zST`UQpJiBA#_Ro_AIx}+087qF%16vYV*dr>*rMkW00+SWuwsEdO;4;F;D6>^D>2BP05fI=P^R^?ZN-7<@?1Z>Yh${kvAXt-% z@RgGWur7{c!gX%5l@j9>63-aGN_zQVAeS+5XEjKn29rD41A1~Z=E;{9a<98Y*kh-N z+Xv$z4F;PN`=z0rM@H%926rp%3MNHO1O(+#6;0bSnWR>vGnny|qjAP*l{p4r!j&NA z44I2T&S6}iIUX5RWkzqYU%<6RG6=Ry7Y?iR%g78IrXh-^OG202DasM28&#Oopls9A z7rheUiYhCgI36^YOVTY}C@U^=jeE(Z38xZe5AbyDB;5RU5xN9yu{Oo@lX)N%)37S) z2ZF=0M<1+N4K{v4F+M_1=3Ss%_O7XBj$^`2_UVhhffwni^Er$(o)sz_lXTgBn$EuA zJ3Y?>pm@NxqBNIfbRH^Cc*`^iJW-|@2HHf#=w5hOsMeOkZuRGNHuh!FYTm?s=ZAwP zwdr8m$!MF^SuXRt%`W!U{ZY>o?WFiw8ghs~OS)*f>7sw<{tf`w@C%U8AFUPu0000< KMNUMnLSTZJ%B{x$ literal 0 HcmV?d00001 diff --git a/source/libwiigui/gui_gamegrid.cpp b/source/libwiigui/gui_gamegrid.cpp new file mode 100644 index 00000000..29760c22 --- /dev/null +++ b/source/libwiigui/gui_gamegrid.cpp @@ -0,0 +1,625 @@ +/**************************************************************************** + * libwiigui + * + * gui_gamebrowser.cpp + * + * GUI class definitions + ***************************************************************************/ + +#include "gui.h" +#include "../wpad.h" + +#include +#include "gui_gamegrid.h" +#include "../cfg.h" + +#include +#include + +#define GAMESELECTSIZE 30 +extern const int vol; +//int txtscroll = 0; +int changed = 0; +int tooMuch; +/** + * Constructor for the GuiGameGrid class. + */ +GuiGameGrid::GuiGameGrid(int w, int h, struct discHdr * l, int gameCnt, const char *themePath, const u8 *imagebg, int selected, int offset) +{ + width = 640; + height = h; + this->gameCnt = gameCnt; + gameList = l; + pagesize = 8; + scrollbaron = (gameCnt > pagesize) ? 1 : 0; + selectable = true; + listOffset = (offset == 0) ? this->FindMenuItem(-1, 1) : offset; + selectedItem = selected - offset; + focus = 1; // allow focus + char imgPath[100]; + tooMuch=(gameCnt-(gameCnt%8)); + + trigA = new GuiTrigger; + trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + trigHeldA = new GuiTrigger; + trigL = new GuiTrigger; + trigL->SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT); + trigR = new GuiTrigger; + trigR->SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT); + trigPlus = new GuiTrigger; + trigPlus->SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0); + trigMinus = new GuiTrigger; + trigMinus->SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0); + + btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM, vol); + + snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path); + imgLeft = new GuiImageData(imgPath, startgame_arrow_left_png); + snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path); + imgRight = new GuiImageData(imgPath, startgame_arrow_right_png); + + btnLeftImg = new GuiImage(imgLeft); + btnLeft = new GuiButton(imgLeft->GetWidth(), imgLeft->GetHeight()); + //GuiImage btnLeftImg(&imgLeft); + //GuiButton btnLeft(imgLeft.GetWidth(), imgLeft.GetHeight()); + btnLeft->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + btnLeft->SetPosition(20, -30); + btnLeft->SetParent(this); + btnLeft->SetImage(btnLeftImg); + btnLeft->SetSoundOver(btnSoundOver); + btnLeft->SetTrigger(trigA); + btnLeft->SetTrigger(trigL); + btnLeft->SetTrigger(trigMinus); + btnLeft->SetEffectGrow(); + + btnRightImg = new GuiImage(imgRight); + btnRight = new GuiButton(imgRight->GetWidth(), imgRight->GetHeight()); + //GuiButton btnRight(imgRight.GetWidth(), imgRight.GetHeight()); + btnRight->SetParent(this); + btnRight->SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); + btnRight->SetPosition(-20, -30); + btnRight->SetImage(btnRightImg); + btnRight->SetSoundOver(btnSoundOver); + btnRight->SetTrigger(trigA); + btnRight->SetTrigger(trigR); + btnRight->SetTrigger(trigPlus); + btnRight->SetEffectGrow(); + + gameIndex = new int[pagesize]; + game = new GuiButton * [pagesize]; + //gameTxt = new GuiText * [pagesize]; + //gameBg = new GuiImage * [pagesize]; + coverImg = new GuiImage * [pagesize]; + cover = new GuiImageData * [pagesize]; + + //char buffer[THEME.maxcharacters + 4]; + char ID[4]; + char IDfull[7]; + + for(int i=0; i < pagesize; i++) + { + /*if (strlen(get_title(&gameList[i])) < (u32)(THEME.maxcharacters + 3)) + { + sprintf(buffer, "%s", get_title(&gameList[i])); + } + else + { + sprintf(buffer, get_title(&gameList[i]), THEME.maxcharacters); + buffer[THEME.maxcharacters] = '\0'; + strncat(buffer, "...", 3); + } + *///////////////////////////////////////////////// + + struct discHdr *header = &gameList[i]; + snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); + snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + //w.Remove(&DownloadBtn); + + //load game cover + //if (cover) + //{ + // delete cover; + // cover = NULL; + //} + + snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, IDfull); + cover[i] = new GuiImageData(imgPath,0); //load short id + if (!cover[i]->GetImage()) //if could not load the short id image + { + delete cover[i]; + snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, ID); + cover[i] = new GuiImageData(imgPath, 0); //load full id image + if (!cover[i]->GetImage()) + { + delete cover[i]; + snprintf(imgPath, sizeof(imgPath), "%snoimage.png", CFG.covers_path); + cover[i] = new GuiImageData(imgPath, nocover_png); //load no image + } + } + + //if (coverImg) + //{ + // delete coverImg; + // coverImg = NULL; + //} + coverImg[i] = new GuiImage(cover[i]); + coverImg[i]->SetWidescreen(CFG.widescreen); + coverImg[i]->SetScale(0.6); + + //DownloadBtn.SetImage(coverImg);// put the new image on the download button + //w.Append(&DownloadBtn); + ///////////////////////////////////////////////// + + //gameTxt[i] = new GuiText(buffer, 20, (GXColor){THEME.gameText_r, THEME.gameText_g, THEME.gameText_b, 0xff}); + //gameTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + //gameTxt[i]->SetPosition(24,0); + + //gameBg[i] = new GuiImage(bgGamesEntry); + + game[i] = new GuiButton(coverImg[i]->GetWidth()*.45,coverImg[i]->GetHeight()*.7); + game[i]->SetParent(this); + game[i]->SetAlignment(ALIGN_TOP,ALIGN_LEFT); + //game[i]->SetLabel(gameTxt[i]); + //game[i]->SetImageOver(gameBg[i]); + game[i]->SetImage(coverImg[i]); + coverImg[i]->SetParent(game[i]); + //coverImg[i]->SetAlignment(ALIGN_CENTRE,ALIGN_MIDDLE); + coverImg[i]->SetPosition(-10,-35); + //game[i]->SetPosition(5,GAMESELECTSIZE*i+4); + if (i<4)game[i]->SetPosition(117+i*110,25); + if (i>3)game[i]->SetPosition(117+(i-4)*110,185); + game[i]->SetRumble(false); + game[i]->SetTrigger(trigA); + game[i]->SetSoundClick(btnSoundClick); + game[i]->SetEffectGrow(); + coverImg[i]->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); + } +} + +/** + * Destructor for the GuiGameGrid class. + */ +//GuiGameGrid::~GuiGameGrid() +GuiGameGrid::~GuiGameGrid() +{ + + delete imgRight; + delete imgLeft; + delete btnLeftImg; + delete btnRightImg; + delete btnRight; + delete btnLeft; + + delete trigA; + delete btnSoundClick; + + for(int i=0; iResetState(); + + if(f == 1) + game[selectedItem]->SetState(STATE_SELECTED); +} + +void GuiGameGrid::ResetState() +{ + LOCK(this); + if(state != STATE_DISABLED) + { + state = STATE_DEFAULT; + stateChan = -1; + } + + for(int i=0; iResetState(); + } +} + +int GuiGameGrid::GetOffset() +{ + return changed; +} +int GuiGameGrid::GetClickedOption() +{ + int found = -1; + for(int i=0; iGetState() == STATE_CLICKED) + { + game[i]->SetState(STATE_SELECTED); + found = changed+i; + break; + } + } + return found; +} + +int GuiGameGrid::GetSelectedOption() +{ + int found = -1; + for(int i=0; iGetState() == STATE_SELECTED) + { + game[i]->SetState(STATE_SELECTED); + found = changed+i; + break; + } + } + return found; +} + +/**************************************************************************** + * FindMenuItem + * + * Help function to find the next visible menu item on the list + ***************************************************************************/ + +int GuiGameGrid::FindMenuItem(int currentItem, int direction) +{ + int nextItem = currentItem + direction; + + if(nextItem < 0 || nextItem >= gameCnt) + return -1; + + if(strlen(get_title(&gameList[nextItem])) > 0) + return nextItem; + else + return FindMenuItem(nextItem, direction); +} + +/** + * Draw the button on screen + */ +void GuiGameGrid::Draw() +{ + LOCK(this); + if(!this->IsVisible()) + return; + + //bgGameImg->Draw(); + + + int next = listOffset; + + for(int i=0; i= 0) + { + game[i]->Draw(); + next = this->FindMenuItem(next, 1); + } + else + break; + } + + btnRight->Draw(); + btnLeft->Draw(); + this->UpdateEffects(); +} + +void GuiGameGrid::Update(GuiTrigger * t) +{ + LOCK(this); + if(state == STATE_DISABLED || !t) + return; + + int next; //prev; + //static int position2; + u8 over=0; + //if (changed>gameCnt){changed=tooMuch;over=1;} + + //int extra=(gameCnt-changed-1); + + + // scrolldelay affects how fast the list scrolls + // when the arrows are clicked + //float scrolldelay = 3.5; + + + btnRight->Update(t); + btnLeft->Update(t); + + next = listOffset; + //char buffer[THEME.maxcharacters + 4]; + char ID[4]; + char IDfull[7]; + char imgPath[100]; + + for(int i=0; i= 0) + { + if(game[i]->GetState() == STATE_DISABLED) + { + game[i]->SetVisible(true); + game[i]->SetState(STATE_DEFAULT); + } + + + /*if (strlen(get_title(&gameList[next])) < (u32)(THEME.maxcharacters + 3)) + { + sprintf(buffer, "%s", get_title(&gameList[next])); + } + else + { + sprintf(buffer, get_title(&gameList[next]), THEME.maxcharacters); + buffer[THEME.maxcharacters] = '\0'; + strncat(buffer, "...", 3); + } + + gameTxt[i]->SetText(buffer); + gameTxt[i]->SetPosition(24, 0);*/ + + gameIndex[i] = next; + next = this->FindMenuItem(next, 1); + } + else + { + game[i]->SetVisible(false); + game[i]->SetState(STATE_DISABLED); + } + + if(focus) + { + if(i != selectedItem && game[i]->GetState() == STATE_SELECTED) + game[i]->ResetState(); + else if(i == selectedItem && game[i]->GetState() == STATE_DEFAULT) + game[selectedItem]->SetState(STATE_SELECTED, t->chan); + } + + game[i]->Update(t); + + if(game[i]->GetState() == STATE_SELECTED) + { + selectedItem = i; + } + } + + // pad/joystick navigation + if(!focus) + return; // skip navigation + + if (scrollbaron == 1) { + + if ((t->Right() || + btnRight->GetState() == STATE_CLICKED) ) + //&&(changed<(tooMuch+1))) + { + + //////////////////////////////////////////// + changed += pagesize; + if (changed>gameCnt)changed=0; + + + for(int i=0; iid[0], header->id[1], header->id[2]); + snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + + snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, IDfull); + cover[i] = new GuiImageData(imgPath,0); //load short id + if (!cover[i]->GetImage()) //if could not load the short id image + { + delete cover[i]; + snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, ID); + cover[i] = new GuiImageData(imgPath, 0); //load full id image + if (!cover[i]->GetImage()) + { + delete cover[i]; + snprintf(imgPath, sizeof(imgPath), "%snoimage.png", CFG.covers_path); + cover[i] = new GuiImageData(imgPath, nocover_png); //load no image + } + } + + coverImg[i] = new GuiImage(cover[i]); + coverImg[i]->SetWidescreen(CFG.widescreen); + coverImg[i]->SetScale(0.6); + coverImg[i]->SetParent(game[i]); + //coverImg[i]->SetAlignment(ALIGN_CENTRE,ALIGN_MIDDLE); + coverImg[i]->SetPosition(-10,-35); + game[i]->SetImage(coverImg[i]); + coverImg[i]->SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 65); + //if ((extra<8)&&(i>extra)){ + //if ((changed>gameCnt)){//&& (i>((changed-gameCnt)-1))){ + if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) + coverImg[i]->SetVisible(false);//} + //delete coverImg[i];} + + //} + //else { delete game[i]; + // delete coverImg[i]; + //delete cover[i];} + //} + //usleep(500000); + + } + + //game[i] = new GuiButton(coverImg[i]->GetWidth(),coverImg[i]->GetHeight()); + //game[i]->SetParent(this); + //game[i]->SetImage(coverImg[i]); + //game[i]->SetPosition(5,GAMESELECTSIZE*i+4); + //game[i]->SetRumble(false); + //game[i]->SetTrigger(trigA); + //game[i]->SetSoundClick(btnSoundClick); + //////////////////////////////////////////////////// + + + + WPAD_ScanPads(); + u8 cnt, buttons = NULL; + /* Get pressed buttons */ + for (cnt = 0; cnt < 4; cnt++) + buttons |= WPAD_ButtonsHeld(cnt); + if (buttons == WPAD_BUTTON_A) { + + } else { + btnRight->ResetState(); + + } + + } + else if((t->Left() || + btnLeft->GetState() == STATE_CLICKED)) + //&& (changed>7)) ////////////////////////////////////////////up + //arrowUpBtn->GetState() == STATE_HELD) + {changed -= pagesize;if (changed<0)changed=tooMuch+pagesize; + over=0; + //if (changed<9)changed=0; + + + + + for(int i=0; iSetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 65); + + //usleep(500000); + + //if (changedid[0], header->id[1], header->id[2]); + snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + + snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, IDfull); + cover[i] = new GuiImageData(imgPath,0); //load short id + if (!cover[i]->GetImage()) //if could not load the short id image + { + delete cover[i]; + snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, ID); + cover[i] = new GuiImageData(imgPath, 0); //load full id image + if (!cover[i]->GetImage()) + { + delete cover[i]; + snprintf(imgPath, sizeof(imgPath), "%snoimage.png", CFG.covers_path); + cover[i] = new GuiImageData(imgPath, nocover_png); //load no image + } + } + + coverImg[i] = new GuiImage(cover[i]); + coverImg[i]->SetWidescreen(CFG.widescreen); + coverImg[i]->SetScale(0.6); + coverImg[i]->SetParent(game[i]); + //coverImg[i]->SetAlignment(ALIGN_CENTRE,ALIGN_MIDDLE); + coverImg[i]->SetPosition(-10,-35); + game[i]->ResetState(); + game[i]->SetVisible(true); + game[i]->SetImage(coverImg[i]); + coverImg[i]->SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 65);//} + if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) + coverImg[i]->SetVisible(false); + //usleep(500000); + + } + //prev = this->FindMenuItem(gameIndex[selectedItem], -1); + + //if(prev >= 0) + + + WPAD_ScanPads(); + u8 cnt, buttons = NULL; + /* Get pressed buttons */ + for (cnt = 0; cnt < 4; cnt++) + buttons |= WPAD_ButtonsHeld(cnt); + if (buttons == WPAD_BUTTON_A) { + + } else { + btnLeft->ResetState(); + + } + } + + + + } + + if(updateCB) + updateCB(this); +} + +void GuiGameGrid::Reload(struct discHdr * l, int count) +{ + LOCK(this); + gameList = l; + gameCnt = count; + changed=0; + tooMuch=(gameCnt-(gameCnt%12)); + scrollbaron = (gameCnt > pagesize) ? 1 : 0; + selectedItem = 0; + listOffset = 0; + char ID[4]; + char IDfull[7]; + char imgPath[100]; + + for(int i=0; iSetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50); + + //usleep(500000); + + //if (changedid[0], header->id[1], header->id[2]); + snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + + snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, IDfull); + cover[i] = new GuiImageData(imgPath,0); //load short id + if (!cover[i]->GetImage()) //if could not load the short id image + { + delete cover[i]; + snprintf(imgPath, sizeof(imgPath), "%s%s.png", CFG.covers_path, ID); + cover[i] = new GuiImageData(imgPath, 0); //load full id image + if (!cover[i]->GetImage()) + { + delete cover[i]; + snprintf(imgPath, sizeof(imgPath), "%snoimage.png", CFG.covers_path); + cover[i] = new GuiImageData(imgPath, nocover_png); //load no image + } + } + + coverImg[i] = new GuiImage(cover[i]); + coverImg[i]->SetWidescreen(CFG.widescreen); + coverImg[i]->SetScale(0.6); + coverImg[i]->SetParent(game[i]); + //coverImg[i]->SetAlignment(ALIGN_CENTRE,ALIGN_MIDDLE); + coverImg[i]->SetPosition(-10,-35); + game[i]->ResetState(); + game[i]->SetVisible(true); + game[i]->SetImage(coverImg[i]); + coverImg[i]->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);//} + if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) + coverImg[i]->SetVisible(false); + //usleep(500000); + + game[i]->ResetState();} +} diff --git a/source/libwiigui/gui_gamegrid.h b/source/libwiigui/gui_gamegrid.h new file mode 100644 index 00000000..74dfbc4a --- /dev/null +++ b/source/libwiigui/gui_gamegrid.h @@ -0,0 +1,108 @@ +#ifndef _GUIGAMEGRID_H_ +#define _GUIGAMEGRID_H_ + +#include "gui.h" +#include "../disc.h" +/* +class GameBrowserList { + public: + GameBrowserList(int size) { + name = new char * [size]; + + for (int i = 0; i < size; i++) + { + name[i] = new char[50]; + } + length = size; + }; + ~GameBrowserList(){ + for (int i = 0; i < length; i++) + { + delete [] name[i]; + } + delete [] name; + }; + + public: + int length; + char ** name; +}; +*/ + +class GuiGameGrid : public GuiElement +{ + public: + GuiGameGrid(int w, int h, struct discHdr * l, int gameCnt, const char *themePath, const u8 *imagebg, int selected = 0, int offset = 0); + ~GuiGameGrid(); + int FindMenuItem(int c, int d); + int GetClickedOption(); + int GetSelectedOption(); + void ResetState(); + void SetFocus(int f); + void Draw(); + void Update(GuiTrigger * t); + int GetOffset(); + void Reload(struct discHdr * l, int count); + //GuiText * optionVal[PAGESIZE]; + protected: + int selectedItem; + int listOffset; + int scrollbaron; + int pagesize; + + struct discHdr * gameList; + int gameCnt; + + int * gameIndex; + GuiButton ** game; + GuiText ** gameTxt; + //GuiImage ** gameBg; + GuiImage ** coverImg; + GuiImageData ** cover; + + //GuiButton * arrowUpBtn; + //GuiButton * arrowDownBtn; + //GuiButton * scrollbarBoxBtn; + GuiButton * btnRight; + GuiButton * btnLeft; + + //GuiImage * bgGameImg; + //GuiImage * scrollbarImg; + //GuiImage * arrowDownImg; + //GuiImage * arrowDownOverImg; + //GuiImage * ttarrowUpImg; + //GuiImage * ttarrowDownImg; + //GuiImage * arrowUpImg; + //GuiImage * arrowUpOverImg; + //GuiImage * scrollbarBoxImg; + //GuiImage * scrollbarBoxOverImg; + + GuiImage * btnLeftImg; + GuiImage * btnRightImg; + + GuiText * ttarrowDownTxt; + GuiText * ttarrowUpTxt; + + //GuiImageData * bgGames; + //GuiImageData * bgGamesEntry; + //GuiImageData * scrollbar; + //GuiImageData * arrowDown; + //GuiImageData * arrowDownOver; + //GuiImageData * ttarrow; + //GuiImageData * arrowUp; + //GuiImageData * arrowUpOver; + //GuiImageData * scrollbarBox; + //GuiImageData * scrollbarBoxOver; + GuiImageData * imgLeft; + GuiImageData * imgRight; + + GuiSound * btnSoundOver; + GuiSound * btnSoundClick; + GuiTrigger * trigA; + GuiTrigger * trigL; + GuiTrigger * trigR; + GuiTrigger * trigPlus; + GuiTrigger * trigMinus; + GuiTrigger * trigHeldA; +}; +#endif diff --git a/source/libwiigui/gui_keyboard.cpp b/source/libwiigui/gui_keyboard.cpp index bc9fcdb3..1c336d79 100644 --- a/source/libwiigui/gui_keyboard.cpp +++ b/source/libwiigui/gui_keyboard.cpp @@ -209,6 +209,64 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang) } }; memcpy(keys, thekeys, sizeof(thekeys));} + + //AZERTY// + if (mode == 3){ + Key thekeys[4][11] = { + { + {'1','&','²','À'}, + {'2','~','³','é'}, + {'3','"','#','È'}, + {'4','`','«','ù'}, + {'5','(','[','Ì'}, + {'6','-','|','ì'}, + {'7','µ','»','è'}, + {'8','_','\'','ò'}, + {'9','+','^','ç'}, + {'0','=','@','à'}, + {'°',')',']','Ý'} + }, + { + {'a','A','Æ','Á'}, + {'z','Z','Œ','á'}, + {'e','E','€','É'}, + {'r','R','®','ë'}, + {'t','T','†','Í'}, + {'y','Y','ÿ','í'}, + {'u','U','Õ','Ó'}, + {'i','I','õ','Ò'}, + {'o','O','Ø','Ú'}, + {'p','P','ø','ú'}, + {'$','£','¤','ý'} + }, + { + {'q','Q','æ','Â'}, + {'s','S','œ','â'}, + {'d','D','\0','Ê'}, + {'f','F','ß','ê'}, + {'g','G','\0','Î'}, + {'h','H','\0','î'}, + {'j','J','\0','Ô'}, + {'k','K','\0','ô'}, + {'l','L','\0','Û'}, + {'m','M','\0','û'}, + {'*','%','\0','Ù'} + }, + { + {'<','>','\0','Ã'}, + {'w','W','\0','Ä'}, + {'x','X','\0','Ë'}, + {'c','C','©','Ç'}, + {'v','V','“','Ï'}, + {'b','B','”','ï'}, + {'n','N','\0','Ñ'}, + {',','?','\0','ñ'}, + {';','.','\0','ó'}, + {':','/','\0','ö'}, + {'!','§','\0','Ö'} + } + }; + memcpy(keys, thekeys, sizeof(thekeys));} keyTextbox = new GuiImageData(keyboard_textbox_png); keyTextboxImg = new GuiImage(keyTextbox); @@ -236,7 +294,7 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang) trigB->SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); int eurocheck = 0; - if(lang == 2) { + if(mode > 1) { eurocheck = -20; } @@ -251,7 +309,7 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang) keyBack->SetSoundClick(keySoundClick); keyBack->SetTrigger(trigA); keyBack->SetTrigger(trigB); - if (mode == 2){ + if (mode > 1){ keyBack->SetPosition(11*42+40+eurocheck, 0*42+120);} else{ keyBack->SetPosition(10*42+40+eurocheck, 0*42+120);}//(10*42+40, 0*42+80); @@ -284,7 +342,7 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang) keyAlt->SetTrigger(trigA); keyAlt->SetPosition(84+eurocheck, 4*42+120);//(10*42+40, 4*42+120); keyAlt->SetEffectGrow(); - if (mode == 2){this->Append(keyAlt);} + if (mode > 1){this->Append(keyAlt);} keyAlt2Img = new GuiImage(keyMedium); keyAlt2OverImg = new GuiImage(keyMediumOver); @@ -298,7 +356,7 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang) keyAlt2->SetTrigger(trigA); keyAlt2->SetPosition((8*42+40)+eurocheck, 4*42+120);//(10*42+40, 4*42+120); keyAlt2->SetEffectGrow(); - if (mode == 2){this->Append(keyAlt2);} + if (mode > 1){this->Append(keyAlt2);} keyCapsImg = new GuiImage(keyMedium); keyCapsOverImg = new GuiImage(keyMediumOver); diff --git a/source/menu.cpp b/source/menu.cpp index 61dcd3ff..0d8f1ed3 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -31,6 +31,7 @@ #include "wdvd.h" #include "libwbfs/libwbfs.h" #include "sys.h" +#include "libwiigui/gui_gamegrid.h" #include "patchcode.h" #include "wpad.h" #include "cfg.h" @@ -2509,6 +2510,7 @@ static int OnScreenKeyboard(char * var, u32 maxlen, int min) if (Settings.keyset == us) keyset = 0; else if (Settings.keyset == dvorak) keyset = 1; else if (Settings.keyset == euro) keyset = 2; + else if (Settings.keyset == azerty) keyset = 3; GuiKeyboard keyboard(var, maxlen, min, keyset); @@ -2839,6 +2841,8 @@ static int MenuDiscList() GuiImageData imgarrangeGrid(imgPath, arrangeGrid_png); snprintf(imgPath, sizeof(imgPath), "%sarrangeGrid_gray.png", CFG.theme_path); GuiImageData imgarrangeGrid_gray(imgPath, arrangeGrid_gray_png); + snprintf(imgPath, sizeof(imgPath), "%sarrangeList_gray.png", CFG.theme_path); + GuiImageData imgarrangeList_gray(imgPath, arrangeList_gray_png); snprintf(imgPath, sizeof(imgPath), "%sarrangeCarosselle.png", CFG.theme_path); GuiImageData imgarrangeCarosselle(imgPath, arrangeCarosselle_png); snprintf(imgPath, sizeof(imgPath), "%sarrangeCarosselle_gray.png", CFG.theme_path); @@ -3007,10 +3011,13 @@ static int MenuDiscList() countBtn.SetEffectGrow(); countBtn.SetAlpha(180); + GuiImage gridBtnImg(&imgarrangeGrid); gridBtnImg.SetWidescreen(CFG.widescreen); GuiImage gridBtnImg_g(&imgarrangeGrid_gray); + GuiImage listBtnImg_g(&imgarrangeList_gray); gridBtnImg_g.SetWidescreen(CFG.widescreen); + listBtnImg_g.SetWidescreen(CFG.widescreen); GuiButton gridBtn(gridBtnImg.GetWidth(), gridBtnImg.GetHeight()); gridBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);//(ALIGN_CENTRE, ALIGN_MIDDLE); gridBtn.SetPosition(116, 15); @@ -3020,6 +3027,7 @@ static int MenuDiscList() gridBtn.SetTrigger(&trigA); gridBtn.SetEffectGrow(); gridBtn.SetAlpha(180); + if (Settings.gameDisplay==grid)gridBtn.SetImage(&listBtnImg_g); GuiImage carosselleBtnImg(&imgarrangeCarosselle); carosselleBtnImg.SetWidescreen(CFG.widescreen); @@ -3050,6 +3058,13 @@ static int MenuDiscList() countBtn.SetImage(&countBtnImg); countBtn.SetAlpha(255); } + if (Settings.gameDisplay==grid){ + favoriteBtn.SetPosition(-80,13); + abcBtn.SetPosition(-48,13); + countBtn.SetPosition(-16,13); + gridBtn.SetPosition(16,13); + carosselleBtn.SetPosition(48,13); + } //Downloading Covers GuiTooltip DownloadBtnTT(LANGUAGE.ClicktoDownloadCovers); @@ -3073,15 +3088,23 @@ static int MenuDiscList() gameBrowser.SetPosition(THEME.selection_x, THEME.selection_y); gameBrowser.SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); + GuiGameGrid gameGrid(640,400, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset); + gameGrid.SetPosition(0,20); + gameGrid.SetAlignment(ALIGN_LEFT, ALIGN_CENTRE); + GuiText clockTimeBack("88:88", 40, (GXColor){138, 138, 138, 40}); clockTimeBack.SetAlignment(THEME.clockAlign, ALIGN_TOP); clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y); clockTimeBack.SetFont(fontClock); + if (Settings.gameDisplay==grid){ + clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y+3);} GuiText clockTime(theTime, 40, (GXColor){138, 138, 138, 240}); clockTime.SetAlignment(THEME.clockAlign, ALIGN_TOP); clockTime.SetPosition(THEME.clock_x, THEME.clock_y); clockTime.SetFont(fontClock); + if (Settings.gameDisplay==grid){ + clockTime.SetPosition(THEME.clock_x, THEME.clock_y+3);} HaltGui(); GuiWindow w(screenwidth, screenheight); @@ -3114,7 +3137,8 @@ static int MenuDiscList() w.Append(&clockTime); } - mainWindow->Append(&gameBrowser); + if (Settings.gameDisplay==list){mainWindow->Append(&gameBrowser);} + if (Settings.gameDisplay==grid){mainWindow->Append(&gameGrid);} mainWindow->Append(&w); ResumeGui(); @@ -3185,7 +3209,8 @@ static int MenuDiscList() STM_ShutdownToStandby(); } else { poweroffBtn.ResetState(); - gameBrowser.SetFocus(1); + if (Settings.gameDisplay==list){gameBrowser.SetFocus(1);} + else if (Settings.gameDisplay==grid){gameGrid.SetFocus(1);} } } @@ -3213,14 +3238,16 @@ static int MenuDiscList() SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } else { homeBtn.ResetState(); - gameBrowser.SetFocus(1); + if (Settings.gameDisplay==list){gameBrowser.SetFocus(1);} + else if (Settings.gameDisplay==grid){gameGrid.SetFocus(1);} } } else if(wiiBtn.GetState() == STATE_CLICKED) { dataed++; wiiBtn.ResetState(); - gameBrowser.SetFocus(1); + if (Settings.gameDisplay==list){gameBrowser.SetFocus(1);} + else if (Settings.gameDisplay==grid){gameGrid.SetFocus(1);} } else if(installBtn.GetState() == STATE_CLICKED) { @@ -3233,17 +3260,22 @@ static int MenuDiscList() else { installBtn.ResetState(); - gameBrowser.SetFocus(1); + if (Settings.gameDisplay==list){gameBrowser.SetFocus(1);} + else if (Settings.gameDisplay==grid){gameGrid.SetFocus(1);} } } else if(sdcardBtn.GetState() == STATE_CLICKED) { SDCard_deInit(); - SDCard_Init(); - startat = gameBrowser.GetSelectedOption(); - offset = gameBrowser.GetOffset(); - if(isSdInserted()) { + SDCard_Init(); + if (Settings.gameDisplay==list){ + startat = gameBrowser.GetSelectedOption(); + offset = gameBrowser.GetOffset();} + else if (Settings.gameDisplay==grid){ + startat = gameGrid.GetSelectedOption(); + offset = gameGrid.GetOffset();} + if(isSdInserted()) { CFG_Load(); } sdcardBtn.ResetState(); @@ -3304,12 +3336,17 @@ static int MenuDiscList() WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtodownloadimages, LANGUAGE.ok, 0,0,0); } DownloadBtn.ResetState(); - gameBrowser.SetFocus(1); + if (Settings.gameDisplay==list){gameBrowser.SetFocus(1);} + else if (Settings.gameDisplay==grid){gameGrid.SetFocus(1);} }//end download else if(settingsBtn.GetState() == STATE_CLICKED) - { startat = gameBrowser.GetSelectedOption(); - offset = gameBrowser.GetOffset(); + { if (Settings.gameDisplay==list){ + startat = gameBrowser.GetSelectedOption(); + offset = gameBrowser.GetOffset();} + else if (Settings.gameDisplay==grid){ + startat = gameGrid.GetSelectedOption(); + offset = gameGrid.GetOffset();} menu = MENU_SETTINGS; break; @@ -3322,6 +3359,10 @@ static int MenuDiscList() cfg_save_global(); } __Menu_GetEntries(); + if (Settings.gameDisplay==list){ + gameBrowser.Reload(gameList, gameCnt);} + else if (Settings.gameDisplay==grid){ + gameGrid.Reload(gameList, gameCnt);} gameBrowser.Reload(gameList, gameCnt); sprintf(GamesCnt,"%s: %i",LANGUAGE.Games, gameCnt); gamecntTxt.SetText(GamesCnt); @@ -3338,7 +3379,10 @@ static int MenuDiscList() cfg_save_global(); } __Menu_GetEntries(); - gameBrowser.Reload(gameList, gameCnt); + if (Settings.gameDisplay==list){ + gameBrowser.Reload(gameList, gameCnt);} + else if (Settings.gameDisplay==grid){ + gameGrid.Reload(gameList, gameCnt);} selectedold = 1; abcBtn.SetImage(&abcBtnImg); abcBtn.SetAlpha(255); @@ -3356,7 +3400,10 @@ static int MenuDiscList() cfg_save_global(); } __Menu_GetEntries(); - gameBrowser.Reload(gameList, gameCnt); + if (Settings.gameDisplay==list){ + gameBrowser.Reload(gameList, gameCnt);} + else if (Settings.gameDisplay==grid){ + gameGrid.Reload(gameList, gameCnt);} selectedold = 1; abcBtn.SetImage(&abcBtnImg_g); abcBtn.SetAlpha(180); @@ -3365,16 +3412,76 @@ static int MenuDiscList() } countBtn.ResetState(); } - + + else if(gridBtn.GetState() == STATE_CLICKED) + { + if (Settings.gameDisplay==list){ + Settings.gameDisplay=grid; + + mainWindow->Remove(&gameBrowser); + mainWindow->Append(&gameGrid); + if (GameIDTxt)w.Remove(GameIDTxt); + if (GameRegionTxt)w.Remove(GameRegionTxt); + if (coverImg)w.Remove(&DownloadBtn); + gridBtn.SetImage(&listBtnImg_g); + favoriteBtn.SetPosition(-80,13); + abcBtn.SetPosition(-48,13); + countBtn.SetPosition(-16,13); + gridBtn.SetPosition(16,13); + carosselleBtn.SetPosition(48,13); + clockTime.SetPosition(THEME.clock_x, THEME.clock_y+3); + clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y+3); + w.Append(&clockTime); + w.Append(&clockTimeBack); + w.Append(&favoriteBtn); + w.Append(&abcBtn); + w.Append(&countBtn); + w.Append(&gridBtn); + w.Append(&carosselleBtn);} + + else if (Settings.gameDisplay==grid){ + Settings.gameDisplay=list; + + mainWindow->Remove(&gameGrid); + mainWindow->Append(&gameBrowser); + gridBtn.SetImage(&gridBtnImg_g); + favoriteBtn.SetPosition(20,15); + abcBtn.SetPosition(52,15); + countBtn.SetPosition(84,15); + gridBtn.SetPosition(116,15); + carosselleBtn.SetPosition(148,15); + clockTime.SetPosition(THEME.clock_x, THEME.clock_y); + clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y); + w.Append(&clockTime); + w.Append(&clockTimeBack); + w.Append(&favoriteBtn); + w.Append(&abcBtn); + w.Append(&countBtn); + w.Append(&gridBtn); + w.Append(&carosselleBtn);} + + if(isSdInserted()) { + cfg_save_global(); + } + + //menu = MENU_DISCLIST; + gridBtn.ResetState(); + } + + if (Settings.gameDisplay==grid){ + int selectimg; + selectimg = gameGrid.GetSelectedOption(); + gameSelected = gameGrid.GetClickedOption();} + + if (Settings.gameDisplay==list) { //Get selected game under cursor int selectimg;//, promptnumber; char ID[4]; char IDfull[7]; selectimg = gameBrowser.GetSelectedOption(); gameSelected = gameBrowser.GetClickedOption(); - - - + + if (gameSelected > 0) //if click occured selectimg = gameSelected; @@ -3475,6 +3582,7 @@ static int MenuDiscList() } } } + } if ((gameSelected >= 0) && (gameSelected < (s32)gameCnt)) { @@ -3722,13 +3830,15 @@ static int MenuDiscList() else if(choice == 0) - gameBrowser.SetFocus(1); + if (Settings.gameDisplay==list){gameBrowser.SetFocus(1);} + else if (Settings.gameDisplay==grid){gameGrid.SetFocus(1);} } } } HaltGui(); - mainWindow->Remove(&gameBrowser); + if (Settings.gameDisplay==list)mainWindow->Remove(&gameBrowser); + else if (Settings.gameDisplay==grid)mainWindow->Remove(&gameGrid); mainWindow->Remove(&w); ResumeGui(); return menu; @@ -4628,7 +4738,7 @@ static int MenuSettings() if (pageToDisplay == 3){ - if ( Settings.keyset > 2 ) + if ( Settings.keyset > 3 ) Settings.keyset = 0; if ( Settings.unicodefix > 2 ) Settings.unicodefix = 0; @@ -4657,6 +4767,7 @@ static int MenuSettings() if (Settings.keyset == us) sprintf (options2.value[2],"QWERTY"); else if (Settings.keyset == dvorak) sprintf (options2.value[2],"DVORAK"); else if (Settings.keyset == euro) sprintf (options2.value[2],"QWERTZ"); + else if (Settings.keyset == azerty) sprintf (options2.value[2],"AZERTY"); if (Settings.unicodefix == 0) sprintf (options2.value[3],"%s",LANGUAGE.OFF); else if (Settings.unicodefix == 1) sprintf (options2.value[3],"%s",LANGUAGE.TChinese);