Refactor EditorManager
This commit is contained in:
@@ -307,17 +307,16 @@ void EditorManager::ManageKeyboardShortcuts() {
|
||||
}
|
||||
}
|
||||
|
||||
void EditorManager::DrawFileDialog() {}
|
||||
|
||||
void EditorManager::DrawStatusPopup() {
|
||||
static absl::Status prev_status;
|
||||
if (!status_.ok()) {
|
||||
show_status_ = true;
|
||||
prev_status_ = status_;
|
||||
prev_status = status_;
|
||||
}
|
||||
|
||||
if (show_status_ && (BeginCentered("StatusWindow"))) {
|
||||
Text("%s", ICON_MD_ERROR);
|
||||
Text("%s", prev_status_.ToString().c_str());
|
||||
Text("%s", prev_status.ToString().c_str());
|
||||
Spacing();
|
||||
NextColumn();
|
||||
Columns(1);
|
||||
@@ -331,7 +330,7 @@ void EditorManager::DrawStatusPopup() {
|
||||
}
|
||||
SameLine();
|
||||
if (Button(ICON_MD_CONTENT_COPY, ImVec2(50, 0))) {
|
||||
SetClipboardText(prev_status_.ToString().c_str());
|
||||
SetClipboardText(prev_status.ToString().c_str());
|
||||
}
|
||||
End();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "ImGuiColorTextEdit/TextEditor.h"
|
||||
#include "ImGuiFileDialog/ImGuiFileDialog.h"
|
||||
#include "absl/status/status.h"
|
||||
|
||||
#include "app/core/constants.h"
|
||||
#include "app/core/message.h"
|
||||
#include "app/core/project.h"
|
||||
@@ -42,8 +41,8 @@ namespace editor {
|
||||
|
||||
/**
|
||||
* @class EditorManager
|
||||
* @brief The EditorManager class represents the main editor for a Rom in the
|
||||
* Yaze application.
|
||||
* @brief The EditorManager controls the main editor window and manages the
|
||||
* various editor classes.
|
||||
*
|
||||
* This class inherits from SharedRom, GfxContext, and ExperimentFlags, and
|
||||
* provides functionality for setting up the screen, updating the editor, and
|
||||
@@ -58,9 +57,7 @@ namespace editor {
|
||||
* @note This class assumes the presence of an SDL_Renderer object for rendering
|
||||
* graphics.
|
||||
*/
|
||||
class EditorManager : public SharedRom,
|
||||
public context::GfxContext,
|
||||
public core::ExperimentFlags {
|
||||
class EditorManager : public SharedRom, public core::ExperimentFlags {
|
||||
public:
|
||||
EditorManager() {
|
||||
current_editor_ = &overworld_editor_;
|
||||
@@ -77,13 +74,11 @@ class EditorManager : public SharedRom,
|
||||
|
||||
auto emulator() -> emu::Emulator& { return emulator_; }
|
||||
auto quit() { return quit_; }
|
||||
auto overworld_editor() -> OverworldEditor& { return overworld_editor_; }
|
||||
|
||||
private:
|
||||
void ManageActiveEditors();
|
||||
void ManageKeyboardShortcuts();
|
||||
|
||||
void DrawFileDialog();
|
||||
void DrawStatusPopup();
|
||||
void DrawAboutPopup();
|
||||
void DrawInfoPopup();
|
||||
@@ -106,15 +101,18 @@ class EditorManager : public SharedRom,
|
||||
bool rom_assets_loaded_ = false;
|
||||
|
||||
absl::Status status_;
|
||||
absl::Status prev_status_;
|
||||
|
||||
ImVector<int> active_tabs_;
|
||||
std::vector<Editor*> active_editors_;
|
||||
|
||||
core::MessageDispatcher dispatcher_;
|
||||
emu::Emulator emulator_;
|
||||
|
||||
Project current_project_;
|
||||
yaze_editor_context editor_context_;
|
||||
ExtensionManager extension_manager_;
|
||||
core::MessageDispatcher dispatcher_;
|
||||
|
||||
Editor* current_editor_ = nullptr;
|
||||
AssemblyEditor assembly_editor_;
|
||||
DungeonEditor dungeon_editor_;
|
||||
GraphicsEditor graphics_editor_;
|
||||
@@ -126,10 +124,6 @@ class EditorManager : public SharedRom,
|
||||
SettingsEditor settings_editor_;
|
||||
MessageEditor message_editor_;
|
||||
MemoryEditorWithDiffChecker memory_editor_;
|
||||
|
||||
ImVector<int> active_tabs_;
|
||||
std::vector<Editor*> active_editors_;
|
||||
Editor* current_editor_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "ImGuiFileDialog/ImGuiFileDialog.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gui/canvas.h"
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
|
||||
#include "imgui/imgui.h"
|
||||
#include "imgui/misc/cpp/imgui_stdlib.h"
|
||||
#include "imgui_memory_editor.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
@@ -15,11 +11,13 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/color.h"
|
||||
#include "imgui/imgui.h"
|
||||
#include "imgui/misc/cpp/imgui_stdlib.h"
|
||||
#include "imgui_memory_editor.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
|
||||
@@ -452,14 +452,7 @@ class Rom : public core::ExperimentFlags {
|
||||
return rom_data_[i];
|
||||
}
|
||||
|
||||
core::ResourceLabelManager* resource_label() {
|
||||
return &resource_label_manager_;
|
||||
}
|
||||
VersionConstants version_constants() const {
|
||||
return kVersionConstantsMap.at(version_);
|
||||
}
|
||||
|
||||
auto is_loaded() const {
|
||||
bool is_loaded() const {
|
||||
if (!absl::StrContains(filename_, ".sfc") &&
|
||||
!absl::StrContains(filename_, ".smc")) {
|
||||
return false;
|
||||
@@ -470,9 +463,18 @@ class Rom : public core::ExperimentFlags {
|
||||
// Full graphical data for the game
|
||||
std::vector<uint8_t> graphics_buffer() const { return graphics_buffer_; }
|
||||
|
||||
auto title() const { return title_; }
|
||||
auto size() const { return size_; }
|
||||
auto begin() { return rom_data_.begin(); }
|
||||
auto end() { return rom_data_.end(); }
|
||||
auto data() { return rom_data_.data(); }
|
||||
auto vector() const { return rom_data_; }
|
||||
auto version() const { return version_; }
|
||||
auto filename() const { return filename_; }
|
||||
auto set_filename(std::string name) { filename_ = name; }
|
||||
|
||||
auto link_graphics() { return link_graphics_; }
|
||||
auto mutable_link_graphics() { return &link_graphics_; }
|
||||
|
||||
auto gfx_sheets() { return graphics_sheets_; }
|
||||
auto mutable_gfx_sheets() { return &graphics_sheets_; }
|
||||
|
||||
@@ -483,15 +485,12 @@ class Rom : public core::ExperimentFlags {
|
||||
return palette_groups_.dungeon_main.mutable_palette(i);
|
||||
}
|
||||
|
||||
auto title() const { return title_; }
|
||||
auto size() const { return size_; }
|
||||
auto begin() { return rom_data_.begin(); }
|
||||
auto end() { return rom_data_.end(); }
|
||||
auto data() { return rom_data_.data(); }
|
||||
auto vector() const { return rom_data_; }
|
||||
auto version() const { return version_; }
|
||||
auto filename() const { return filename_; }
|
||||
auto set_filename(std::string name) { filename_ = name; }
|
||||
core::ResourceLabelManager* resource_label() {
|
||||
return &resource_label_manager_;
|
||||
}
|
||||
VersionConstants version_constants() const {
|
||||
return kVersionConstantsMap.at(version_);
|
||||
}
|
||||
|
||||
std::vector<std::vector<uint8_t>> main_blockset_ids;
|
||||
std::vector<std::vector<uint8_t>> room_blockset_ids;
|
||||
|
||||
Reference in New Issue
Block a user