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;
66 const bool validate_session =
68 const size_t expected_session_id =
71 validate_session, expected_session_id]() {
72 if (validate_session &&
94 switch (editor_type) {
108 "Failed to prepare editor: " + std::string(status.message()),
121 for (
auto* editor : editor_set->active_editors_) {
122 if (editor->type() == editor_type) {
124 editor->set_active(
true);
126 editor->toggle_active();
130 if (*editor->active()) {
155 if (old_category != new_category) {
182 std::string new_category =
184 if (old_category != new_category) {
192 const EditorType fallback_type = other->type();
211 const size_t expected_session_id =
214 [
this, type, validate_session, expected_session_id]() {
215 if (validate_session &&
225 bool force_visible) {
256 ImGuiContext* ctx = ImGui::GetCurrentContext();
258 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
263 LOG_INFO(
"EditorActivator",
"Initialized emulator layout");
302 ImGuiContext* ctx = ImGui::GetCurrentContext();
303 if (!ctx || !ctx->WithinFrameScope) {
311 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
314 LOG_INFO(
"EditorActivator",
"Initialized layout for editor type %d",
315 static_cast<int>(type));
330 std::string(status.message()),
341 editor_set->GetDungeonEditor()->add_room(room_id);
346 LOG_WARN(
"EditorActivator",
"Rejected invalid overworld map jump target %d",
350 "Invalid overworld map ID: " + std::to_string(map_id),
367 std::string(status.message()),
378 editor_set->GetOverworldEditor()->set_current_map(map_id);
395 std::string(status.message()),
405 if (
auto* message_editor = editor_set->GetMessageEditor()) {
406 if (!message_editor->OpenMessageById(message_id)) {
409 "Message ID not found: " + std::to_string(message_id),
431 std::string(status.message()),
441 if (
auto* asm_editor = editor_set->GetAssemblyEditor()) {
442 const auto status = asm_editor->JumpToReference(symbol);
446 "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 QueueEditorLayoutInitialization(EditorType type)
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.