mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-12-25 02:31:50 +01:00
improve scrollbars, add confirmation prompts, save preferences when closing game settings
This commit is contained in:
parent
4a2fd0d76f
commit
5c351075b0
@ -796,7 +796,6 @@ class GuiOptionBrowser : public GuiElement
|
||||
|
||||
GuiButton * arrowUpBtn;
|
||||
GuiButton * arrowDownBtn;
|
||||
GuiButton * scrollbarBoxBtn;
|
||||
|
||||
GuiImage * bgOptionsImg;
|
||||
GuiImage * scrollbarImg;
|
||||
@ -804,8 +803,6 @@ class GuiOptionBrowser : public GuiElement
|
||||
GuiImage * arrowDownOverImg;
|
||||
GuiImage * arrowUpImg;
|
||||
GuiImage * arrowUpOverImg;
|
||||
GuiImage * scrollbarBoxImg;
|
||||
GuiImage * scrollbarBoxOverImg;
|
||||
|
||||
GuiImageData * bgOptions;
|
||||
GuiImageData * bgOptionsEntry;
|
||||
@ -814,8 +811,6 @@ class GuiOptionBrowser : public GuiElement
|
||||
GuiImageData * arrowDownOver;
|
||||
GuiImageData * arrowUp;
|
||||
GuiImageData * arrowUpOver;
|
||||
GuiImageData * scrollbarBox;
|
||||
GuiImageData * scrollbarBoxOver;
|
||||
|
||||
GuiSound * btnSoundOver;
|
||||
GuiSound * btnSoundClick;
|
||||
@ -860,15 +855,12 @@ class GuiSaveBrowser : public GuiElement
|
||||
|
||||
GuiButton * arrowUpBtn;
|
||||
GuiButton * arrowDownBtn;
|
||||
GuiButton * scrollbarBoxBtn;
|
||||
|
||||
GuiImage * scrollbarImg;
|
||||
GuiImage * arrowDownImg;
|
||||
GuiImage * arrowDownOverImg;
|
||||
GuiImage * arrowUpImg;
|
||||
GuiImage * arrowUpOverImg;
|
||||
GuiImage * scrollbarBoxImg;
|
||||
GuiImage * scrollbarBoxOverImg;
|
||||
|
||||
GuiImageData * gameSave;
|
||||
GuiImageData * gameSaveOver;
|
||||
@ -878,8 +870,6 @@ class GuiSaveBrowser : public GuiElement
|
||||
GuiImageData * arrowDownOver;
|
||||
GuiImageData * arrowUp;
|
||||
GuiImageData * arrowUpOver;
|
||||
GuiImageData * scrollbarBox;
|
||||
GuiImageData * scrollbarBoxOver;
|
||||
|
||||
GuiSound * btnSoundOver;
|
||||
GuiSound * btnSoundClick;
|
||||
|
@ -92,7 +92,7 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
|
||||
scrollbarBoxBtn->SetImageOver(scrollbarBoxOverImg);
|
||||
scrollbarBoxBtn->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
||||
scrollbarBoxBtn->SetMinY(0);
|
||||
scrollbarBoxBtn->SetMaxY(304);
|
||||
scrollbarBoxBtn->SetMaxY(136);
|
||||
scrollbarBoxBtn->SetSelectable(false);
|
||||
scrollbarBoxBtn->SetClickable(false);
|
||||
scrollbarBoxBtn->SetHoldable(true);
|
||||
@ -148,8 +148,8 @@ GuiFileBrowser::~GuiFileBrowser()
|
||||
|
||||
delete btnSoundOver;
|
||||
delete btnSoundClick;
|
||||
delete trigA;
|
||||
delete trigHeldA;
|
||||
delete trigA;
|
||||
|
||||
for(int i=0; i<PAGESIZE; i++)
|
||||
{
|
||||
@ -216,7 +216,8 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
if(state == STATE_DISABLED || !t)
|
||||
return;
|
||||
|
||||
int position;
|
||||
int position = 0;
|
||||
int positionWiimote = 0;
|
||||
|
||||
arrowUpBtn->Update(t);
|
||||
arrowDownBtn->Update(t);
|
||||
@ -230,14 +231,14 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
)
|
||||
{
|
||||
scrollbarBoxBtn->SetPosition(0,0);
|
||||
position = t->wpad.ir.y - 60 - scrollbarBoxBtn->GetTop();
|
||||
positionWiimote = t->wpad.ir.y - 60 - scrollbarBoxBtn->GetTop();
|
||||
|
||||
if(position < scrollbarBoxBtn->GetMinY())
|
||||
position = scrollbarBoxBtn->GetMinY();
|
||||
else if(position > scrollbarBoxBtn->GetMaxY())
|
||||
position = scrollbarBoxBtn->GetMaxY();
|
||||
if(positionWiimote < scrollbarBoxBtn->GetMinY())
|
||||
positionWiimote = scrollbarBoxBtn->GetMinY();
|
||||
else if(positionWiimote > scrollbarBoxBtn->GetMaxY())
|
||||
positionWiimote = scrollbarBoxBtn->GetMaxY();
|
||||
|
||||
browser.pageIndex = (position * browser.numEntries)/136.0 - selectedItem;
|
||||
browser.pageIndex = (positionWiimote * browser.numEntries)/136.0 - selectedItem;
|
||||
|
||||
if(browser.pageIndex <= 0)
|
||||
{
|
||||
@ -250,6 +251,7 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
selectedItem = PAGESIZE-1;
|
||||
}
|
||||
listChanged = true;
|
||||
focus = false;
|
||||
}
|
||||
|
||||
if(arrowDownBtn->GetState() == STATE_HELD && arrowDownBtn->GetStateChan() == t->chan)
|
||||
@ -375,11 +377,12 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
}
|
||||
|
||||
// update the location of the scroll box based on the position in the file list
|
||||
if(listChanged)
|
||||
{
|
||||
if(positionWiimote > 0)
|
||||
position = positionWiimote; // follow wiimote cursor
|
||||
else
|
||||
position = 136*(browser.pageIndex + selectedItem) / browser.numEntries;
|
||||
|
||||
scrollbarBoxBtn->SetPosition(0,position+36);
|
||||
}
|
||||
|
||||
listChanged = false;
|
||||
|
||||
|
@ -54,10 +54,6 @@ GuiOptionBrowser::GuiOptionBrowser(int w, int h, OptionList * l)
|
||||
arrowUpImg = new GuiImage(arrowUp);
|
||||
arrowUpOver = new GuiImageData(scrollbar_arrowup_over_png);
|
||||
arrowUpOverImg = new GuiImage(arrowUpOver);
|
||||
scrollbarBox = new GuiImageData(scrollbar_box_png);
|
||||
scrollbarBoxImg = new GuiImage(scrollbarBox);
|
||||
scrollbarBoxOver = new GuiImageData(scrollbar_box_over_png);
|
||||
scrollbarBoxOverImg = new GuiImage(scrollbarBoxOver);
|
||||
|
||||
arrowUpBtn = new GuiButton(arrowUpImg->GetWidth(), arrowUpImg->GetHeight());
|
||||
arrowUpBtn->SetParent(this);
|
||||
@ -79,13 +75,6 @@ GuiOptionBrowser::GuiOptionBrowser(int w, int h, OptionList * l)
|
||||
arrowDownBtn->SetSoundOver(btnSoundOver);
|
||||
arrowDownBtn->SetSoundClick(btnSoundClick);
|
||||
|
||||
scrollbarBoxBtn = new GuiButton(scrollbarBoxImg->GetWidth(), scrollbarBoxImg->GetHeight());
|
||||
scrollbarBoxBtn->SetParent(this);
|
||||
scrollbarBoxBtn->SetImage(scrollbarBoxImg);
|
||||
scrollbarBoxBtn->SetImageOver(scrollbarBoxOverImg);
|
||||
scrollbarBoxBtn->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
||||
scrollbarBoxBtn->SetSelectable(false);
|
||||
|
||||
for(int i=0; i<PAGESIZE; i++)
|
||||
{
|
||||
optionTxt[i] = new GuiText(options->name[i], 22, (GXColor){0, 0, 0, 0xff});
|
||||
@ -116,7 +105,6 @@ GuiOptionBrowser::~GuiOptionBrowser()
|
||||
{
|
||||
delete arrowUpBtn;
|
||||
delete arrowDownBtn;
|
||||
delete scrollbarBoxBtn;
|
||||
|
||||
delete bgOptionsImg;
|
||||
delete scrollbarImg;
|
||||
@ -124,8 +112,6 @@ GuiOptionBrowser::~GuiOptionBrowser()
|
||||
delete arrowDownOverImg;
|
||||
delete arrowUpImg;
|
||||
delete arrowUpOverImg;
|
||||
delete scrollbarBoxImg;
|
||||
delete scrollbarBoxOverImg;
|
||||
|
||||
delete bgOptions;
|
||||
delete bgOptionsEntry;
|
||||
@ -134,8 +120,6 @@ GuiOptionBrowser::~GuiOptionBrowser()
|
||||
delete arrowDownOver;
|
||||
delete arrowUp;
|
||||
delete arrowUpOver;
|
||||
delete scrollbarBox;
|
||||
delete scrollbarBoxOver;
|
||||
|
||||
delete trigA;
|
||||
delete btnSoundOver;
|
||||
@ -241,7 +225,6 @@ void GuiOptionBrowser::Draw()
|
||||
scrollbarImg->Draw();
|
||||
arrowUpBtn->Draw();
|
||||
arrowDownBtn->Draw();
|
||||
scrollbarBoxBtn->Draw();
|
||||
|
||||
this->UpdateEffects();
|
||||
}
|
||||
@ -253,17 +236,8 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
|
||||
|
||||
int next, prev;
|
||||
|
||||
// update the location of the scroll box based on the position in the option list
|
||||
int position = 136*(listOffset+selectedItem)/options->length;
|
||||
|
||||
if(position > 130)
|
||||
position = 136;
|
||||
|
||||
scrollbarBoxBtn->SetPosition(0,position+36);
|
||||
|
||||
arrowUpBtn->Update(t);
|
||||
arrowDownBtn->Update(t);
|
||||
scrollbarBoxBtn->Update(t);
|
||||
|
||||
next = listOffset;
|
||||
|
||||
|
@ -58,10 +58,6 @@ GuiSaveBrowser::GuiSaveBrowser(int w, int h, SaveList * s, int a)
|
||||
arrowUpImg = new GuiImage(arrowUp);
|
||||
arrowUpOver = new GuiImageData(scrollbar_arrowup_over_png);
|
||||
arrowUpOverImg = new GuiImage(arrowUpOver);
|
||||
scrollbarBox = new GuiImageData(scrollbar_box_png);
|
||||
scrollbarBoxImg = new GuiImage(scrollbarBox);
|
||||
scrollbarBoxOver = new GuiImageData(scrollbar_box_over_png);
|
||||
scrollbarBoxOverImg = new GuiImage(scrollbarBoxOver);
|
||||
|
||||
arrowUpBtn = new GuiButton(arrowUpImg->GetWidth(), arrowUpImg->GetHeight());
|
||||
arrowUpBtn->SetParent(this);
|
||||
@ -83,13 +79,6 @@ GuiSaveBrowser::GuiSaveBrowser(int w, int h, SaveList * s, int a)
|
||||
arrowDownBtn->SetSoundOver(btnSoundOver);
|
||||
arrowDownBtn->SetSoundClick(btnSoundClick);
|
||||
|
||||
scrollbarBoxBtn = new GuiButton(scrollbarBoxImg->GetWidth(), scrollbarBoxImg->GetHeight());
|
||||
scrollbarBoxBtn->SetParent(this);
|
||||
scrollbarBoxBtn->SetImage(scrollbarBoxImg);
|
||||
scrollbarBoxBtn->SetImageOver(scrollbarBoxOverImg);
|
||||
scrollbarBoxBtn->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
||||
scrollbarBoxBtn->SetSelectable(false);
|
||||
|
||||
for(int i=0; i<SAVELISTSIZE; i++)
|
||||
{
|
||||
saveDate[i] = new GuiText(NULL, 22, (GXColor){0, 0, 0, 0xff});
|
||||
@ -135,15 +124,12 @@ GuiSaveBrowser::~GuiSaveBrowser()
|
||||
{
|
||||
delete arrowUpBtn;
|
||||
delete arrowDownBtn;
|
||||
delete scrollbarBoxBtn;
|
||||
|
||||
delete scrollbarImg;
|
||||
delete arrowDownImg;
|
||||
delete arrowDownOverImg;
|
||||
delete arrowUpImg;
|
||||
delete arrowUpOverImg;
|
||||
delete scrollbarBoxImg;
|
||||
delete scrollbarBoxOverImg;
|
||||
|
||||
delete gameSave;
|
||||
delete gameSaveOver;
|
||||
@ -153,8 +139,6 @@ GuiSaveBrowser::~GuiSaveBrowser()
|
||||
delete arrowDownOver;
|
||||
delete arrowUp;
|
||||
delete arrowUpOver;
|
||||
delete scrollbarBox;
|
||||
delete scrollbarBoxOver;
|
||||
|
||||
delete btnSoundOver;
|
||||
delete btnSoundClick;
|
||||
@ -226,7 +210,6 @@ void GuiSaveBrowser::Draw()
|
||||
scrollbarImg->Draw();
|
||||
arrowUpBtn->Draw();
|
||||
arrowDownBtn->Draw();
|
||||
scrollbarBoxBtn->Draw();
|
||||
|
||||
this->UpdateEffects();
|
||||
}
|
||||
@ -238,21 +221,9 @@ void GuiSaveBrowser::Update(GuiTrigger * t)
|
||||
|
||||
int i, len;
|
||||
char savetext[50];
|
||||
// update the location of the scroll box based on the position in the option list
|
||||
int position;
|
||||
if(action == 0)
|
||||
position = 136*(listOffset+selectedItem)/saves->length;
|
||||
else
|
||||
position = 136*(listOffset+selectedItem+2)/saves->length;
|
||||
|
||||
if(position > 130)
|
||||
position = 136;
|
||||
|
||||
scrollbarBoxBtn->SetPosition(0,position+36);
|
||||
|
||||
arrowUpBtn->Update(t);
|
||||
arrowDownBtn->Update(t);
|
||||
scrollbarBoxBtn->Update(t);
|
||||
|
||||
// pad/joystick navigation
|
||||
if(!focus)
|
||||
|
@ -1377,15 +1377,20 @@ static int MenuGame()
|
||||
menu = MENU_GAME_LOAD;
|
||||
}
|
||||
else if(resetBtn.GetState() == STATE_CLICKED)
|
||||
{
|
||||
if (WindowPrompt("Reset Game", "Are you sure that you want to reset this game? Any unsaved progress will be lost.", "OK", "Cancel"))
|
||||
{
|
||||
S9xSoftReset ();
|
||||
menu = MENU_EXIT;
|
||||
}
|
||||
}
|
||||
else if(gameSettingsBtn.GetState() == STATE_CLICKED)
|
||||
{
|
||||
menu = MENU_GAMESETTINGS;
|
||||
}
|
||||
else if(mainmenuBtn.GetState() == STATE_CLICKED)
|
||||
{
|
||||
if (WindowPrompt("Quit Game", "Quit this game? Any unsaved progress will be lost.", "OK", "Cancel"))
|
||||
{
|
||||
if(gameScreenImg)
|
||||
{
|
||||
@ -1404,6 +1409,7 @@ static int MenuGame()
|
||||
#endif
|
||||
menu = MENU_GAMESELECTION;
|
||||
}
|
||||
}
|
||||
else if(closeBtn.GetState() == STATE_CLICKED)
|
||||
{
|
||||
menu = MENU_EXIT;
|
||||
@ -1895,6 +1901,7 @@ static int MenuGameSettings()
|
||||
else if(closeBtn.GetState() == STATE_CLICKED)
|
||||
{
|
||||
menu = MENU_EXIT;
|
||||
SavePrefs(NOTSILENT);
|
||||
|
||||
exitSound->Play();
|
||||
bgTopImg->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 15);
|
||||
|
Loading…
Reference in New Issue
Block a user