mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-30 22:44:22 +01:00
This commit is contained in:
parent
b27d4a7d09
commit
5489397e55
@ -888,14 +888,14 @@ class GuiFileBrowser : public GuiElement
|
|||||||
void Draw();
|
void Draw();
|
||||||
void TriggerUpdate();
|
void TriggerUpdate();
|
||||||
void Update(GuiTrigger * t);
|
void Update(GuiTrigger * t);
|
||||||
GuiButton * gameList[PAGESIZE];
|
GuiButton * fileList[PAGESIZE];
|
||||||
protected:
|
protected:
|
||||||
int selectedItem;
|
int selectedItem;
|
||||||
bool listChanged;
|
bool listChanged;
|
||||||
|
|
||||||
GuiText * gameListText[PAGESIZE];
|
GuiText * fileListText[PAGESIZE];
|
||||||
GuiImage * gameListBg[PAGESIZE];
|
GuiImage * fileListBg[PAGESIZE];
|
||||||
GuiImage * gameListFolder[PAGESIZE];
|
GuiImage * fileListFolder[PAGESIZE];
|
||||||
|
|
||||||
GuiButton * arrowUpBtn;
|
GuiButton * arrowUpBtn;
|
||||||
GuiButton * arrowDownBtn;
|
GuiButton * arrowDownBtn;
|
||||||
|
@ -100,20 +100,20 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
|
|||||||
|
|
||||||
for(int i=0; i<PAGESIZE; i++)
|
for(int i=0; i<PAGESIZE; i++)
|
||||||
{
|
{
|
||||||
gameListText[i] = new GuiText(NULL,22, (GXColor){0, 0, 0, 0xff});
|
fileListText[i] = new GuiText(NULL,22, (GXColor){0, 0, 0, 0xff});
|
||||||
gameListText[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
fileListText[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||||
gameListText[i]->SetPosition(5,0);
|
fileListText[i]->SetPosition(5,0);
|
||||||
|
|
||||||
gameListBg[i] = new GuiImage(bgGameSelectionEntry);
|
fileListBg[i] = new GuiImage(bgGameSelectionEntry);
|
||||||
gameListFolder[i] = new GuiImage(gameFolder);
|
fileListFolder[i] = new GuiImage(gameFolder);
|
||||||
|
|
||||||
gameList[i] = new GuiButton(380, 30);
|
fileList[i] = new GuiButton(380, 30);
|
||||||
gameList[i]->SetParent(this);
|
fileList[i]->SetParent(this);
|
||||||
gameList[i]->SetLabel(gameListText[i]);
|
fileList[i]->SetLabel(fileListText[i]);
|
||||||
gameList[i]->SetImageOver(gameListBg[i]);
|
fileList[i]->SetImageOver(fileListBg[i]);
|
||||||
gameList[i]->SetPosition(2,30*i+3);
|
fileList[i]->SetPosition(2,30*i+3);
|
||||||
gameList[i]->SetTrigger(trigA);
|
fileList[i]->SetTrigger(trigA);
|
||||||
gameList[i]->SetSoundClick(btnSoundClick);
|
fileList[i]->SetSoundClick(btnSoundClick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,10 +153,10 @@ GuiFileBrowser::~GuiFileBrowser()
|
|||||||
|
|
||||||
for(int i=0; i<PAGESIZE; i++)
|
for(int i=0; i<PAGESIZE; i++)
|
||||||
{
|
{
|
||||||
delete gameListText[i];
|
delete fileListText[i];
|
||||||
delete gameList[i];
|
delete fileList[i];
|
||||||
delete gameListBg[i];
|
delete fileListBg[i];
|
||||||
delete gameListFolder[i];
|
delete fileListFolder[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,10 +165,10 @@ void GuiFileBrowser::SetFocus(int f)
|
|||||||
focus = f;
|
focus = f;
|
||||||
|
|
||||||
for(int i=0; i<PAGESIZE; i++)
|
for(int i=0; i<PAGESIZE; i++)
|
||||||
gameList[i]->ResetState();
|
fileList[i]->ResetState();
|
||||||
|
|
||||||
if(f == 1)
|
if(f == 1)
|
||||||
gameList[selectedItem]->SetState(STATE_SELECTED);
|
fileList[selectedItem]->SetState(STATE_SELECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiFileBrowser::ResetState()
|
void GuiFileBrowser::ResetState()
|
||||||
@ -179,7 +179,7 @@ void GuiFileBrowser::ResetState()
|
|||||||
|
|
||||||
for(int i=0; i<PAGESIZE; i++)
|
for(int i=0; i<PAGESIZE; i++)
|
||||||
{
|
{
|
||||||
gameList[i]->ResetState();
|
fileList[i]->ResetState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ void GuiFileBrowser::Draw()
|
|||||||
|
|
||||||
for(int i=0; i<PAGESIZE; i++)
|
for(int i=0; i<PAGESIZE; i++)
|
||||||
{
|
{
|
||||||
gameList[i]->Draw();
|
fileList[i]->Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollbarImg->Draw();
|
scrollbarImg->Draw();
|
||||||
@ -302,10 +302,10 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
|||||||
browser.pageIndex++;
|
browser.pageIndex++;
|
||||||
listChanged = true;
|
listChanged = true;
|
||||||
}
|
}
|
||||||
else if(gameList[selectedItem+1]->IsVisible())
|
else if(fileList[selectedItem+1]->IsVisible())
|
||||||
{
|
{
|
||||||
gameList[selectedItem]->ResetState();
|
fileList[selectedItem]->ResetState();
|
||||||
gameList[++selectedItem]->SetState(STATE_SELECTED, t->chan);
|
fileList[++selectedItem]->SetState(STATE_SELECTED, t->chan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -319,8 +319,8 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
|||||||
}
|
}
|
||||||
else if(selectedItem > 0)
|
else if(selectedItem > 0)
|
||||||
{
|
{
|
||||||
gameList[selectedItem]->ResetState();
|
fileList[selectedItem]->ResetState();
|
||||||
gameList[--selectedItem]->SetState(STATE_SELECTED, t->chan);
|
fileList[--selectedItem]->SetState(STATE_SELECTED, t->chan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,45 +332,45 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
|||||||
{
|
{
|
||||||
if(browser.pageIndex+i < browser.numEntries)
|
if(browser.pageIndex+i < browser.numEntries)
|
||||||
{
|
{
|
||||||
if(gameList[i]->GetState() == STATE_DISABLED)
|
if(fileList[i]->GetState() == STATE_DISABLED)
|
||||||
gameList[i]->SetState(STATE_DEFAULT);
|
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
|
if(browserList[browser.pageIndex+i].isdir) // directory
|
||||||
{
|
{
|
||||||
gameList[i]->SetIcon(gameListFolder[i]);
|
fileList[i]->SetIcon(fileListFolder[i]);
|
||||||
gameListText[i]->SetPosition(30,0);
|
fileListText[i]->SetPosition(30,0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gameList[i]->SetIcon(NULL);
|
fileList[i]->SetIcon(NULL);
|
||||||
gameListText[i]->SetPosition(10,0);
|
fileListText[i]->SetPosition(10,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gameList[i]->SetVisible(false);
|
fileList[i]->SetVisible(false);
|
||||||
gameList[i]->SetState(STATE_DISABLED);
|
fileList[i]->SetState(STATE_DISABLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i != selectedItem && gameList[i]->GetState() == STATE_SELECTED)
|
if(i != selectedItem && fileList[i]->GetState() == STATE_SELECTED)
|
||||||
gameList[i]->ResetState();
|
fileList[i]->ResetState();
|
||||||
else if(focus && i == selectedItem && gameList[i]->GetState() == STATE_DEFAULT)
|
else if(focus && i == selectedItem && fileList[i]->GetState() == STATE_DEFAULT)
|
||||||
gameList[selectedItem]->SetState(STATE_SELECTED, t->chan);
|
fileList[selectedItem]->SetState(STATE_SELECTED, t->chan);
|
||||||
|
|
||||||
int currChan = 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;
|
t->chan = -1;
|
||||||
|
|
||||||
gameList[i]->Update(t);
|
fileList[i]->Update(t);
|
||||||
t->chan = currChan;
|
t->chan = currChan;
|
||||||
|
|
||||||
if(gameList[i]->GetState() == STATE_SELECTED)
|
if(fileList[i]->GetState() == STATE_SELECTED)
|
||||||
{
|
{
|
||||||
selectedItem = i;
|
selectedItem = i;
|
||||||
browser.selIndex = browser.pageIndex + i;
|
browser.selIndex = browser.pageIndex + i;
|
||||||
|
@ -25,9 +25,15 @@ GuiImage::GuiImage()
|
|||||||
|
|
||||||
GuiImage::GuiImage(GuiImageData * img)
|
GuiImage::GuiImage(GuiImageData * img)
|
||||||
{
|
{
|
||||||
image = img->GetImage();
|
image = NULL;
|
||||||
width = img->GetWidth();
|
width = 0;
|
||||||
height = img->GetHeight();
|
height = 0;
|
||||||
|
if(img)
|
||||||
|
{
|
||||||
|
image = img->GetImage();
|
||||||
|
width = img->GetWidth();
|
||||||
|
height = img->GetHeight();
|
||||||
|
}
|
||||||
imageangle = 0;
|
imageangle = 0;
|
||||||
tile = -1;
|
tile = -1;
|
||||||
stripe = 0;
|
stripe = 0;
|
||||||
@ -88,9 +94,15 @@ u8 * GuiImage::GetImage()
|
|||||||
|
|
||||||
void GuiImage::SetImage(GuiImageData * img)
|
void GuiImage::SetImage(GuiImageData * img)
|
||||||
{
|
{
|
||||||
image = img->GetImage();
|
image = NULL;
|
||||||
width = img->GetWidth();
|
width = 0;
|
||||||
height = img->GetHeight();
|
height = 0;
|
||||||
|
if(img)
|
||||||
|
{
|
||||||
|
image = img->GetImage();
|
||||||
|
width = img->GetWidth();
|
||||||
|
height = img->GetHeight();
|
||||||
|
}
|
||||||
imgType = IMAGE_DATA;
|
imgType = IMAGE_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -971,7 +971,7 @@ static int MenuGameSelection()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
gameBrowser.ResetState();
|
gameBrowser.ResetState();
|
||||||
gameBrowser.gameList[0]->SetState(STATE_SELECTED);
|
gameBrowser.fileList[0]->SetState(STATE_SELECTED);
|
||||||
gameBrowser.TriggerUpdate();
|
gameBrowser.TriggerUpdate();
|
||||||
|
|
||||||
while(menu == MENU_NONE)
|
while(menu == MENU_NONE)
|
||||||
@ -982,9 +982,9 @@ static int MenuGameSelection()
|
|||||||
// set MENU_EXIT if A button pressed on a game
|
// set MENU_EXIT if A button pressed on a game
|
||||||
for(i=0; i<PAGESIZE; i++)
|
for(i=0; i<PAGESIZE; i++)
|
||||||
{
|
{
|
||||||
if(gameBrowser.gameList[i]->GetState() == STATE_CLICKED)
|
if(gameBrowser.fileList[i]->GetState() == STATE_CLICKED)
|
||||||
{
|
{
|
||||||
gameBrowser.gameList[i]->ResetState();
|
gameBrowser.fileList[i]->ResetState();
|
||||||
// check corresponding browser entry
|
// check corresponding browser entry
|
||||||
if(browserList[browser.selIndex].isdir || IsSz())
|
if(browserList[browser.selIndex].isdir || IsSz())
|
||||||
{
|
{
|
||||||
@ -996,7 +996,7 @@ static int MenuGameSelection()
|
|||||||
if(res)
|
if(res)
|
||||||
{
|
{
|
||||||
gameBrowser.ResetState();
|
gameBrowser.ResetState();
|
||||||
gameBrowser.gameList[0]->SetState(STATE_SELECTED);
|
gameBrowser.fileList[0]->SetState(STATE_SELECTED);
|
||||||
gameBrowser.TriggerUpdate();
|
gameBrowser.TriggerUpdate();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user