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

@@ -46,7 +46,6 @@ include_directories(
../../external/capstone/include
../../external/imgui
../../external/imgui/backends
../../external/nfd/src/include
../../external/cflags/include
../../external/mINI/src/
ImGuiImpl/
@@ -109,7 +108,6 @@ add_subdirectory(../../external/SDL SDL)
add_subdirectory(../../external/cflags cflags)
add_subdirectory(../../external/imgui imgui)
add_subdirectory(../../external/mINI mINI)
add_subdirectory(../../external/nfd nfd)
set(CAPSTONE_ARCHITECTURE_DEFAULT OFF)
set(CAPSTONE_MIPS_SUPPORT ON)
set(CAPSTONE_X86_SUPPORT ON)
@@ -134,7 +132,7 @@ add_executable(kaizen
Debugger.hpp
Debugger.cpp)
target_link_libraries(kaizen PUBLIC imgui nfd SDL3::SDL3 SDL3::SDL3-static cflags::cflags discord-rpc mio parallel-rdp capstone backend)
target_link_libraries(kaizen PUBLIC imgui SDL3::SDL3 SDL3::SDL3-static cflags::cflags discord-rpc mio parallel-rdp capstone backend)
target_compile_definitions(kaizen PUBLIC SDL_MAIN_HANDLED)
file(COPY ../../resources/ DESTINATION ${PROJECT_BINARY_DIR}/resources/)

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 {

View File

@@ -29,7 +29,6 @@ private:
bool fileDialogOpen = false;
bool quit = false;
std::function<void()> emuExitFunc;
void FileDialog();
void RenderUI();
void HandleInput(SDL_Event event);
void QueryDevices(SDL_Event event);

View File

@@ -1,5 +1,4 @@
#include <SettingsWindow.hpp>
#include <nfd.hpp>
#include <log.hpp>
#include <Options.hpp>
#include <imgui.h>
@@ -20,18 +19,22 @@ bool SettingsWindow::render() {
if(ImGui::BeginTabItem("General")) {
if(ImGui::Button("Pick...")) {
NFD::Guard guard;
NFD::UniquePath outPath;
SDL_ShowOpenFolderDialog([](void *userdata, const char * const *filelist, int filter) {
SettingsWindow* settings = (SettingsWindow*)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;
}
auto result = NFD::PickFolder(outPath);
if(result == NFD_ERROR)
panic("Error: {}", NFD::GetError());
if(result != NFD_CANCEL) {
savesPath = outPath.get();
Options::GetInstance().SetValue<std::string>("general", "savePath", savesPath);
applyEnabled = true;
}
settings->savesPath = *filelist;
Options::GetInstance().SetValue<std::string>("general", "savePath", settings->savesPath);
settings->applyEnabled = true;
}, this, window.getHandle(), nullptr, false);
}
ImGui::SameLine();
ImGui::BeginDisabled();

View File

@@ -1,18 +1,19 @@
#pragma once
#include <AudioSettings.hpp>
#include <CPUSettings.hpp>
#include <SDL3/SDL.h>
#include <NativeWindow.hpp>
#include <memory>
class SettingsWindow final {
AudioSettings audioSettings;
std::string savesPath;
bool applyEnabled = false;
gui::NativeWindow& window;
public:
CPUSettings cpuSettings;
bool isOpen = false;
bool render();
SettingsWindow() = default;
SettingsWindow(gui::NativeWindow& window);
[[nodiscard]] float getVolumeL() const { return audioSettings.volumeL / 100.f; }
[[nodiscard]] float getVolumeR() const { return audioSettings.volumeR / 100.f; }
};