*Fixes for Grid (not yet completly done)

This commit is contained in:
dimok321 2009-05-25 17:59:28 +00:00
parent 305dc85fc3
commit 1c0ecfd589
4 changed files with 53 additions and 97 deletions

File diff suppressed because one or more lines are too long

View File

@ -18,9 +18,7 @@
#define GAMESELECTSIZE 30 #define GAMESELECTSIZE 30
extern const int vol; extern const int vol;
//int txtscroll = 0;
int changed = 0;
int tooMuch;
/** /**
* Constructor for the GuiGameGrid class. * Constructor for the GuiGameGrid class.
*/ */
@ -51,7 +49,8 @@ GuiGameGrid::GuiGameGrid(int w, int h, struct discHdr * l, int gameCnt, const ch
trigMinus = new GuiTrigger; trigMinus = new GuiTrigger;
trigMinus->SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0); trigMinus->SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM, vol); btnSoundClick = new GuiSound(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, vol);
btnSoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM, vol);
snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path);
imgLeft = new GuiImageData(imgPath, startgame_arrow_left_png); imgLeft = new GuiImageData(imgPath, startgame_arrow_left_png);
@ -65,6 +64,7 @@ GuiGameGrid::GuiGameGrid(int w, int h, struct discHdr * l, int gameCnt, const ch
btnLeft->SetParent(this); btnLeft->SetParent(this);
btnLeft->SetImage(btnLeftImg); btnLeft->SetImage(btnLeftImg);
btnLeft->SetSoundOver(btnSoundOver); btnLeft->SetSoundOver(btnSoundOver);
btnLeft->SetSoundClick(btnSoundClick);
btnLeft->SetTrigger(trigA); btnLeft->SetTrigger(trigA);
btnLeft->SetTrigger(trigL); btnLeft->SetTrigger(trigL);
btnLeft->SetTrigger(trigMinus); btnLeft->SetTrigger(trigMinus);
@ -77,6 +77,7 @@ GuiGameGrid::GuiGameGrid(int w, int h, struct discHdr * l, int gameCnt, const ch
btnRight->SetPosition(-20, -30); btnRight->SetPosition(-20, -30);
btnRight->SetImage(btnRightImg); btnRight->SetImage(btnRightImg);
btnRight->SetSoundOver(btnSoundOver); btnRight->SetSoundOver(btnSoundOver);
btnRight->SetSoundClick(btnSoundClick);
btnRight->SetTrigger(trigA); btnRight->SetTrigger(trigA);
btnRight->SetTrigger(trigR); btnRight->SetTrigger(trigR);
btnRight->SetTrigger(trigPlus); btnRight->SetTrigger(trigPlus);
@ -128,12 +129,16 @@ GuiGameGrid::GuiGameGrid(int w, int h, struct discHdr * l, int gameCnt, const ch
if (i>3)game[i]->SetPosition(117+(i-4)*110,185); if (i>3)game[i]->SetPosition(117+(i-4)*110,185);
game[i]->SetRumble(false); game[i]->SetRumble(false);
game[i]->SetTrigger(trigA); game[i]->SetTrigger(trigA);
game[i]->SetSoundOver(btnSoundOver);
game[i]->SetSoundClick(btnSoundClick); game[i]->SetSoundClick(btnSoundClick);
game[i]->SetEffectGrow(); game[i]->SetEffectGrow();
game[i]->SetVisible(true); game[i]->SetVisible(true);
if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) game[i]->SetClickable(true);
game[i]->SetVisible(false);
coverImg[i]->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); coverImg[i]->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);
if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) {
game[i]->SetVisible(false);
game[i]->SetClickable(false);
}
} }
} }
@ -297,7 +302,6 @@ void GuiGameGrid::Update(GuiTrigger * t)
game[i]->SetVisible(true); game[i]->SetVisible(true);
game[i]->SetState(STATE_DEFAULT); game[i]->SetState(STATE_DEFAULT);
} }
gameIndex[i] = next; gameIndex[i] = next;
next = this->FindMenuItem(next, 1); next = this->FindMenuItem(next, 1);
} }
@ -312,9 +316,8 @@ void GuiGameGrid::Update(GuiTrigger * t)
if(i != selectedItem && game[i]->GetState() == STATE_SELECTED) if(i != selectedItem && game[i]->GetState() == STATE_SELECTED)
game[i]->ResetState(); game[i]->ResetState();
else if(i == selectedItem && game[i]->GetState() == STATE_DEFAULT) else if(i == selectedItem && game[i]->GetState() == STATE_DEFAULT)
game[selectedItem]->SetState(STATE_SELECTED); game[selectedItem]->SetState(STATE_SELECTED, t->chan);
} }
game[i]->Update(t); game[i]->Update(t);
if(game[i]->GetState() == STATE_SELECTED) if(game[i]->GetState() == STATE_SELECTED)
@ -327,7 +330,7 @@ void GuiGameGrid::Update(GuiTrigger * t)
if(!focus) if(!focus)
return; // skip navigation return; // skip navigation
if ((t->Right() || btnRight->GetState() == STATE_CLICKED) ) { if ((t->Right() || btnRight->GetState() == STATE_CLICKED)) {
changed += pagesize; changed += pagesize;
if (changed>gameCnt-1) if (changed>gameCnt-1)
@ -371,9 +374,12 @@ void GuiGameGrid::Update(GuiTrigger * t)
coverImg[i]->SetPosition(-10,-35); coverImg[i]->SetPosition(-10,-35);
game[i]->SetImage(coverImg[i]); game[i]->SetImage(coverImg[i]);
game[i]->SetVisible(true); game[i]->SetVisible(true);
coverImg[i]->SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 65); game[i]->SetClickable(true);
if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) coverImg[i]->SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 65);
game[i]->SetVisible(false);//} if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) {
game[i]->SetVisible(false);
game[i]->SetClickable(false);
}
} }
btnRight->ResetState(); btnRight->ResetState();
@ -424,14 +430,16 @@ void GuiGameGrid::Update(GuiTrigger * t)
game[i]->ResetState(); game[i]->ResetState();
game[i]->SetVisible(true); game[i]->SetVisible(true);
game[i]->SetImage(coverImg[i]); game[i]->SetImage(coverImg[i]);
coverImg[i]->SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 65);//} game[i]->SetClickable(true);
if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) coverImg[i]->SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 65);
if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) {
game[i]->SetVisible(false); game[i]->SetVisible(false);
game[i]->SetClickable(false);
}
} }
btnLeft->ResetState(); btnLeft->ResetState();
} }
if(updateCB) if(updateCB)
updateCB(this); updateCB(this);
} }
@ -442,7 +450,6 @@ void GuiGameGrid::Reload(struct discHdr * l, int count)
gameList = l; gameList = l;
gameCnt = count; gameCnt = count;
changed=0; changed=0;
tooMuch=(gameCnt-(gameCnt%12));
scrollbaron = (gameCnt > pagesize) ? 1 : 0; scrollbaron = (gameCnt > pagesize) ? 1 : 0;
selectedItem = 0; selectedItem = 0;
listOffset = 0; listOffset = 0;
@ -450,9 +457,7 @@ void GuiGameGrid::Reload(struct discHdr * l, int count)
char IDfull[7]; char IDfull[7];
char imgPath[100]; char imgPath[100];
for(int i=0; i<pagesize; i++) for(int i=0; i<pagesize; i++) {
{
coverImg[i]->SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50);
if(coverImg[i]) { if(coverImg[i]) {
delete coverImg[i]; delete coverImg[i];
@ -492,9 +497,11 @@ void GuiGameGrid::Reload(struct discHdr * l, int count)
game[i]->ResetState(); game[i]->ResetState();
game[i]->SetVisible(true); game[i]->SetVisible(true);
game[i]->SetImage(coverImg[i]); game[i]->SetImage(coverImg[i]);
coverImg[i]->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);//} game[i]->SetClickable(true);
if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) coverImg[i]->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);
if (((changed+pagesize)>gameCnt)&&(i>((gameCnt-changed)-1))) {
game[i]->SetVisible(false); game[i]->SetVisible(false);
game[i]->SetClickable(false);
game[i]->ResetState();} }
}
} }

