From 5489397e5528d1e386e4acb8a9a8774bcc6230c4 Mon Sep 17 00:00:00 2001 From: dborth Date: Sun, 7 Jun 2009 18:00:57 +0000 Subject: [PATCH] --- source/ngc/gui/gui.h | 8 +-- source/ngc/gui/gui_filebrowser.cpp | 84 +++++++++++++++--------------- source/ngc/gui/gui_image.cpp | 24 ++++++--- source/ngc/menu.cpp | 8 +-- 4 files changed, 68 insertions(+), 56 deletions(-) diff --git a/source/ngc/gui/gui.h b/source/ngc/gui/gui.h index adf36c9..2e92676 100644 --- a/source/ngc/gui/gui.h +++ b/source/ngc/gui/gui.h @@ -888,14 +888,14 @@ class GuiFileBrowser : public GuiElement void Draw(); void TriggerUpdate(); void Update(GuiTrigger * t); - GuiButton * gameList[PAGESIZE]; + GuiButton * fileList[PAGESIZE]; protected: int selectedItem; bool listChanged; - GuiText * gameListText[PAGESIZE]; - GuiImage * gameListBg[PAGESIZE]; - GuiImage * gameListFolder[PAGESIZE]; + GuiText * fileListText[PAGESIZE]; + GuiImage * fileListBg[PAGESIZE]; + GuiImage * fileListFolder[PAGESIZE]; GuiButton * arrowUpBtn; GuiButton * arrowDownBtn; diff --git a/source/ngc/gui/gui_filebrowser.cpp b/source/ngc/gui/gui_filebrowser.cpp index c118c92..1516a52 100644 --- a/source/ngc/gui/gui_filebrowser.cpp +++ b/source/ngc/gui/gui_filebrowser.cpp @@ -100,20 +100,20 @@ GuiFileBrowser::GuiFileBrowser(int w, int h) for(int i=0; iSetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); - gameListText[i]->SetPosition(5,0); + fileListText[i] = new GuiText(NULL,22, (GXColor){0, 0, 0, 0xff}); + fileListText[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); + fileListText[i]->SetPosition(5,0); - gameListBg[i] = new GuiImage(bgGameSelectionEntry); - gameListFolder[i] = new GuiImage(gameFolder); + fileListBg[i] = new GuiImage(bgGameSelectionEntry); + fileListFolder[i] = new GuiImage(gameFolder); - gameList[i] = new GuiButton(380, 30); - gameList[i]->SetParent(this); - gameList[i]->SetLabel(gameListText[i]); - gameList[i]->SetImageOver(gameListBg[i]); - gameList[i]->SetPosition(2,30*i+3); - gameList[i]->SetTrigger(trigA); - gameList[i]->SetSoundClick(btnSoundClick); + fileList[i] = new GuiButton(380, 30); + fileList[i]->SetParent(this); + fileList[i]->SetLabel(fileListText[i]); + fileList[i]->SetImageOver(fileListBg[i]); + fileList[i]->SetPosition(2,30*i+3); + fileList[i]->SetTrigger(trigA); + fileList[i]->SetSoundClick(btnSoundClick); } } @@ -153,10 +153,10 @@ GuiFileBrowser::~GuiFileBrowser() for(int i=0; iResetState(); + fileList[i]->ResetState(); if(f == 1) - gameList[selectedItem]->SetState(STATE_SELECTED); + fileList[selectedItem]->SetState(STATE_SELECTED); } void GuiFileBrowser::ResetState() @@ -179,7 +179,7 @@ void GuiFileBrowser::ResetState() for(int i=0; iResetState(); + fileList[i]->ResetState(); } } @@ -200,7 +200,7 @@ void GuiFileBrowser::Draw() for(int i=0; iDraw(); + fileList[i]->Draw(); } scrollbarImg->Draw(); @@ -302,10 +302,10 @@ void GuiFileBrowser::Update(GuiTrigger * t) browser.pageIndex++; listChanged = true; } - else if(gameList[selectedItem+1]->IsVisible()) + else if(fileList[selectedItem+1]->IsVisible()) { - gameList[selectedItem]->ResetState(); - gameList[++selectedItem]->SetState(STATE_SELECTED, t->chan); + fileList[selectedItem]->ResetState(); + fileList[++selectedItem]->SetState(STATE_SELECTED, t->chan); } } } @@ -319,8 +319,8 @@ void GuiFileBrowser::Update(GuiTrigger * t) } else if(selectedItem > 0) { - gameList[selectedItem]->ResetState(); - gameList[--selectedItem]->SetState(STATE_SELECTED, t->chan); + fileList[selectedItem]->ResetState(); + fileList[--selectedItem]->SetState(STATE_SELECTED, t->chan); } } @@ -332,45 +332,45 @@ void GuiFileBrowser::Update(GuiTrigger * t) { if(browser.pageIndex+i < browser.numEntries) { - if(gameList[i]->GetState() == STATE_DISABLED) - gameList[i]->SetState(STATE_DEFAULT); + if(fileList[i]->GetState() == STATE_DISABLED) + fileList[i]->SetState(STATE_DEFAULT); - gameList[i]->SetVisible(true); + fileList[i]->SetVisible(true); - gameListText[i]->SetText(browserList[browser.pageIndex+i].displayname); + fileListText[i]->SetText(browserList[browser.pageIndex+i].displayname); if(browserList[browser.pageIndex+i].isdir) // directory { - gameList[i]->SetIcon(gameListFolder[i]); - gameListText[i]->SetPosition(30,0); + fileList[i]->SetIcon(fileListFolder[i]); + fileListText[i]->SetPosition(30,0); } else { - gameList[i]->SetIcon(NULL); - gameListText[i]->SetPosition(10,0); + fileList[i]->SetIcon(NULL); + fileListText[i]->SetPosition(10,0); } } else { - gameList[i]->SetVisible(false); - gameList[i]->SetState(STATE_DISABLED); + fileList[i]->SetVisible(false); + fileList[i]->SetState(STATE_DISABLED); } } - if(i != selectedItem && gameList[i]->GetState() == STATE_SELECTED) - gameList[i]->ResetState(); - else if(focus && i == selectedItem && gameList[i]->GetState() == STATE_DEFAULT) - gameList[selectedItem]->SetState(STATE_SELECTED, t->chan); + if(i != selectedItem && fileList[i]->GetState() == STATE_SELECTED) + fileList[i]->ResetState(); + else if(focus && i == selectedItem && fileList[i]->GetState() == STATE_DEFAULT) + fileList[selectedItem]->SetState(STATE_SELECTED, t->chan); int currChan = t->chan; - if(t->wpad.ir.valid && !gameList[i]->IsInside(t->wpad.ir.x, t->wpad.ir.y)) + if(t->wpad.ir.valid && !fileList[i]->IsInside(t->wpad.ir.x, t->wpad.ir.y)) t->chan = -1; - gameList[i]->Update(t); + fileList[i]->Update(t); t->chan = currChan; - if(gameList[i]->GetState() == STATE_SELECTED) + if(fileList[i]->GetState() == STATE_SELECTED) { selectedItem = i; browser.selIndex = browser.pageIndex + i; diff --git a/source/ngc/gui/gui_image.cpp b/source/ngc/gui/gui_image.cpp index 426eb97..6f15f48 100644 --- a/source/ngc/gui/gui_image.cpp +++ b/source/ngc/gui/gui_image.cpp @@ -25,9 +25,15 @@ GuiImage::GuiImage() GuiImage::GuiImage(GuiImageData * img) { - image = img->GetImage(); - width = img->GetWidth(); - height = img->GetHeight(); + image = NULL; + width = 0; + height = 0; + if(img) + { + image = img->GetImage(); + width = img->GetWidth(); + height = img->GetHeight(); + } imageangle = 0; tile = -1; stripe = 0; @@ -88,9 +94,15 @@ u8 * GuiImage::GetImage() void GuiImage::SetImage(GuiImageData * img) { - image = img->GetImage(); - width = img->GetWidth(); - height = img->GetHeight(); + image = NULL; + width = 0; + height = 0; + if(img) + { + image = img->GetImage(); + width = img->GetWidth(); + height = img->GetHeight(); + } imgType = IMAGE_DATA; } diff --git a/source/ngc/menu.cpp b/source/ngc/menu.cpp index a878e8b..18134b4 100644 --- a/source/ngc/menu.cpp +++ b/source/ngc/menu.cpp @@ -971,7 +971,7 @@ static int MenuGameSelection() else { gameBrowser.ResetState(); - gameBrowser.gameList[0]->SetState(STATE_SELECTED); + gameBrowser.fileList[0]->SetState(STATE_SELECTED); gameBrowser.TriggerUpdate(); while(menu == MENU_NONE) @@ -982,9 +982,9 @@ static int MenuGameSelection() // set MENU_EXIT if A button pressed on a game for(i=0; iGetState() == STATE_CLICKED) + if(gameBrowser.fileList[i]->GetState() == STATE_CLICKED) { - gameBrowser.gameList[i]->ResetState(); + gameBrowser.fileList[i]->ResetState(); // check corresponding browser entry if(browserList[browser.selIndex].isdir || IsSz()) { @@ -996,7 +996,7 @@ static int MenuGameSelection() if(res) { gameBrowser.ResetState(); - gameBrowser.gameList[0]->SetState(STATE_SELECTED); + gameBrowser.fileList[0]->SetState(STATE_SELECTED); gameBrowser.TriggerUpdate(); } else