17#include "imgui/imgui.h"
18#include "imgui/imgui_internal.h"
51 LOG_INFO(
"EditorActivator",
"Subscribed to navigation events");
58 LOG_WARN(
"EditorActivator",
"Not initialized, cannot switch editor");
63 ImGuiContext* imgui_ctx = ImGui::GetCurrentContext();
64 const bool frame_active = imgui_ctx !=
nullptr && imgui_ctx->WithinFrameScope;
67 [
this, editor_type, force_visible, from_dialog]() {
85 switch (editor_type) {
99 "Failed to prepare editor: " + std::string(status.message()),
112 for (
auto* editor : editor_set->active_editors_) {
113 if (editor->type() == editor_type) {
115 editor->set_active(
true);
117 editor->toggle_active();
121 if (*editor->active()) {
146 if (old_category != new_category) {
161 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
162 deps_.layout_manager->InitializeEditorLayout(type, dockspace_id);
180 std::string new_category =
182 if (old_category != new_category) {
192 bool force_visible) {
223 ImGuiContext* ctx = ImGui::GetCurrentContext();
225 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
230 LOG_INFO(
"EditorActivator",
"Initialized emulator layout");
269 ImGuiContext* ctx = ImGui::GetCurrentContext();
270 if (!ctx || !ctx->WithinFrameScope) {
279 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
281 LOG_INFO(
"EditorActivator",
"Initialized layout for editor type %d",
282 static_cast<int>(type));
297 std::string(status.message()),
308 editor_set->GetDungeonEditor()->add_room(room_id);
313 LOG_WARN(
"EditorActivator",
"Rejected invalid overworld map jump target %d",
317 "Invalid overworld map ID: " + std::to_string(map_id),
334 std::string(status.message()),
345 editor_set->GetOverworldEditor()->set_current_map(map_id);
362 std::string(status.message()),
372 if (
auto* message_editor = editor_set->GetMessageEditor()) {
373 if (!message_editor->OpenMessageById(message_id)) {
376 "Message ID not found: " + std::to_string(message_id),
398 std::string(status.message()),
408 if (
auto* asm_editor = editor_set->GetAssemblyEditor()) {
409 const auto status = asm_editor->JumpToReference(symbol);
413 "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 OpenDrawer(DrawerType type)
Open a specific drawer.
DrawerType GetActiveDrawer() const
Get the currently active drawer type.
void CloseDrawer()
Close the currently active drawer.
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)
void SetActiveCategory(const std::string &category, bool notify=true)
std::string GetActiveCategory() const
void OnEditorSwitch(const std::string &from_category, const std::string &to_category)
Handle editor/category switching for panel visibility.
bool OpenWindow(size_t session_id, const std::string &base_window_id)
void ClearWorkspaceTransitionState()
#define LOG_WARN(category, format,...)
#define LOG_INFO(category, format,...)
constexpr int kNumOverworldMaps
LayoutManager * layout_manager
std::function< EditorSet *()> get_current_editor_set
std::function< void(std::function< void()>)> queue_deferred_action
ToastManager * toast_manager
RightDrawerManager * right_drawer_manager
UICoordinator * ui_coordinator
std::function< size_t()> get_current_session_id
std::function< absl::Status(EditorType)> ensure_editor_assets_loaded
WorkspaceWindowManager * window_manager
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.