diff --git a/src/app/core/platform/app_delegate.mm b/src/app/core/platform/app_delegate.mm index 3609bd4b..491c4527 100644 --- a/src/app/core/platform/app_delegate.mm +++ b/src/app/core/platform/app_delegate.mm @@ -206,7 +206,8 @@ } - (void)openFileAction:(id)sender { - if (!yaze::app::SharedRom::shared_rom_->LoadFromFile(FileDialogWrapper::ShowOpenFileDialog()) + if (!yaze::app::SharedRom::shared_rom_ + ->LoadFromFile(yaze::app::core::FileDialogWrapper::ShowOpenFileDialog()) .ok()) { NSAlert *alert = [[NSAlert alloc] init]; [alert setMessageText:@"Error"]; diff --git a/src/app/core/platform/file_dialog.cc b/src/app/core/platform/file_dialog.cc index 2e16fe7c..08c9669b 100644 --- a/src/app/core/platform/file_dialog.cc +++ b/src/app/core/platform/file_dialog.cc @@ -1,5 +1,9 @@ #include "file_dialog.h" +namespace yaze { +namespace app { +namespace core { + #if defined(__linux__) std::string FileDialogWrapper::ShowOpenFileDialog() { @@ -20,4 +24,8 @@ std::vector FileDialogWrapper::GetFilesInFolder( return {"Linux: Files in folder"}; } -#endif \ No newline at end of file +#endif + +} // namespace core +} // namespace app +} // namespace yaze \ No newline at end of file diff --git a/src/app/core/platform/file_dialog.h b/src/app/core/platform/file_dialog.h index 09bc827d..a4732636 100644 --- a/src/app/core/platform/file_dialog.h +++ b/src/app/core/platform/file_dialog.h @@ -4,6 +4,10 @@ #include #include +namespace yaze { +namespace app { +namespace core { + #ifdef _WIN32 // Include Windows-specific headers #include @@ -83,7 +87,7 @@ class FileDialogWrapper { } static std::vector GetSubdirectoriesInFolder( - const std::string& folder_path) { + const std::string &folder_path) { std::vector subdirectories; WIN32_FIND_DATA findFileData; HANDLE hFind = FindFirstFile((folder_path + "\\*").c_str(), &findFileData); @@ -102,7 +106,7 @@ class FileDialogWrapper { } static std::vector GetFilesInFolder( - const std::string& folder_path) { + const std::string &folder_path) { std::vector files; WIN32_FIND_DATA findFileData; HANDLE hFind = FindFirstFile((folder_path + "\\*").c_str(), &findFileData); @@ -135,4 +139,8 @@ class FileDialogWrapper { #endif +} // namespace core +} // namespace app +} // namespace yaze + #endif // YAZE_APP_CORE_PLATFORM_FILE_DIALOG_H diff --git a/src/app/core/platform/file_dialog.mm b/src/app/core/platform/file_dialog.mm index e9f05bb4..31f677b3 100644 --- a/src/app/core/platform/file_dialog.mm +++ b/src/app/core/platform/file_dialog.mm @@ -56,7 +56,7 @@ std::vector FileDialogWrapper::GetSubdirectoriesInFolder(const std: #import -std::string FileDialogWrapper::ShowOpenFileDialog() { +std::string yaze::app::core::FileDialogWrapper::ShowOpenFileDialog() { NSOpenPanel* openPanel = [NSOpenPanel openPanel]; [openPanel setCanChooseFiles:YES]; [openPanel setCanChooseDirectories:NO]; @@ -71,7 +71,7 @@ std::string FileDialogWrapper::ShowOpenFileDialog() { return ""; } -std::string FileDialogWrapper::ShowOpenFolderDialog() { +std::string yaze::app::core::FileDialogWrapper::ShowOpenFolderDialog() { NSOpenPanel* openPanel = [NSOpenPanel openPanel]; [openPanel setCanChooseFiles:NO]; [openPanel setCanChooseDirectories:YES]; @@ -86,7 +86,8 @@ std::string FileDialogWrapper::ShowOpenFolderDialog() { return ""; } -std::vector FileDialogWrapper::GetFilesInFolder(const std::string& folder) { +std::vector yaze::app::core::FileDialogWrapper::GetFilesInFolder( + const std::string& folder) { std::vector filenames; NSFileManager* fileManager = [NSFileManager defaultManager]; NSDirectoryEnumerator* enumerator = @@ -101,7 +102,8 @@ std::vector FileDialogWrapper::GetFilesInFolder(const std::string& return filenames; } -std::vector FileDialogWrapper::GetSubdirectoriesInFolder(const std::string& folder) { +std::vector yaze::app::core::FileDialogWrapper::GetSubdirectoriesInFolder( + const std::string& folder) { std::vector subdirectories; NSFileManager* fileManager = [NSFileManager defaultManager]; NSDirectoryEnumerator* enumerator = @@ -125,4 +127,4 @@ std::vector FileDialogWrapper::GetSubdirectoriesInFolder(const std: // Unsupported platform #endif // TARGET_OS_MAC -#endif // __APPLE__ && __MACH__ +#endif // __APPLE__ && __MACH__ \ No newline at end of file diff --git a/src/app/editor/code/assembly_editor.cc b/src/app/editor/code/assembly_editor.cc index 2f783b8e..77f6f240 100644 --- a/src/app/editor/code/assembly_editor.cc +++ b/src/app/editor/code/assembly_editor.cc @@ -1,7 +1,6 @@ #include "assembly_editor.h" #include "ImGuiColorTextEdit/TextEditor.h" - #include "app/core/platform/file_dialog.h" #include "app/gui/icons.h" #include "app/gui/input.h" @@ -11,6 +10,8 @@ namespace yaze { namespace app { namespace editor { +using core::FileDialogWrapper; + namespace { std::vector RemoveIgnoredFiles( diff --git a/src/app/editor/code/memory_editor.h b/src/app/editor/code/memory_editor.h index 0923cf2c..3fb5e086 100644 --- a/src/app/editor/code/memory_editor.h +++ b/src/app/editor/code/memory_editor.h @@ -46,7 +46,7 @@ struct MemoryEditorWithDiffChecker : public SharedRom { static Rom comparison_rom; ImGui::Begin("Hex Editor", &show_memory_editor); if (ImGui::Button("Compare Rom")) { - auto file_name = FileDialogWrapper::ShowOpenFileDialog(); + auto file_name = core::FileDialogWrapper::ShowOpenFileDialog(); PRINT_IF_ERROR(comparison_rom.LoadFromFile(file_name)); show_compare_rom = true; } diff --git a/src/app/editor/editor_manager.cc b/src/app/editor/editor_manager.cc index 24125ade..2c1decea 100644 --- a/src/app/editor/editor_manager.cc +++ b/src/app/editor/editor_manager.cc @@ -39,6 +39,7 @@ namespace app { namespace editor { using namespace ImGui; +using core::FileDialogWrapper; namespace { @@ -484,8 +485,8 @@ void EditorManager::DrawYazeMenuBar() { } if (MenuItem("Open Project")) { // Open an existing project - status_ = - current_project_.Open(FileDialogWrapper::ShowOpenFileDialog()); + status_ = current_project_.Open( + core::FileDialogWrapper::ShowOpenFileDialog()); if (status_.ok()) { status_ = OpenProject(); } diff --git a/src/app/editor/graphics/graphics_editor.cc b/src/app/editor/graphics/graphics_editor.cc index 2a6ee854..7c0ac5ad 100644 --- a/src/app/editor/graphics/graphics_editor.cc +++ b/src/app/editor/graphics/graphics_editor.cc @@ -370,10 +370,10 @@ absl::Status GraphicsEditor::UpdatePaletteColumn() { RETURN_IF_ERROR( rom() ->mutable_gfx_sheets() - ->at(current_sheet_) + ->data()[current_sheet_] .ApplyPaletteWithTransparent(palette, edit_palette_sub_index_)); Renderer::GetInstance().UpdateBitmap( - &rom()->mutable_gfx_sheets()->at(current_sheet_), true); + &rom()->mutable_gfx_sheets()->data()[current_sheet_], true); refresh_graphics_ = false; } } diff --git a/src/app/editor/sprite/sprite_editor.cc b/src/app/editor/sprite/sprite_editor.cc index 74b0fe6d..fb7ce453 100644 --- a/src/app/editor/sprite/sprite_editor.cc +++ b/src/app/editor/sprite/sprite_editor.cc @@ -243,7 +243,7 @@ void SpriteEditor::DrawCustomSpritesMetadata() { // ZSprite Maker format open file dialog if (ImGui::Button("Open ZSprite")) { // Open ZSprite file - std::string file_path = FileDialogWrapper::ShowOpenFileDialog(); + std::string file_path = core::FileDialogWrapper::ShowOpenFileDialog(); if (!file_path.empty()) { zsprite::ZSprite zsprite; status_ = zsprite.Load(file_path); diff --git a/src/app/emu/emulator.cc b/src/app/emu/emulator.cc index 8f9807cf..b70aee12 100644 --- a/src/app/emu/emulator.cc +++ b/src/app/emu/emulator.cc @@ -246,7 +246,7 @@ void Emulator::RenderNavBar() { } if (open_file) { - auto file_name = FileDialogWrapper::ShowOpenFileDialog(); + auto file_name = core::FileDialogWrapper::ShowOpenFileDialog(); if (!file_name.empty()) { std::ifstream file(file_name, std::ios::binary); // Load the data directly into rom_data