mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-25 01:00:01 +00:00
Add support for changing the InputBox's title to the description text provided by the game(or the emulator itself). If none is provided(empty string), fall back to a default string.
This commit is contained in:
parent
22bceea46c
commit
1da0454508
@ -760,19 +760,28 @@ int PSPOskDialog::NativeKeyboard()
|
||||
std::string initial_text;
|
||||
ConvertUCS2ToUTF8(initial_text, oskParams->fields[0].intext);
|
||||
|
||||
const size_t buf_len = 512;
|
||||
char buf[buf_len];
|
||||
const size_t defaultText_len = 512;
|
||||
char defaultText[defaultText_len];
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
memset(defaultText, 0, sizeof(defaultText));
|
||||
|
||||
if(initial_text.length() < buf_len)
|
||||
sprintf(buf, initial_text.c_str());
|
||||
if(initial_text.length() < defaultText_len)
|
||||
sprintf(defaultText, initial_text.c_str());
|
||||
else {
|
||||
ERROR_LOG(HLE, "NativeKeyboard: initial text length is too long");
|
||||
sprintf(buf, "VALUE");
|
||||
sprintf(defaultText, "VALUE");
|
||||
}
|
||||
|
||||
if(!InputBox_GetString(0, MainWindow::hwndMain, NULL, buf, input, FieldMaxLength())) {
|
||||
char windowTitle[defaultText_len];
|
||||
memset(windowTitle, 0, sizeof(windowTitle));
|
||||
|
||||
std::string description_text;
|
||||
ConvertUCS2ToUTF8(description_text, oskParams->fields[0].desc);
|
||||
|
||||
if(description_text.length() < defaultText_len)
|
||||
sprintf(windowTitle, description_text.c_str());
|
||||
|
||||
if(!InputBox_GetString(0, MainWindow::hwndMain, windowTitle, defaultText, input, FieldMaxLength())) {
|
||||
sprintf(input, "");
|
||||
}
|
||||
#endif
|
||||
|
@ -1552,7 +1552,7 @@ void SystemScreen::render() {
|
||||
char name[name_len];
|
||||
memset(name, 0, sizeof(name));
|
||||
|
||||
if(InputBox_GetString(MainWindow::GetHInstance(), MainWindow::hwndMain, NULL, "PPSSPP", name, name_len))
|
||||
if(InputBox_GetString(MainWindow::GetHInstance(), MainWindow::hwndMain, "Enter a new PSP nickname", "PPSSPP", name, name_len))
|
||||
g_Config.sNickName.assign(name);
|
||||
else
|
||||
g_Config.sNickName.assign("PPSSPP");
|
||||
|
@ -4,12 +4,14 @@
|
||||
|
||||
static TCHAR textBoxContents[256];
|
||||
static TCHAR out[256];
|
||||
static TCHAR windowTitle[256];
|
||||
|
||||
static INT_PTR CALLBACK InputBoxFunc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message) {
|
||||
case WM_INITDIALOG:
|
||||
SetWindowText(GetDlgItem(hDlg,IDC_INPUTBOX),textBoxContents);
|
||||
SetWindowText(hDlg, windowTitle);
|
||||
return TRUE;
|
||||
case WM_COMMAND:
|
||||
switch (wParam)
|
||||
@ -51,11 +53,21 @@ bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, TCHAR *defa
|
||||
|
||||
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, TCHAR *defaultvalue, TCHAR *outvalue, u32 outlength)
|
||||
{
|
||||
const char *defaultTitle = "Input value";
|
||||
|
||||
if (defaultvalue && strlen(defaultvalue)<255)
|
||||
strcpy(textBoxContents,defaultvalue);
|
||||
else
|
||||
strcpy(textBoxContents,"");
|
||||
|
||||
|
||||
if(title && strlen(title) <= 0)
|
||||
strcpy(windowTitle, defaultTitle);
|
||||
else if(title && strlen(title) < 255)
|
||||
strcpy(windowTitle, title);
|
||||
else
|
||||
strcpy(windowTitle, defaultTitle);
|
||||
|
||||
if (IDOK==DialogBox(hInst,(LPCSTR)IDD_INPUTBOX,hParent,InputBoxFunc))
|
||||
{
|
||||
strncpy(outvalue, out, outlength);
|
||||
|
Loading…
Reference in New Issue
Block a user