Merge pull request #90 from gizmo98/patch-2
[libretro-ppsspp.git] / UI / HostTypes.h
blob9d987962d9fa1b2ce504a0218524608a33d6e823
1 // Copyright (c) 2014- PPSSPP Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0 or later versions.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official git repository and contact information can be found at
16 // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
18 #pragma once
20 #include "Core/Host.h"
22 #if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
23 #include "Core/Debugger/SymbolMap.h"
24 #include "Qt/mainwindow.h"
25 #endif
27 // TODO: Get rid of this junk
28 class NativeHost : public Host {
29 public:
30 NativeHost() {
33 void UpdateUI() override {}
35 void UpdateMemView() override {}
36 void UpdateDisassembly() override {}
38 void SetDebugMode(bool mode) override { }
40 bool InitGraphics(std::string *error_message) override { return true; }
41 void ShutdownGraphics() override {}
43 void InitSound() override;
44 void UpdateSound() override {}
45 void ShutdownSound() override;
47 // this is sent from EMU thread! Make sure that Host handles it properly!
48 void BootDone() override {}
50 bool IsDebuggingEnabled() override {return false;}
51 bool AttemptLoadSymbolMap() override {return false;}
52 void SetWindowTitle(const char *message) override {}
55 #if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
56 static const char* SymbolMapFilename(std::string currentFilename)
58 std::string result = currentFilename;
59 size_t dot = result.rfind('.');
60 if (dot == result.npos)
61 return (result + ".map").c_str();
63 result.replace(dot, result.npos, ".map");
64 return result.c_str();
67 class QtHost : public Host {
68 public:
69 QtHost(MainWindow *mainWindow_)
71 mainWindow = mainWindow_;
72 m_GPUStep = false;
73 m_GPUFlag = 0;
76 virtual void UpdateUI() override {
77 mainWindow->updateMenus();
80 virtual void UpdateMemView() override {
81 if(mainWindow->GetDialogMemory())
82 mainWindow->GetDialogMemory()->Update();
84 virtual void UpdateDisassembly() override {
85 if(mainWindow->GetDialogDisasm())
86 mainWindow->GetDialogDisasm()->Update();
87 if(mainWindow->GetDialogDisplaylist())
88 mainWindow->GetDialogDisplaylist()->Update();
91 virtual void SetDebugMode(bool mode) override {
92 if(mainWindow->GetDialogDisasm())
93 mainWindow->GetDialogDisasm()->SetDebugMode(mode);
96 virtual bool InitGraphics(std::string *error_message) override { return true; }
97 virtual void ShutdownGraphics() override {}
99 virtual void InitSound() override;
100 virtual void UpdateSound() override {}
101 virtual void ShutdownSound();
103 // this is sent from EMU thread! Make sure that Host handles it properly!
104 virtual void BootDone() {
105 symbolMap.SortSymbols();
106 mainWindow->Boot();
109 virtual bool IsDebuggingEnabled() {
110 #ifdef _DEBUG
111 return true;
112 #else
113 return false;
114 #endif
116 virtual bool AttemptLoadSymbolMap() {
117 return symbolMap.LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart));
119 virtual void PrepareShutdown() {
120 symbolMap.SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart));
122 virtual void ResetSymbolMap() {}
123 virtual void AddSymbol(std::string name, u32 addr, u32 size, int type=0) {}
124 virtual void SetWindowTitle(const char *message) {
125 QString title = "PPSSPP " + QString(PPSSPP_GIT_VERSION) + " - " + QString::fromUtf8(message);
127 mainWindow->setWindowTitle(title);
129 bool GPUDebuggingActive()
131 auto dialogDisplayList = mainWindow->GetDialogDisplaylist();
132 if (dialogDisplayList && dialogDisplayList->isVisible())
134 if (m_GPUStep && m_GPUFlag == -1)
135 m_GPUFlag = 0;
137 return true;
139 return false;
141 void SetGPUStep(bool value, int flag = 0, u32 data = 0)
143 m_GPUStep = value;
144 m_GPUFlag = flag;
145 m_GPUData = data;
147 private:
148 MainWindow* mainWindow;
149 bool m_GPUStep;
150 int m_GPUFlag;
151 u32 m_GPUData;
153 #endif