small bugfixes

This commit is contained in:
dborth 2009-03-30 08:16:41 +00:00
parent eb19288847
commit 138b496bd9
5 changed files with 65 additions and 50 deletions

View File

@ -474,11 +474,12 @@ typedef struct _keytype {
class GuiKeyboard : public GuiWindow class GuiKeyboard : public GuiWindow
{ {
public: public:
GuiKeyboard(char * t); GuiKeyboard(char * t, u16 m);
~GuiKeyboard(); ~GuiKeyboard();
void Update(GuiTrigger * t); void Update(GuiTrigger * t);
char kbtextstr[100]; char kbtextstr[100];
protected: protected:
u16 kbtextmaxlen;
Key keys[4][10]; Key keys[4][10];
int shift; int shift;
int caps; int caps;

View File

@ -13,7 +13,7 @@
* Constructor for the GuiKeyboard class. * Constructor for the GuiKeyboard class.
*/ */
GuiKeyboard::GuiKeyboard(char * t) GuiKeyboard::GuiKeyboard(char * t, u16 max)
{ {
width = 540; width = 540;
height = 400; height = 400;
@ -25,6 +25,7 @@ GuiKeyboard::GuiKeyboard(char * t)
alignmentVert = ALIGN_MIDDLE; alignmentVert = ALIGN_MIDDLE;
strncpy(kbtextstr, t, 100); strncpy(kbtextstr, t, 100);
kbtextstr[100] = 0; kbtextstr[100] = 0;
kbtextmaxlen = max;
Key thekeys[4][10] = { Key thekeys[4][10] = {
{ {
@ -234,9 +235,12 @@ void GuiKeyboard::Update(GuiTrigger * t)
} }
if(keySpace->GetState() == STATE_CLICKED) if(keySpace->GetState() == STATE_CLICKED)
{
if(strlen(kbtextstr) < kbtextmaxlen)
{ {
kbtextstr[strlen(kbtextstr)] = ' '; kbtextstr[strlen(kbtextstr)] = ' ';
kbText->SetText(kbtextstr); kbText->SetText(kbtextstr);
}
keySpace->SetState(STATE_SELECTED); keySpace->SetState(STATE_SELECTED);
} }
else if(keyBack->GetState() == STATE_CLICKED) else if(keyBack->GetState() == STATE_CLICKED)
@ -270,6 +274,8 @@ void GuiKeyboard::Update(GuiTrigger * t)
keyTxt[i][j]->SetText(txt); keyTxt[i][j]->SetText(txt);
if(keyBtn[i][j]->GetState() == STATE_CLICKED) if(keyBtn[i][j]->GetState() == STATE_CLICKED)
{
if(strlen(kbtextstr) < kbtextmaxlen)
{ {
if(shift || caps) if(shift || caps)
{ {
@ -277,8 +283,10 @@ void GuiKeyboard::Update(GuiTrigger * t)
if(shift) shift ^= 1; if(shift) shift ^= 1;
} }
else else
{
kbtextstr[strlen(kbtextstr)] = keys[i][j].ch; kbtextstr[strlen(kbtextstr)] = keys[i][j].ch;
}
}
kbText->SetText(kbtextstr); kbText->SetText(kbtextstr);
keyBtn[i][j]->SetState(STATE_SELECTED); keyBtn[i][j]->SetState(STATE_SELECTED);
} }

View File

@ -498,11 +498,11 @@ void AutoSave()
} }
} }
static void OnScreenKeyboard(char * var) static void OnScreenKeyboard(char * var, u16 maxlen)
{ {
int save = -1; int save = -1;
GuiKeyboard keyboard(var); GuiKeyboard keyboard(var, maxlen);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM); GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM);
GuiImageData btnOutline(button_png); GuiImageData btnOutline(button_png);
@ -562,8 +562,7 @@ static void OnScreenKeyboard(char * var)
if(save) if(save)
{ {
strncpy(var, keyboard.kbtextstr, 100); snprintf(var, maxlen, "%s", keyboard.kbtextstr);
var[100] = 0;
} }
HaltGui(); HaltGui();
@ -2819,10 +2818,11 @@ static int MenuSettingsFile()
int ret; int ret;
int i = 0; int i = 0;
OptionList options; OptionList options;
sprintf(options.name[i++], "Load Method"); sprintf(options.name[i++], "Load Device");
sprintf(options.name[i++], "Save Device");
sprintf(options.name[i++], "Load Folder"); sprintf(options.name[i++], "Load Folder");
sprintf(options.name[i++], "Save Method");
sprintf(options.name[i++], "Save Folder"); sprintf(options.name[i++], "Save Folder");
sprintf(options.name[i++], "Cheats Folder");
sprintf(options.name[i++], "Auto Load"); sprintf(options.name[i++], "Auto Load");
sprintf(options.name[i++], "Auto Save"); sprintf(options.name[i++], "Auto Save");
sprintf(options.name[i++], "Verify MC Saves"); sprintf(options.name[i++], "Verify MC Saves");
@ -2858,7 +2858,7 @@ static int MenuSettingsFile()
GuiOptionBrowser optionBrowser(552, 248, &options); GuiOptionBrowser optionBrowser(552, 248, &options);
optionBrowser.SetPosition(0, 108); optionBrowser.SetPosition(0, 108);
optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
optionBrowser.SetCol2Position(180); optionBrowser.SetCol2Position(185);
HaltGui(); HaltGui();
GuiWindow w(screenwidth, screenheight); GuiWindow w(screenwidth, screenheight);
@ -2901,7 +2901,7 @@ static int MenuSettingsFile()
GCSettings.SaveMethod++; GCSettings.SaveMethod++;
if(GCSettings.SaveMethod == METHOD_MC_SLOTB) if(GCSettings.SaveMethod == METHOD_MC_SLOTB)
GCSettings.SaveMethod++; GCSettings.SaveMethod++;
options.name[6][0] = 0; options.name[7][0] = 0;
#endif #endif
// correct load/save methods out of bounds // correct load/save methods out of bounds
@ -2910,67 +2910,71 @@ static int MenuSettingsFile()
if(GCSettings.SaveMethod > 6) if(GCSettings.SaveMethod > 6)
GCSettings.SaveMethod = 0; GCSettings.SaveMethod = 0;
if (GCSettings.LoadMethod == METHOD_AUTO) sprintf (options.value[0],"Auto"); if (GCSettings.LoadMethod == METHOD_AUTO) sprintf (options.value[0],"Auto Detect");
else if (GCSettings.LoadMethod == METHOD_SD) sprintf (options.value[0],"SD"); else if (GCSettings.LoadMethod == METHOD_SD) sprintf (options.value[0],"SD");
else if (GCSettings.LoadMethod == METHOD_USB) sprintf (options.value[0],"USB"); else if (GCSettings.LoadMethod == METHOD_USB) sprintf (options.value[0],"USB");
else if (GCSettings.LoadMethod == METHOD_DVD) sprintf (options.value[0],"DVD"); else if (GCSettings.LoadMethod == METHOD_DVD) sprintf (options.value[0],"DVD");
else if (GCSettings.LoadMethod == METHOD_SMB) sprintf (options.value[0],"Network"); else if (GCSettings.LoadMethod == METHOD_SMB) sprintf (options.value[0],"Network");
sprintf (options.value[1], "%s", GCSettings.LoadFolder); if (GCSettings.SaveMethod == METHOD_AUTO) sprintf (options.value[1],"Auto Detect");
else if (GCSettings.SaveMethod == METHOD_SD) sprintf (options.value[1],"SD");
else if (GCSettings.SaveMethod == METHOD_USB) sprintf (options.value[1],"USB");
else if (GCSettings.SaveMethod == METHOD_SMB) sprintf (options.value[1],"Network");
else if (GCSettings.SaveMethod == METHOD_MC_SLOTA) sprintf (options.value[1],"MC Slot A");
else if (GCSettings.SaveMethod == METHOD_MC_SLOTB) sprintf (options.value[1],"MC Slot B");
if (GCSettings.SaveMethod == METHOD_AUTO) sprintf (options.value[2],"Auto"); snprintf (options.value[2], 256, "%s", GCSettings.LoadFolder);
else if (GCSettings.SaveMethod == METHOD_SD) sprintf (options.value[2],"SD"); snprintf (options.value[3], 256, "%s", GCSettings.SaveFolder);
else if (GCSettings.SaveMethod == METHOD_USB) sprintf (options.value[2],"USB"); snprintf (options.value[4], 256, "%s", GCSettings.CheatFolder);
else if (GCSettings.SaveMethod == METHOD_SMB) sprintf (options.value[2],"Network");
else if (GCSettings.SaveMethod == METHOD_MC_SLOTA) sprintf (options.value[2],"MC Slot A");
else if (GCSettings.SaveMethod == METHOD_MC_SLOTB) sprintf (options.value[2],"MC Slot B");
sprintf (options.value[3], "%s", GCSettings.SaveFolder); if (GCSettings.AutoLoad == 0) sprintf (options.value[5],"Off");
else if (GCSettings.AutoLoad == 1) sprintf (options.value[5],"SRAM");
if (GCSettings.AutoLoad == 0) sprintf (options.value[4],"Off"); else if (GCSettings.AutoLoad == 2) sprintf (options.value[5],"Snapshot");
else if (GCSettings.AutoLoad == 1) sprintf (options.value[4],"SRAM");
else if (GCSettings.AutoLoad == 2) sprintf (options.value[4],"Snapshot");
if (GCSettings.AutoSave == 0) sprintf (options.value[5],"Off"); if (GCSettings.AutoSave == 0) sprintf (options.value[5],"Off");
else if (GCSettings.AutoSave == 1) sprintf (options.value[5],"SRAM"); else if (GCSettings.AutoSave == 1) sprintf (options.value[6],"SRAM");
else if (GCSettings.AutoSave == 2) sprintf (options.value[5],"Snapshot"); else if (GCSettings.AutoSave == 2) sprintf (options.value[6],"Snapshot");
else if (GCSettings.AutoSave == 3) sprintf (options.value[5],"Both"); else if (GCSettings.AutoSave == 3) sprintf (options.value[6],"Both");
sprintf (options.value[6], "%s", GCSettings.VerifySaves == true ? "On" : "Off"); sprintf (options.value[7], "%s", GCSettings.VerifySaves == true ? "On" : "Off");
ret = optionBrowser.GetClickedOption(); ret = optionBrowser.GetClickedOption();
switch (ret) switch (ret)
{ {
case 0: case 0:
GCSettings.LoadMethod ++; GCSettings.LoadMethod++;
break; break;
case 1: case 1:
OnScreenKeyboard(GCSettings.LoadFolder); GCSettings.SaveMethod++;
break; break;
case 2: case 2:
GCSettings.SaveMethod ++; OnScreenKeyboard(GCSettings.LoadFolder, 256);
break; break;
case 3: case 3:
OnScreenKeyboard(GCSettings.SaveFolder); OnScreenKeyboard(GCSettings.SaveFolder, 256);
break; break;
case 4: case 4:
GCSettings.AutoLoad ++; OnScreenKeyboard(GCSettings.CheatFolder, 256);
break;
case 5:
GCSettings.AutoLoad++;
if (GCSettings.AutoLoad > 2) if (GCSettings.AutoLoad > 2)
GCSettings.AutoLoad = 0; GCSettings.AutoLoad = 0;
break; break;
case 5: case 6:
GCSettings.AutoSave ++; GCSettings.AutoSave++;
if (GCSettings.AutoSave > 3) if (GCSettings.AutoSave > 3)
GCSettings.AutoSave = 0; GCSettings.AutoSave = 0;
break; break;
case 6: case 7:
GCSettings.VerifySaves ^= 1; GCSettings.VerifySaves ^= 1;
break; break;
} }
@ -3189,19 +3193,19 @@ static int MenuSettingsNetwork()
switch (ret) switch (ret)
{ {
case 0: case 0:
OnScreenKeyboard(GCSettings.smbip); OnScreenKeyboard(GCSettings.smbip, 16);
break; break;
case 1: case 1:
OnScreenKeyboard(GCSettings.smbshare); OnScreenKeyboard(GCSettings.smbshare, 20);
break; break;
case 2: case 2:
OnScreenKeyboard(GCSettings.smbuser); OnScreenKeyboard(GCSettings.smbuser, 20);
break; break;
case 3: case 3:
OnScreenKeyboard(GCSettings.smbpwd); OnScreenKeyboard(GCSettings.smbpwd, 20);
break; break;
} }

View File

@ -41,6 +41,8 @@ void FixInvalidSettings()
GCSettings.SFXVolume = 40; GCSettings.SFXVolume = 40;
if(GCSettings.Controller > CTRL_PAD4 || GCSettings.Controller < CTRL_MOUSE) if(GCSettings.Controller > CTRL_PAD4 || GCSettings.Controller < CTRL_MOUSE)
GCSettings.Controller = CTRL_PAD2; GCSettings.Controller = CTRL_PAD2;
if(!(GCSettings.render >= 0 && GCSettings.render < 3))
GCSettings.render = 2;
} }
/**************************************************************************** /****************************************************************************

View File

@ -66,9 +66,9 @@ struct SGCSettings{
int AutoSave; int AutoSave;
int LoadMethod; // For ROMS: Auto, SD, DVD, USB, Network (SMB) int LoadMethod; // For ROMS: Auto, SD, DVD, USB, Network (SMB)
int SaveMethod; // For SRAM, Freeze, Prefs: Auto, SD, Memory Card Slot A, Memory Card Slot B, USB, SMB int SaveMethod; // For SRAM, Freeze, Prefs: Auto, SD, Memory Card Slot A, Memory Card Slot B, USB, SMB
char LoadFolder[200]; // Path to game files char LoadFolder[256]; // Path to game files
char SaveFolder[200]; // Path to save files char SaveFolder[256]; // Path to save files
char CheatFolder[200]; // Path to cheat files char CheatFolder[256]; // Path to cheat files
char smbip[16]; char smbip[16];
char smbuser[20]; char smbuser[20];