mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-24 03:29:22 +01:00
fix turning autosave off in menu, fix keyboard, add more keyboard keys
This commit is contained in:
parent
ef3b5a84f6
commit
9563296da3
@ -748,13 +748,13 @@ typedef struct _keytype {
|
||||
class GuiKeyboard : public GuiWindow
|
||||
{
|
||||
public:
|
||||
GuiKeyboard(char * t, u16 m);
|
||||
GuiKeyboard(char * t, u32 m);
|
||||
~GuiKeyboard();
|
||||
void Update(GuiTrigger * t);
|
||||
char kbtextstr[100];
|
||||
char kbtextstr[256];
|
||||
protected:
|
||||
u16 kbtextmaxlen;
|
||||
Key keys[4][10];
|
||||
u32 kbtextmaxlen;
|
||||
Key keys[4][11];
|
||||
int shift;
|
||||
int caps;
|
||||
GuiText * kbText;
|
||||
@ -774,10 +774,10 @@ class GuiKeyboard : public GuiWindow
|
||||
GuiImage * keySpaceImg;
|
||||
GuiImage * keySpaceOverImg;
|
||||
GuiButton * keySpace;
|
||||
GuiButton * keyBtn[4][10];
|
||||
GuiImage * keyImg[4][10];
|
||||
GuiImage * keyImgOver[4][10];
|
||||
GuiText * keyTxt[4][10];
|
||||
GuiButton * keyBtn[4][11];
|
||||
GuiImage * keyImg[4][11];
|
||||
GuiImage * keyImgOver[4][11];
|
||||
GuiText * keyTxt[4][11];
|
||||
GuiImageData * keyTextbox;
|
||||
GuiImageData * key;
|
||||
GuiImageData * keyOver;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* Constructor for the GuiKeyboard class.
|
||||
*/
|
||||
|
||||
GuiKeyboard::GuiKeyboard(char * t, u16 max)
|
||||
GuiKeyboard::GuiKeyboard(char * t, u32 max)
|
||||
{
|
||||
width = 540;
|
||||
height = 400;
|
||||
@ -23,11 +23,11 @@ GuiKeyboard::GuiKeyboard(char * t, u16 max)
|
||||
focus = 0; // allow focus
|
||||
alignmentHor = ALIGN_CENTRE;
|
||||
alignmentVert = ALIGN_MIDDLE;
|
||||
strncpy(kbtextstr, t, 100);
|
||||
kbtextstr[100] = 0;
|
||||
strncpy(kbtextstr, t, max);
|
||||
kbtextstr[max] = 0;
|
||||
kbtextmaxlen = max;
|
||||
|
||||
Key thekeys[4][10] = {
|
||||
Key thekeys[4][11] = {
|
||||
{
|
||||
{'1','!'},
|
||||
{'2','@'},
|
||||
@ -38,7 +38,8 @@ GuiKeyboard::GuiKeyboard(char * t, u16 max)
|
||||
{'7','&'},
|
||||
{'8','*'},
|
||||
{'9','('},
|
||||
{'0',')'}
|
||||
{'0',')'},
|
||||
{'\0','\0'}
|
||||
},
|
||||
{
|
||||
{'q','Q'},
|
||||
@ -50,7 +51,8 @@ GuiKeyboard::GuiKeyboard(char * t, u16 max)
|
||||
{'u','U'},
|
||||
{'i','I'},
|
||||
{'o','O'},
|
||||
{'p','P'}
|
||||
{'p','P'},
|
||||
{'-','_'}
|
||||
},
|
||||
{
|
||||
{'a','A'},
|
||||
@ -62,7 +64,8 @@ GuiKeyboard::GuiKeyboard(char * t, u16 max)
|
||||
{'j','J'},
|
||||
{'k','K'},
|
||||
{'l','L'},
|
||||
{':',';'}
|
||||
{':',';'},
|
||||
{'\'','"'}
|
||||
},
|
||||
|
||||
{
|
||||
@ -75,7 +78,8 @@ GuiKeyboard::GuiKeyboard(char * t, u16 max)
|
||||
{'m','M'},
|
||||
{',','<'},
|
||||
{'.','>'},
|
||||
{'/','?'}
|
||||
{'/','?'},
|
||||
{'\0','\0'}
|
||||
}
|
||||
};
|
||||
memcpy(keys, thekeys, sizeof(thekeys));
|
||||
@ -164,23 +168,26 @@ GuiKeyboard::GuiKeyboard(char * t, u16 max)
|
||||
|
||||
for(int i=0; i<4; i++)
|
||||
{
|
||||
for(int j=0; j<10; j++)
|
||||
for(int j=0; j<11; j++)
|
||||
{
|
||||
keyImg[i][j] = new GuiImage(key);
|
||||
keyImgOver[i][j] = new GuiImage(keyOver);
|
||||
keyTxt[i][j] = new GuiText(NULL, 22, (GXColor){0, 0, 0, 0xff});
|
||||
keyTxt[i][j]->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
|
||||
keyTxt[i][j]->SetPosition(0, -10);
|
||||
keyBtn[i][j] = new GuiButton(key->GetWidth(), key->GetHeight());
|
||||
keyBtn[i][j]->SetImage(keyImg[i][j]);
|
||||
keyBtn[i][j]->SetImageOver(keyImgOver[i][j]);
|
||||
keyBtn[i][j]->SetSoundOver(keySoundOver);
|
||||
keyBtn[i][j]->SetSoundClick(keySoundClick);
|
||||
keyBtn[i][j]->SetTrigger(trigA);
|
||||
keyBtn[i][j]->SetLabel(keyTxt[i][j]);
|
||||
keyBtn[i][j]->SetPosition(j*42+21*i+40, i*42+80);
|
||||
keyBtn[i][j]->SetEffectGrow();
|
||||
this->Append(keyBtn[i][j]);
|
||||
if(keys[i][j].ch != '\0')
|
||||
{
|
||||
keyImg[i][j] = new GuiImage(key);
|
||||
keyImgOver[i][j] = new GuiImage(keyOver);
|
||||
keyTxt[i][j] = new GuiText(NULL, 22, (GXColor){0, 0, 0, 0xff});
|
||||
keyTxt[i][j]->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
|
||||
keyTxt[i][j]->SetPosition(0, -10);
|
||||
keyBtn[i][j] = new GuiButton(key->GetWidth(), key->GetHeight());
|
||||
keyBtn[i][j]->SetImage(keyImg[i][j]);
|
||||
keyBtn[i][j]->SetImageOver(keyImgOver[i][j]);
|
||||
keyBtn[i][j]->SetSoundOver(keySoundOver);
|
||||
keyBtn[i][j]->SetSoundClick(keySoundClick);
|
||||
keyBtn[i][j]->SetTrigger(trigA);
|
||||
keyBtn[i][j]->SetLabel(keyTxt[i][j]);
|
||||
keyBtn[i][j]->SetPosition(j*42+21*i+40, i*42+80);
|
||||
keyBtn[i][j]->SetEffectGrow();
|
||||
this->Append(keyBtn[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -220,12 +227,15 @@ GuiKeyboard::~GuiKeyboard()
|
||||
|
||||
for(int i=0; i<4; i++)
|
||||
{
|
||||
for(int j=0; j<10; j++)
|
||||
for(int j=0; j<11; j++)
|
||||
{
|
||||
delete keyImg[i][j];
|
||||
delete keyImgOver[i][j];
|
||||
delete keyTxt[i][j];
|
||||
delete keyBtn[i][j];
|
||||
if(keys[i][j].ch != '\0')
|
||||
{
|
||||
delete keyImg[i][j];
|
||||
delete keyImgOver[i][j];
|
||||
delete keyTxt[i][j];
|
||||
delete keyBtn[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -271,31 +281,34 @@ void GuiKeyboard::Update(GuiTrigger * t)
|
||||
|
||||
for(int i=0; i<4; i++)
|
||||
{
|
||||
for(int j=0; j<10; j++)
|
||||
for(int j=0; j<11; j++)
|
||||
{
|
||||
if(shift || caps)
|
||||
txt[0] = keys[i][j].chShift;
|
||||
else
|
||||
txt[0] = keys[i][j].ch;
|
||||
|
||||
keyTxt[i][j]->SetText(txt);
|
||||
|
||||
if(keyBtn[i][j]->GetState() == STATE_CLICKED)
|
||||
if(keys[i][j].ch != '\0')
|
||||
{
|
||||
if(strlen(kbtextstr) < kbtextmaxlen)
|
||||
if(shift || caps)
|
||||
txt[0] = keys[i][j].chShift;
|
||||
else
|
||||
txt[0] = keys[i][j].ch;
|
||||
|
||||
keyTxt[i][j]->SetText(txt);
|
||||
|
||||
if(keyBtn[i][j]->GetState() == STATE_CLICKED)
|
||||
{
|
||||
if(shift || caps)
|
||||
if(strlen(kbtextstr) < kbtextmaxlen)
|
||||
{
|
||||
kbtextstr[strlen(kbtextstr)] = keys[i][j].chShift;
|
||||
if(shift) shift ^= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
kbtextstr[strlen(kbtextstr)] = keys[i][j].ch;
|
||||
if(shift || caps)
|
||||
{
|
||||
kbtextstr[strlen(kbtextstr)] = keys[i][j].chShift;
|
||||
if(shift) shift ^= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
kbtextstr[strlen(kbtextstr)] = keys[i][j].ch;
|
||||
}
|
||||
}
|
||||
kbText->SetText(kbtextstr);
|
||||
keyBtn[i][j]->SetState(STATE_SELECTED);
|
||||
}
|
||||
kbText->SetText(kbtextstr);
|
||||
keyBtn[i][j]->SetState(STATE_SELECTED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -571,7 +571,7 @@ void AutoSave()
|
||||
* Opens an on-screen keyboard window, with the data entered being stored
|
||||
* into the specified variable.
|
||||
***************************************************************************/
|
||||
static void OnScreenKeyboard(char * var, u16 maxlen)
|
||||
static void OnScreenKeyboard(char * var, u32 maxlen)
|
||||
{
|
||||
int save = -1;
|
||||
|
||||
@ -3149,7 +3149,7 @@ static int MenuSettingsFile()
|
||||
else if (GCSettings.AutoLoad == 1) sprintf (options.value[5],"SRAM");
|
||||
else if (GCSettings.AutoLoad == 2) sprintf (options.value[5],"Snapshot");
|
||||
|
||||
if (GCSettings.AutoSave == 0) sprintf (options.value[5],"Off");
|
||||
if (GCSettings.AutoSave == 0) sprintf (options.value[6],"Off");
|
||||
else if (GCSettings.AutoSave == 1) sprintf (options.value[6],"SRAM");
|
||||
else if (GCSettings.AutoSave == 2) sprintf (options.value[6],"Snapshot");
|
||||
else if (GCSettings.AutoSave == 3) sprintf (options.value[6],"Both");
|
||||
@ -3169,15 +3169,15 @@ static int MenuSettingsFile()
|
||||
break;
|
||||
|
||||
case 2:
|
||||
OnScreenKeyboard(GCSettings.LoadFolder, 256);
|
||||
OnScreenKeyboard(GCSettings.LoadFolder, 30);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
OnScreenKeyboard(GCSettings.SaveFolder, 256);
|
||||
OnScreenKeyboard(GCSettings.SaveFolder, 30);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
OnScreenKeyboard(GCSettings.CheatFolder, 256);
|
||||
OnScreenKeyboard(GCSettings.CheatFolder, 30);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
|
Loading…
Reference in New Issue
Block a user