Added basic UI; misc memory fixes

This commit is contained in:
Hamish Milne
2020-01-03 17:19:59 +00:00
committed by zhupengfei
parent 558e710e17
commit 26e90a99cd
13 changed files with 90 additions and 36 deletions

View File

@@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <clocale>
#include <fstream>
#include <memory>
#include <thread>
#include <QDesktopWidget>
@@ -606,6 +607,8 @@ void GMainWindow::ConnectMenuEvents() {
&GMainWindow::OnMenuReportCompatibility);
connect(ui.action_Configure, &QAction::triggered, this, &GMainWindow::OnConfigure);
connect(ui.action_Cheats, &QAction::triggered, this, &GMainWindow::OnCheats);
connect(ui.action_Save, &QAction::triggered, this, &GMainWindow::OnSave);
connect(ui.action_Load, &QAction::triggered, this, &GMainWindow::OnLoad);
// View
connect(ui.action_Single_Window_Mode, &QAction::triggered, this,
@@ -1033,6 +1036,8 @@ void GMainWindow::ShutdownGame() {
ui.action_Stop->setEnabled(false);
ui.action_Restart->setEnabled(false);
ui.action_Cheats->setEnabled(false);
ui.action_Save->setEnabled(false);
ui.action_Load->setEnabled(false);
ui.action_Load_Amiibo->setEnabled(false);
ui.action_Remove_Amiibo->setEnabled(false);
ui.action_Report_Compatibility->setEnabled(false);
@@ -1343,6 +1348,8 @@ void GMainWindow::OnStartGame() {
ui.action_Stop->setEnabled(true);
ui.action_Restart->setEnabled(true);
ui.action_Cheats->setEnabled(true);
ui.action_Save->setEnabled(true);
ui.action_Load->setEnabled(true);
ui.action_Load_Amiibo->setEnabled(true);
ui.action_Report_Compatibility->setEnabled(true);
ui.action_Enable_Frame_Advancing->setEnabled(true);
@@ -1496,6 +1503,23 @@ void GMainWindow::OnCheats() {
cheat_dialog.exec();
}
void GMainWindow::OnSave() {
Core::System& system{Core::System::GetInstance()};
auto fs = std::ofstream("save0.citrasave");
emu_thread->SetRunning(false);
Core::System::GetInstance().Save(fs);
emu_thread->SetRunning(true);
}
void GMainWindow::OnLoad() {
if (QFileInfo("save0.citrasave").exists()) {
auto fs = std::ifstream("save0.citrasave");
emu_thread->SetRunning(false);
Core::System::GetInstance().Load(fs);
emu_thread->SetRunning(true);
}
}
void GMainWindow::OnConfigure() {
ConfigureDialog configureDialog(this, hotkey_registry,
!multiplayer_state->IsHostingPublicRoom());

View File

@@ -163,6 +163,8 @@ private slots:
void OnStartGame();
void OnPauseGame();
void OnStopGame();
void OnSave();
void OnLoad();
void OnMenuReportCompatibility();
/// Called whenever a user selects a game in the game list widget.
void OnGameListLoadFile(QString game_path);

View File

@@ -88,6 +88,8 @@
<addaction name="separator"/>
<addaction name="action_Configure"/>
<addaction name="action_Cheats"/>
<addaction name="action_Save"/>
<addaction name="action_Load"/>
</widget>
<widget class="QMenu" name="menu_View">
<property name="title">
@@ -217,6 +219,22 @@
<string>&amp;Stop</string>
</property>
</action>
<action name="action_Save">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Save</string>
</property>
</action>
<action name="action_Load">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Load</string>
</property>
</action>
<action name="action_FAQ">
<property name="text">
<string>FAQ</string>