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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
|
#include "nw4r/lyt/lyt_window.h"
#include "nw4r/lyt/lyt_common.h"
#include "nw4r/lyt/lyt_layout.h"
#include "nw4r/lyt/lyt_types.h"
namespace nw4r {
namespace lyt {
// TODO: Find Place
struct TextureFlipInfo {
u8 coords[4][2]; // at 0x00
u8 idx[2]; // at 0x8
};
namespace {
// GetTexutreFlipInfo__Q34nw4r3lyt24@unnamed@lyt_window_cpp@FUc
// GetTexutreFlipInfo__24@unnamed@lyt_window_cpp@FUc
// look at TextureFlip enum in lyt_window.h
TextureFlipInfo &GetTextureFlipInfo(u8 textureFlip) {
static TextureFlipInfo flipInfos[6] = {
// TopL TopR BotL BotR idx
{{{0, 0}, {1, 0}, {0, 1}, {1, 1}}, {0, 1}}, // Normal
{{{1, 0}, {0, 0}, {1, 1}, {0, 1}}, {0, 1}}, // Horizontal Flip
{{{0, 1}, {1, 1}, {0, 0}, {1, 0}}, {0, 1}}, // Vertical Flip
{{{0, 1}, {0, 0}, {1, 1}, {1, 0}}, {1, 0}}, // Rotate 90
{{{1, 1}, {0, 1}, {1, 0}, {0, 0}}, {0, 1}}, // Rotate 180
{{{1, 0}, {1, 1}, {0, 0}, {0, 1}}, {1, 0}}, // Rotate 270
};
return flipInfos[textureFlip];
}
/** +----> +x
* LT RT |
* v v v
* +-------+-----------------+-------+ ^ -y
* | ^ | | |
* | t | | | VTX: (x, y)
* | v | | | base = (x, y)
* LB->+-------+-----------------+ + | LT = ( x , y )
* | | | | | RT = ( x + w - r , y )
* | | | | | LB = ( x , y - t )
* |<- l ->| |<- r ->| h RB = ( x + l , y - h + b )
* | | | | | SIZE: (w, h)
* | | RB (at +) | | | LT = ( w - r , t )
* | | V | | | RT = ( r , h - b )
* + +-----------------+-------+ | LB = ( l , h - t )
* | | ^ | | RB = ( w - l , b )
* | | b | |
* | | v | |
* +-------+-----------------+-------+ v
* <--------------- w --------------->
*/
// The below functions were started with
// https://github.com/Treeki/LayoutStudio/blob/be8b56a7f0a8f6ba5456a099b61d032fd8aa2f61/layoutgl/widget.cpp#L162 Really
// helped read the awful Ghidra output xD
// GetLTFrameSize__Q34nw4r3lyt24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2PQ34nw4r3lyt4SizeRCQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt15WindowFrameSize
// GetLTFrameSize__24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2PQ34nw4r3lyt4SizeRCQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt15WindowFrameSize
void GetLTFrameSize(
math::VEC2 *pPt, Size *pSize, const math::VEC2 &basePt, const Size &windSize, const WindowFrameSize &frameSize
) {
*pPt = basePt;
// pPt->x = basePt.x;
// pPt->y = basePt.y;
pSize->width = windSize.width - frameSize.r;
pSize->height = frameSize.t;
// *pSize = Size(windSize.width - frameSize.r, frameSize.t);
}
// GetLTTexCoord__Q34nw4r3lyt24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt4SizeUc
// GetLTTexCoord__24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt4SizeUc
void GetLTTexCoord(math::VEC2 *texCds, const Size &polSize, const Size &texSize, u8 textureFlip) {
const TextureFlipInfo &flipInfo = GetTextureFlipInfo(textureFlip);
int ix = flipInfo.idx[0];
int iy = flipInfo.idx[1];
math::VEC2 tSz(texSize.width, texSize.height);
// clang-format off
// Again no temp vars used here
texCds[TopL][ix] = texCds[BotL][ix] = flipInfo.coords[TopL][ix];
texCds[TopL][iy] = texCds[TopR][iy] = flipInfo.coords[TopL][iy];
texCds[BotR][ix] = texCds[TopR][ix] = flipInfo.coords[TopL][ix] + polSize.width / ((flipInfo.coords[TopR][ix] - flipInfo.coords[TopL][ix]) * tSz[ix]);
texCds[BotR][iy] = texCds[BotL][iy] = flipInfo.coords[TopL][iy] + polSize.height / ((flipInfo.coords[BotL][iy] - flipInfo.coords[TopL][iy]) * tSz[iy]);
// clang-format on
}
// GetRTFrameSize__Q34nw4r3lyt24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2PQ34nw4r3lyt4SizeRCQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt15WindowFrameSize
// GetRTFrameSize__24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2PQ34nw4r3lyt4SizeRCQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt15WindowFrameSize
void GetRTFrameSize(
math::VEC2 *pPt, Size *pSize, const math::VEC2 &basePt, const Size &windSize, const WindowFrameSize &frameSize
) {
*pPt = math::VEC2(basePt.x + windSize.width - frameSize.r, basePt.y);
// pPt->x = basePt.x + windSize.width - frameSize.r;
// pPt->y = basePt.y
// *pSize = Size(frameSize.r, windSize.height - frameSize.b);
pSize->width = frameSize.r;
pSize->height = windSize.height - frameSize.b;
}
// GetRTTexCoord__Q34nw4r3lyt24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt4SizeUc
// GetRTTexCoord__24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt4SizeUc
void GetRTTexCoord(math::VEC2 *texCds, const Size &polSize, const Size &texSize, u8 textureFlip) {
const TextureFlipInfo &flipInfo = GetTextureFlipInfo(textureFlip);
int ix = flipInfo.idx[0];
int iy = flipInfo.idx[1];
math::VEC2 tSz(texSize.width, texSize.height);
// clang-format off
// Again no temp vars used here
texCds[TopR][ix] = texCds[BotR][ix] = flipInfo.coords[TopR][ix];
texCds[TopR][iy] = texCds[TopL][iy] = flipInfo.coords[TopR][iy];
texCds[BotL][ix] = texCds[TopL][ix] = flipInfo.coords[TopR][ix] + polSize.width / ((flipInfo.coords[TopL][ix] - flipInfo.coords[TopR][ix]) * tSz[ix]);
texCds[BotL][iy] = texCds[BotR][iy] = flipInfo.coords[TopR][iy] + polSize.height / ((flipInfo.coords[BotR][iy] - flipInfo.coords[TopR][iy]) * tSz[iy]);
// clang-format on
}
// GetLBFrameSize__Q34nw4r3lyt24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2PQ34nw4r3lyt4SizeRCQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt15WindowFrameSize
// GetLBFrameSize__24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2PQ34nw4r3lyt4SizeRCQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt15WindowFrameSize
void GetLBFrameSize(
math::VEC2 *pPt, Size *pSize, const math::VEC2 &basePt, const Size &windSize, const WindowFrameSize &frameSize
) {
*pPt = math::VEC2(basePt.x, basePt.y - frameSize.t);
// pPt->x = basePt.x;
// pPt->y = basePt.y - frameSize.t;
// *pSize = Size(frameSize.l, windSize.height - frameSize.t);
pSize->width = frameSize.l;
pSize->height = windSize.height - frameSize.t;
}
// GetLBTexCoord__Q34nw4r3lyt24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt4SizeUc
// GetLBTexCoord__24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt4SizeUc
void GetLBTexCoord(math::VEC2 *texCds, const Size &polSize, const Size &texSize, u8 textureFlip) {
const TextureFlipInfo &flipInfo = GetTextureFlipInfo(textureFlip);
int ix = flipInfo.idx[0];
int iy = flipInfo.idx[1];
math::VEC2 tSz(texSize.width, texSize.height);
// clang-format off
// Again no temp vars used here
texCds[BotL][ix] = texCds[TopL][ix] = flipInfo.coords[BotL][ix];
texCds[BotL][iy] = texCds[BotR][iy] = flipInfo.coords[BotL][iy];
texCds[TopR][ix] = texCds[BotR][ix] = flipInfo.coords[BotL][ix] + polSize.width / ((flipInfo.coords[BotR][ix] - flipInfo.coords[BotL][ix]) * tSz[ix]);
texCds[TopR][iy] = texCds[TopL][iy] = flipInfo.coords[BotL][iy] + polSize.height / ((flipInfo.coords[TopL][iy] - flipInfo.coords[BotL][iy]) * tSz[iy]);
// clang-format on
}
// GetRBFrameSize__Q34nw4r3lyt24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2PQ34nw4r3lyt4SizeRCQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt15WindowFrameSize
// GetRBFrameSize__24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2PQ34nw4r3lyt4SizeRCQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt15WindowFrameSize
void GetRBFrameSize(
math::VEC2 *pPt, Size *pSize, const math::VEC2 &basePt, const Size &windSize, const WindowFrameSize &frameSize
) {
*pPt = math::VEC2(basePt.x + frameSize.l, basePt.y - windSize.height + frameSize.b);
// pPt->x = basePt.x + frameSize.l;
// pPt->y = basePt.y - windSize.height + frameSize.b;
// *pSize = Size(windSize.width - frameSize.l, frameSize.b);
pSize->width = windSize.width - frameSize.l;
pSize->height = frameSize.b;
}
// GetRBTexCoord__Q34nw4r3lyt24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt4SizeUc
// GetRBTexCoord__24@unnamed@lyt_window_cpp@FPQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeRCQ34nw4r3lyt4SizeUc
void GetRBTexCoord(math::VEC2 *texCds, const Size &polSize, const Size &texSize, u8 textureFlip) {
const TextureFlipInfo &flipInfo = GetTextureFlipInfo(textureFlip);
int ix = flipInfo.idx[0];
int iy = flipInfo.idx[1];
math::VEC2 tSz(texSize.width, texSize.height);
// clang-format off
texCds[BotR][ix] = texCds[TopR][ix] = flipInfo.coords[BotR][ix];
texCds[BotR][iy] = texCds[BotL][iy] = flipInfo.coords[BotR][iy];
texCds[TopL][ix] = texCds[BotL][ix] = flipInfo.coords[BotR][ix] + polSize.width / ((flipInfo.coords[BotL][ix] - flipInfo.coords[BotR][ix]) * tSz[ix]);
texCds[TopL][iy] = texCds[TopR][iy] = flipInfo.coords[BotR][iy] + polSize.height / ((flipInfo.coords[TopR][iy] - flipInfo.coords[BotR][iy]) * tSz[iy]);
// clang-format on
}
} // namespace
NW4R_UT_RTTI_DEF_DERIVED(Window, Pane);
// __dt__Q44nw4r3lyt6Window5FrameFv
// __ct__Q34nw4r3lyt6WindowFPCQ44nw4r3lyt3res6WindowRCQ34nw4r3lyt11ResBlockSet
Window::Window(const res::Window *pBlock, const ResBlockSet &resBlockSet) : Pane(pBlock), mContent() {
const res::WindowContent *pResContent =
detail::ConvertOffsToPtr<const res::WindowContent>(pBlock, pBlock->contentOffset);
u8 texCoordNum = ut::Min<u8>(pResContent->texCoordNum, 8);
InitContent(texCoordNum);
const u32 *matOffsTbl = detail::ConvertOffsToPtr<u32>(resBlockSet.pMaterialList, sizeof(res::MaterialList));
mContentInflation = pBlock->inflation;
for (int i = 0; i < TEXCOORD_VTX_COUNT; i++) {
mContent.vtxColors[i] = pResContent->vtxCols[i];
}
if (texCoordNum && !mContent.texCoordAry.IsEmpty()) {
mContent.texCoordAry.Copy(&pResContent[1], texCoordNum);
}
const res::Material *pResMaterial =
detail::ConvertOffsToPtr<res::Material>(resBlockSet.pMaterialList, matOffsTbl[pResContent->materialIdx]);
mpMaterial = Layout::NewObj<Material>(pResMaterial, resBlockSet);
mFrameNum = 0;
mFrames = nullptr;
if (pBlock->frameNum) {
InitFrame(pBlock->frameNum);
const u32 *frameOffsetTable = detail::ConvertOffsToPtr<u32>(pBlock, pBlock->frameOffsetTableOffset);
for (int i = 0; i < mFrameNum; i++) {
const res::WindowFrame *pResWindowFrame =
detail::ConvertOffsToPtr<res::WindowFrame>(pBlock, frameOffsetTable[i]);
mFrames[i].textureFlip = pResWindowFrame->textureFlip;
const res::Material *pResMaterial = detail::ConvertOffsToPtr<res::Material>(
resBlockSet.pMaterialList, matOffsTbl[pResWindowFrame->materialIdx]
);
mFrames[i].pMaterial = Layout::NewObj<Material>(pResMaterial, resBlockSet);
}
}
}
// InitContent__Q34nw4r3lyt6WindowFUc
void Window::InitContent(u8 texNum) {
// Guess based of of usual Init Patterns
// not needed to match ¯\_(ツ)_/¯
if (texNum) {
ReserveTexCoord(texNum);
}
}
// InitFrame__Q34nw4r3lyt6WindowFUc
void Window::InitFrame(u8 frameNum) {
mFrameNum = 0;
mFrames = Layout::NewArray<Frame>(frameNum);
if (mFrames) {
mFrameNum = frameNum;
}
}
// __dt__Q44nw4r3lyt6Window7ContentFv
// __dt__Q34nw4r3lyt6WindowFv
Window::~Window() {
Layout::DeleteArray(mFrames, mFrameNum);
if (mpMaterial && !mpMaterial->IsUserAllocated()) {
Layout::DeleteObj(mpMaterial);
mpMaterial = nullptr;
}
mContent.texCoordAry.Free();
}
// ReserveTexCoord__Q34nw4r3lyt6WindowFUc
void Window::ReserveTexCoord(u8 num) {
// Inline Guess
mContent.texCoordAry.Reserve(num);
}
// FindMaterialByName__Q34nw4r3lyt6WindowFPCcb
Material *Window::FindMaterialByName(const char *findName, bool bRecursive) {
if (mpMaterial && detail::EqualsMaterialName(mpMaterial->GetName(), findName)) {
return mpMaterial;
}
for (int i = 0; i < mFrameNum; i++) {
if (detail::EqualsMaterialName(mFrames[i].pMaterial->GetName(), findName)) {
return mFrames[i].pMaterial;
}
}
if (bRecursive) {
for (ut::LinkList<Pane, 4>::Iterator it = mChildList.GetBeginIter(); it != mChildList.GetEndIter(); it++) {
Material *pMat = it->FindMaterialByName(findName, bRecursive);
if (pMat) {
return pMat;
}
}
}
return nullptr;
}
// FindAnimationLink__Q34nw4r3lyt6WindowFPQ34nw4r3lyt13AnimTransform
// AnimationLink *Window::FindAnimationLink(AnimTransform *pAnimTrans) {
// // Not In SS - Part of Vtable in Pane
// }
// SetAnimationEnable__Q34nw4r3lyt6WindowFPQ34nw4r3lyt13AnimTransformbb
// void Window::SetAnimationEnable(AnimTransform *pAnimTrans, bool, bool) {
// // Not In SS - Part of Vtable in Pane
// }
// GetVtxColor__Q34nw4r3lyt6WindowCFUl
ut::Color Window::GetVtxColor(u32 idx) const {
return mContent.vtxColors[idx];
}
// SetVtxColor__Q34nw4r3lyt6WindowFUlQ34nw4r2ut5Color
void Window::SetVtxColor(u32 idx, ut::Color value) {
mContent.vtxColors[idx] = value;
}
// GetVtxColorElement__Q34nw4r3lyt6WindowCFUl
u8 Window::GetVtxColorElement(u32 idx) const {
return detail::GetVtxColorElement(mContent.vtxColors, idx);
}
// SetVtxColorElement__Q34nw4r3lyt6WindowFUlUc
void Window::SetVtxColorElement(u32 idx, u8 value) {
detail::SetVtxColElement(mContent.vtxColors, idx, value);
}
// DrawSelf__Q34nw4r3lyt6WindowFRCQ34nw4r3lyt8DrawInfo
void Window::DrawSelf(const DrawInfo &drawInfo) {
LoadMtx(drawInfo);
WindowFrameSize frameSize = GetFrameSize(mFrameNum, mFrames);
math::VEC2 basePt = GetVtxPos();
DrawContent(basePt, frameSize, mGlbAlpha);
switch (mFrameNum) {
case 1: DrawFrame(basePt, mFrames[0], frameSize, mGlbAlpha); break;
case 4: DrawFrame4(basePt, mFrames, frameSize, mGlbAlpha); break;
case 8: DrawFrame8(basePt, mFrames, frameSize, mGlbAlpha); break;
}
}
// AnimateSelf__Q34nw4r3lyt6WindowFUl
void Window::AnimateSelf(u32 option) {
Pane::AnimateSelf(option);
if (IsVisible() || !(option & 1)) {
for (int i = 0; i < mFrameNum; i++) {
mFrames[i].pMaterial->Animate();
}
}
}
// UnbindAnimationSelf__Q34nw4r3lyt6WindowFPQ34nw4r3lyt13AnimTransform
void Window::UnbindAnimationSelf(AnimTransform *pAnimTrans) {
for (int i = 0; i < mFrameNum; i++) {
mFrames[i].pMaterial->UnbindAnimation(pAnimTrans);
}
Pane::UnbindAnimationSelf(pAnimTrans);
}
// DrawContent__Q34nw4r3lyt6WindowFRCQ34nw4r4math4VEC2RCQ34nw4r3lyt15WindowFrameSizeUc
void Window::DrawContent(const math::VEC2 &basePt, const WindowFrameSize &frameSize, u8 alpha) {
bool bUseVtxCol = detail::IsModulateVertexColor(mContent.vtxColors, alpha);
bUseVtxCol = mpMaterial->SetupGX(bUseVtxCol, alpha);
detail::SetVertexFormat(bUseVtxCol, mContent.texCoordAry.GetSize());
// Why not use temps wtf. only bUseVtxCol is defined in DWARF and I cant find evidence of an inline
detail::DrawQuad(
math::VEC2(basePt.x + frameSize.l - mContentInflation.l, basePt.y - frameSize.t + mContentInflation.t),
Size(
mSize.width - frameSize.l + mContentInflation.l - frameSize.r + mContentInflation.r,
mSize.height - frameSize.t + mContentInflation.t - frameSize.b + mContentInflation.b
),
mContent.texCoordAry.GetSize(), mContent.texCoordAry.GetArray(), bUseVtxCol ? mContent.vtxColors : nullptr,
alpha
);
}
// DrawFrame__Q34nw4r3lyt6WindowFRCQ34nw4r4math4VEC2RCQ44nw4r3lyt6Window5FrameRCQ34nw4r3lyt15WindowFrameSizeUc
void Window::DrawFrame(const math::VEC2 &basePt, const Frame &frame, const WindowFrameSize &frameSize, u8 alpha) {
if (frame.pMaterial->GetTextureNum() != 0) {
bool bUseVtxCol = detail::IsModulateVertexColor(nullptr, alpha);
bUseVtxCol = frame.pMaterial->SetupGX(bUseVtxCol, alpha);
detail::SetVertexFormat(bUseVtxCol, 1);
Size texSize = detail::GetTextureSize(frame.pMaterial, 0);
ut::Color vtxColors[4];
detail::TexCoordData texCds[1];
math::VEC2 polPt;
Size polSize;
// Splits Frame into 4 Corners (repeats frame for each part (texture is quartered))
// Not sure if just edges or Quadrants
// (Top Left Quadrant)
GetLTFrameSize(&polPt, &polSize, basePt, mSize, frameSize);
GetLTTexCoord(texCds[0], polSize, texSize, TEXFLIP_NONE);
detail::DrawQuad(polPt, polSize, 1, texCds, bUseVtxCol ? vtxColors : nullptr, alpha);
// (Top Right Quadrant)
GetRTFrameSize(&polPt, &polSize, basePt, mSize, frameSize);
GetRTTexCoord(texCds[0], polSize, texSize, TEXFLIP_HORIZONTAL);
detail::DrawQuad(polPt, polSize, 1, texCds, bUseVtxCol ? vtxColors : nullptr, alpha);
// (Bottom Right Quadrant)
GetRBFrameSize(&polPt, &polSize, basePt, mSize, frameSize);
GetRBTexCoord(texCds[0], polSize, texSize, TEXFLIP_ROTATE_180);
detail::DrawQuad(polPt, polSize, 1, texCds, bUseVtxCol ? vtxColors : nullptr, alpha);
// (Bottom Left Quadrant)
GetLBFrameSize(&polPt, &polSize, basePt, mSize, frameSize);
GetLBTexCoord(texCds[0], polSize, texSize, TEXFLIP_VERTICAL);
detail::DrawQuad(polPt, polSize, 1, texCds, bUseVtxCol ? vtxColors : nullptr, alpha);
}
}
// DrawFrame4__Q34nw4r3lyt6WindowFRCQ34nw4r4math4VEC2PCQ44nw4r3lyt6Window5FrameRCQ34nw4r3lyt15WindowFrameSizeUc
void Window::DrawFrame4(const math::VEC2 &basePt, const Frame *frame, const WindowFrameSize &frameSize, u8 alpha) {
ut::Color vtxColors[4];
detail::TexCoordData texCds[1];
math::VEC2 polPt;
Size polSize;
bool bModVtxCol = detail::IsModulateVertexColor(nullptr, alpha);
if (frame[0].pMaterial->GetTextureNum() != 0) {
bool bUseVtxCol = frame[0].pMaterial->SetupGX(bModVtxCol, alpha);
GetLTFrameSize(&polPt, &polSize, basePt, mSize, frameSize);
GetLTTexCoord(texCds[0], polSize, detail::GetTextureSize(frame[0].pMaterial, 0), frame[0].textureFlip);
detail::SetVertexFormat(bUseVtxCol, 1);
detail::DrawQuad(polPt, polSize, 1, texCds, bUseVtxCol ? vtxColors : nullptr, alpha);
}
if (frame[1].pMaterial->GetTextureNum() != 0) {
bool bUseVtxCol = frame[1].pMaterial->SetupGX(bModVtxCol, alpha);
GetRTFrameSize(&polPt, &polSize, basePt, mSize, frameSize);
GetRTTexCoord(texCds[0], polSize, detail::GetTextureSize(frame[1].pMaterial, 0), frame[1].textureFlip);
detail::SetVertexFormat(bUseVtxCol, 1);
detail::DrawQuad(polPt, polSize, 1, texCds, bUseVtxCol ? vtxColors : nullptr, alpha);
}
if (frame[3].pMaterial->GetTextureNum() != 0) {
bool bUseVtxCol = frame[3].pMaterial->SetupGX(bModVtxCol, alpha);
GetRBFrameSize(&polPt, &polSize, basePt, mSize, frameSize);
GetRBTexCoord(texCds[0], polSize, detail::GetTextureSize(frame[3].pMaterial, 0), frame[3].textureFlip);
detail::SetVertexFormat(bUseVtxCol, 1);
detail::DrawQuad(polPt, polSize, 1, texCds, bUseVtxCol ? vtxColors : nullptr, alpha);
}
if (frame[2].pMaterial->GetTextureNum() != 0) {
bool bUseVtxCol = frame[2].pMaterial->SetupGX(bModVtxCol, alpha);
GetLBFrameSize(&polPt, &polSize, basePt, mSize, frameSize);
GetLBTexCoord(texCds[0], polSize, detail::GetTextureSize(frame[2].pMaterial, 0), frame[2].textureFlip);
detail::SetVertexFormat(bUseVtxCol, 1);
detail::DrawQuad(polPt, polSize, 1, texCds, bUseVtxCol ? vtxColors : nullptr, alpha);
}
}
/** +----> +x
* LT T RT |
* v v v v
* +-------+-----------------+-------+ ^ -y
* | | ^ | | | VTX: (x, y)
* | | t | | | base = (x, y)
* | | v | | | LT = ( x , y ) | L = ( x , y - t )
* L->+-------+-----------------+-------+ | RT = ( x + w - r , y ) | R = ( x + w - r , y - t )
* | | ^| | | LB = ( y - h + b , y - h + b ) | T = ( x + l , y )
* | | R| | | RB = ( x + w - r , y - h + b ) | B = ( x + l , y - h + b )
* |<- l ->| |<- r ->| h
* | | | | | SIZE: (w, h)
* | |B RB| | | LT = ( l , t ) | L = ( l , h - t - b )
* | |V V| | | RT = ( r , t ) | R = ( r , h - t - b )
* LB->+-------+-----------------+-------+ | LB = ( l , b ) | T = ( w - l - r , t )
* | | ^ | | | RB = ( r , b ) | B = ( w - l - r , b )
* | | b | | |
* | | v | | |
* +-------+-----------------+-------+ v
* <--------------- w --------------->
*/
// DrawFrame8__Q34nw4r3lyt6WindowFRCQ34nw4r4math4VEC2PCQ44nw4r3lyt6Window5FrameRCQ34nw4r3lyt15WindowFrameSizeUc
void Window::DrawFrame8(const math::VEC2 &basePt, const Frame *frame, const WindowFrameSize &frameSize, u8 alpha) {
ut::Color vtxColors[4];
detail::TexCoordData texCds[1];
Size polSize;
bool bModVtxCol = detail::IsModulateVertexColor(nullptr, alpha);
// TOP LEFT
if (frame[0].pMaterial->GetTextureNum() != 0) {
bool bUseVtxCol = frame[0].pMaterial->SetupGX(bModVtxCol, alpha);
polSize = Size(frameSize.l, frameSize.t);
GetLTTexCoord(texCds[0], polSize, detail::GetTextureSize(frame[0].pMaterial, 0), frame[0].textureFlip);
detail::SetVertexFormat(bUseVtxCol, 1);
detail::DrawQuad(basePt, polSize, 1, texCds, bUseVtxCol ? vtxColors : nullptr, alpha);
}
// TOP
if (frame[6].pMaterial->GetTextureNum() != 0) {
bool bUseVtxCol = frame[6].pMaterial->SetupGX(bModVtxCol, alpha);
polSize = Size(mSize.width - frameSize.l - frameSize.r, frameSize.t);
GetLTTexCoord(texCds[0], polSize, detail::GetTextureSize(frame[6].pMaterial, 0), frame[6].textureFlip);
detail::SetVertexFormat(bUseVtxCol, 1);
detail::DrawQuad(
math::VEC2(basePt.x + frameSize.l, basePt.y), polSize, 1, texCds, bUseVtxCol ? vtxColors : nullptr, alpha
);
}
// TOP RIGHT
if (frame[1].pMaterial->GetTextureNum() != 0) {
bool bUseVtxCol = frame[1].pMaterial->SetupGX(bModVtxCol, alpha);
polSize = Size(frameSize.r, frameSize.t);
GetRTTexCoord(texCds[0], polSize, detail::GetTextureSize(frame[1].pMaterial, 0), frame[1].textureFlip);
detail::SetVertexFormat(bUseVtxCol, 1);
detail::DrawQuad(
math::VEC2(basePt.x + mSize.width - frameSize.r, basePt.y), polSize, 1, texCds,
bUseVtxCol ? vtxColors : nullptr, alpha
);
}
// RIGHT
if (frame[5].pMaterial->GetTextureNum() != 0) {
bool bUseVtxCol = frame[5].pMaterial->SetupGX(bModVtxCol, alpha);
polSize = Size(frameSize.r, mSize.height - frameSize.t - frameSize.b);
GetRTTexCoord(texCds[0], polSize, detail::GetTextureSize(frame[5].pMaterial, 0), frame[5].textureFlip);
detail::SetVertexFormat(bUseVtxCol, 1);
detail::DrawQuad(
math::VEC2(basePt.x + mSize.width - frameSize.r, basePt.y - frameSize.t), polSize, 1, texCds,
bUseVtxCol ? vtxColors : nullptr, alpha
);
}
// BOTTOM RIGHT
if (frame[3].pMaterial->GetTextureNum() != 0) {
bool bUseVtxCol = frame[3].pMaterial->SetupGX(bModVtxCol, alpha);
polSize = Size(frameSize.r, frameSize.b);
GetRBTexCoord(texCds[0], polSize, detail::GetTextureSize(frame[3].pMaterial, 0), frame[3].textureFlip);
detail::SetVertexFormat(bUseVtxCol, 1);
detail::DrawQuad(
math::VEC2(basePt.x + mSize.width - frameSize.r, basePt.y - mSize.height + frameSize.b), polSize, 1, texCds,
bUseVtxCol ? vtxColors : nullptr, alpha
);
}
// BOTTOM
if (frame[7].pMaterial->GetTextureNum() != 0) {
bool bUseVtxCol = frame[7].pMaterial->SetupGX(bModVtxCol, alpha);
polSize = Size(mSize.width - frameSize.l - frameSize.r, frameSize.b);
GetRBTexCoord(texCds[0], polSize, detail::GetTextureSize(frame[7].pMaterial, 0), frame[7].textureFlip);
detail::SetVertexFormat(bUseVtxCol, 1);
detail::DrawQuad(
math::VEC2(basePt.x + frameSize.l, basePt.y - mSize.height + frameSize.b), polSize, 1, texCds,
bUseVtxCol ? vtxColors : nullptr, alpha
);
}
// BOTTOM LEFT
if (frame[2].pMaterial->GetTextureNum() != 0) {
bool bUseVtxCol = frame[2].pMaterial->SetupGX(bModVtxCol, alpha);
polSize = Size(frameSize.l, frameSize.b);
GetLBTexCoord(texCds[0], polSize, detail::GetTextureSize(frame[2].pMaterial, 0), frame[2].textureFlip);
detail::SetVertexFormat(bUseVtxCol, 1);
detail::DrawQuad(
math::VEC2(basePt.x, basePt.y - mSize.height + frameSize.b), polSize, 1, texCds,
bUseVtxCol ? vtxColors : nullptr, alpha
);
}
// LEFT
if (frame[4].pMaterial->GetTextureNum() != 0) {
bool bUseVtxCol = frame[4].pMaterial->SetupGX(bModVtxCol, alpha);
polSize = Size(frameSize.l, mSize.height - frameSize.t - frameSize.b);
GetLBTexCoord(texCds[0], polSize, detail::GetTextureSize(frame[4].pMaterial, 0), frame[4].textureFlip);
detail::SetVertexFormat(bUseVtxCol, 1);
detail::DrawQuad(
math::VEC2(basePt.x, basePt.y - frameSize.t), polSize, 1, texCds, bUseVtxCol ? vtxColors : nullptr, alpha
);
}
}
// GetFrameSize__Q34nw4r3lyt6WindowFUcPCQ44nw4r3lyt6Window5Frame
WindowFrameSize Window::GetFrameSize(u8 frameNum, const Frame *frames) {
WindowFrameSize ret = {0.0f, 0.0f, 0.0f, 0.0f};
switch (frameNum) {
case 1: {
Size texSize = detail::GetTextureSize(frames[0].pMaterial, 0);
ret.l = texSize.width;
ret.t = texSize.height;
ret.r = texSize.width;
ret.b = texSize.height;
} break;
case 4:
case 8: {
Size texSize = detail::GetTextureSize(frames[0].pMaterial, 0);
ret.l = texSize.width;
ret.t = texSize.height;
texSize = detail::GetTextureSize(frames[3].pMaterial, 0);
ret.r = texSize.width;
ret.b = texSize.height;
} break;
}
return ret;
}
// GetMaterialNum__Q34nw4r3lyt6WindowCFv
u8 Window::GetMaterialNum() const {
return mFrameNum + 1;
}
// GetMaterial__Q34nw4r3lyt6WindowCFUl
Material *Window::GetMaterial(u32 idx) const {
if (idx == 0) {
return GetContentMaterial();
} else {
return GetFrameMaterial(idx - 1);
}
}
// GetFrameMaterial__Q34nw4r3lyt6WindowCFUl
Material *Window::GetFrameMaterial(u32 frameIdx) const {
if (frameIdx >= mFrameNum) {
return nullptr;
}
return mFrames[frameIdx].pMaterial;
}
// GetContentMaterial__Q34nw4r3lyt6WindowCFv
Material *Window::GetContentMaterial() const {
return reinterpret_cast<const Pane *>(this)->GetMaterial();
}
} // namespace lyt
} // namespace nw4r
// HEADER STUFF
// ConvertOffsToPtr<res::WindowFrame>
// ConvertOffsToPtr<res::WindowContent>
// __as__Q34nw4r3lyt13InflationLRTBFRCQ34nw4r3lyt13InflationLRTB
// texCoordNum .sdata
// flipInfos . data
// ut::Min<uc>
|