View File

@ -3,31 +3,6 @@
#include "gui.h" #include "gui.h"
#include "../disc.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 class GuiGameGrid : public GuiElement
{ {
@ -49,6 +24,7 @@ class GuiGameGrid : public GuiElement
int listOffset; int listOffset;
int scrollbaron; int scrollbaron;
int pagesize; int pagesize;
int changed;
struct discHdr * gameList; struct discHdr * gameList;
int gameCnt; int gameCnt;
@ -56,43 +32,16 @@ class GuiGameGrid : public GuiElement
int * gameIndex; int * gameIndex;
GuiButton ** game; GuiButton ** game;
GuiText ** gameTxt; GuiText ** gameTxt;
//GuiImage ** gameBg;
GuiImage ** coverImg; GuiImage ** coverImg;
GuiImageData ** cover; GuiImageData ** cover;
//GuiButton * arrowUpBtn;
//GuiButton * arrowDownBtn;
//GuiButton * scrollbarBoxBtn;
GuiButton * btnRight; GuiButton * btnRight;
GuiButton * btnLeft; 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 * btnLeftImg;
GuiImage * btnRightImg; 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 * imgLeft;
GuiImageData * imgRight; GuiImageData * imgRight;

View File

@ -3124,7 +3124,9 @@ static int MenuDiscList()
w.Append(&installBtn); w.Append(&installBtn);
w.Append(&homeBtn); w.Append(&homeBtn);
w.Append(&settingsBtn); w.Append(&settingsBtn);
if (Settings.gameDisplay==list){
w.Append(&DownloadBtn); w.Append(&DownloadBtn);
}
w.Append(&favoriteBtn); w.Append(&favoriteBtn);
w.Append(&abcBtn); w.Append(&abcBtn);
w.Append(&countBtn); w.Append(&countBtn);
@ -3411,39 +3413,36 @@ static int MenuDiscList()
countBtn.SetAlpha(255); countBtn.SetAlpha(255);
} }
countBtn.ResetState(); countBtn.ResetState();
}
else if(gridBtn.GetState() == STATE_CLICKED) } else if(gridBtn.GetState() == STATE_CLICKED) {
{
if (Settings.gameDisplay==list){ if (Settings.gameDisplay==list){
Settings.gameDisplay=grid; Settings.gameDisplay=grid;
mainWindow->Remove(&gameBrowser); mainWindow->Remove(&gameBrowser);
mainWindow->Append(&gameGrid); mainWindow->Append(&gameGrid);
if (GameIDTxt)w.Remove(GameIDTxt); if (GameIDTxt)w.Remove(GameIDTxt);
if (GameRegionTxt)w.Remove(GameRegionTxt); if (GameRegionTxt)w.Remove(GameRegionTxt);
if (coverImg)w.Remove(&DownloadBtn); w.Remove(&DownloadBtn);
gridBtn.SetImage(&listBtnImg_g); gridBtn.SetImage(&listBtnImg_g);
favoriteBtn.SetPosition(-80,13); favoriteBtn.SetPosition(-80,13);
abcBtn.SetPosition(-48,13); abcBtn.SetPosition(-48,13);
countBtn.SetPosition(-16,13); countBtn.SetPosition(-16,13);
gridBtn.SetPosition(16,13); gridBtn.SetPosition(16,13);
carosselleBtn.SetPosition(48,13); carosselleBtn.SetPosition(48,13);
if((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) { if((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) {
clockTime.SetPosition(THEME.clock_x, THEME.clock_y+3); clockTime.SetPosition(THEME.clock_x, THEME.clock_y+3);
clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y+3); clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y+3);
w.Append(&clockTime); w.Append(&clockTime);
w.Append(&clockTimeBack); w.Append(&clockTimeBack);
} }
w.Append(&favoriteBtn); w.Append(&favoriteBtn);
w.Append(&abcBtn); w.Append(&abcBtn);
w.Append(&countBtn); w.Append(&countBtn);
w.Append(&gridBtn); w.Append(&gridBtn);
w.Append(&carosselleBtn);} w.Append(&carosselleBtn);
else if (Settings.gameDisplay==grid){ } else if (Settings.gameDisplay==grid){
Settings.gameDisplay=list; Settings.gameDisplay=list;
mainWindow->Remove(&gameGrid); mainWindow->Remove(&gameGrid);
@ -3465,12 +3464,12 @@ static int MenuDiscList()
w.Append(&abcBtn); w.Append(&abcBtn);
w.Append(&countBtn); w.Append(&countBtn);
w.Append(&gridBtn); w.Append(&gridBtn);
w.Append(&carosselleBtn);} w.Append(&carosselleBtn);
w.Append(&DownloadBtn);
}
if(isSdInserted()) { if(isSdInserted()) {
cfg_save_global(); cfg_save_global();
} }
//menu = MENU_DISCLIST; //menu = MENU_DISCLIST;
gridBtn.ResetState(); gridBtn.ResetState();
} }
@ -3478,7 +3477,8 @@ static int MenuDiscList()
if (Settings.gameDisplay==grid){ if (Settings.gameDisplay==grid){
int selectimg; int selectimg;
selectimg = gameGrid.GetSelectedOption(); selectimg = gameGrid.GetSelectedOption();
gameSelected = gameGrid.GetClickedOption();} gameSelected = gameGrid.GetClickedOption();
}
if (Settings.gameDisplay==list) { if (Settings.gameDisplay==list) {
//Get selected game under cursor //Get selected game under cursor