mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Windows inputbox: Add flags field, delete dupe code, add ability to mask passwords
This commit is contained in:
parent
9699be2110
commit
f020d1d815
16 changed files with 109 additions and 121 deletions
|
@ -84,8 +84,8 @@ extern RequestManager g_requestManager;
|
|||
// Wrappers for easy requests.
|
||||
// NOTE: Semantics have changed - this no longer calls the callback on cancellation, instead you
|
||||
// can specify a different callback for that.
|
||||
inline void System_InputBoxGetString(RequesterToken token, std::string_view title, std::string_view defaultValue, RequestCallback callback, RequestFailedCallback failedCallback = nullptr) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::INPUT_TEXT_MODAL, token, callback, failedCallback, title, defaultValue, 0);
|
||||
inline void System_InputBoxGetString(RequesterToken token, std::string_view title, std::string_view defaultValue, bool passwordMasking, RequestCallback callback, RequestFailedCallback failedCallback = nullptr) {
|
||||
g_requestManager.MakeSystemRequest(SystemRequestType::INPUT_TEXT_MODAL, token, callback, failedCallback, title, defaultValue, passwordMasking ? 1 : 0);
|
||||
}
|
||||
|
||||
// This one will pop up a special image browser if available. You can also pick
|
||||
|
|
|
@ -528,7 +528,7 @@ EventReturn PopupTextInputChoice::HandleClick(EventParams &e) {
|
|||
|
||||
// Choose method depending on platform capabilities.
|
||||
if (System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) {
|
||||
System_InputBoxGetString(token_, text_, *value_ , [=](const std::string &enteredValue, int) {
|
||||
System_InputBoxGetString(token_, text_, *value_, passwordDisplay_, [=](const std::string &enteredValue, int) {
|
||||
*value_ = StripSpaces(enteredValue);
|
||||
EventParams params{};
|
||||
OnChange.Trigger(params);
|
||||
|
|
|
@ -897,7 +897,7 @@ int PSPOskDialog::NativeKeyboard() {
|
|||
defaultText.assign(u"VALUE");
|
||||
|
||||
// There's already ConvertUCS2ToUTF8 in this file. Should we use that instead of the global ones?
|
||||
System_InputBoxGetString(NON_EPHEMERAL_TOKEN, ::ConvertUCS2ToUTF8(titleText), ::ConvertUCS2ToUTF8(defaultText),
|
||||
System_InputBoxGetString(NON_EPHEMERAL_TOKEN, ::ConvertUCS2ToUTF8(titleText), ::ConvertUCS2ToUTF8(defaultText), false,
|
||||
[&](const std::string &value, int) {
|
||||
// Success callback
|
||||
std::lock_guard<std::mutex> guard(nativeMutex_);
|
||||
|
|
|
@ -234,7 +234,8 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
|||
g_QuitRequested = true;
|
||||
return true;
|
||||
#if PPSSPP_PLATFORM(SWITCH)
|
||||
case SystemRequestType::INPUT_TEXT_MODAL: {
|
||||
case SystemRequestType::INPUT_TEXT_MODAL:
|
||||
{
|
||||
// swkbd only works on "real" titles
|
||||
if (__nx_applet_type != AppletType_Application && __nx_applet_type != AppletType_SystemApplication) {
|
||||
g_requestManager.PostSystemFailure(requestId);
|
||||
|
|
|
@ -180,7 +180,7 @@ void ChatMenu::Update() {
|
|||
// Could remove the fullscreen check here, it works now.
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
if (promptInput_ && g_Config.bBypassOSKWithKeyboard && !g_Config.UseFullScreen()) {
|
||||
System_InputBoxGetString(token_, n->T("Chat"), n->T("Chat Here"), [](const std::string &value, int) {
|
||||
System_InputBoxGetString(token_, n->T("Chat"), n->T("Chat Here"), false, [](const std::string &value, int) {
|
||||
sendChat(value);
|
||||
});
|
||||
promptInput_ = false;
|
||||
|
|
|
@ -1648,7 +1648,7 @@ UI::EventReturn GameSettingsScreen::OnAudioDevice(UI::EventParams &e) {
|
|||
UI::EventReturn GameSettingsScreen::OnChangeQuickChat0(UI::EventParams &e) {
|
||||
#if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH)
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
System_InputBoxGetString(GetRequesterToken(), n->T("Enter Quick Chat 1"), g_Config.sQuickChat0, [](const std::string &value, int) {
|
||||
System_InputBoxGetString(GetRequesterToken(), n->T("Enter Quick Chat 1"), g_Config.sQuickChat0, false, [](const std::string &value, int) {
|
||||
g_Config.sQuickChat0 = value;
|
||||
});
|
||||
#endif
|
||||
|
@ -1658,7 +1658,7 @@ UI::EventReturn GameSettingsScreen::OnChangeQuickChat0(UI::EventParams &e) {
|
|||
UI::EventReturn GameSettingsScreen::OnChangeQuickChat1(UI::EventParams &e) {
|
||||
#if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH)
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
System_InputBoxGetString(GetRequesterToken(), n->T("Enter Quick Chat 2"), g_Config.sQuickChat1, [](const std::string &value, int) {
|
||||
System_InputBoxGetString(GetRequesterToken(), n->T("Enter Quick Chat 2"), g_Config.sQuickChat1, false, [](const std::string &value, int) {
|
||||
g_Config.sQuickChat1 = value;
|
||||
});
|
||||
#endif
|
||||
|
@ -1668,7 +1668,7 @@ UI::EventReturn GameSettingsScreen::OnChangeQuickChat1(UI::EventParams &e) {
|
|||
UI::EventReturn GameSettingsScreen::OnChangeQuickChat2(UI::EventParams &e) {
|
||||
#if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH)
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
System_InputBoxGetString(GetRequesterToken(), n->T("Enter Quick Chat 3"), g_Config.sQuickChat2, [](const std::string &value, int) {
|
||||
System_InputBoxGetString(GetRequesterToken(), n->T("Enter Quick Chat 3"), g_Config.sQuickChat2, false, [](const std::string &value, int) {
|
||||
g_Config.sQuickChat2 = value;
|
||||
});
|
||||
#endif
|
||||
|
@ -1678,7 +1678,7 @@ UI::EventReturn GameSettingsScreen::OnChangeQuickChat2(UI::EventParams &e) {
|
|||
UI::EventReturn GameSettingsScreen::OnChangeQuickChat3(UI::EventParams &e) {
|
||||
#if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH)
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
System_InputBoxGetString(GetRequesterToken(), n->T("Enter Quick Chat 4"), g_Config.sQuickChat3, [](const std::string &value, int) {
|
||||
System_InputBoxGetString(GetRequesterToken(), n->T("Enter Quick Chat 4"), g_Config.sQuickChat3, false, [](const std::string &value, int) {
|
||||
g_Config.sQuickChat3 = value;
|
||||
});
|
||||
#endif
|
||||
|
@ -1688,7 +1688,7 @@ UI::EventReturn GameSettingsScreen::OnChangeQuickChat3(UI::EventParams &e) {
|
|||
UI::EventReturn GameSettingsScreen::OnChangeQuickChat4(UI::EventParams &e) {
|
||||
#if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH)
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
System_InputBoxGetString(GetRequesterToken(), n->T("Enter Quick Chat 5"), g_Config.sQuickChat4, [](const std::string &value, int) {
|
||||
System_InputBoxGetString(GetRequesterToken(), n->T("Enter Quick Chat 5"), g_Config.sQuickChat4, false, [](const std::string &value, int) {
|
||||
g_Config.sQuickChat4 = value;
|
||||
});
|
||||
#endif
|
||||
|
@ -1698,7 +1698,7 @@ UI::EventReturn GameSettingsScreen::OnChangeQuickChat4(UI::EventParams &e) {
|
|||
UI::EventReturn GameSettingsScreen::OnChangeNickname(UI::EventParams &e) {
|
||||
#if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH)
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
System_InputBoxGetString(GetRequesterToken(), n->T("Enter a new PSP nickname"), g_Config.sNickName, [](const std::string &value, int) {
|
||||
System_InputBoxGetString(GetRequesterToken(), n->T("Enter a new PSP nickname"), g_Config.sNickName, false, [](const std::string &value, int) {
|
||||
g_Config.sNickName = StripSpaces(value);
|
||||
});
|
||||
#endif
|
||||
|
@ -2325,7 +2325,7 @@ UI::EventReturn HostnameSelectScreen::OnDeleteAllClick(UI::EventParams &e) {
|
|||
|
||||
UI::EventReturn HostnameSelectScreen::OnEditClick(UI::EventParams& e) {
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
System_InputBoxGetString(GetRequesterToken(), n->T("proAdhocServer Address:"), addrView_->GetText(), [this](const std::string& value, int) {
|
||||
System_InputBoxGetString(GetRequesterToken(), n->T("proAdhocServer Address:"), addrView_->GetText(), false, [this](const std::string& value, int) {
|
||||
addrView_->SetText(value);
|
||||
});
|
||||
return UI::EVENT_DONE;
|
||||
|
|
|
@ -798,7 +798,7 @@ void GameBrowser::Refresh() {
|
|||
if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_TV) {
|
||||
topBar->Add(new Choice(mm->T("Enter Path"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Add([=](UI::EventParams &) {
|
||||
auto mm = GetI18NCategory(I18NCat::MAINMENU);
|
||||
System_InputBoxGetString(token_, mm->T("Enter Path"), path_.GetPath().ToString(), [=](const char *responseString, int responseValue) {
|
||||
System_InputBoxGetString(token_, mm->T("Enter Path"), path_.GetPath().ToString(), false, [=](const char *responseString, int responseValue) {
|
||||
this->SetPath(Path(responseString));
|
||||
});
|
||||
return UI::EVENT_DONE;
|
||||
|
@ -1358,7 +1358,7 @@ bool MainScreen::key(const KeyInput &touch) {
|
|||
searchKeyModifier_ = true;
|
||||
if (touch.keyCode == NKCODE_F && searchKeyModifier_ && System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) {
|
||||
auto se = GetI18NCategory(I18NCat::SEARCH);
|
||||
System_InputBoxGetString(GetRequesterToken(), se->T("Search term"), searchFilter_, [&](const std::string &value, int) {
|
||||
System_InputBoxGetString(GetRequesterToken(), se->T("Search term"), searchFilter_, false, [&](const std::string &value, int) {
|
||||
searchFilter_ = StripSpaces(value);
|
||||
searchChanged_ = true;
|
||||
});
|
||||
|
|
|
@ -296,7 +296,7 @@ void RetroAchievementsSettingsScreen::CreateAccountTab(UI::ViewGroup *viewGroup)
|
|||
Achievements::Logout();
|
||||
return UI::EVENT_DONE;
|
||||
});
|
||||
} else if (System_GetPropertyBool(SYSPROP_HAS_LOGIN_DIALOG)) {
|
||||
} else if (false && System_GetPropertyBool(SYSPROP_HAS_LOGIN_DIALOG)) {
|
||||
viewGroup->Add(new Choice(di->T("Log in")))->OnClick.Add([=](UI::EventParams &) -> UI::EventReturn {
|
||||
std::string title = StringFromFormat("RetroAchievements: %s", di->T_cstr("Log in"));
|
||||
System_AskUsernamePassword(GetRequesterToken(), title, [](const std::string &value, int) {
|
||||
|
|
|
@ -670,7 +670,7 @@ UI::EventReturn SavedataScreen::OnSortClick(UI::EventParams &e) {
|
|||
UI::EventReturn SavedataScreen::OnSearch(UI::EventParams &e) {
|
||||
if (System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
System_InputBoxGetString(GetRequesterToken(), di->T("Filter"), searchFilter_, [](const std::string &value, int ivalue) {
|
||||
System_InputBoxGetString(GetRequesterToken(), di->T("Filter"), searchFilter_, false, [](const std::string &value, int ivalue) {
|
||||
System_PostUIMessage(UIMessage::SAVEDATA_SEARCH, value);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -280,21 +280,22 @@ std::string trimString(std::string input)
|
|||
void CtrlDisAsmView::assembleOpcode(u32 address, const std::string &defaultText)
|
||||
{
|
||||
auto memLock = Memory::Lock();
|
||||
if (Core_IsStepping() == false) {
|
||||
if (!Core_IsStepping()) {
|
||||
MessageBox(wnd,L"Cannot change code while the core is running!",L"Error",MB_OK);
|
||||
return;
|
||||
}
|
||||
std::string op;
|
||||
bool result = InputBox_GetString(MainWindow::GetHInstance(),wnd,L"Assemble opcode",defaultText, op, false);
|
||||
if (!result)
|
||||
bool result = InputBox_GetString(MainWindow::GetHInstance(), wnd, L"Assemble opcode", defaultText, op, InputBoxFlags::Default);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check if it changes registers first
|
||||
auto seperator = op.find('=');
|
||||
if (seperator != std::string::npos)
|
||||
auto separator = op.find('=');
|
||||
if (separator != std::string::npos)
|
||||
{
|
||||
std::string registerName = trimString(op.substr(0,seperator));
|
||||
std::string expression = trimString(op.substr(seperator+1));
|
||||
std::string registerName = trimString(op.substr(0,separator));
|
||||
std::string expression = trimString(op.substr(separator+1));
|
||||
|
||||
u32 value;
|
||||
if (parseExpression(expression.c_str(),debugger,value) == true)
|
||||
|
|
|
@ -18,7 +18,7 @@ void displayExpressionError(HWND hwnd)
|
|||
bool executeExpressionWindow(HWND hwnd, DebugInterface* cpu, u32& dest)
|
||||
{
|
||||
std::string expression;
|
||||
if (InputBox_GetString(GetModuleHandle(NULL), hwnd, L"Expression", "",expression) == false)
|
||||
if (InputBox_GetString(GetModuleHandle(NULL), hwnd, L"Expression", "", expression) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -30,4 +30,4 @@ bool executeExpressionWindow(HWND hwnd, DebugInterface* cpu, u32& dest)
|
|||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -397,7 +397,7 @@ void CtrlDisplayListView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
|
|||
case ID_GEDBG_GOTOADDR:
|
||||
{
|
||||
std::string expression = StringFromFormat("%08x", curAddress);
|
||||
if (!InputBox_GetString(GetModuleHandle(NULL), wnd, L"Address", expression, expression, true)) {
|
||||
if (!InputBox_GetString(GetModuleHandle(NULL), wnd, L"Address", expression, expression, InputBoxFlags::Selected)) {
|
||||
break;
|
||||
}
|
||||
uint32_t newAddress = curAddress;
|
||||
|
|
|
@ -6,31 +6,45 @@
|
|||
#include "Windows/W32Util/Misc.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
|
||||
static std::wstring textBoxContents;
|
||||
static std::wstring passwordContents;
|
||||
static std::wstring out;
|
||||
static std::wstring windowTitle;
|
||||
static bool defaultSelected;
|
||||
static std::string g_userName;
|
||||
static std::string g_passWord;
|
||||
struct DialogBoxParams {
|
||||
std::wstring textBoxContents;
|
||||
std::wstring passwordContents;
|
||||
std::wstring out;
|
||||
std::wstring windowTitle;
|
||||
bool defaultSelected;
|
||||
bool passwordMasking;
|
||||
std::string userName;
|
||||
std::string passWord;
|
||||
};
|
||||
|
||||
static DialogBoxParams g_params;
|
||||
|
||||
static INT_PTR CALLBACK InputBoxFunc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message) {
|
||||
case WM_INITDIALOG:
|
||||
SetWindowText(GetDlgItem(hDlg, IDC_INPUTBOX), textBoxContents.c_str());
|
||||
SetWindowText(hDlg, windowTitle.c_str());
|
||||
if (defaultSelected == false)
|
||||
PostMessage(GetDlgItem(hDlg,IDC_INPUTBOX),EM_SETSEL,-1,-1);
|
||||
{
|
||||
HWND hwndTextBox = GetDlgItem(hDlg, IDC_INPUTBOX);
|
||||
SetWindowText(hwndTextBox, g_params.textBoxContents.c_str());
|
||||
SetWindowText(hDlg, g_params.windowTitle.c_str());
|
||||
if (!g_params.defaultSelected) {
|
||||
PostMessage(hwndTextBox, EM_SETSEL, -1, -1);
|
||||
}
|
||||
if (g_params.passwordMasking) {
|
||||
LONG_PTR style = GetWindowLongPtr(hwndTextBox, GWL_STYLE);
|
||||
SetWindowLongPtr(hwndTextBox, GWL_STYLE, style | ES_PASSWORD);
|
||||
SendMessage(hwndTextBox, EM_SETPASSWORDCHAR, (WPARAM)'*', 0);
|
||||
}
|
||||
W32Util::CenterWindow(hDlg);
|
||||
return TRUE;
|
||||
}
|
||||
case WM_COMMAND:
|
||||
switch (wParam) {
|
||||
case IDOK:
|
||||
{
|
||||
wchar_t temp[512];
|
||||
GetWindowText(GetDlgItem(hDlg, IDC_INPUTBOX), temp, ARRAY_SIZE(temp) - 1);
|
||||
out = temp;
|
||||
GetWindowText(GetDlgItem(hDlg, IDC_INPUTBOX), temp, ARRAY_SIZE(temp));
|
||||
g_params.out = temp;
|
||||
EndDialog(hDlg, IDOK);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -45,97 +59,55 @@ static INT_PTR CALLBACK InputBoxFunc(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
}
|
||||
}
|
||||
|
||||
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::string &defaultValue, std::string &outvalue, bool selected)
|
||||
{
|
||||
defaultSelected = selected;
|
||||
if (defaultValue.size() < 255)
|
||||
textBoxContents = ConvertUTF8ToWString(defaultValue);
|
||||
else
|
||||
textBoxContents.clear();
|
||||
|
||||
if (title != NULL)
|
||||
windowTitle = title;
|
||||
else
|
||||
windowTitle.clear();
|
||||
|
||||
if (IDOK == DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc)) {
|
||||
outvalue = ConvertWStringToUTF8(out);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::string &defaultValue, std::string &outvalue)
|
||||
{
|
||||
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::string &defaultValue, std::string &outvalue, InputBoxFlags flags) {
|
||||
const wchar_t *defaultTitle = L"Input value";
|
||||
defaultSelected = true;
|
||||
|
||||
textBoxContents = ConvertUTF8ToWString(defaultValue);
|
||||
g_params.defaultSelected = flags & InputBoxFlags::Selected;
|
||||
g_params.passwordMasking = flags & InputBoxFlags::PasswordMasking;
|
||||
if (defaultValue.size() < 255) {
|
||||
g_params.textBoxContents = ConvertUTF8ToWString(defaultValue);
|
||||
} else {
|
||||
g_params.textBoxContents.clear();
|
||||
}
|
||||
|
||||
if (title && wcslen(title) <= 0)
|
||||
windowTitle = defaultTitle;
|
||||
else if (title && wcslen(title) < 255)
|
||||
windowTitle = title;
|
||||
else
|
||||
windowTitle = defaultTitle;
|
||||
if (title && wcslen(title) <= 0) {
|
||||
g_params.windowTitle = defaultTitle;
|
||||
} else if (title && wcslen(title) < 255) {
|
||||
g_params.windowTitle = title;
|
||||
} else {
|
||||
g_params.windowTitle = defaultTitle;
|
||||
}
|
||||
|
||||
if (IDOK == DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc)) {
|
||||
outvalue = ConvertWStringToUTF8(out);
|
||||
outvalue = ConvertWStringToUTF8(g_params.out);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool InputBox_GetWString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::wstring &defaultValue, std::wstring &outvalue)
|
||||
{
|
||||
const wchar_t *defaultTitle = L"Input value";
|
||||
defaultSelected = true;
|
||||
|
||||
textBoxContents = defaultValue;
|
||||
|
||||
if (title && wcslen(title) <= 0)
|
||||
windowTitle = defaultTitle;
|
||||
else if (title && wcslen(title) < 255)
|
||||
windowTitle = title;
|
||||
else
|
||||
windowTitle = defaultTitle;
|
||||
|
||||
if (IDOK == DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc)) {
|
||||
outvalue = out;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InputBox_GetHex(HINSTANCE hInst, HWND hParent, const wchar_t* title, u32 defaultvalue, u32& outvalue)
|
||||
{
|
||||
bool InputBox_GetHex(HINSTANCE hInst, HWND hParent, const wchar_t* title, u32 defaultvalue, u32 &outvalue) {
|
||||
const wchar_t *defaultTitle = L"Input value";
|
||||
wchar_t temp[256];
|
||||
wsprintf(temp, L"%08x", defaultvalue);
|
||||
textBoxContents = temp;
|
||||
g_params.textBoxContents = temp;
|
||||
|
||||
if (title && wcslen(title) <= 0)
|
||||
windowTitle = defaultTitle;
|
||||
g_params.windowTitle = defaultTitle;
|
||||
else if (title && wcslen(title) < 255)
|
||||
windowTitle = title;
|
||||
g_params.windowTitle = title;
|
||||
else
|
||||
windowTitle = defaultTitle;
|
||||
g_params.windowTitle = defaultTitle;
|
||||
|
||||
INT_PTR value = DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc);
|
||||
|
||||
if (value == IDOK)
|
||||
{
|
||||
if (swscanf(out.c_str(), L"0x%08x", &outvalue) == 1)
|
||||
if (value == IDOK) {
|
||||
if (swscanf(g_params.out.c_str(), L"0x%08x", &outvalue) == 1)
|
||||
return true;
|
||||
if (swscanf(out.c_str(), L"%08x", &outvalue) == 1)
|
||||
if (swscanf(g_params.out.c_str(), L"%08x", &outvalue) == 1)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
outvalue = 0;
|
||||
return false;
|
||||
}
|
||||
|
@ -147,7 +119,7 @@ static INT_PTR CALLBACK UserPasswordBoxFunc(HWND hDlg, UINT message, WPARAM wPar
|
|||
case WM_INITDIALOG:
|
||||
SetWindowText(GetDlgItem(hDlg, IDC_INPUTBOX), L"");
|
||||
SetWindowText(GetDlgItem(hDlg, IDC_PASSWORDBOX), L"");
|
||||
SetWindowText(hDlg, windowTitle.c_str());
|
||||
SetWindowText(hDlg, g_params.windowTitle.c_str());
|
||||
PostMessage(GetDlgItem(hDlg, IDC_INPUTBOX), EM_SETSEL, -1, -1);
|
||||
PostMessage(GetDlgItem(hDlg, IDC_PASSWORDBOX), EM_SETSEL, -1, -1);
|
||||
W32Util::CenterWindow(hDlg);
|
||||
|
@ -158,10 +130,10 @@ static INT_PTR CALLBACK UserPasswordBoxFunc(HWND hDlg, UINT message, WPARAM wPar
|
|||
case IDOK:
|
||||
{
|
||||
wchar_t temp[256];
|
||||
GetWindowText(GetDlgItem(hDlg, IDC_INPUTBOX), temp, 255);
|
||||
g_userName = ConvertWStringToUTF8(temp);
|
||||
GetWindowText(GetDlgItem(hDlg, IDC_PASSWORDBOX), temp, 255);
|
||||
g_passWord = ConvertWStringToUTF8(temp);
|
||||
GetWindowText(GetDlgItem(hDlg, IDC_INPUTBOX), temp, sizeof(temp));
|
||||
g_params.userName = ConvertWStringToUTF8(temp);
|
||||
GetWindowText(GetDlgItem(hDlg, IDC_PASSWORDBOX), temp, sizeof(temp));
|
||||
g_params.passWord = ConvertWStringToUTF8(temp);
|
||||
EndDialog(hDlg, IDOK);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -177,12 +149,12 @@ static INT_PTR CALLBACK UserPasswordBoxFunc(HWND hDlg, UINT message, WPARAM wPar
|
|||
}
|
||||
|
||||
bool UserPasswordBox_GetStrings(HINSTANCE hInst, HWND hParent, const wchar_t *title, std::string *username, std::string *password) {
|
||||
windowTitle = title;
|
||||
g_params.windowTitle = title;
|
||||
INT_PTR value = DialogBox(hInst, (LPCWSTR)IDD_USERPASSWORDBOX, hParent, UserPasswordBoxFunc);
|
||||
|
||||
if (value == IDOK) {
|
||||
*username = g_userName;
|
||||
*password = g_passWord;
|
||||
*username = g_params.userName;
|
||||
*password = g_params.passWord;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -2,11 +2,17 @@
|
|||
|
||||
#include <string>
|
||||
#include "Common/CommonWindows.h"
|
||||
#include "Common/Common.h"
|
||||
|
||||
enum class InputBoxFlags {
|
||||
Default = 0,
|
||||
Selected = 1,
|
||||
PasswordMasking = 2,
|
||||
};
|
||||
ENUM_CLASS_BITOPS(InputBoxFlags);
|
||||
|
||||
// All I/O is in UTF-8
|
||||
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::string &defaultvalue, std::string &outvalue, bool selected);
|
||||
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::string &defaultvalue, std::string &outvalue);
|
||||
bool InputBox_GetWString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::wstring &defaultvalue, std::wstring &outvalue);
|
||||
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::string &defaultvalue, std::string &outvalue, InputBoxFlags flags = InputBoxFlags::Default);
|
||||
bool InputBox_GetHex(HINSTANCE hInst, HWND hParent, const wchar_t *title, u32 defaultvalue, u32 &outvalue);
|
||||
|
||||
bool UserPasswordBox_GetStrings(HINSTANCE hInst, HWND hParent, const wchar_t *title, std::string *username, std::string *password);
|
||||
|
|
|
@ -540,7 +540,14 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
|||
case SystemRequestType::INPUT_TEXT_MODAL:
|
||||
std::thread([=] {
|
||||
std::string out;
|
||||
if (InputBox_GetString(MainWindow::GetHInstance(), MainWindow::GetHWND(), ConvertUTF8ToWString(param1).c_str(), param2, out)) {
|
||||
InputBoxFlags flags{};
|
||||
if (param3) {
|
||||
flags |= InputBoxFlags::PasswordMasking;
|
||||
}
|
||||
if (!param2.empty()) {
|
||||
flags |= InputBoxFlags::Selected;
|
||||
}
|
||||
if (InputBox_GetString(MainWindow::GetHInstance(), MainWindow::GetHWND(), ConvertUTF8ToWString(param1).c_str(), param2, out, flags)) {
|
||||
g_requestManager.PostSystemSuccess(requestId, out.c_str());
|
||||
} else {
|
||||
g_requestManager.PostSystemFailure(requestId);
|
||||
|
|
|
@ -1120,6 +1120,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
|||
PushCommand("copy_to_clipboard", param1);
|
||||
return true;
|
||||
case SystemRequestType::INPUT_TEXT_MODAL:
|
||||
case SystemRequestType::INPUT_PASSWORD_MODAL:
|
||||
{
|
||||
std::string serialized = StringFromFormat("%d:@:%s:@:%s", requestId, param1.c_str(), param2.c_str());
|
||||
PushCommand("inputbox", serialized.c_str());
|
||||
|
|
Loading…
Add table
Reference in a new issue