mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Add InputBox as a platform-specific system function instead of a host function. Enable it on all Qt platforms. Add Set Nickname to mobile Qt.
This commit is contained in:
parent
08a0709091
commit
a0c5af288c
10 changed files with 34 additions and 71 deletions
|
@ -28,7 +28,7 @@
|
|||
#include "GPU/GPUState.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Core/Host.h"
|
||||
#include "base/NativeApp.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
|
@ -803,7 +803,7 @@ int PSPOskDialog::NativeKeyboard()
|
|||
if(defaultText.empty())
|
||||
defaultText.assign(L"VALUE");
|
||||
|
||||
if(host->InputBoxGetWString(titleText.c_str(), defaultText, inputChars))
|
||||
if(System_InputBoxGetWString(titleText.c_str(), defaultText, inputChars))
|
||||
{
|
||||
u32 maxLength = FieldMaxLength();
|
||||
if (inputChars.length() > maxLength)
|
||||
|
@ -851,8 +851,8 @@ int PSPOskDialog::Update(int animSpeed)
|
|||
// TODO: Add your platforms here when you have a NativeKeyboard func.
|
||||
|
||||
#ifdef _WIN32
|
||||
// Fall back to the OSK/continue normally if we're in fullscreen. The dialog box
|
||||
// doesn't work right if in fullscreen.
|
||||
// Windows: Fall back to the OSK/continue normally if we're in fullscreen.
|
||||
// The dialog box doesn't work right if in fullscreen.
|
||||
if(g_Config.bBypassOSKWithKeyboard && !g_Config.bFullScreen)
|
||||
return NativeKeyboard();
|
||||
#endif
|
||||
|
|
|
@ -75,12 +75,6 @@ public:
|
|||
virtual bool CanCreateShortcut() {return false;}
|
||||
virtual bool CreateDesktopShortcut(std::string argumentPath, std::string title) {return false;}
|
||||
|
||||
#if defined(_WIN32) || (defined(USING_QT_UI) && !defined(USING_GLES2))
|
||||
// Implement this on your platform to grab text input from the user for whatever purpose.
|
||||
virtual bool InputBoxGetString(char *title, const char *defaultValue, char *outValue, size_t outlength) { return false; }
|
||||
virtual bool InputBoxGetWString(const wchar_t *title, const std::wstring &defaultvalue, std::wstring &outvalue) { return false; }
|
||||
#endif
|
||||
|
||||
// Used for headless.
|
||||
virtual bool ShouldSkipUI() { return false; }
|
||||
virtual void SendDebugOutput(const std::string &output) {}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// This file is Qt Desktop's equivalent of NativeApp.cpp
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QInputDialog>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
|
@ -243,31 +242,6 @@ void QtHost::NextGPUStep()
|
|||
m_hGPUStepEvent.notify_one();
|
||||
}
|
||||
|
||||
bool QtHost::InputBoxGetString(char *title, const char *defaultValue, char *outValue, size_t outLength)
|
||||
{
|
||||
bool ok;
|
||||
QString text = QInputDialog::getText(mainWindow, title, title, QLineEdit::Normal, defaultValue, &ok);
|
||||
if (ok && !text.isEmpty()) {
|
||||
strcpy(outValue, text.toStdString().c_str());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool QtHost::InputBoxGetWString(const wchar_t *title, const std::wstring &defaultValue, std::wstring &outValue)
|
||||
{
|
||||
bool ok;
|
||||
QString text = QInputDialog::getText(mainWindow, QString::fromStdWString(title), QString::fromStdWString(title), QLineEdit::Normal, QString::fromStdWString(defaultValue), &ok);
|
||||
if (ok && !text.isEmpty()) {
|
||||
outValue = text.toStdWString();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void NativeInit(int argc, const char *argv[], const char *savegame_directory, const char *external_directory, const char *installID)
|
||||
{
|
||||
isMessagePending = false;
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
// Globals
|
||||
static PMixer *g_mixer;
|
||||
static QString fileToStart;
|
||||
static QtEmuGL* glWindow;
|
||||
|
||||
class QtHost : public QObject, public Host
|
||||
{
|
||||
|
@ -57,8 +56,6 @@ public:
|
|||
void SendGPUStart();
|
||||
void SetGPUStep(bool value, int flag = 0, u32 data = 0);
|
||||
void NextGPUStep();
|
||||
bool InputBoxGetString(char *title, const char *defaultValue, char *outValue, size_t outlength);
|
||||
bool InputBoxGetWString(const wchar_t *title, const std::wstring &defaultValue, std::wstring &outValue);
|
||||
|
||||
signals:
|
||||
void BootDoneSignal();
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
extern bool g_TakeScreenshot;
|
||||
|
||||
class QtEmuGL;
|
||||
class MenuAction;
|
||||
class MenuTree;
|
||||
|
||||
|
@ -135,7 +134,6 @@ private:
|
|||
QTranslator translator;
|
||||
QString currentLanguage;
|
||||
|
||||
MainUI *emugl;
|
||||
CoreState nextState;
|
||||
InputState input_state;
|
||||
GlobalUIState lastUIState;
|
||||
|
|
|
@ -121,7 +121,7 @@ void GameSettingsScreen::CreateViews() {
|
|||
postProcChoice_->OnClick.Handle(this, &GameSettingsScreen::OnPostProcShader);
|
||||
postProcChoice_->SetEnabled(g_Config.iRenderingMode != 0);
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) || defined(USING_QT_UI)
|
||||
graphicsSettings->Add(new CheckBox(&g_Config.bFullScreen, gs->T("FullScreen")))->OnClick.Handle(this, &GameSettingsScreen::OnFullscreenChange);
|
||||
#endif
|
||||
graphicsSettings->Add(new CheckBox(&g_Config.bStretchToDisplay, gs->T("Stretch to Display")));
|
||||
|
@ -293,9 +293,11 @@ void GameSettingsScreen::CreateViews() {
|
|||
systemSettings->Add(new ItemHeader(s->T("PSP Settings")));
|
||||
// TODO: Come up with a way to display a keyboard for mobile users,
|
||||
// so until then, this is Windows/Desktop only.
|
||||
#if defined(_WIN32) || (defined(USING_QT_UI) && !defined(USING_GLES2))
|
||||
#if defined(_WIN32) || defined(USING_QT_UI)
|
||||
systemSettings->Add(new Choice(s->T("Change Nickname")))->OnClick.Handle(this, &GameSettingsScreen::OnChangeNickname);
|
||||
// Screenshot functionality is not yet available on non-Windows
|
||||
#endif
|
||||
#if defined(_WIN32) || (defined(USING_QT_UI) && !defined(USING_GLES2))
|
||||
// Screenshot functionality is not yet available on non-Windows/non-Qt
|
||||
systemSettings->Add(new CheckBox(&g_Config.bScreenshotsAsPNG, s->T("Screenshots as PNG")));
|
||||
#endif
|
||||
systemSettings->Add(new CheckBox(&g_Config.bDayLightSavings, s->T("Day Light Saving")));
|
||||
|
@ -432,13 +434,13 @@ void GlobalSettingsScreen::CreateViews() {
|
|||
}*/
|
||||
|
||||
UI::EventReturn GameSettingsScreen::OnChangeNickname(UI::EventParams &e) {
|
||||
#if defined(_WIN32) || (defined(USING_QT_UI) && !defined(USING_GLES2))
|
||||
#if defined(_WIN32) || defined(USING_QT_UI)
|
||||
const size_t name_len = 256;
|
||||
|
||||
char name[name_len];
|
||||
memset(name, 0, sizeof(name));
|
||||
|
||||
if (host->InputBoxGetString("Enter a new PSP nickname", g_Config.sNickName.c_str(), name, name_len)) {
|
||||
if (System_InputBoxGetString("Enter a new PSP nickname", g_Config.sNickName.c_str(), name, name_len)) {
|
||||
g_Config.sNickName = name;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "Windows/Debugger/DebuggerShared.h"
|
||||
#include "Windows/Debugger/Debugger_Disasm.h"
|
||||
#include "Windows/Debugger/Debugger_MemoryDlg.h"
|
||||
#include "Windows/InputBox.h"
|
||||
|
||||
#include "Windows/DinputDevice.h"
|
||||
#include "Windows/XinputDevice.h"
|
||||
|
@ -277,27 +276,6 @@ void WindowsHost::UpdateConsolePosition()
|
|||
}
|
||||
}
|
||||
|
||||
bool WindowsHost::InputBoxGetString(char *title, const char *defaultValue, char *outValue, size_t outLength)
|
||||
{
|
||||
std::string out;
|
||||
if (InputBox_GetString(MainWindow::GetHInstance(), MainWindow::GetHWND(), ConvertUTF8ToWString(title).c_str(), defaultValue, out)) {
|
||||
strcpy(outValue, out.c_str());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool WindowsHost::InputBoxGetWString(const wchar_t *title, const std::wstring &defaultvalue, std::wstring &outvalue)
|
||||
{
|
||||
if (InputBox_GetWString(MainWindow::GetHInstance(), MainWindow::GetHWND(), title, defaultvalue, outvalue)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/aa969393.aspx
|
||||
HRESULT CreateLink(LPCWSTR lpszPathObj, LPCWSTR lpszArguments, LPCWSTR lpszPathLink, LPCWSTR lpszDesc) {
|
||||
HRESULT hres;
|
||||
|
|
|
@ -67,8 +67,6 @@ public:
|
|||
|
||||
virtual void GoFullscreen(bool);
|
||||
|
||||
bool InputBoxGetString(char *title, const char *defaultValue, char *outValue, size_t outlength);
|
||||
bool InputBoxGetWString(const wchar_t *title, const std::wstring &defaultvalue, std::wstring &outvalue);
|
||||
std::shared_ptr<KeyboardDevice> keyboard;
|
||||
|
||||
private:
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "Windows/Debugger/CtrlDisAsmView.h"
|
||||
#include "Windows/Debugger/CtrlMemView.h"
|
||||
#include "Windows/Debugger/CtrlRegisterList.h"
|
||||
#include "Windows/InputBox.h"
|
||||
|
||||
#include "Windows/WindowsHost.h"
|
||||
#include "Windows/main.h"
|
||||
|
@ -179,6 +180,27 @@ void EnableCrashingOnCrashes()
|
|||
}
|
||||
}
|
||||
|
||||
bool System_InputBoxGetString(char *title, const char *defaultValue, char *outValue, size_t outLength)
|
||||
{
|
||||
std::string out;
|
||||
if (InputBox_GetString(MainWindow::GetHInstance(), MainWindow::GetHWND(), ConvertUTF8ToWString(title).c_str(), defaultValue, out)) {
|
||||
strcpy(outValue, out.c_str());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool System_InputBoxGetWString(const wchar_t *title, const std::wstring &defaultvalue, std::wstring &outvalue)
|
||||
{
|
||||
if (InputBox_GetWString(MainWindow::GetHInstance(), MainWindow::GetHWND(), title, defaultvalue, outvalue)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
|
||||
{
|
||||
EnableCrashingOnCrashes();
|
||||
|
|
2
native
2
native
|
@ -1 +1 @@
|
|||
Subproject commit 69806cdd3befb9ad3a61430a260c90940dff99ff
|
||||
Subproject commit 9e5df6028ad08d796a4656a30fa532058aa9466d
|
Loading…
Add table
Reference in a new issue