2013-11-20 01:50:16 +00:00
// Qt Desktop UI: works on Linux, Windows and Mac OSX
2013-01-13 23:29:42 +00:00
# include "mainwindow.h"
2013-11-20 01:50:16 +00:00
# include <QApplication>
# include <QDesktopServices>
# include <QDesktopWidget>
# include <QFileDialog>
# include <QMessageBox>
2014-02-10 15:28:01 +00:00
# include "base/display.h"
2017-04-28 03:03:50 +00:00
# include "base/NativeApp.h"
2013-01-13 23:29:42 +00:00
# include "Core/MIPS/MIPSDebugInterface.h"
2013-02-10 15:36:06 +00:00
# include "Core/Debugger/SymbolMap.h"
2013-01-13 23:29:42 +00:00
# include "Core/SaveState.h"
# include "Core/System.h"
2013-02-01 01:08:01 +00:00
# include "GPU/GPUInterface.h"
2013-11-05 06:00:13 +00:00
# include "UI/GamepadEmu.h"
2013-01-13 23:29:42 +00:00
2014-09-24 21:24:23 +00:00
MainWindow : : MainWindow ( QWidget * parent , bool fullscreen ) :
2013-01-15 16:16:07 +00:00
QMainWindow ( parent ) ,
2013-11-20 14:06:40 +00:00
currentLanguage ( " en " ) ,
2013-01-13 23:29:42 +00:00
nextState ( CORE_POWERDOWN ) ,
2013-10-19 20:59:48 +00:00
lastUIState ( UISTATE_MENU ) ,
2013-02-10 15:36:06 +00:00
dialogDisasm ( 0 ) ,
2013-02-17 00:06:06 +00:00
memoryWindow ( 0 ) ,
memoryTexWindow ( 0 ) ,
2013-11-20 14:06:40 +00:00
displaylistWindow ( 0 )
2013-01-13 23:29:42 +00:00
{
2014-09-22 18:07:03 +00:00
QDesktopWidget * desktop = QApplication : : desktop ( ) ;
2014-09-24 21:24:23 +00:00
int screenNum = QProcessEnvironment : : systemEnvironment ( ) . value ( " SDL_VIDEO_FULLSCREEN_HEAD " , " 0 " ) . toInt ( ) ;
// Move window to top left coordinate of selected screen
QRect rect = desktop - > screenGeometry ( screenNum ) ;
2014-09-22 18:07:03 +00:00
move ( rect . topLeft ( ) ) ;
2014-10-15 20:33:38 +00:00
2014-07-10 12:41:26 +00:00
SetGameTitle ( " " ) ;
2013-11-26 15:45:38 +00:00
emugl = new MainUI ( this ) ;
2013-11-22 06:15:10 +00:00
2013-11-19 04:02:24 +00:00
setCentralWidget ( emugl ) ;
2013-11-22 06:15:10 +00:00
createMenus ( ) ;
updateMenus ( ) ;
2016-05-21 16:22:14 +00:00
SetWindowScale ( - 1 ) ;
2014-09-23 20:27:18 +00:00
2014-09-24 21:24:23 +00:00
if ( fullscreen )
2014-09-23 20:27:18 +00:00
fullscrAct ( ) ;
2013-01-15 16:16:07 +00:00
2013-11-26 15:45:38 +00:00
QObject : : connect ( emugl , SIGNAL ( doubleClick ( ) ) , this , SLOT ( fullscrAct ( ) ) ) ;
QObject : : connect ( emugl , SIGNAL ( newFrame ( ) ) , this , SLOT ( newFrame ( ) ) ) ;
2013-01-13 23:29:42 +00:00
}
2013-02-19 20:59:53 +00:00
void MainWindow : : ShowMemory ( u32 addr )
2013-01-13 23:29:42 +00:00
{
2013-02-19 20:59:53 +00:00
if ( memoryWindow )
memoryWindow - > Goto ( addr ) ;
2013-01-13 23:29:42 +00:00
}
2013-07-07 07:47:50 +00:00
inline float clamp1 ( float x ) {
if ( x > 1.0f ) return 1.0f ;
if ( x < - 1.0f ) return - 1.0f ;
return x ;
}
2013-11-26 15:45:38 +00:00
void MainWindow : : newFrame ( )
2013-01-13 23:29:42 +00:00
{
2014-06-24 14:34:13 +00:00
if ( lastUIState ! = GetUIState ( ) ) {
lastUIState = GetUIState ( ) ;
2013-11-04 12:30:38 +00:00
if ( lastUIState = = UISTATE_INGAME & & g_Config . bFullScreen & & ! QApplication : : overrideCursor ( ) & & ! g_Config . bShowTouchControls )
QApplication : : setOverrideCursor ( QCursor ( Qt : : BlankCursor ) ) ;
if ( lastUIState ! = UISTATE_INGAME & & g_Config . bFullScreen & & QApplication : : overrideCursor ( ) )
QApplication : : restoreOverrideCursor ( ) ;
2013-11-19 10:18:11 +00:00
updateMenus ( ) ;
2013-04-20 10:43:55 +00:00
}
2018-01-31 17:35:48 +00:00
std : : unique_lock < std : : mutex > lock ( msgMutex_ ) ;
while ( ! msgQueue_ . empty ( ) ) {
MainWindowMsg msg = msgQueue_ . front ( ) ;
msgQueue_ . pop ( ) ;
switch ( msg ) {
case MainWindowMsg : : BOOT_DONE :
bootDone ( ) ;
break ;
}
}
2013-02-10 15:36:06 +00:00
}
2013-11-19 10:18:11 +00:00
void MainWindow : : updateMenus ( )
2013-01-13 23:29:42 +00:00
{
2013-11-19 04:02:24 +00:00
foreach ( QAction * action , anisotropicGroup - > actions ( ) ) {
if ( g_Config . iAnisotropyLevel = = action - > data ( ) . toInt ( ) ) {
action - > setChecked ( true ) ;
break ;
}
}
foreach ( QAction * action , screenGroup - > actions ( ) ) {
2016-05-21 16:22:14 +00:00
int width = ( g_Config . IsPortrait ( ) ? 272 : 480 ) * action - > data ( ) . toInt ( ) ;
int height = ( g_Config . IsPortrait ( ) ? 480 : 272 ) * action - > data ( ) . toInt ( ) ;
if ( g_Config . iWindowWidth = = width & & g_Config . iWindowHeight = = height ) {
2013-11-19 04:02:24 +00:00
action - > setChecked ( true ) ;
break ;
}
}
2015-11-13 21:30:32 +00:00
foreach ( QAction * action , displayLayoutGroup - > actions ( ) ) {
2015-12-21 05:32:05 +00:00
if ( g_Config . iSmallDisplayZoomType = = action - > data ( ) . toInt ( ) ) {
2015-11-13 21:30:32 +00:00
2017-04-28 03:03:50 +00:00
NativeMessageReceived ( " gpu_resized " , " " ) ;
2015-11-13 21:30:32 +00:00
action - > setChecked ( true ) ;
break ;
}
}
2013-11-19 04:02:24 +00:00
int defaultLevel = LogManager : : GetInstance ( ) - > GetLogLevel ( LogTypes : : COMMON ) ;
foreach ( QAction * action , defaultLogGroup - > actions ( ) ) {
if ( defaultLevel = = action - > data ( ) . toInt ( ) ) {
action - > setChecked ( true ) ;
break ;
}
}
int g3dLevel = LogManager : : GetInstance ( ) - > GetLogLevel ( LogTypes : : G3D ) ;
foreach ( QAction * action , g3dLogGroup - > actions ( ) ) {
if ( g3dLevel = = action - > data ( ) . toInt ( ) ) {
action - > setChecked ( true ) ;
break ;
}
}
int hleLevel = LogManager : : GetInstance ( ) - > GetLogLevel ( LogTypes : : HLE ) ;
foreach ( QAction * action , hleLogGroup - > actions ( ) ) {
if ( hleLevel = = action - > data ( ) . toInt ( ) ) {
action - > setChecked ( true ) ;
break ;
}
}
2013-11-22 04:05:36 +00:00
emit updateMenu ( ) ;
2013-02-19 20:59:53 +00:00
}
2013-01-13 23:29:42 +00:00
2018-01-31 17:35:48 +00:00
void MainWindow : : bootDone ( )
2013-02-19 20:59:53 +00:00
{
dialogDisasm = new Debugger_Disasm ( currentDebugMIPS , this , this ) ;
if ( g_Config . bShowDebuggerOnLoad )
dialogDisasm - > show ( ) ;
2013-01-13 23:29:42 +00:00
2013-02-19 20:59:53 +00:00
if ( g_Config . bFullScreen ! = isFullScreen ( ) )
2013-11-22 04:05:36 +00:00
fullscrAct ( ) ;
2013-02-13 22:07:02 +00:00
2013-02-19 20:59:53 +00:00
memoryWindow = new Debugger_Memory ( currentDebugMIPS , this , this ) ;
memoryTexWindow = new Debugger_MemoryTex ( this ) ;
2017-02-06 10:55:54 +00:00
displaylistWindow = new Debugger_DisplayList ( currentDebugMIPS , gpu - > GetDrawContext ( ) , this , this ) ;
2013-02-13 22:07:02 +00:00
2013-02-19 20:59:53 +00:00
notifyMapsLoaded ( ) ;
if ( nextState = = CORE_RUNNING )
2013-11-22 04:05:36 +00:00
runAct ( ) ;
2013-11-19 10:18:11 +00:00
updateMenus ( ) ;
2013-01-13 23:29:42 +00:00
}
2018-01-31 17:35:48 +00:00
/* SIGNALS */
2013-11-22 04:05:36 +00:00
void MainWindow : : openAct ( )
2013-01-13 23:29:42 +00:00
{
2013-02-19 20:59:53 +00:00
QString filename = QFileDialog : : getOpenFileName ( NULL , " Load File " , g_Config . currentDirectory . c_str ( ) , " PSP ROMs (*.pbp *.elf *.iso *.cso *.prx) " ) ;
if ( QFile : : exists ( filename ) )
2013-01-13 23:29:42 +00:00
{
2013-02-19 20:59:53 +00:00
QFileInfo info ( filename ) ;
g_Config . currentDirectory = info . absolutePath ( ) . toStdString ( ) ;
2013-04-18 15:40:30 +00:00
NativeMessageReceived ( " boot " , filename . toStdString ( ) . c_str ( ) ) ;
2013-01-13 23:29:42 +00:00
}
}
2013-11-22 04:05:36 +00:00
void MainWindow : : closeAct ( )
2013-01-13 23:29:42 +00:00
{
if ( dialogDisasm )
dialogDisasm - > Stop ( ) ;
2013-02-19 20:59:53 +00:00
2013-02-10 15:36:06 +00:00
if ( dialogDisasm & & dialogDisasm - > isVisible ( ) )
dialogDisasm - > close ( ) ;
if ( memoryWindow & & memoryWindow - > isVisible ( ) )
memoryWindow - > close ( ) ;
2013-02-17 00:06:06 +00:00
if ( memoryTexWindow & & memoryTexWindow - > isVisible ( ) )
memoryTexWindow - > close ( ) ;
if ( displaylistWindow & & displaylistWindow - > isVisible ( ) )
displaylistWindow - > close ( ) ;
2013-01-13 23:29:42 +00:00
2013-04-18 15:40:30 +00:00
NativeMessageReceived ( " stop " , " " ) ;
2013-02-12 00:36:16 +00:00
SetGameTitle ( " " ) ;
2013-01-13 23:29:42 +00:00
}
2016-05-28 04:25:05 +00:00
void SaveStateActionFinished ( bool result , const std : : string & message , void * userdata )
2013-01-13 23:29:42 +00:00
{
// TODO: Improve messaging?
if ( ! result )
{
QMessageBox msgBox ;
msgBox . setWindowTitle ( " Load Save State " ) ;
2013-01-15 16:16:07 +00:00
msgBox . setText ( " Savestate failure. Please try again later " ) ;
2013-01-13 23:29:42 +00:00
msgBox . exec ( ) ;
return ;
}
}
2013-11-22 04:05:36 +00:00
void MainWindow : : qlstateAct ( )
2013-02-19 20:59:53 +00:00
{
2015-09-23 17:29:39 +00:00
std : : string gamePath = PSP_CoreParameter ( ) . fileToStart ;
SaveState : : LoadSlot ( gamePath , 0 , SaveStateActionFinished , this ) ;
2013-02-19 20:59:53 +00:00
}
2013-11-22 04:05:36 +00:00
void MainWindow : : qsstateAct ( )
2013-02-19 20:59:53 +00:00
{
2015-09-23 17:29:39 +00:00
std : : string gamePath = PSP_CoreParameter ( ) . fileToStart ;
SaveState : : SaveSlot ( gamePath , 0 , SaveStateActionFinished , this ) ;
2013-02-19 20:59:53 +00:00
}
2013-11-22 04:05:36 +00:00
void MainWindow : : lstateAct ( )
2013-01-13 23:29:42 +00:00
{
QFileDialog dialog ( 0 , " Load state " ) ;
dialog . setFileMode ( QFileDialog : : ExistingFile ) ;
QStringList filters ;
filters < < " Save States (*.ppst) " < < " |All files (*.*) " ;
dialog . setNameFilters ( filters ) ;
dialog . setAcceptMode ( QFileDialog : : AcceptOpen ) ;
if ( dialog . exec ( ) )
{
2013-02-19 20:59:53 +00:00
QStringList fileNames = dialog . selectedFiles ( ) ;
2013-01-13 23:29:42 +00:00
SaveState : : Load ( fileNames [ 0 ] . toStdString ( ) , SaveStateActionFinished , this ) ;
}
}
2013-11-22 04:05:36 +00:00
void MainWindow : : sstateAct ( )
2013-01-13 23:29:42 +00:00
{
QFileDialog dialog ( 0 , " Save state " ) ;
dialog . setFileMode ( QFileDialog : : AnyFile ) ;
dialog . setAcceptMode ( QFileDialog : : AcceptSave ) ;
QStringList filters ;
filters < < " Save States (*.ppst) " < < " |All files (*.*) " ;
dialog . setNameFilters ( filters ) ;
if ( dialog . exec ( ) )
{
2013-02-19 20:59:53 +00:00
QStringList fileNames = dialog . selectedFiles ( ) ;
2013-01-13 23:29:42 +00:00
SaveState : : Save ( fileNames [ 0 ] . toStdString ( ) , SaveStateActionFinished , this ) ;
}
}
2013-11-22 04:05:36 +00:00
void MainWindow : : exitAct ( )
2013-01-13 23:29:42 +00:00
{
2013-11-22 04:05:36 +00:00
closeAct ( ) ;
2013-02-19 20:59:53 +00:00
QApplication : : exit ( 0 ) ;
2013-01-13 23:29:42 +00:00
}
2013-11-22 04:05:36 +00:00
void MainWindow : : runAct ( )
2013-01-13 23:29:42 +00:00
{
2013-04-18 15:40:30 +00:00
NativeMessageReceived ( " run " , " " ) ;
2013-01-13 23:29:42 +00:00
}
2013-11-22 04:05:36 +00:00
void MainWindow : : pauseAct ( )
2013-01-13 23:29:42 +00:00
{
2013-04-18 15:40:30 +00:00
NativeMessageReceived ( " pause " , " " ) ;
2013-01-13 23:29:42 +00:00
}
2013-11-22 04:05:36 +00:00
void MainWindow : : resetAct ( )
2013-01-13 23:29:42 +00:00
{
2013-02-19 20:59:53 +00:00
if ( dialogDisasm )
dialogDisasm - > Stop ( ) ;
2013-01-13 23:29:42 +00:00
2013-02-19 20:59:53 +00:00
if ( dialogDisasm )
dialogDisasm - > close ( ) ;
if ( memoryWindow )
memoryWindow - > close ( ) ;
if ( memoryTexWindow )
memoryTexWindow - > close ( ) ;
if ( displaylistWindow )
displaylistWindow - > close ( ) ;
2013-01-13 23:29:42 +00:00
2013-04-18 15:40:30 +00:00
NativeMessageReceived ( " reset " , " " ) ;
2013-01-13 23:29:42 +00:00
}
2013-11-22 04:05:36 +00:00
void MainWindow : : runonloadAct ( )
2013-01-13 23:29:42 +00:00
{
2013-11-22 04:05:36 +00:00
g_Config . bAutoRun = ! g_Config . bAutoRun ;
2013-01-13 23:29:42 +00:00
}
2013-11-22 04:05:36 +00:00
void MainWindow : : lmapAct ( )
2013-01-13 23:29:42 +00:00
{
2013-02-10 15:36:06 +00:00
QFileDialog dialog ( 0 , " Load .MAP " ) ;
dialog . setFileMode ( QFileDialog : : ExistingFile ) ;
QStringList filters ;
filters < < " Maps (*.map) " < < " |All files (*.*) " ;
dialog . setNameFilters ( filters ) ;
dialog . setAcceptMode ( QFileDialog : : AcceptOpen ) ;
QStringList fileNames ;
if ( dialog . exec ( ) )
fileNames = dialog . selectedFiles ( ) ;
2014-08-26 19:16:06 +00:00
if ( fileNames . count ( ) > 0 )
{
QString fileName = QFileInfo ( fileNames [ 0 ] ) . absoluteFilePath ( ) ;
2015-11-01 00:09:15 +00:00
g_symbolMap - > LoadSymbolMap ( fileName . toStdString ( ) . c_str ( ) ) ;
2013-02-19 20:59:53 +00:00
notifyMapsLoaded ( ) ;
2013-02-10 15:36:06 +00:00
}
2013-01-13 23:29:42 +00:00
}
2013-11-22 04:05:36 +00:00
void MainWindow : : smapAct ( )
2013-01-13 23:29:42 +00:00
{
2013-02-10 15:36:06 +00:00
QFileDialog dialog ( 0 , " Save .MAP " ) ;
dialog . setFileMode ( QFileDialog : : AnyFile ) ;
dialog . setAcceptMode ( QFileDialog : : AcceptSave ) ;
QStringList filters ;
filters < < " Save .MAP (*.map) " < < " |All files (*.*) " ;
dialog . setNameFilters ( filters ) ;
QStringList fileNames ;
if ( dialog . exec ( ) )
{
fileNames = dialog . selectedFiles ( ) ;
2015-11-01 00:09:15 +00:00
g_symbolMap - > SaveSymbolMap ( fileNames [ 0 ] . toStdString ( ) . c_str ( ) ) ;
2013-02-10 15:36:06 +00:00
}
2013-01-13 23:29:42 +00:00
}
2013-11-22 04:05:36 +00:00
void MainWindow : : resetTableAct ( )
2013-01-13 23:29:42 +00:00
{
2015-11-01 00:09:15 +00:00
g_symbolMap - > Clear ( ) ;
2013-02-19 20:59:53 +00:00
notifyMapsLoaded ( ) ;
}
2013-11-22 04:05:36 +00:00
void MainWindow : : dumpNextAct ( )
2013-02-19 20:59:53 +00:00
{
gpu - > DumpNextFrame ( ) ;
2013-01-13 23:29:42 +00:00
}
2013-11-22 04:05:36 +00:00
void MainWindow : : disasmAct ( )
2013-01-13 23:29:42 +00:00
{
if ( dialogDisasm )
dialogDisasm - > show ( ) ;
}
2013-11-22 04:05:36 +00:00
void MainWindow : : dpyListAct ( )
2013-02-19 20:59:53 +00:00
{
if ( displaylistWindow )
displaylistWindow - > show ( ) ;
}
2013-11-22 04:05:36 +00:00
void MainWindow : : consoleAct ( )
2013-02-19 20:59:53 +00:00
{
LogManager : : GetInstance ( ) - > GetConsoleListener ( ) - > Show ( LogManager : : GetInstance ( ) - > GetConsoleListener ( ) - > Hidden ( ) ) ;
}
2013-11-22 04:05:36 +00:00
void MainWindow : : memviewAct ( )
2013-01-13 23:29:42 +00:00
{
2013-02-10 15:36:06 +00:00
if ( memoryWindow )
memoryWindow - > show ( ) ;
2013-01-13 23:29:42 +00:00
}
2013-11-22 04:05:36 +00:00
void MainWindow : : memviewTexAct ( )
2013-01-13 23:29:42 +00:00
{
2013-02-19 20:59:53 +00:00
if ( memoryTexWindow )
memoryTexWindow - > show ( ) ;
}
2014-09-23 20:27:18 +00:00
void MainWindow : : raiseTopMost ( )
{
setWindowState ( ( windowState ( ) & ~ Qt : : WindowMinimized ) | Qt : : WindowActive ) ;
raise ( ) ;
activateWindow ( ) ;
}
2013-11-22 04:05:36 +00:00
void MainWindow : : fullscrAct ( )
2013-01-13 23:29:42 +00:00
{
2013-02-01 01:08:01 +00:00
if ( isFullScreen ( ) ) {
2013-02-10 15:36:06 +00:00
g_Config . bFullScreen = false ;
2013-11-21 03:48:16 +00:00
menuBar ( ) - > show ( ) ;
2013-11-22 04:05:36 +00:00
updateMenus ( ) ;
2013-11-21 03:48:16 +00:00
2013-02-01 01:08:01 +00:00
showNormal ( ) ;
2016-05-21 16:22:14 +00:00
SetWindowScale ( - 1 ) ;
2014-02-10 15:28:01 +00:00
InitPadLayout ( dp_xres , dp_yres ) ;
2014-06-24 14:34:13 +00:00
if ( GetUIState ( ) = = UISTATE_INGAME & & QApplication : : overrideCursor ( ) )
2013-11-04 12:30:38 +00:00
QApplication : : restoreOverrideCursor ( ) ;
2013-01-13 23:29:42 +00:00
}
else {
2013-02-10 15:36:06 +00:00
g_Config . bFullScreen = true ;
2013-11-21 03:48:16 +00:00
menuBar ( ) - > hide ( ) ;
2013-02-01 01:08:01 +00:00
2013-11-20 14:06:40 +00:00
emugl - > setFixedSize ( QWIDGETSIZE_MAX , QWIDGETSIZE_MAX ) ;
2013-11-21 03:24:33 +00:00
setMaximumSize ( QWIDGETSIZE_MAX , QWIDGETSIZE_MAX ) ;
2013-11-28 03:27:10 +00:00
setFixedSize ( QWIDGETSIZE_MAX , QWIDGETSIZE_MAX ) ;
2013-02-01 01:08:01 +00:00
showFullScreen ( ) ;
2017-04-28 03:03:50 +00:00
NativeMessageReceived ( " gpu_resized " , " " ) ;
2014-02-10 15:28:01 +00:00
InitPadLayout ( dp_xres , dp_yres ) ;
2014-06-24 14:34:13 +00:00
if ( GetUIState ( ) = = UISTATE_INGAME & & ! g_Config . bShowTouchControls )
2013-11-04 12:30:38 +00:00
QApplication : : setOverrideCursor ( QCursor ( Qt : : BlankCursor ) ) ;
2013-01-13 23:29:42 +00:00
}
2014-09-23 20:27:18 +00:00
2014-09-24 21:24:23 +00:00
QTimer : : singleShot ( 1000 , this , SLOT ( raiseTopMost ( ) ) ) ;
2013-01-13 23:29:42 +00:00
}
2013-11-22 04:05:36 +00:00
void MainWindow : : websiteAct ( )
2013-01-13 23:29:42 +00:00
{
2017-11-14 11:50:27 +00:00
QDesktopServices : : openUrl ( QUrl ( " https://www.ppsspp.org/ " ) ) ;
2013-01-13 23:29:42 +00:00
}
2014-07-10 12:41:26 +00:00
void MainWindow : : forumAct ( )
{
2017-11-14 11:50:27 +00:00
QDesktopServices : : openUrl ( QUrl ( " https://forums.ppsspp.org/ " ) ) ;
2014-07-10 12:41:26 +00:00
}
2017-02-05 13:16:22 +00:00
void MainWindow : : gitAct ( )
{
QDesktopServices : : openUrl ( QUrl ( " https://github.com/hrydgard/ppsspp/ " ) ) ;
}
2013-11-22 04:05:36 +00:00
void MainWindow : : aboutAct ( )
2013-01-13 23:29:42 +00:00
{
2016-10-12 18:58:50 +00:00
QMessageBox : : about ( this , " About " , QString ( " PPSSPP Qt %1 \n \n "
2014-07-10 12:41:26 +00:00
" PSP emulator and debugger \n \n "
" Copyright (c) by Henrik Rydg \xc3 \xa5 rd and the PPSSPP Project 2012- \n "
" Qt port maintained by xSacha \n \n "
" Additional credits: \n "
" PSPSDK by #pspdev (freenode) \n "
" CISO decompression code by BOOSTER \n "
" zlib by Jean-loup Gailly (compression) and Mark Adler (decompression) \n "
" Qt project by Digia \n \n "
" All trademarks are property of their respective owners. \n "
2016-10-12 18:58:50 +00:00
" The emulator is for educational and development purposes only and it may not be used to play games you do not legally own. " ) . arg ( PPSSPP_GIT_VERSION ) ) ;
2013-01-13 23:29:42 +00:00
}
2013-02-19 20:59:53 +00:00
/* Private functions */
2016-05-21 16:22:14 +00:00
void MainWindow : : SetWindowScale ( int zoom ) {
2013-11-21 03:48:16 +00:00
if ( isFullScreen ( ) )
2013-11-22 04:05:36 +00:00
fullscrAct ( ) ;
2013-02-19 20:59:53 +00:00
2016-05-21 16:22:14 +00:00
int width , height ;
2016-05-21 17:43:24 +00:00
if ( zoom = = - 1 & & ( g_Config . iWindowWidth < = 0 | | g_Config . iWindowHeight < = 0 ) ) {
// Default to zoom level 2.
zoom = 2 ;
}
2016-05-21 16:22:14 +00:00
if ( zoom = = - 1 ) {
// Take the last setting.
width = g_Config . iWindowWidth ;
height = g_Config . iWindowHeight ;
} else {
// Update to the specified factor. Let's clamp first.
if ( zoom < 1 )
zoom = 1 ;
if ( zoom > 4 )
zoom = 4 ;
width = ( g_Config . IsPortrait ( ) ? 272 : 480 ) * zoom ;
height = ( g_Config . IsPortrait ( ) ? 480 : 272 ) * zoom ;
}
2013-02-19 20:59:53 +00:00
2016-05-21 16:22:14 +00:00
g_Config . iWindowWidth = width ;
g_Config . iWindowHeight = height ;
emugl - > setFixedSize ( g_Config . iWindowWidth , g_Config . iWindowHeight ) ;
setFixedSize ( sizeHint ( ) ) ;
2013-02-03 23:45:37 +00:00
}
2013-02-06 17:49:20 +00:00
2013-02-19 20:59:53 +00:00
void MainWindow : : SetGameTitle ( QString text )
2013-02-06 17:49:20 +00:00
{
2016-10-12 18:58:50 +00:00
QString title = QString ( " PPSSPP %1 " ) . arg ( PPSSPP_GIT_VERSION ) ;
2013-02-19 20:59:53 +00:00
if ( text ! = " " )
title + = QString ( " - %1 " ) . arg ( text ) ;
setWindowTitle ( title ) ;
2013-02-06 17:49:20 +00:00
}
2013-11-22 04:05:36 +00:00
void MainWindow : : loadLanguage ( const QString & language , bool translate )
2013-02-06 17:49:20 +00:00
{
if ( currentLanguage ! = language )
{
2014-07-10 12:41:26 +00:00
QLocale : : setDefault ( QLocale ( language ) ) ;
2013-11-19 09:32:31 +00:00
QApplication : : removeTranslator ( & translator ) ;
2014-07-10 12:41:26 +00:00
currentLanguage = language ;
2013-11-19 09:32:31 +00:00
if ( translator . load ( QString ( " :/languages/ppsspp_%1.qm " ) . arg ( language ) ) ) {
QApplication : : installTranslator ( & translator ) ;
}
2014-07-10 12:41:26 +00:00
if ( translate )
emit retranslate ( ) ;
2013-02-06 17:49:20 +00:00
}
}
2013-11-19 10:18:11 +00:00
void MainWindow : : createMenus ( )
2013-02-06 17:49:20 +00:00
{
2013-11-19 04:02:24 +00:00
// File
2013-11-22 04:05:36 +00:00
MenuTree * fileMenu = new MenuTree ( this , menuBar ( ) , QT_TR_NOOP ( " &File " ) ) ;
fileMenu - > add ( new MenuAction ( this , SLOT ( openAct ( ) ) , QT_TR_NOOP ( " &Open... " ) , QKeySequence : : Open ) )
- > addEnableState ( UISTATE_MENU ) ;
fileMenu - > add ( new MenuAction ( this , SLOT ( closeAct ( ) ) , QT_TR_NOOP ( " &Close " ) , QKeySequence : : Close ) )
- > addDisableState ( UISTATE_MENU ) ;
2013-11-19 11:02:43 +00:00
fileMenu - > addSeparator ( ) ;
2013-11-22 04:05:36 +00:00
fileMenu - > add ( new MenuAction ( this , SLOT ( qlstateAct ( ) ) , QT_TR_NOOP ( " Quickload State " ) , Qt : : Key_F4 ) )
- > addDisableState ( UISTATE_MENU ) ;
fileMenu - > add ( new MenuAction ( this , SLOT ( qsstateAct ( ) ) , QT_TR_NOOP ( " Quicksave State " ) , Qt : : Key_F2 ) )
- > addDisableState ( UISTATE_MENU ) ;
fileMenu - > add ( new MenuAction ( this , SLOT ( lstateAct ( ) ) , QT_TR_NOOP ( " &Load State File... " ) ) )
- > addDisableState ( UISTATE_MENU ) ;
fileMenu - > add ( new MenuAction ( this , SLOT ( sstateAct ( ) ) , QT_TR_NOOP ( " &Save State File... " ) ) )
- > addDisableState ( UISTATE_MENU ) ;
2013-11-19 11:02:43 +00:00
fileMenu - > addSeparator ( ) ;
2013-11-22 04:05:36 +00:00
fileMenu - > add ( new MenuAction ( this , SLOT ( exitAct ( ) ) , QT_TR_NOOP ( " E&xit " ) , QKeySequence : : Quit ) ) ;
2013-11-19 04:02:24 +00:00
// Emulation
2013-11-22 04:05:36 +00:00
MenuTree * emuMenu = new MenuTree ( this , menuBar ( ) , QT_TR_NOOP ( " &Emulation " ) ) ;
emuMenu - > add ( new MenuAction ( this , SLOT ( runAct ( ) ) , QT_TR_NOOP ( " &Run " ) , Qt : : Key_F7 ) )
- > addEnableStepping ( ) - > addEnableState ( UISTATE_PAUSEMENU ) ;
emuMenu - > add ( new MenuAction ( this , SLOT ( pauseAct ( ) ) , QT_TR_NOOP ( " &Pause " ) , Qt : : Key_F8 ) )
- > addEnableState ( UISTATE_INGAME ) ;
emuMenu - > add ( new MenuAction ( this , SLOT ( resetAct ( ) ) , QT_TR_NOOP ( " Re&set " ) ) )
- > addEnableState ( UISTATE_INGAME ) ;
2013-11-19 11:02:43 +00:00
emuMenu - > addSeparator ( ) ;
2013-11-22 04:05:36 +00:00
emuMenu - > add ( new MenuAction ( this , SLOT ( runonloadAct ( ) ) , QT_TR_NOOP ( " Run on &load " ) ) )
- > addEventChecked ( & g_Config . bAutoRun ) ;
2013-11-19 04:02:24 +00:00
// Debug
2013-11-22 04:05:36 +00:00
MenuTree * debugMenu = new MenuTree ( this , menuBar ( ) , QT_TR_NOOP ( " De&bug " ) ) ;
debugMenu - > add ( new MenuAction ( this , SLOT ( lmapAct ( ) ) , QT_TR_NOOP ( " Load Map File... " ) ) )
- > addDisableState ( UISTATE_MENU ) ;
debugMenu - > add ( new MenuAction ( this , SLOT ( smapAct ( ) ) , QT_TR_NOOP ( " Save Map File... " ) ) )
- > addDisableState ( UISTATE_MENU ) ;
debugMenu - > add ( new MenuAction ( this , SLOT ( resetTableAct ( ) ) , QT_TR_NOOP ( " Reset Symbol Table " ) ) )
- > addDisableState ( UISTATE_MENU ) ;
2013-11-19 11:02:43 +00:00
debugMenu - > addSeparator ( ) ;
2013-11-22 04:05:36 +00:00
debugMenu - > add ( new MenuAction ( this , SLOT ( dumpNextAct ( ) ) , QT_TR_NOOP ( " Dump next frame to log " ) ) )
- > addDisableState ( UISTATE_MENU ) ;
2013-12-07 18:57:06 +00:00
debugMenu - > add ( new MenuAction ( this , SLOT ( takeScreen ( ) ) , QT_TR_NOOP ( " Take Screenshot " ) , Qt : : Key_F12 ) )
- > addDisableState ( UISTATE_MENU ) ;
2013-11-19 11:02:43 +00:00
debugMenu - > addSeparator ( ) ;
2013-11-22 04:05:36 +00:00
debugMenu - > add ( new MenuAction ( this , SLOT ( disasmAct ( ) ) , QT_TR_NOOP ( " Disassembly " ) , Qt : : CTRL + Qt : : Key_D ) )
- > addDisableState ( UISTATE_MENU ) ;
2014-09-19 12:39:22 +00:00
//commented out until someone bothers to maintain it
//debugMenu->add(new MenuAction(this, SLOT(dpyListAct()), QT_TR_NOOP("Display List...")))
// ->addDisableState(UISTATE_MENU);
2013-11-22 04:05:36 +00:00
debugMenu - > add ( new MenuAction ( this , SLOT ( consoleAct ( ) ) , QT_TR_NOOP ( " Log Console " ) ) )
- > addDisableState ( UISTATE_MENU ) ;
debugMenu - > add ( new MenuAction ( this , SLOT ( memviewAct ( ) ) , QT_TR_NOOP ( " Memory View " ) ) )
- > addDisableState ( UISTATE_MENU ) ;
debugMenu - > add ( new MenuAction ( this , SLOT ( memviewTexAct ( ) ) , QT_TR_NOOP ( " Memory View Texture " ) ) )
- > addDisableState ( UISTATE_MENU ) ;
2013-11-19 04:02:24 +00:00
// Options
2013-11-22 04:05:36 +00:00
MenuTree * optionsMenu = new MenuTree ( this , menuBar ( ) , QT_TR_NOOP ( " &Options " ) ) ;
2013-11-19 04:02:24 +00:00
// - Core
2013-11-22 04:05:36 +00:00
MenuTree * coreMenu = new MenuTree ( this , optionsMenu , QT_TR_NOOP ( " &Core " ) ) ;
coreMenu - > add ( new MenuAction ( this , SLOT ( vertexDynarecAct ( ) ) , QT_TR_NOOP ( " &Vertex Decoder Dynarec " ) ) )
- > addEventChecked ( & g_Config . bVertexDecoderJit ) ;
coreMenu - > add ( new MenuAction ( this , SLOT ( fastmemAct ( ) ) , QT_TR_NOOP ( " Fast &Memory (unstable) " ) ) )
- > addEventChecked ( & g_Config . bFastMemory ) ;
coreMenu - > add ( new MenuAction ( this , SLOT ( ignoreIllegalAct ( ) ) , QT_TR_NOOP ( " &Ignore Illegal reads/writes " ) ) )
- > addEventChecked ( & g_Config . bIgnoreBadMemAccess ) ;
2013-11-19 04:02:24 +00:00
// - Video
2013-11-22 04:05:36 +00:00
MenuTree * videoMenu = new MenuTree ( this , optionsMenu , QT_TR_NOOP ( " &Video " ) ) ;
2013-11-19 04:02:24 +00:00
// - Anisotropic Filtering
2013-11-22 04:05:36 +00:00
MenuTree * anisotropicMenu = new MenuTree ( this , videoMenu , QT_TR_NOOP ( " &Anisotropic Filtering " ) ) ;
anisotropicGroup = new MenuActionGroup ( this , anisotropicMenu , SLOT ( anisotropicGroup_triggered ( QAction * ) ) ,
QStringList ( ) < < " Off " < < " 2x " < < " 4x " < < " 8x " < < " 16x " ,
QList < int > ( ) < < 0 < < 1 < < 2 < < 3 < < 4 ) ;
videoMenu - > add ( new MenuAction ( this , SLOT ( bufferRenderAct ( ) ) , QT_TR_NOOP ( " &Buffered Rendering " ) , Qt : : Key_F5 ) )
- > addEventChecked ( & g_Config . iRenderingMode ) ;
videoMenu - > add ( new MenuAction ( this , SLOT ( linearAct ( ) ) , QT_TR_NOOP ( " &Linear Filtering " ) ) )
- > addEventChecked ( & g_Config . iTexFiltering ) ;
2013-11-19 04:02:24 +00:00
videoMenu - > addSeparator ( ) ;
// - Screen Size
2013-11-22 04:05:36 +00:00
MenuTree * screenMenu = new MenuTree ( this , videoMenu , QT_TR_NOOP ( " &Screen Size " ) ) ;
screenGroup = new MenuActionGroup ( this , screenMenu , SLOT ( screenGroup_triggered ( QAction * ) ) ,
QStringList ( ) < < " 1x " < < " 2x " < < " 3x " < < " 4x " ,
QList < int > ( ) < < 1 < < 2 < < 3 < < 4 ,
2013-11-19 10:18:11 +00:00
QList < int > ( ) < < Qt : : CTRL + Qt : : Key_1 < < Qt : : CTRL + Qt : : Key_2 < < Qt : : CTRL + Qt : : Key_3 < < Qt : : CTRL + Qt : : Key_4 ) ;
2013-11-22 04:05:36 +00:00
2015-11-13 21:30:32 +00:00
MenuTree * displayLayoutMenu = new MenuTree ( this , videoMenu , QT_TR_NOOP ( " &Display Layout Options " ) ) ;
displayLayoutGroup = new MenuActionGroup ( this , displayLayoutMenu , SLOT ( displayLayoutGroup_triggered ( QAction * ) ) ,
2015-12-21 05:32:05 +00:00
QStringList ( ) < < " Stretched " < < " Partialy stretched " < < " Auto Scaling " < < " Manual Scaling " ,
QList < int > ( ) < < 0 < < 1 < < 2 < < 3 ) ;
2013-11-19 04:02:24 +00:00
videoMenu - > addSeparator ( ) ;
2013-11-22 04:05:36 +00:00
videoMenu - > add ( new MenuAction ( this , SLOT ( transformAct ( ) ) , QT_TR_NOOP ( " &Hardware Transform " ) , Qt : : Key_F6 ) )
- > addEventChecked ( & g_Config . bHardwareTransform ) ;
videoMenu - > add ( new MenuAction ( this , SLOT ( vertexCacheAct ( ) ) , QT_TR_NOOP ( " &Vertex Cache " ) ) )
- > addEventChecked ( & g_Config . bVertexCache ) ;
videoMenu - > add ( new MenuAction ( this , SLOT ( frameskipAct ( ) ) , QT_TR_NOOP ( " &Frameskip " ) ) )
- > addEventChecked ( & g_Config . iFrameSkip ) ;
optionsMenu - > add ( new MenuAction ( this , SLOT ( audioAct ( ) ) , QT_TR_NOOP ( " &Audio " ) ) )
- > addEventChecked ( & g_Config . bEnableSound ) ;
2013-11-19 04:02:24 +00:00
optionsMenu - > addSeparator ( ) ;
2013-11-26 07:03:31 +00:00
# if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
2013-11-22 04:05:36 +00:00
optionsMenu - > add ( new MenuAction ( this , SLOT ( fullscrAct ( ) ) , QT_TR_NOOP ( " &Fullscreen " ) , Qt : : Key_F11 ) )
2013-11-26 07:03:31 +00:00
# else
optionsMenu - > add ( new MenuAction ( this , SLOT ( fullscrAct ( ) ) , QT_TR_NOOP ( " &Fullscreen " ) , QKeySequence : : FullScreen ) )
# endif
2013-11-22 04:05:36 +00:00
- > addEventChecked ( & g_Config . bFullScreen ) ;
optionsMenu - > add ( new MenuAction ( this , SLOT ( statsAct ( ) ) , QT_TR_NOOP ( " &Show debug statistics " ) ) )
- > addEventChecked ( & g_Config . bShowDebugStats ) ;
optionsMenu - > add ( new MenuAction ( this , SLOT ( showFPSAct ( ) ) , QT_TR_NOOP ( " &Show FPS " ) ) )
- > addEventChecked ( & g_Config . iShowFPSCounter ) ;
2013-11-19 04:02:24 +00:00
optionsMenu - > addSeparator ( ) ;
// - Log Levels
2013-11-22 04:05:36 +00:00
MenuTree * levelsMenu = new MenuTree ( this , optionsMenu , QT_TR_NOOP ( " Lo&g levels " ) ) ;
2013-11-19 09:32:31 +00:00
QMenu * defaultLogMenu = levelsMenu - > addMenu ( " Default " ) ;
2013-11-22 04:05:36 +00:00
defaultLogGroup = new MenuActionGroup ( this , defaultLogMenu , SLOT ( defaultLogGroup_triggered ( QAction * ) ) ,
QStringList ( ) < < " Debug " < < " Warning " < < " Info " < < " Error " ,
QList < int > ( ) < < LogTypes : : LDEBUG < < LogTypes : : LWARNING < < LogTypes : : LINFO < < LogTypes : : LERROR ) ;
2013-11-19 09:32:31 +00:00
QMenu * g3dLogMenu = levelsMenu - > addMenu ( " G3D " ) ;
2013-11-22 04:05:36 +00:00
g3dLogGroup = new MenuActionGroup ( this , g3dLogMenu , SLOT ( g3dLogGroup_triggered ( QAction * ) ) ,
QStringList ( ) < < " Debug " < < " Warning " < < " Info " < < " Error " ,
QList < int > ( ) < < LogTypes : : LDEBUG < < LogTypes : : LWARNING < < LogTypes : : LINFO < < LogTypes : : LERROR ) ;
2013-11-19 09:32:31 +00:00
QMenu * hleLogMenu = levelsMenu - > addMenu ( " HLE " ) ;
2013-11-22 04:05:36 +00:00
hleLogGroup = new MenuActionGroup ( this , hleLogMenu , SLOT ( hleLogGroup_triggered ( QAction * ) ) ,
QStringList ( ) < < " Debug " < < " Warning " < < " Info " < < " Error " ,
QList < int > ( ) < < LogTypes : : LDEBUG < < LogTypes : : LWARNING < < LogTypes : : LINFO < < LogTypes : : LERROR ) ;
2013-11-19 04:02:24 +00:00
optionsMenu - > addSeparator ( ) ;
// - Language
2013-11-22 04:05:36 +00:00
MenuTree * langMenu = new MenuTree ( this , optionsMenu , QT_TR_NOOP ( " &Language " ) ) ;
QActionGroup * langGroup = new QActionGroup ( this ) ;
2013-02-12 17:07:36 +00:00
QStringList fileNames = QDir ( " :/languages " ) . entryList ( QStringList ( " ppsspp_*.qm " ) ) ;
2013-02-06 23:04:49 +00:00
if ( fileNames . size ( ) = = 0 )
{
2013-11-19 09:32:31 +00:00
QAction * action = new QAction ( " No translations " , this ) ;
2013-02-06 23:04:49 +00:00
action - > setDisabled ( true ) ;
langGroup - > addAction ( action ) ;
2013-11-19 04:02:24 +00:00
} else {
connect ( langGroup , SIGNAL ( triggered ( QAction * ) ) , this , SLOT ( langChanged ( QAction * ) ) ) ;
2013-11-21 16:32:46 +00:00
bool found = false ;
QString currentLocale = g_Config . sLanguageIni . c_str ( ) ;
QString currentLang = currentLocale . split ( ' _ ' ) . first ( ) ;
2013-11-19 04:02:24 +00:00
for ( int i = 0 ; i < fileNames . size ( ) ; + + i )
{
QString locale = fileNames [ i ] ;
locale . truncate ( locale . lastIndexOf ( ' . ' ) ) ;
locale . remove ( 0 , locale . indexOf ( ' _ ' ) + 1 ) ;
2013-02-06 17:49:20 +00:00
2013-11-26 07:03:31 +00:00
# if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
2013-11-19 04:02:24 +00:00
QString language = QLocale ( locale ) . nativeLanguageName ( ) ;
2013-02-13 05:52:33 +00:00
# else
2013-11-19 04:02:24 +00:00
QString language = QLocale : : languageToString ( QLocale ( locale ) . language ( ) ) ;
2013-02-13 05:52:33 +00:00
# endif
2013-11-21 16:32:46 +00:00
QAction * action = new MenuAction ( this , langGroup , locale , language ) ;
std : : string testLang = g_Config . sLanguageIni ;
if ( currentLocale = = locale | | currentLang = = locale ) {
2013-11-19 09:32:31 +00:00
action - > setChecked ( true ) ;
2013-11-21 16:38:19 +00:00
loadLanguage ( locale , false ) ;
2013-11-21 16:32:46 +00:00
found = true ;
2013-11-19 09:32:31 +00:00
}
2013-11-21 16:32:46 +00:00
if ( ! found & & locale = = " en " ) {
2013-11-19 04:02:24 +00:00
action - > setChecked ( true ) ;
}
2013-02-06 17:49:20 +00:00
}
}
2013-11-19 04:02:24 +00:00
langMenu - > addActions ( langGroup - > actions ( ) ) ;
// Help
2013-11-22 04:05:36 +00:00
MenuTree * helpMenu = new MenuTree ( this , menuBar ( ) , QT_TR_NOOP ( " &Help " ) ) ;
2014-07-10 12:41:26 +00:00
helpMenu - > add ( new MenuAction ( this , SLOT ( websiteAct ( ) ) , QT_TR_NOOP ( " Official &website " ) , QKeySequence : : HelpContents ) ) ;
helpMenu - > add ( new MenuAction ( this , SLOT ( forumAct ( ) ) , QT_TR_NOOP ( " Official &forum " ) ) ) ;
2017-02-05 13:19:30 +00:00
helpMenu - > add ( new MenuAction ( this , SLOT ( gitAct ( ) ) , QT_TR_NOOP ( " &GitHub " ) ) ) ;
2013-11-26 07:03:31 +00:00
helpMenu - > add ( new MenuAction ( this , SLOT ( aboutAct ( ) ) , QT_TR_NOOP ( " &About PPSSPP... " ) , QKeySequence : : WhatsThis ) ) ;
2013-11-19 09:32:31 +00:00
2013-11-22 04:05:36 +00:00
retranslate ( ) ;
2013-02-06 17:49:20 +00:00
}
2013-02-19 20:59:53 +00:00
void MainWindow : : notifyMapsLoaded ( )
2013-02-06 17:49:20 +00:00
{
2013-02-19 20:59:53 +00:00
if ( dialogDisasm )
dialogDisasm - > NotifyMapLoaded ( ) ;
if ( memoryWindow )
memoryWindow - > NotifyMapLoaded ( ) ;
2013-02-17 00:06:06 +00:00
}