mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-30 09:35:40 +00:00
Qt: Skeleton of load/save state menus
This commit is contained in:
parent
1998aa96a4
commit
183928b0f6
|
@ -18,6 +18,7 @@ MainWindow::MainWindow(QtHostInterface* host_interface) : QMainWindow(nullptr),
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
setupAdditionalUi();
|
setupAdditionalUi();
|
||||||
connectSignals();
|
connectSignals();
|
||||||
|
populateLoadSaveStateMenus(QString());
|
||||||
|
|
||||||
resize(750, 690);
|
resize(750, 690);
|
||||||
}
|
}
|
||||||
|
@ -39,15 +40,16 @@ void MainWindow::onEmulationStarting()
|
||||||
|
|
||||||
void MainWindow::onEmulationStarted()
|
void MainWindow::onEmulationStarted()
|
||||||
{
|
{
|
||||||
updateEmulationActions(false, true);
|
|
||||||
m_emulation_running = true;
|
m_emulation_running = true;
|
||||||
|
updateEmulationActions(false, true);
|
||||||
|
populateLoadSaveStateMenus(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onEmulationStopped()
|
void MainWindow::onEmulationStopped()
|
||||||
{
|
{
|
||||||
|
m_emulation_running = false;
|
||||||
updateEmulationActions(false, false);
|
updateEmulationActions(false, false);
|
||||||
switchToGameListView();
|
switchToGameListView();
|
||||||
m_emulation_running = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onEmulationPaused(bool paused)
|
void MainWindow::onEmulationPaused(bool paused)
|
||||||
|
@ -212,8 +214,8 @@ void MainWindow::updateEmulationActions(bool starting, bool running)
|
||||||
m_ui.actionChangeDisc->setDisabled(starting || !running);
|
m_ui.actionChangeDisc->setDisabled(starting || !running);
|
||||||
m_ui.menuChangeDisc->setDisabled(starting || !running);
|
m_ui.menuChangeDisc->setDisabled(starting || !running);
|
||||||
|
|
||||||
m_ui.actionLoadState->setDisabled(starting);
|
m_ui.actionSaveState->setDisabled(starting || !running);
|
||||||
m_ui.actionSaveState->setDisabled(starting);
|
m_ui.menuSaveState->setDisabled(starting || !running);
|
||||||
|
|
||||||
m_ui.actionFullscreen->setDisabled(starting || !running);
|
m_ui.actionFullscreen->setDisabled(starting || !running);
|
||||||
|
|
||||||
|
@ -265,6 +267,8 @@ void MainWindow::connectSignals()
|
||||||
connect(m_ui.actionPowerOff, &QAction::triggered, m_host_interface, &QtHostInterface::powerOffSystem);
|
connect(m_ui.actionPowerOff, &QAction::triggered, m_host_interface, &QtHostInterface::powerOffSystem);
|
||||||
connect(m_ui.actionReset, &QAction::triggered, m_host_interface, &QtHostInterface::resetSystem);
|
connect(m_ui.actionReset, &QAction::triggered, m_host_interface, &QtHostInterface::resetSystem);
|
||||||
connect(m_ui.actionPause, &QAction::toggled, m_host_interface, &QtHostInterface::pauseSystem);
|
connect(m_ui.actionPause, &QAction::toggled, m_host_interface, &QtHostInterface::pauseSystem);
|
||||||
|
connect(m_ui.actionLoadState, &QAction::triggered, this, [this]() { m_ui.menuLoadState->exec(QCursor::pos()); });
|
||||||
|
connect(m_ui.actionSaveState, &QAction::triggered, this, [this]() { m_ui.menuSaveState->exec(QCursor::pos()); });
|
||||||
connect(m_ui.actionExit, &QAction::triggered, this, &MainWindow::onExitActionTriggered);
|
connect(m_ui.actionExit, &QAction::triggered, this, &MainWindow::onExitActionTriggered);
|
||||||
connect(m_ui.actionFullscreen, &QAction::triggered, this, &MainWindow::toggleFullscreen);
|
connect(m_ui.actionFullscreen, &QAction::triggered, this, &MainWindow::toggleFullscreen);
|
||||||
connect(m_ui.actionSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::Count); });
|
connect(m_ui.actionSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::Count); });
|
||||||
|
@ -307,10 +311,12 @@ void MainWindow::connectSignals()
|
||||||
if (!entry)
|
if (!entry)
|
||||||
{
|
{
|
||||||
m_ui.statusBar->clearMessage();
|
m_ui.statusBar->clearMessage();
|
||||||
|
populateLoadSaveStateMenus(QString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui.statusBar->showMessage(QString::fromStdString(entry->path));
|
m_ui.statusBar->showMessage(QString::fromStdString(entry->path));
|
||||||
|
populateLoadSaveStateMenus(QString::fromStdString(entry->code));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,3 +352,41 @@ void MainWindow::updateDebugMenuGPURenderer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::populateLoadSaveStateMenus(QString game_code)
|
||||||
|
{
|
||||||
|
static constexpr int NUM_SAVE_STATE_SLOTS = 10;
|
||||||
|
|
||||||
|
QMenu* const load_menu = m_ui.menuLoadState;
|
||||||
|
QMenu* const save_menu = m_ui.menuSaveState;
|
||||||
|
|
||||||
|
load_menu->clear();
|
||||||
|
save_menu->clear();
|
||||||
|
|
||||||
|
load_menu->addAction(tr("Resume State"));
|
||||||
|
load_menu->addSeparator();
|
||||||
|
|
||||||
|
for (int i = 0; i < NUM_SAVE_STATE_SLOTS; i++)
|
||||||
|
{
|
||||||
|
// TODO: Do we want to test for the existance of these on disk here?
|
||||||
|
load_menu->addAction(tr("Global Save %1 (2020-01-01 00:01:02)").arg(i + 1));
|
||||||
|
|
||||||
|
if (m_emulation_running)
|
||||||
|
save_menu->addAction(tr("Global Save %1").arg(i + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!game_code.isEmpty())
|
||||||
|
{
|
||||||
|
load_menu->addSeparator();
|
||||||
|
if (m_emulation_running)
|
||||||
|
save_menu->addSeparator();
|
||||||
|
|
||||||
|
for (int i = 0; i < NUM_SAVE_STATE_SLOTS; i++)
|
||||||
|
{
|
||||||
|
load_menu->addAction(tr("Game Save %1 (2020-01-01 00:01:02)").arg(i + 1));
|
||||||
|
|
||||||
|
if (m_emulation_running)
|
||||||
|
save_menu->addAction(tr("Game Save %1").arg(i + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ private Q_SLOTS:
|
||||||
float worst_frame_time);
|
float worst_frame_time);
|
||||||
|
|
||||||
void onStartDiscActionTriggered();
|
void onStartDiscActionTriggered();
|
||||||
void onChangeDiscActionTriggered();
|
|
||||||
void onChangeDiscFromFileActionTriggered();
|
void onChangeDiscFromFileActionTriggered();
|
||||||
void onChangeDiscFromGameListActionTriggered();
|
void onChangeDiscFromGameListActionTriggered();
|
||||||
void onStartBiosActionTriggered();
|
void onStartBiosActionTriggered();
|
||||||
|
@ -43,7 +42,6 @@ private Q_SLOTS:
|
||||||
void onAboutActionTriggered();
|
void onAboutActionTriggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createGameList();
|
|
||||||
void setupAdditionalUi();
|
void setupAdditionalUi();
|
||||||
void connectSignals();
|
void connectSignals();
|
||||||
void updateEmulationActions(bool starting, bool running);
|
void updateEmulationActions(bool starting, bool running);
|
||||||
|
@ -51,6 +49,7 @@ private:
|
||||||
void switchToEmulationView();
|
void switchToEmulationView();
|
||||||
void doSettings(SettingsDialog::Category category = SettingsDialog::Category::Count);
|
void doSettings(SettingsDialog::Category category = SettingsDialog::Category::Count);
|
||||||
void updateDebugMenuGPURenderer();
|
void updateDebugMenuGPURenderer();
|
||||||
|
void populateLoadSaveStateMenus(QString game_code);
|
||||||
|
|
||||||
Ui::MainWindow m_ui;
|
Ui::MainWindow m_ui;
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,24 @@
|
||||||
<addaction name="actionChangeDiscFromFile"/>
|
<addaction name="actionChangeDiscFromFile"/>
|
||||||
<addaction name="actionChangeDiscFromGameList"/>
|
<addaction name="actionChangeDiscFromGameList"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuLoadState">
|
||||||
|
<property name="title">
|
||||||
|
<string>Load State</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources/icons.qrc">
|
||||||
|
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuSaveState">
|
||||||
|
<property name="title">
|
||||||
|
<string>Save State</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources/icons.qrc">
|
||||||
|
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
<addaction name="actionStartDisc"/>
|
<addaction name="actionStartDisc"/>
|
||||||
<addaction name="actionStartBios"/>
|
<addaction name="actionStartBios"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
@ -56,8 +74,8 @@
|
||||||
<addaction name="actionPause"/>
|
<addaction name="actionPause"/>
|
||||||
<addaction name="menuChangeDisc"/>
|
<addaction name="menuChangeDisc"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionLoadState"/>
|
<addaction name="menuLoadState"/>
|
||||||
<addaction name="actionSaveState"/>
|
<addaction name="menuSaveState"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionExit"/>
|
<addaction name="actionExit"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -361,6 +379,16 @@
|
||||||
<string>From Game List...</string>
|
<string>From Game List...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionResume_State">
|
||||||
|
<property name="text">
|
||||||
|
<string>Resume State</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionGlobal_State">
|
||||||
|
<property name="text">
|
||||||
|
<string>Global State</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="resources/icons.qrc"/>
|
<include location="resources/icons.qrc"/>
|
||||||
|
|
Loading…
Reference in a new issue