16#include "imgui/imgui.h"
17#include "imgui/imgui_internal.h"
49 LOG_INFO(
"EditorActivator",
"Subscribed to navigation events");
56 LOG_WARN(
"EditorActivator",
"Not initialized, cannot switch editor");
61 ImGuiContext* imgui_ctx = ImGui::GetCurrentContext();
62 const bool frame_active = imgui_ctx !=
nullptr && imgui_ctx->WithinFrameScope;
81 for (
auto* editor : editor_set->active_editors_) {
82 if (editor->type() == editor_type) {
84 editor->set_active(
true);
86 editor->toggle_active();
90 if (*editor->active()) {
113 if (old_category != new_category) {
122 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
123 deps_.layout_manager->InitializeEditorLayout(type, dockspace_id);
140 if (old_category != new_category) {
164 if (force_visible) is_visible =
true;
173 ImGuiContext* ctx = ImGui::GetCurrentContext();
175 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
179 LOG_INFO(
"EditorActivator",
"Initialized emulator layout");
216 ImGuiContext* ctx = ImGui::GetCurrentContext();
217 if (!ctx || !ctx->WithinFrameScope) {
227 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
229 LOG_INFO(
"EditorActivator",
"Initialized layout for editor type %d",
230 static_cast<int>(type));
236 if (!editor_set)
return;
243 "Failed to prepare Dungeon editor: " + std::string(status.message()),
254 editor_set->GetDungeonEditor()->add_room(room_id);
259 if (!editor_set)
return;
267 std::string(status.message()),
278 editor_set->GetOverworldEditor()->set_current_map(map_id);
282 if (message_id < 0)
return;
286 if (!editor_set)
return;
293 std::string(status.message()),
303 if (
auto* message_editor = editor_set->GetMessageEditor()) {
304 if (!message_editor->OpenMessageById(message_id)) {
307 std::to_string(message_id),
315 if (symbol.empty())
return;
319 if (!editor_set)
return;
327 std::string(status.message()),
337 if (
auto* asm_editor = editor_set->GetAssemblyEditor()) {
338 const auto status = asm_editor->JumpToReference(symbol);
342 "Assembly jump failed: " + std::string(status.message()),
HandlerId Subscribe(std::function< void(const T &)> handler)
void HandleNonEditorClassSwitch(EditorType type, bool force_visible)
void ActivatePanelBasedEditor(EditorType type, Editor *editor)
void JumpToAssemblySymbol(const std::string &symbol)
Jump to an assembly symbol definition in the Assembly editor.
void SwitchToEditor(EditorType type, bool force_visible=false, bool from_dialog=false)
Switch to an editor, optionally forcing visibility.
void Initialize(const Dependencies &deps)
void JumpToMessage(int message_id)
Jump to a specific message ID in the Message editor.
void InitializeEditorLayout(EditorType type)
Initialize the DockBuilder layout for an editor.
void JumpToDungeonRoom(int room_id)
Jump to a specific dungeon room.
void JumpToOverworldMap(int map_id)
Jump to a specific overworld map.
void DeactivatePanelBasedEditor(EditorType type, Editor *editor, EditorSet *editor_set)
static bool IsPanelBasedEditor(EditorType type)
static std::string GetEditorCategory(EditorType type)
Contains a complete set of editors for a single ROM instance.
std::vector< Editor * > active_editors_
Interface for editor classes.
bool IsLayoutInitialized(EditorType type) const
Check if a layout has been initialized for an editor.
void InitializeEditorLayout(EditorType type, ImGuiID dockspace_id)
Initialize the default layout for a specific editor type.
void OnEditorSwitch(const std::string &from_category, const std::string &to_category)
Handle editor/category switching for panel visibility.
void SetActiveCategory(const std::string &category, bool notify=true)
bool ShowPanel(size_t session_id, const std::string &base_card_id)
std::string GetActiveCategory() const
void ClosePanel()
Close the currently active panel.
PanelType GetActivePanel() const
Get the currently active panel type.
void OpenPanel(PanelType type)
Open a specific panel.
void Show(const std::string &message, ToastType type=ToastType::kInfo, float ttl_seconds=3.0f)
bool IsEmulatorVisible() const
bool IsAsmEditorVisible() const
void SetEmulatorVisible(bool visible)
void SetAsmEditorVisible(bool visible)
void SetEditorSelectionVisible(bool visible)
#define LOG_WARN(category, format,...)
#define LOG_INFO(category, format,...)
LayoutManager * layout_manager
PanelManager * panel_manager
std::function< EditorSet *()> get_current_editor_set
std::function< void(std::function< void()>)> queue_deferred_action
ToastManager * toast_manager
RightPanelManager * right_panel_manager
UICoordinator * ui_coordinator
std::function< size_t()> get_current_session_id
std::function< absl::Status(EditorType)> ensure_editor_assets_loaded
Request to navigate to an assembly symbol definition.
Request to navigate to a specific overworld map.
Request to navigate to a specific message ID.
Request to navigate to a specific dungeon room.