-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathScanMenu.cpp
257 lines (212 loc) · 6.55 KB
/
ScanMenu.cpp
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
#include "stdafx.h"
#include "ScanMenu.h"
#include "ResourceIcon.h"
/// AUTOGENERATED METHODS ///
int ScanMenu::AddRef() {
return Simulator::cStrategy::AddRef();
}
int ScanMenu::Release() {
return Simulator::cStrategy::Release();
}
const char* ScanMenu::GetName() const {
return "RattlerSpore::ScanMenu";
}
bool ScanMenu::Write(Simulator::ISerializerStream* stream)
{
return Simulator::ClassSerializer(this, ATTRIBUTES).Write(stream);
}
bool ScanMenu::Read(Simulator::ISerializerStream* stream)
{
return Simulator::ClassSerializer(this, ATTRIBUTES).Read(stream);
}
/// END OF AUTOGENERATED METHODS ///
////////////////////////////////////
Simulator::Attribute ScanMenu::ATTRIBUTES[] = {
// Add more attributes here
// This one must always be at the end
Simulator::Attribute()
};
void ScanMenu::Initialize() {
counter = 0;
close = false;
mpUIlayout = nullptr;
sInstance = this;
}
void ScanMenu::Dispose() {
}
void ScanMenu::Update(int deltaTime, int deltaGameTime) {
if (Simulator::IsSpaceGame()) //If we're in the space stage... (adventures do not count)
{
if (mWindowOffset != 0 && mpUIlayout)
{
auto window = mpUIlayout->FindWindowByID(0xFFFFFFFF, false);
float offset2 = (((mWindowOffset * -1) + 1) / 8); //max((((windowOffset * -1) + 1) / 8), 1.0)
if (close) {
counter++;
if (counter == 100) {
mWindowOffset = -2;
}
if (counter > 100) {
offset2 = ((mWindowOffset) / 8); //max((((windowOffset * -1) + 1) / 8), 1.0)
}
}
mWindowOffset = mWindowOffset + offset2;
//TODO: FIX THIS CRAP!!!!!
UTFWin::IWindow* parentWindow = window->GetParent();
Math::Rectangle rec = parentWindow->GetArea();
//window->SetArea(Math::Rectangle(rec.right / 2 - (700 / 2), (rec.bottom / 2 - (400 / 2)) + mWindowOffset, rec.right / 2 + (700 / 2), (rec.bottom / 2 + (400 / 2)) + mWindowOffset));
window->SetArea(Math::Rectangle((rec.right / 2 - (700 / 2)) + (rec.right / 4), (rec.bottom / 2 - (400 / 2)) + mWindowOffset + rec.top - 400, (rec.right / 2 + (700 / 2)) + (rec.right / 4), (rec.bottom / 2 + (400 / 2)) + mWindowOffset + rec.top - 400));
if (mWindowOffset <= -600 && close) {
DeleteScan(true);
}
}
}
else
{
if (mpUIlayout)
{
CloseScan(false);
}
}
}
bool ScanMenu::WriteToXML(Simulator::XmlSerializer* writexml)
{
return false;
}
bool ScanMenu::AddResources(vector<uint32_t> resources)
{
auto resourcesWindow = mpUIlayout->FindWindowByID(id("cat"), true);
if (resourcesWindow) {
vector<UTFWin::IWindow*> shin;
for (UTFWin::IWindow* child : resourcesWindow->children()) {
if (child) {
//resourcesWindow->RemoveWindow(child);
shin.push_back(child);
}
}
while (shin.size() != 0) {
resourcesWindow->RemoveWindow(shin.back());
shin.pop_back();
}
}
int i = 0;
for each (uint32_t zurg in resources)
{
App::ConsolePrintF("%d", zurg);
if (true)
{
UTFWin::UILayout* layout = new UTFWin::UILayout();
layout->LoadByID(id("recipeslot"));
layout->SetParentWindow(resourcesWindow);
layout->SetVisible(true);
if (auto itemWindow = layout->FindWindowByID(id("crapingslot")))
{
auto icon = itemWindow->FindWindowByID(id("icon"));
ResourceKey imgKey;
PropertyListPtr sillyPropList;
if (PropManager.GetPropertyList(zurg, 0x034d97fa, sillyPropList))
{
App::ConsolePrintF("Yay!");
if (App::Property::GetKey(sillyPropList.get(), 0x3068D95C, imgKey))
{
App::ConsolePrintF("Wahoo!");
ImagePtr img;
if (Image::GetImage(imgKey, img))
{
App::ConsolePrintF("Yipee!");
ImageDrawable* drawable = new ImageDrawable();
drawable->SetImage(img.get());
uint32_t rColor;
if (App::Property::GetUInt32(sillyPropList.get(), 0x058CBB75, rColor)) {
App::ConsolePrintF("ZurgTastic!");
rColor = rColor + 4278190080;
Color ColR = Color::Color(rColor);
icon->SetShadeColor(ColR);
// LocalizedString westyorkshire;
// App::Property::GetText(sillyPropList.get(), 0x3068D95D, westyorkshire);
// itemWindow->FindWindowByID(0x03754e6c)->SetCaption(westyorkshire.GetText());
}
// icon->SetShadeColor(Color::RED); Use later when setting recipe node colors.
icon->SetDrawable(drawable);
}
}
}
itemWindow->SetFlag(UTFWin::WindowFlags::kWinFlagAlwaysInFront, true);
itemWindow->FindWindowByID(id("zurgtastic"))->AddWinProc(new ResourceIcon(itemWindow, zurg, 1));
itemWindow->SetLayoutLocation((60 * (i % 6)) + (8 * ((i % 6) + 1)), div((i), 6).quot * 80);
mapUI.push_back(itemWindow);
}
i++;
}
}
return false;
}
bool ScanMenu::OpenScan(bool sex)
{
DeleteScan(true);
if (!mpUIlayout)
{
mpUIlayout = new UTFWin::UILayout();
}
counter = 0;
close = false;
if (mpUIlayout->LoadByID(id("ScanMenu")))
{
//mpUIlayout->LoadByID(id("FabMenu"));
mpUIlayout->SetVisible(true);
mpUIlayout->SetParentWindow(WindowManager.GetMainWindow());
auto window = mpUIlayout->FindWindowByID(0xFFFFFFFF, false);
window->SetSize(1601.0F, 802.0F);
WindowManager.GetMainWindow()->SendToBack(mpUIlayout->GetContainerWindow());
Math::Rectangle rec = window->GetParent()->GetArea();
if (sex)
{
mWindowOffset = (rec.top / 2 + (400 / 2) * -1);
}
else
{
mWindowOffset = 0;
}
window->SetArea(Math::Rectangle((rec.right / 2 - (700 / 2)) + (rec.right / 4), (rec.bottom / 2 - (400 / 2)) + mWindowOffset + rec.top - 200, (rec.right / 2 + (700 / 2)) + (rec.right / 4), (rec.bottom / 2 + (400 / 2)) + mWindowOffset + rec.top - 200));
//window->SetArea(Math::Rectangle((rec.right / 2 - (700 / 2))+(rec.right/4), (rec.bottom / 2 - (400 / 2)) + mWindowOffset + (rec.bottom / 2), (rec.right / 2 + (700 / 2)) + (rec.right / 4), (rec.bottom / 2 + (400 / 2)) + mWindowOffset + (rec.bottom / 2)));
auto menuWindow = mpUIlayout->FindWindowByID(id("ScanMenu"));
layout.SetParentWindow(window);
return true;
}
return false;
}
ScanMenu* ScanMenu::Get()
{
return sInstance;
}
bool ScanMenu::CloseScan(bool sex) {
if (mpUIlayout)
{
counter = 0;
close = true;
//mWindowOffset = -2;
return true;
}
return false;
}
bool ScanMenu::DeleteScan(bool sex)
{ //App::ConsolePrintF("mario");
if (mpUIlayout)
{
counter = 0;
close = false;
mpUIlayout->SetVisible(false);
//App::ConsolePrintF("le test");
WindowManager.GetMainWindow()->RemoveWindow(mpUIlayout->FindWindowByID(0xFFFFFFFF, false));
auto Delete(mpUIlayout);
mpUIlayout = nullptr;
return true;
}
//App::ConsolePrintF("brug");
return false;
}
bool ScanMenu::getClosed()
{
return close;
}
ScanMenu* ScanMenu::sInstance;