WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
AppState.h
Go to the documentation of this file.
1#pragma once
2
3// ---- Consolidated application state header --------------------------------
4// Decomposed into sub-structs following the subsystem pattern from
5// Game Engine Architecture (Gregory): each group owns a cohesive slice
6// of the application's mutable state.
7
8#include <atomic>
9#include <chrono>
10#include <filesystem>
11#include <memory>
12#include <mutex>
13#include <string>
14#include <thread>
15#include <unordered_map>
16#include <vector>
17
18#include "AppSettings.h"
19#include "OrbitCamera.h"
20#include "Renderer.h"
21#include "ViewportFBO.h"
22#include "wow_enums.h"
23
24// Panel type imports (lightweight value types only)
25#include "AnimationPanel.h"
28#include "ItemSetsPanel.h"
29#include "MountsPanel.h"
30
31// Full definitions required for std::unique_ptr members
32#include "Attachment.h"
33#include "ExporterPlugin.h"
34#include "ImporterPlugin.h"
35
36// Forward declarations for pointer / reference members
37class GameFile;
38class WoWModel;
39
40// Full definition required for std::vector<core::GameConfig>
41#include "GameFolder.h"
42
43// ---- Supporting types -----------------------------------------------------
44
47{
48 std::string name;
49 std::string path;
50};
51
52// ---- Type aliases for brevity ---------------------------------------------
53
63
64// ---- Sub-struct: Scene (3D scene graph, camera, timing, model flags) ------
65
68{
71 std::unique_ptr<Attachment> root;
72 WoWModel* selModel = nullptr;
74
75 float animTime = 0.0f;
76 std::chrono::steady_clock::time_point lastTick;
77 float fps = 0.0f;
79 float fpsAccum = 0.0f;
80
81 bool isModel = false;
82 bool isChar = false;
83 bool isMounted = false;
84};
85
86// ---- Sub-struct: Loading (async game-data loading thread) -----------------
87
90{
91 bool isWoWLoaded = false;
92 std::atomic<bool> initDB{false};
93 std::string loadStatus;
94 std::atomic<float> loadProgress{0.0f};
95 bool loadInProgress = false;
96 std::thread loadThread;
97 std::mutex loadStatusMutex;
98 std::atomic<bool> loadThreadDone{false};
99 std::atomic<bool> loadThreadSuccess{false};
100 std::string pathBuf;
101 bool showConfigPopup = false;
102 std::vector<core::GameConfig> pendingConfigs;
104};
105
106// ---- Sub-struct: UI (visibility toggles, fonts, log, folder picker) -------
107
110{
111 // Dialog visibility
112 bool showAboutDialog = false;
113 bool showLanguageDialog = false;
114
115 // Panel open/close state (persisted via ImGui settings handler).
116 // Panels not in the map default to open.
117 std::unordered_map<std::string, bool> panelOpen;
118
121 bool& panel(const char* name)
122 {
123 auto [it, _] = panelOpen.try_emplace(name, true);
124 return it->second;
125 }
126
127 // Transient dialog visibility (not persisted)
128 bool showImportDialog = false;
129 bool showFolderPicker = false;
130
131 // Import dialog UI state
133
134 // Font system
135 std::vector<FontEntry> availableFonts;
136 bool fontsDirty = false;
137 float dpiScale = 1.0f;
138
139 // Folder picker
140 std::filesystem::path folderPickerCurrent;
141 std::vector<std::filesystem::path> folderPickerEntries;
143
144 // Log viewer
145 std::vector<std::string> logLines;
146 bool logAutoScroll = true;
147 bool logNeedsReload = true;
148};
149
150// ---- Sub-struct: Animation (playback, skins) ------------------------------
151
154{
155 std::vector<AnimEntry> animEntries;
157 float animSpeed = 1.0f;
158 bool autoAnimate = true;
161 float mouthSpeed = 1.0f;
162 bool lockAnims = true;
163 int loopCount = 0;
164 std::vector<SkinEntry> skinEntries;
165 int selectedSkin = -1;
166 int blpSkin[3] = {-1, -1, -1};
167};
168
169// ---- Sub-struct: Character (customization + equipment) --------------------
170
173{
174 std::vector<CustomizationOption> customizationOptions;
175 std::string equipSearchBuf;
178 std::vector<size_t> equipFilteredItems;
180};
181
182// ---- Sub-struct: Browsers (NPC, Item, Mount, ItemSet, StartOutfit) --------
183
186{
187 // Item Sets
188 std::vector<ItemSetEntry> itemSets;
189 bool itemSetsBuilt = false;
190 std::string itemSetSearchBuf;
191 std::vector<size_t> itemSetFiltered;
193
194 // Start Outfits
195 std::vector<StartOutfitEntry> startOutfits;
196 bool startOutfitsBuilt = false;
198 std::vector<size_t> startOutfitFiltered;
200
201 // NPC Browser
202 std::string npcSearchBuf;
203 std::vector<size_t> npcFiltered;
204 bool npcFilterDirty = true;
205
206 // Item Browser
208 std::vector<size_t> itemBrowseFiltered;
210
211 // Mounts
212 std::vector<MountEntry> mountList;
213 std::vector<GameFile*> creatureModels;
214 std::vector<std::string> creatureModelNames;
215 bool mountListBuilt = false;
216 std::string mountSearchBuf;
217 int mountTab = 0;
218 std::vector<size_t> mountFiltered;
219 bool mountFilterDirty = true;
220
221 // Model control (geosets, particle color)
222 std::vector<GeosetGroupEntry> geosetGroups;
224};
225
226// ---- Sub-struct: Export (export, import, screenshot, presets) --------------
227
230{
231 std::vector<std::unique_ptr<ExporterPlugin>> exporters;
233 std::string exportPath = "export";
234 std::string exportStatus;
235 std::vector<char> exportAnimChecked;
236
237 // Screenshot
238 std::string screenshotPath = "screenshot.png";
239 std::string screenshotStatus;
240 bool useCanvasOverride = false;
241 int canvasWidth = 1920;
242 int canvasHeight = 1080;
243
244 // Presets
245 std::string presetPath = "userSettings/preset.ini";
246 std::string presetStatus;
247
248 // URL Import
249 std::vector<std::unique_ptr<ImporterPlugin>> importers;
250 std::string importUrlBuf;
251 std::string importStatus;
252};
253
254// ---- Consolidated application state ---------------------------------------
255
Abstract base class representing a file within the game data archive.
Definition GameFile.h:12
Orbit camera that revolves around a target point.
Definition OrbitCamera.h:10
Core WoW .m2 model: geometry, animation, textures, and character data.
Definition WoWModel.h:50
Reusable animation entry — matches CharacterViewerPanel::AnimEntry.
Mutable state for animation playback and skin selection.
Definition AppState.h:154
std::vector< SkinEntry > skinEntries
Definition AppState.h:164
int selectedSecondaryAnim
Definition AppState.h:159
int selectedMouthAnim
Definition AppState.h:160
int blpSkin[3]
Definition AppState.h:166
float mouthSpeed
Definition AppState.h:161
float animSpeed
Definition AppState.h:157
int selectedAnimCombo
Definition AppState.h:156
std::vector< AnimEntry > animEntries
Definition AppState.h:155
Persistent application settings backed by userSettings/Config.ini.
Definition AppSettings.h:8
Top-level aggregate of all mutable application state.
Definition AppState.h:261
LoadingState loading
Definition AppState.h:263
SceneState scene
Definition AppState.h:262
AppSettings settings
Definition AppState.h:269
AnimationState anim
Definition AppState.h:265
ExportState exporting
Definition AppState.h:268
CharacterState character
Definition AppState.h:266
BrowserState browsers
Definition AppState.h:267
UIState ui
Definition AppState.h:264
Mutable state for the NPC, Item, Mount, ItemSet, and StartOutfit browsers.
Definition AppState.h:186
std::string npcSearchBuf
Definition AppState.h:202
std::vector< size_t > itemBrowseFiltered
Definition AppState.h:208
bool itemBrowseFilterDirty
Definition AppState.h:209
std::vector< MountEntry > mountList
Definition AppState.h:212
std::string itemBrowseSearchBuf
Definition AppState.h:207
std::vector< std::string > creatureModelNames
Definition AppState.h:214
std::vector< StartOutfitEntry > startOutfits
Definition AppState.h:195
bool mountFilterDirty
Definition AppState.h:219
std::string itemSetSearchBuf
Definition AppState.h:190
std::vector< size_t > mountFiltered
Definition AppState.h:218
std::vector< size_t > npcFiltered
Definition AppState.h:203
ParticleColorState pcrState
Definition AppState.h:223
bool npcFilterDirty
Definition AppState.h:204
std::string mountSearchBuf
Definition AppState.h:216
std::vector< size_t > startOutfitFiltered
Definition AppState.h:198
bool mountListBuilt
Definition AppState.h:215
std::vector< GeosetGroupEntry > geosetGroups
Definition AppState.h:222
std::string startOutfitSearchBuf
Definition AppState.h:197
std::vector< GameFile * > creatureModels
Definition AppState.h:213
std::vector< ItemSetEntry > itemSets
Definition AppState.h:188
bool itemSetFilterDirty
Definition AppState.h:192
bool startOutfitsBuilt
Definition AppState.h:196
bool startOutfitFilterDirty
Definition AppState.h:199
std::vector< size_t > itemSetFiltered
Definition AppState.h:191
bool itemSetsBuilt
Definition AppState.h:189
Mutable state for character customisation and equipment editing.
Definition AppState.h:173
std::vector< CustomizationOption > customizationOptions
Definition AppState.h:174
std::string equipSearchBuf
Definition AppState.h:175
int equipSlotLevels[NUM_CHAR_SLOTS]
Definition AppState.h:179
int equipSlotToEdit
Definition AppState.h:176
std::vector< size_t > equipFilteredItems
Definition AppState.h:178
bool equipPopupJustOpened
Definition AppState.h:177
Mutable state for export, import, screenshot, and preset operations.
Definition AppState.h:230
std::vector< std::unique_ptr< ExporterPlugin > > exporters
Definition AppState.h:231
std::string screenshotPath
Definition AppState.h:238
int canvasWidth
Definition AppState.h:241
std::string presetPath
Definition AppState.h:245
std::string screenshotStatus
Definition AppState.h:239
int canvasHeight
Definition AppState.h:242
int selectedExporter
Definition AppState.h:232
std::vector< std::unique_ptr< ImporterPlugin > > importers
Definition AppState.h:249
std::string presetStatus
Definition AppState.h:246
std::string exportStatus
Definition AppState.h:234
std::string exportPath
Definition AppState.h:233
bool useCanvasOverride
Definition AppState.h:240
std::string importUrlBuf
Definition AppState.h:250
std::string importStatus
Definition AppState.h:251
std::vector< char > exportAnimChecked
Definition AppState.h:235
Font entry for the UI font selector.
Definition AppState.h:47
std::string path
Absolute path to the .ttf file.
Definition AppState.h:49
std::string name
Display name of the font.
Definition AppState.h:48
An item set from the ItemSet DB2 table.
A starter outfit from the CharStartOutfit DB2 table.
Mutable state for the async game-data loading thread.
Definition AppState.h:90
std::atomic< bool > loadThreadDone
Definition AppState.h:98
std::atomic< float > loadProgress
Definition AppState.h:94
std::string pathBuf
Definition AppState.h:100
bool showConfigPopup
Definition AppState.h:101
bool isWoWLoaded
Definition AppState.h:91
std::thread loadThread
Definition AppState.h:96
std::atomic< bool > initDB
Definition AppState.h:92
std::atomic< bool > loadThreadSuccess
Definition AppState.h:99
bool loadInProgress
Definition AppState.h:95
int selectedConfig
Definition AppState.h:103
std::mutex loadStatusMutex
Definition AppState.h:97
std::vector< core::GameConfig > pendingConfigs
Definition AppState.h:102
std::string loadStatus
Definition AppState.h:93
A mount entry from the CreatureDisplayInfo DB2 table.
Definition MountsPanel.h:16
Mutable state for the 3D scene: renderer, camera, model tree, and timing.
Definition AppState.h:68
bool isMounted
Definition AppState.h:83
float animTime
Definition AppState.h:75
Renderer renderer
Definition AppState.h:69
std::chrono::steady_clock::time_point lastTick
Definition AppState.h:76
bool isModel
Definition AppState.h:81
bool isChar
Definition AppState.h:82
OrbitCamera camera
Definition AppState.h:70
float fpsAccum
Definition AppState.h:79
float fps
Definition AppState.h:77
ViewportFBO fbo
Definition AppState.h:73
std::unique_ptr< Attachment > root
Definition AppState.h:71
WoWModel * selModel
Definition AppState.h:72
int fpsFrameCount
Definition AppState.h:78
Mutable state for the UI layer: dialogs, fonts, log viewer, folder picker.
Definition AppState.h:110
bool showAboutDialog
Definition AppState.h:112
bool folderPickerNeedsRefresh
Definition AppState.h:142
float dpiScale
Definition AppState.h:137
std::vector< std::filesystem::path > folderPickerEntries
Definition AppState.h:141
bool logAutoScroll
Definition AppState.h:146
bool logNeedsReload
Definition AppState.h:147
bool showLanguageDialog
Definition AppState.h:113
std::unordered_map< std::string, bool > panelOpen
Definition AppState.h:117
bool importPopupJustOpened
Definition AppState.h:132
bool showImportDialog
Definition AppState.h:128
bool fontsDirty
Definition AppState.h:136
bool & panel(const char *name)
Definition AppState.h:121
std::vector< FontEntry > availableFonts
Definition AppState.h:135
bool showFolderPicker
Definition AppState.h:129
std::vector< std::string > logLines
Definition AppState.h:145
std::filesystem::path folderPickerCurrent
Definition AppState.h:140
Simple OpenGL framebuffer object wrapper for off-screen rendering.
Definition ViewportFBO.h:10
Single geoset entry referencing a model geoset by index and id.
A named group of geosets sharing the same mesh id.
Editable state for particle colour replacement (colour IDs 11, 12, 13).
@ NUM_CHAR_SLOTS
Definition wow_enums.h:21