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