7
#include <QActionGroup>
9
#include "ConsoleListener.h"
10
#include "Core/Core.h"
11
#include "Core/Config.h"
12
#include "Core/System.h"
13
#include "Debugger/debugger_disasm.h"
14
#include "Debugger/debugger_memory.h"
15
#include "Debugger/debugger_memorytex.h"
16
#include "Debugger/debugger_displaylist.h"
17
#include "base/QtMain.h"
19
extern bool g_TakeScreenshot;
24
class MainWindow : public QMainWindow
29
explicit MainWindow(QWidget *parent = 0, bool fullscreen=false);
32
Debugger_Disasm* GetDialogDisasm() { return dialogDisasm; }
33
Debugger_Memory* GetDialogMemory() { return memoryWindow; }
34
Debugger_MemoryTex* GetDialogMemoryTex() { return memoryTexWindow; }
35
Debugger_DisplayList* GetDialogDisplaylist() { return displaylistWindow; }
36
CoreState GetNextState() { return nextState; }
38
void ShowMemory(u32 addr);
42
void changeEvent(QEvent *e)
44
QMainWindow::changeEvent(e);
45
// Does not work on Linux for Qt5.2 or Qt5.3 (Qt bug)
46
if(e->type() == QEvent::WindowStateChange)
47
Core_NotifyWindowHidden(isMinimized());
50
void closeEvent(QCloseEvent *) { exitAct(); }
81
void takeScreen() { g_TakeScreenshot = true; }
90
void vertexDynarecAct() { g_Config.bVertexDecoderJit = !g_Config.bVertexDecoderJit; }
91
void fastmemAct() { g_Config.bFastMemory = !g_Config.bFastMemory; }
92
void ignoreIllegalAct() { g_Config.bIgnoreBadMemAccess = !g_Config.bIgnoreBadMemAccess; }
95
void anisotropicGroup_triggered(QAction *action) { g_Config.iAnisotropyLevel = action->data().toInt(); }
97
void bufferRenderAct() { g_Config.iRenderingMode = !g_Config.iRenderingMode; }
98
void linearAct() { g_Config.iTexFiltering = (g_Config.iTexFiltering != 0) ? 0 : 3; }
100
void screenGroup_triggered(QAction *action) { SetWindowScale(action->data().toInt()); }
102
void displayLayoutGroup_triggered(QAction *action) { g_Config.iSmallDisplayZoomType = action->data().toInt(); }
103
void transformAct() { g_Config.bHardwareTransform = !g_Config.bHardwareTransform; }
104
void vertexCacheAct() { g_Config.bVertexCache = !g_Config.bVertexCache; }
105
void frameskipAct() { g_Config.iFrameSkip = !g_Config.iFrameSkip; }
108
void audioAct() { g_Config.bEnableSound = !g_Config.bEnableSound; }
112
void statsAct() { g_Config.bShowDebugStats = !g_Config.bShowDebugStats; }
113
void showFPSAct() { g_Config.iShowFPSCounter = !g_Config.iShowFPSCounter; }
116
void defaultLogGroup_triggered(QAction * action) {
117
LogTypes::LOG_LEVELS level = (LogTypes::LOG_LEVELS)action->data().toInt();
118
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
120
LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i;
121
if(type == LogTypes::G3D || type == LogTypes::HLE)
123
LogManager::GetInstance()->SetLogLevel(type, level);
126
void g3dLogGroup_triggered(QAction * action) { LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, (LogTypes::LOG_LEVELS)action->data().toInt()); }
127
void hleLogGroup_triggered(QAction * action) { LogManager::GetInstance()->SetLogLevel(LogTypes::HLE, (LogTypes::LOG_LEVELS)action->data().toInt()); }
135
void langChanged(QAction *action) { loadLanguage(action->data().toString(), true); }
138
void SetWindowScale(int zoom);
139
void SetGameTitle(QString text);
140
void loadLanguage(const QString &language, bool retranslate);
142
void notifyMapsLoaded();
144
QTranslator translator;
145
QString currentLanguage;
148
InputState input_state;
149
GlobalUIState lastUIState;
151
Debugger_Disasm *dialogDisasm;
152
Debugger_Memory *memoryWindow;
153
Debugger_MemoryTex *memoryTexWindow;
154
Debugger_DisplayList *displaylistWindow;
156
QActionGroup *anisotropicGroup, *screenGroup, *displayLayoutGroup,
157
*defaultLogGroup, *g3dLogGroup, *hleLogGroup;
160
class MenuAction : public QAction
166
MenuAction(QWidget* parent, const char *callback, const char *text, QKeySequence key = 0) :
167
QAction(parent), _text(text), _eventCheck(0), _stateEnable(-1), _stateDisable(-1), _enableStepping(false)
169
if (key != (QKeySequence)0) {
170
this->setShortcut(key);
171
parent->addAction(this); // So we don't lose the shortcut when menubar is hidden
173
connect(this, SIGNAL(triggered()), parent, callback);
174
connect(parent, SIGNAL(retranslate()), this, SLOT(retranslate()));
175
connect(parent, SIGNAL(updateMenu()), this, SLOT(update()));
177
// Add to QActionGroup
178
MenuAction(QWidget* parent, QActionGroup* group, QVariant data, QString text, QKeySequence key = 0) :
179
QAction(parent), _eventCheck(0), _stateEnable(-1), _stateDisable(-1), _enableStepping(false)
181
this->setCheckable(true);
183
this->setText(text); // Not translatable, yet
184
if (key != (QKeySequence)0) {
185
this->setShortcut(key);
186
parent->addAction(this); // So we don't lose the shortcut when menubar is hidden
188
group->addAction(this);
190
// Event which causes it to be checked
191
void addEventChecked(bool* event) {
192
this->setCheckable(true);
195
// TODO: Possibly handle compares
196
void addEventChecked(int* event) {
197
this->setCheckable(true);
198
_eventCheck = (bool*)event;
200
// UI State which causes it to be enabled
201
void addEnableState(int state) {
202
_stateEnable = state;
204
void addDisableState(int state) {
205
_stateDisable = state;
207
MenuAction* addEnableStepping() {
208
_enableStepping = true;
213
setText(qApp->translate("MainWindow", _text));
217
setChecked(*_eventCheck);
218
if (_stateEnable >= 0)
219
setEnabled(GetUIState() == _stateEnable);
220
if (_stateDisable >= 0)
221
setEnabled(GetUIState() != _stateDisable);
222
if (_enableStepping && Core_IsStepping())
228
int _stateEnable, _stateDisable;
229
bool _enableStepping;
232
class MenuActionGroup : public QActionGroup
236
MenuActionGroup(QWidget* parent, QMenu* menu, const char* callback, QStringList nameList,
237
QList<int> valueList, QList<int> keyList = QList<int>()) :
240
QListIterator<int> i(valueList);
241
QListIterator<int> k(keyList);
242
foreach(QString name, nameList) {
243
new MenuAction(parent, this, i.next(), name, keyList.size() ? k.next() : 0);
245
connect(this, SIGNAL(triggered(QAction *)), parent, callback);
246
menu->addActions(this->actions());
250
class MenuTree : public QMenu
254
MenuTree(QWidget* parent, QMenuBar* menu, const char *text) :
255
QMenu(parent), _text(text)
258
connect(parent, SIGNAL(retranslate()), this, SLOT(retranslate()));
260
MenuTree(QWidget* parent, QMenu* menu, const char *text) :
261
QMenu(parent), _text(text)
264
connect(parent, SIGNAL(retranslate()), this, SLOT(retranslate()));
266
MenuAction* add(MenuAction* action)
273
setTitle(qApp->translate("MainWindow", _text));
279
#endif // MAINWINDOW_H