Skip to content

Commit

Permalink
Win32: Simplify Change Nickname code and slightly change InputBox_Get…
Browse files Browse the repository at this point in the history
…String to take a const default value. We don't modify it.
  • Loading branch information
thedax committed Aug 23, 2013
1 parent 09dc4ac commit e97def9
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Core/Host.h
Expand Up @@ -67,7 +67,7 @@ class Host

#ifdef _WIN32
// Implement this on your platform to grab text input from the user for whatever purpose.
virtual bool InputBoxGetString(char *title, char *defaultValue, char *outValue, size_t outlength) { return false; }
virtual bool InputBoxGetString(char *title, const char *defaultValue, char *outValue, size_t outlength) { return false; }
#endif

// Used for headless.
Expand Down
11 changes: 1 addition & 10 deletions UI/GameSettingsScreen.cpp
Expand Up @@ -477,19 +477,10 @@ UI::EventReturn GameSettingsScreen::OnChangeNickname(UI::EventParams &e) {
char name[name_len];
memset(name, 0, sizeof(name));

size_t default_len = strlen(g_Config.sNickName.c_str());

char *defaultVal = new char[default_len];
memset(defaultVal, 0, sizeof(default_len));
strcat(defaultVal, g_Config.sNickName.c_str());

if (host->InputBoxGetString("Enter a new PSP nickname", defaultVal, name, name_len)) {
if (host->InputBoxGetString("Enter a new PSP nickname", g_Config.sNickName.c_str(), name, name_len)) {
g_Config.sNickName = name;
}

delete [] defaultVal;
defaultVal = NULL;

#endif
return UI::EVENT_DONE;
}
Expand Down
2 changes: 1 addition & 1 deletion Windows/InputBox.cpp
Expand Up @@ -59,7 +59,7 @@ bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, TCHAR *defa
return false;
}

bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, TCHAR *defaultvalue, TCHAR *outvalue, size_t outlength)
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, const TCHAR *defaultvalue, TCHAR *outvalue, size_t outlength)
{
const char *defaultTitle = "Input value";
defaultSelected = true;
Expand Down
2 changes: 1 addition & 1 deletion Windows/InputBox.h
Expand Up @@ -4,5 +4,5 @@

#include "Common/CommonWindows.h"
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, TCHAR *defaultvalue, TCHAR *outvalue, bool selected = true);
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, TCHAR *defaultvalue, TCHAR *outvalue, size_t outlength);
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, const TCHAR *defaultvalue, TCHAR *outvalue, size_t outlength);
bool InputBox_GetHex(HINSTANCE hInst, HWND hParent, TCHAR *title, u32 defaultvalue, u32 &outvalue);
2 changes: 1 addition & 1 deletion Windows/WindowsHost.cpp
Expand Up @@ -287,7 +287,7 @@ void WindowsHost::UpdateConsolePosition()
}
}

bool WindowsHost::InputBoxGetString(char *title, char *defaultValue, char *outValue, size_t outLength)
bool WindowsHost::InputBoxGetString(char *title, const char *defaultValue, char *outValue, size_t outLength)
{
return InputBox_GetString(MainWindow::GetHInstance(), MainWindow::GetHWND(), title, defaultValue, outValue, outLength);
}
2 changes: 1 addition & 1 deletion Windows/WindowsHost.h
Expand Up @@ -55,7 +55,7 @@ class WindowsHost : public Host
void SaveSymbolMap();
void SetWindowTitle(const char *message);

bool InputBoxGetString(char *title, char *defaultValue, char *outValue, size_t outlength);
bool InputBoxGetString(char *title, const char *defaultValue, char *outValue, size_t outlength);

std::shared_ptr<KeyboardDevice> keyboard;

Expand Down

0 comments on commit e97def9

Please sign in to comment.