Merge pull request #8778 from unknownbrackets/coupling

Remove some dependency coupling
This commit is contained in:
Henrik Rydgård 2016-05-28 12:25:01 +02:00
commit 63e7304467
39 changed files with 170 additions and 137 deletions

View File

@ -1676,7 +1676,6 @@ set(LinkCommon ${CoreLibName} ${CMAKE_THREAD_LIBS_INIT} ${nativeExtraLibs})
if(HEADLESS)
add_executable(PPSSPPHeadless
headless/Headless.cpp
UI/OnScreenDisplay.cpp
headless/StubHost.h
headless/Compare.cpp
headless/Compare.h)
@ -1695,7 +1694,6 @@ if(UNITTEST)
unittest/JitHarness.cpp
Core/MIPS/ARM/ArmRegCache.cpp
Core/MIPS/ARM/ArmRegCacheFPU.cpp
UI/OnScreenDisplay.cpp
)
target_link_libraries(unitTest
${COCOA_LIBRARY} ${LinkCommon} Common)

View File

@ -57,8 +57,6 @@ static double lastActivity = 0.0;
static double lastKeepAwake = 0.0;
static GraphicsContext *graphicsContext;
extern InputState input_state;
void Core_SetGraphicsContext(GraphicsContext *ctx) {
graphicsContext = ctx;
}
@ -152,16 +150,16 @@ bool UpdateScreenScale(int width, int height, bool smallWindow) {
return false;
}
void UpdateRunLoop() {
void UpdateRunLoop(InputState *input_state) {
if (windowHidden && g_Config.bPauseWhenMinimized) {
sleep_ms(16);
return;
}
NativeUpdate(input_state);
NativeUpdate(*input_state);
{
lock_guard guard(input_state.lock);
EndInputState(&input_state);
lock_guard guard(input_state->lock);
EndInputState(input_state);
}
if (GetUIState() != UISTATE_EXIT) {
@ -169,13 +167,13 @@ void UpdateRunLoop() {
}
}
void Core_RunLoop(GraphicsContext *ctx) {
void Core_RunLoop(GraphicsContext *ctx, InputState *input_state) {
graphicsContext = ctx;
while ((GetUIState() != UISTATE_INGAME || !PSP_IsInited()) && GetUIState() != UISTATE_EXIT) {
time_update();
#if defined(USING_WIN_UI)
double startTime = time_now_d();
UpdateRunLoop();
UpdateRunLoop(input_state);
// Simple throttling to not burn the GPU in the menu.
time_update();
@ -187,13 +185,13 @@ void Core_RunLoop(GraphicsContext *ctx) {
ctx->SwapBuffers();
}
#else
UpdateRunLoop();
UpdateRunLoop(input_state);
#endif
}
while (!coreState && GetUIState() == UISTATE_INGAME) {
time_update();
UpdateRunLoop();
UpdateRunLoop(input_state);
#if defined(USING_WIN_UI)
if (!windowHidden && !Core_IsStepping()) {
ctx->SwapBuffers();
@ -234,7 +232,7 @@ static inline void CoreStateProcessed() {
}
// Some platforms, like Android, do not call this function but handle things on their own.
void Core_Run(GraphicsContext *ctx)
void Core_Run(GraphicsContext *ctx, InputState *input_state)
{
#if defined(_DEBUG)
host->UpdateDisassembly();
@ -249,7 +247,7 @@ reswitch:
if (GetUIState() == UISTATE_EXIT) {
return;
}
Core_RunLoop(ctx);
Core_RunLoop(ctx, input_state);
#if defined(USING_QT_UI) && !defined(MOBILE_DEVICE)
return;
#else
@ -261,7 +259,7 @@ reswitch:
{
case CORE_RUNNING:
// enter a fast runloop
Core_RunLoop(ctx);
Core_RunLoop(ctx, input_state);
break;
// We should never get here on Android.

View File

@ -21,10 +21,11 @@
#include "Core/CoreParameter.h"
class GraphicsContext;
struct InputState;
// called from emu thread
void UpdateRunLoop();
void Core_Run(GraphicsContext *ctx);
void UpdateRunLoop(GraphicsContext *input_state);
void Core_Run(GraphicsContext *ctx, InputState *input_state);
void Core_Stop();
void Core_ErrorPause();
// For platforms that don't call Core_Run

View File

@ -1,5 +1,4 @@
#include "i18n/i18n.h"
#include "UI/OnScreenDisplay.h"
#include "Common/StringUtils.h"
#include "Common/ChunkFile.h"
#include "Common/FileUtil.h"
@ -7,6 +6,7 @@
#include "Core/CoreParameter.h"
#include "Core/CwCheat.h"
#include "Core/Config.h"
#include "Core/Host.h"
#include "Core/MIPS/MIPS.h"
#include "Core/ELF/ParamSFO.h"
#include "Core/System.h"
@ -50,7 +50,7 @@ static void __CheatStart() {
}
if (!File::Exists(activeCheatFile)) {
I18NCategory *err = GetI18NCategory("Error");
osm.Show(err->T("Unable to create cheat file, disk may be full"));
host->NotifyUserMessage(err->T("Unable to create cheat file, disk may be full"));
}
}

View File

@ -19,6 +19,7 @@
#include "base/logging.h"
#include "Common/ChunkFile.h"
#include "Core/Config.h"
#include "Core/Host.h"
#include "Core/Reporting.h"
#include "Core/System.h"
#include "Core/Dialog/SavedataParam.h"
@ -30,7 +31,6 @@
#include "Core/ELF/ParamSFO.h"
#include "Core/HW/MemoryStick.h"
#include "Core/Util/PPGeDraw.h"
#include "UI/OnScreenDisplay.h"
#include "image/png_load.h"
@ -372,7 +372,7 @@ bool SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &save
if (!pspFileSystem.GetFileInfo(dirPath).exists) {
if (!pspFileSystem.MkDir(dirPath)) {
I18NCategory *err = GetI18NCategory("Error");
osm.Show(err->T("Unable to write savedata, disk may be full"));
host->NotifyUserMessage(err->T("Unable to write savedata, disk may be full"));
}
}
@ -397,7 +397,7 @@ bool SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &save
if (EncryptData(decryptMode, cryptedData, &cryptedSize, &aligned_len, cryptedHash, (HasKey(param) ? param->key : 0)) != 0)
{
I18NCategory *err = GetI18NCategory("Error");
osm.Show(err->T("Save encryption failed. This save won't work on real PSP"), 6.0f);
host->NotifyUserMessage(err->T("Save encryption failed. This save won't work on real PSP"), 6.0f);
ERROR_LOG(SCEUTILITY,"Save encryption failed. This save won't work on real PSP");
delete[] cryptedData;
cryptedData = 0;
@ -642,8 +642,8 @@ void SavedataParam::LoadCryptedSave(SceUtilitySavedataParam *param, u8 *data, u8
// Don't notify the user if we're not going to upgrade the save.
if (!g_Config.bEncryptSave) {
I18NCategory *di = GetI18NCategory("Dialog");
osm.Show(di->T("When you save, it will load on a PSP, but not an older PPSSPP"), 6.0f);
osm.Show(di->T("Old savedata detected"), 6.0f);
host->NotifyUserMessage(di->T("When you save, it will load on a PSP, but not an older PPSSPP"), 6.0f);
host->NotifyUserMessage(di->T("Old savedata detected"), 6.0f);
}
} else {
if (decryptMode == 5 && prevCryptMode == 3) {

View File

@ -26,8 +26,8 @@
#include "Core/FileSystems/ISOFileSystem.h"
#include "Core/HLE/sceKernel.h"
#include "Core/HW/MemoryStick.h"
#include "Core/Host.h"
#include "Core/Reporting.h"
#include "UI/OnScreenDisplay.h"
#ifdef _WIN32
#include "Common/CommonWindows.h"
@ -223,7 +223,7 @@ bool DirectoryFileHandle::Open(std::string &basePath, std::string &fileName, Fil
if (w32err == ERROR_DISK_FULL || w32err == ERROR_NOT_ENOUGH_QUOTA) {
// This is returned when the disk is full.
I18NCategory *err = GetI18NCategory("Error");
osm.Show(err->T("Disk full while writing data"));
host->NotifyUserMessage(err->T("Disk full while writing data"));
error = SCE_KERNEL_ERROR_ERRNO_NO_PERM;
}
}
@ -278,7 +278,7 @@ bool DirectoryFileHandle::Open(std::string &basePath, std::string &fileName, Fil
} else if (errno == ENOSPC) {
// This is returned when the disk is full.
I18NCategory *err = GetI18NCategory("Error");
osm.Show(err->T("Disk full while writing data"));
host->NotifyUserMessage(err->T("Disk full while writing data"));
error = SCE_KERNEL_ERROR_ERRNO_NO_PERM;
}
#endif
@ -333,13 +333,13 @@ size_t DirectoryFileHandle::Write(const u8* pointer, s64 size)
}
if (diskFull) {
// Sign extend on 64-bit.
ERROR_LOG(FILESYS, "Disk full");
I18NCategory *err = GetI18NCategory("Error");
osm.Show(err->T("Disk full while writing data"));
host->NotifyUserMessage(err->T("Disk full while writing data"));
// We only return an error when the disk is actually full.
// When writing this would cause the disk to be full, so it wasn't written, we return 0.
if (MemoryStick_FreeSpace() == 0) {
// Sign extend on 64-bit.
return (size_t)(s64)(s32)SCE_KERNEL_ERROR_ERRNO_DEVICE_NO_FREE_SPACE;
}
}

View File

@ -24,10 +24,10 @@
#include <cstring>
#include "util/text/parsers.h"
#include "Core/Core.h"
#include "Core/Host.h"
#include "Core/HLE/sceKernelInterrupt.h"
#include "Core/HLE/sceKernelThread.h"
#include "Core/HLE/sceKernelMemory.h"
#include "UI/OnScreenDisplay.h"
#include "proAdhoc.h"
#include "i18n/i18n.h"
@ -1419,7 +1419,7 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
iResult = getaddrinfo(g_Config.proAdhocServer.c_str(),0,NULL,&resultAddr);
if (iResult != 0) {
ERROR_LOG(SCENET, "DNS Error (%s)\n", g_Config.proAdhocServer.c_str());
osm.Show("DNS Error connecting to " + g_Config.proAdhocServer, 8.0f);
host->NotifyUserMessage("DNS Error connecting to " + g_Config.proAdhocServer, 8.0f);
return iResult;
}
for (ptr = resultAddr; ptr != NULL; ptr = ptr->ai_next) {
@ -1442,7 +1442,7 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
char buffer[512];
snprintf(buffer, sizeof(buffer), "Socket error (%i) when connecting to %s/%u.%u.%u.%u:%u", errno, g_Config.proAdhocServer.c_str(), sip[0], sip[1], sip[2], sip[3], ntohs(server_addr.sin_port));
ERROR_LOG(SCENET, "%s", buffer);
osm.Show(std::string(buffer), 8.0f);
host->NotifyUserMessage(buffer, 8.0f);
return iResult;
}
@ -1458,7 +1458,7 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
changeBlockingMode(metasocket, 1); // Change to non-blocking
if (sent > 0) {
I18NCategory *n = GetI18NCategory("Networking");
osm.Show(n->T("Network Initialized"), 1.0);
host->NotifyUserMessage(n->T("Network Initialized"), 1.0);
return 0;
}
else{

View File

@ -64,6 +64,8 @@ public:
virtual bool CanCreateShortcut() {return false;}
virtual bool CreateDesktopShortcut(std::string argumentPath, std::string title) {return false;}
virtual void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) {}
// Used for headless.
virtual bool ShouldSkipUI() { return false; }
virtual void SendDebugOutput(const std::string &output) {}

View File

@ -20,7 +20,6 @@
#include "base/mutex.h"
#include "base/timeutil.h"
#include "base/NativeApp.h"
#include "i18n/i18n.h"
#include "Common/FileUtil.h"
@ -44,7 +43,6 @@
#include "Core/MIPS/JitCommon/JitBlockCache.h"
#include "HW/MemoryStick.h"
#include "GPU/GPUState.h"
#include "UI/OnScreenDisplay.h"
namespace SaveState
{
@ -380,11 +378,7 @@ namespace SaveState
void NextSlot()
{
I18NCategory *sy = GetI18NCategory("System");
g_Config.iCurrentStateSlot = (g_Config.iCurrentStateSlot + 1) % NUM_SLOTS;
std::string msg = StringFromFormat("%s: %d", sy->T("Savestate Slot"), g_Config.iCurrentStateSlot + 1);
osm.Show(msg);
NativeMessageReceived("slotchanged", "");
}
void LoadSlot(const std::string &gameFilename, int slot, Callback callback, void *cbUserData)
@ -394,9 +388,8 @@ namespace SaveState
Load(fn, callback, cbUserData);
} else {
I18NCategory *sy = GetI18NCategory("System");
osm.Show(sy->T("Failed to load state. Error in the file system."), 2.0);
if (callback)
callback(false, cbUserData);
callback(false, sy->T("Failed to load state. Error in the file system."), cbUserData);
}
}
@ -405,7 +398,7 @@ namespace SaveState
std::string fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION);
std::string shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION);
if (!fn.empty()) {
auto renameCallback = [=](bool status, void *data) {
auto renameCallback = [=](bool status, const std::string &message, void *data) {
if (status) {
if (File::Exists(fn)) {
File::Delete(fn);
@ -413,17 +406,16 @@ namespace SaveState
File::Rename(fn + ".tmp", fn);
}
if (callback) {
callback(status, data);
callback(status, message, data);
}
};
// Let's also create a screenshot.
SaveScreenshot(shot, Callback(), 0);
Save(fn + ".tmp", renameCallback, cbUserData);
} else {
I18NCategory *sc = GetI18NCategory("Screen");
osm.Show("Failed to save state. Error in the file system.", 2.0);
I18NCategory *sy = GetI18NCategory("System");
if (callback)
callback(false, cbUserData);
callback(false, sy->T("Failed to save state. Error in the file system."), cbUserData);
}
}
@ -569,6 +561,7 @@ namespace SaveState
Operation &op = operations[i];
CChunkFileReader::Error result;
bool callbackResult;
std::string callbackMessage;
std::string reason;
I18NCategory *sc = GetI18NCategory("Screen");
@ -585,16 +578,16 @@ namespace SaveState
INFO_LOG(COMMON, "Loading state from %s", op.filename.c_str());
result = CChunkFileReader::Load(op.filename, PPSSPP_GIT_VERSION, state, &reason);
if (result == CChunkFileReader::ERROR_NONE) {
osm.Show(sc->T("Loaded State"), 2.0);
callbackMessage = sc->T("Loaded State");
callbackResult = true;
hasLoadedState = true;
} else if (result == CChunkFileReader::ERROR_BROKEN_STATE) {
HandleFailure();
osm.Show(i18nLoadFailure, 2.0);
callbackMessage = i18nLoadFailure;
ERROR_LOG(COMMON, "Load state failure: %s", reason.c_str());
callbackResult = false;
} else {
osm.Show(sc->T(reason.c_str(), i18nLoadFailure), 2.0);
callbackMessage = sc->T(reason.c_str(), i18nLoadFailure);
callbackResult = false;
}
break;
@ -603,45 +596,48 @@ namespace SaveState
INFO_LOG(COMMON, "Saving state to %s", op.filename.c_str());
result = CChunkFileReader::Save(op.filename, g_paramSFO.GetValueString("TITLE"), PPSSPP_GIT_VERSION, state);
if (result == CChunkFileReader::ERROR_NONE) {
osm.Show(sc->T("Saved State"), 2.0);
callbackMessage = sc->T("Saved State");
callbackResult = true;
} else if (result == CChunkFileReader::ERROR_BROKEN_STATE) {
HandleFailure();
osm.Show(i18nSaveFailure, 2.0);
callbackMessage = i18nSaveFailure;
ERROR_LOG(COMMON, "Save state failure: %s", reason.c_str());
callbackResult = false;
} else {
osm.Show(i18nSaveFailure, 2.0);
callbackMessage = i18nSaveFailure;
callbackResult = false;
}
break;
case SAVESTATE_VERIFY:
INFO_LOG(COMMON, "Verifying save state system");
callbackResult = CChunkFileReader::Verify(state) == CChunkFileReader::ERROR_NONE;
if (callbackResult) {
INFO_LOG(COMMON, "Verified save state system");
} else {
ERROR_LOG(COMMON, "Save state system verification failed");
}
break;
case SAVESTATE_REWIND:
INFO_LOG(COMMON, "Rewinding to recent savestate snapshot");
result = rewindStates.Restore();
if (result == CChunkFileReader::ERROR_NONE) {
osm.Show(sc->T("Loaded State"), 2.0);
callbackMessage = sc->T("Loaded State");
callbackResult = true;
hasLoadedState = true;
} else if (result == CChunkFileReader::ERROR_BROKEN_STATE) {
// Cripes. Good news is, we might have more. Let's try those too, better than a reset.
if (HandleFailure()) {
// Well, we did rewind, even if too much...
osm.Show(sc->T("Loaded State"), 2.0);
callbackMessage = sc->T("Loaded State");
callbackResult = true;
hasLoadedState = true;
} else {
osm.Show(i18nLoadFailure, 2.0);
callbackMessage = i18nLoadFailure;
callbackResult = false;
}
} else {
osm.Show(i18nLoadFailure, 2.0);
callbackMessage = i18nLoadFailure;
callbackResult = false;
}
break;
@ -660,7 +656,7 @@ namespace SaveState
}
if (op.callback)
op.callback(callbackResult, op.cbUserData);
op.callback(callbackResult, callbackMessage, op.cbUserData);
}
if (operations.size()) {
// Avoid triggering frame skipping due to slowdown

View File

@ -23,7 +23,7 @@
namespace SaveState
{
typedef std::function<void(bool status, void *cbUserData)> Callback;
typedef std::function<void(bool status, const std::string &message, void *cbUserData)> Callback;
static const int NUM_SLOTS = 5;
static const char *STATE_EXTENSION = "ppst";

View File

@ -22,13 +22,13 @@
#include "Common/Common.h"
#include "Core/Config.h"
#include "Core/CoreParameter.h"
#include "Core/Host.h"
#include "Core/Reporting.h"
#include "Core/ELF/ParamSFO.h"
#include "Core/System.h"
#include "GPU/Common/FramebufferCommon.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUState.h"
#include "UI/OnScreenDisplay.h" // Gross dependency!
void CenterDisplayOutputRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH, int rotation) {
float outW;
@ -1012,5 +1012,5 @@ void FramebufferManagerCommon::ShowScreenResolution() {
messageStream << gr->T("Window Size") << ": ";
messageStream << PSP_CoreParameter().pixelWidth << "x" << PSP_CoreParameter().pixelHeight;
osm.Show(messageStream.str(), 2.0f, 0xFFFFFF, -1, true, "resize");
host->NotifyUserMessage(messageStream.str(), 2.0f, 0xFFFFFF, "resize");
}

View File

@ -22,12 +22,14 @@
#include <map>
#include "helper/global.h"
#include "base/logging.h"
#include "i18n/i18n.h"
#include "math/lin/matrix4x4.h"
#include "math/math_util.h"
#include "util/text/utf8.h"
#include "Common/Common.h"
#include "Core/Config.h"
#include "Core/Host.h"
#include "Core/Reporting.h"
#include "GPU/Math3D.h"
#include "GPU/GPUState.h"
@ -35,7 +37,6 @@
#include "GPU/Directx9/ShaderManagerDX9.h"
#include "GPU/Directx9/DrawEngineDX9.h"
#include "GPU/Directx9/FramebufferDX9.h"
#include "UI/OnScreenDisplay.h"
namespace DX9 {
@ -613,8 +614,9 @@ VSShader *ShaderManagerDX9::ApplyShader(int prim, u32 vertType) {
vs = new VSShader(VSID, codeBuffer_, useHWTransform);
if (vs->Failed()) {
I18NCategory *gr = GetI18NCategory("Graphics");
ERROR_LOG(HLE, "Shader compilation failed, falling back to software transform");
osm.Show("hardware transform error - falling back to software", 2.5f, 0xFF3030FF, -1, true);
host->NotifyUserMessage(gr->T("hardware transform error - falling back to software"), 2.5f, 0xFF3030FF);
delete vs;
ComputeVertexShaderID(&VSID, vertType, false);

View File

@ -46,8 +46,6 @@
#include "GPU/GLES/DrawEngineGLES.h"
#include "GPU/GLES/ShaderManager.h"
#include "UI/OnScreenDisplay.h"
// #define DEBUG_READ_PIXELS 1
static const char tex_fs[] =
@ -180,9 +178,9 @@ void FramebufferManager::CompileDraw2DProgram() {
}
}
if (!firstLine.empty()) {
osm.Show("Post-shader error: " + firstLine + "...", 10.0f, 0xFF3090FF);
host->NotifyUserMessage("Post-shader error: " + firstLine + "...", 10.0f, 0xFF3090FF);
} else {
osm.Show("Post-shader error, see log for details", 10.0f, 0xFF3090FF);
host->NotifyUserMessage("Post-shader error, see log for details", 10.0f, 0xFF3090FF);
}
usePostShader_ = false;
} else {

View File

@ -26,12 +26,14 @@
#include "base/logging.h"
#include "base/timeutil.h"
#include "i18n/i18n.h"
#include "math/math_util.h"
#include "math/lin/matrix4x4.h"
#include "profiler/profiler.h"
#include "Common/FileUtil.h"
#include "Core/Config.h"
#include "Core/Host.h"
#include "Core/Reporting.h"
#include "GPU/Math3D.h"
#include "GPU/GPUState.h"
@ -39,9 +41,7 @@
#include "GPU/GLES/GLStateCache.h"
#include "GPU/GLES/ShaderManager.h"
#include "GPU/GLES/DrawEngineGLES.h"
#include "UI/OnScreenDisplay.h"
#include "Framebuffer.h"
#include "i18n/i18n.h"
Shader::Shader(const char *code, uint32_t glShaderType, bool useHWTransform)
: failed_(false), useHWTransform_(useHWTransform) {
@ -845,7 +845,7 @@ Shader *ShaderManager::ApplyVertexShader(int prim, u32 vertType, ShaderID *VSID)
if (vs->Failed()) {
I18NCategory *gr = GetI18NCategory("Graphics");
ERROR_LOG(G3D, "Shader compilation failed, falling back to software transform");
osm.Show(gr->T("hardware transform error - falling back to software"), 2.5f, 0xFF3030FF, -1, true);
host->NotifyUserMessage(gr->T("hardware transform error - falling back to software"), 2.5f, 0xFF3030FF);
delete vs;
// TODO: Look for existing shader with the appropriate ID, use that instead of generating a new one - however, need to make sure

View File

@ -38,7 +38,6 @@
#include "GPU/GLES/ShaderManager.h"
#include "GPU/GLES/DrawEngineGLES.h"
#include "GPU/Common/TextureDecoder.h"
#include "UI/OnScreenDisplay.h"
#ifdef _M_SSE
#include <xmmintrin.h>
@ -1917,9 +1916,9 @@ void TextureCache::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &repla
I18NCategory *err = GetI18NCategory("Error");
if (scaleFactor > 1) {
osm.Show(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
host->NotifyUserMessage(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
} else {
osm.Show(err->T("Warning: Video memory FULL, switching to slow caching mode"), 2.0f);
host->NotifyUserMessage(err->T("Warning: Video memory FULL, switching to slow caching mode"), 2.0f);
}
} else if (err != GL_NO_ERROR) {
// We checked the err anyway, might as well log if there is one.

View File

@ -50,8 +50,6 @@
#include "GPU/Vulkan/ShaderManagerVulkan.h"
#include "GPU/Vulkan/VulkanUtil.h"
#include "UI/OnScreenDisplay.h"
const VkFormat framebufFormat = VK_FORMAT_R8G8B8A8_UNORM;
static const char tex_fs[] = R"(#version 400

View File

@ -39,7 +39,6 @@
#include "GPU/Vulkan/FramebufferVulkan.h"
#include "GPU/Vulkan/FragmentShaderGeneratorVulkan.h"
#include "GPU/Vulkan/VertexShaderGeneratorVulkan.h"
#include "UI/OnScreenDisplay.h"
VulkanFragmentShader::VulkanFragmentShader(VulkanContext *vulkan, ShaderID id, const char *code, bool useHWTransform)
: vulkan_(vulkan), id_(id), failed_(false), useHWTransform_(useHWTransform), module_(0) {

View File

@ -42,7 +42,6 @@
#include "GPU/Vulkan/ShaderManagerVulkan.h"
#include "GPU/Vulkan/DrawEngineVulkan.h"
#include "GPU/Common/TextureDecoder.h"
#include "UI/OnScreenDisplay.h"
#ifdef _M_SSE
#include <xmmintrin.h>
@ -1360,9 +1359,9 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry,VulkanPushBuffe
I18NCategory *err = GetI18NCategory("Error");
if (scaleFactor > 1) {
osm.Show(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
host->NotifyUserMessage(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
} else {
osm.Show(err->T("Warning: Video memory FULL, switching to slow caching mode"), 2.0f);
host->NotifyUserMessage(err->T("Warning: Video memory FULL, switching to slow caching mode"), 2.0f);
}
scaleFactor = 1;

View File

@ -178,7 +178,7 @@ void MainWindow::closeAct()
SetGameTitle("");
}
void SaveStateActionFinished(bool result, void *userdata)
void SaveStateActionFinished(bool result, const std::string &message, void *userdata)
{
// TODO: Improve messaging?
if (!result)

View File

@ -73,6 +73,7 @@
EmuScreen::EmuScreen(const std::string &filename)
: bootPending_(true), gamePath_(filename), invalid_(true), quit_(false), pauseTrigger_(false), saveStatePreviewShownTime_(0.0), saveStatePreview_(nullptr) {
memset(axisState_, 0, sizeof(axisState_));
saveStateSlot_ = SaveState::GetCurrentSlot();
}
void EmuScreen::bootGame(const std::string &filename) {
@ -217,7 +218,14 @@ void EmuScreen::dialogFinished(const Screen *dialog, DialogResult result) {
RecreateViews();
}
static void AfterStateLoad(bool success, void *ignored) {
static void AfterSaveStateAction(bool success, const std::string &message, void *) {
if (!message.empty()) {
osm.Show(message, 2.0);
}
}
static void AfterStateBoot(bool success, const std::string &message, void *ignored) {
AfterSaveStateAction(success, message, ignored);
Core_EnableStepping(false);
host->UpdateDisassembly();
}
@ -251,7 +259,7 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
} else if (!strcmp(message, "boot")) {
const char *ext = strrchr(value, '.');
if (ext != nullptr && !strcmp(ext, ".ppst")) {
SaveState::Load(value, &AfterStateLoad);
SaveState::Load(value, &AfterStateBoot);
} else {
PSP_Shutdown();
bootPending_ = true;
@ -290,22 +298,6 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
} else {
gstate_c.skipDrawReason &= ~SKIPDRAW_WINDOW_MINIMIZED;
}
} else if (!strcmp(message, "slotchanged")) {
if (saveStatePreview_) {
int curSlot = SaveState::GetCurrentSlot();
std::string fn;
if (SaveState::HasSaveInSlot(gamePath_, curSlot)) {
fn = SaveState::GenerateSaveSlotFilename(gamePath_, curSlot, SaveState::SCREENSHOT_EXTENSION);
}
saveStatePreview_->SetFilename(fn);
if (!fn.empty()) {
saveStatePreview_->SetVisibility(UI::V_VISIBLE);
saveStatePreviewShownTime_ = time_now_d();
} else {
saveStatePreview_->SetVisibility(UI::V_GONE);
}
}
}
}
@ -400,19 +392,20 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) {
case VIRTKEY_REWIND:
if (SaveState::CanRewind()) {
SaveState::Rewind();
SaveState::Rewind(&AfterSaveStateAction);
} else {
osm.Show(sc->T("norewind", "No rewind save states available"), 2.0);
}
break;
case VIRTKEY_SAVE_STATE:
SaveState::SaveSlot(gamePath_, g_Config.iCurrentStateSlot, SaveState::Callback());
SaveState::SaveSlot(gamePath_, g_Config.iCurrentStateSlot, &AfterSaveStateAction);
break;
case VIRTKEY_LOAD_STATE:
SaveState::LoadSlot(gamePath_, g_Config.iCurrentStateSlot, SaveState::Callback());
SaveState::LoadSlot(gamePath_, g_Config.iCurrentStateSlot, &AfterSaveStateAction);
break;
case VIRTKEY_NEXT_SLOT:
SaveState::NextSlot();
NativeMessageReceived("savestate_displayslot", "");
break;
case VIRTKEY_TOGGLE_FULLSCREEN:
System_SendMessage("toggle_fullscreen", "");
@ -806,8 +799,34 @@ void EmuScreen::update(InputState &input) {
screenManager()->push(new GamePauseScreen(gamePath_));
}
if (time_now_d() - saveStatePreviewShownTime_ > 2 && saveStatePreview_->GetVisibility() == UI::V_VISIBLE) {
saveStatePreview_->SetVisibility(UI::V_GONE);
if (saveStatePreview_) {
int currentSlot = SaveState::GetCurrentSlot();
if (saveStateSlot_ != currentSlot) {
saveStateSlot_ = currentSlot;
std::string fn;
if (SaveState::HasSaveInSlot(gamePath_, currentSlot)) {
fn = SaveState::GenerateSaveSlotFilename(gamePath_, currentSlot, SaveState::SCREENSHOT_EXTENSION);
}
saveStatePreview_->SetFilename(fn);
if (!fn.empty()) {
saveStatePreview_->SetVisibility(UI::V_VISIBLE);
saveStatePreviewShownTime_ = time_now_d();
} else {
saveStatePreview_->SetVisibility(UI::V_GONE);
}
}
if (saveStatePreview_->GetVisibility() == UI::V_VISIBLE) {
double endTime = saveStatePreviewShownTime_ + 2.0;
float alpha = clamp_value((endTime - time_now_d()) * 4.0, 0.0, 1.0);
saveStatePreview_->SetColor(colorAlpha(0x00FFFFFF, alpha));
if (time_now_d() - saveStatePreviewShownTime_ > 2) {
saveStatePreview_->SetVisibility(UI::V_GONE);
}
}
}
}
@ -1012,7 +1031,7 @@ void EmuScreen::autoLoad() {
//check if save state has save, if so, load
int lastSlot = SaveState::GetNewestSlot(gamePath_);
if (g_Config.bEnableAutoLoad && lastSlot != -1) {
SaveState::LoadSlot(gamePath_, lastSlot, SaveState::Callback(), 0);
SaveState::LoadSlot(gamePath_, lastSlot, &AfterSaveStateAction);
g_Config.iCurrentStateSlot = lastSlot;
}
}

View File

@ -89,4 +89,5 @@ private:
double saveStatePreviewShownTime_;
AsyncImageFileView *saveStatePreview_;
int saveStateSlot_;
};

View File

@ -18,6 +18,7 @@
#pragma once
#include "Core/Host.h"
#include "UI/OnScreenDisplay.h"
#if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
#include "Core/Debugger/SymbolMap.h"
@ -50,6 +51,10 @@ public:
bool IsDebuggingEnabled() override {return false;}
bool AttemptLoadSymbolMap() override {return false;}
void SetWindowTitle(const char *message) override {}
void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override {
osm.Show(message, duration, color, -1, true, id);
}
};
#if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
@ -126,6 +131,11 @@ public:
mainWindow->setWindowTitle(title);
}
void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override {
osm.Show(message, duration, color, -1, true, id);
}
bool GPUDebuggingActive()
{
auto dialogDisplayList = mainWindow->GetDialogDisplaylist();

View File

@ -489,8 +489,13 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
}
#endif
if (!boot_filename.empty() && stateToLoad != NULL)
SaveState::Load(stateToLoad);
if (!boot_filename.empty() && stateToLoad != NULL) {
SaveState::Load(stateToLoad, [](bool status, const std::string &message, void *) {
if (!message.empty()) {
osm.Show(message, 2.0);
}
});
}
screenManager = new ScreenManager();
if (skipLogo) {
@ -766,6 +771,12 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) {
g_Config.sNickName = inputboxValue[1];
inputboxValue.clear();
}
if (msg == "savestate_displayslot") {
I18NCategory *sy = GetI18NCategory("System");
std::string msg = StringFromFormat("%s: %d", sy->T("Savestate Slot"), SaveState::GetCurrentSlot() + 1);
// Show for the same duration as the preview.
osm.Show(msg, 2.0f, 0xFFFFFF, -1, true, "savestate_slot");
}
}
void NativeUpdate(InputState &input) {

View File

@ -40,6 +40,7 @@
#include "UI/ReportScreen.h"
#include "UI/CwCheatScreen.h"
#include "UI/MainScreen.h"
#include "UI/OnScreenDisplay.h"
#include "UI/GameInfoCache.h"
void AsyncImageFileView::GetContentDimensions(const UIContext &dc, float &w, float &h) const {
@ -224,9 +225,15 @@ void SaveSlotView::Draw(UIContext &dc) {
UI::LinearLayout::Draw(dc);
}
static void AfterSaveStateAction(bool status, const std::string &message, void *) {
if (!message.empty()) {
osm.Show(message, 2.0);
}
}
UI::EventReturn SaveSlotView::OnLoadState(UI::EventParams &e) {
g_Config.iCurrentStateSlot = slot_;
SaveState::LoadSlot(gamePath_, slot_, SaveState::Callback(), 0);
SaveState::LoadSlot(gamePath_, slot_, &AfterSaveStateAction);
UI::EventParams e2;
e2.v = this;
OnStateLoaded.Trigger(e2);
@ -235,7 +242,7 @@ UI::EventReturn SaveSlotView::OnLoadState(UI::EventParams &e) {
UI::EventReturn SaveSlotView::OnSaveState(UI::EventParams &e) {
g_Config.iCurrentStateSlot = slot_;
SaveState::SaveSlot(gamePath_, slot_, SaveState::Callback(), 0);
SaveState::SaveSlot(gamePath_, slot_, &AfterSaveStateAction);
UI::EventParams e2;
e2.v = this;
OnStateSaved.Trigger(e2);
@ -389,7 +396,7 @@ UI::EventReturn GamePauseScreen::OnReportFeedback(UI::EventParams &e) {
}
UI::EventReturn GamePauseScreen::OnRewind(UI::EventParams &e) {
SaveState::Rewind(SaveState::Callback(), 0);
SaveState::Rewind(&AfterSaveStateAction);
screenManager()->finishDialog(this, DR_CANCEL);
return UI::EVENT_DONE;

View File

@ -60,6 +60,7 @@
<ClInclude Include="GameScreen.h" />
<ClInclude Include="GameSettingsScreen.h" />
<ClInclude Include="CwCheatScreen.h" />
<ClInclude Include="HostTypes.h" />
<ClInclude Include="MainScreen.h" />
<ClInclude Include="MiscScreens.h" />
<ClInclude Include="OnScreenDisplay.h" />

View File

@ -132,6 +132,7 @@
<Filter>Screens</Filter>
</ClInclude>
<ClInclude Include="DisplayLayoutEditor.h" />
<ClInclude Include="HostTypes.h" />
</ItemGroup>
<ItemGroup>
<Filter Include="Screens">

View File

@ -192,7 +192,7 @@ unsigned int WINAPI TheThread(void *)
if (!Core_IsActive())
UpdateUIState(UISTATE_MENU);
Core_Run(graphicsContext);
Core_Run(graphicsContext, &input_state);
}
shutdown:

View File

@ -400,7 +400,10 @@ namespace MainWindow {
g_Config.iInternalScreenRotation = rotation;
}
static void SaveStateActionFinished(bool result, void *userdata) {
static void SaveStateActionFinished(bool result, const std::string &message, void *userdata) {
if (!message.empty()) {
osm.Show(message, 2.0);
}
PostMessage(MainWindow::GetHWND(), WM_USER_SAVESTATE_FINISH, 0, 0);
}
@ -580,6 +583,7 @@ namespace MainWindow {
case ID_FILE_SAVESTATE_NEXT_SLOT:
{
SaveState::NextSlot();
NativeMessageReceived("savestate_displayslot", "");
break;
}
@ -588,6 +592,7 @@ namespace MainWindow {
if (KeyMap::g_controllerMap[VIRTKEY_NEXT_SLOT].empty())
{
SaveState::NextSlot();
NativeMessageReceived("savestate_displayslot", "");
}
break;
}

View File

@ -34,10 +34,12 @@
#include "input/keycodes.h"
#include "util/text/utf8.h"
#include "Common/StringUtils.h"
#include "Core/Core.h"
#include "Core/Config.h"
#include "Core/CoreParameter.h"
#include "Core/System.h"
#include "Core/Debugger/SymbolMap.h"
#include "Windows/EmuThread.h"
#include "Windows/DSoundStream.h"
#include "Windows/WindowsHost.h"
@ -54,10 +56,8 @@
#include "Windows/XinputDevice.h"
#include "Windows/KeyboardDevice.h"
#include "Core/Debugger/SymbolMap.h"
#include "Common/StringUtils.h"
#include "Windows/main.h"
#include "UI/OnScreenDisplay.h"
static const int numCPUs = 1;
@ -348,3 +348,7 @@ void WindowsHost::GoFullscreen(bool viewFullscreen) {
void WindowsHost::ToggleDebugConsoleVisibility() {
MainWindow::ToggleDebugConsoleVisibility();
}
void WindowsHost::NotifyUserMessage(const std::string &message, float duration, u32 color, const char *id) {
osm.Show(message, duration, color, -1, true, id);
}

View File

@ -64,6 +64,8 @@ public:
bool CanCreateShortcut() override;
bool CreateDesktopShortcut(std::string argumentPath, std::string title) override;
void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override;
void GoFullscreen(bool) override;
std::shared_ptr<KeyboardDevice> keyboard;

View File

@ -169,7 +169,6 @@ EXEC_AND_LIB_FILES := \
$(SRC)/Core/MIPS/IR/IRPassSimplify.cpp \
$(SRC)/Core/MIPS/IR/IRRegCache.cpp \
$(SRC)/UI/ui_atlas.cpp \
$(SRC)/UI/OnScreenDisplay.cpp \
$(SRC)/ext/libkirk/AES.c \
$(SRC)/ext/libkirk/amctrl.c \
$(SRC)/ext/libkirk/SHA1.c \
@ -411,6 +410,7 @@ LOCAL_SRC_FILES := \
$(SRC)/UI/TouchControlVisibilityScreen.cpp \
$(SRC)/UI/CwCheatScreen.cpp \
$(SRC)/UI/InstallZipScreen.cpp \
$(SRC)/UI/OnScreenDisplay.cpp \
$(SRC)/UI/ProfilerDraw.cpp \
$(SRC)/UI/NativeApp.cpp \
$(SRC)/UI/ComboKeyMappingScreen.cpp

View File

@ -348,7 +348,7 @@ void BlackberryMain::runMain() {
switchDisplay(screen_ui);
}
time_update();
UpdateRunLoop();
UpdateRunLoop(&input_state);
// This handles VSync
if (emulating)
eglSwapBuffers(egl_disp[screen_emu], egl_surf[screen_emu]);

View File

@ -859,7 +859,7 @@ int main(int argc, char *argv[]) {
SimulateGamepad(keys, &input_state);
input_state.pad_buttons = pad_buttons;
UpdateInputState(&input_state, true);
UpdateRunLoop();
UpdateRunLoop(&input_state);
if (g_QuitRequested)
break;
#if defined(PPSSPP) && !defined(MOBILE_DEVICE)

View File

@ -360,7 +360,7 @@ void MainUI::paintGL()
updateAccelerometer();
UpdateInputState(&input_state);
time_update();
UpdateRunLoop();
UpdateRunLoop(&input_state);
}
void MainUI::updateAccelerometer()

View File

@ -66,14 +66,9 @@ public:
struct InputState;
// Temporary hacks around annoying linking errors.
void D3D9_SwapBuffers() { }
void GL_SwapBuffers() { }
void GL_SwapInterval(int) { }
void Vulkan_SwapBuffers() {}
void NativeUpdate(InputState &input_state) { }
void NativeRender(GraphicsContext *graphicsContext) { }
void NativeResized() { }
void NativeMessageReceived(const char *message, const char *value) {}
std::string System_GetProperty(SystemProperty prop) { return ""; }
int System_GetPropertyInt(SystemProperty prop) { return -1; }
@ -82,8 +77,6 @@ bool System_InputBoxGetWString(const wchar_t *title, const std::wstring &default
void System_AskForPermission(SystemPermission permission) {}
PermissionStatus System_GetPermissionStatus(SystemPermission permission) { return PERMISSION_STATUS_GRANTED; }
InputState input_state;
int printUsage(const char *progname, const char *reason)
{
if (reason != NULL)

View File

@ -224,7 +224,6 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\ext\native\ext\glew\glew.c" />
<ClCompile Include="..\UI\OnScreenDisplay.cpp" />
<ClCompile Include="..\Windows\GPU\D3D9Context.cpp" />
<ClCompile Include="..\Windows\GPU\WindowsGLContext.cpp" />
<ClCompile Include="..\Windows\GPU\WindowsVulkanContext.cpp" />
@ -266,7 +265,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\UI\OnScreenDisplay.h" />
<ClInclude Include="Compare.h" />
<ClInclude Include="StubHost.h" />
<ClInclude Include="WindowsHeadlessHost.h" />

View File

@ -3,7 +3,6 @@
<ItemGroup>
<ClCompile Include="Headless.cpp" />
<ClCompile Include="Compare.cpp" />
<ClCompile Include="..\UI\OnScreenDisplay.cpp" />
<ClCompile Include="..\ext\native\ext\glew\glew.c" />
<ClCompile Include="..\Windows\GPU\D3D9Context.cpp">
<Filter>Windows</Filter>
@ -28,7 +27,6 @@
<ItemGroup>
<ClInclude Include="StubHost.h" />
<ClInclude Include="Compare.h" />
<ClInclude Include="..\UI\OnScreenDisplay.h" />
<ClInclude Include="WindowsHeadlessHost.h">
<Filter>Windows</Filter>
</ClInclude>

View File

@ -33,8 +33,6 @@
struct InputState;
// Temporary hacks around annoying linking errors. Copied from Headless.
void D3D9_SwapBuffers() { }
void GL_SwapBuffers() { }
void NativeUpdate(InputState &input_state) { }
void NativeRender(GraphicsContext *graphicsContext) { }
void NativeResized() { }

View File

@ -48,13 +48,8 @@
#include "unittest/TestVertexJit.h"
#include "unittest/UnitTest.h"
InputState input_state;
std::string System_GetProperty(SystemProperty prop) { return ""; }
int System_GetPropertyInt(SystemProperty prop) { return -1; }
void NativeMessageReceived(const char *message, const char *value) {}
void GL_SwapInterval(int) {}
void Vulkan_SwapBuffers() {}
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923