Refactor DungeonEditor and introduce new components for enhanced dungeon editing
- Integrated new components: DungeonToolset, DungeonObjectInteraction, DungeonRenderer, DungeonRoomLoader, and DungeonUsageTracker to streamline dungeon editing functionalities. - Updated DungeonEditor to utilize the new components for room loading, object interaction, and rendering, improving code organization and maintainability. - Enhanced object selection and placement features, including drag-and-drop functionality and improved UI interactions. - Removed legacy methods and refactored existing code to delegate responsibilities to the new components, ensuring a cleaner architecture. - Added support for usage tracking of blocksets, spritesets, and palettes across dungeon rooms, providing insights for optimization.
This commit is contained in:
57
src/app/editor/dungeon/dungeon_usage_tracker.h
Normal file
57
src/app/editor/dungeon/dungeon_usage_tracker.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef YAZE_APP_EDITOR_DUNGEON_DUNGEON_USAGE_TRACKER_H
|
||||
#define YAZE_APP_EDITOR_DUNGEON_DUNGEON_USAGE_TRACKER_H
|
||||
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "app/zelda3/dungeon/room.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
|
||||
/**
|
||||
* @brief Tracks and analyzes usage statistics for dungeon resources
|
||||
*
|
||||
* This component manages blockset, spriteset, and palette usage statistics
|
||||
* across all dungeon rooms, providing insights for optimization.
|
||||
*/
|
||||
class DungeonUsageTracker {
|
||||
public:
|
||||
DungeonUsageTracker() = default;
|
||||
|
||||
// Statistics calculation
|
||||
void CalculateUsageStats(const std::array<zelda3::Room, 0x128>& rooms);
|
||||
void DrawUsageStats();
|
||||
void DrawUsageGrid();
|
||||
void RenderSetUsage(const absl::flat_hash_map<uint16_t, int>& usage_map,
|
||||
uint16_t& selected_set, int spriteset_offset = 0x00);
|
||||
|
||||
// Data access
|
||||
const absl::flat_hash_map<uint16_t, int>& GetBlocksetUsage() const { return blockset_usage_; }
|
||||
const absl::flat_hash_map<uint16_t, int>& GetSpritesetUsage() const { return spriteset_usage_; }
|
||||
const absl::flat_hash_map<uint16_t, int>& GetPaletteUsage() const { return palette_usage_; }
|
||||
|
||||
// Selection state
|
||||
uint16_t GetSelectedBlockset() const { return selected_blockset_; }
|
||||
uint16_t GetSelectedSpriteset() const { return selected_spriteset_; }
|
||||
uint16_t GetSelectedPalette() const { return selected_palette_; }
|
||||
|
||||
void SetSelectedBlockset(uint16_t blockset) { selected_blockset_ = blockset; }
|
||||
void SetSelectedSpriteset(uint16_t spriteset) { selected_spriteset_ = spriteset; }
|
||||
void SetSelectedPalette(uint16_t palette) { selected_palette_ = palette; }
|
||||
|
||||
// Clear data
|
||||
void ClearUsageStats();
|
||||
|
||||
private:
|
||||
absl::flat_hash_map<uint16_t, int> spriteset_usage_;
|
||||
absl::flat_hash_map<uint16_t, int> blockset_usage_;
|
||||
absl::flat_hash_map<uint16_t, int> palette_usage_;
|
||||
|
||||
uint16_t selected_blockset_ = 0xFFFF; // 0xFFFF indicates no selection
|
||||
uint16_t selected_spriteset_ = 0xFFFF;
|
||||
uint16_t selected_palette_ = 0xFFFF;
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_APP_EDITOR_DUNGEON_DUNGEON_USAGE_TRACKER_H
|
||||
Reference in New Issue
Block a user