2013-01-13 23:29:42 +00:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QKeyEvent>
|
2013-02-01 01:08:01 +00:00
|
|
|
#include <QDesktopWidget>
|
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"
|
|
|
|
#include "Core/Config.h"
|
|
|
|
#include "ConsoleListener.h"
|
|
|
|
#include "base/display.h"
|
2013-09-04 20:38:45 +00:00
|
|
|
#include "base/NKCodeFromQt.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
|
|
|
|
2013-01-15 16:16:07 +00:00
|
|
|
#include "QtHost.h"
|
|
|
|
#include "EmuThread.h"
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-02-19 15:36:06 +00:00
|
|
|
// TODO: Make this class thread-aware. Can't send events to a different thread. Currently only works on X11.
|
|
|
|
// Needs to use QueuedConnection for signals/slots.
|
2013-01-13 23:29:42 +00:00
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
2013-01-15 16:16:07 +00:00
|
|
|
QMainWindow(parent),
|
2013-01-13 23:29:42 +00:00
|
|
|
ui(new Ui::MainWindow),
|
2013-10-19 20:59:48 +00:00
|
|
|
timer(this),
|
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-10-19 20:59:48 +00:00
|
|
|
displaylistWindow(0)
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-01-15 16:16:07 +00:00
|
|
|
ui->setupUi(this);
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-01-15 16:16:07 +00:00
|
|
|
host = new QtHost(this);
|
2013-02-12 00:36:16 +00:00
|
|
|
emugl = ui->widget;
|
|
|
|
emugl->init(&input_state);
|
|
|
|
emugl->resize(pixel_xres, pixel_yres);
|
|
|
|
emugl->setMinimumSize(pixel_xres, pixel_yres);
|
|
|
|
emugl->setMaximumSize(pixel_xres, pixel_yres);
|
|
|
|
QObject::connect( emugl, SIGNAL(doubleClick()), this, SLOT(on_action_OptionsFullScreen_triggered()) );
|
2013-01-15 16:16:07 +00:00
|
|
|
|
2013-02-06 23:04:49 +00:00
|
|
|
createLanguageMenu();
|
2013-01-15 16:16:07 +00:00
|
|
|
UpdateMenus();
|
|
|
|
|
2013-10-09 04:17:48 +00:00
|
|
|
int zoom = g_Config.iInternalResolution;
|
2013-01-15 16:16:07 +00:00
|
|
|
if (zoom < 1) zoom = 1;
|
|
|
|
if (zoom > 4) zoom = 4;
|
|
|
|
SetZoom(zoom);
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
SetGameTitle(fileToStart);
|
2013-02-05 21:22:14 +00:00
|
|
|
|
2013-04-18 15:40:30 +00:00
|
|
|
connect(&timer, SIGNAL(timeout()), this, SLOT(Update()));
|
|
|
|
timer.setInterval(0);
|
|
|
|
timer.start();
|
2013-01-15 16:16:07 +00:00
|
|
|
|
2013-04-18 15:40:30 +00:00
|
|
|
// if (!fileToStart.isNull())
|
|
|
|
// {
|
|
|
|
// UpdateMenus();
|
|
|
|
|
|
|
|
// if (stateToLoad != NULL)
|
|
|
|
// SaveState::Load(stateToLoad);
|
|
|
|
// }
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
2013-01-15 16:16:07 +00:00
|
|
|
delete ui;
|
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-02-19 20:59:53 +00:00
|
|
|
void MainWindow::Update()
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-04-18 15:40:30 +00:00
|
|
|
emugl->updateGL();
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-04-20 10:43:55 +00:00
|
|
|
if (lastUIState != globalUIState) {
|
|
|
|
lastUIState = globalUIState;
|
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-04-20 10:43:55 +00:00
|
|
|
UpdateMenus();
|
|
|
|
}
|
2013-02-10 15:36:06 +00:00
|
|
|
}
|
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
void MainWindow::UpdateMenus()
|
|
|
|
{
|
2013-04-04 01:58:10 +00:00
|
|
|
bool enable = globalUIState == UISTATE_MENU;
|
2013-01-13 23:29:42 +00:00
|
|
|
ui->action_FileLoad->setEnabled(enable);
|
2013-02-19 20:59:53 +00:00
|
|
|
ui->action_FileClose->setEnabled(!enable);
|
2013-01-13 23:29:42 +00:00
|
|
|
ui->action_FileSaveStateFile->setEnabled(!enable);
|
|
|
|
ui->action_FileLoadStateFile->setEnabled(!enable);
|
|
|
|
ui->action_FileQuickloadState->setEnabled(!enable);
|
|
|
|
ui->action_FileQuickSaveState->setEnabled(!enable);
|
2013-02-17 00:53:55 +00:00
|
|
|
ui->action_CPUDynarec->setEnabled(enable);
|
|
|
|
ui->action_CPUInterpreter->setEnabled(enable);
|
2013-02-12 00:36:16 +00:00
|
|
|
ui->action_DebugDumpFrame->setEnabled(!enable);
|
|
|
|
ui->action_DebugDisassembly->setEnabled(!enable);
|
|
|
|
ui->action_DebugMemoryView->setEnabled(!enable);
|
2013-02-17 00:06:06 +00:00
|
|
|
ui->action_DebugMemoryViewTexture->setEnabled(!enable);
|
|
|
|
ui->action_DebugDisplayList->setEnabled(!enable);
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-04-04 01:58:10 +00:00
|
|
|
ui->action_EmulationRun->setEnabled(Core_IsStepping() || globalUIState == UISTATE_PAUSEMENU);
|
|
|
|
ui->action_EmulationPause->setEnabled(globalUIState == UISTATE_INGAME);
|
|
|
|
ui->action_EmulationReset->setEnabled(globalUIState == UISTATE_INGAME);
|
2013-02-19 20:59:53 +00:00
|
|
|
|
|
|
|
// checking
|
|
|
|
ui->action_EmulationRunLoad->setChecked(g_Config.bAutoRun);
|
|
|
|
|
|
|
|
ui->action_CPUInterpreter->setChecked(!g_Config.bJit);
|
|
|
|
ui->action_CPUDynarec->setChecked(g_Config.bJit);
|
|
|
|
ui->action_OptionsFastMemory->setChecked(g_Config.bFastMemory);
|
|
|
|
ui->action_OptionsIgnoreIllegalReadsWrites->setChecked(g_Config.bIgnoreBadMemAccess);
|
|
|
|
|
|
|
|
ui->action_AFOff->setChecked(g_Config.iAnisotropyLevel == 0);
|
|
|
|
ui->action_AF2x->setChecked(g_Config.iAnisotropyLevel == 2);
|
|
|
|
ui->action_AF4x->setChecked(g_Config.iAnisotropyLevel == 4);
|
|
|
|
ui->action_AF8x->setChecked(g_Config.iAnisotropyLevel == 8);
|
|
|
|
ui->action_AF16x->setChecked(g_Config.iAnisotropyLevel == 16);
|
|
|
|
|
2013-07-29 18:30:29 +00:00
|
|
|
ui->action_OptionsBufferedRendering->setChecked(g_Config.iRenderingMode == 1);
|
2013-07-02 15:03:07 +00:00
|
|
|
ui->action_OptionsLinearFiltering->setChecked(3 == g_Config.iTexFiltering);
|
2013-02-19 20:59:53 +00:00
|
|
|
|
2013-10-09 04:17:48 +00:00
|
|
|
ui->action_OptionsScreen1x->setChecked(0 == (g_Config.iInternalResolution - 1));
|
|
|
|
ui->action_OptionsScreen2x->setChecked(1 == (g_Config.iInternalResolution - 1));
|
|
|
|
ui->action_OptionsScreen3x->setChecked(2 == (g_Config.iInternalResolution - 1));
|
|
|
|
ui->action_OptionsScreen4x->setChecked(3 == (g_Config.iInternalResolution - 1));
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
ui->action_Stretch_to_display->setChecked(g_Config.bStretchToDisplay);
|
|
|
|
ui->action_OptionsHardwareTransform->setChecked(g_Config.bHardwareTransform);
|
|
|
|
ui->action_OptionsVertexCache->setChecked(g_Config.bVertexCache);
|
2013-02-25 22:55:37 +00:00
|
|
|
ui->actionFrameskip->setChecked(g_Config.iFrameSkip != 0);
|
2013-02-19 20:59:53 +00:00
|
|
|
|
|
|
|
ui->action_Sound->setChecked(g_Config.bEnableSound);
|
|
|
|
|
|
|
|
ui->action_OptionsShowDebugStatistics->setChecked(g_Config.bShowDebugStats);
|
2013-06-21 15:33:36 +00:00
|
|
|
ui->action_Show_FPS_counter->setChecked(g_Config.iShowFPSCounter);
|
2013-02-19 20:59:53 +00:00
|
|
|
|
|
|
|
ui->actionLogDefDebug->setChecked(LogManager::GetInstance()->GetLogLevel(LogTypes::COMMON) == LogTypes::LDEBUG);
|
|
|
|
ui->actionLogDefInfo->setChecked(LogManager::GetInstance()->GetLogLevel(LogTypes::COMMON) == LogTypes::LINFO);
|
|
|
|
ui->actionLogDefWarning->setChecked(LogManager::GetInstance()->GetLogLevel(LogTypes::COMMON) == LogTypes::LWARNING);
|
|
|
|
ui->actionLogDefError->setChecked(LogManager::GetInstance()->GetLogLevel(LogTypes::COMMON) == LogTypes::LERROR);
|
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
ui->actionLogG3DDebug->setChecked(LogManager::GetInstance()->GetLogLevel(LogTypes::G3D) == LogTypes::LDEBUG);
|
|
|
|
ui->actionLogG3DInfo->setChecked(LogManager::GetInstance()->GetLogLevel(LogTypes::G3D) == LogTypes::LINFO);
|
|
|
|
ui->actionLogG3DWarning->setChecked(LogManager::GetInstance()->GetLogLevel(LogTypes::G3D) == LogTypes::LWARNING);
|
|
|
|
ui->actionLogG3DError->setChecked(LogManager::GetInstance()->GetLogLevel(LogTypes::G3D) == LogTypes::LERROR);
|
|
|
|
|
|
|
|
ui->actionLogHLEDebug->setChecked(LogManager::GetInstance()->GetLogLevel(LogTypes::HLE) == LogTypes::LDEBUG);
|
|
|
|
ui->actionLogHLEInfo->setChecked(LogManager::GetInstance()->GetLogLevel(LogTypes::HLE) == LogTypes::LINFO);
|
|
|
|
ui->actionLogHLEWarning->setChecked(LogManager::GetInstance()->GetLogLevel(LogTypes::HLE) == LogTypes::LWARNING);
|
|
|
|
ui->actionLogHLEError->setChecked(LogManager::GetInstance()->GetLogLevel(LogTypes::HLE) == LogTypes::LERROR);
|
2013-02-19 20:59:53 +00:00
|
|
|
}
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::changeEvent(QEvent *e)
|
|
|
|
{
|
|
|
|
if (e->type() == QEvent::LanguageChange)
|
|
|
|
ui->retranslateUi(this);
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::closeEvent(QCloseEvent *)
|
|
|
|
{
|
|
|
|
on_action_FileExit_triggered();
|
|
|
|
}
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::keyPressEvent(QKeyEvent *e)
|
|
|
|
{
|
2013-06-06 14:00:00 +00:00
|
|
|
if(isFullScreen() && e->key() == Qt::Key_F11)
|
2013-02-19 20:59:53 +00:00
|
|
|
{
|
|
|
|
on_action_OptionsFullScreen_triggered();
|
|
|
|
return;
|
|
|
|
}
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-09-04 20:38:45 +00:00
|
|
|
NativeKey(KeyInput(DEVICE_ID_KEYBOARD, KeyMapRawQttoNative.find(e->key())->second, KEY_DOWN));
|
2013-02-19 20:59:53 +00:00
|
|
|
}
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::keyReleaseEvent(QKeyEvent *e)
|
|
|
|
{
|
2013-09-04 20:38:45 +00:00
|
|
|
NativeKey(KeyInput(DEVICE_ID_KEYBOARD, KeyMapRawQttoNative.find(e->key())->second, KEY_UP));
|
2013-02-19 20:59:53 +00:00
|
|
|
}
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
/* SLOTS */
|
|
|
|
void MainWindow::Boot()
|
|
|
|
{
|
|
|
|
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())
|
|
|
|
on_action_OptionsFullScreen_triggered();
|
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);
|
|
|
|
displaylistWindow = new Debugger_DisplayList(currentDebugMIPS, this, this);
|
2013-02-13 22:07:02 +00:00
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
notifyMapsLoaded();
|
|
|
|
|
|
|
|
if (nextState == CORE_RUNNING)
|
|
|
|
on_action_EmulationRun_triggered();
|
|
|
|
UpdateMenus();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::CoreEmitWait(bool isWaiting)
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-19 20:59:53 +00:00
|
|
|
// Unlock mutex while core is waiting;
|
|
|
|
EmuThread_LockDraw(!isWaiting);
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_FileLoad_triggered()
|
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-04-18 15:40:30 +00:00
|
|
|
UpdateMenus();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_FileClose_triggered()
|
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
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SaveStateActionFinished(bool result, void *userdata)
|
|
|
|
{
|
|
|
|
// 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-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_FileQuickloadState_triggered()
|
|
|
|
{
|
|
|
|
SaveState::LoadSlot(0, SaveStateActionFinished, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_FileQuickSaveState_triggered()
|
|
|
|
{
|
|
|
|
SaveState::SaveSlot(0, SaveStateActionFinished, this);
|
|
|
|
}
|
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
void MainWindow::on_action_FileLoadStateFile_triggered()
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_FileSaveStateFile_triggered()
|
|
|
|
{
|
|
|
|
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-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_FileExit_triggered()
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-19 20:59:53 +00:00
|
|
|
on_action_FileClose_triggered();
|
|
|
|
QApplication::exit(0);
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_EmulationRun_triggered()
|
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-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_EmulationPause_triggered()
|
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-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_EmulationReset_triggered()
|
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-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_EmulationRunLoad_triggered()
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-19 20:59:53 +00:00
|
|
|
g_Config.bAutoRun = !g_Config.bAutoRun;
|
2013-01-13 23:29:42 +00:00
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_DebugLoadMapFile_triggered()
|
|
|
|
{
|
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())
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-10 15:36:06 +00:00
|
|
|
fileNames = dialog.selectedFiles();
|
|
|
|
symbolMap.LoadSymbolMap(fileNames[0].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
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_DebugSaveMapFile_triggered()
|
|
|
|
{
|
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();
|
|
|
|
symbolMap.SaveSymbolMap(fileNames[0].toStdString().c_str());
|
|
|
|
}
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_DebugResetSymbolTable_triggered()
|
|
|
|
{
|
2013-10-18 19:22:32 +00:00
|
|
|
symbolMap.Clear();
|
2013-02-19 20:59:53 +00:00
|
|
|
notifyMapsLoaded();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_DebugDumpFrame_triggered()
|
|
|
|
{
|
|
|
|
gpu->DumpNextFrame();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_DebugDisassembly_triggered()
|
|
|
|
{
|
|
|
|
if(dialogDisasm)
|
|
|
|
dialogDisasm->show();
|
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_DebugDisplayList_triggered()
|
|
|
|
{
|
|
|
|
if(displaylistWindow)
|
|
|
|
displaylistWindow->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_DebugLog_triggered()
|
|
|
|
{
|
|
|
|
LogManager::GetInstance()->GetConsoleListener()->Show(LogManager::GetInstance()->GetConsoleListener()->Hidden());
|
|
|
|
}
|
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
void MainWindow::on_action_DebugMemoryView_triggered()
|
|
|
|
{
|
2013-02-10 15:36:06 +00:00
|
|
|
if (memoryWindow)
|
|
|
|
memoryWindow->show();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_DebugMemoryViewTexture_triggered()
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-19 20:59:53 +00:00
|
|
|
if(memoryTexWindow)
|
|
|
|
memoryTexWindow->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_CPUDynarec_triggered()
|
|
|
|
{
|
|
|
|
g_Config.bJit = true;
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_CPUInterpreter_triggered()
|
|
|
|
{
|
|
|
|
g_Config.bJit = false;
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_OptionsFastMemory_triggered()
|
|
|
|
{
|
|
|
|
g_Config.bFastMemory = !g_Config.bFastMemory;
|
|
|
|
UpdateMenus();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_OptionsIgnoreIllegalReadsWrites_triggered()
|
|
|
|
{
|
|
|
|
g_Config.bIgnoreBadMemAccess = !g_Config.bIgnoreBadMemAccess;
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_AFOff_triggered()
|
|
|
|
{
|
|
|
|
g_Config.iAnisotropyLevel = 0;
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_AF2x_triggered()
|
|
|
|
{
|
|
|
|
g_Config.iAnisotropyLevel = 2;
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_AF4x_triggered()
|
|
|
|
{
|
|
|
|
g_Config.iAnisotropyLevel = 4;
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_AF8x_triggered()
|
|
|
|
{
|
|
|
|
g_Config.iAnisotropyLevel = 8;
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_AF16x_triggered()
|
|
|
|
{
|
|
|
|
g_Config.iAnisotropyLevel = 16;
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_OptionsBufferedRendering_triggered()
|
|
|
|
{
|
2013-07-29 18:30:29 +00:00
|
|
|
g_Config.iRenderingMode = !g_Config.iRenderingMode;
|
2013-02-19 20:59:53 +00:00
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_OptionsLinearFiltering_triggered()
|
|
|
|
{
|
2013-07-02 15:03:07 +00:00
|
|
|
if (g_Config.iTexFiltering == 0)
|
|
|
|
g_Config.iTexFiltering = 3;
|
|
|
|
else
|
|
|
|
g_Config.iTexFiltering = 0;
|
2013-02-19 20:59:53 +00:00
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_OptionsScreen1x_triggered()
|
|
|
|
{
|
|
|
|
SetZoom(1);
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_OptionsScreen2x_triggered()
|
|
|
|
{
|
|
|
|
SetZoom(2);
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_OptionsScreen3x_triggered()
|
|
|
|
{
|
|
|
|
SetZoom(3);
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_OptionsScreen4x_triggered()
|
|
|
|
{
|
|
|
|
SetZoom(4);
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_Stretch_to_display_triggered()
|
|
|
|
{
|
|
|
|
g_Config.bStretchToDisplay = !g_Config.bStretchToDisplay;
|
|
|
|
UpdateMenus();
|
|
|
|
if (gpu)
|
|
|
|
gpu->Resized();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_OptionsHardwareTransform_triggered()
|
|
|
|
{
|
|
|
|
g_Config.bHardwareTransform = !g_Config.bHardwareTransform;
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_OptionsVertexCache_triggered()
|
|
|
|
{
|
|
|
|
g_Config.bVertexCache = !g_Config.bVertexCache;
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionFrameskip_triggered()
|
|
|
|
{
|
2013-02-25 22:55:37 +00:00
|
|
|
g_Config.iFrameSkip = !g_Config.iFrameSkip;
|
2013-02-19 20:59:53 +00:00
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_Sound_triggered()
|
|
|
|
{
|
|
|
|
g_Config.bEnableSound = !g_Config.bEnableSound;
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
void MainWindow::on_action_OptionsFullScreen_triggered()
|
|
|
|
{
|
2013-02-01 01:08:01 +00:00
|
|
|
if(isFullScreen()) {
|
2013-02-10 15:36:06 +00:00
|
|
|
g_Config.bFullScreen = false;
|
2013-02-01 01:08:01 +00:00
|
|
|
showNormal();
|
|
|
|
ui->menubar->setVisible(true);
|
|
|
|
ui->statusbar->setVisible(true);
|
2013-10-09 04:17:48 +00:00
|
|
|
SetZoom(g_Config.iInternalResolution);
|
2013-11-05 06:00:13 +00:00
|
|
|
InitPadLayout();
|
2013-11-04 12:30:38 +00:00
|
|
|
if (globalUIState == UISTATE_INGAME && QApplication::overrideCursor())
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-02-10 15:36:06 +00:00
|
|
|
g_Config.bFullScreen = true;
|
2013-02-01 01:08:01 +00:00
|
|
|
ui->menubar->setVisible(false);
|
|
|
|
ui->statusbar->setVisible(false);
|
|
|
|
|
|
|
|
// Remove constraint
|
2013-02-12 00:36:16 +00:00
|
|
|
emugl->setMinimumSize(0, 0);
|
|
|
|
emugl->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
2013-02-01 01:08:01 +00:00
|
|
|
ui->centralwidget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
|
|
|
setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
|
|
|
|
|
|
|
showFullScreen();
|
|
|
|
|
|
|
|
int width = (int) QApplication::desktop()->screenGeometry().width();
|
|
|
|
int height = (int) QApplication::desktop()->screenGeometry().height();
|
|
|
|
PSP_CoreParameter().pixelWidth = width;
|
|
|
|
PSP_CoreParameter().pixelHeight = height;
|
|
|
|
PSP_CoreParameter().outputWidth = width;
|
|
|
|
PSP_CoreParameter().outputHeight = height;
|
2013-10-14 14:40:25 +00:00
|
|
|
PSP_CoreParameter().renderWidth = width;
|
|
|
|
PSP_CoreParameter().renderHeight = height;
|
2013-02-13 22:07:02 +00:00
|
|
|
|
2013-02-01 01:08:01 +00:00
|
|
|
pixel_xres = width;
|
|
|
|
pixel_yres = height;
|
2013-02-10 15:36:06 +00:00
|
|
|
dp_xres = pixel_xres;
|
|
|
|
dp_yres = pixel_yres;
|
2013-02-01 01:08:01 +00:00
|
|
|
if (gpu)
|
|
|
|
gpu->Resized();
|
2013-11-05 06:00:13 +00:00
|
|
|
InitPadLayout();
|
2013-11-04 12:30:38 +00:00
|
|
|
if (globalUIState == UISTATE_INGAME && !g_Config.bShowTouchControls)
|
|
|
|
QApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
|
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_OptionsShowDebugStatistics_triggered()
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-19 20:59:53 +00:00
|
|
|
g_Config.bShowDebugStats = !g_Config.bShowDebugStats;
|
2013-01-13 23:29:42 +00:00
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_Show_FPS_counter_triggered()
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-06-21 15:33:36 +00:00
|
|
|
g_Config.iShowFPSCounter = !g_Config.iShowFPSCounter;
|
2013-01-13 23:29:42 +00:00
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void setDefLogLevel(LogTypes::LOG_LEVELS level)
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-19 20:59:53 +00:00
|
|
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
|
|
|
|
{
|
|
|
|
LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i;
|
|
|
|
if(type == LogTypes::G3D || type == LogTypes::HLE) continue;
|
|
|
|
LogManager::GetInstance()->SetLogLevel(type, level);
|
|
|
|
}
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_actionLogDefDebug_triggered()
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-19 20:59:53 +00:00
|
|
|
setDefLogLevel(LogTypes::LDEBUG);
|
2013-01-13 23:29:42 +00:00
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_actionLogDefWarning_triggered()
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-19 20:59:53 +00:00
|
|
|
setDefLogLevel(LogTypes::LWARNING);
|
|
|
|
UpdateMenus();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_actionLogDefInfo_triggered()
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-19 20:59:53 +00:00
|
|
|
setDefLogLevel(LogTypes::LINFO);
|
|
|
|
UpdateMenus();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_actionLogDefError_triggered()
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-19 20:59:53 +00:00
|
|
|
setDefLogLevel(LogTypes::LERROR);
|
|
|
|
UpdateMenus();
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionLogG3DDebug_triggered()
|
|
|
|
{
|
|
|
|
LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LDEBUG);
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionLogG3DWarning_triggered()
|
|
|
|
{
|
|
|
|
LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LWARNING);
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionLogG3DError_triggered()
|
|
|
|
{
|
|
|
|
LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LERROR);
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionLogG3DInfo_triggered()
|
|
|
|
{
|
|
|
|
LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LINFO);
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionLogHLEDebug_triggered()
|
|
|
|
{
|
|
|
|
LogManager::GetInstance()->SetLogLevel(LogTypes::HLE, LogTypes::LDEBUG);
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionLogHLEWarning_triggered()
|
|
|
|
{
|
|
|
|
LogManager::GetInstance()->SetLogLevel(LogTypes::HLE, LogTypes::LWARNING);
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionLogHLEInfo_triggered()
|
|
|
|
{
|
|
|
|
LogManager::GetInstance()->SetLogLevel(LogTypes::HLE, LogTypes::LINFO);
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionLogHLEError_triggered()
|
|
|
|
{
|
|
|
|
LogManager::GetInstance()->SetLogLevel(LogTypes::HLE, LogTypes::LERROR);
|
|
|
|
UpdateMenus();
|
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_HelpOpenWebsite_triggered()
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-19 20:59:53 +00:00
|
|
|
QDesktopServices::openUrl(QUrl("http://www.ppsspp.org/"));
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_action_HelpAbout_triggered()
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-19 20:59:53 +00:00
|
|
|
// TODO display about
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
void MainWindow::on_language_changed(QAction *action)
|
2013-01-13 23:29:42 +00:00
|
|
|
{
|
2013-02-19 20:59:53 +00:00
|
|
|
loadLanguage(action->data().toString());
|
2013-01-13 23:29:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
/* Private functions */
|
|
|
|
void MainWindow::SetZoom(float zoom) {
|
|
|
|
if (zoom < 5)
|
2013-10-09 04:17:48 +00:00
|
|
|
g_Config.iInternalResolution = (int) zoom;
|
2013-02-19 20:59:53 +00:00
|
|
|
|
|
|
|
pixel_xres = 480 * zoom;
|
|
|
|
pixel_yres = 272 * zoom;
|
|
|
|
dp_xres = pixel_xres;
|
|
|
|
dp_yres = pixel_yres;
|
|
|
|
|
|
|
|
emugl->resize(pixel_xres, pixel_yres);
|
|
|
|
emugl->setMinimumSize(pixel_xres, pixel_yres);
|
|
|
|
emugl->setMaximumSize(pixel_xres, pixel_yres);
|
|
|
|
|
|
|
|
ui->centralwidget->setFixedSize(pixel_xres, pixel_yres);
|
|
|
|
ui->centralwidget->resize(pixel_xres, pixel_yres);
|
|
|
|
|
|
|
|
setFixedSize(sizeHint());
|
|
|
|
resize(sizeHint());
|
|
|
|
|
|
|
|
PSP_CoreParameter().pixelWidth = pixel_xres;
|
|
|
|
PSP_CoreParameter().pixelHeight = pixel_yres;
|
|
|
|
PSP_CoreParameter().outputWidth = pixel_xres;
|
|
|
|
PSP_CoreParameter().outputHeight = pixel_yres;
|
|
|
|
|
|
|
|
if (gpu)
|
|
|
|
gpu->Resized();
|
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
|
|
|
{
|
2013-03-02 20:31:11 +00:00
|
|
|
QString title = "PPSSPP " + QString(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
|
|
|
}
|
|
|
|
|
|
|
|
void switchTranslator(QTranslator &translator, const QString &filename)
|
|
|
|
{
|
|
|
|
qApp->removeTranslator(&translator);
|
|
|
|
|
|
|
|
if (translator.load(filename))
|
|
|
|
qApp->installTranslator(&translator);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::loadLanguage(const QString& language)
|
|
|
|
{
|
|
|
|
if (currentLanguage != language)
|
|
|
|
{
|
|
|
|
currentLanguage = language;
|
2013-02-19 20:59:53 +00:00
|
|
|
QLocale::setDefault(QLocale(currentLanguage));
|
2013-02-12 21:01:00 +00:00
|
|
|
switchTranslator(translator, QString(":/languages/ppsspp_%1.qm").arg(language));
|
2013-02-06 17:49:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::createLanguageMenu()
|
|
|
|
{
|
|
|
|
QActionGroup *langGroup = new QActionGroup(ui->menuLanguage);
|
|
|
|
langGroup->setExclusive(true);
|
|
|
|
|
|
|
|
connect(langGroup, SIGNAL(triggered(QAction *)), this, SLOT(on_language_changed(QAction *)));
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
QAction *action = new QAction(tr("No translations"), this);
|
|
|
|
action->setCheckable(false);
|
|
|
|
action->setDisabled(true);
|
|
|
|
ui->menuLanguage->addAction(action);
|
|
|
|
langGroup->addAction(action);
|
|
|
|
}
|
2013-02-06 17:49:20 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < fileNames.size(); ++i)
|
|
|
|
{
|
|
|
|
QString locale = fileNames[i];
|
2013-02-06 23:04:49 +00:00
|
|
|
locale.truncate(locale.lastIndexOf('.'));
|
2013-02-06 17:49:20 +00:00
|
|
|
locale.remove(0, locale.indexOf('_') + 1);
|
|
|
|
|
2013-02-13 05:52:33 +00:00
|
|
|
#if QT_VERSION >= 0x040800
|
2013-02-06 23:04:49 +00:00
|
|
|
QString language = QLocale(locale).nativeLanguageName();
|
2013-02-13 05:52:33 +00:00
|
|
|
#else
|
|
|
|
QString language = QLocale::languageToString(QLocale(locale).language());
|
|
|
|
#endif
|
2013-02-06 17:49:20 +00:00
|
|
|
QAction *action = new QAction(language, this);
|
|
|
|
action->setCheckable(true);
|
|
|
|
action->setData(locale);
|
|
|
|
|
|
|
|
ui->menuLanguage->addAction(action);
|
|
|
|
langGroup->addAction(action);
|
|
|
|
|
2013-02-06 23:04:49 +00:00
|
|
|
// TODO check en as default until we save language to config
|
|
|
|
if ("en" == locale)
|
2013-02-06 17:49:20 +00:00
|
|
|
{
|
|
|
|
action->setChecked(true);
|
2013-02-06 23:04:49 +00:00
|
|
|
currentLanguage = "en";
|
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
|
|
|
}
|