-
Notifications
You must be signed in to change notification settings - Fork 8
/
ObjectPrefabManager.h
104 lines (79 loc) · 2.83 KB
/
ObjectPrefabManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once
#include "Wrappers.h"
namespace cse
{
namespace objectPrefabs
{
class ObjectPrefabManager;
// all forms are temporary
struct PrefabObjectPreviewData
{
TESPreviewControl* Parent;
TESFormArrayT BaseForms;
TESObjectREFRArrayT References;
NiNode* RootNode;
PrefabObjectPreviewData();
~PrefabObjectPreviewData();
void Attach(TESPreviewControl* To);
void Detach();
};
class PrefabObject
{
friend class ObjectPrefabManager;
enum
{
kState_None = 0, // operation not performed (Serialize/Deserialize)
kState_Good, // operation completed successfully
kState_Bad, // errors encountered during operation/operation couldn't be performed
};
TESFileWrapper* SourceFile;
ObjectRefCollectionSerializer* Serializer;
ObjectRefCollectionInstantiator* Instantiator;
UInt8 SerializationState;
UInt8 DeserializationState;
std::string FileName;
std::string FilePath; // as passed to the c'tor
void SetInDialog(HWND Dialog);
UInt8 Deserialize(bool Force = false); // returns the state
UInt8 Serialize(bgsee::FormListT& Forms, bool Force = false);
public:
PrefabObject(const char* SourceFilePath, const char* RepositoryPath, bool OverwriteExisting);
~PrefabObject();
PrefabObjectPreviewData* GeneratePreviewData(TESPreviewControl* PreviewControl); // caller takes ownership of pointer
bool Instantiate();
};
class ObjectPrefabManager
{
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static int CALLBACK SortComparator(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
typedef std::vector<std::unique_ptr<PrefabObject>> PrefabObjectArrayT;
static const bgsee::ResourceLocation kRepositoryPath;
static const char* kPrefabFileExtension;
PrefabObjectArrayT LoadedPrefabs;
PrefabObject* CurrentSelection;
PrefabObjectPreviewData* PreviewData;
HWND MainDialog;
UInt32 TimeCounter;
BaseExtraList* ExtraDataList;
TESPreviewControl* Renderer;
bool RefreshingList;
void InitializeDialog(HWND Dialog);
void DeinitializeDialog(HWND Dialog);
void RefreshPrefabList();
void LoadPrefabsInDirectory(const char* DirectoryPath);
void ReloadPrefabs();
void NewPrefab();
void InstatiateSelection();
void RemoveSelection();
bool ShowFileDialog(bool Save, std::string& OutPath, std::string& OutName);
bool GetExistingPrefab(const char* FilePath, PrefabObject** Out);
bool RemoveLoadedPrefab(PrefabObject* Data);
public:
ObjectPrefabManager();
~ObjectPrefabManager();
void Show();
void Close();
static ObjectPrefabManager Instance;
};
}
}