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) {
|
void KaizenGui::HandleInput(SDL_Event event) {
|
||||||
n64::PIF &pif = core->cpu->GetMem().mmio.si.pif;
|
n64::PIF &pif = core->cpu->GetMem().mmio.si.pif;
|
||||||
switch(event.type) {
|
switch(event.type) {
|
||||||
@@ -90,6 +107,24 @@ void KaizenGui::HandleInput(SDL_Event event) {
|
|||||||
break;
|
break;
|
||||||
{
|
{
|
||||||
auto keys = SDL_GetKeyboardState(nullptr);
|
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::Z, keys[SDL_SCANCODE_Z]);
|
||||||
pif.UpdateButton(0, n64::Controller::Key::CUp, keys[SDL_SCANCODE_HOME]);
|
pif.UpdateButton(0, n64::Controller::Key::CUp, keys[SDL_SCANCODE_HOME]);
|
||||||
pif.UpdateButton(0, n64::Controller::Key::CDown, keys[SDL_SCANCODE_END]);
|
pif.UpdateButton(0, n64::Controller::Key::CDown, keys[SDL_SCANCODE_END]);
|
||||||
@@ -115,26 +150,10 @@ void KaizenGui::HandleInput(SDL_Event event) {
|
|||||||
void KaizenGui::RenderUI() {
|
void KaizenGui::RenderUI() {
|
||||||
gui::StartFrame();
|
gui::StartFrame();
|
||||||
|
|
||||||
static bool actionsEnabled = false;
|
|
||||||
|
|
||||||
if(ImGui::BeginMainMenuBar()) {
|
if(ImGui::BeginMainMenuBar()) {
|
||||||
if(ImGui::BeginMenu("File")) {
|
if(ImGui::BeginMenu("File")) {
|
||||||
if(ImGui::MenuItem("Open")) {
|
if(ImGui::MenuItem("Open", "Ctrl-O")) {
|
||||||
NFD::Guard guard;
|
FileDialog();
|
||||||
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("Exit")) {
|
if(ImGui::MenuItem("Exit")) {
|
||||||
quit = true;
|
quit = true;
|
||||||
@@ -143,19 +162,19 @@ void KaizenGui::RenderUI() {
|
|||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
if(ImGui::BeginMenu("Emulation")) {
|
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();
|
emuThread.TogglePause();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ImGui::MenuItem("Reset")) {
|
if(ImGui::MenuItem("Reset", "R")) {
|
||||||
emuThread.Reset();
|
emuThread.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ImGui::MenuItem("Stop")) {
|
if(ImGui::MenuItem("Stop", "Q")) {
|
||||||
emuThread.Stop();
|
emuThread.Stop();
|
||||||
actionsEnabled = false;
|
core->romLoaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
@@ -199,7 +218,7 @@ void KaizenGui::RenderUI() {
|
|||||||
ImGui::RenderPlatformWindowsDefault();
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!core->pause && core->romLoaded) {
|
if(core->romLoaded) {
|
||||||
core->parallel.UpdateScreen(*core.get());
|
core->parallel.UpdateScreen(*core.get());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
std::function<void()> emuExitFunc;
|
std::function<void()> emuExitFunc;
|
||||||
|
void FileDialog();
|
||||||
void RenderUI();
|
void RenderUI();
|
||||||
void HandleInput(SDL_Event event);
|
void HandleInput(SDL_Event event);
|
||||||
void QueryDevices(SDL_Event event);
|
void QueryDevices(SDL_Event event);
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
std::string savePath;
|
std::string savePath;
|
||||||
|
|
||||||
bool SettingsWindow::render() {
|
bool SettingsWindow::render() {
|
||||||
static bool applyEnabled = false;
|
|
||||||
ImGui::OpenPopup("Settings", ImGuiPopupFlags_None);
|
ImGui::OpenPopup("Settings", ImGuiPopupFlags_None);
|
||||||
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
|
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
|
||||||
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class SettingsWindow final {
|
|||||||
CPUSettings cpuSettings;
|
CPUSettings cpuSettings;
|
||||||
AudioSettings audioSettings;
|
AudioSettings audioSettings;
|
||||||
std::string savesPath;
|
std::string savesPath;
|
||||||
|
bool applyEnabled = false;
|
||||||
public:
|
public:
|
||||||
bool render();
|
bool render();
|
||||||
SettingsWindow() = default;
|
SettingsWindow() = default;
|
||||||
|
|||||||
Reference in New Issue
Block a user