5#include <unordered_set>
8#include "absl/strings/str_format.h"
20#if defined(YAZE_BUILD_AGENT_UI)
28void UpdateBuildWorkflowStatus(
StatusBar* status_bar,
32 if (status_bar !=
nullptr) {
35 if (project_panel !=
nullptr) {
40void AppendWorkflowHistoryEntry(
const std::string& kind,
42 const std::string& output_log) {
46 .output_log = output_log,
47 .timestamp = std::chrono::system_clock::now()});
100 bool is_emulator_visible =
111 if (!save_status.ok()) {
112 LOG_WARN(
"EditorManager",
"Failed to save user settings: %s",
113 save_status.ToString().c_str());
123 static Rom* last_test_rom =
nullptr;
125 if (last_test_rom != current_rom) {
128 "EditorManager::Update - ROM changed, updating TestManager: %p -> %p",
129 (
void*)last_test_rom, (
void*)current_rom);
131 last_test_rom = current_rom;
138 const bool current_session_has_unsaved_work =
140 const auto* current_session =
143 const bool backup_restore_requires_explicit_save =
144 current_session !=
nullptr && current_session->backup_restore_pending;
146 current_session_has_unsaved_work &&
147 !backup_restore_requires_explicit_save) {
154 }
else if (absl::IsCancelled(st)) {
159 absl::StrFormat(
"Autosave failed: %s", st.message()),
168 if (current_rom && current_rom->is_loaded()) {
172 agent_ui_->SetAsarWrapperContext(editor_set->GetAsarWrapper());
175 agent_ui_->SetAssemblySymbolTableContext(
176 &editor_set->GetAssemblySymbols());
192 UpdateBuildWorkflowStatus(
197 : (snapshot.status.ok() ?
"Build succeeded" :
"Build failed"),
198 snapshot.output_tail.empty()
201 "Running the configured project build command")
202 : std::string(snapshot.status.message()))
203 : snapshot.output_tail,
208 snapshot.output_tail, snapshot.running));
219 if (!snapshot.status.ok()) {
220 AppendWorkflowHistoryEntry(
222 MakeBuildStatus(
"Build failed", std::string(snapshot.status.message()),
227 absl::StrFormat(
"Build failed: %s", snapshot.status.message()),
228 snapshot.status.code() == absl::StatusCode::kCancelled
234 AppendWorkflowHistoryEntry(
238 snapshot.output_tail.empty() ? std::string(
"Project build completed")
239 : snapshot.output_tail,
243 ?
"Project build completed"
244 : absl::StrFormat(
"Project build completed: %s",
245 snapshot.output_tail),
262 const bool finish_current_open =
266 if (finish_current_open) {
322 std::unordered_set<std::string> active_editor_categories;
326 for (
size_t session_idx = 0;
331 if (!session || !session->rom.is_loaded()) {
335 for (
auto* editor : session->editors.active_editors_) {
337 std::string category =
339 active_editor_categories.insert(category);
345 active_editor_categories.insert(
"Emulator");
350 const bool prefer_dashboard_only =
354 if (!prefer_dashboard_only && sidebar_category.empty() &&
355 !all_categories.empty()) {
357 if (!sidebar_category.empty()) {
369 auto has_rom_callback = [
this]() ->
bool {
375 auto is_rom_dirty_callback = [
this]() ->
bool {
379 auto pending_dungeon_rooms_callback = [
this]() ->
int {
383 return dungeon_editor->PendingRoomCount();
389 all_categories, active_editor_categories,
390 has_rom_callback, is_rom_dirty_callback,
391 pending_dungeon_rooms_callback);
407 session_index, session_count,
412 bool has_agent_info =
false;
413#if defined(YAZE_BUILD_AGENT_UI)
414 if (
auto* agent_editor =
agent_ui_->GetAgentEditor()) {
415 auto* chat = agent_editor->GetAgentChat();
416 const auto* ctx =
agent_ui_->GetContext();
418 const auto& config = ctx->agent_config();
419 bool active = chat && *chat->active();
421 has_agent_info =
true;
425 if (!has_agent_info) {
440 editor_opts.
tooltip =
"Click to switch editor (Ctrl+E)";
448 std::move(editor_opts));
456 dirty_opts.
tooltip = absl::StrFormat(
460 if (!absl::IsCancelled(status) && !status.ok()) {
465 std::move(dirty_opts));
475 "Right sidebar open — Esc closes, View > Right Sidebar toggles";
477 std::move(drawer_opts));
509 if (ImGui::BeginMenuBar()) {
512 const char* tooltip = sidebar_visible ?
"Hide Activity Bar (Ctrl+B)"
513 :
"Show Activity Bar (Ctrl+B)";
515 icon, tooltip, sidebar_visible)) {
539 ImGui::ShowDemoWindow(&visible);
546 ImGui::ShowMetricsWindow(&visible);
554 bool* hex_visibility =
556 if (hex_visibility) {
560 editor->set_active(*hex_visibility);
562 *hex_visibility = *editor->active();
568 editor->set_active(
true);
570 if (!*editor->active()) {
590#ifdef YAZE_ENABLE_TESTING
591 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.
DungeonEditorV2 - Simplified dungeon editor using component delegation.
std::optional< RomLoadOptionsOwner > rom_load_options_owner_
std::unique_ptr< SessionCoordinator > session_coordinator_
std::unique_ptr< AgentUiController > agent_ui_
project::YazeProject current_project_
std::unique_ptr< RightDrawerManager > right_drawer_manager_
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_
Rom * GetCurrentRom() const override
absl::Status SaveCurrentSession()
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_
bool RomLoadOptionsMatchCurrentSession() const
StartupVisibility dashboard_mode_override_
static bool IsPanelBasedEditor(EditorType type)
absl::Status Update()
Main update loop for the editor application.
size_t GetCurrentSessionIndex() const
void ShowPostLoadSurface()
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
void CloseRomLoadOptions(const char *reason)
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