WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
TabardDetails.cpp
Go to the documentation of this file.
1#include "TabardDetails.h"
2#include "Game.h"
3#include "WoWDatabase.h"
4#include "DB2Table.h"
5
6#include <set>
7
9 : showCustom(false),
10 iconId(0),
11 iconColor(0),
12 borderId(0),
13 borderColor(0),
14 backgroundId(0),
15 tier(0)
16{
17 if (const DB2Table* tbl = WOWDB.getTable("GuildTabardBackground"))
18 {
19 std::set<int> unique;
20 for (const auto& row : *tbl)
21 unique.insert(static_cast<int>(row.getUInt("Color")));
22 backgrounds.assign(unique.begin(), unique.end());
23 }
24
25 if (const DB2Table* tbl = WOWDB.getTable("GuildTabardEmblem"))
26 {
27 std::set<int> unique;
28 for (const auto& row : *tbl)
29 unique.insert(static_cast<int>(row.getUInt("EmblemID")));
30 icons.assign(unique.begin(), unique.end());
31 }
32
33 if (const DB2Table* tbl = WOWDB.getTable("GuildTabardBorder"))
34 {
35 std::set<int> unique;
36 for (const auto& row : *tbl)
37 unique.insert(static_cast<int>(row.getUInt("BorderID")));
38 borders.assign(unique.begin(), unique.end());
39 }
40}
41
43{
44 if (const DB2Table* tbl = WOWDB.getTable("GuildTabardBackground"))
45 {
46 for (const auto& row : *tbl)
47 {
48 if (static_cast<int>(row.getUInt("Color")) == backgroundId &&
49 static_cast<int>(row.getUInt("Tier")) == tier &&
50 static_cast<int>(row.getUInt("Component")) == slot)
51 return GAMEDIRECTORY.getFile(row.getUInt("FileDataID"));
52 }
53 }
54 return nullptr;
55}
56
58{
59 if (const DB2Table* tbl = WOWDB.getTable("GuildTabardBorder"))
60 {
61 for (const auto& row : *tbl)
62 {
63 if (static_cast<int>(row.getUInt("BorderID")) == borderId &&
64 static_cast<int>(row.getUInt("Color")) == borderColor &&
65 static_cast<int>(row.getUInt("Tier")) == tier &&
66 static_cast<int>(row.getUInt("Component")) == slot)
67 return GAMEDIRECTORY.getFile(row.getUInt("FileDataID"));
68 }
69 }
70 return nullptr;
71}
72
74{
75 if (const DB2Table* tbl = WOWDB.getTable("GuildTabardEmblem"))
76 {
77 for (const auto& row : *tbl)
78 {
79 if (static_cast<int>(row.getUInt("EmblemID")) == iconId &&
80 static_cast<int>(row.getUInt("Color")) == iconColor &&
81 static_cast<int>(row.getUInt("Component")) == slot)
82 return GAMEDIRECTORY.getFile(row.getUInt("FileDataID"));
83 }
84 }
85 return nullptr;
86}
87
89{
90 return static_cast<int>(backgrounds.size());
91}
92
94{
95 return static_cast<int>(icons.size());
96}
97
99{
100 if (const DB2Table* tbl = WOWDB.getTable("GuildTabardEmblem"))
101 {
102 std::set<int> uniqueColors;
103 for (const auto& row : *tbl)
104 if (static_cast<int>(row.getUInt("EmblemID")) == icon)
105 uniqueColors.insert(static_cast<int>(row.getUInt("Color")));
106 return static_cast<int>(uniqueColors.size());
107 }
108 return -1;
109}
110
112{
113 return static_cast<int>(borders.size());
114}
115
117{
118 if (const DB2Table* tbl = WOWDB.getTable("GuildTabardBorder"))
119 {
120 std::set<int> uniqueColors;
121 for (const auto& row : *tbl)
122 if (static_cast<int>(row.getUInt("BorderID")) == border)
123 uniqueColors.insert(static_cast<int>(row.getUInt("Color")));
124 return static_cast<int>(uniqueColors.size());
125 }
126 return -1;
127}
128
129void TabardDetails::save(pugi::xml_node& parentNode)
130{
131 pugi::xml_node node = parentNode.append_child("TabardDetails");
132
133 node.append_child("Icon").append_attribute("value") = iconId;
134 node.append_child("IconColor").append_attribute("value") = iconColor;
135 node.append_child("Border").append_attribute("value") = borderId;
136 node.append_child("BorderColor").append_attribute("value") = borderColor;
137 node.append_child("Background").append_attribute("value") = backgroundId;
138}
139
140void TabardDetails::load(const pugi::xml_node& node)
141{
142 for (pugi::xml_node child = node.first_child(); child; child = child.next_sibling())
143 {
144 const std::string name = child.name();
145
146 if (name == "Icon")
147 iconId = child.attribute("value").as_int();
148 else if (name == "IconColor")
149 iconColor = child.attribute("value").as_int();
150 else if (name == "Border")
151 borderId = child.attribute("value").as_int();
152 else if (name == "BorderColor")
153 borderColor = child.attribute("value").as_int();
154 else if (name == "Background")
155 backgroundId = child.attribute("value").as_int();
156 }
157}
158
160{
161 return std::distance(icons.begin(), std::find(icons.begin(), icons.end(), iconId));
162}
163
165{
166 return iconColor;
167}
168
170{
171 return std::distance(borders.begin(), std::find(borders.begin(), borders.end(), borderId));
172}
173
175{
176 return borderColor;
177}
178
180{
181 return std::distance(backgrounds.begin(), std::find(backgrounds.begin(), backgrounds.end(), backgroundId));
182}
183
185{
186 iconId = icons[icon];
187}
188
190{
191 iconColor = color;
192}
193
195{
196 borderId = borders[border];
197}
198
200{
201 borderColor = color;
202}
203
205{
206 backgroundId = backgrounds[background];
207}
208
210{
211 if (itemid == 69210) // Renowned Guild Tabard
212 tier = 2;
213 else if (itemid == 69209) // Illustrious Guild Tabard
214 tier = 1;
215 else // regular Guild Tabard
216 tier = 0;
217}
218
220{
221 iconId = id;
222}
223
225{
226 borderId = id;
227}
228
230{
231 backgroundId = id;
232}
#define GAMEDIRECTORY
Definition Game.h:9
#define WOWDB
Definition WoWDatabase.h:65
std::string name() const
Definition Component.cpp:52
Provides typed, field-name-based access to records in a WDC DB2 file.
Definition DB2Table.h:50
Abstract base class representing a file within the game data archive.
Definition GameFile.h:12
GameFile * GetBorderTex(int slot)
void setIconId(int id)
GameFile * GetIconTex(int slot)
void setBorderId(int id)
std::vector< int > backgrounds
void setBackgroundId(int id)
void setBackground(int background)
std::vector< int > borders
void setIcon(int icon)
int GetMaxIconColor(int icon)
void setIconColor(int color)
std::vector< int > icons
void setTabardId(int itemid)
void load(const pugi::xml_node &node)
void setBorder(int border)
void setBorderColor(int color)
void save(pugi::xml_node &parentNode)
int GetMaxBorderColor(int border)
GameFile * GetBackgroundTex(int slot)