refactor(editor): extract editor management responsibilities into dedicated classes
- Introduced EditorRegistry, ProjectManager, and RomFileManager to streamline editor operations and improve code organization. - Refactored EditorManager to delegate responsibilities to the new classes, enhancing maintainability and clarity. - Updated CMake configuration to include new source files for the extracted components. Benefits: - Improves separation of concerns within the editor, leading to a more modular and manageable codebase. - Enhances the overall architecture by clearly defining roles for editor management, project handling, and ROM file operations.
This commit is contained in:
70
src/app/editor/system/project_manager.h
Normal file
70
src/app/editor/system/project_manager.h
Normal file
@@ -0,0 +1,70 @@
|
||||
#ifndef YAZE_APP_EDITOR_SYSTEM_PROJECT_MANAGER_H_
|
||||
#define YAZE_APP_EDITOR_SYSTEM_PROJECT_MANAGER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "app/core/project.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
|
||||
class ToastManager;
|
||||
|
||||
/**
|
||||
* @class ProjectManager
|
||||
* @brief Handles all project file operations
|
||||
*
|
||||
* Extracted from EditorManager to provide focused project management:
|
||||
* - Project creation and templates
|
||||
* - Project loading and saving
|
||||
* - Project import/export
|
||||
* - Project validation and repair
|
||||
*/
|
||||
class ProjectManager {
|
||||
public:
|
||||
explicit ProjectManager(ToastManager* toast_manager);
|
||||
~ProjectManager() = default;
|
||||
|
||||
// Project file operations
|
||||
absl::Status CreateNewProject(const std::string& template_name = "");
|
||||
absl::Status OpenProject(const std::string& filename = "");
|
||||
absl::Status SaveProject();
|
||||
absl::Status SaveProjectAs(const std::string& filename = "");
|
||||
|
||||
// Project import/export
|
||||
absl::Status ImportProject(const std::string& project_path);
|
||||
absl::Status ExportProject(const std::string& export_path);
|
||||
|
||||
// Project maintenance
|
||||
absl::Status RepairCurrentProject();
|
||||
absl::Status ValidateProject();
|
||||
|
||||
// Project information
|
||||
core::YazeProject& GetCurrentProject() { return current_project_; }
|
||||
const core::YazeProject& GetCurrentProject() const { return current_project_; }
|
||||
bool HasActiveProject() const { return !current_project_.filepath.empty(); }
|
||||
std::string GetProjectName() const;
|
||||
std::string GetProjectPath() const;
|
||||
|
||||
// Project templates
|
||||
std::vector<std::string> GetAvailableTemplates() const;
|
||||
absl::Status CreateFromTemplate(const std::string& template_name,
|
||||
const std::string& project_name);
|
||||
|
||||
private:
|
||||
core::YazeProject current_project_;
|
||||
ToastManager* toast_manager_ = nullptr;
|
||||
|
||||
// Helper methods
|
||||
absl::Status LoadProjectFromFile(const std::string& filename);
|
||||
absl::Status SaveProjectToFile(const std::string& filename);
|
||||
std::string GenerateProjectFilename(const std::string& project_name) const;
|
||||
bool IsValidProjectFile(const std::string& filename) const;
|
||||
absl::Status InitializeProjectStructure(const std::string& project_path);
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_APP_EDITOR_SYSTEM_PROJECT_MANAGER_H_
|
||||
Reference in New Issue
Block a user