small QoL
This commit is contained in:
@@ -34,6 +34,23 @@ void KaizenGui::QueryDevices(SDL_Event event) {
|
||||
}
|
||||
}
|
||||
|
||||
void KaizenGui::FileDialog() {
|
||||
NFD::Guard guard;
|
||||
NFD::UniquePath path;
|
||||
static const std::vector<nfdfilteritem_t> filterItems = {
|
||||
{"Nintendo 64 rom archive", "rar,RAR,tar,TAR,zip,ZIP,7z,7Z"},
|
||||
{"Nintendo 64 rom", "n64,z64,v64,N64,Z64,V64"}
|
||||
};
|
||||
|
||||
auto result = NFD::OpenDialog(path, filterItems.data(), filterItems.size());
|
||||
if(result == NFD_ERROR)
|
||||
Util::panic("Error: {}", NFD::GetError());
|
||||
|
||||
if(result != NFD_CANCEL) {
|
||||
LoadROM(path.get());
|
||||
}
|
||||
}
|
||||
|
||||
void KaizenGui::HandleInput(SDL_Event event) {
|
||||
n64::PIF &pif = core->cpu->GetMem().mmio.si.pif;
|
||||
switch(event.type) {
|
||||
@@ -90,6 +107,24 @@ void KaizenGui::HandleInput(SDL_Event event) {
|
||||
break;
|
||||
{
|
||||
auto keys = SDL_GetKeyboardState(nullptr);
|
||||
if((keys[SDL_SCANCODE_LCTRL] || keys[SDL_SCANCODE_RCTRL]) && keys[SDL_SCANCODE_O]) {
|
||||
FileDialog();
|
||||
}
|
||||
|
||||
if(core->romLoaded) {
|
||||
if(keys[SDL_SCANCODE_P]) {
|
||||
emuThread.TogglePause();
|
||||
}
|
||||
|
||||
if(keys[SDL_SCANCODE_R]) {
|
||||
emuThread.Reset();
|
||||
}
|
||||
|
||||
if(keys[SDL_SCANCODE_Q]) {
|
||||
emuThread.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
pif.UpdateButton(0, n64::Controller::Key::Z, keys[SDL_SCANCODE_Z]);
|
||||
pif.UpdateButton(0, n64::Controller::Key::CUp, keys[SDL_SCANCODE_HOME]);
|
||||
pif.UpdateButton(0, n64::Controller::Key::CDown, keys[SDL_SCANCODE_END]);
|
||||
@@ -115,26 +150,10 @@ void KaizenGui::HandleInput(SDL_Event event) {
|
||||
void KaizenGui::RenderUI() {
|
||||
gui::StartFrame();
|
||||
|
||||
static bool actionsEnabled = false;
|
||||
|
||||
if(ImGui::BeginMainMenuBar()) {
|
||||
if(ImGui::BeginMenu("File")) {
|
||||
if(ImGui::MenuItem("Open")) {
|
||||
NFD::Guard guard;
|
||||
NFD::UniquePath path;
|
||||
static const std::vector<nfdfilteritem_t> filterItems = {
|
||||
{"Nintendo 64 rom archive", "rar,RAR,tar,TAR,zip,ZIP,7z,7Z"},
|
||||
{"Nintendo 64 rom", "n64,z64,v64,N64,Z64,V64"}
|
||||
};
|
||||
|
||||
auto result = NFD::OpenDialog(path, filterItems.data(), filterItems.size());
|
||||
if(result == NFD_ERROR)
|
||||
Util::panic("Error: {}", NFD::GetError());
|
||||
|
||||
if(result != NFD_CANCEL) {
|
||||
LoadROM(path.get());
|
||||
actionsEnabled = true;
|
||||
}
|
||||
if(ImGui::MenuItem("Open", "Ctrl-O")) {
|
||||
FileDialog();
|
||||
}
|
||||
if(ImGui::MenuItem("Exit")) {
|
||||
quit = true;
|
||||
@@ -143,19 +162,19 @@ void KaizenGui::RenderUI() {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if(ImGui::BeginMenu("Emulation")) {
|
||||
ImGui::BeginDisabled(!actionsEnabled);
|
||||
ImGui::BeginDisabled(!core->romLoaded);
|
||||
|
||||
if(ImGui::MenuItem(core->pause ? "Resume" : "Pause")) {
|
||||
if(ImGui::MenuItem(core->pause ? "Resume" : "Pause", "P")) {
|
||||
emuThread.TogglePause();
|
||||
}
|
||||
|
||||
if(ImGui::MenuItem("Reset")) {
|
||||
if(ImGui::MenuItem("Reset", "R")) {
|
||||
emuThread.Reset();
|
||||
}
|
||||
|
||||
if(ImGui::MenuItem("Stop")) {
|
||||
if(ImGui::MenuItem("Stop", "Q")) {
|
||||
emuThread.Stop();
|
||||
actionsEnabled = false;
|
||||
core->romLoaded = false;
|
||||
}
|
||||
|
||||
ImGui::EndDisabled();
|
||||
@@ -199,7 +218,7 @@ void KaizenGui::RenderUI() {
|
||||
ImGui::RenderPlatformWindowsDefault();
|
||||
}
|
||||
|
||||
if(!core->pause && core->romLoaded) {
|
||||
if(core->romLoaded) {
|
||||
core->parallel.UpdateScreen(*core.get());
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user