feat: Implement lazy loading for dungeon rooms and refactor room graphics handling
- Introduced lazy loading for room data to optimize performance and reduce initial load times. - Updated DungeonEditor and DungeonRoomLoader to handle room graphics rendering directly from room objects. - Refactored methods to accept room references instead of IDs for better clarity and type safety. - Enhanced tab management in the DungeonEditor UI for improved user experience.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -86,12 +86,12 @@ bool LoadROMPaletteGroups(Rom* rom, CanvasPaletteManager& palette_manager) {
|
||||
}
|
||||
|
||||
palette_manager.palettes_loaded = true;
|
||||
util::logf("Canvas: Loaded %zu ROM palette groups",
|
||||
LOG_INFO("Canvas", "Loaded %zu ROM palette groups",
|
||||
palette_manager.rom_palette_groups.size());
|
||||
return true;
|
||||
|
||||
} catch (const std::exception& e) {
|
||||
util::logf("Canvas: Failed to load ROM palette groups: %s", e.what());
|
||||
LOG_ERROR("Canvas", "Failed to load ROM palette groups");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -117,12 +117,12 @@ bool ApplyPaletteGroup(gfx::Bitmap* bitmap,
|
||||
}
|
||||
|
||||
Renderer::Get().UpdateBitmap(bitmap);
|
||||
util::logf("Canvas: Applied palette group %d, index %d to bitmap",
|
||||
LOG_INFO("Canvas", "Applied palette group %d, index %d to bitmap",
|
||||
group_index, palette_index);
|
||||
return true;
|
||||
|
||||
} catch (const std::exception& e) {
|
||||
util::logf("Canvas: Failed to apply palette: %s", e.what());
|
||||
LOG_ERROR("Canvas", "Failed to apply palette");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,12 +85,12 @@ bool LoadROMPaletteGroups(Rom* rom, CanvasPaletteManager& palette_manager) {
|
||||
}
|
||||
|
||||
palette_manager.palettes_loaded = true;
|
||||
util::logf("Canvas: Loaded %zu ROM palette groups",
|
||||
LOG_INFO("Canvas", "Loaded %zu ROM palette groups",
|
||||
palette_manager.rom_palette_groups.size());
|
||||
return true;
|
||||
|
||||
} catch (const std::exception& e) {
|
||||
util::logf("Canvas: Failed to load ROM palette groups: %s", e.what());
|
||||
LOG_ERROR("Canvas", "Failed to load ROM palette groups");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -116,12 +116,12 @@ bool ApplyPaletteGroup(gfx::Bitmap* bitmap,
|
||||
}
|
||||
|
||||
Renderer::Get().UpdateBitmap(bitmap);
|
||||
util::logf("Canvas: Applied palette group %d, index %d to bitmap",
|
||||
LOG_INFO("Canvas", "Applied palette group %d, index %d to bitmap",
|
||||
group_index, palette_index);
|
||||
return true;
|
||||
|
||||
} catch (const std::exception& e) {
|
||||
util::logf("Canvas: Failed to apply palette: %s", e.what());
|
||||
LOG_ERROR("Canvas", "Failed to apply palette");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,12 +174,9 @@ bool EnhancedPaletteEditor::ApplyROMPalette(gfx::Bitmap* bitmap, int group_index
|
||||
current_group_index_ = group_index;
|
||||
current_palette_index_ = palette_index;
|
||||
|
||||
util::logf("Applied ROM palette: %s (index %d)",
|
||||
palette_group_names_[group_index].c_str(), palette_index);
|
||||
return true;
|
||||
|
||||
} catch (const std::exception& e) {
|
||||
util::logf("Failed to apply ROM palette: %s", e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -455,10 +452,9 @@ void EnhancedPaletteEditor::LoadROMPalettes() {
|
||||
}
|
||||
|
||||
rom_palettes_loaded_ = true;
|
||||
util::logf("Enhanced Palette Editor: Loaded %zu ROM palette groups", rom_palette_groups_.size());
|
||||
|
||||
} catch (const std::exception& e) {
|
||||
util::logf("Enhanced Palette Editor: Failed to load ROM palettes: %s", e.what());
|
||||
LOG_ERROR("Enhanced Palette Editor", "Failed to load ROM palettes");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
72
src/app/gui/feature_flags_menu.h
Normal file
72
src/app/gui/feature_flags_menu.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef YAZE_APP_GUI_FEATURE_FLAGS_MENU_H
|
||||
#define YAZE_APP_GUI_FEATURE_FLAGS_MENU_H
|
||||
|
||||
#include "app/core/features.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace gui {
|
||||
|
||||
using ImGui::BeginMenu;
|
||||
using ImGui::Checkbox;
|
||||
using ImGui::EndMenu;
|
||||
using ImGui::MenuItem;
|
||||
using ImGui::Separator;
|
||||
|
||||
struct FlagsMenu {
|
||||
void DrawOverworldFlags() {
|
||||
Checkbox("Enable Overworld Sprites",
|
||||
&core::FeatureFlags::get().overworld.kDrawOverworldSprites);
|
||||
Separator();
|
||||
Checkbox("Save Overworld Maps",
|
||||
&core::FeatureFlags::get().overworld.kSaveOverworldMaps);
|
||||
Checkbox("Save Overworld Entrances",
|
||||
&core::FeatureFlags::get().overworld.kSaveOverworldEntrances);
|
||||
Checkbox("Save Overworld Exits",
|
||||
&core::FeatureFlags::get().overworld.kSaveOverworldExits);
|
||||
Checkbox("Save Overworld Items",
|
||||
&core::FeatureFlags::get().overworld.kSaveOverworldItems);
|
||||
Checkbox("Save Overworld Properties",
|
||||
&core::FeatureFlags::get().overworld.kSaveOverworldProperties);
|
||||
Checkbox("Enable Custom Overworld Features",
|
||||
&core::FeatureFlags::get().overworld.kLoadCustomOverworld);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("?")) {
|
||||
ImGui::OpenPopup("CustomOverworldHelp");
|
||||
}
|
||||
if (ImGui::BeginPopup("CustomOverworldHelp")) {
|
||||
ImGui::Text("This flag enables ZSCustomOverworld features.");
|
||||
ImGui::Text("If ZSCustomOverworld ASM is already applied to the ROM,");
|
||||
ImGui::Text("features are auto-enabled regardless of this flag.");
|
||||
ImGui::Text("For vanilla ROMs, enable this to use custom features.");
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
Checkbox("Apply ZSCustomOverworld ASM",
|
||||
&core::FeatureFlags::get().overworld.kApplyZSCustomOverworldASM);
|
||||
}
|
||||
|
||||
void DrawDungeonFlags() {
|
||||
Checkbox("Save Dungeon Maps", &core::FeatureFlags::get().kSaveDungeonMaps);
|
||||
}
|
||||
|
||||
void DrawResourceFlags() {
|
||||
Checkbox("Save All Palettes", &core::FeatureFlags::get().kSaveAllPalettes);
|
||||
Checkbox("Save Gfx Groups", &core::FeatureFlags::get().kSaveGfxGroups);
|
||||
Checkbox("Save Graphics Sheets", &core::FeatureFlags::get().kSaveGraphicsSheet);
|
||||
}
|
||||
|
||||
void DrawSystemFlags() {
|
||||
Checkbox("Enable Console Logging", &core::FeatureFlags::get().kLogToConsole);
|
||||
Checkbox("Enable Performance Monitoring",
|
||||
&core::FeatureFlags::get().kEnablePerformanceMonitoring);
|
||||
Checkbox("Log Instructions to Emulator Debugger",
|
||||
&core::FeatureFlags::get().kLogInstructions);
|
||||
Checkbox("Use Native File Dialog (NFD)",
|
||||
&core::FeatureFlags::get().kUseNativeFileDialog);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_APP_GUI_FEATURE_FLAGS_MENU_H
|
||||
@@ -2,6 +2,7 @@ set(
|
||||
YAZE_GUI_SRC
|
||||
app/gui/modules/asset_browser.cc
|
||||
app/gui/modules/text_editor.cc
|
||||
app/gui/widgets/agent_chat_widget.cc
|
||||
app/gui/canvas.cc
|
||||
app/gui/canvas_utils.cc
|
||||
app/gui/enhanced_palette_editor.cc
|
||||
@@ -12,6 +13,7 @@ set(
|
||||
app/gui/background_renderer.cc
|
||||
app/gui/bpp_format_ui.cc
|
||||
app/gui/widget_id_registry.cc
|
||||
app/gui/widget_auto_register.cc
|
||||
# Canvas system components
|
||||
app/gui/canvas/canvas_modals.cc
|
||||
app/gui/canvas/canvas_context_menu.cc
|
||||
|
||||
@@ -125,7 +125,7 @@ void ThemeManager::InitializeBuiltInThemes() {
|
||||
// Load all available theme files dynamically
|
||||
auto status = LoadAllAvailableThemes();
|
||||
if (!status.ok()) {
|
||||
util::logf("Warning: Failed to load some theme files: %s", status.message().data());
|
||||
LOG_ERROR("Theme Manager", "Failed to load some theme files");
|
||||
}
|
||||
|
||||
// Ensure we have a valid current theme (Classic is already set above)
|
||||
@@ -326,7 +326,7 @@ void ThemeManager::ApplyTheme(const std::string& theme_name) {
|
||||
// Fallback to YAZE Tre if theme not found
|
||||
auto fallback_status = LoadTheme("YAZE Tre");
|
||||
if (!fallback_status.ok()) {
|
||||
util::logf("Failed to load fallback theme: %s", fallback_status.message().data());
|
||||
LOG_ERROR("Theme Manager", "Failed to load fallback theme");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -426,7 +426,7 @@ void ThemeManager::ShowThemeSelector(bool* p_open) {
|
||||
name.c_str()).c_str(), ImVec2(-1, 40))) {
|
||||
auto status = LoadTheme(name); // Use LoadTheme instead of ApplyTheme to ensure correct tracking
|
||||
if (!status.ok()) {
|
||||
util::logf("Failed to load theme %s: %s", name.c_str(), status.message().data());
|
||||
LOG_ERROR("Theme Manager", "Failed to load theme %s", name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ void ThemeManager::ShowThemeSelector(bool* p_open) {
|
||||
if (ImGui::Button(absl::StrFormat("%s Refresh Themes", ICON_MD_REFRESH).c_str())) {
|
||||
auto status = RefreshAvailableThemes();
|
||||
if (!status.ok()) {
|
||||
util::logf("Failed to refresh themes: %s", status.message().data());
|
||||
LOG_ERROR("Theme Manager", "Failed to refresh themes");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1019,7 +1019,7 @@ void ThemeManager::ShowSimpleThemeEditor(bool* p_open) {
|
||||
if (!current_file_path.empty()) {
|
||||
auto status = SaveThemeToFile(current_theme_, current_file_path);
|
||||
if (!status.ok()) {
|
||||
util::logf("Failed to save theme: %s", status.message().data());
|
||||
LOG_ERROR("Theme Manager", "Failed to save theme");
|
||||
}
|
||||
} else {
|
||||
// No existing file, prompt for new location
|
||||
@@ -1027,7 +1027,7 @@ void ThemeManager::ShowSimpleThemeEditor(bool* p_open) {
|
||||
if (!file_path.empty()) {
|
||||
auto status = SaveThemeToFile(current_theme_, file_path);
|
||||
if (!status.ok()) {
|
||||
util::logf("Failed to save theme: %s", status.message().data());
|
||||
LOG_ERROR("Theme Manager", "Failed to save theme");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1038,7 +1038,7 @@ void ThemeManager::ShowSimpleThemeEditor(bool* p_open) {
|
||||
if (!file_path.empty()) {
|
||||
auto status = SaveThemeToFile(current_theme_, file_path);
|
||||
if (!status.ok()) {
|
||||
util::logf("Failed to save theme: %s", status.message().data());
|
||||
LOG_ERROR("Theme Manager", "Failed to save theme");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1831,7 +1831,7 @@ void ThemeManager::ShowSimpleThemeEditor(bool* p_open) {
|
||||
ApplyTheme(edit_theme);
|
||||
theme_backup_made = false; // Reset backup state since theme is now applied
|
||||
} else {
|
||||
util::logf("Failed to save over current theme: %s", status.message().data());
|
||||
LOG_ERROR("Theme Manager", "Failed to save over current theme");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1873,7 +1873,7 @@ void ThemeManager::ShowSimpleThemeEditor(bool* p_open) {
|
||||
themes_[edit_theme.name] = edit_theme;
|
||||
ApplyTheme(edit_theme);
|
||||
} else {
|
||||
util::logf("Failed to save theme: %s", status.message().data());
|
||||
LOG_ERROR("Theme Manager", "Failed to save theme");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1981,7 +1981,7 @@ std::vector<std::string> ThemeManager::DiscoverAvailableThemeFiles() const {
|
||||
}
|
||||
#endif
|
||||
} catch (const std::exception& e) {
|
||||
util::logf("Error scanning directory %s: %s", search_path.c_str(), e.what());
|
||||
LOG_ERROR("Theme Manager", "Error scanning directory %s", search_path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user