5#include <unordered_set>
8#include "absl/strings/str_format.h"
19#if defined(YAZE_BUILD_AGENT_UI)
27void UpdateBuildWorkflowStatus(
StatusBar* status_bar,
31 if (status_bar !=
nullptr) {
34 if (project_panel !=
nullptr) {
39void AppendWorkflowHistoryEntry(
const std::string& kind,
41 const std::string& output_log) {
45 .output_log = output_log,
46 .timestamp = std::chrono::system_clock::now()});
99 bool is_emulator_visible =
110 if (!save_status.ok()) {
111 LOG_WARN(
"EditorManager",
"Failed to save user settings: %s",
112 save_status.ToString().c_str());
122 static Rom* last_test_rom =
nullptr;
124 if (last_test_rom != current_rom) {
127 "EditorManager::Update - ROM changed, updating TestManager: %p -> %p",
128 (
void*)last_test_rom, (
void*)current_rom);
130 last_test_rom = current_rom;
137 const bool current_session_has_unsaved_work =
139 const auto* current_session =
142 const bool backup_restore_requires_explicit_save =
143 current_session !=
nullptr && current_session->backup_restore_pending;
145 current_session_has_unsaved_work &&
146 !backup_restore_requires_explicit_save) {
153 }
else if (absl::IsCancelled(st)) {
158 absl::StrFormat(
"Autosave failed: %s", st.message()),
167 if (current_rom && current_rom->is_loaded()) {
175 &editor_set->GetAssemblySymbols());
191 UpdateBuildWorkflowStatus(
196 : (snapshot.status.ok() ?
"Build succeeded" :
"Build failed"),
197 snapshot.output_tail.empty()
200 "Running the configured project build command")
201 : std::string(snapshot.status.message()))
202 : snapshot.output_tail,
207 snapshot.output_tail, snapshot.running));
218 if (!snapshot.status.ok()) {
219 AppendWorkflowHistoryEntry(
221 MakeBuildStatus(
"Build failed", std::string(snapshot.status.message()),
226 absl::StrFormat(
"Build failed: %s", snapshot.status.message()),
227 snapshot.status.code() == absl::StatusCode::kCancelled
233 AppendWorkflowHistoryEntry(
237 snapshot.output_tail.empty() ? std::string(
"Project build completed")
238 : snapshot.output_tail,
242 ?
"Project build completed"
243 : absl::StrFormat(
"Project build completed: %s",
244 snapshot.output_tail),
312 std::unordered_set<std::string> active_editor_categories;
316 for (
size_t session_idx = 0;
321 if (!session || !session->rom.is_loaded()) {
325 for (
auto* editor : session->editors.active_editors_) {
327 std::string category =
329 active_editor_categories.insert(category);
335 active_editor_categories.insert(
"Emulator");
340 const bool prefer_dashboard_only =
344 if (!prefer_dashboard_only && sidebar_category.empty() &&
345 !all_categories.empty()) {
347 if (!sidebar_category.empty()) {
359 auto has_rom_callback = [
this]() ->
bool {
365 auto is_rom_dirty_callback = [
this]() ->
bool {
369 auto pending_dungeon_rooms_callback = [
this]() ->
int {
373 return dungeon_editor->PendingRoomCount();
379 all_categories, active_editor_categories,
380 has_rom_callback, is_rom_dirty_callback,
381 pending_dungeon_rooms_callback);
397 session_index, session_count,
402 bool has_agent_info =
false;
403#if defined(YAZE_BUILD_AGENT_UI)
405 auto* chat = agent_editor->GetAgentChat();
409 bool active = chat && *chat->active();
411 has_agent_info =
true;
415 if (!has_agent_info) {
430 editor_opts.
tooltip =
"Click to switch editor (Ctrl+E)";
438 std::move(editor_opts));
446 dirty_opts.
tooltip = absl::StrFormat(
447 "%s. Click to save ROM when ROM-buffer work is pending, otherwise open "
448 "the Project drawer.",
450 dirty_opts.
on_click = [
this, session_index]() {
462 std::move(dirty_opts));
472 "Right sidebar open — Esc closes, View > Right Sidebar toggles";
474 std::move(drawer_opts));
506 if (ImGui::BeginMenuBar()) {
509 const char* tooltip = sidebar_visible ?
"Hide Activity Bar (Ctrl+B)"
510 :
"Show Activity Bar (Ctrl+B)";
512 icon, tooltip, sidebar_visible)) {
536 ImGui::ShowDemoWindow(&visible);
543 ImGui::ShowMetricsWindow(&visible);
551 bool* hex_visibility =
553 if (hex_visibility) {
557 editor->set_active(*hex_visibility);
559 *hex_visibility = *editor->active();
565 editor->set_active(
true);
567 if (!*editor->active()) {
587#ifdef YAZE_ENABLE_TESTING
588 if (show_test_dashboard_) {
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
project::ResourceLabelManager * resource_label()
static TimingManager & Get()
float Update()
Update the timing manager (call once per frame)
float GetElapsedTime() const
Get total elapsed time since first update.
AgentConfigState & agent_config()
void SetRomContext(Rom *rom)
AgentUIContext * GetContext()
void SetProjectContext(project::YazeProject *project)
void SetAssemblySymbolTableContext(const std::map< std::string, core::AsarSymbol > *table)
AgentEditor * GetAgentEditor()
void SetAsarWrapperContext(core::AsarWrapper *asar_wrapper)
DungeonEditorV2 - Simplified dungeon editor using component delegation.
std::unique_ptr< SessionCoordinator > session_coordinator_
project::YazeProject current_project_
std::unique_ptr< RightDrawerManager > right_drawer_manager_
AgentUiController agent_ui_
float settings_dirty_timestamp_
std::string GetPreferredStartupCategory(const std::string &saved_category, const std::vector< std::string > &available_categories) const
bool active_project_build_reported_
bool SessionHasPendingRomWork(size_t session_index) const
Rom * GetCurrentRom() const override
std::unique_ptr< DashboardPanel > dashboard_panel_
void DrawSecondaryWindows()
std::string CompactPendingUnsavedWorkLabel(size_t session_index) const
void SyncEditorContextForCategory(const std::string &category)
ToastManager toast_manager_
LayoutCoordinator layout_coordinator_
std::string startup_editor_hint_
auto GetCurrentEditorSet() const -> EditorSet *
std::string DescribePendingUnsavedWork(size_t session_index) const
std::unique_ptr< MenuOrchestrator > menu_orchestrator_
ProjectFileEditor project_file_editor_
void HandleHostVisibilityChanged(bool visible)
WorkspaceWindowManager window_manager_
bool show_rom_load_options_
absl::Status AutosaveActiveSession()
RomLoadOptionsDialog rom_load_options_dialog_
std::vector< std::string > startup_panel_hints_
StartupVisibility dashboard_mode_override_
static bool IsPanelBasedEditor(EditorType type)
absl::Status Update()
Main update loop for the editor application.
size_t GetCurrentSessionIndex() const
size_t GetCurrentSessionId() const
Stable workspace identity; unlike the UI index, it does not compact.
std::unique_ptr< ActivityBar > activity_bar_
ShortcutManager shortcut_manager_
bool SessionHasPendingUnsavedWork(size_t session_index) const
std::unique_ptr< BackgroundCommandTask > active_project_build_
UserSettings user_settings_
ProposalDrawer proposal_drawer_
std::unique_ptr< ProjectManagementPanel > project_management_panel_
void PollProjectWorkflowTasks()
ProjectWorkflowStatus MakeBuildStatus(const std::string &summary, const std::string &detail, ProjectWorkflowState state, const std::string &output_tail="", bool can_cancel=false) const
std::unique_ptr< UICoordinator > ui_coordinator_
void CaptureActiveProjectEditingState()
static std::vector< std::string > GetAllEditorCategories()
Get all editor categories in display order for sidebar.
static std::string GetEditorCategory(EditorType type)
virtual void ContributeStatus(StatusBar *)
void ProcessLayoutRebuild(EditorType current_editor_type, bool is_emulator_visible)
Process pending layout rebuild requests.
Panel for managing project settings, ROM versions, and snapshots.
void SetBuildStatus(const ProjectWorkflowStatus &status)
void Draw(bool *p_open)
Draw the dialog (wrapper around Show)
A session-aware status bar displayed at the bottom of the application.
void ClearProjectWorkflowStatus()
void SetBuildStatus(const ProjectWorkflowStatus &status)
void SetSessionInfo(size_t session_id, size_t total_sessions, const std::string &display_name={})
Set session information.
void SetRom(Rom *rom)
Set the current ROM for dirty status and filename display.
void SetActiveEditor(const std::string &name)
Set the active editor category/name for the context strip.
void SetDirtyScope(const std::string &short_label)
Compact dirty-scope chip (ROM / Project / Rooms / …).
void SetCustomSegment(const std::string &key, const std::string &value)
Set a custom segment with key-value pair.
void ClearEditorContributions()
Clear frame-scoped editor contributions.
void Draw()
Draw the status bar.
void SetAgentInfo(const std::string &provider, const std::string &model, bool active)
void Show(const std::string &message, ToastType type=ToastType::kInfo, float ttl_seconds=3.0f, std::string action_label={}, std::function< void()> on_action=nullptr)
size_t GetActiveSessionId() const
void RestoreVisibilityState(size_t session_id, const std::unordered_map< std::string, bool > &state, bool publish_events=false)
Restore panel visibility state from persistence.
void ToggleSidebarVisibility()
void SetActiveCategory(const std::string &category, bool notify=true)
std::string GetActiveCategory() const
void DrawVisibleWindows()
bool IsSidebarVisible() const
bool * GetWindowVisibilityFlag(size_t session_id, const std::string &base_window_id)
bool is_audio_focus_mode() const
bool is_snes_initialized() const
auto running() const -> bool
void ClearWorkspaceTransitionState()
void SetCurrentRom(Rom *rom)
void DrawTestDashboard(bool *show_dashboard=nullptr)
static TestManager & Get()
void UpdateResourceStats()
#define ICON_MD_MENU_OPEN
#define LOG_DEBUG(category, format,...)
#define LOG_WARN(category, format,...)
void AppendWorkflowHistory(const ProjectWorkflowHistoryEntry &entry)
void SetBuildWorkflowStatus(const ProjectWorkflowStatus &status)
void SetBuildWorkflowLog(const std::string &output)
const char * GetDrawerTypeName(RightDrawerManager::DrawerType type)
bool ShouldTickEmulatorWhenHidden(bool keep_running_in_background)
void ExecuteShortcuts(const ShortcutManager &shortcut_manager)
Fire at most one shortcut for this frame's key press.
Represents a single session, containing a ROM and its associated editors.
Optional behavior for an interactive status bar segment.
std::function< void()> on_click
bool emulator_keep_running_in_background
std::unordered_map< std::string, std::unordered_map< std::string, bool > > panel_visibility_state
void DisplayLabels(bool *p_open)
bool project_opened() const
std::string labels_filename