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