Refactor editor classes to accept a ROM pointer in constructors, enhancing dependency management and initialization across all editor types.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "app/editor/editor.h"
|
||||
#include "app/gui/modules/text_editor.h"
|
||||
#include "app/gui/style.h"
|
||||
#include "app/rom.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
@@ -22,7 +23,7 @@ struct FolderItem {
|
||||
*/
|
||||
class AssemblyEditor : public Editor {
|
||||
public:
|
||||
AssemblyEditor() {
|
||||
explicit AssemblyEditor(Rom* rom = nullptr) : rom_(rom) {
|
||||
text_editor_.SetLanguageDefinition(gui::GetAssemblyLanguageDef());
|
||||
text_editor_.SetPalette(TextEditor::GetDarkPalette());
|
||||
text_editor_.SetShowWhitespaces(false);
|
||||
@@ -54,6 +55,12 @@ class AssemblyEditor : public Editor {
|
||||
|
||||
void OpenFolder(const std::string &folder_path);
|
||||
|
||||
// Set the ROM pointer
|
||||
void set_rom(Rom* rom) { rom_ = rom; }
|
||||
|
||||
// Get the ROM pointer
|
||||
Rom* rom() const { return rom_; }
|
||||
|
||||
private:
|
||||
void DrawFileMenu();
|
||||
void DrawEditMenu();
|
||||
@@ -71,6 +78,8 @@ class AssemblyEditor : public Editor {
|
||||
std::string current_file_;
|
||||
FolderItem current_folder_;
|
||||
TextEditor text_editor_;
|
||||
|
||||
Rom* rom_;
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
|
||||
|
||||
#include "app/core/platform/file_dialog.h"
|
||||
#include "app/editor/code/memory_editor.h"
|
||||
#include "app/gui/input.h"
|
||||
#include "app/rom.h"
|
||||
#include "imgui/imgui.h"
|
||||
@@ -15,7 +14,9 @@ namespace editor {
|
||||
using ImGui::SameLine;
|
||||
using ImGui::Text;
|
||||
|
||||
struct MemoryEditorWithDiffChecker : public SharedRom {
|
||||
struct MemoryEditorWithDiffChecker {
|
||||
explicit MemoryEditorWithDiffChecker(Rom* rom = nullptr) : rom_(rom) {}
|
||||
|
||||
void Update(bool &show_memory_editor) {
|
||||
static MemoryEditor mem_edit;
|
||||
static MemoryEditor comp_edit;
|
||||
@@ -56,6 +57,15 @@ struct MemoryEditorWithDiffChecker : public SharedRom {
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
// Set the ROM pointer
|
||||
void set_rom(Rom* rom) { rom_ = rom; }
|
||||
|
||||
// Get the ROM pointer
|
||||
Rom* rom() const { return rom_; }
|
||||
|
||||
private:
|
||||
Rom* rom_;
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
|
||||
Reference in New Issue
Block a user