mirror of
https://github.com/dborth/vbagx.git
synced 2024-12-27 11:11:50 +01:00
improvements to onscreen keyboard
This commit is contained in:
parent
d941c4a02c
commit
af143efc34
@ -59,6 +59,7 @@ extern FreeTypeGX *fontSystem;
|
||||
#define SAVELISTSIZE 6
|
||||
#define MAX_SAVES 20
|
||||
#define MAX_OPTIONS 30
|
||||
#define MAX_KEYBOARD_DISPLAY 32
|
||||
|
||||
typedef void (*UpdateCallback)(void * e);
|
||||
|
||||
|
@ -9,6 +9,24 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "gui.h"
|
||||
|
||||
static char tmptxt[MAX_KEYBOARD_DISPLAY];
|
||||
|
||||
static char * GetDisplayText(char * t)
|
||||
{
|
||||
if(!t)
|
||||
return NULL;
|
||||
|
||||
int len = strlen(t);
|
||||
|
||||
if(len < MAX_KEYBOARD_DISPLAY)
|
||||
return t;
|
||||
|
||||
strncpy(tmptxt, &t[len-MAX_KEYBOARD_DISPLAY], MAX_KEYBOARD_DISPLAY);
|
||||
tmptxt[MAX_KEYBOARD_DISPLAY-1] = 0;
|
||||
return &tmptxt[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for the GuiKeyboard class.
|
||||
*/
|
||||
@ -90,7 +108,7 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
|
||||
keyTextboxImg->SetPosition(0, 0);
|
||||
this->Append(keyTextboxImg);
|
||||
|
||||
kbText = new GuiText(kbtextstr, 22, (GXColor){0, 0, 0, 0xff});
|
||||
kbText = new GuiText(GetDisplayText(kbtextstr), 22, (GXColor){0, 0, 0, 0xff});
|
||||
kbText->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
||||
kbText->SetPosition(0, 13);
|
||||
this->Append(kbText);
|
||||
@ -166,15 +184,18 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
|
||||
keySpace->SetEffectGrow();
|
||||
this->Append(keySpace);
|
||||
|
||||
char txt[2] = { 0, 0 };
|
||||
|
||||
for(int i=0; i<4; i++)
|
||||
{
|
||||
for(int j=0; j<11; j++)
|
||||
{
|
||||
if(keys[i][j].ch != '\0')
|
||||
{
|
||||
txt[0] = keys[i][j].ch;
|
||||
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] = new GuiText(txt, 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());
|
||||
@ -251,6 +272,8 @@ void GuiKeyboard::Update(GuiTrigger * t)
|
||||
catch (const std::exception& e) { }
|
||||
}
|
||||
|
||||
bool update = false;
|
||||
|
||||
if(keySpace->GetState() == STATE_CLICKED)
|
||||
{
|
||||
if(strlen(kbtextstr) < kbtextmaxlen)
|
||||
@ -263,18 +286,20 @@ void GuiKeyboard::Update(GuiTrigger * t)
|
||||
else if(keyBack->GetState() == STATE_CLICKED)
|
||||
{
|
||||
kbtextstr[strlen(kbtextstr)-1] = 0;
|
||||
kbText->SetText(kbtextstr);
|
||||
kbText->SetText(GetDisplayText(kbtextstr));
|
||||
keyBack->SetState(STATE_SELECTED, t->chan);
|
||||
}
|
||||
else if(keyShift->GetState() == STATE_CLICKED)
|
||||
{
|
||||
shift ^= 1;
|
||||
keyShift->SetState(STATE_SELECTED, t->chan);
|
||||
update = true;
|
||||
}
|
||||
else if(keyCaps->GetState() == STATE_CLICKED)
|
||||
{
|
||||
caps ^= 1;
|
||||
keyCaps->SetState(STATE_SELECTED, t->chan);
|
||||
update = true;
|
||||
}
|
||||
|
||||
char txt[2] = { 0, 0 };
|
||||
@ -285,12 +310,15 @@ void GuiKeyboard::Update(GuiTrigger * t)
|
||||
{
|
||||
if(keys[i][j].ch != '\0')
|
||||
{
|
||||
if(shift || caps)
|
||||
txt[0] = keys[i][j].chShift;
|
||||
else
|
||||
txt[0] = keys[i][j].ch;
|
||||
if(update)
|
||||
{
|
||||
if(shift || caps)
|
||||
txt[0] = keys[i][j].chShift;
|
||||
else
|
||||
txt[0] = keys[i][j].ch;
|
||||
|
||||
keyTxt[i][j]->SetText(txt);
|
||||
keyTxt[i][j]->SetText(txt);
|
||||
}
|
||||
|
||||
if(keyBtn[i][j]->GetState() == STATE_CLICKED)
|
||||
{
|
||||
@ -306,7 +334,7 @@ void GuiKeyboard::Update(GuiTrigger * t)
|
||||
kbtextstr[strlen(kbtextstr)] = keys[i][j].ch;
|
||||
}
|
||||
}
|
||||
kbText->SetText(kbtextstr);
|
||||
kbText->SetText(GetDisplayText(kbtextstr));
|
||||
keyBtn[i][j]->SetState(STATE_SELECTED, t->chan);
|
||||
}
|
||||
}
|
||||
|
@ -3176,9 +3176,9 @@ static int MenuSettingsFile()
|
||||
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");
|
||||
|
||||
snprintf (options.value[2], 256, "%s", GCSettings.LoadFolder);
|
||||
snprintf (options.value[3], 256, "%s", GCSettings.SaveFolder);
|
||||
snprintf (options.value[4], 256, "%s", GCSettings.CheatFolder);
|
||||
snprintf (options.value[2], 30, "%s", GCSettings.LoadFolder);
|
||||
snprintf (options.value[3], 30, "%s", GCSettings.SaveFolder);
|
||||
//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],"SRAM");
|
||||
@ -3204,15 +3204,15 @@ static int MenuSettingsFile()
|
||||
break;
|
||||
|
||||
case 2:
|
||||
OnScreenKeyboard(GCSettings.LoadFolder, 30);
|
||||
OnScreenKeyboard(GCSettings.LoadFolder, MAXPATHLEN);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
OnScreenKeyboard(GCSettings.SaveFolder, 30);
|
||||
OnScreenKeyboard(GCSettings.SaveFolder, MAXPATHLEN);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
OnScreenKeyboard(GCSettings.CheatFolder, 30);
|
||||
OnScreenKeyboard(GCSettings.CheatFolder, MAXPATHLEN);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
|
@ -47,9 +47,9 @@ struct SGCSettings{
|
||||
int AutoSave;
|
||||
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
|
||||
char LoadFolder[200]; // Path to game files
|
||||
char SaveFolder[200]; // Path to save files
|
||||
char CheatFolder[200]; // Path to cheat files
|
||||
char LoadFolder[MAXPATHLEN]; // Path to game files
|
||||
char SaveFolder[MAXPATHLEN]; // Path to save files
|
||||
char CheatFolder[MAXPATHLEN]; // Path to cheat files
|
||||
int VerifySaves;
|
||||
|
||||
char smbip[16];
|
||||
|
Loading…
Reference in New Issue
Block a user