From 32a599c957a4ee1ee4e3baa1e9954d6582d9991b Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Fri, 29 Mar 2013 19:32:20 +0100 Subject: [PATCH] Win32 gl ui: Fixes and tweaks. --- Core/Core.cpp | 8 ++++++- Core/System.cpp | 1 + Core/System.h | 3 ++- Windows/WndMainWindow.cpp | 28 ++++++++++++++--------- Windows/ppsspp.rc | 21 +---------------- Windows/resource.h | 45 ------------------------------------- android/jni/EmuScreen.cpp | 3 +++ android/jni/MenuScreens.cpp | 35 ++++++++++++++++++++++++----- android/jni/MenuScreens.h | 1 + 9 files changed, 62 insertions(+), 83 deletions(-) diff --git a/Core/Core.cpp b/Core/Core.cpp index 6fa48eda87..b0a80defda 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -111,14 +111,20 @@ void UpdateScreenScale() { void Core_RunLoop() { while (!coreState) { + time_update(); UpdateScreenScale(); { lock_guard guard(input_state.lock); + if (GetAsyncKeyState(VK_ESCAPE)) { + input_state.pad_buttons |= PAD_BUTTON_MENU; + } else { + input_state.pad_buttons &= ~PAD_BUTTON_MENU; + } NativeUpdate(input_state); } NativeRender(); // Simple throttling to not burn the GPU in the menu. - if (!PSP_CoreParameter().fileToStart.size()) + if (globalUIState != UISTATE_INGAME) Sleep(15); GL_SwapBuffers(); } diff --git a/Core/System.cpp b/Core/System.cpp index 7da0b27381..d72f369d25 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -49,6 +49,7 @@ MetaFileSystem pspFileSystem; ParamSFOData g_paramSFO; +GlobalUIState globalUIState; static CoreParameter coreParameter; static PSPMixer *mixer; diff --git a/Core/System.h b/Core/System.h index 59982a5261..75079f2934 100644 --- a/Core/System.h +++ b/Core/System.h @@ -28,13 +28,14 @@ extern ParamSFOData g_paramSFO; // To synchronize the two UIs, we need to know which state we're in. -enum UIState { +enum GlobalUIState { UISTATE_MENU, UISTATE_PAUSEMENU, UISTATE_INGAME, }; +extern GlobalUIState globalUIState; bool PSP_Init(const CoreParameter &coreParam, std::string *error_string); bool PSP_IsInited(); diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 6690375bd5..1f42dc8779 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -218,7 +218,7 @@ namespace MainWindow filter[i] = '\0'; } - if (W32Util::BrowseForFileName(true, GetHWND(), "Load File",defaultPath.size() ? defaultPath.c_str() : 0, filter.c_str(),"*.pbp;*.elf;*.iso;*.cso;",fn)) + if (W32Util::BrowseForFileName(true, GetHWND(), "Load File", defaultPath.size() ? defaultPath.c_str() : 0, filter.c_str(),"*.pbp;*.elf;*.iso;*.cso;",fn)) { // decode the filename with fullpath std::string fullpath = fn; @@ -229,7 +229,7 @@ namespace MainWindow _splitpath(fullpath.c_str(), drive, dir, fname, ext); std::string executable = std::string(drive) + std::string(dir) + std::string(fname) + std::string(ext); - NativeMessageReceived("run", executable.c_str()); + NativeMessageReceived("boot", executable.c_str()); } } @@ -243,10 +243,10 @@ namespace MainWindow break; case WM_SIZE: break; - + case WM_ERASEBKGND: return DefWindowProc(hWnd, message, wParam, lParam); - + case WM_LBUTTONDOWN: { lock_guard guard(input_state.lock); @@ -274,7 +274,6 @@ namespace MainWindow } break; - case WM_PAINT: return DefWindowProc(hWnd, message, wParam, lParam); default: @@ -332,6 +331,7 @@ namespace MainWindow break; case ID_EMULATION_RUN: + NativeMessageReceived("run", ""); for (int i=0; iGetDlgHandle(), WM_COMMAND, IDC_STOP, 0); @@ -695,6 +695,9 @@ namespace MainWindow PostMessage(hwndMain, WM_COMMAND, ID_EMULATION_RUN, 0); UpdateMenus(); break; + case WM_MENUSELECT: + UpdateMenus(); + break; default: return DefWindowProc(hWnd, message, wParam, lParam); @@ -730,16 +733,21 @@ namespace MainWindow CHECKITEM(ID_OPTIONS_FRAMESKIP, g_Config.iFrameSkip != 0); CHECKITEM(ID_OPTIONS_USEMEDIAENGINE, g_Config.bUseMediaEngine); - UINT enable = !Core_IsStepping() ? MF_GRAYED : MF_ENABLED; + + bool paused = !Core_IsStepping(); + + UINT enable = paused ? MF_GRAYED : MF_ENABLED; bool pspRunning = PSP_CoreParameter().fileToStart.size() != 0; - EnableMenuItem(menu,ID_EMULATION_RUN, pspRunning ? enable : MF_GRAYED); - EnableMenuItem(menu,ID_EMULATION_PAUSE, pspRunning ? !enable : MF_GRAYED); - EnableMenuItem(menu,ID_EMULATION_RESET, FALSE); //pspRunning ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(menu,ID_EMULATION_RUN, globalUIState == UISTATE_PAUSEMENU ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(menu,ID_EMULATION_PAUSE, globalUIState == UISTATE_INGAME ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(menu,ID_EMULATION_STOP, globalUIState == UISTATE_INGAME ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(menu,ID_EMULATION_RESET, MF_GRAYED); //pspRunning ? MF_ENABLED : MF_GRAYED); - enable = pspRunning ? MF_GRAYED : MF_ENABLED; + enable = globalUIState == UISTATE_MENU ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu,ID_FILE_LOAD,enable); + EnableMenuItem(menu,ID_FILE_LOAD_MEMSTICK,enable); EnableMenuItem(menu,ID_FILE_SAVESTATEFILE,!enable); EnableMenuItem(menu,ID_FILE_LOADSTATEFILE,!enable); EnableMenuItem(menu,ID_FILE_QUICKSAVESTATE,!enable); diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 687eb8729c..0a3a3736c6 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -413,7 +413,7 @@ BEGIN VALUE "FileDescription", "PPSSPP" VALUE "FileVersion", "1, 0, 5, 0" VALUE "InternalName", "s" - VALUE "LegalCopyright", "Copyright (C) 2006-2012 by Henrik Rydgård" + VALUE "LegalCopyright", "Copyright (C) 2006-2013 by Henrik Rydgård" VALUE "LegalTrademarks", "All product names are trademarks of their respective owners." VALUE "OriginalFilename", "PPSSPP.exe" VALUE "ProductName", "PPSSPP" @@ -426,23 +426,4 @@ BEGIN END END - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_GAMELISTPATH "Path" - IDS_UNIMPLEMENTED "Unimplemented" -END - -STRINGTABLE -BEGIN - IDS_GAMELISTGENRE "Genre" - IDS_APPNAME "Potemkin" - IDS_GAMELISTTYPE "Type" -END - #endif // Neutral (Default) resources diff --git a/Windows/resource.h b/Windows/resource.h index d5eb2a3165..57ded8dd45 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -2,31 +2,6 @@ // Microsoft Visual C++ generated include file. // Used by ppsspp.rc // -#define IDS_DLGSETTINGSGENERAL 5 -#define IDS_DLGSETTINGSGCMPATHS 6 -#define IDS_DLGSETTINGSPLUGINS 7 -#define IDS_ERRORNOGAMESFOUND 9 -#define IDS_GAMELISTBANNER 10 -#define IDS_GAMELISTCOMPANY 11 -#define IDS_GAMELISTTITLE 12 -#define IDS_GAMELISTNOTES 13 -#define IDS_GAMELISTID 14 -#define IDS_GAMELISTSIZE 15 -#define IDS_GAMELISTPATH 16 -#define IDS_TIPS_LOADDOL 17 -#define IDS_TIPS_LOADELF 18 -#define IDS_TIPS_LOADGCM 19 -#define IDS_TIPS_REFRESHGAMELIST 20 -#define IDS_TIPS_RUN 21 -#define IDS_TIPS_PAUSE 22 -#define IDS_TIPS_STOP 23 -#define IDS_TIPS_FRAMEBUFFER 24 -#define IDS_TIPS_HELP 25 -#define IDS_TIPS_CONFIGUREGFX 26 -#define IDS_TIPS_CONFIGUREAUDIO 27 -#define IDS_TIPS_CONFIGUREPAD 28 -#define IDS_TIPS_CONFIGUREDVD 29 -#define IDS_TIPS_SETTINGS 30 #define IDS_UNIMPLEMENTED 31 #define IDS_GAMELISTGENRE 32 #define IDS_APPNAME 33 @@ -51,8 +26,6 @@ #define ID_DEBUG_REGISTERS 120 #define ID_DEBUG_LOG 121 #define ID_DEBUG_BREAKPOINTS 122 -#define ID_FILE_LOAD_BIN 123 -#define ID_FILE_LOAD_ISO 125 #define ID_FILE_LOADSTATEFILE 126 #define ID_FILE_SAVESTATEFILE 127 #define ID_EMULATION_RESET 130 @@ -68,21 +41,14 @@ #define IDD_MEMORY 160 #define ID_DEBUG_MEMORYVIEW 161 #define IDR_ACCELS 162 -#define ID_FILE_LOAD_ELF 165 #define ID_FILE_BOOTDVD 166 #define ID_OPTIONS_ENABLEFRAMEBUFFER 167 #define IDR_POPUPMENUS 169 -#define ID_CHEATS_ACTIONREPLAYCODES 171 #define ID_DEBUG_MEMORYCHECKS 173 #define ID_DVD_INSERTISO 175 -#define ID_FILE_LOAD_GCM 175 #define ID_DVD_EJECT 176 #define ID_DVD_ 177 #define ID_DVD_OPENLID 178 -#define ID_PLUGINS_CONFIGUREGFXPLUGIN 179 -#define ID_PLUGINS_CONFIGUREAUDIOPLUGIN 180 -#define ID_PLUGINS_INPUTPLUGINSETTINGS 182 -#define ID_PLUGINS_CONFIGUREPADPLUGIN 182 #define ID_DVD_BOOT 183 #define ID_DVD_HLEBOOT 184 #define ID_Menu185 185 @@ -120,7 +86,6 @@ #define IDC_STEP 1009 #define IDC_VERSION 1010 #define IDC_UP 1014 -#define IDC_DIRTREE 1014 #define IDC_DOWN 1015 #define IDC_BREAKPOINTS_LIST 1015 #define IDC_ADD 1016 @@ -157,25 +122,16 @@ #define IDC_BROWSE 1159 #define IDC_SHOWVFPU 1161 #define IDC_LISTCONTROLS 1162 -#define ID_FILE_BOOTISO 40001 #define ID_FILE_EXIT 40002 #define ID_CONFIG_SELECT_PLUGINS 40003 #define ID_BUTTON40013 40013 #define ID_BUTTON40014 40014 #define ID_BUTTON40015 40015 -#define ID_FILE_BOOTBIOS 40018 -#define ID_COMPARE_STARTSERVER 40019 -#define ID_COMPARE_CONNECTASCLIENT 40020 -#define ID_CPU_COMPARE_CLOSECONNECTION 40022 #define ID_OPTIONS_EMULATESYSCALL 40023 #define ID_DEBUG_LOCATESYMBOLS 40025 #define ID_HELP_TOPICS 40026 -#define ID_PLUGINS_DVDPLUGINSETTINGS 40027 -#define ID_PLUGINS_CONFIGUREDVDPLUGIN 40027 #define ID_DEBUG_SAVEMAPFILE 40028 -#define ID_DEBUG_ 40029 #define ID_BUTTON40030 40030 -#define ID_BUTTON40031 40031 #define ID_BUTTON40032 40032 #define ID_BUTTON40033 40033 #define ID_BUTTON40034 40034 @@ -199,7 +155,6 @@ #define ID_DISASM_COPYINSTRUCTIONDISASM 40059 #define ID_DISASM_COPYINSTRUCTIONHEX 40060 #define ID_OPTIONS_CONFIGURATIONWIZARD 40064 -#define ID_TOOLS_GCMSHRINKER 40065 #define ID_BUTTON40066 40066 #define ID_GAMELIST_SHRINK 40067 #define ID_GAMELIST_PROPERTIES 40068 diff --git a/android/jni/EmuScreen.cpp b/android/jni/EmuScreen.cpp index 8ce3c094bb..a1cea502d7 100644 --- a/android/jni/EmuScreen.cpp +++ b/android/jni/EmuScreen.cpp @@ -58,8 +58,10 @@ EmuScreen::EmuScreen(const std::string &filename) : invalid_(true) coreParam.enableDebugging = false; coreParam.printfEmuLog = false; coreParam.headLess = false; +#ifndef _WIN32 if (g_Config.iWindowZoom < 1 || g_Config.iWindowZoom > 2) g_Config.iWindowZoom = 1; +#endif coreParam.renderWidth = 480 * g_Config.iWindowZoom; coreParam.renderHeight = 272 * g_Config.iWindowZoom; coreParam.outputWidth = dp_xres; @@ -126,6 +128,7 @@ inline float clamp1(float x) { void EmuScreen::update(InputState &input) { + globalUIState = UISTATE_INGAME; if (errorMessage_.size()) { screenManager()->push(new ErrorScreen( "Error loading file", diff --git a/android/jni/MenuScreens.cpp b/android/jni/MenuScreens.cpp index 5b8773cdbd..c5a23bd2fa 100644 --- a/android/jni/MenuScreens.cpp +++ b/android/jni/MenuScreens.cpp @@ -19,6 +19,12 @@ #include #include +#ifdef _WIN32 +namespace MainWindow { + void BrowseAndBoot(std::string defaultPath); +} +#endif + #ifdef _MSC_VER #define snprintf _snprintf #endif @@ -39,12 +45,13 @@ #include "UIShader.h" #include "Common/StringUtil.h" -#include "../../GPU/ge_constants.h" -#include "../../GPU/GPUState.h" -#include "../../GPU/GPUInterface.h" -#include "../../Core/Config.h" -#include "../../Core/CoreParameter.h" -#include "../../Core/SaveState.h" +#include "Core/System.h" +#include "GPU/ge_constants.h" +#include "GPU/GPUState.h" +#include "GPU/GPUInterface.h" +#include "Core/Config.h" +#include "Core/CoreParameter.h" +#include "Core/SaveState.h" #include "MenuScreens.h" #include "EmuScreen.h" @@ -157,9 +164,16 @@ void LogoScreen::render() { // ================== void MenuScreen::update(InputState &input_state) { + globalUIState = UISTATE_MENU; frames_++; } +void MenuScreen::sendMessage(const char *message, const char *value) { + if (!strcmp(message, "boot")) { + screenManager()->switchScreen(new EmuScreen(value)); + } +} + void MenuScreen::render() { UIShader_Prepare(); UIBegin(); @@ -189,6 +203,8 @@ void MenuScreen::render() { g_Config.Save(); screenManager()->switchScreen(new EmuScreen(fileName.toStdString())); } +#elif _WIN32 + MainWindow::BrowseAndBoot(""); #else FileSelectScreenOptions options; options.allowChooseDirectory = true; @@ -203,10 +219,12 @@ void MenuScreen::render() { UIReset(); } +#ifndef _WIN32 if (UIButton(GEN_ID, vlinear, w, "Settings", ALIGN_RIGHT)) { screenManager()->push(new SettingsScreen(), 0); UIReset(); } +#endif if (UIButton(GEN_ID, vlinear, w, "Credits", ALIGN_RIGHT)) { screenManager()->switchScreen(new CreditsScreen()); @@ -245,6 +263,7 @@ void MenuScreen::render() { void PauseScreen::update(InputState &input) { + globalUIState = UISTATE_PAUSEMENU; if (input.pad_buttons_down & PAD_BUTTON_BACK) { screenManager()->finishDialog(this, DR_CANCEL); } @@ -306,9 +325,11 @@ void PauseScreen::render() { if (UIButton(GEN_ID, vlinear, LARGE_BUTTON_WIDTH, "Continue", ALIGN_RIGHT)) { screenManager()->finishDialog(this, DR_CANCEL); } +#ifndef _WIN32 if (UIButton(GEN_ID, vlinear, LARGE_BUTTON_WIDTH, "Settings", ALIGN_RIGHT)) { screenManager()->push(new SettingsScreen(), 0); } +#endif if (UIButton(GEN_ID, vlinear, LARGE_BUTTON_WIDTH, "Return to Menu", ALIGN_RIGHT)) { screenManager()->finishDialog(this, DR_OK); } @@ -327,6 +348,7 @@ void PauseScreen::render() { } void SettingsScreen::update(InputState &input) { + globalUIState = UISTATE_MENU; if (input.pad_buttons_down & PAD_BUTTON_BACK) { g_Config.Save(); screenManager()->finishDialog(this, DR_OK); @@ -527,6 +549,7 @@ void FileSelectScreen::render() { } void CreditsScreen::update(InputState &input_state) { + globalUIState = UISTATE_MENU; if (input_state.pad_buttons_down & PAD_BUTTON_BACK) { screenManager()->switchScreen(new MenuScreen()); } diff --git a/android/jni/MenuScreens.h b/android/jni/MenuScreens.h index b9c20ba261..9504925bd1 100644 --- a/android/jni/MenuScreens.h +++ b/android/jni/MenuScreens.h @@ -45,6 +45,7 @@ public: MenuScreen() : frames_(0) {} void update(InputState &input); void render(); + void sendMessage(const char *message, const char *value); private: int frames_;