chore: Refactor file_dialog.cc and file_dialog.h to use namespace aliases
This commit is contained in:
@@ -206,7 +206,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)openFileAction:(id)sender {
|
- (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()) {
|
.ok()) {
|
||||||
NSAlert *alert = [[NSAlert alloc] init];
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
[alert setMessageText:@"Error"];
|
[alert setMessageText:@"Error"];
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
#include "file_dialog.h"
|
#include "file_dialog.h"
|
||||||
|
|
||||||
|
namespace yaze {
|
||||||
|
namespace app {
|
||||||
|
namespace core {
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
|
|
||||||
std::string FileDialogWrapper::ShowOpenFileDialog() {
|
std::string FileDialogWrapper::ShowOpenFileDialog() {
|
||||||
@@ -20,4 +24,8 @@ std::vector<std::string> FileDialogWrapper::GetFilesInFolder(
|
|||||||
return {"Linux: Files in folder"};
|
return {"Linux: Files in folder"};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
} // namespace core
|
||||||
|
} // namespace app
|
||||||
|
} // namespace yaze
|
||||||
@@ -4,6 +4,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace yaze {
|
||||||
|
namespace app {
|
||||||
|
namespace core {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Include Windows-specific headers
|
// Include Windows-specific headers
|
||||||
#include <shobjidl.h>
|
#include <shobjidl.h>
|
||||||
@@ -83,7 +87,7 @@ class FileDialogWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<std::string> GetSubdirectoriesInFolder(
|
static std::vector<std::string> GetSubdirectoriesInFolder(
|
||||||
const std::string& folder_path) {
|
const std::string &folder_path) {
|
||||||
std::vector<std::string> subdirectories;
|
std::vector<std::string> subdirectories;
|
||||||
WIN32_FIND_DATA findFileData;
|
WIN32_FIND_DATA findFileData;
|
||||||
HANDLE hFind = FindFirstFile((folder_path + "\\*").c_str(), &findFileData);
|
HANDLE hFind = FindFirstFile((folder_path + "\\*").c_str(), &findFileData);
|
||||||
@@ -102,7 +106,7 @@ class FileDialogWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<std::string> GetFilesInFolder(
|
static std::vector<std::string> GetFilesInFolder(
|
||||||
const std::string& folder_path) {
|
const std::string &folder_path) {
|
||||||
std::vector<std::string> files;
|
std::vector<std::string> files;
|
||||||
WIN32_FIND_DATA findFileData;
|
WIN32_FIND_DATA findFileData;
|
||||||
HANDLE hFind = FindFirstFile((folder_path + "\\*").c_str(), &findFileData);
|
HANDLE hFind = FindFirstFile((folder_path + "\\*").c_str(), &findFileData);
|
||||||
@@ -135,4 +139,8 @@ class FileDialogWrapper {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
} // namespace core
|
||||||
|
} // namespace app
|
||||||
|
} // namespace yaze
|
||||||
|
|
||||||
#endif // YAZE_APP_CORE_PLATFORM_FILE_DIALOG_H
|
#endif // YAZE_APP_CORE_PLATFORM_FILE_DIALOG_H
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ std::vector<std::string> FileDialogWrapper::GetSubdirectoriesInFolder(const std:
|
|||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
std::string FileDialogWrapper::ShowOpenFileDialog() {
|
std::string yaze::app::core::FileDialogWrapper::ShowOpenFileDialog() {
|
||||||
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
|
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
|
||||||
[openPanel setCanChooseFiles:YES];
|
[openPanel setCanChooseFiles:YES];
|
||||||
[openPanel setCanChooseDirectories:NO];
|
[openPanel setCanChooseDirectories:NO];
|
||||||
@@ -71,7 +71,7 @@ std::string FileDialogWrapper::ShowOpenFileDialog() {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FileDialogWrapper::ShowOpenFolderDialog() {
|
std::string yaze::app::core::FileDialogWrapper::ShowOpenFolderDialog() {
|
||||||
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
|
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
|
||||||
[openPanel setCanChooseFiles:NO];
|
[openPanel setCanChooseFiles:NO];
|
||||||
[openPanel setCanChooseDirectories:YES];
|
[openPanel setCanChooseDirectories:YES];
|
||||||
@@ -86,7 +86,8 @@ std::string FileDialogWrapper::ShowOpenFolderDialog() {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> FileDialogWrapper::GetFilesInFolder(const std::string& folder) {
|
std::vector<std::string> yaze::app::core::FileDialogWrapper::GetFilesInFolder(
|
||||||
|
const std::string& folder) {
|
||||||
std::vector<std::string> filenames;
|
std::vector<std::string> filenames;
|
||||||
NSFileManager* fileManager = [NSFileManager defaultManager];
|
NSFileManager* fileManager = [NSFileManager defaultManager];
|
||||||
NSDirectoryEnumerator* enumerator =
|
NSDirectoryEnumerator* enumerator =
|
||||||
@@ -101,7 +102,8 @@ std::vector<std::string> FileDialogWrapper::GetFilesInFolder(const std::string&
|
|||||||
return filenames;
|
return filenames;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> FileDialogWrapper::GetSubdirectoriesInFolder(const std::string& folder) {
|
std::vector<std::string> yaze::app::core::FileDialogWrapper::GetSubdirectoriesInFolder(
|
||||||
|
const std::string& folder) {
|
||||||
std::vector<std::string> subdirectories;
|
std::vector<std::string> subdirectories;
|
||||||
NSFileManager* fileManager = [NSFileManager defaultManager];
|
NSFileManager* fileManager = [NSFileManager defaultManager];
|
||||||
NSDirectoryEnumerator* enumerator =
|
NSDirectoryEnumerator* enumerator =
|
||||||
@@ -125,4 +127,4 @@ std::vector<std::string> FileDialogWrapper::GetSubdirectoriesInFolder(const std:
|
|||||||
// Unsupported platform
|
// Unsupported platform
|
||||||
#endif // TARGET_OS_MAC
|
#endif // TARGET_OS_MAC
|
||||||
|
|
||||||
#endif // __APPLE__ && __MACH__
|
#endif // __APPLE__ && __MACH__
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "assembly_editor.h"
|
#include "assembly_editor.h"
|
||||||
|
|
||||||
#include "ImGuiColorTextEdit/TextEditor.h"
|
#include "ImGuiColorTextEdit/TextEditor.h"
|
||||||
|
|
||||||
#include "app/core/platform/file_dialog.h"
|
#include "app/core/platform/file_dialog.h"
|
||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
#include "app/gui/input.h"
|
#include "app/gui/input.h"
|
||||||
@@ -11,6 +10,8 @@ namespace yaze {
|
|||||||
namespace app {
|
namespace app {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
|
using core::FileDialogWrapper;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::vector<std::string> RemoveIgnoredFiles(
|
std::vector<std::string> RemoveIgnoredFiles(
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ struct MemoryEditorWithDiffChecker : public SharedRom {
|
|||||||
static Rom comparison_rom;
|
static Rom comparison_rom;
|
||||||
ImGui::Begin("Hex Editor", &show_memory_editor);
|
ImGui::Begin("Hex Editor", &show_memory_editor);
|
||||||
if (ImGui::Button("Compare Rom")) {
|
if (ImGui::Button("Compare Rom")) {
|
||||||
auto file_name = FileDialogWrapper::ShowOpenFileDialog();
|
auto file_name = core::FileDialogWrapper::ShowOpenFileDialog();
|
||||||
PRINT_IF_ERROR(comparison_rom.LoadFromFile(file_name));
|
PRINT_IF_ERROR(comparison_rom.LoadFromFile(file_name));
|
||||||
show_compare_rom = true;
|
show_compare_rom = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ namespace app {
|
|||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
using namespace ImGui;
|
using namespace ImGui;
|
||||||
|
using core::FileDialogWrapper;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -484,8 +485,8 @@ void EditorManager::DrawYazeMenuBar() {
|
|||||||
}
|
}
|
||||||
if (MenuItem("Open Project")) {
|
if (MenuItem("Open Project")) {
|
||||||
// Open an existing project
|
// Open an existing project
|
||||||
status_ =
|
status_ = current_project_.Open(
|
||||||
current_project_.Open(FileDialogWrapper::ShowOpenFileDialog());
|
core::FileDialogWrapper::ShowOpenFileDialog());
|
||||||
if (status_.ok()) {
|
if (status_.ok()) {
|
||||||
status_ = OpenProject();
|
status_ = OpenProject();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -370,10 +370,10 @@ absl::Status GraphicsEditor::UpdatePaletteColumn() {
|
|||||||
RETURN_IF_ERROR(
|
RETURN_IF_ERROR(
|
||||||
rom()
|
rom()
|
||||||
->mutable_gfx_sheets()
|
->mutable_gfx_sheets()
|
||||||
->at(current_sheet_)
|
->data()[current_sheet_]
|
||||||
.ApplyPaletteWithTransparent(palette, edit_palette_sub_index_));
|
.ApplyPaletteWithTransparent(palette, edit_palette_sub_index_));
|
||||||
Renderer::GetInstance().UpdateBitmap(
|
Renderer::GetInstance().UpdateBitmap(
|
||||||
&rom()->mutable_gfx_sheets()->at(current_sheet_), true);
|
&rom()->mutable_gfx_sheets()->data()[current_sheet_], true);
|
||||||
refresh_graphics_ = false;
|
refresh_graphics_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ void SpriteEditor::DrawCustomSpritesMetadata() {
|
|||||||
// ZSprite Maker format open file dialog
|
// ZSprite Maker format open file dialog
|
||||||
if (ImGui::Button("Open ZSprite")) {
|
if (ImGui::Button("Open ZSprite")) {
|
||||||
// Open ZSprite file
|
// Open ZSprite file
|
||||||
std::string file_path = FileDialogWrapper::ShowOpenFileDialog();
|
std::string file_path = core::FileDialogWrapper::ShowOpenFileDialog();
|
||||||
if (!file_path.empty()) {
|
if (!file_path.empty()) {
|
||||||
zsprite::ZSprite zsprite;
|
zsprite::ZSprite zsprite;
|
||||||
status_ = zsprite.Load(file_path);
|
status_ = zsprite.Load(file_path);
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ void Emulator::RenderNavBar() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (open_file) {
|
if (open_file) {
|
||||||
auto file_name = FileDialogWrapper::ShowOpenFileDialog();
|
auto file_name = core::FileDialogWrapper::ShowOpenFileDialog();
|
||||||
if (!file_name.empty()) {
|
if (!file_name.empty()) {
|
||||||
std::ifstream file(file_name, std::ios::binary);
|
std::ifstream file(file_name, std::ios::binary);
|
||||||
// Load the data directly into rom_data
|
// Load the data directly into rom_data
|
||||||
|
|||||||
Reference in New Issue
Block a user