get rid of NFD dependency since im using SDL3 and its builtin functionality

This commit is contained in:
irisz64
2025-07-22 12:47:31 +02:00
parent 3520a309ed
commit 4bcfd18d0b
53 changed files with 39 additions and 8093 deletions

View File

@@ -1,11 +1,10 @@
#include <KaizenGui.hpp>
#include <nfd.hpp>
#include <backend/Core.hpp>
#include <ImGuiImpl/GUI.hpp>
#include <ImGuiImpl/StatusBar.hpp>
#include <resources/gamecontrollerdb.h>
KaizenGui::KaizenGui() noexcept : window("Kaizen", 800, 600), core(std::make_shared<n64::Core>(static_cast<n64::Core::CPUType>(settingsWindow.cpuSettings.GetCPUType()))), vulkanWidget(core, window.getHandle()), emuThread(core, fpsCounter, vulkanWidget, settingsWindow) {
KaizenGui::KaizenGui() noexcept : window("Kaizen", 800, 600), settingsWindow(window), core(std::make_shared<n64::Core>(static_cast<n64::Core::CPUType>(settingsWindow.cpuSettings.GetCPUType()))), vulkanWidget(core, window.getHandle()), emuThread(core, fpsCounter, vulkanWidget, settingsWindow) {
gui::Initialize(core->parallel.wsi, window.getHandle());
SDL_InitSubSystem(SDL_INIT_GAMEPAD);
@@ -34,22 +33,6 @@ 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 or rom archive", "rar,RAR,tar,TAR,zip,ZIP,7z,7Z,n64,z64,v64,N64,Z64,V64"}
};
auto result = NFD::OpenDialog(path, filterItems.data(), filterItems.size());
if(result == NFD_ERROR)
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) {
@@ -230,17 +213,31 @@ void KaizenGui::RenderUI() {
ImGui::RenderPlatformWindowsDefault();
}
if(fileDialogOpen) {
fileDialogOpen = false;
const SDL_DialogFileFilter filters[] = {{"All files", "*"}, {"Nintendo 64 executable", "n64;z64;v64"}, {"Nintendo 64 executable archive", "rar;tar;zip;7z"}};
SDL_ShowOpenFileDialog([](void *userdata, const char * const *filelist, int filter) {
KaizenGui* kaizen = (KaizenGui*)userdata;
if (!filelist) {
panic("An error occured: %s", SDL_GetError());
return;
} else if (!*filelist) {
warn("The user did not select any file.");
warn("Most likely, the dialog was canceled.");
return;
}
kaizen->LoadROM(*filelist);
}, this, window.getHandle(), filters, 3, nullptr, false);
}
if(core->romLoaded) {
core->parallel.UpdateScreen(*core.get());
return;
}
core->parallel.UpdateScreen(*core.get(), false);
if(fileDialogOpen) {
fileDialogOpen = false;
FileDialog();
}
}
void KaizenGui::LoadROM(const std::string &path) noexcept {