16#include <unordered_set>
21#include <TargetConditionals.h>
25#define IMGUI_DEFINE_MATH_OPERATORS
26#include "absl/status/status.h"
27#include "absl/status/statusor.h"
28#include "absl/strings/ascii.h"
29#include "absl/strings/match.h"
30#include "absl/strings/str_format.h"
31#include "absl/strings/str_split.h"
32#include "absl/strings/string_view.h"
33#include "imgui/imgui.h"
80#include "yaze_config.h"
94#ifdef YAZE_ENABLE_TESTING
100#ifdef YAZE_ENABLE_GTEST
116 const std::string lower = absl::AsciiStrToLower(std::string(name));
118 const std::string candidate = absl::AsciiStrToLower(
120 if (candidate == lower) {
128 if (panel_id.size() > 2 && panel_id[0] ==
's' &&
129 absl::ascii_isdigit(panel_id[1])) {
130 const size_t dot = panel_id.find(
'.');
131 if (dot != absl::string_view::npos) {
132 return std::string(panel_id.substr(dot + 1));
135 return std::string(panel_id);
154 std::string category =
176#ifdef YAZE_BUILD_AGENT_UI
177void EditorManager::ShowAIAgent() {
184void EditorManager::ShowChatHistory() {
190 : project_manager_(&toast_manager_), rom_file_manager_(&toast_manager_) {
191 std::stringstream ss;
192 ss << YAZE_VERSION_MAJOR <<
"." << YAZE_VERSION_MINOR <<
"."
193 << YAZE_VERSION_PATCH;
278 if (!rom_path.empty()) {
295 absl::StrFormat(
"Failed to reload ROM: %s", status.message()),
306 absl::StrFormat(
"Failed to save project: %s", status.message()),
311 [
this](
const std::string& type) {
313 if (!folder_path.empty()) {
314 if (type ==
"code") {
318 editor_set->GetAssemblyEditor()->OpenFolder(folder_path);
321 }
else if (type ==
"assets") {
325 folder_path.c_str()),
379 {.card_id =
"dashboard.main",
380 .display_name =
"Dashboard",
381 .window_title =
" Dashboard",
383 .category =
"Dashboard",
384 .shortcut_hint =
"F1",
418#ifdef YAZE_ENABLE_TESTING
422 LOG_DEBUG(
"EditorManager",
"Session switched to %zu via observer", new_index);
426 LOG_INFO(
"EditorManager",
"Session %zu created via observer", index);
430#ifdef YAZE_ENABLE_TESTING
435 LOG_INFO(
"EditorManager",
"Session %zu closed via observer", index);
439#ifdef YAZE_ENABLE_TESTING
445 LOG_INFO(
"EditorManager",
"ROM loaded in session %zu via observer", index);
451#ifdef YAZE_ENABLE_TESTING
453 test_manager.RegisterTestSuite(std::make_unique<test::IntegratedTestSuite>());
454 test_manager.RegisterTestSuite(
455 std::make_unique<test::PerformanceTestSuite>());
456 test_manager.RegisterTestSuite(std::make_unique<test::UITestSuite>());
457 test_manager.RegisterTestSuite(
458 std::make_unique<test::RomDependentTestSuite>());
461 test_manager.RegisterTestSuite(std::make_unique<test::E2ETestSuite>());
462 test_manager.RegisterTestSuite(
463 std::make_unique<test::ZSCustomOverworldTestSuite>());
467#ifdef YAZE_ENABLE_GTEST
468 test_manager.RegisterTestSuite(std::make_unique<test::UnitTestSuite>());
477 test_manager.UpdateResourceStats();
481 const std::string& filename) {
491 if (!filename.empty()) {
502 .display_name =
"CPU Debugger",
503 .window_title =
" CPU Debugger",
505 .category =
"Emulator",
508 .display_name =
"PPU Viewer",
509 .window_title =
" PPU Viewer",
511 .category =
"Emulator",
514 .display_name =
"Memory Viewer",
515 .window_title =
" Memory Viewer",
517 .category =
"Emulator",
520 .display_name =
"Breakpoints",
521 .window_title =
" Breakpoints",
523 .category =
"Emulator",
526 .display_name =
"Performance",
527 .window_title =
" Performance",
529 .category =
"Emulator",
532 .display_name =
"AI Agent",
533 .window_title =
" AI Agent",
535 .category =
"Emulator",
538 .display_name =
"Save States",
539 .window_title =
" Save States",
541 .category =
"Emulator",
544 .display_name =
"Keyboard Config",
545 .window_title =
" Keyboard Config",
547 .category =
"Emulator",
550 .display_name =
"Virtual Controller",
551 .window_title =
" Virtual Controller",
553 .category =
"Emulator",
556 .display_name =
"APU Debugger",
557 .window_title =
" APU Debugger",
559 .category =
"Emulator",
562 .display_name =
"Audio Mixer",
563 .window_title =
" Audio Mixer",
565 .category =
"Emulator",
570 .display_name =
"Hex Editor",
573 .category =
"Memory",
589 LOG_WARN(
"EditorManager",
"Failed to load user settings: %s",
600 LOG_INFO(
"EditorManager",
"WASM Control and Session APIs initialized");
609 flags.overworld.kSaveOverworldEntrances =
638 LOG_INFO(
"EditorManager",
"ROM load options applied: preset=%s",
658 [
this](
const std::string& template_name) {
676#ifdef YAZE_BUILD_AGENT_UI
724 absl::StrFormat(
"Failed to save ROM: %s", status.message()),
732 auto status = current_editor->Undo();
735 absl::StrFormat(
"Undo failed: %s", status.message()),
743 auto status = current_editor->Redo();
746 absl::StrFormat(
"Redo failed: %s", status.message()),
780 [
this](
bool visible,
bool expanded) {
787 [
this](
const std::string& category) {
803 [
this](
const std::string& category) {
815 [
this](
const std::string& category,
const std::string& path) {
816 if (category ==
"Assembly") {
819 editor_set->GetAssemblyEditor()->ChangeActiveFile(path);
837#ifdef YAZE_ENABLE_TESTING
861 const std::string& editor_name,
const std::string& panels_str) {
862 const bool has_editor = !editor_name.empty();
863 const bool has_panels = !panels_str.empty();
865 if (!has_editor && !has_panels) {
870 "Processing startup flags: editor='%s', panels='%s'",
871 editor_name.c_str(), panels_str.c_str());
873 std::optional<EditorType> editor_type_to_open =
874 has_editor ? ParseEditorTypeFromString(editor_name) : std::nullopt;
875 if (has_editor && !editor_type_to_open.has_value()) {
876 LOG_WARN(
"EditorManager",
"Unknown editor specified via flag: %s",
877 editor_name.c_str());
878 }
else if (editor_type_to_open.has_value()) {
890 bool applied_category_from_panel =
false;
892 for (absl::string_view token :
893 absl::StrSplit(panels_str,
',', absl::SkipWhitespace())) {
897 std::string panel_name = std::string(absl::StripAsciiWhitespace(token));
898 LOG_DEBUG(
"EditorManager",
"Attempting to open panel: '%s'",
901 const std::string lower_name = absl::AsciiStrToLower(panel_name);
902 if (lower_name ==
"welcome" || lower_name ==
"welcome_screen") {
908 if (lower_name ==
"dashboard" || lower_name ==
"dashboard.main" ||
909 lower_name ==
"editor_selection") {
921 if (absl::StartsWith(panel_name,
"Room ")) {
924 int room_id = std::stoi(panel_name.substr(5));
925 editor_set->GetDungeonEditor()->add_room(room_id);
926 }
catch (
const std::exception& e) {
927 LOG_WARN(
"EditorManager",
"Invalid room ID format: %s",
934 std::optional<std::string> resolved_panel;
936 resolved_panel = panel_name;
938 for (
const auto& [prefixed_id, descriptor] :
940 const std::string base_id = StripSessionPrefix(prefixed_id);
941 const std::string card_lower = absl::AsciiStrToLower(base_id);
942 const std::string display_lower =
943 absl::AsciiStrToLower(descriptor.display_name);
945 if (card_lower == lower_name || display_lower == lower_name) {
946 resolved_panel = base_id;
952 if (!resolved_panel.has_value()) {
954 "Unknown panel '%s' from --open_panels (known count: %zu)",
961 const auto* descriptor =
963 if (descriptor && !applied_category_from_panel &&
966 applied_category_from_panel =
true;
967 }
else if (!applied_category_from_panel && descriptor &&
968 descriptor->category.empty() && !last_known_category.empty()) {
972 LOG_WARN(
"EditorManager",
"Failed to show panel '%s'",
973 resolved_panel->c_str());
992 const bool sidebar_visible =
1019 std::string panels_str;
1020 for (
size_t i = 0; i < config.
open_panels.size(); ++i) {
1058 std::vector<std::function<void()>> actions_to_execute;
1060 for (
auto& action : actions_to_execute) {
1071 bool is_emulator_visible =
1114 static Rom* last_test_rom =
nullptr;
1116 if (last_test_rom != current_rom) {
1119 "EditorManager::Update - ROM changed, updating TestManager: %p -> "
1121 (
void*)last_test_rom, (
void*)current_rom);
1123 last_test_rom = current_rom;
1143 std::unordered_set<std::string> active_editor_categories;
1147 for (
size_t session_idx = 0;
1152 if (!session || !session->rom.is_loaded()) {
1156 for (
auto* editor : session->editors.active_editors_) {
1158 std::string category =
1160 active_editor_categories.insert(category);
1167 active_editor_categories.insert(
"Emulator");
1175 if (sidebar_category.empty() && !all_categories.empty()) {
1176 sidebar_category = all_categories[0];
1181 auto has_rom_callback = [
this]() ->
bool {
1183 return rom && rom->is_loaded();
1190 all_categories, active_editor_categories,
1211 current_rom->dirty()) {
1218 auto st = current_rom->SaveToFile(s);
1231 if (!current_editor_set) {
1234 return absl::OkStatus();
1240 return absl::OkStatus();
1263 if (current_rom && current_rom->is_loaded()) {
1269 editor_set->GetAssemblyEditor()->asar_wrapper());
1280 return absl::OkStatus();
1300 static bool show_display_settings =
false;
1302 if (ImGui::BeginMenuBar()) {
1305 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
1306 ImGui::PushStyleColor(ImGuiCol_ButtonHovered,
1308 ImGui::PushStyleColor(ImGuiCol_ButtonActive,
1328 ImGui::PopStyleColor(4);
1330 if (ImGui::IsItemHovered()) {
1332 ?
"Hide Activity Bar (Ctrl+B)"
1333 :
"Show Activity Bar (Ctrl+B)";
1334 ImGui::SetTooltip(
"%s", tooltip);
1347 ImGui::EndMenuBar();
1350 if (show_display_settings) {
1353 show_display_settings =
false;
1358 bool visible =
true;
1359 ImGui::ShowDemoWindow(&visible);
1366 bool visible =
true;
1367 ImGui::ShowMetricsWindow(&visible);
1376 bool* hex_visibility =
1378 if (hex_visibility && *hex_visibility) {
1379 editor_set->GetMemoryEditor()->Update(*hex_visibility);
1383 bool visible =
true;
1384 editor_set->GetAssemblyEditor()->Update(visible);
1403#ifdef YAZE_ENABLE_TESTING
1404 if (show_test_dashboard_) {
1406 test_manager.UpdateResourceStats();
1407 test_manager.DrawTestDashboard(&show_test_dashboard_);
1446 bool visible =
true;
1490 auto load_from_path = [
this](
const std::string& file_name) -> absl::Status {
1491 if (file_name.empty()) {
1492 return absl::OkStatus();
1496 if (absl::StrContains(file_name,
".yaze")) {
1503 return absl::OkStatus();
1511 std::move(temp_rom), file_name);
1512 if (!session_or.ok()) {
1513 return session_or.status();
1522 label_provider.SetPreferHMagicNames(
1524 LOG_INFO(
"EditorManager",
"Initialized ResourceLabelProvider for LoadRom");
1526#ifdef YAZE_ENABLE_TESTING
1531 manager.AddFile(file_name);
1544 return absl::OkStatus();
1547#if defined(__APPLE__) && TARGET_OS_IOS == 1
1550 [
this, load_from_path](
const std::string& file_name) {
1551 auto status = load_from_path(file_name);
1554 absl::StrFormat(
"Failed to load ROM: %s", status.message()),
1558 return absl::OkStatus();
1562 return load_from_path(file_name);
1569 if (!current_rom || !current_editor_set) {
1570 return absl::FailedPreconditionError(
"No ROM or editor set loaded");
1573 auto start_time = std::chrono::steady_clock::now();
1575#ifdef __EMSCRIPTEN__
1577 auto loading_handle =
1579 ?
static_cast<app::platform::WasmLoadingManager::LoadingHandle
>(
1581 : app::platform::WasmLoadingManager::BeginLoading(
1582 "Loading Editor Assets");
1585 constexpr float kStartProgress = 0.10f;
1586 constexpr float kEndProgress = 1.0f;
1587 constexpr int kTotalSteps = 11;
1588 int current_step = 0;
1589 auto update_progress = [&](
const std::string& message) {
1592 kStartProgress + (kEndProgress - kStartProgress) *
1593 (
static_cast<float>(current_step) / kTotalSteps);
1594 app::platform::WasmLoadingManager::UpdateProgress(loading_handle, progress);
1595 app::platform::WasmLoadingManager::UpdateMessage(loading_handle, message);
1598 auto cleanup_loading = [&]() {
1599 app::platform::WasmLoadingManager::EndLoading(loading_handle);
1601 struct LoadingGuard {
1602 std::function<void()> cleanup;
1603 bool dismissed =
false;
1608 void dismiss() { dismissed =
true; }
1609 } loading_guard{cleanup_loading};
1611 (void)passed_handle;
1621 current_editor_set->GetOverworldEditor()->Initialize();
1622 current_editor_set->GetMessageEditor()->Initialize();
1623 current_editor_set->GetGraphicsEditor()->Initialize();
1624 current_editor_set->GetScreenEditor()->Initialize();
1625 current_editor_set->GetSpriteEditor()->Initialize();
1626 current_editor_set->GetPaletteEditor()->Initialize();
1627 current_editor_set->GetAssemblyEditor()->Initialize();
1628 current_editor_set->GetMusicEditor()->Initialize();
1631 current_editor_set->GetDungeonEditor()->Initialize(
renderer_, current_rom);
1633#ifdef __EMSCRIPTEN__
1634 update_progress(
"Loading graphics sheets...");
1638 if (!current_session) {
1639 return absl::FailedPreconditionError(
"No active ROM session");
1648 current_session->game_data.gfx_bitmaps;
1651 auto* game_data = ¤t_session->game_data;
1652 current_editor_set->GetDungeonEditor()->SetGameData(game_data);
1653 current_editor_set->GetOverworldEditor()->SetGameData(game_data);
1654 current_editor_set->GetGraphicsEditor()->SetGameData(game_data);
1655 current_editor_set->GetScreenEditor()->SetGameData(game_data);
1656 current_editor_set->GetPaletteEditor()->SetGameData(game_data);
1657 current_editor_set->GetSpriteEditor()->SetGameData(game_data);
1658 current_editor_set->GetMessageEditor()->SetGameData(game_data);
1660#ifdef __EMSCRIPTEN__
1661 update_progress(
"Loading overworld...");
1665#ifdef __EMSCRIPTEN__
1666 update_progress(
"Loading dungeons...");
1670#ifdef __EMSCRIPTEN__
1671 update_progress(
"Loading screen editor...");
1675#ifdef __EMSCRIPTEN__
1676 update_progress(
"Loading graphics editor...");
1680#ifdef __EMSCRIPTEN__
1681 update_progress(
"Loading settings...");
1686#ifdef __EMSCRIPTEN__
1687 update_progress(
"Loading sprites...");
1691#ifdef __EMSCRIPTEN__
1692 update_progress(
"Loading messages...");
1696#ifdef __EMSCRIPTEN__
1697 update_progress(
"Loading music...");
1701#ifdef __EMSCRIPTEN__
1702 update_progress(
"Loading palettes...");
1706#ifdef __EMSCRIPTEN__
1707 update_progress(
"Finishing up...");
1712 auto* settings = current_editor_set->GetSettingsPanel();
1721 if (
auto* settings = current_editor_set->GetSettingsPanel()) {
1730#ifdef __EMSCRIPTEN__
1732 loading_guard.dismiss();
1733 app::platform::WasmLoadingManager::EndLoading(loading_handle);
1736 auto end_time = std::chrono::steady_clock::now();
1737 auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
1738 end_time - start_time);
1739 LOG_DEBUG(
"EditorManager",
"ROM assets loaded in %lld ms", duration.count());
1741 return absl::OkStatus();
1762 if (!current_rom || !current_editor_set) {
1763 return absl::FailedPreconditionError(
"No ROM or editor set loaded");
1769 *current_rom, current_editor_set->GetScreenEditor()->dungeon_maps_));
1785 return absl::FailedPreconditionError(
"No ROM loaded");
1793 if (save_status.ok()) {
1798 session->filepath = filename;
1804 manager.AddFile(filename);
1812 LOG_INFO(
"EditorManager",
"OpenRomOrProject called with: '%s'",
1814 if (filename.empty()) {
1815 LOG_INFO(
"EditorManager",
"Empty filename provided, skipping load.");
1816 return absl::OkStatus();
1819#ifdef __EMSCRIPTEN__
1821 auto loading_handle =
1822 app::platform::WasmLoadingManager::BeginLoading(
"Loading ROM");
1823 app::platform::WasmLoadingManager::UpdateMessage(loading_handle,
1824 "Reading ROM file...");
1826 struct LoadingGuard {
1827 app::platform::WasmLoadingManager::LoadingHandle handle;
1828 bool dismissed =
false;
1831 app::platform::WasmLoadingManager::EndLoading(handle);
1833 void dismiss() { dismissed =
true; }
1834 } loading_guard{loading_handle};
1837 if (absl::StrContains(filename,
".yaze")) {
1849#ifdef __EMSCRIPTEN__
1850 app::platform::WasmLoadingManager::UpdateProgress(loading_handle, 0.05f);
1851 app::platform::WasmLoadingManager::UpdateMessage(loading_handle,
1852 "Loading ROM data...");
1858 std::move(temp_rom), filename);
1859 if (!session_or.ok()) {
1860 return session_or.status();
1875 label_provider.SetPreferHMagicNames(
1878 "Initialized ResourceLabelProvider for ROM-only load");
1882#ifdef YAZE_ENABLE_TESTING
1883 LOG_DEBUG(
"EditorManager",
"Setting ROM in TestManager - %p ('%s')",
1897#ifdef __EMSCRIPTEN__
1898 app::platform::WasmLoadingManager::UpdateProgress(loading_handle, 0.10f);
1899 app::platform::WasmLoadingManager::UpdateMessage(loading_handle,
1900 "Initializing editors...");
1903 loading_guard.dismiss();
1917 return absl::OkStatus();
1929#if !(defined(__APPLE__) && TARGET_OS_IOS == 1)
1940 auto open_project_from_path =
1941 [
this](
const std::string& file_path) -> absl::Status {
1942 if (file_path.empty()) {
1943 return absl::OkStatus();
1950 auto validation_status = new_project.
Validate();
1951 if (!validation_status.ok()) {
1953 validation_status.message()),
1970#if defined(__APPLE__) && TARGET_OS_IOS == 1
1973 [
this, open_project_from_path](
const std::string& file_path) {
1974 auto status = open_project_from_path(file_path);
1977 absl::StrFormat(
"Failed to open project: %s", status.message()),
1981 return absl::OkStatus();
1984 return open_project_from_path(file_path);
1993 "Project has no ROM file configured. Please select a ROM.",
1995#if defined(__APPLE__) && TARGET_OS_IOS == 1
1998 [
this](
const std::string& rom_path) {
1999 if (rom_path.empty()) {
2004 if (!save_status.ok()) {
2006 absl::StrFormat(
"Failed to update project ROM: %s",
2007 save_status.message()),
2014 absl::StrFormat(
"Failed to load project ROM: %s",
2019 return absl::OkStatus();
2023 if (rom_path.empty()) {
2024 return absl::OkStatus();
2036 if (!load_status.ok()) {
2039 absl::StrFormat(
"Could not load ROM '%s': %s. Please select a new ROM.",
2042#if defined(__APPLE__) && TARGET_OS_IOS == 1
2045 [
this](
const std::string& rom_path) {
2046 if (rom_path.empty()) {
2051 if (!save_status.ok()) {
2053 absl::StrFormat(
"Failed to update project ROM: %s",
2054 save_status.message()),
2061 absl::StrFormat(
"Failed to load project ROM: %s",
2066 return absl::OkStatus();
2070 if (rom_path.empty()) {
2071 return absl::OkStatus();
2081 if (!session_or.ok()) {
2082 return session_or.status();
2095#ifdef YAZE_ENABLE_TESTING
2096 LOG_DEBUG(
"EditorManager",
"Setting ROM in TestManager - %p ('%s')",
2132 "Initialized ResourceLabelProvider with project labels");
2150 return absl::OkStatus();
2177 for (
const auto& file : manager.GetRecentFiles()) {
2189 :
"untitled_project";
2193 if (file_path.empty()) {
2194 return absl::OkStatus();
2198 if (file_path.find(
".yaze") == std::string::npos) {
2199 file_path +=
".yaze";
2207 if (save_status.ok()) {
2210 manager.AddFile(file_path);
2219 absl::StrFormat(
"Failed to save project: %s", save_status.message()),
2231 return absl::OkStatus();
2236 return absl::FailedPreconditionError(
"No project is currently open");
2243 return absl::OkStatus();
2248 return absl::InvalidArgumentError(
"Invalid ROM pointer");
2257 if (session && &session->rom == rom) {
2261 return absl::OkStatus();
2267 return absl::NotFoundError(
"ROM not found in existing sessions");
2314 EditorType type,
size_t session_index)
const {
2315 const char* base_name =
kEditorNames[
static_cast<int>(type)];
2317 base_name, session_index)
2318 : std::string(base_name);
2336#ifdef YAZE_BUILD_AGENT_UI
2358 : manager_(manager),
2359 prev_rom_(manager->GetCurrentRom()),
2360 prev_editor_set_(manager->GetCurrentEditorSet()),
2361 prev_session_id_(manager->GetCurrentSessionId()) {
2368 manager_->session_coordinator_->SwitchToSession(prev_session_id_);
2418 absl::StrFormat(
"Failed to load project file: %s", status.message()),
2430 size_t session_id) {
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
static TimingManager & Get()
float Update()
Update the timing manager (call once per frame)
void SetRomContext(Rom *rom)
void SetProjectContext(project::YazeProject *project)
void SetAsarWrapperContext(core::AsarWrapper *asar_wrapper)
void Initialize(ToastManager *toast_manager, ProposalDrawer *proposal_drawer, RightPanelManager *right_panel_manager, PanelManager *panel_manager)
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 JumpToDungeonRoom(int room_id)
Jump to a specific dungeon room.
void JumpToOverworldMap(int map_id)
Jump to a specific overworld map.
SessionScope(EditorManager *manager, size_t session_id)
The EditorManager controls the main editor window and manages the various editor classes.
absl::Status SaveProjectAs()
std::unique_ptr< SessionCoordinator > session_coordinator_
void OnSessionClosed(size_t index) override
Called when a session is closed.
StartupVisibility welcome_mode_override_
void InitializeTestSuites()
std::unique_ptr< GlobalEditorContext > editor_context_
absl::Status SaveRomAs(const std::string &filename)
project::YazeProject current_project_
AgentUiController agent_ui_
absl::Status LoadProjectWithRom()
MenuBuilder menu_builder_
void ConfigureSession(RomSession *session)
void JumpToDungeonRoom(int room_id)
void SwitchToSession(size_t index)
size_t GetActiveSessionCount() const
absl::Status OpenProject()
ProjectManager project_manager_
void CloseCurrentSession()
gfx::IRenderer * renderer_
bool HasDuplicateSession(const std::string &filepath)
absl::Status RepairCurrentProject()
std::unique_ptr< LayoutManager > layout_manager_
std::unique_ptr< DashboardPanel > dashboard_panel_
void ProcessStartupActions(const AppConfig &config)
std::string GenerateUniqueEditorTitle(EditorType type, size_t session_index) const
void DrawMenuBar()
Draw the main menu bar.
void ShowProjectManagement()
Injects dependencies into all editors within an EditorSet.
void DuplicateCurrentSession()
void Initialize(gfx::IRenderer *renderer, const std::string &filename="")
EditorRegistry editor_registry_
void ApplyStartupVisibilityOverrides()
void ResetWorkspaceLayout()
absl::Status CreateNewProject(const std::string &template_name="Basic ROM Hack")
ToastManager toast_manager_
LayoutCoordinator layout_coordinator_
absl::Status LoadAssets(uint64_t loading_handle=0)
auto GetCurrentEditorSet() const -> EditorSet *
void OnSessionRomLoaded(size_t index, RomSession *session) override
Called when a ROM is loaded into a session.
std::unique_ptr< MenuOrchestrator > menu_orchestrator_
ProjectFileEditor project_file_editor_
void ApplyLayoutPreset(const std::string &preset_name)
void ApplyStartupVisibility(const AppConfig &config)
~EditorManager() override
auto GetCurrentEditor() const -> Editor *
bool show_rom_load_options_
absl::Status SaveProject()
std::unique_ptr< RightPanelManager > right_panel_manager_
std::unique_ptr< core::VersionManager > version_manager_
StartupVisibility sidebar_mode_override_
void JumpToOverworldMap(int map_id)
void OnSessionSwitched(size_t new_index, RomSession *session) override
Called when the active session changes.
RomLoadOptionsDialog rom_load_options_dialog_
absl::Status LoadRom()
Load a ROM file into a new or existing session.
std::vector< std::function< void()> > deferred_actions_
void OpenEditorAndPanelsFromFlags(const std::string &editor_name, const std::string &panels_str)
StartupVisibility dashboard_mode_override_
void ShowProjectFileEditor()
static bool IsPanelBasedEditor(EditorType type)
absl::Status Update()
Main update loop for the editor application.
size_t GetCurrentSessionIndex() const
absl::Status ImportProject(const std::string &project_path)
size_t GetCurrentSessionId() const
void OnSessionCreated(size_t index, RomSession *session) override
Called when a new session is created.
void QueueDeferredAction(std::function< void()> action)
SelectionPropertiesPanel selection_properties_panel_
WindowDelegate window_delegate_
std::unique_ptr< ActivityBar > activity_bar_
ShortcutManager shortcut_manager_
void HideCurrentEditorPanels()
EditorDependencies::SharedClipboard shared_clipboard_
void SwitchToEditor(EditorType editor_type, bool force_visible=false, bool from_dialog=false)
UserSettings user_settings_
WorkspaceManager workspace_manager_
auto GetCurrentRom() const -> Rom *
ProposalDrawer proposal_drawer_
void ConfigureEditorDependencies(EditorSet *editor_set, Rom *rom, size_t session_id)
WelcomeScreen welcome_screen_
std::unique_ptr< ProjectManagementPanel > project_management_panel_
absl::Status OpenRomOrProject(const std::string &filename)
void RemoveSession(size_t index)
PanelManager panel_manager_
std::unique_ptr< PopupManager > popup_manager_
std::unique_ptr< UICoordinator > ui_coordinator_
EditorActivator editor_activator_
absl::Status SaveRom()
Save the current ROM file.
absl::Status SetCurrentRom(Rom *rom)
RomFileManager rom_file_manager_
void ResetCurrentEditorLayout()
static EditorType GetEditorTypeFromCategory(const std::string &category)
static std::vector< std::string > GetAllEditorCategories()
Get all editor categories in display order for sidebar.
static bool IsPanelBasedEditor(EditorType type)
static std::string GetEditorCategory(EditorType type)
Contains a complete set of editors for a single ROM instance.
size_t session_id() const
void ApplyDependencies(const EditorDependencies &dependencies)
void set_user_settings(UserSettings *settings)
SettingsPanel * GetSettingsPanel() const
void ProcessDeferredActions()
Process all queued deferred actions.
void ResetWorkspaceLayout()
Reset the workspace layout to defaults.
void ProcessLayoutRebuild(EditorType current_editor_type, bool is_emulator_visible)
Process pending layout rebuild requests.
void ResetCurrentEditorLayout(EditorType editor_type, size_t session_id)
Reset current editor layout to its default configuration.
void ApplyLayoutPreset(const std::string &preset_name, size_t session_id)
Apply a named layout preset.
void Initialize(const Dependencies &deps)
Initialize with all dependencies.
void ToggleSidebarVisibility()
void SetUndoCallback(std::function< void()> cb)
void SetShowCommandPaletteCallback(std::function< void()> cb)
void SetOnCategorySelectedCallback(std::function< void(const std::string &)> callback)
void SetSidebarStateChangedCallback(std::function< void(bool, bool)> cb)
void SetFileBrowserPath(const std::string &category, const std::string &path)
void SetShowPanelBrowserCallback(std::function< void()> cb)
void SetShowSearchCallback(std::function< void()> cb)
const PanelDescriptor * GetPanelDescriptor(size_t session_id, const std::string &base_card_id) const
void SetCategoryChangedCallback(std::function< void(const std::string &)> cb)
bool * GetVisibilityFlag(size_t session_id, const std::string &base_card_id)
void SetOnPanelClickedCallback(std::function< void(const std::string &)> callback)
void SetShowShortcutsCallback(std::function< void()> cb)
bool ShowPanel(size_t session_id, const std::string &base_card_id)
void RegisterPanel(size_t session_id, const PanelDescriptor &base_info)
std::string GetActiveCategory() const
void EnableFileBrowser(const std::string &category, const std::string &root_path="")
void SetShowEmulatorCallback(std::function< void()> cb)
void SetPanelExpanded(bool expanded)
void SetShowSettingsCallback(std::function< void()> cb)
void DrawAllVisiblePanels()
Draw all visible EditorPanel instances (central drawing)
bool IsSidebarVisible() const
void SetRedoCallback(std::function< void()> cb)
static constexpr const char * kDashboardCategory
const std::unordered_map< std::string, PanelDescriptor > & GetAllPanelDescriptors() const
Get all panel descriptors (for layout designer, panel browser, etc.)
void SetSidebarVisible(bool visible)
void SetSaveRomCallback(std::function< void()> cb)
void SetShowHelpCallback(std::function< void()> cb)
void SetActiveCategory(const std::string &category)
void SetFileClickedCallback(std::function< void(const std::string &category, const std::string &path)> callback)
void HideAllPanelsInCategory(size_t session_id, const std::string &category)
absl::Status LoadFile(const std::string &filepath)
Load a project file into the editor.
void SetProject(project::YazeProject *project)
Set the project pointer for label import operations.
void set_active(bool active)
Set whether the editor window is active.
void SetToastManager(ToastManager *toast_manager)
Set toast manager for notifications.
absl::Status FinalizeProjectCreation(const std::string &project_name, const std::string &project_path)
Complete project creation after ROM is loaded.
absl::Status SetProjectRom(const std::string &rom_path)
Set the ROM for the current project.
absl::Status CreateNewProject(const std::string &template_name="")
absl::Status ImportProject(const std::string &project_path)
project::YazeProject & GetCurrentProject()
absl::Status LoadRom(Rom *rom, const std::string &filename)
absl::Status SaveRom(Rom *rom)
absl::Status SaveRomAs(Rom *rom, const std::string &filename)
void Open(Rom *rom, const std::string &rom_filename)
Open the dialog after ROM detection.
void SetConfirmCallback(std::function< void(const LoadOptions &)> callback)
Set callback for when options are confirmed.
void Draw(bool *p_open)
Draw the dialog (wrapper around Show)
void SetSessionInfo(size_t session_id, size_t total_sessions)
Set session information.
void SetRom(Rom *rom)
Set the current ROM for dirty status and filename display.
void SetEnabled(bool enabled)
Enable or disable the status bar.
void Initialize(GlobalEditorContext *context)
void Draw()
Draw the status bar.
void Show(const std::string &message, ToastType type=ToastType::kInfo, float ttl_seconds=3.0f)
void SetNewProjectCallback(std::function< void()> callback)
Set callback for creating new project.
void SetOpenAgentCallback(std::function< void()> callback)
Set callback for opening AI Agent.
void SetOpenRomCallback(std::function< void()> callback)
Set callback for opening ROM.
void SetNewProjectWithTemplateCallback(std::function< void(const std::string &)> callback)
Set callback for creating project with template.
void SetOpenProjectCallback(std::function< void(const std::string &)> callback)
Set callback for opening project.
void set_panel_manager(PanelManager *manager)
bool is_audio_focus_mode() const
void set_renderer(gfx::IRenderer *renderer)
bool is_snes_initialized() const
auto running() const -> bool
void set_panel_manager(editor::PanelManager *manager)
auto mutable_gfx_sheets()
Get mutable reference to all graphics sheets.
Defines an abstract interface for all rendering operations.
static RecentFilesManager & GetInstance()
void SetCurrentRom(Rom *rom)
static TestManager & Get()
static void ShowOpenFileDialogAsync(const FileDialogOptions &options, std::function< void(const std::string &)> callback)
static std::string ShowSaveFileDialog(const std::string &default_name="", const std::string &default_extension="")
ShowSaveFileDialog opens a save file dialog and returns the selected filepath. Uses global feature fl...
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath. Uses global feature flag to...
static std::string ShowOpenFolderDialog()
ShowOpenFolderDialog opens a file dialog and returns the selected folder path. Uses global feature fl...
#define ICON_MD_VIDEOGAME_ASSET
#define ICON_MD_BUG_REPORT
#define ICON_MD_AUDIOTRACK
#define ICON_MD_DASHBOARD
#define ICON_MD_SPORTS_ESPORTS
#define ICON_MD_AUDIO_FILE
#define ICON_MD_SMART_TOY
#define ICON_MD_MENU_OPEN
#define LOG_DEBUG(category, format,...)
#define LOG_WARN(category, format,...)
#define LOG_INFO(category, format,...)
#define PRINT_IF_ERROR(expression)
std::string GetEditorName(EditorType type)
std::string StripSessionPrefix(absl::string_view panel_id)
std::optional< EditorType > ParseEditorTypeFromString(absl::string_view name)
Editors are the view controllers for the application.
constexpr std::array< const char *, 14 > kEditorNames
void ConfigureMenuShortcuts(const ShortcutDependencies &deps, ShortcutManager *shortcut_manager)
void ConfigureEditorShortcuts(const ShortcutDependencies &deps, ShortcutManager *shortcut_manager)
void ExecuteShortcuts(const ShortcutManager &shortcut_manager)
ImVec4 GetSurfaceContainerHighestVec4()
ImVec4 GetTextSecondaryVec4()
ImVec4 GetSurfaceContainerHighVec4()
void RegisterZ3edTestSuites()
FileDialogOptions MakeRomFileDialogOptions(bool include_all_files)
absl::Status LoadGameData(Rom &rom, GameData &data, const LoadOptions &options)
Loads all Zelda3-specific game data from a generic ROM.
absl::Status SaveAllGraphicsData(Rom &rom, const std::array< gfx::Bitmap, kNumGfxSheets > &sheets)
Saves all graphics sheets back to ROM.
void SetPreferHmagicSpriteNames(bool prefer)
absl::Status SaveDungeonMaps(Rom &rom, std::vector< DungeonMap > &dungeon_maps)
Save the dungeon maps to the ROM.
ResourceLabelProvider & GetResourceLabels()
Get the global ResourceLabelProvider instance.
#define RETURN_IF_ERROR(expr)
Configuration options for the application startup.
std::string startup_editor
StartupVisibility welcome_mode
std::vector< std::string > open_panels
StartupVisibility sidebar_mode
StartupVisibility dashboard_mode
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
Unified dependency container for all editor types.
project::YazeProject * project
ToastManager * toast_manager
SharedClipboard * shared_clipboard
gfx::IRenderer * renderer
ShortcutManager * shortcut_manager
UserSettings * user_settings
core::VersionManager * version_manager
PanelManager * panel_manager
PopupManager * popup_manager
All dependencies required by LayoutCoordinator.
PanelManager * panel_manager
ToastManager * toast_manager
UICoordinator * ui_coordinator
RightPanelManager * right_panel_manager
LayoutManager * layout_manager
bool save_overworld_items
std::string selected_preset
bool save_overworld_exits
bool enable_custom_overworld
bool save_overworld_entrances
Represents a single session, containing a ROM and its associated editors.
core::FeatureFlags::Flags feature_flags
SessionCoordinator * session_coordinator
WorkspaceManager * workspace_manager
EditorRegistry * editor_registry
MenuOrchestrator * menu_orchestrator
ToastManager * toast_manager
RomFileManager * rom_file_manager
EditorManager * editor_manager
ProjectManager * project_manager
UICoordinator * ui_coordinator
PopupManager * popup_manager
PanelManager * panel_manager
bool sidebar_panel_expanded
bool show_welcome_on_startup
std::string sidebar_active_category
bool prefer_hmagic_sprite_names
float autosave_interval_secs
std::vector< std::string > recent_files
Modern project structure with comprehensive settings consolidation.
absl::Status RepairProject()
bool project_opened() const
void InitializeResourceLabelProvider()
Initialize the global ResourceLabelProvider with this project's labels.
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > resource_labels
std::string assets_folder
std::string labels_filename
std::string GetDisplayName() const
WorkspaceSettings workspace_settings
absl::Status Open(const std::string &project_path)
absl::Status Validate() const
core::FeatureFlags::Flags feature_flags