feat: Enhance editor card management and shortcut functionality

- Introduced new shortcut categories for graphics, screen, and sprite editors, improving accessibility and organization.
- Updated DungeonEditorV2 and other editor classes to register cards with the EditorCardManager, allowing for better control and visibility management.
- Refactored shortcut registration for dungeon, graphics, screen, and sprite editors, ensuring consistent user experience across the application.
- Improved initialization processes to handle dynamic card visibility and shortcuts effectively.
This commit is contained in:
scawful
2025-10-09 09:46:29 -04:00
parent 9465195956
commit 219406901d
15 changed files with 315 additions and 86 deletions

View File

@@ -157,7 +157,9 @@ void DungeonCanvasViewer::DrawDungeonCanvas(int room_id) {
// Process queued texture commands
if (rom_ && rom_->is_loaded()) {
gfx::Arena::Get().ProcessTextureQueue(nullptr); // Will use default renderer
// Process texture queue using Arena's stored renderer
// The renderer was initialized in EditorManager::LoadAssets()
gfx::Arena::Get().ProcessTextureQueue(nullptr);
}
// Draw layer information overlay

View File

@@ -881,8 +881,11 @@ absl::Status DungeonEditor::UpdateRoomBackgroundLayers(int /*room_id*/) {
void DungeonEditor::ProcessDeferredTextures() {
// Process queued texture commands via Arena's deferred system
// Note: Arena will use its stored renderer reference
// Note: Arena uses its stored renderer reference (initialized in EditorManager)
// The parameter is ignored, but we pass nullptr to indicate we're using the stored renderer
gfx::Arena::Get().ProcessTextureQueue(nullptr);
// NOTE: This is deprecated - use DungeonEditorV2 instead
}
} // namespace yaze::editor

View File

@@ -24,55 +24,8 @@ void DungeonEditorV2::Initialize(gfx::IRenderer* renderer, Rom* rom) {
// Setup docking class for room windows
room_window_class_.ClassId = ImGui::GetID("DungeonRoomClass");
room_window_class_.DockingAllowUnclassed = false; // Room windows dock together
}
void DungeonEditorV2::Initialize() {}
absl::Status DungeonEditorV2::Load() {
if (!rom_ || !rom_->is_loaded()) {
return absl::FailedPreconditionError("ROM not loaded");
}
// Load all rooms using the loader component - DEFERRED for lazy loading
// RETURN_IF_ERROR(room_loader_.LoadAllRooms(rooms_));
RETURN_IF_ERROR(room_loader_.LoadRoomEntrances(entrances_));
// Load palette group
auto dungeon_main_pal_group = rom_->palette_group().dungeon_main;
current_palette_ = dungeon_main_pal_group[current_palette_group_id_];
ASSIGN_OR_RETURN(current_palette_group_,
gfx::CreatePaletteGroupFromLargePalette(current_palette_));
// Initialize components with loaded data
room_selector_.set_rooms(&rooms_);
room_selector_.set_entrances(&entrances_);
room_selector_.set_active_rooms(active_rooms_);
room_selector_.set_room_selected_callback(
[this](int room_id) { OnRoomSelected(room_id); });
canvas_viewer_.SetRooms(&rooms_);
canvas_viewer_.SetCurrentPaletteGroup(current_palette_group_);
canvas_viewer_.SetCurrentPaletteId(current_palette_id_);
object_selector_.SetCurrentPaletteGroup(current_palette_group_);
object_selector_.SetCurrentPaletteId(current_palette_id_);
object_selector_.set_rooms(&rooms_);
// NOW initialize emulator preview with loaded ROM
object_emulator_preview_.Initialize(renderer_, rom_);
// Initialize palette editor with loaded ROM
palette_editor_.Initialize(rom_);
// Initialize unified object editor card
object_editor_card_ = std::make_unique<ObjectEditorCard>(renderer_, rom_, &canvas_viewer_);
// Initialize manual renderer for debugging (uses canvas from canvas_viewer_)
manual_renderer_ = std::make_unique<ManualObjectRenderer>(
&canvas_viewer_.canvas(), rom_);
printf("[DungeonEditorV2] Manual renderer initialized for debugging\n");
// Register all cards with the card manager for unified control
// Register all cards with the card manager (done once during initialization)
auto& card_manager = gui::EditorCardManager::Get();
card_manager.RegisterCard({
@@ -146,6 +99,53 @@ absl::Status DungeonEditorV2::Load() {
});
printf("[DungeonEditorV2] Registered 7 cards with EditorCardManager\n");
}
void DungeonEditorV2::Initialize() {}
absl::Status DungeonEditorV2::Load() {
if (!rom_ || !rom_->is_loaded()) {
return absl::FailedPreconditionError("ROM not loaded");
}
// Load all rooms using the loader component - DEFERRED for lazy loading
// RETURN_IF_ERROR(room_loader_.LoadAllRooms(rooms_));
RETURN_IF_ERROR(room_loader_.LoadRoomEntrances(entrances_));
// Load palette group
auto dungeon_main_pal_group = rom_->palette_group().dungeon_main;
current_palette_ = dungeon_main_pal_group[current_palette_group_id_];
ASSIGN_OR_RETURN(current_palette_group_,
gfx::CreatePaletteGroupFromLargePalette(current_palette_));
// Initialize components with loaded data
room_selector_.set_rooms(&rooms_);
room_selector_.set_entrances(&entrances_);
room_selector_.set_active_rooms(active_rooms_);
room_selector_.set_room_selected_callback(
[this](int room_id) { OnRoomSelected(room_id); });
canvas_viewer_.SetRooms(&rooms_);
canvas_viewer_.SetCurrentPaletteGroup(current_palette_group_);
canvas_viewer_.SetCurrentPaletteId(current_palette_id_);
object_selector_.SetCurrentPaletteGroup(current_palette_group_);
object_selector_.SetCurrentPaletteId(current_palette_id_);
object_selector_.set_rooms(&rooms_);
// NOW initialize emulator preview with loaded ROM
object_emulator_preview_.Initialize(renderer_, rom_);
// Initialize palette editor with loaded ROM
palette_editor_.Initialize(rom_);
// Initialize unified object editor card
object_editor_card_ = std::make_unique<ObjectEditorCard>(renderer_, rom_, &canvas_viewer_);
// Initialize manual renderer for debugging (uses canvas from canvas_viewer_)
manual_renderer_ = std::make_unique<ManualObjectRenderer>(
&canvas_viewer_.canvas(), rom_);
printf("[DungeonEditorV2] Manual renderer initialized for debugging\n");
// Wire palette changes to trigger room re-renders
palette_editor_.SetOnPaletteChanged([this](int /*palette_id*/) {
@@ -267,12 +267,16 @@ void DungeonEditorV2::DrawToolset() {
void DungeonEditorV2::DrawControlPanel() {
// Small, collapsible control panel for dungeon editor
ImGui::SetNextWindowSize(ImVec2(250, 200), ImGuiCond_FirstUseEver);
ImGui::SetNextWindowSize(ImVec2(280, 280), ImGuiCond_FirstUseEver);
ImGui::SetNextWindowPos(ImVec2(10, 100), ImGuiCond_FirstUseEver);
ImGuiWindowFlags flags = ImGuiWindowFlags_None;
if (ImGui::Begin(ICON_MD_CASTLE " Dungeon Controls", &show_control_panel_, flags)) {
ImGui::TextWrapped("Welcome to Dungeon Editor V2!");
ImGui::TextDisabled("Use checkboxes below to open cards");
ImGui::Separator();
DrawToolset();
ImGui::Separator();

View File

@@ -120,14 +120,16 @@ class DungeonEditorV2 : public Editor {
std::unordered_map<int, std::shared_ptr<gui::EditorCard>> room_cards_;
int current_room_id_ = 0;
// Card visibility flags
bool show_room_selector_ = true;
// Card visibility flags - Start with only control panel visible
// Other cards hidden by default to prevent crash on ROM load
// User can open them via View menu or shortcuts
bool show_room_selector_ = false;
bool show_room_matrix_ = false;
bool show_entrances_list_ = false;
bool show_room_graphics_ = false; // Room graphics card
bool show_object_editor_ = true; // Unified object editor card
bool show_palette_editor_ = true;
bool show_control_panel_ = true; // Optional control panel
bool show_room_graphics_ = false;
bool show_object_editor_ = false;
bool show_palette_editor_ = false;
bool show_control_panel_ = true; // Only control panel visible on start
bool control_panel_minimized_ = false;
// Palette management