refactor: Restructure file dialog handling and introduce utility classes

- Updated file dialog references across the application to utilize a new `util::FileDialogWrapper` for consistent file handling.
- Refactored existing code to replace direct calls to `core::FileDialogWrapper` with the new utility class, enhancing modularity and maintainability.
- Introduced `util::PlatformPaths` for cross-platform directory management, ensuring consistent access to user directories and application data paths.
- Added new utility functions for file operations, improving the overall file handling capabilities within the application.
- Updated CMake configurations to include new utility source files, streamlining the build process.
This commit is contained in:
scawful
2025-10-04 23:26:42 -04:00
parent 429506e503
commit bcc8f8e8f9
39 changed files with 385 additions and 144 deletions

View File

@@ -6,13 +6,13 @@
#include "absl/strings/str_cat.h"
#include "absl/strings/match.h"
#include "app/core/platform/file_dialog.h"
#include "util/file_util.h"
#include "app/gui/icons.h"
#include "app/gui/modules/text_editor.h"
namespace yaze::editor {
using core::FileDialogWrapper;
using util::FileDialogWrapper;
namespace {
@@ -283,7 +283,7 @@ void AssemblyEditor::DrawFileTabView() {
void AssemblyEditor::DrawFileMenu() {
if (ImGui::BeginMenu("File")) {
if (ImGui::MenuItem("Open", "Ctrl+O")) {
auto filename = core::FileDialogWrapper::ShowOpenFileDialog();
auto filename = util::FileDialogWrapper::ShowOpenFileDialog();
ChangeActiveFile(filename);
}
if (ImGui::MenuItem("Save", "Ctrl+S")) {

View File

@@ -1,7 +1,7 @@
#ifndef YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
#define YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
#include "app/core/platform/file_dialog.h"
#include "util/file_util.h"
#include "app/gui/input.h"
#include "app/rom.h"
#include "app/snes.h"
@@ -25,7 +25,7 @@ struct MemoryEditorWithDiffChecker {
static Rom comparison_rom;
ImGui::Begin("Hex Editor", &show_memory_editor);
if (ImGui::Button("Compare Rom")) {
auto file_name = core::FileDialogWrapper::ShowOpenFileDialog();
auto file_name = util::FileDialogWrapper::ShowOpenFileDialog();
PRINT_IF_ERROR(comparison_rom.LoadFromFile(file_name));
show_compare_rom = true;
}

View File

@@ -6,7 +6,7 @@
#include "absl/strings/match.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_split.h"
#include "app/core/platform/file_dialog.h"
#include "util/file_util.h"
#include "app/editor/system/toast_manager.h"
#include "app/gui/icons.h"
#include "imgui/imgui.h"
@@ -40,7 +40,7 @@ void ProjectFileEditor::Draw() {
ImGui::TableNextColumn();
if (ImGui::Button(absl::StrFormat("%s Open", ICON_MD_FOLDER_OPEN).c_str())) {
auto file = core::FileDialogWrapper::ShowOpenFileDialog();
auto file = util::FileDialogWrapper::ShowOpenFileDialog();
if (!file.empty()) {
auto status = LoadFile(file);
if (!status.ok() && toast_manager_) {
@@ -65,7 +65,7 @@ void ProjectFileEditor::Draw() {
ImGui::TableNextColumn();
if (ImGui::Button(absl::StrFormat("%s Save As", ICON_MD_SAVE_AS).c_str())) {
auto file = core::FileDialogWrapper::ShowSaveFileDialog(
auto file = util::FileDialogWrapper::ShowSaveFileDialog(
filepath_.empty() ? "project" : filepath_, "yaze");
if (!file.empty()) {
auto status = SaveFileAs(file);