1 /* Copyright 2005 Guillaume Duhamel 2 Copyright 2005-2006, 2013 Theo Berkau 3 Copyright 2008 Filipe Azevedo <pasnox@gmail.com> 4 5 This file is part of Yabause. 6 7 Yabause is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 Yabause is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with Yabause; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 #ifndef UIYABAUSE_H 22 #define UIYABAUSE_H 23 24 #include "ui_UIYabause.h" 25 #include "../YabauseThread.h" 26 #include "UICheatSearch.h" 27 #include <QTimer> 28 29 extern "C" { 30 #include "../screen.h" 31 } 32 33 class YabauseGLProxy; 34 class QTextEdit; 35 class QDockWidget; 36 37 enum BARDISPLAY 38 { 39 BD_NEVERHIDE=0, 40 BD_HIDEFS=1, 41 BD_ALWAYSHIDE=2, 42 BD_SHOWONFSHOVER=3 43 }; 44 45 class YabauseLocker 46 { 47 public: YabauseLocker(YabauseThread * yt)48 YabauseLocker( YabauseThread* yt/*, bool fr = false*/ ) 49 { 50 Q_ASSERT( yt ); 51 mThread = yt; 52 //mForceRun = fr; 53 mRunning = mThread->emulationRunning(); 54 mPaused = mThread->emulationPaused(); 55 if ( mRunning && !mPaused ) 56 mThread->pauseEmulation( true, false ); 57 } ~YabauseLocker()58 ~YabauseLocker() 59 { 60 if ( ( mRunning && !mPaused ) /*|| mForceRun*/ ) 61 mThread->pauseEmulation( false, false ); 62 } 63 64 protected: 65 YabauseThread* mThread; 66 bool mRunning; 67 bool mPaused; 68 //bool mForceRun; 69 }; 70 71 class UIYabause : public QMainWindow, public Ui::UIYabause 72 { 73 Q_OBJECT 74 75 public: 76 UIYabause( QWidget* parent = 0 ); 77 ~UIYabause(); 78 79 void swapBuffers(); 80 virtual bool eventFilter( QObject* o, QEvent* e ); 81 82 protected: 83 YabauseGLProxy* mYabauseGL; 84 YabauseThread* mYabauseThread; 85 QDockWidget* mLogDock; 86 QTextEdit* teLog; 87 bool mCanLog; 88 bool mInit; 89 QList <cheatsearch_struct> search; 90 int searchType; 91 QList <supportedRes_struct> supportedResolutions; 92 int oldMouseX, oldMouseY; 93 bool mouseCaptured; 94 95 float mouseXRatio, mouseYRatio; 96 int mouseSensitivity; 97 bool emulateMouse; 98 int showMenuBarHeight; 99 QTimer* hideMouseTimer; 100 QTimer* mouseCursorTimer; 101 QList <translation_struct> translations; 102 virtual void showEvent( QShowEvent* event ); 103 virtual void closeEvent( QCloseEvent* event ); 104 virtual void keyPressEvent( QKeyEvent* event ); 105 virtual void keyReleaseEvent( QKeyEvent* event ); 106 virtual void leaveEvent(QEvent * event); 107 virtual void mousePressEvent( QMouseEvent* event ); 108 virtual void mouseReleaseEvent( QMouseEvent* event ); 109 virtual void mouseMoveEvent( QMouseEvent* event ); 110 virtual void resizeEvent( QResizeEvent* event ); 111 112 public slots: 113 void appendLog( const char* msg ); 114 void pause( bool paused ); 115 void reset(); 116 void hideMouse(); 117 void cursorRestore(); 118 void toggleEmulateMouse( bool enable ); 119 void disableGL(); 120 121 void breakpointHandlerSH1(bool displayMessage); 122 void breakpointHandlerMSH2(bool displayMessage); 123 void breakpointHandlerSSH2(bool displayMessage); 124 void breakpointHandlerM68K(); 125 void breakpointHandlerSCUDSP(); 126 void breakpointHandlerSCSPDSP(); 127 protected slots: 128 void errorReceived( const QString& error, bool internal = true ); 129 void sizeRequested( const QSize& size ); 130 void fixAspectRatio( int width ); 131 void getSupportedResolutions(); 132 int isResolutionValid( int width, int height, int bpp, int freq ); 133 int findBestVideoFreq( int width, int height, int bpp, int videoFormat ); 134 void toggleFullscreen( int width, int height, bool f, int videoFormat ); 135 void fullscreenRequested( bool fullscreen ); 136 void refreshStatesActions(); 137 void adjustHeight(int & height); 138 void resizeIntegerScaling(); 139 // file menu 140 void on_aFileSettings_triggered(); 141 void on_aFileOpenISO_triggered(); 142 void on_aFileOpenCDRom_triggered(); 143 void on_aFileOpenSSF_triggered(); 144 void on_mFileSaveState_triggered( QAction* ); 145 void on_mFileLoadState_triggered( QAction* ); 146 void on_aFileSaveStateAs_triggered(); 147 void on_aFileLoadStateAs_triggered(); 148 void on_aFileScreenshot_triggered(); 149 void on_aFileQuit_triggered(); 150 // emulation menu 151 void on_aEmulationRun_triggered(); 152 void on_aEmulationPause_triggered(); 153 void on_aEmulationReset_triggered(); 154 void on_aEmulationFrameSkipLimiter_toggled( bool toggled ); 155 // tools 156 void on_aToolsBackupManager_triggered(); 157 void on_aToolsCheatsList_triggered(); 158 void on_aToolsCheatSearch_triggered(); 159 void on_aToolsTransfer_triggered(); 160 // view menu 161 void on_aViewFPS_triggered( bool toggled ); 162 void on_aViewLayerVdp1_triggered(); 163 void on_aViewLayerNBG0_triggered(); 164 void on_aViewLayerNBG1_triggered(); 165 void on_aViewLayerNBG2_triggered(); 166 void on_aViewLayerNBG3_triggered(); 167 void on_aViewLayerRBG0_triggered(); 168 void on_aViewFullscreen_triggered( bool b ); 169 // debug menu 170 void on_aViewDebugMSH2_triggered(); 171 void on_aViewDebugSSH2_triggered(); 172 void on_aViewDebugVDP1_triggered(); 173 void on_aViewDebugVDP2_triggered(); 174 void on_aViewDebugM68K_triggered(); 175 void on_aViewDebugSCSP_triggered(); 176 void on_aViewDebugSCSPChan_triggered(); 177 void on_aViewDebugSCSPDSP_triggered(); 178 void on_aViewDebugSCUDSP_triggered(); 179 void on_aViewDebugSH1_triggered(); 180 void on_aViewDebugMemoryEditor_triggered(); 181 void on_aTraceLogging_triggered( bool toggled ); 182 // help menu 183 void on_aHelpDocumentation_triggered(); 184 void on_aHelpCompatibilityList_triggered(); 185 void on_aHelpAbout_triggered(); 186 // toolbar 187 void on_aSound_triggered(); 188 void on_aVideoDriver_triggered(); 189 void on_cbSound_toggled( bool toggled ); 190 void on_sVolume_valueChanged( int value ); 191 void on_cbVideoDriver_currentIndexChanged( int id ); 192 }; 193 194 #endif // UIYABAUSE_H 195