-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAppearanceEditorFrame.h
269 lines (224 loc) · 8.48 KB
/
AppearanceEditorFrame.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#ifndef APPEARANCEEDITORFRAME_H
#define APPEARANCEEDITORFRAME_H
#include <QFrame>
#include "GlContextWidget.h"
#include "zgranny.h"
#include "PakReader.h"
#include "EquipmentHandler.h"
#include "GameCharacter.h"
#include "GenStatsReader.h"
#define TEXT_INVALID " (Invalid)"
namespace Ui {
class AppearanceEditorFrame;
}
typedef struct {
std::string name;
std::string maleValue;
std::string femaleValue;
std::string ¤tValue(bool isMale) {
if (isMale) {
return maleValue;
} else {
return femaleValue;
}
}
void setValue(std::string &value, bool isMale) {
if (isMale) {
maleValue = value;
} else {
femaleValue = value;
}
}
} fieldValue_t;
typedef struct {
ZGrannyScene *scene;
std::vector<GLuint> textures;
MeshAttachmentPoint *attachmentPoint;
} equippedItemData_t;
struct itemColor {
VertexRGB color1;
VertexRGB color2;
VertexRGB color3;
};
class AppearanceChangeCallback {
public:
virtual void onAppearanceChange(LsbObject *oldPlayerCustomDataObject, LsbObject *newPlayerCustomDataObject) = 0;
};
class AppearanceEditorFrame : public QFrame
{
Q_OBJECT
public:
explicit AppearanceEditorFrame(std::wstring gameDataPath, GameCharacter *character, QWidget *parent = 0);
~AppearanceEditorFrame();
void showEvent(QShowEvent *);
void closeEvent(QCloseEvent *);
void keyPressEvent(QKeyEvent* e) {
GlContextWidget *glContext = this->findChild<GlContextWidget *>("glContext");
glContext->keyPressEvent(e);
}
void keyReleaseEvent(QKeyEvent* e) {
GlContextWidget *glContext = this->findChild<GlContextWidget *>("glContext");
glContext->keyReleaseEvent(e);
}
EquipmentHandler *getEquipHandler() const;
void setEquipHandler(EquipmentHandler *value);
GamePakData *getGamePakData() const;
void setGamePakData(GamePakData *value);
void registerAppearanceChangeCallback(AppearanceChangeCallback *appearanceChangeCallback);
private slots:
void on_aiPersonalityNext_clicked();
void on_aiPersonalityPrev_clicked();
void on_voicePrev_clicked();
void on_voiceNext_clicked();
void on_skinColorPrev_clicked();
void on_skinColorNext_clicked();
void on_headPrev_clicked();
void on_headNext_clicked();
void on_hairPrev_clicked();
void on_hairNext_clicked();
void on_hairColorPrev_clicked();
void on_hairColorNext_clicked();
void on_underwearPrev_clicked();
void on_underwearNext_clicked();
void on_cancelButton_clicked();
void on_skinColorPicker_clicked();
void on_hairColorPicker_clicked();
void on_armorToggleButton_clicked();
void on_femaleButton_clicked();
void on_maleButton_clicked();
void on_portraitPrev_clicked();
void on_portraitNext_clicked();
void on_applyButton_clicked();
private:
std::vector<fieldValue_t> portraits;
std::vector<fieldValue_t> aiPersonalities;
std::vector<fieldValue_t> voices;
std::vector<fieldValue_t> skinColors;
std::vector<fieldValue_t> heads;
std::vector<fieldValue_t> headDiffuse;
std::vector<fieldValue_t> headNormal;
std::vector<fieldValue_t> headSpecular;
std::vector<fieldValue_t> headMask;
std::vector<fieldValue_t> hairs;
std::vector<fieldValue_t> hairDiffuse;
std::vector<fieldValue_t> hairNormal;
std::vector<fieldValue_t> hairSpecular;
std::vector<fieldValue_t> hairMask;
std::vector<fieldValue_t> hairColors;
std::vector<fieldValue_t> underwears;
std::vector<fieldValue_t> underwearDiffuse;
std::vector<fieldValue_t> underwearNormal;
std::vector<fieldValue_t> underwearSpecular;
std::vector<fieldValue_t> underwearMask;
std::string textureDiffuseOverride;
std::string textureNormalOverride;
std::string textureSpecularOverride;
std::string textureMaskOverride;
VertexRGB *maleOverrideColor = 0;
VertexRGB *femaleOverrideColor = 0;
std::vector<fieldValue_t> henchHeads;
std::vector<fieldValue_t> henchHeadDiffuse;
std::vector<fieldValue_t> henchHeadNormal;
std::vector<fieldValue_t> henchHeadSpecular;
std::vector<fieldValue_t> henchHeadMask;
std::vector<fieldValue_t> henchHairs;
std::vector<fieldValue_t> henchHairDiffuse;
std::vector<fieldValue_t> henchHairNormal;
std::vector<fieldValue_t> henchHairSpecular;
std::vector<fieldValue_t> henchHairMask;
std::vector<fieldValue_t> henchUnderwears;
std::vector<fieldValue_t> henchUnderwearDiffuse;
std::vector<fieldValue_t> henchUnderwearNormal;
std::vector<fieldValue_t> henchUnderwearSpecular;
std::vector<fieldValue_t> henchUnderwearMask;
//std::vector<fieldValue_t> underwearTextures;
int portraitIdx = 0;
int aiPersonalityIdx = 0;
int voiceIdx = 0;
int skinColorIdx = 0;
int headIdx = 0;
int hairIdx = 0;
int hairColorIdx = 0;
int underwearIdx = 0;
bool hasVisualHelmet;
static bool didInitGlew;
GlShaderProgram *shaderProgram = 0;
GlShaderProgram *equipmentShaderProgram = 0;
Ui::AppearanceEditorFrame *ui;
bool isMale;
bool isHench;
std::wstring gameDataPath;
static bool loadedPaks;
static PakReader mainPak;
static PakReader texturesPak;
static LsbObject *playersTemplateObjects;
EquipmentHandler *equipHandler;
GamePakData *gamePakData;
bool showEquipped = true;
GameCharacter *character;
LsbObject *oldPlayerCustomDataObject = 0;
LsbObject *playerCustomDataObject = 0;
AppearanceChangeCallback *appearanceChangeCallback = 0;
std::string portrait;
VertexRGB *skinColor = 0;
VertexRGB *hairColor = 0;
VertexRGB *underwearColor = 0;
itemColor helmColor;
itemColor breastColor;
itemColor breastColor2;
itemColor breastColor3;
itemColor bootColor;
itemColor bracerColor;
itemColor garmentColor;
static std::vector<StatsContainer *> itemColorStats;
LsbObject *weaponsResourceBankObject = 0;
LsbObject *armorsPlayerResourceBankObject = 0;
LsbObject *playerMaleResourceBankObject = 0;
LsbObject *playerFemaleResourceBankObject = 0;
ZGrannyScene *currentHair = 0;
ZGrannyScene *currentHead = 0;
ZGrannyScene *currentUnderwear = 0;
std::vector<equippedItemData_t> equippedItems;
void cleanup();
void cleanupEquipmentData();
void loadEquipmentData();
void updateAllFields();
void initIndexesToCustomData();
std::string getItemStatText(GameItem *item, std::string statName);
std::string getModStatText(GameItem *item, std::string statName);
std::string getPermBoostStatText(GameItem *item, std::string statName);
std::string getFinalItemStatText(GameItem *item, std::string statName);
unsigned long hexToNumber(std::string hex);
void generateEquipmentModels();
std::string getGR2(LsbObject *resourceBankObject, std::string &visualTemplate);
std::string getTextureFromTextureTemplate(LsbObject *resourceBankObject, std::string &textureTemplate);
bool _getTextureMaps(LsbObject *materialsResourceBankObject, std::string &materialId, std::string &diffuseMap, std::string &normalMap,
std::string &specularMap, std::string &maskMap);
bool getTextureMaps(LsbObject *resourceBankObject, LsbObject *materialsResourceBankObject, std::string &visualTemplate, std::string &diffuseMap, std::string &normalMap,
std::string &specularMap, std::string &maskMap);
bool updateToCurrentModel(ZGrannyScene *¤t, std::vector<fieldValue_t> &models, std::vector<fieldValue_t> &diffuse,
std::vector<fieldValue_t> &normal, std::vector<fieldValue_t> &specular, std::vector<fieldValue_t> &mask,
int index, VertexRGB *foreColor, VertexRGB *backColor, bool useOverride);
void updatePortraitData();
void updateToCurrentPortrait();
void updatePortraitImage();
bool updateToCurrentHead();
bool updateToCurrentHair();
bool updateToCurrentUnderwear();
void updateToCurrentSkinColor();
void updateToCurrentHairColor();
void updateColorData(const char *colorPath, VertexRGB *colorInfo);
void getVisualInfoForItem(LsbObject *equipmentObject, std::string &visualTemplate, std::string &customBodyMaterial, bool& armorLookup);
ZGrannyScene *createModelForItem(GameItem *item, std::vector<GLuint > &textures);
void setup();
void generateFields();
void populateFieldValuesForTemplate(std::string templateId, std::string fieldType, std::string namePrefix,
std::vector<fieldValue_t> &modelFields, std::vector<fieldValue_t> &diffuseFields,
std::vector<fieldValue_t> &normalFields, std::vector<fieldValue_t> &specularFields, std::vector<fieldValue_t> &maskFields, bool isMale);
QLabel *field(const char *fieldName);
void changeFieldValue(const char *labelName, int& idx, std::vector<fieldValue_t> &vec, int increment = 0);
void updateFieldText(QLabel *label, std::vector<fieldValue_t> &updateVector, int index);
void appendFieldText(std::string labelName, std::string text);
void updateObjectValue(const char *labelName, int& idx, std::vector<fieldValue_t> &vec);
};
#endif // APPEARANCEEDITORFRAME_H