Add a File->Close option
This commit is contained in:
parent
ca54f9f212
commit
222a9721aa
|
@ -167,6 +167,9 @@ bool EmulatorWindow::Initialize() {
|
|||
file_menu->AddChild(
|
||||
MenuItem::Create(MenuItem::Type::kString, L"&Open", L"Ctrl+O",
|
||||
std::bind(&EmulatorWindow::FileOpen, this)));
|
||||
file_menu->AddChild(
|
||||
MenuItem::Create(MenuItem::Type::kString, L"Close",
|
||||
std::bind(&EmulatorWindow::FileClose, this)));
|
||||
file_menu->AddChild(MenuItem::Create(MenuItem::Type::kString, L"E&xit",
|
||||
L"Alt+F4",
|
||||
[this]() { window_->Close(); }));
|
||||
|
@ -304,6 +307,12 @@ void EmulatorWindow::FileOpen() {
|
|||
}
|
||||
}
|
||||
|
||||
void EmulatorWindow::FileClose() {
|
||||
if (emulator_->is_title_open()) {
|
||||
emulator_->TerminateTitle();
|
||||
}
|
||||
}
|
||||
|
||||
void EmulatorWindow::CheckHideCursor() {
|
||||
if (!window_->is_fullscreen()) {
|
||||
// Only hide when fullscreen.
|
||||
|
|
|
@ -44,6 +44,7 @@ class EmulatorWindow {
|
|||
|
||||
void FileDrop(wchar_t* filename);
|
||||
void FileOpen();
|
||||
void FileClose();
|
||||
void CheckHideCursor();
|
||||
void CpuTimeScalarReset();
|
||||
void CpuTimeScalarSetHalf();
|
||||
|
|
|
@ -178,6 +178,17 @@ X_STATUS Emulator::Setup(
|
|||
return result;
|
||||
}
|
||||
|
||||
X_STATUS Emulator::TerminateTitle() {
|
||||
if (!is_title_open()) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
kernel_state_->TerminateTitle();
|
||||
title_id_ = 0;
|
||||
game_title_ = L"";
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
X_STATUS Emulator::LaunchPath(std::wstring path) {
|
||||
// Launch based on file type.
|
||||
// This is a silly guess based on file extension.
|
||||
|
|
|
@ -56,6 +56,9 @@ class Emulator {
|
|||
// Title of the game in the default language.
|
||||
const std::wstring& game_title() const { return game_title_; }
|
||||
|
||||
// Are we currently running a title?
|
||||
bool is_title_open() const { return title_id_ != 0; }
|
||||
|
||||
// Window used for displaying graphical output.
|
||||
ui::Window* display_window() const { return display_window_; }
|
||||
|
||||
|
@ -103,6 +106,9 @@ class Emulator {
|
|||
std::function<std::vector<std::unique_ptr<hid::InputDriver>>(ui::Window*)>
|
||||
input_driver_factory);
|
||||
|
||||
// Terminates the currently running title.
|
||||
X_STATUS TerminateTitle();
|
||||
|
||||
// Launches a game from the given file path.
|
||||
// This will attempt to infer the type of the given file (such as an iso, etc)
|
||||
// using heuristics.
|
||||
|
|
Loading…
Reference in New Issue