menu improvements

This commit is contained in:
dborth 2009-07-27 22:37:56 +00:00
parent 66de3b0b6d
commit 15ebd5ff8c
3 changed files with 273 additions and 212 deletions

View File

@ -800,11 +800,13 @@ class GuiOptionBrowser : public GuiElement
void ResetState();
void SetFocus(int f);
void Draw();
void TriggerUpdate();
void Update(GuiTrigger * t);
GuiText * optionVal[PAGESIZE];
protected:
int selectedItem;
int listOffset;
bool listChanged;
OptionList * options;
int optionIndex[PAGESIZE];

View File

@ -20,6 +20,7 @@ GuiOptionBrowser::GuiOptionBrowser(int w, int h, OptionList * l)
options = l;
selectable = true;
listOffset = this->FindMenuItem(-1, 1);
listChanged = true; // trigger an initial list update
selectedItem = 0;
focus = 0; // allow focus
@ -76,7 +77,7 @@ GuiOptionBrowser::GuiOptionBrowser(int w, int h, OptionList * l)
for(int i=0; i<PAGESIZE; i++)
{
optionTxt[i] = new GuiText(options->name[i], 22, (GXColor){0, 0, 0, 0xff});
optionTxt[i] = new GuiText(NULL, 22, (GXColor){0, 0, 0, 0xff});
optionTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
optionTxt[i]->SetPosition(8,0);
@ -228,6 +229,11 @@ void GuiOptionBrowser::Draw()
this->UpdateEffects();
}
void GuiOptionBrowser::TriggerUpdate()
{
listChanged = true;
}
void GuiOptionBrowser::Update(GuiTrigger * t)
{
if(state == STATE_DISABLED || !t)
@ -240,6 +246,9 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
next = listOffset;
if(listChanged)
{
listChanged = false;
for(int i=0; i<PAGESIZE; i++)
{
if(next >= 0)
@ -260,7 +269,11 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
optionBtn[i]->SetVisible(false);
optionBtn[i]->SetState(STATE_DISABLED);
}
}
}
for(int i=0; i<PAGESIZE; i++)
{
if(i != selectedItem && optionBtn[i]->GetState() == STATE_SELECTED)
optionBtn[i]->ResetState();
else if(focus && i == selectedItem && optionBtn[i]->GetState() == STATE_DEFAULT)
@ -292,6 +305,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
{
// move list down by 1
listOffset = this->FindMenuItem(listOffset, 1);
listChanged = true;
}
else if(optionBtn[selectedItem+1]->IsVisible())
{
@ -312,6 +326,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
{
// move list up by 1
listOffset = prev;
listChanged = true;
}
else
{

View File

@ -205,8 +205,11 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, const ch
mainWindow->SetState(STATE_DISABLED);
mainWindow->Append(&promptWindow);
mainWindow->ChangeFocus(&promptWindow);
if(btn2Label)
{
btn1.ResetState();
btn2.SetState(STATE_SELECTED);
}
ResumeGui();
while(choice == -1)
@ -2079,6 +2082,7 @@ static int MenuGameCheats()
{
FCEUI_ToggleCheat(ret);
sprintf (options.value[ret], "%s", options.value[ret][1] == 'f' ? "On" : "Off");
optionBrowser.TriggerUpdate();
}
if(backBtn.GetState() == STATE_CLICKED)
@ -2507,6 +2511,7 @@ static int MenuSettingsMappingsMap()
int menu = MENU_NONE;
int ret,i,j;
OptionList options;
bool firstRun = true;
char menuTitle[100];
char menuSubtitle[100];
@ -2609,6 +2614,39 @@ static int MenuSettingsMappingsMap()
{
usleep(THREAD_SLEEP);
if(backBtn.GetState() == STATE_CLICKED)
{
menu = MENU_GAMESETTINGS_MAPPINGS_CTRL;
}
else if(resetBtn.GetState() == STATE_CLICKED)
{
resetBtn.ResetState();
int choice = WindowPrompt(
"Reset Mappings",
"Are you sure that you want to reset your mappings?",
"Yes",
"No");
if(choice == 1)
{
ResetControls(mapMenuCtrlNES, mapMenuCtrl);
firstRun = true;
}
}
ret = optionBrowser.GetClickedOption();
if(ret >= 0)
{
// get a button selection from user
btnmap[mapMenuCtrlNES][mapMenuCtrl][ret] = ButtonMappingWindow();
}
if(ret >= 0 || firstRun)
{
firstRun = false;
for(i=0; i < options.length; i++)
{
for(j=0; j < ctrlr_def[mapMenuCtrl].num_btns; j++)
@ -2626,31 +2664,7 @@ static int MenuSettingsMappingsMap()
}
}
}
ret = optionBrowser.GetClickedOption();
if(ret >= 0)
{
// get a button selection from user
btnmap[mapMenuCtrlNES][mapMenuCtrl][ret] = ButtonMappingWindow();
}
if(backBtn.GetState() == STATE_CLICKED)
{
menu = MENU_GAMESETTINGS_MAPPINGS_CTRL;
}
else if(resetBtn.GetState() == STATE_CLICKED)
{
resetBtn.ResetState();
int choice = WindowPrompt(
"Reset Mappings",
"Are you sure that you want to reset your mappings?",
"Yes",
"No");
if(choice == 1)
ResetControls(mapMenuCtrlNES, mapMenuCtrl);
optionBrowser.TriggerUpdate();
}
}
HaltGui();
@ -2873,6 +2887,7 @@ static int MenuSettingsVideo()
int ret;
int i = 0;
OptionList options;
bool firstRun = true;
sprintf(options.name[i++], "Rendering");
sprintf(options.name[i++], "Scaling");
@ -2938,55 +2953,6 @@ static int MenuSettingsVideo()
{
usleep(THREAD_SLEEP);
// don't allow original render mode if progressive video mode detected
if (GCSettings.render==0 && progressive)
GCSettings.render++;
if (GCSettings.render == 0)
sprintf (options.value[0], "Original");
else if (GCSettings.render == 1)
sprintf (options.value[0], "Filtered");
else if (GCSettings.render == 2)
sprintf (options.value[0], "Unfiltered");
if(GCSettings.widescreen)
sprintf (options.value[1], "16:9 Correction");
else
sprintf (options.value[1], "Default");
sprintf (options.value[2], "%s", GetFilterName((RenderFilter)GCSettings.FilterMethod));
switch(GCSettings.hideoverscan)
{
case 0: sprintf (options.value[3], "Off"); break;
case 1: sprintf (options.value[3], "Vertical"); break;
case 2: sprintf (options.value[3], "Horizontal"); break;
case 3: sprintf (options.value[3], "Both"); break;
}
sprintf (options.value[4], "%s",
GCSettings.currpal ? palettes[GCSettings.currpal-1].name : "Default");
sprintf (options.value[5], "%s", GCSettings.timing == 1 ? "PAL" : "NTSC");
sprintf (options.value[6], "%.2f%%", GCSettings.ZoomLevel*100);
sprintf (options.value[7], "%d, %d", GCSettings.xshift, GCSettings.yshift);
sprintf (options.value[8], "%s", GCSettings.crosshair == 1 ? "On" : "Off");
sprintf (options.value[9], "%s", GCSettings.spritelimit == 1 ? "On" : "Off");
switch(GCSettings.videomode)
{
case 0:
sprintf (options.value[10], "Automatic (Recommended)"); break;
case 1:
sprintf (options.value[10], "NTSC (480i)"); break;
case 2:
sprintf (options.value[10], "Progressive (480p)"); break;
case 3:
sprintf (options.value[10], "PAL (50Hz)"); break;
case 4:
sprintf (options.value[10], "PAL (60Hz)"); break;
}
ret = optionBrowser.GetClickedOption();
switch (ret)
@ -3045,6 +3011,61 @@ static int MenuSettingsVideo()
break;
}
if(ret >= 0 || firstRun)
{
firstRun = false;
// don't allow original render mode if progressive video mode detected
if (GCSettings.render==0 && progressive)
GCSettings.render++;
if (GCSettings.render == 0)
sprintf (options.value[0], "Original");
else if (GCSettings.render == 1)
sprintf (options.value[0], "Filtered");
else if (GCSettings.render == 2)
sprintf (options.value[0], "Unfiltered");
if(GCSettings.widescreen)
sprintf (options.value[1], "16:9 Correction");
else
sprintf (options.value[1], "Default");
sprintf (options.value[2], "%s", GetFilterName((RenderFilter)GCSettings.FilterMethod));
switch(GCSettings.hideoverscan)
{
case 0: sprintf (options.value[3], "Off"); break;
case 1: sprintf (options.value[3], "Vertical"); break;
case 2: sprintf (options.value[3], "Horizontal"); break;
case 3: sprintf (options.value[3], "Both"); break;
}
sprintf (options.value[4], "%s",
GCSettings.currpal ? palettes[GCSettings.currpal-1].name : "Default");
sprintf (options.value[5], "%s", GCSettings.timing == 1 ? "PAL" : "NTSC");
sprintf (options.value[6], "%.2f%%", GCSettings.ZoomLevel*100);
sprintf (options.value[7], "%d, %d", GCSettings.xshift, GCSettings.yshift);
sprintf (options.value[8], "%s", GCSettings.crosshair == 1 ? "On" : "Off");
sprintf (options.value[9], "%s", GCSettings.spritelimit == 1 ? "On" : "Off");
switch(GCSettings.videomode)
{
case 0:
sprintf (options.value[10], "Automatic (Recommended)"); break;
case 1:
sprintf (options.value[10], "NTSC (480i)"); break;
case 2:
sprintf (options.value[10], "Progressive (480p)"); break;
case 3:
sprintf (options.value[10], "PAL (50Hz)"); break;
case 4:
sprintf (options.value[10], "PAL (60Hz)"); break;
}
optionBrowser.TriggerUpdate();
}
if(backBtn.GetState() == STATE_CLICKED)
{
menu = MENU_GAMESETTINGS;
@ -3234,6 +3255,7 @@ static int MenuSettingsFile()
int menu = MENU_NONE;
int ret;
int i = 0;
bool firstRun = true;
OptionList options;
sprintf(options.name[i++], "Load Device");
sprintf(options.name[i++], "Save Device");
@ -3244,7 +3266,6 @@ static int MenuSettingsFile()
sprintf(options.name[i++], "Auto Save");
sprintf(options.name[i++], "Verify MC Saves");
options.length = i;
options.name[4][0] = 0; // hide cheats folder (not implemented)
for(i=0; i < options.length; i++)
options.value[i][0] = 0;
@ -3295,6 +3316,51 @@ static int MenuSettingsFile()
{
usleep(THREAD_SLEEP);
ret = optionBrowser.GetClickedOption();
switch (ret)
{
case 0:
GCSettings.LoadMethod++;
break;
case 1:
GCSettings.SaveMethod++;
break;
case 2:
OnScreenKeyboard(GCSettings.LoadFolder, MAXPATHLEN);
break;
case 3:
OnScreenKeyboard(GCSettings.SaveFolder, MAXPATHLEN);
break;
case 4:
OnScreenKeyboard(GCSettings.CheatFolder, MAXPATHLEN);
break;
case 5:
GCSettings.AutoLoad++;
if (GCSettings.AutoLoad > 2)
GCSettings.AutoLoad = 0;
break;
case 6:
GCSettings.AutoSave++;
if (GCSettings.AutoSave > 3)
GCSettings.AutoSave = 0;
break;
case 7:
GCSettings.VerifySaves ^= 1;
break;
}
if(ret >= 0 || firstRun)
{
firstRun = false;
// some load/save methods are not implemented - here's where we skip them
// they need to be skipped in the order they were enumerated in snes9xGX.h
@ -3348,7 +3414,7 @@ static int MenuSettingsFile()
snprintf (options.value[2], 30, "%s", GCSettings.LoadFolder);
snprintf (options.value[3], 30, "%s", GCSettings.SaveFolder);
//snprintf (options.value[4], 30, "%s", GCSettings.CheatFolder);
snprintf (options.value[4], 30, "%s", GCSettings.CheatFolder);
if (GCSettings.AutoLoad == 0) sprintf (options.value[5],"Off");
else if (GCSettings.AutoLoad == 1) sprintf (options.value[5],"RAM");
@ -3361,45 +3427,7 @@ static int MenuSettingsFile()
sprintf (options.value[7], "%s", GCSettings.VerifySaves == true ? "On" : "Off");
ret = optionBrowser.GetClickedOption();
switch (ret)
{
case 0:
GCSettings.LoadMethod++;
break;
case 1:
GCSettings.SaveMethod++;
break;
case 2:
OnScreenKeyboard(GCSettings.LoadFolder, MAXPATHLEN);
break;
case 3:
OnScreenKeyboard(GCSettings.SaveFolder, MAXPATHLEN);
break;
case 4:
OnScreenKeyboard(GCSettings.CheatFolder, MAXPATHLEN);
break;
case 5:
GCSettings.AutoLoad++;
if (GCSettings.AutoLoad > 2)
GCSettings.AutoLoad = 0;
break;
case 6:
GCSettings.AutoSave++;
if (GCSettings.AutoSave > 3)
GCSettings.AutoSave = 0;
break;
case 7:
GCSettings.VerifySaves ^= 1;
break;
optionBrowser.TriggerUpdate();
}
if(backBtn.GetState() == STATE_CLICKED)
@ -3423,6 +3451,7 @@ static int MenuSettingsMenu()
int menu = MENU_NONE;
int ret;
int i = 0;
bool firstRun = true;
OptionList options;
sprintf(options.name[i++], "Exit Action");
@ -3480,6 +3509,38 @@ static int MenuSettingsMenu()
{
usleep(THREAD_SLEEP);
ret = optionBrowser.GetClickedOption();
switch (ret)
{
case 0:
GCSettings.ExitAction++;
if(GCSettings.ExitAction > 3)
GCSettings.ExitAction = 0;
break;
case 1:
GCSettings.WiimoteOrientation ^= 1;
break;
case 2:
GCSettings.MusicVolume += 10;
if(GCSettings.MusicVolume > 100)
GCSettings.MusicVolume = 0;
bgMusic->SetVolume(GCSettings.MusicVolume);
break;
case 3:
GCSettings.SFXVolume += 10;
if(GCSettings.SFXVolume > 100)
GCSettings.SFXVolume = 0;
break;
case 4:
GCSettings.Rumble ^= 1;
break;
}
if(ret >= 0 || firstRun)
{
firstRun = false;
#ifdef HW_RVL
if (GCSettings.ExitAction == 1)
sprintf (options.value[0], "Return to Wii Menu");
@ -3523,32 +3584,7 @@ static int MenuSettingsMenu()
else
sprintf (options.value[4], "Disabled");
ret = optionBrowser.GetClickedOption();
switch (ret)
{
case 0:
GCSettings.ExitAction++;
if(GCSettings.ExitAction > 3)
GCSettings.ExitAction = 0;
break;
case 1:
GCSettings.WiimoteOrientation ^= 1;
break;
case 2:
GCSettings.MusicVolume += 10;
if(GCSettings.MusicVolume > 100)
GCSettings.MusicVolume = 0;
bgMusic->SetVolume(GCSettings.MusicVolume);
break;
case 3:
GCSettings.SFXVolume += 10;
if(GCSettings.SFXVolume > 100)
GCSettings.SFXVolume = 0;
break;
case 4:
GCSettings.Rumble ^= 1;
break;
optionBrowser.TriggerUpdate();
}
if(backBtn.GetState() == STATE_CLICKED)
@ -3573,6 +3609,7 @@ static int MenuSettingsNetwork()
#ifdef HW_RVL
int ret;
int i = 0;
bool firstRun = true;
OptionList options;
sprintf(options.name[i++], "SMB Share IP");
sprintf(options.name[i++], "SMB Share Name");
@ -3628,11 +3665,6 @@ static int MenuSettingsNetwork()
{
usleep(THREAD_SLEEP);
strncpy (options.value[0], GCSettings.smbip, 15);
strncpy (options.value[1], GCSettings.smbshare, 19);
strncpy (options.value[2], GCSettings.smbuser, 19);
strncpy (options.value[3], GCSettings.smbpwd, 19);
ret = optionBrowser.GetClickedOption();
switch (ret)
@ -3654,6 +3686,18 @@ static int MenuSettingsNetwork()
break;
}
if(ret >= 0 || firstRun)
{
firstRun = false;
strncpy (options.value[0], GCSettings.smbip, 15);
strncpy (options.value[1], GCSettings.smbshare, 19);
strncpy (options.value[2], GCSettings.smbuser, 19);
strncpy (options.value[3], GCSettings.smbpwd, 19);
optionBrowser.TriggerUpdate();
}
if(backBtn.GetState() == STATE_CLICKED)
{
menu = MENU_SETTINGS;