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());