Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
AnimationEditorWindow.h
Go to the documentation of this file.
1/**
2 * @file AnimationEditorWindow.h
3 * @brief Animation Editor window for creating and editing animation banks
4 * @author Olympe Engine - Animation System
5 * @date 2025
6 *
7 * @details
8 * Provides a comprehensive animation editor for creating, editing, and previewing
9 * animation banks with multi-spritesheet support.
10 *
11 * Features:
12 * - Multi-spritesheet management per bank
13 * - Animation sequence editor with frame ranges
14 * - Real-time preview with playback controls
15 * - Spritesheet viewer with grid overlay and zoom/pan
16 * - JSON export using Unified Schema v2 format
17 */
18
19#pragma once
20
21#include "../Animation/AnimationTypes.h"
22#include <string>
23#include <vector>
24
25// Forward declarations
26struct SDL_Texture;
27struct SDL_Window;
28struct SDL_Renderer;
29struct ImGuiContext;
30
31namespace Olympe
32{
33 /**
34 * @class AnimationEditorWindow
35 * @brief Main animation editor window
36 *
37 * Provides UI for creating and editing animation banks with multi-spritesheet support.
38 * Opens with F9 hotkey. Renders in standalone SDL3 window (like BT Debugger).
39 */
41 {
42 public:
45
46 /**
47 * @brief Toggle window visibility
48 */
49 void Toggle();
50
51 /**
52 * @brief Check if window is open
53 */
54 bool IsOpen() const { return m_isOpen; }
55
56 /**
57 * @brief Update and render the editor window (separate window)
58 * @param deltaTime Time elapsed since last frame in seconds
59 */
60 void Update(float deltaTime);
61
62 /**
63 * @brief Process SDL events for the separate window
64 * @param event SDL event to process
65 */
67
68 /**
69 * @brief Update preview animation (call every frame with deltaTime)
70 * @param deltaTime Time elapsed since last frame in seconds
71 */
72 void UpdatePreview(float deltaTime);
73
74 /**
75 * @brief Render the editor window
76 */
77 void Render();
78
79 private:
80 // UI Panel Rendering
81 void RenderMainMenu();
85 void RenderPreviewPanel();
87
88 // File Operations
89 void NewBank();
90 void OpenBank(const std::string& filepath);
91 void SaveBank();
92 void SaveBankAs();
93 void ImportBankJSON(const std::string& filepath);
94 void ExportBankJSON(const std::string& filepath);
95 std::vector<std::string> ScanBankDirectory(const std::string& dirPath);
96
97 // Spritesheet Operations
98 void AddSpritesheet();
99 void RemoveSpritesheet(int index);
101 SDL_Texture* LoadSpritesheetTexture(const std::string& path);
102
103 // Sequence Operations
104 void AddSequence();
105 void RemoveSequence(int index);
106
107 // Preview Operations
108 void StartPreview();
109 void StopPreview();
110 void PausePreview();
111 void ResetPreview();
112 void RenderPreviewFrame();
113
114 // Helper Methods
115 void MarkDirty();
116 void ClearDirty();
118 void UpdateWindowTitle();
119
120 // State
121 bool m_isOpen = false;
122 bool m_isDirty = false;
123
124 // Current Bank Data
126 std::string m_currentBankPath;
127 bool m_hasBankLoaded = false;
128
129 // Selection State
132
133 // UI State
134 int m_activeTab = 0; // 0 = Spritesheets, 1 = Sequences
135
136 // Preview State
137 bool m_isPreviewPlaying = false;
138 bool m_isPreviewPaused = false;
139 float m_previewSpeed = 1.0f;
142
143 // Spritesheet Viewer State
144 float m_spritesheetZoom = 1.0f;
145 float m_spritesheetPanX = 0.0f;
146 float m_spritesheetPanY = 0.0f;
147 bool m_showGrid = true;
148
149 // Texture Cache (spritesheet path -> SDL_Texture*)
150 // Note: We'll use DataManager for texture loading, so this is just for tracking
151
152 // Dialog State
157
158 // Input Buffers (for dialogs)
159 char m_inputBankId[256] = "";
160 char m_inputDescription[1024] = "";
161 char m_inputAuthor[256] = "";
162 char m_inputSpritesheetId[256] = "";
164 char m_inputSequenceName[256] = "";
165
166 // ===== Standalone Window Management =====
170
174 };
175
176} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Main animation editor window.
void Toggle()
Toggle window visibility.
void ExportBankJSON(const std::string &filepath)
void AutoDetectGrid(SpritesheetInfo &sheet)
std::vector< std::string > ScanBankDirectory(const std::string &dirPath)
bool IsOpen() const
Check if window is open.
void UpdatePreview(float deltaTime)
Update preview animation (call every frame with deltaTime)
void Update(float deltaTime)
Update and render the editor window (separate window)
void ImportBankJSON(const std::string &filepath)
void OpenBank(const std::string &filepath)
void Render()
Render the editor window.
void ProcessEvent(SDL_Event *event)
Process SDL events for the separate window.
SDL_Texture * LoadSpritesheetTexture(const std::string &path)
Collection of animations for an entity with multi-spritesheet support.
Metadata for a single spritesheet within an animation bank.