comparison GUIWindow.cpp @ 0:8b8875f5b359

Initial commit
author Nomad
date Fri, 05 Oct 2012 16:07:14 +0200
parents
children 2ca04ccb612a
comparison
equal deleted inserted replaced
-1:000000000000 0:8b8875f5b359
1 #include "GUIWindow.h"
2 #include "GUIButton.h"
3 #include "GUIFont.h"
4 #include "Party.h"
5 #include "LOD.h"
6 #include "Keyboard.h"
7 #include "IndoorCamera.h"
8 #include "Math.h"
9 #include "VideoPlayer.h"
10 #include "Allocator.h"
11 #include "MapInfo.h"
12 #include "Time.h"
13 #include "AudioPlayer.h"
14 #include "Mouse.h"
15 #include "Viewport.h"
16 #include "Render.h"
17 #include "PlayerFrameTable.h"
18 #include "stru179.h"
19 #include "SaveLoad.h"
20 #include "FactionTable.h"
21 #include "StorylineTextTable.h"
22 #include "Events2D.h"
23
24
25 #include "mm7_data.h"
26
27
28
29
30 int pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[1]; // idb
31 struct GUIWindow *pWindow_Credits;
32 struct GUIWindow pWindowList[20];
33
34 struct GUIMessageQueue *pMessageQueue_50CBD0 = new GUIMessageQueue;
35
36
37 //----- (004356B9) --------------------------------------------------------
38 void GUIMessageQueue::PopMessage(enum UIMessageType *pType, int *pParam, int *a4)
39 {
40 signed int v4; // edx@1
41 GUIMessage *v5; // eax@2
42
43 v4 = 0;
44 if ( this->uNumMessages )
45 {
46 v5 = this->pMessages;
47 *pType = this->pMessages[0].eType;
48 *pParam = this->pMessages[0].param;
49 *a4 = this->pMessages[0].field_8;
50 if ( (signed int)(this->uNumMessages - 1) > 0 )
51 {
52 do
53 {
54 v5->eType = v5[1].eType;
55 v5->param = v5[1].param;
56 v5->field_8 = v5[1].field_8;
57 ++v4;
58 ++v5;
59 }
60 while ( v4 < (signed int)(this->uNumMessages - 1) );
61 }
62 --this->uNumMessages;
63 }
64 }
65
66
67
68 //----- (0041D73D) --------------------------------------------------------
69 char GUIWindow::_41D73D_draw_buff_tooltip()
70 {
71 GUIFont *v1; // esi@1
72 GUIWindow *v2; // edi@1
73 SpellBuff *v3; // eax@1
74 unsigned int v4; // eax@5
75 int v5; // ecx@5
76 unsigned int v6; // eax@5
77 unsigned int v7; // ecx@5
78 char *v8; // ebx@7
79 unsigned int v9; // eax@8
80 unsigned int v10; // ecx@8
81 __int64 v11; // ST28_8@11
82 int v12; // esi@11
83 const char *v13; // ST0C_4@11
84 unsigned int v14; // eax@11
85 char **v16; // [sp+14h] [bp-10h]@7
86 GUIFont *a2; // [sp+18h] [bp-Ch]@1
87 SpellBuff *v18; // [sp+1Ch] [bp-8h]@7
88 int v19; // [sp+20h] [bp-4h]@1
89 int v20; // [sp+20h] [bp-4h]@7
90
91 v1 = pFontComic;
92 v2 = this;
93 a2 = pFontComic;
94 v19 = 0;
95 v3 = pParty->pPartyBuffs;
96 do
97 {
98 if ( (signed __int64)v3->uExpireTime > 0 )
99 ++v19;
100 ++v3;
101 }
102 while ( (signed int)v3 < (signed int)pParty->pPlayers );
103 v4 = LOBYTE(pFontArrus->uFontHeight) + 72;
104 this->uFrameHeight = v4;
105 v5 = v4 + (v19 - 1) * LOBYTE(pFontArrus->uFontHeight);
106 v6 = v2->uFrameWidth;
107 v2->uFrameHeight = v5;
108 v7 = v2->uFrameHeight;
109 v2->uFrameZ = v6 + v2->uFrameX - 1;
110 v2->uFrameW = v2->uFrameY + v7 - 1;
111 v2->_415551(0);
112 v2->DrawText2(pFontArrus, 0, 0xCu, 0, pGlobalTXT_LocalizationStrings[451], 3u);
113 if ( !v19 )
114 v2->DrawText2(v1, 0, 0x28u, 0, pGlobalTXT_LocalizationStrings[153], 3u);
115 v20 = 0;
116 GetTickCount();
117 v8 = &_4E2B21_buff_spell_tooltip_colors[1];
118 v16 = aSpellNames;
119 v18 = pParty->pPartyBuffs;
120 do
121 {
122 v9 = LODWORD(v18->uExpireTime);
123 v10 = HIDWORD(v18->uExpireTime);
124 if ( (v10 & 0x80000000u) == 0 && ((signed int)v10 > 0 || v9) )
125 {
126 v11 = __PAIR__(v10, v9) - pParty->uTimePlayed;
127 v12 = v20 * LOBYTE(v1->uFontHeight) + 40;
128 v13 = *v16;
129 ++v20;
130 v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(
131 (unsigned __int8)*(v8 - 1),
132 (unsigned __int8)*v8,
133 (unsigned __int8)v8[1]);
134 v2->DrawText(a2, 52, v12, v14, v13, 0, 0, 0);
135 LOBYTE(v9) = sub_41D20D_buff_remaining_time_string(v12, v2, v11, a2);
136 v1 = a2;
137 }
138 ++v18;
139 ++v16;
140 v8 += 3;
141 }
142 while ( (signed int)v18 < (signed int)pParty->pPlayers );
143 return v9;
144 }
145
146
147 //----- (0041D3B7) --------------------------------------------------------
148 char GUIWindow::_41D3B7()
149 {
150 GUIWindow *v1; // edi@1
151 Player *pPlayer; // esi@1
152 int v3; // ecx@1
153 SpellBuff *v4; // eax@1
154 signed int v5; // ebx@1
155 int v6; // eax@5
156 int v7; // ebx@5
157 unsigned int v8; // ecx@5
158 int v9; // ebx@5
159 unsigned int v10; // eax@5
160 int v11; // eax@5
161 unsigned int v12; // ecx@5
162 Texture *v13; // eax@6
163 unsigned int v14; // eax@12
164 PlayerFrame *v15; // eax@12
165 unsigned int v16; // eax@15
166 signed int v17; // ST28_4@15
167 int v18; // ST24_4@15
168 signed int v19; // eax@15
169 unsigned int v20; // eax@15
170 int v21; // ST28_4@15
171 int v22; // ST24_4@15
172 int v23; // eax@15
173 unsigned int v24; // eax@15
174 unsigned int v25; // eax@15
175 char *v26; // ST28_4@15
176 signed int v27; // eax@15
177 unsigned __int8 v28; // al@15
178 char *v29; // eax@16
179 unsigned int v30; // esi@18
180 SpellBuff *v31; // edx@18
181 char *v32; // edi@18
182 signed int v33; // ecx@19
183 unsigned int v34; // eax@19
184 __int64 v35; // ST38_8@22
185 int v36; // esi@22
186 const char *v37; // ST1C_4@22
187 unsigned int v38; // eax@22
188 char *v39; // eax@24
189 SpellBuff *v41; // [sp+14h] [bp-14h]@1
190 GUIFont *a2; // [sp+18h] [bp-10h]@1
191 GUIWindow *a1; // [sp+1Ch] [bp-Ch]@1
192 signed int uFramesetID; // [sp+20h] [bp-8h]@9
193 int uFramesetIDa; // [sp+20h] [bp-8h]@18
194 const char **v46; // [sp+24h] [bp-4h]@18
195
196 v1 = this;
197 a2 = pFontComic;
198 pPlayer = &pParty->pPlayers[(unsigned int)this->ptr_1C];
199 a1 = this;
200 v3 = 0;
201 v4 = pPlayer->pPlayerBuffs;
202 v5 = 24;
203 v41 = pPlayer->pPlayerBuffs;
204 do
205 {
206 if ( (signed __int64)v4->uExpireTime > 0 )
207 ++v3;
208 ++v4;
209 --v5;
210 }
211 while ( v5 );
212 v6 = LOBYTE(pFontArrus->uFontHeight) + 162;
213 v1->uFrameHeight = v6;
214 v7 = (v3 - 1) * LOBYTE(pFontArrus->uFontHeight);
215 v8 = v1->uFrameX;
216 v9 = v6 + v7;
217 v10 = v1->uFrameWidth;
218 v1->uFrameHeight = v9;
219 v11 = v10 + v8 - 1;
220 v12 = v1->uFrameY;
221 v1->uFrameZ = v11;
222 v1->uFrameW = v9 + v12 - 1;
223 v1->_415551(0);
224 if ( pPlayer->pConditions[16] )
225 {
226 v13 = pTexture_PlayerFaceEradicated;
227 }
228 else
229 {
230 if ( pPlayer->pConditions[14] )
231 {
232 v13 = pTexture_PlayerFaceDead;
233 }
234 else
235 {
236 uFramesetID = pPlayerFrameTable->GetFrameIdBy_field0(pPlayer->uExpressionID);
237 if ( !uFramesetID )
238 uFramesetID = 1;
239 if ( pPlayer->uExpressionID == 21 )
240 {
241 v15 = pPlayerFrameTable->GetFrameBy_y(
242 &pPlayer->field_1AA8,
243 &pPlayer->field_1AA4,
244 pMiscTimer->uTimeElapsed);
245 }
246 else
247 {
248 v14 = pMiscTimer->Time();
249 v15 = pPlayerFrameTable->GetFrameBy_x(uFramesetID, v14);
250 }
251 pPlayer->field_1AA2 = v15->uTextureID - 1;
252 v13 = (Texture *)A74CEC_player_faces_minus1_indexing[v15->uTextureID + 56 * (unsigned int)v1->ptr_1C];
253 }
254 }
255 pRenderer->DrawTextureTransparent(v1->uFrameX + 24, v1->uFrameY + 24, v13);
256 v16 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
257 sprintfex(pTmpBuf, format_4E2DC8, v16);
258 sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->uClass]);
259 strcat(pTmpBuf, pTmpBuf2);
260 strcat(pTmpBuf, string_4E3294);
261 v17 = pPlayer->GetMaxHealth();
262 v18 = pPlayer->sHealth;
263 v19 = pPlayer->GetMaxHealth();
264 v20 = sub_4178FE(pPlayer->sHealth, v19);
265 sprintfex(pTmpBuf2, "%s : ", pGlobalTXT_LocalizationStrings[108], v20, v18, v17);
266 strcat(pTmpBuf, pTmpBuf2);
267 v21 = pPlayer->GetMaxMana();
268 v22 = pPlayer->sMana;
269 v23 = pPlayer->GetMaxMana();
270 v24 = sub_4178FE(pPlayer->sMana, v23);
271 sprintfex(pTmpBuf2, "%s : ", pGlobalTXT_LocalizationStrings[212], v24, v22, v21);
272 strcat(pTmpBuf, pTmpBuf2);
273 v25 = pPlayer->GetMajorConditionrIdx();
274 v26 = aCharacterConditionNames[v25];
275 v27 = GetConditionDrawColor(v25);
276 sprintfex(pTmpBuf2, "%s: ", pGlobalTXT_LocalizationStrings[47], v27, v26);
277 strcat(pTmpBuf, pTmpBuf2);
278 v28 = pPlayer->uQuickSpell;
279 if ( v28 )
280 v29 = pSpellStats->pInfos[v28].pShortName;
281 else
282 v29 = pGlobalTXT_LocalizationStrings[153];
283 sprintfex(pTmpBuf2, "%s: %s", pGlobalTXT_LocalizationStrings[172], v29);
284 strcat(pTmpBuf, pTmpBuf2);
285 v30 = 0;
286 a1->DrawText(pFontArrus, 120, 22, 0, pTmpBuf, 0, 0, 0);
287 v31 = v41;
288 uFramesetIDa = 0;
289 v32 = &_4E2AD8_ui_colors[1];
290 v46 = (const char **)&aSpellNames[20];
291 do
292 {
293 v33 = HIDWORD(v31->uExpireTime);
294 v34 = LODWORD(v31->uExpireTime);
295 if ( v33 >= (signed int)v30 && (v33 > (signed int)v30 || v34 > v30) )
296 {
297 v35 = __PAIR__(v33, v34) - pParty->uTimePlayed;
298 v36 = uFramesetIDa++ * LOBYTE(a2->uFontHeight) + 134;
299 v37 = *v46;
300 v38 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(
301 (unsigned __int8)*(v32 - 1),
302 (unsigned __int8)*v32,
303 (unsigned __int8)v32[1]);
304 a1->DrawText(a2, 52, v36, v38, v37, 0, 0, 0);
305 sub_41D20D_buff_remaining_time_string(v36, a1, v35, a2);
306 v31 = v41;
307 v30 = 0;
308 }
309 ++v46;
310 ++v31;
311 v32 += 3;
312 v41 = v31;
313 }
314 while ( (signed int)v46 < (signed int)&dword_506978 );
315 v39 = nullstring;
316 if ( uFramesetIDa == v30 )
317 v39 = pGlobalTXT_LocalizationStrings[153];
318 sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[450], v39);
319 return a1->DrawText(pFontArrus, 14, 114, v30, pTmpBuf, v30, v30, v30);
320 }
321
322 //----- (0041D08F) --------------------------------------------------------
323 void GUIWindow::_41D08F(int a2, int a3, int a4, int a5)
324 {
325 if ( a2 )
326 {
327 this->field_28 = a2;
328 this->field_30 = a3;
329 this->field_34 = a4;
330 this->field_2C_focus_id = a5;
331 this->field_38 = a5;
332 this->field_44 = 1;
333 }
334 else
335 {
336 this->field_28 = 0;
337 this->field_30 = a3;
338 this->field_34 = a4;
339 this->field_2C_focus_id = 0;
340 this->field_38 = 0;
341 this->field_44 = 0;
342 }
343 }
344
345
346 //----- (0041C26A) --------------------------------------------------------
347 void GUIWindow::Release()
348 {
349 GUIWindow *v1; // esi@1
350 unsigned int v2; // eax@2
351 int v3; // eax@5
352 int v4; // eax@6
353 int v5; // eax@14
354 int v6; // eax@15
355 int i; // edi@20
356 GUIButton *v8; // eax@26
357 GUIButton *v9; // edi@27
358 int v10; // esi@28
359 int v11; // ecx@28
360 int v12; // edx@29
361
362 v1 = this;
363 if ( !this )
364 return;
365 v2 = this->uWindowType;
366 if ( (signed int)v2 > 18 )
367 {
368 v5 = v2 - 19;
369 if ( !v5 )
370 {
371 pIcons_LOD->_40F9C5();
372 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = dword_506978;
373 pKeyActionMap->_459ED1(3);
374 goto LABEL_26;
375 }
376 v6 = v5 - 6;
377 if ( !v6 )
378 {
379 for ( i = 0; i < uNumDialogueNPCPortraits; ++i )
380 pDialogueNPCPortraits[i]->Release();
381 uNumDialogueNPCPortraits = 0;
382 pTexture_Dialogue_Background->Release();
383
384 pIcons_LOD->_40F9C5();
385 pIcons_LOD->_4114F2();
386 dword_5C35D4 = 0;
387 if ( bFlipOnExit )
388 {
389 pIndoorCamera->sRotationY = (stru_5C6E00->uIntegerDoublePi - 1) & (stru_5C6E00->uIntegerPi
390 + pIndoorCamera->sRotationY);
391 pParty->sRotationY = pIndoorCamera->sRotationY;
392 }
393 pParty->uFlags |= 2u;
394 goto LABEL_26;
395 }
396 if ( v6 == 1 )
397 {
398 pVideoPlayer->Unload();
399 goto LABEL_18;
400 }
401 }
402 else
403 {
404 if ( v2 == 18 )
405 {
406 sub_41140B();
407 sub_411473();
408 }
409 else
410 {
411 if ( !v2 )
412 return;
413 v3 = v2 - 9;
414 if ( v3 )
415 {
416 v4 = v3 - 1;
417 if ( !v4 )
418 {
419 if ( !dword_591084 )
420 pDialogueNPCPortraits[0]->Release();
421 uNumDialogueNPCPortraits = 0;
422 pTexture_Dialogue_Background->Release();
423
424 pIcons_LOD->_40F9C5();
425 goto LABEL_19;
426 }
427 if ( v4 != 7 )
428 goto LABEL_26;
429 LABEL_18:
430 pTexture_outside->Release();
431 pTexture_Dialogue_Background->Release();
432 pIcons_LOD->_40F9C5();
433 LABEL_19:
434 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = dword_506978;
435 goto LABEL_26;
436 }
437 OnCloseSpellook();
438 }
439 }
440 LABEL_26:
441 v8 = v1->pControlsHead;
442 if ( v8 )
443 {
444 do
445 {
446 v9 = v8->pNext;
447 pAllocator->FreeChunk(v8);
448 v8 = v9;
449 }
450 while ( v9 );
451 }
452 v1->pControlsHead = 0;
453 v1->pControlsTail = 0;
454 v1->uNumControls = 0;
455 v1->uWindowType = 0;
456 v10 = v1->field_3C;
457 v11 = uNumVisibleWindows;
458 while ( v10 < v11 )
459 {
460 v12 = pVisibleWindowsIdxs[v10 + 1];
461 pVisibleWindowsIdxs[v10] = v12;
462 --*((int *)&stru_506F20.field_18 + 21 * v12);
463 ++v10;
464 }
465 pVisibleWindowsIdxs[v11] = 0;
466 uNumVisibleWindows = v11 - 1;
467 }
468
469
470
471
472
473
474 //----- (0041CD3B) --------------------------------------------------------
475 GUIButton *GUIWindow::GetControl(unsigned int uID)
476 {
477 GUIButton *result; // eax@1
478 unsigned int v3; // ecx@1
479
480 result = this->pControlsHead;
481 v3 = uID;
482 if ( (signed int)uID > 0 )
483 {
484 do
485 {
486 result = result->pNext;
487 --v3;
488 }
489 while ( v3 );
490 }
491 return result;
492 }
493
494 //----- (00411BFC) --------------------------------------------------------
495 void GUIWindow::InitializeBookView()
496 {
497 GUIWindow *v1; // ebp@1
498 signed int v2; // ecx@8
499 __int64 *v3; // ebp@9
500 char *v4; // ecx@10
501 char *v5; // eax@12
502 int v6; // eax@12
503 __int64 v7; // qax@12
504 unsigned int v8; // esi@12
505 GUIButton *v9; // eax@19
506 signed int v10; // esi@19
507 int v11; // eax@24
508 int v12; // eax@27
509 int i; // esi@28
510 char *v14; // ebp@29
511 int v15; // eax@31
512 unsigned int v16; // esi@35
513 Player *v17; // esi@38
514 unsigned __int16 v18; // ax@38
515 unsigned int v19; // edi@43
516 unsigned int v20; // edi@45
517 void *v21; // esi@45
518 char *v22; // [sp+10h] [bp-5Ch]@9
519 signed int v23; // [sp+10h] [bp-5Ch]@38
520 int v24; // [sp+14h] [bp-58h]@9
521 char *v25; // [sp+14h] [bp-58h]@21
522 GUIWindow v26; // [sp+18h] [bp-54h]@8
523
524 v1 = this;
525 pAudioPlayer->StopChannels(-1, -1);
526 InitializeBookFonts();
527 v1->CreateButton(0x1DBu, 0x1BDu, 0x9Eu, 0x22u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], 0);
528 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 3;
529 dword_506524 = 0;
530 dword_506528 = 0;
531 dword_50651C = 0;
532 dword_506520 = 0;
533 if ( v1->ptr_1C == (void *)177 )
534 {
535 byte_506360 = 0;
536 pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("lb_bordr", TEXTURE_16BIT_PALETTE)];
537 pTexture_LloydBeacons[0] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
538 pTexture_50635C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
539 pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
540 pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
541 pBtn_Book_1 = v1->CreateButton(
542 415u,
543 13u,
544 39u,
545 36u,
546 1,
547 0,
548 0xB2u,
549 0,
550 0,
551 pGlobalTXT_LocalizationStrings[375],
552 0);
553 pBtn_Book_2 = v1->CreateButton(
554 415u,
555 48u,
556 39u,
557 36u,
558 1,
559 0,
560 0xB2u,
561 1u,
562 0,
563 pGlobalTXT_LocalizationStrings[523],
564 0);
565 v17 = &pParty->pPlayers[_506348_current_lloyd_playerid];
566 v23 = 1;
567 v18 = v17->pActiveSkills[14];
568 if ( HIBYTE(v18) & 1 || (v18 & 0x80u) != 0 )
569 {
570 v23 = 5;
571 }
572 else
573 {
574 if ( v18 & 0x40 )
575 v23 = 3;
576 }
577 v19 = 0;
578 if ( v23 > 0 )
579 {
580 do
581 {
582 v1->CreateButton(
583 pLloydsBeaconsPreviewXs[v19],
584 pLloydsBeaconsPreviewYs[v19],
585 0x5Cu,
586 0x44u,
587 1,
588 180,
589 0xB3u,
590 v19,
591 0,
592 nullstring,
593 0);
594 ++v19;
595 }
596 while ( (signed int)v19 < v23 );
597 }
598 v20 = 0;
599 v21 = v17->pInstalledBeacons;
600 do
601 {
602 if ( *(_QWORD *)v21 >= (signed __int64)pParty->uTimePlayed )
603 LoadThumbnailLloydTexture(v20, _506348_current_lloyd_playerid + 1);
604 else
605 memset(v21, 0, 0x1Cu);
606 ++v20;
607 v21 = (char *)v21 + 28;
608 }
609 while ( (signed int)v20 < 5 );
610 }
611 else
612 {
613 if ( v1->ptr_1C == (void *)195 )
614 {
615 pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("townport", TEXTURE_16BIT_PALETTE)];
616 pTexture_TownPortalHarmn = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tpharmndy", TEXTURE_16BIT_PALETTE)];
617 pTexture_TownPortalElf = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tpelf", TEXTURE_16BIT_PALETTE)];
618 pTexture_TownPortalWarlock = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tpwarlock", TEXTURE_16BIT_PALETTE)];
619 pTexture_TownPortalIsland = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tpisland", TEXTURE_16BIT_PALETTE)];
620 pTexture_TownPortalHeaven = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tpheaven", TEXTURE_16BIT_PALETTE)];
621 v16 = 0;
622 pTexture_TownPortalHell = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "tphell", TEXTURE_16BIT_PALETTE)];
623 do
624 {
625 v1->CreateButton(
626 pTownPortalBook_xs[v16],
627 pTownPortalBook_ys[v16],
628 pTownPortalBook_ws[v16],
629 pTownPortalBook_hs[v16],
630 1,
631 182,
632 0xB7u,
633 v16,
634 0,
635 nullstring,
636 0);
637 ++v16;
638 }
639 while ( (signed int)v16 < 6 );
640 }
641 else
642 {
643 if ( v1->ptr_1C == (void *)200 )
644 {
645 pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "sbquiknot", TEXTURE_16BIT_PALETTE)];
646 pTextures_5064A0[10] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "divbar", TEXTURE_16BIT_PALETTE)];
647 pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
648 pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
649 pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
650 pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
651 pBtn_Book_1 = v1->CreateButton(
652 pViewport->uViewportX + 398,
653 pViewport->uViewportY + 1,
654 pTex_tab_an_6b__zoom_on->uTextureWidth,
655 pTex_tab_an_6b__zoom_on->uTextureHeight,
656 1,
657 0,
658 0x47u,
659 0xBu,
660 0,
661 pGlobalTXT_LocalizationStrings[192],// "Scroll Up"
662 pTex_tab_an_6b__zoom_on,
663 0);
664 pBtn_Book_2 = v1->CreateButton(
665 pViewport->uViewportX + 398,
666 pViewport->uViewportY + 38,
667 pTex_tab_an_7b__zoot_on->uTextureHeight,
668 pTex_tab_an_7b__zoot_on->uTextureHeight,
669 1,
670 0,
671 0x47u,
672 0xAu,
673 0,
674 pGlobalTXT_LocalizationStrings[193],// "Scroll Down"
675 pTex_tab_an_7b__zoot_on,
676 0);
677 dword_506520 = 0;
678 memset(&pStru179, 0, 0xFA0u);
679 for ( i = dword_506528; i < 512; ++i )
680 {
681 v14 = (&dword_722F10)[4 * i];
682 if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, i) && v14 )
683 {
684 v15 = dword_506520++;
685 pStru179->field_0[v15] = i;
686 }
687 }
688 }
689 else
690 {
691 if ( v1->ptr_1C == (void *)201 )
692 {
693 pTexture_AutonotesBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbautnot", TEXTURE_16BIT_PALETTE)];
694 pTextures_5064A0[10] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("divbar", TEXTURE_16BIT_PALETTE)];
695 pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
696 pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
697 pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
698 pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
699 pTexture_506394 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-1b", TEXTURE_16BIT_PALETTE)];
700 pTexture_506390 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-1a", TEXTURE_16BIT_PALETTE)];
701 pTexture_50638C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-2b", TEXTURE_16BIT_PALETTE)];
702 pTexture_506388 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-2a", TEXTURE_16BIT_PALETTE)];
703 pTexture_506384 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-3b", TEXTURE_16BIT_PALETTE)];
704 pTexture_506380 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-3a", TEXTURE_16BIT_PALETTE)];
705 pTexture_50637C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-5b", TEXTURE_16BIT_PALETTE)];
706 pTexture_506378 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-5a", TEXTURE_16BIT_PALETTE)];
707 pTexture_506374 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-4b", TEXTURE_16BIT_PALETTE)];
708 pTexture_506370 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-4a", TEXTURE_16BIT_PALETTE)];
709 pTexture_50636C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-8b", TEXTURE_16BIT_PALETTE)];
710 pTexture_506368 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-8a", TEXTURE_16BIT_PALETTE)];
711 pBtn_Book_1 = v1->CreateButton(
712 pViewport->uViewportX + 398,
713 pViewport->uViewportY + 1,
714 0x32u,
715 0x22u,
716 1,
717 0,
718 0x47u,
719 0xBu,
720 0,
721 pGlobalTXT_LocalizationStrings[193],
722 pTex_tab_an_6b__zoom_on,
723 0);
724 pBtn_Book_2 = v1->CreateButton(
725 pViewport->uViewportX + 398,
726 pViewport->uViewportY + 38,
727 0x32u,
728 0x22u,
729 1,
730 0,
731 0x47u,
732 0xAu,
733 0,
734 pGlobalTXT_LocalizationStrings[192],
735 pTex_tab_an_7b__zoot_on,
736 0);
737 pBtn_Book_3 = v1->CreateButton(
738 pViewport->uViewportX + 398,
739 pViewport->uViewportY + 113,
740 0x32u,
741 0x22u,
742 1,
743 0,
744 0x47u,
745 2u,
746 0,
747 pGlobalTXT_LocalizationStrings[85],// "Potion Notes"
748 pTexture_506394,
749 0);
750 pBtn_Book_4 = v1->CreateButton(
751 pViewport->uViewportX + 399,
752 pViewport->uViewportY + 150,
753 0x32u,
754 0x22u,
755 1,
756 0,
757 0x47u,
758 3u,
759 0,
760 pGlobalTXT_LocalizationStrings[137],// "Fountain Notes"
761 pTexture_50638C,
762 0);
763 pBtn_Book_5 = v1->CreateButton(
764 pViewport->uViewportX + 397,
765 pViewport->uViewportY + 188,
766 0x32u,
767 0x22u,
768 1,
769 0,
770 0x47u,
771 4u,
772 0,
773 pGlobalTXT_LocalizationStrings[8],// "Obelisk Notes"
774 pTexture_506384,
775 0);
776 pBtn_Book_6 = v1->CreateButton(
777 pViewport->uViewportX + 397,
778 pViewport->uViewportY + 226,
779 0x32u,
780 0x22u,
781 1,
782 0,
783 0x47u,
784 5u,
785 0,
786 pGlobalTXT_LocalizationStrings[141],// "Seer Notes"
787 pTexture_50637C,
788 0);
789 pBtn_Autonotes_Misc = v1->CreateButton(
790 pViewport->uViewportX + 397,
791 pViewport->uViewportY + 264,
792 0x32u,
793 0x22u,
794 1,
795 0,
796 0x47u,
797 6u,
798 0,
799 pGlobalTXT_LocalizationStrings[123],// "Miscellaneous Notes"
800 pTexture_506374,
801 0);
802 v9 = v1->CreateButton(
803 pViewport->uViewportX + 397,
804 pViewport->uViewportY + 302,
805 0x32u,
806 0x22u,
807 1,
808 0,
809 0x47u,
810 7u,
811 0,
812 pGlobalTXT_LocalizationStrings[662],// "Instructors"
813 pTexture_50636C,
814 0);
815 v10 = dword_506528;
816 pBtn_Autonotes_Instructors = v9;
817 dword_506520 = 0;
818 while ( v10 < 196 )
819 {
820 if ( dword_506568 == dword_72371C[2 * v10] )
821 {
822 v25 = (&dword_723718_autonote_related)[8 * (signed __int16)v10];
823 if ( (short)v10 )
824 {
825 if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)pParty->_autonote_related_stuff, v10) && v25 )
826 {
827 v11 = dword_506520++;
828 pStru179->field_0[v11] = (signed __int16)v10;
829 }
830 }
831 }
832 ++v10;
833 }
834 }
835 else
836 {
837 if ( v1->ptr_1C == (void *)202 )
838 {
839 dword_506364 = 1;
840 pTextures_5064A0[12] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
841 pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoom-on", TEXTURE_16BIT_PALETTE)];
842 pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoot-on", TEXTURE_16BIT_PALETTE)];
843 pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoom-off", TEXTURE_16BIT_PALETTE)];
844 pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoot-off", TEXTURE_16BIT_PALETTE)];
845 pTexture_506394 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabNon", TEXTURE_16BIT_PALETTE)];
846 pTexture_506390 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabNoff", TEXTURE_16BIT_PALETTE)];
847 pTexture_50638C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabSon", TEXTURE_16BIT_PALETTE)];
848 pTexture_506388 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabSoff", TEXTURE_16BIT_PALETTE)];
849 pTexture_506384 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabEon", TEXTURE_16BIT_PALETTE)];
850 pTexture_506380 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabEoff", TEXTURE_16BIT_PALETTE)];
851 pTexture_50637C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabWon", TEXTURE_16BIT_PALETTE)];
852 pTexture_506378 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabWoff", TEXTURE_16BIT_PALETTE)];
853 pBtn_Book_1 = v1->CreateButton(
854 pViewport->uViewportX + 398,
855 pViewport->uViewportY + 1,
856 0x32u,
857 0x22u,
858 1,
859 0,
860 0x47u,
861 0,
862 0,
863 pGlobalTXT_LocalizationStrings[251],// "Zoom In"
864 pTex_tab_an_6b__zoom_on,
865 0);
866 pBtn_Book_2 = v1->CreateButton(
867 pViewport->uViewportX + 398,
868 pViewport->uViewportY + 38,
869 0x32u,
870 0x22u,
871 1,
872 0,
873 0x47u,
874 1u,
875 0,
876 pGlobalTXT_LocalizationStrings[252],// "Zoom Out"
877 pTex_tab_an_7b__zoot_on,
878 0);
879 pBtn_Book_3 = v1->CreateButton(
880 pViewport->uViewportX + 397,
881 pViewport->uViewportY + 113,
882 0x32u,
883 0x22u,
884 1,
885 0,
886 0x47u,
887 2u,
888 0,
889 pGlobalTXT_LocalizationStrings[192],// Scroll Up
890 (Texture *)nullstring,
891 0);
892 pBtn_Book_4 = v1->CreateButton(
893 pViewport->uViewportX + 397,
894 pViewport->uViewportY + 150,
895 0x32u,
896 0x22u,
897 1,
898 0,
899 0x47u,
900 3u,
901 0,
902 pGlobalTXT_LocalizationStrings[193],// Scroll Down
903 (Texture *)nullstring,
904 0);
905 pBtn_Book_5 = v1->CreateButton(
906 pViewport->uViewportX + 397,
907 pViewport->uViewportY + 188,
908 0x32u,
909 0x22u,
910 1,
911 0,
912 0x47u,
913 4u,
914 0,
915 pGlobalTXT_LocalizationStrings[573],// "Scroll Right"
916 (Texture *)nullstring,
917 0);
918 pBtn_Book_6 = v1->CreateButton(
919 pViewport->uViewportX + 397,
920 pViewport->uViewportY + 226,
921 0x32u,
922 0x22u,
923 1,
924 0,
925 0x47u,
926 5u,
927 0,
928 pGlobalTXT_LocalizationStrings[572],// "Scroll Left"
929 (Texture *)nullstring,
930 0);
931 return;
932 }
933 if ( v1->ptr_1C == (void *)203 )
934 {
935 pTextures_5064A0[13] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbdate-time", TEXTURE_16BIT_PALETTE)];
936 pTex_moon_new = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_new", TEXTURE_16BIT_PALETTE)];
937 pTex_moon_4 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_4", TEXTURE_16BIT_PALETTE)];
938 pTex_moon_2 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_2", TEXTURE_16BIT_PALETTE)];
939 pTex_moon_2_2 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_2", TEXTURE_16BIT_PALETTE)];
940 pTex_moon_ful = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_ful", TEXTURE_16BIT_PALETTE)];
941 return;
942 }
943 if ( v1->ptr_1C != (void *)224 )
944 return;
945 pTextures_5064A0[11] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbplayrnot", TEXTURE_16BIT_PALETTE)];
946 pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
947 pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
948 pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
949 pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
950 pBtn_Book_1 = v1->CreateButton(
951 pViewport->uViewportX + 398,
952 pViewport->uViewportY + 1,
953 pTex_tab_an_6b__zoom_on->uTextureWidth,
954 pTex_tab_an_6b__zoom_on->uTextureHeight,
955 1,
956 0,
957 0x47u,
958 0xBu,
959 0,
960 pGlobalTXT_LocalizationStrings[192],
961 pTex_tab_an_6b__zoom_on,
962 0);
963 pBtn_Book_2 = v1->CreateButton(
964 pViewport->uViewportX + 398,
965 pViewport->uViewportY + 38,
966 pTex_tab_an_7b__zoot_on->uTextureHeight,
967 pTex_tab_an_7b__zoot_on->uTextureHeight,
968 1,
969 0,
970 0x47u,
971 0xAu,
972 0,
973 pGlobalTXT_LocalizationStrings[193],
974 pTex_tab_an_7b__zoot_on,
975 0);
976 dword_506520 = 0;
977 v26.uFrameX = 48;
978 v26.uFrameY = 70;
979 v26.uFrameWidth = 360;
980 v26.uFrameHeight = 264;
981 v2 = LOBYTE(pAutonoteFont->uFontHeight) - 3;
982 v26.uFrameZ = 407;
983 v26.uFrameHeight = v2 * 264 / v2;
984 v26.uFrameW = v26.uFrameHeight + 69;
985 memset(&pStru179, 0, 0xFA0u);
986 memset(byte_5C6D50, 0, 0x64u);
987 if ( dword_506528 < 29 )
988 {
989 v3 = (__int64 *)&pParty->field_3C.field_4F0[2 * dword_506528];
990 v24 = dword_506528 + 1;
991 v22 = (char *)&pStorylineText->field_4[3 * dword_506528 + 2];
992 do
993 {
994 v4 = *(char **)v22;
995 if ( *v3 )
996 {
997 if ( v4 )
998 {
999 v5 = sub_495461(v4, uActiveCharacter - 1, 0, 0, 0, v3);
1000 v6 = pAutonoteFont->CalcTextHeight(v5, &v26, 1, 0);
1001 v7 = (v6 - 3) / (signed int)v26.uFrameHeight;
1002 v8 = v7 + 1;
1003 if ( (signed int)v7 + 1 > 0 )
1004 {
1005 memset32((void *)(4 * dword_506520 + 6043152), v24, v8);
1006 do
1007 {
1008 LODWORD(v7) = dword_506520++;
1009 byte_5C6D50[(int)v7] = BYTE4(v7);
1010 ++HIDWORD(v7);
1011 }
1012 while ( SHIDWORD(v7) < (signed int)v8 );
1013 }
1014 }
1015 }
1016 v22 += 12;
1017 ++v3;
1018 ++v24;
1019 __debugbreak(); // fix condition
1020 }
1021 while ( (signed int)v22 < (signed int)&pFactionTable->relations + 8 );
1022 }
1023 }
1024 }
1025 v12 = dword_506520;
1026 dword_506520 = 0;
1027 dword_506524 = v12;
1028 }
1029 }
1030 }
1031
1032
1033
1034
1035 //----- (00415551) --------------------------------------------------------
1036 void GUIWindow::_415551(int arg0)
1037 {
1038 unsigned int v2; // edi@1
1039 GUIWindow *v3; // ebx@1
1040 signed int v4; // esi@2
1041 unsigned int v5; // eax@2
1042 unsigned int v6; // edx@4
1043 unsigned int v7; // ecx@6
1044 unsigned int v8; // eax@9
1045 __int32 v9; // eax@10
1046 unsigned int v10; // eax@18
1047 LONG v11; // ecx@18
1048 unsigned int v12; // edx@18
1049 unsigned int v13; // eax@18
1050 const char *v14; // ecx@18
1051 int v15; // eax@19
1052 unsigned int v16; // esi@19
1053 const char *v17; // ebx@25
1054 int v18; // eax@26
1055 GUIWindow v19; // [sp+Ch] [bp-60h]@18
1056 POINT a2; // [sp+60h] [bp-Ch]@8
1057 unsigned int v21; // [sp+68h] [bp-4h]@18
1058 unsigned int v22; // [sp+74h] [bp+8h]@2
1059 unsigned int v23; // [sp+74h] [bp+8h]@18
1060
1061 v2 = 0;
1062 v3 = this;
1063 if ( arg0 )
1064 {
1065 v4 = pViewport->uViewportX;
1066 v5 = pViewport->uViewportZ;
1067 v2 = pViewport->uViewportY;
1068 v22 = pViewport->uViewportW;
1069 }
1070 else
1071 {
1072 v4 = 0;
1073 v5 = 640;
1074 v22 = 480;
1075 }
1076 v6 = this->uFrameX;
1077 if ( (signed int)this->uFrameX >= v4 )
1078 {
1079 v7 = this->uFrameWidth;
1080 if ( (signed int)(v7 + v6) <= (signed int)v5 )
1081 goto LABEL_9;
1082 v3->uFrameX = v5 - v7;
1083 }
1084 else
1085 {
1086 this->uFrameX = v4;
1087 }
1088 v3->uFrameY = pMouse->GetCursorPos(&a2)->y + 30;
1089 LABEL_9:
1090 v8 = v3->uFrameY;
1091 if ( (signed int)v8 >= (signed int)v2 )
1092 {
1093 if ( (signed int)(v8 + v3->uFrameHeight) <= (signed int)v22 )
1094 goto LABEL_14;
1095 v9 = pMouse->GetCursorPos(&a2)->y - v3->uFrameHeight - 30;
1096 }
1097 else
1098 {
1099 v9 = pMouse->GetCursorPos(&a2)->y + 30;
1100 }
1101 v3->uFrameY = v9;
1102 LABEL_14:
1103 if ( (signed int)v3->uFrameY < (signed int)v2 )
1104 v3->uFrameY = v2;
1105 if ( (signed int)v3->uFrameX < v4 )
1106 v3->uFrameX = v4;
1107 v10 = v3->uFrameWidth;
1108 v11 = v3->uFrameX;
1109 v12 = v3->uFrameY;
1110 v21 = v10;
1111 a2.y = v11;
1112 v3->uFrameZ = v10 + v11 - 1;
1113 v13 = v3->uFrameHeight;
1114 v3->uFrameW = v13 + v12 - 1;
1115 memcpy(&v19, v3, sizeof(v19));
1116 v19.uFrameX += 12;
1117 v19.uFrameWidth -= 24;
1118 v19.uFrameY += 12;
1119 v19.uFrameHeight -= 12;
1120 v19.uFrameZ = v19.uFrameWidth + v19.uFrameX - 1;
1121 v23 = v12;
1122 v19.uFrameW = v19.uFrameHeight + v19.uFrameY - 1;
1123 v14 = v3->str_48;
1124 if ( v14 )
1125 {
1126 v15 = pFontLucida->CalcTextHeight(v14, &v19, 0, 0);
1127 v12 = v23;
1128 v16 = v15 + 24;
1129 }
1130 else
1131 {
1132 v16 = v13;
1133 }
1134 if ( (signed int)v16 < 64 )
1135 v16 = 64;
1136 if ( (signed int)(v16 + v12) > 479 )
1137 v16 = 479 - v12;
1138 DrawPopupWindow(a2.y, v12, v21, v16);
1139 v17 = v3->str_48;
1140 if ( v17 )
1141 {
1142 v18 = pFontLucida->CalcTextHeight(v17, &v19, 0, 0);
1143 v19.DrawText2(pFontLucida, 0, (signed int)(v16 - v18) / 2 - 14, 0, v17, 3u);
1144 }
1145 }
1146
1147
1148 //----- (0041192C) --------------------------------------------------------
1149 void __cdecl InitializeBookTextures()
1150 {
1151 signed int v0; // ebp@3
1152 Texture **v1; // ebx@3
1153
1154 pAudioPlayer->StopChannels(-1, -1);
1155 ++pIcons_LOD->uTexturePacksCount;
1156 if ( !pIcons_LOD->uNumPrevLoadedFiles )
1157 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
1158 pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
1159 pTextures_5064A0[9] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("book", TEXTURE_16BIT_PALETTE)];
1160 pTexture_pagemask = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("pagemask", TEXTURE_16BIT_PALETTE)];
1161 pTexture_506448 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m5-u", TEXTURE_16BIT_PALETTE)];
1162 ptr_506440 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m5-d", TEXTURE_16BIT_PALETTE)];
1163 pTexture_50643C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m6-u",TEXTURE_16BIT_PALETTE)];
1164 v0 = 1;
1165 v1 = (Texture **)&pTextures_tabs[0][0].pName[4];
1166 pTexture_506444 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m6-d",TEXTURE_16BIT_PALETTE)];
1167 do
1168 {
1169 *(&pTexture_pagemask + v0) = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(
1170 (const char *)pLloydsBeacons_SomeYs[v0 + 4],
1171 TEXTURE_16BIT_PALETTE)];
1172 sprintfex(pTmpBuf, "tab%da", v0);
1173 *(v1 - 1) = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE)];
1174 sprintfex(pTmpBuf, "tab%db", v0++);
1175 *v1 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE)];
1176 v1 += 2;
1177 }
1178 while ( (signed int)v1 <= (signed int)&unk_506494 );
1179 }
1180
1181 //----- (00411AAA) --------------------------------------------------------
1182 void __cdecl InitializeBookFonts()
1183 {
1184 pAudioPlayer->StopChannels(-1, -1);
1185 ++pIcons_LOD->uTexturePacksCount;
1186 if ( !pIcons_LOD->uNumPrevLoadedFiles )
1187 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
1188 pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
1189 pTexture_mapbordr = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("mapbordr", TEXTURE_16BIT_PALETTE)];
1190 pBookFont = LoadFont("book.fnt", "FONTPAL", 0);
1191 pBook2Font = LoadFont("book2.fnt", "FONTPAL", 0);
1192 pAutonoteFont = LoadFont("autonote.fnt", "FONTPAL", 0);
1193 pSpellFont = LoadFont("spell.fnt", "FONTPAL", 0);
1194 }
1195
1196 //----- (00411B59) --------------------------------------------------------
1197 void __fastcall LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer)
1198 {
1199 unsigned int v2; // esi@1
1200 unsigned int v3; // edi@1
1201 FILE *v4; // ebx@1
1202 FILE *v5; // eax@2
1203 char pContainerName[64]; // [sp+Ch] [bp-44h]@1
1204 unsigned int v7; // [sp+4Ch] [bp-4h]@1
1205
1206 v2 = uSlot;
1207 v7 = uPlayer;
1208 v3 = uSlot + 1;
1209 sprintfex(pContainerName, "data\\lloyd%d%d.pcx", uPlayer, uSlot + 1);
1210 v4 = fopen(pContainerName, "rb");
1211 if ( v4 )
1212 {
1213 pSavegameThumbnails[v2].LoadFromFILE(v4, 0, 1u);
1214 fclose(v4);
1215 }
1216 else
1217 {
1218 sprintfex(pContainerName, "lloyd%d%d.pcx", v7, v3);
1219 v5 = pNew_LOD->FindContainer(pContainerName, 1);
1220 if ( v5 )
1221 pSavegameThumbnails[v2].LoadFromFILE(v5, 0, 0);
1222 else
1223 *((int *)&pSavegameThumbnails->pPixels + 10 * v2) = 0;
1224 }
1225 }
1226
1227
1228 //----- (00411621) --------------------------------------------------------
1229 GUIButton *GUIWindow::_411621()
1230 {
1231 Player *v1; // edi@1
1232 GUIWindow *v2; // esi@1
1233 unsigned int v3; // ebp@1
1234 int v4; // eax@3
1235 GUIButton *result; // eax@25
1236 int a2; // [sp+10h] [bp-8h]@1
1237 int v7; // [sp+14h] [bp-4h]@1
1238
1239 v1 = pPlayers[uActiveCharacter];
1240 v2 = this;
1241 LoadSpellbook(v1->field_1A4E);
1242 v3 = 0;
1243 a2 = 0;
1244 v7 = (int)(&v1->pFileSpellbook + v1->field_1A4E);
1245 do
1246 {
1247 if ( *(char *)(v7 + v3) )
1248 {
1249 v4 = 2 * (12 * v1->field_1A4E + (unsigned __int8)*(&byte_4E2431[12 * v1->field_1A4E] + v3));
1250 v2->CreateButton(
1251 pViewport->uViewportX + dword_4E20D0[v4],
1252 pViewport->uViewportY + dword_4E20D0[v4 + 1],
1253 *(short *)(dword_50640C[v3] + 24),
1254 *(short *)(dword_50640C[v3] + 26),
1255 1,
1256 79,
1257 0x56u,
1258 v3,
1259 0,
1260 nullstring,
1261 0);
1262 ++a2;
1263 }
1264 ++v3;
1265 }
1266 while ( (signed int)v3 < 11 );
1267 v2->CreateButton(0, 0, 0, 0, 1, 0, 0x33u, 0, 9u, nullstring, 0);
1268 if ( a2 )
1269 v2->_41D08F(a2, 0, 0, 0);
1270 if ( v1->pActiveSkills[12] )
1271 v2->CreateButton(0x18Fu, 0xAu, 0x32u, 0x24u, 1, 0, 0x57u, 0, 0, aSpellSchoolNames[0], 0);
1272 if ( v1->pActiveSkills[13] )
1273 v2->CreateButton(0x18Fu, 0x2Eu, 0x32u, 0x24u, 1, 0, 0x57u, 1u, 0, aSpellSchoolNames[1], 0);
1274 if ( v1->pActiveSkills[14] )
1275 v2->CreateButton(0x18Fu, 0x53u, 0x32u, 0x24u, 1, 0, 0x57u, 2u, 0, aSpellSchoolNames[2], 0);
1276 if ( v1->pActiveSkills[15] )
1277 v2->CreateButton(0x18Fu, 0x79u, 0x32u, 0x24u, 1, 0, 0x57u, 3u, 0, aSpellSchoolNames[3], 0);
1278 if ( v1->pActiveSkills[16] )
1279 v2->CreateButton(0x18Fu, 0x9Eu, 0x32u, 0x24u, 1, 0, 0x57u, 4u, 0, aSpellSchoolNames[4], 0);
1280 if ( v1->pActiveSkills[17] )
1281 v2->CreateButton(0x190u, 0xC4u, 0x32u, 0x24u, 1, 0, 0x57u, 5u, 0, aSpellSchoolNames[5], 0);
1282 if ( v1->pActiveSkills[18] )
1283 v2->CreateButton(0x190u, 0xEAu, 0x32u, 0x24u, 1, 0, 0x57u, 6u, 0, aSpellSchoolNames[6], 0);
1284 if ( v1->pActiveSkills[19] )
1285 v2->CreateButton(0x190u, 0x10Fu, 0x32u, 0x24u, 1, 0, 0x57u, 7u, 0, aSpellSchoolNames[7], 0);
1286 if ( v1->pActiveSkills[20] )
1287 v2->CreateButton(0x190u, 0x133u, 0x32u, 0x24u, 1, 0, 0x57u, 8u, 0, aSpellSchoolNames[8], 0);
1288 v2->CreateButton(
1289 0x1DCu,
1290 0x1C2u,
1291 pTexture_506444->uTextureWidth,
1292 pTexture_506444->uTextureHeight,
1293 1,
1294 78,
1295 0x58u,
1296 0,
1297 0,
1298 nullstring,
1299 0);
1300 ptr_5064F8 = v2->CreateButton(
1301 0x1DCu,
1302 0x1C2u,
1303 0x30u,
1304 0x20u,
1305 1,
1306 78,
1307 0x58u,
1308 0,
1309 0,
1310 nullstring,
1311 pTexture_506444,
1312 0);
1313 v2->CreateButton(
1314 0x231u,
1315 0x1C2u,
1316 ptr_506440->uTextureWidth,
1317 ptr_506440->uTextureHeight,
1318 1,
1319 0,
1320 0x71u,
1321 0,
1322 0,
1323 pGlobalTXT_LocalizationStrings[79],
1324 0);
1325 result = v2->CreateButton(
1326 0x231u,
1327 0x1C2u,
1328 0x30u,
1329 0x20u,
1330 1,
1331 0,
1332 0x71u,
1333 0,
1334 0,
1335 pGlobalTXT_LocalizationStrings[79],
1336 ptr_506440,
1337 0);
1338 ptr_5064F4 = result;
1339 return result;
1340 }
1341 // 50640C: using guessed type int dword_50640C[];
1342
1343
1344 //----- (004B3157) --------------------------------------------------------
1345 void GUIWindow::_4B3157()
1346 {
1347 unsigned __int16 v1; // di@2
1348 const char *v2; // edx@4
1349 signed int v3; // edx@5
1350 char *v4; // edi@9
1351 int v5; // eax@45
1352 int v6; // edi@45
1353 char *v7; // eax@45
1354 int v8; // edi@46
1355 int v9; // eax@50
1356 unsigned int v10; // [sp-10h] [bp-C8h]@53
1357 unsigned __int16 v11; // [sp-Ch] [bp-C4h]@53
1358 unsigned int v12; // [sp-Ch] [bp-C4h]@60
1359 char *v13; // [sp-8h] [bp-C0h]@50
1360 unsigned int v14; // [sp-8h] [bp-C0h]@60
1361 unsigned int v15; // [sp-4h] [bp-BCh]@50
1362 Texture *v16; // [sp-4h] [bp-BCh]@60
1363 GUIWindow w; // [sp+Ch] [bp-ACh]@4
1364 GUIWindow v18; // [sp+60h] [bp-58h]@2
1365 int v19; // [sp+B4h] [bp-4h]@2
1366
1367 if ( !ptr_507BC0 )
1368 return;
1369 memcpy(&v18, this, sizeof(v18));
1370 v18.uFrameWidth -= 18;
1371 v18.uFrameZ -= 18;
1372 v1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
1373 v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
1374 pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
1375 pRenderer->DrawTextureTransparent(
1376 0x1D4u,
1377 0,
1378 (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0));
1379 if ( array_5913D8[6] != (NPCData *)uNumDialogueNPCPortraits || !uHouse_ExitPic )
1380 {
1381 w.uFrameWidth = 130;
1382 w.uFrameHeight = 2 * LOBYTE(pFontCreate->uFontHeight);
1383
1384 //v2 = (const char *)p2DEvents_minus1_::04[13 * (unsigned int)ptr_507BC0->ptr_1C];
1385 v2 = p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].pName;
1386
1387 if ( v2 )
1388 {
1389 v3 = 2 * LOBYTE(pFontCreate->uFontHeight) - 6 - pFontCreate->CalcTextHeight(v2, &w, 0, 0);
1390 if ( v3 < 0 )
1391 v3 = 0;
1392 v18.DrawText2(
1393 pFontCreate,
1394 0x1EAu,
1395 v3 / 2 + 4,
1396 v1,
1397 //(const char *)p2DEvents_minus1_::04[13 * (unsigned int)ptr_507BC0->ptr_1C],
1398 p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].pName,
1399 3u);
1400 }
1401 }
1402 v18.uFrameWidth += 8;
1403 v18.uFrameZ += 8;
1404 if ( !array_5913D8[6] )
1405 {
1406 if ( dword_F8B198 == 31 )
1407 {
1408 LABEL_36:
1409 sub_4B4F4F();
1410 goto LABEL_58;
1411 }
1412 if ( ptr_F8B1E8 )
1413 {
1414 w.uFrameWidth = 458;
1415 w.uFrameZ = 457;
1416 v5 = pFontArrus->CalcTextHeight(ptr_F8B1E8, &w, 13, 0);
1417 v6 = v5 + 7;
1418 pRenderer->_4A6A68(
1419 8u,
1420 352 - (v5 + 7),
1421 (Texture *)(uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0),
1422 (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - (v5 + 7));
1423 pRenderer->DrawTextureIndexed(8u, 347 - v6, pTexture_591428);
1424 v7 = FitTextInAWindow(ptr_F8B1E8, pFontArrus, &w, 0xDu, 0);
1425 ptr_507BC0->DrawText(pFontArrus, 13, 354 - v6, 0, v7, 0, 0, 0);
1426 }
1427 v8 = 0;
1428 if ( uNumDialogueNPCPortraits <= 0 )
1429 goto LABEL_58;
1430 while ( 1 )
1431 {
1432 pRenderer->DrawTextureIndexed(
1433 *(&_4E5E50_transui_x + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4,
1434 *(&_4E5EE0_transui_y + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4,
1435 (Texture *)(uTextureID_50795C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50795C] : 0));
1436 pRenderer->DrawTextureIndexed(
1437 *(&_4E5E50_transui_x + v8 + 6 * uNumDialogueNPCPortraits - 6),
1438 *(&_4E5EE0_transui_y + v8 + 6 * uNumDialogueNPCPortraits - 6),
1439 pDialogueNPCPortraits[v8]);
1440 if ( uNumDialogueNPCPortraits < 4 )
1441 break;
1442 LABEL_57:
1443 ++v8;
1444 if ( v8 >= uNumDialogueNPCPortraits )
1445 goto LABEL_58;
1446 }
1447 if ( v8 + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic )
1448 {
1449 v15 = 3;
1450 v13 = pMapStats->pInfos[uHouse_ExitPic].pName;
1451 v9 = 94 * v8 + 113;
1452 }
1453 else
1454 {
1455 if ( !v8 && dword_591080 )
1456 {
1457 v15 = 3;
1458 //v13 = (char *)p2DEvents_minus1__10[13 * (unsigned int)ptr_507BC0->ptr_1C];
1459 v13 = (char *)p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].pProprieterTitle;
1460 v11 = v19;
1461 v10 = 113;
1462 LABEL_56:
1463 v18.DrawText2(pFontCreate, 0x1E3u, v10, v11, v13, v15);
1464 goto LABEL_57;
1465 }
1466 v15 = 3;
1467 v13 = array_5913D8[v8 - (dword_591080 != 0)]->pName;
1468 v9 = dword_4E5EC8[v8 + 6 * uNumDialogueNPCPortraits] + pDialogueNPCPortraits[v8]->uTextureHeight + 2;
1469 }
1470 v11 = v19;
1471 v10 = v9;
1472 goto LABEL_56;
1473 }
1474 v4 = (char *)array_5913D8[6] - 1;
1475 pRenderer->DrawTextureIndexed(
1476 _4E5E50_transui_x - 4,
1477 _4E5EE0_transui_y - 4,
1478 (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0));
1479 pRenderer->DrawTextureIndexed(_4E5E50_transui_x, _4E5EE0_transui_y, pDialogueNPCPortraits[(signed int)v4]);
1480 if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 14 )
1481 {
1482 CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
1483 goto LABEL_58;
1484 }
1485 if ( v4 || !dword_591080 )
1486 {
1487 sub_4B2A74();
1488 }
1489 else
1490 {
1491 sprintfex(
1492 pTmpBuf,
1493 pGlobalTXT_LocalizationStrings[429],
1494 //p2DEvents_minus1_::08[13 * (unsigned int)ptr_507BC0->ptr_1C],
1495 p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].pProprieterName,
1496 //p2DEvents_minus1__10[13 * (unsigned int)ptr_507BC0->ptr_1C]);
1497 p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].pProprieterTitle);
1498 v18.DrawText2(pFontCreate, 0x1E3u, 0x71u, v19, pTmpBuf, 3u);
1499 if ( dword_F8B198 <= 18 )
1500 {
1501 switch ( dword_F8B198 )
1502 {
1503 case 18:
1504 sub_4B6478();
1505 break;
1506 case 1:
1507 sub_4B910F();
1508 break;
1509 case 2:
1510 sub_4BA928();
1511 break;
1512 case 3:
1513 ui_shop_teachers();
1514 break;
1515 case 4:
1516 sub_4B9CC6();
1517 break;
1518 default:
1519 if ( dword_F8B198 > 4 )
1520 {
1521 if ( dword_F8B198 <= 16 )
1522 {
1523 sub_4B5D7C();
1524 }
1525 else
1526 {
1527 if ( dword_F8B198 == 17 )
1528 sub_4B7911();
1529 }
1530 }
1531 break;
1532 }
1533 goto LABEL_58;
1534 }
1535 switch ( dword_F8B198 )
1536 {
1537 case 21:
1538 sub_4B8285_prolly_draw_arcomage_result();
1539 break;
1540 case 22:
1541 _4B7D7E_bank();
1542 break;
1543 case 23:
1544 sub_4B705E();
1545 break;
1546 default:
1547 if ( dword_F8B198 <= 26 )
1548 break;
1549 if ( dword_F8B198 <= 28 )
1550 {
1551 TravelByTransport();
1552 }
1553 else
1554 {
1555 if ( dword_F8B198 != 30 )
1556 {
1557 if ( dword_F8B198 != 31 )
1558 break;
1559 goto LABEL_36;
1560 }
1561 ui_training();
1562 }
1563 break;
1564 }
1565 }
1566 LABEL_58:
1567 if ( array_5913D8[6] == (NPCData *)uNumDialogueNPCPortraits && uHouse_ExitPic )
1568 {
1569 pRenderer->DrawTextureIndexed(
1570 0x22Cu,
1571 0x1C3u,
1572 (Texture *)(uTextureID_x_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_x_u] : 0));
1573 v16 = (Texture *)(uTextureID_x_ok_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_ok_u] : 0);
1574 v14 = 451;
1575 v12 = 476;
1576 }
1577 else
1578 {
1579 v16 = (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0);
1580 v14 = 445;
1581 v12 = 471;
1582 }
1583 pRenderer->DrawTextureIndexed(v12, v14, v16);
1584 }
1585
1586
1587 //----- (004B1854) --------------------------------------------------------
1588 char *GUIWindow::_4B1854(__int64 a2)
1589 {
1590 unsigned int v2; // edi@1
1591 unsigned int v3; // esi@1
1592 unsigned int v4; // ebp@1
1593 unsigned int v5; // ebx@1
1594 signed __int64 v6; // ST2C_8@1
1595 signed __int64 v7; // kr00_8@1
1596 char *v8; // eax@2
1597 char *v9; // eax@7
1598 char *v10; // eax@13
1599 char *v11; // eax@19
1600 unsigned __int16 v12; // ST0C_2@22
1601 int v13; // eax@22
1602 GUIWindow *v15; // [sp+0h] [bp-1Ch]@1
1603 signed __int64 v16; // [sp+Ch] [bp-10h]@1
1604 signed __int64 v17; // [sp+14h] [bp-8h]@1
1605 unsigned int v18; // [sp+20h] [bp+4h]@1
1606
1607 v15 = this;
1608 v2 = (unsigned __int64)(signed __int64)((double)a2 * 0.234375) >> 32;
1609 v3 = (signed __int64)((double)a2 * 0.234375);
1610 v4 = (unsigned __int64)((signed __int64)((double)a2 * 0.234375) / 60) >> 32;
1611 v5 = (signed __int64)((double)a2 * 0.234375) / 60;
1612 v6 = (signed __int64)((double)a2 * 0.234375) / 60 / 60;
1613 v18 = (unsigned int)v6 / 0x18;
1614 v17 = (signed __int64)__PAIR__(v2, v3) % 60;
1615 v16 = (signed __int64)__PAIR__(v4, v5) % 60;
1616 v7 = v6 % 24;
1617 strcpy(pTmpBuf, pGlobalTXT_LocalizationStrings[532]);
1618 if ( (unsigned int)v6 / 0x18 )
1619 {
1620 v8 = pGlobalTXT_LocalizationStrings[57];
1621 if ( v18 <= 1 )
1622 v8 = pGlobalTXT_LocalizationStrings[56];
1623 sprintfex(pTmpBuf2, "%d %s ", v18, v8);
1624 strcat(pTmpBuf, pTmpBuf2);
1625 }
1626 if ( v7 )
1627 {
1628 if ( v7 <= 1 )
1629 v9 = pGlobalTXT_LocalizationStrings[109];
1630 else
1631 v9 = pGlobalTXT_LocalizationStrings[110];
1632 sprintfex(pTmpBuf2, "%d %s ", v7, v9);
1633 strcat(pTmpBuf, pTmpBuf2);
1634 }
1635 if ( v16 && !v18 )
1636 {
1637 if ( v16 <= 1 )
1638 v10 = pGlobalTXT_LocalizationStrings[437];
1639 else
1640 v10 = pGlobalTXT_LocalizationStrings[436];
1641 sprintfex(pTmpBuf2, "%d %s ", v16, v10);
1642 strcat(pTmpBuf, pTmpBuf2);
1643 }
1644 if ( v17 && !v7 )
1645 {
1646 if ( v17 <= 1 )
1647 v11 = pGlobalTXT_LocalizationStrings[439];
1648 else
1649 v11 = pGlobalTXT_LocalizationStrings[438];
1650 sprintfex(pTmpBuf2, "%d %s ", v17, v11);
1651 strcat(pTmpBuf, pTmpBuf2);
1652 }
1653 v12 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
1654 v13 = pFontArrus->CalcTextHeight(pTmpBuf, v15, 0, 0);
1655 return v15->DrawText2(pFontArrus, 0, (212 - v13) / 2 + 101, v12, pTmpBuf, 3u);
1656 }
1657
1658
1659
1660 //----- (0044D406) --------------------------------------------------------
1661 char *GUIWindow::DrawText2(GUIFont *a2, unsigned int uHorizontalMargin, unsigned int uVerticalMargin, unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing)
1662 {
1663 GUIWindow *v7; // esi@1
1664 unsigned int v8; // ebx@1
1665 char *v9; // eax@1
1666 char *result; // eax@1
1667 unsigned int v11; // edi@1
1668 signed int v12; // esi@1
1669 int v13; // eax@2
1670 GUIFont *v14; // [sp+Ch] [bp-4h]@1
1671 const char *Stra; // [sp+24h] [bp+14h]@5
1672
1673 v7 = this;
1674 v14 = a2;
1675 v8 = this->uFrameWidth - uHorizontalMargin;
1676 ui_current_text_color = uDefaultColor;
1677 v9 = FitTextInAWindow(pInString, a2, this, uHorizontalMargin, 0);
1678 result = strtok(v9, "\n");
1679 v11 = uHorizontalMargin + v7->uFrameX;
1680 v12 = uVerticalMargin + v7->uFrameY;
1681 while ( 1 )
1682 {
1683 Stra = result;
1684 if ( !result )
1685 break;
1686 v13 = (signed int)(v8 - v14->GetLineWidth(result)) >> 1;
1687 if ( v13 < 0 )
1688 v13 = 0;
1689 v14->DrawTextLine(uDefaultColor, v11 + v13, v12, Stra, 640);
1690 v12 += LOBYTE(v14->uFontHeight) - uLineSpacing;
1691 result = strtok(0, "\n");
1692 }
1693 return result;
1694 }
1695 // 5C6DB4: using guessed type int ui_current_text_color;
1696
1697
1698
1699 //----- (0044CE08) --------------------------------------------------------
1700 char GUIWindow::DrawText(GUIFont *a2, signed int uX, int uY, unsigned int uFontColor, const char *Str, int a7, int a8, unsigned int uFontShadowColor)
1701 {
1702 GUIWindow *v9; // edi@1
1703 GUIFont *v10; // ebx@1
1704 int v11; // eax@2
1705 signed int v12; // esi@9
1706 signed int v13; // edi@9
1707 int v14; // edx@9
1708 int v15; // eax@25
1709 unsigned int v16; // ecx@25
1710 int v17; // eax@27
1711 int v18; // edi@32
1712 int v19; // esi@38
1713 std::string v21; // [sp-18h] [bp-50h]@2
1714 const char *v22; // [sp-8h] [bp-40h]@2
1715 int v23; // [sp-4h] [bp-3Ch]@2
1716 char Dest; // [sp+Ch] [bp-2Ch]@32
1717 char v25; // [sp+Fh] [bp-29h]@32
1718 char v26; // [sp+11h] [bp-27h]@34
1719 const char *v27; // [sp+20h] [bp-18h]@25
1720 int v28; // [sp+24h] [bp-14h]@25
1721 int v29; // [sp+28h] [bp-10h]@1
1722 size_t v30; // [sp+2Ch] [bp-Ch]@4
1723 GUIWindow *v31; // [sp+30h] [bp-8h]@1
1724 const char *v32; // [sp+34h] [bp-4h]@7
1725 size_t pInString; // [sp+4Ch] [bp+14h]@11
1726
1727 auto a1 = this;
1728 v29 = 0;
1729 v9 = a1;
1730 v10 = a2;
1731 v31 = a1;
1732 if ( !Str )
1733 {
1734 MessageBoxW(nullptr, L"Invalid string passed!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:859", 0);
1735 return v11;
1736 }
1737 v11 = strcmp(Str, "null");
1738 if ( v11 )
1739 {
1740 v30 = strlen(Str);
1741 LOBYTE(v11) = 0;
1742 if ( !uX )
1743 uX = 12;
1744 if ( a8 )
1745 {
1746 v32 = Str;
1747 }
1748 else
1749 {
1750 v11 = (int)FitTextInAWindow(Str, v10, v9, uX, 0);
1751 v32 = (const char *)v11;
1752 }
1753 v12 = uX + v9->uFrameX;
1754 v13 = uY + v9->uFrameY;
1755 v14 = 0;
1756 if ( !a8 || (v11 = v13 + LOBYTE(v10->uFontHeight), v11 <= a8) )
1757 {
1758 pInString = 0;
1759 if ( (signed int)v30 > 0 )
1760 {
1761 do
1762 {
1763 LOBYTE(v11) = v32[v14];
1764 if ( (unsigned __int8)v11 >= v10->cFirstChar && (unsigned __int8)v11 <= v10->cLastChar
1765 || (char)v11 == 12
1766 || (char)v11 == 13
1767 || (char)v11 == 9
1768 || (char)v11 == 10 )
1769 {
1770 switch ( (unsigned __int8)v11 )
1771 {
1772 case 9u:
1773 strncpy(&Dest, &v32[v14 + 1], 3u);
1774 v25 = 0;
1775 pInString += 3;
1776 v29 = atoi(&Dest);
1777 v19 = atoi(&Dest);
1778 LOBYTE(v11) = (char)v31;
1779 v12 = uX + v31->uFrameX + v19;
1780 break;
1781 case 0xAu:
1782 v11 = LOBYTE(v10->uFontHeight);
1783 uY = uY + v11 - 3;
1784 v13 = uY + v31->uFrameY;
1785 v12 = uX + v29 + v31->uFrameX;
1786 if ( a8 )
1787 goto LABEL_36;
1788 break;
1789 case 0xCu:
1790 strncpy(&Dest, &v32[v14 + 1], 5u);
1791 v26 = 0;
1792 v11 = atoi(&Dest);
1793 pInString += 5;
1794 uFontColor = v11;
1795 break;
1796 case 0xDu:
1797 strncpy(&Dest, &v32[v14 + 1], 3u);
1798 v25 = 0;
1799 pInString += 3;
1800 v18 = atoi(&Dest);
1801 v11 = v10->GetLineWidth(&v32[pInString]);
1802 v12 = v31->uFrameZ - v11 - v18;
1803 v13 = uY + v31->uFrameY;
1804 if ( a8 )
1805 {
1806 v11 = LOBYTE(v10->uFontHeight);
1807 LABEL_36:
1808 v11 = v11 + v13 - 3;
1809 if ( v11 > a8 )
1810 return v11;
1811 break;
1812 }
1813 break;
1814 default:
1815 if ( (char)v11 == 34 && v32[v14 + 1] == 34 )
1816 {
1817 ++v14;
1818 pInString = v14;
1819 }
1820 v27 = &v32[v14];
1821 v15 = (unsigned __int8)v32[v14];
1822 v16 = *((int *)&v10->cFirstChar + 3 * v15 + 9);
1823 v28 = *((int *)&v10->cFirstChar + 3 * v15 + 9);
1824 if ( v14 > 0 )
1825 v12 += v10->pMetrics[v15].uLeftSpacing;
1826 v17 = (int)((char *)&v10[1] + v10->field_C20[v15]);
1827 if ( (short)uFontColor )
1828 pRenderer->DrawText(
1829 v12,
1830 v13,
1831 (unsigned __int8 *)v17,
1832 v16,
1833 LOBYTE(v10->uFontHeight),
1834 v10->pFontPalettes[0],
1835 uFontColor,
1836 uFontShadowColor);
1837 else
1838 pRenderer->DrawTextPalette(
1839 v12,
1840 v13,
1841 v17,
1842 v16,
1843 LOBYTE(v10->uFontHeight),
1844 v10->pFontPalettes[0],
1845 a7);
1846 LOBYTE(v11) = v30;
1847 v12 += v28;
1848 if ( (signed int)pInString < (signed int)v30 )
1849 {
1850 LOBYTE(v11) = 3 * *v27;
1851 v12 += v10->pMetrics[(unsigned __int8)*v27].uRightSpacing;
1852 }
1853 break;
1854 }
1855 }
1856 v14 = pInString++ + 1;
1857 }
1858 while ( (signed int)pInString < (signed int)v30 );
1859 }
1860 }
1861 }
1862 return v11;
1863 }
1864
1865
1866 //----- (0044CB4F) --------------------------------------------------------
1867 int GUIWindow::DrawTextInRect(GUIFont *a2, unsigned int uX, unsigned int uY, unsigned int uColor, const char *Str1, int Source, int a8)
1868 {
1869 GUIFont *v8; // edi@1
1870 int v9; // ebx@1
1871 int v11; // esi@3
1872 unsigned __int8 v12; // cl@7
1873 signed int v13; // esi@19
1874 signed int v14; // ebx@19
1875 unsigned __int8 v15; // cl@21
1876 int v16; // eax@22
1877 int v17; // ecx@22
1878 int v18; // ecx@23
1879 int v19; // ecx@24
1880 unsigned int v20; // ecx@26
1881 int v21; // eax@28
1882 int v22; // ebx@34
1883 int v23; // eax@34
1884 int v24; // ebx@36
1885 char Str; // [sp+Ch] [bp-20h]@34
1886 char v26; // [sp+Fh] [bp-1Dh]@34
1887 char v27; // [sp+11h] [bp-1Bh]@35
1888 int v28; // [sp+20h] [bp-Ch]@17
1889 GUIWindow *a1; // [sp+24h] [bp-8h]@1
1890 size_t v30; // [sp+28h] [bp-4h]@1
1891 size_t Str1a; // [sp+40h] [bp+14h]@5
1892 size_t Str1b; // [sp+40h] [bp+14h]@19
1893 const char *Sourcea; // [sp+44h] [bp+18h]@20
1894 int v34; // [sp+48h] [bp+1Ch]@26
1895
1896 v8 = a2;
1897 a1 = this;
1898 v30 = strlen(Str1);
1899 v9 = v8->GetLineWidth(Str1);
1900 if ( v9 < Source )
1901 {
1902 a1->DrawText(v8, uX, uY, uColor, Str1, 0, 0, 0);
1903 return v9;
1904 }
1905 strcpy(pTmpBuf2, Str1);
1906 v11 = 0;
1907 if ( a8 )
1908 _strrev(pTmpBuf2);
1909 Str1a = 0;
1910 if ( (signed int)v30 > 0 )
1911 {
1912 do
1913 {
1914 if ( v11 >= Source )
1915 break;
1916 if ( v8->IsCharValid(pTmpBuf2[Str1a]) )
1917 {
1918 if ( v12 < 9u )
1919 goto LABEL_12;
1920 if ( v12 > 0xAu )
1921 {
1922 if ( v12 == 12 )
1923 {
1924 Str1a += 5;
1925 }
1926 else
1927 {
1928 if ( v12 != 13 )
1929 {
1930 LABEL_12:
1931 if ( (signed int)Str1a > 0 )
1932 v11 += v8->pMetrics[v12].uLeftSpacing;
1933 v11 += *((int *)&v8->cFirstChar + 3 * v12 + 9);
1934 if ( (signed int)Str1a < (signed int)v30 )
1935 v11 += v8->pMetrics[v12].uRightSpacing;
1936 goto LABEL_16;
1937 }
1938 }
1939 }
1940 }
1941 LABEL_16:
1942 ++Str1a;
1943 }
1944 while ( (signed int)Str1a < (signed int)v30 );
1945 }
1946 pTmpBuf[Str1a + 1999] = 0;
1947 v30 = strlen(pTmpBuf2);
1948 v28 = v8->GetLineWidth(pTmpBuf2);
1949 if ( a8 )
1950 _strrev(pTmpBuf2);
1951 Str1b = 0;
1952 v13 = uX + a1->uFrameX;
1953 v14 = uY + a1->uFrameY;
1954 if ( (signed int)v30 > 0 )
1955 {
1956 Sourcea = &pTmpBuf2[1];
1957 do
1958 {
1959 if ( v8->IsCharValid(pTmpBuf2[Str1b]) )
1960 {
1961 v16 = v15;
1962 v17 = v15 - 9;
1963 if ( v17 )
1964 {
1965 v18 = v17 - 1;
1966 if ( v18 )
1967 {
1968 v19 = v18 - 2;
1969 if ( v19 )
1970 {
1971 if ( v19 == 1 )
1972 {
1973 strncpy(&Str, Sourcea, 3u);
1974 v26 = 0;
1975 Str1b += 3;
1976 Sourcea += 3;
1977 v22 = atoi(&Str);
1978 v23 = v8->GetLineWidth(&pTmpBuf2[Str1b]);
1979 v13 = a1->uFrameZ - v23 - v22;
1980 v14 = uY;
1981 }
1982 else
1983 {
1984 v20 = *((int *)&v8->cFirstChar + 3 * v16 + 9);
1985 v34 = *((int *)&v8->cFirstChar + 3 * v16 + 9);
1986 if ( (signed int)Str1b > 0 )
1987 v13 += v8->pMetrics[v16].uLeftSpacing;
1988 v21 = (int)((char *)&v8[1] + v8->field_C20[v16]);
1989 if ( (short)uColor )
1990 pRenderer->DrawText(
1991 v13,
1992 v14,
1993 (unsigned __int8 *)v21,
1994 v20,
1995 LOBYTE(v8->uFontHeight),
1996 v8->pFontPalettes[0],
1997 uColor,
1998 0);
1999 else
2000 pRenderer->DrawTextPalette(
2001 v13,
2002 v14,
2003 v21,
2004 v20,
2005 LOBYTE(v8->uFontHeight),
2006 v8->pFontPalettes[0],
2007 0);
2008 v13 += v34;
2009 if ( (signed int)Str1b < (signed int)v30 )
2010 v13 += v8->pMetrics[(unsigned __int8)pTmpBuf2[Str1b]].uRightSpacing;
2011 }
2012 }
2013 else
2014 {
2015 strncpy(&Str, Sourcea, 5u);
2016 v27 = 0;
2017 Str1b += 5;
2018 Sourcea += 5;
2019 uColor = atoi(&Str);
2020 }
2021 }
2022 else
2023 {
2024 v24 = LOBYTE(v8->uFontHeight);
2025 v13 = uX;
2026 uY = uY + v24 - 3;
2027 v14 = v24 + uY - 3;
2028 }
2029 }
2030 else
2031 {
2032 strncpy(&Str, Sourcea, 3u);
2033 v26 = 0;
2034 atoi(&Str);
2035 Str1b += 3;
2036 Sourcea += 3;
2037 }
2038 }
2039 ++Str1b;
2040 ++Sourcea;
2041 }
2042 while ( (signed int)Str1b < (signed int)v30 );
2043 }
2044 return v28;
2045 }
2046
2047 //----- (0041D12F) --------------------------------------------------------
2048 GUIButton *GUIWindow::CreateButton(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, int a6, int a7, unsigned int uControlID, unsigned int uControlParam, unsigned __int8 uHotkey, const char *pName, Texture *pTextures, ...)
2049 {
2050 GUIButton *v12; // esi@1
2051 unsigned int v13; // eax@1
2052 unsigned int v14; // ebx@4
2053 unsigned int v15; // eax@4
2054 unsigned int v16; // ebx@4
2055 unsigned int v17; // eax@4
2056 Texture *v18; // eax@4
2057 Texture **v19; // ecx@5
2058 Texture **v20; // edx@5
2059 GUIButton *v21; // eax@7
2060
2061 v12 = (GUIButton *)pAllocator->AllocNamedChunk(0, 0xBCu, "BUTTON");
2062 v12->pParent = this;
2063 v12->uX = uX + this->uFrameX;
2064 v13 = uY + this->uFrameY;
2065 v12->uHeight = uHeight;
2066 v12->uY = v13;
2067 v12->uWidth = uWidth;
2068 if ( a6 == 2 && !uHeight )
2069 v12->uHeight = uWidth;
2070 v14 = v12->uX;
2071 v12->uButtonType = a6;
2072 v15 = v14 + uWidth - 1;
2073 v16 = 0;
2074 v12->uZ = v15;
2075 v17 = v12->uY;
2076 v12->field_2C = 0;
2077 v12->uW = v17 + uHeight - 1;
2078 v12->field_1C = a7;
2079 v12->uControlID = uControlID;
2080 v12->uControlParam = uControlParam;
2081 v12->uHotkey = uHotkey;
2082 strlen(pName);
2083 strcpy(v12->pButtonName, pName);
2084 v18 = pTextures;
2085 if ( pTextures )
2086 {
2087 v19 = &pTextures;
2088 v20 = v12->pTextures;
2089 do
2090 {
2091 ++v19;
2092 *v20 = v18;
2093 ++v16;
2094 ++v20;
2095 v18 = *v19;
2096 }
2097 while ( *v19 );
2098 }
2099 v12->uNumTextures = v16;
2100 v21 = this->pControlsTail;
2101 if ( v21 )
2102 v21->pNext = v12;
2103 else
2104 this->pControlsHead = v12;
2105 v12->pPrev = this->pControlsTail;
2106 this->pControlsTail = v12;
2107 v12->pNext = 0;
2108 ++this->uNumControls;
2109 return v12;
2110 }
2111
2112 //----- (00459C2B) --------------------------------------------------------
2113 void GUIWindow::DrawFlashingInputCursor(signed int a3, int a4, GUIFont *a2)
2114 {
2115 signed int v4; // esi@1
2116 GUIWindow *v5; // edi@1
2117
2118 v4 = a3;
2119 v5 = this;
2120 if ( GetTickCount() % 1000 > 500 )
2121 DrawText(a2, v4, a4, 0, "_", 0, 0, 0);
2122 }
2123
2124
2125 //----- (0041C432) --------------------------------------------------------
2126 GUIWindow *GUIWindow::Create(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uWindowType, int a4, int a5)
2127 {
2128 unsigned int uNextFreeWindowID; // ebp@1
2129 int *v8; // eax@1
2130 GUIWindow *pWindow; // esi@4
2131 int v10; // eax@4
2132 unsigned int v11; // ebx@15
2133 NPCData *v12; // ebp@15
2134 void *v13; // ecx@18
2135 bool v14; // eax@20
2136 void *v15; // ecx@23
2137 bool v16; // eax@25
2138 void *v17; // ecx@28
2139 bool v18; // eax@30
2140 void *v19; // ecx@33
2141 bool v20; // eax@35
2142 void *v21; // ecx@38
2143 bool v22; // eax@40
2144 void *v23; // ecx@43
2145 bool v24; // eax@45
2146 int v25; // eax@65
2147 unsigned int v26; // ebx@65
2148 char *v27; // eax@71
2149 const char *v29; // [sp-8h] [bp-18h]@68
2150 char *v30; // [sp-4h] [bp-14h]@68
2151 int uWidtha; // [sp+14h] [bp+4h]@66
2152 int a4a; // [sp+20h] [bp+10h]@15
2153
2154 uNextFreeWindowID = 0;
2155 v8 = (int *)&pWindowList[0].uWindowType;
2156 do
2157 {
2158 if ( !*v8 )
2159 break;
2160 v8 += 21;
2161 ++uNextFreeWindowID;
2162 }
2163 while ( (signed int)v8 < (signed int)&pVisibleWindowsIdxs[6] );
2164 pWindow = &pWindowList[uNextFreeWindowID];
2165 pWindow->uFrameWidth = uWidth;
2166 pWindow->uFrameZ = uX + uWidth - 1;
2167 pWindow->uFrameW = uY + uHeight - 1;
2168 pWindow->ptr_1C = (void *)a4;
2169 pWindow->str_48 = (char *)a5;
2170 v10 = uNumVisibleWindows;
2171 pWindow->uFrameX = uX;
2172 ++v10;
2173 pWindow->uFrameY = uY;
2174 pWindow->uFrameHeight = uHeight;
2175 pWindow->uWindowType = uWindowType;
2176 pWindow->field_44 = 0;
2177 uNumVisibleWindows = v10;
2178 pWindow->field_3C = v10;
2179 pVisibleWindowsIdxs[v10] = uNextFreeWindowID + 1;
2180 if ( (signed int)uWindowType <= 20 )
2181 {
2182 if ( uWindowType != 20 )
2183 {
2184 switch ( uWindowType )
2185 {
2186 case 9u:
2187 pWindow->InitializeBookView();
2188 break;
2189 case 0xAu:
2190 dword_506978 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
2191 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 4;
2192 ptr_5076F4 = pWindow->CreateButton(
2193 0x1D7u,
2194 0x1BDu,
2195 0xA9u,
2196 0x23u,
2197 1,
2198 0,
2199 0x71u,
2200 0,
2201 0,
2202 pGlobalTXT_LocalizationStrings[79],
2203 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
2204 0);
2205 if ( pWindow->ptr_1C != (void *)1 )
2206 {
2207 a4a = 0;
2208 v11 = LOBYTE(pFontArrus->uFontHeight) - 3;
2209 v12 = GetNPCData(uDialogue_SpeakingActorNPC_ID);
2210 if ( sub_445C8B(uDialogue_SpeakingActorNPC_ID) == 1 )
2211 {
2212 if ( v12->joins )
2213 {
2214 pWindow->CreateButton(0x1E0u, 0x82u, 0x8Cu, v11, 1, 0, 0x88u, 0xDu, 0, nullstring, 0);
2215 a4a = 1;
2216 }
2217 v13 = (void *)v12->bDrawSomeAnim;
2218 if ( v13 )
2219 {
2220 if ( a4a < 4 )
2221 {
2222 v14 = sub_4466C4(v13);
2223 if ( v14 == 1 || v14 == 2 )
2224 pWindow->CreateButton(
2225 0x1E0u,
2226 a4a++ * v11 + 130,
2227 0x8Cu,
2228 v11,
2229 1,
2230 0,
2231 0x88u,
2232 0x13u,
2233 0,
2234 nullstring,
2235 0);
2236 }
2237 }
2238 v15 = (void *)v12->evtb;
2239 if ( v15 )
2240 {
2241 if ( a4a < 4 )
2242 {
2243 v16 = sub_4466C4(v15);
2244 if ( v16 == 1 || v16 == 2 )
2245 pWindow->CreateButton(
2246 0x1E0u,
2247 a4a++ * v11 + 130,
2248 0x8Cu,
2249 v11,
2250 1,
2251 0,
2252 0x88u,
2253 0x14u,
2254 0,
2255 nullstring,
2256 0);
2257 }
2258 }
2259 v17 = (void *)v12->evtc;
2260 if ( v17 )
2261 {
2262 if ( a4a < 4 )
2263 {
2264 v18 = sub_4466C4(v17);
2265 if ( v18 == 1 || v18 == 2 )
2266 pWindow->CreateButton(
2267 0x1E0u,
2268 a4a++ * v11 + 130,
2269 0x8Cu,
2270 v11,
2271 1,
2272 0,
2273 0x88u,
2274 0x15u,
2275 0,
2276 nullstring,
2277 0);
2278 }
2279 }
2280 v19 = (void *)v12->evtd;
2281 if ( v19 )
2282 {
2283 if ( a4a < 4 )
2284 {
2285 v20 = sub_4466C4(v19);
2286 if ( v20 == 1 || v20 == 2 )
2287 pWindow->CreateButton(
2288 0x1E0u,
2289 a4a++ * v11 + 130,
2290 0x8Cu,
2291 v11,
2292 1,
2293 0,
2294 0x88u,
2295 0x16u,
2296 0,
2297 nullstring,
2298 0);
2299 }
2300 }
2301 v21 = (void *)v12->evte;
2302 if ( v21 )
2303 {
2304 if ( a4a < 4 )
2305 {
2306 v22 = sub_4466C4(v21);
2307 if ( v22 == 1 || v22 == 2 )
2308 pWindow->CreateButton(
2309 0x1E0u,
2310 a4a++ * v11 + 130,
2311 0x8Cu,
2312 v11,
2313 1,
2314 0,
2315 0x88u,
2316 0x17u,
2317 0,
2318 nullstring,
2319 0);
2320 }
2321 }
2322 v23 = (void *)v12->evtf;
2323 if ( v23 )
2324 {
2325 if ( a4a < 4 )
2326 {
2327 v24 = sub_4466C4(v23);
2328 if ( v24 == 1 || v24 == 2 )
2329 pWindow->CreateButton(
2330 0x1E0u,
2331 a4a++ * v11 + 130,
2332 0x8Cu,
2333 v11,
2334 1,
2335 0,
2336 0x88u,
2337 0x18u,
2338 0,
2339 nullstring,
2340 0);
2341 }
2342 }
2343 }
2344 else
2345 {
2346 if ( v12->joins )
2347 {
2348 pWindow->CreateButton(
2349 0x1E0u,
2350 0x82u,
2351 0x8Cu,
2352 v11,
2353 1,
2354 0,
2355 0x88u,
2356 0x4Du,
2357 0,
2358 pGlobalTXT_LocalizationStrings[407],
2359 0);
2360 if ( v12->uFlags & 0x80 )
2361 {
2362 sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[408], v12->pName);
2363 pWindow->CreateButton(0x1E0u, v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x4Cu, 0, pTmpBuf, 0);
2364 }
2365 else
2366 {
2367 pWindow->CreateButton(
2368 0x1E0u,
2369 v11 + 130,
2370 0x8Cu,
2371 v11,
2372 1,
2373 0,
2374 0x88u,
2375 0x4Cu,
2376 0,
2377 pGlobalTXT_LocalizationStrings[406],
2378 0);
2379 }
2380 a4a = 2;
2381 }
2382 }
2383 pWindow->_41D08F(a4a, 1, 0, 1);
2384 }
2385 break;
2386 case 0x11u:
2387 dword_506978 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
2388 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 17;
2389 ptr_5076F4 = pWindow->CreateButton(
2390 0x236u,
2391 0x1BDu,
2392 0x4Bu,
2393 0x21u,
2394 1,
2395 0,
2396 0x5Bu,
2397 0,
2398 0x4Eu,
2399 pGlobalTXT_LocalizationStrings[156],
2400 (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),
2401 0);
2402 ptr_5076FC = pWindow->CreateButton(
2403 0x1E6u,
2404 0x1BDu,
2405 0x4Bu,
2406 0x21u,
2407 1,
2408 0,
2409 0x5Au,
2410 0,
2411 0x59u,
2412 pWindow->str_48,
2413 (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0),
2414 0);
2415 pWindow->CreateButton(
2416 _4E5E50_transui_x,
2417 _4E5EE0_transui_y,
2418 0x3Fu,
2419 0x49u,
2420 1,
2421 0,
2422 0x5Au,
2423 1u,
2424 0x20u,
2425 pWindow->str_48,
2426 0,
2427 0,
2428 0);
2429 pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, 0x5Au, 1u, 0, pWindow->str_48, 0);
2430 break;
2431 case 0x12u:
2432 InitializeBookTextures();
2433 pWindow->_411621();
2434 break;
2435 case 0x13u:
2436 dword_506978 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
2437 pKeyActionMap->_459E5A(0, 15, pWindow);
2438 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 19;
2439 break;
2440 }
2441 return pWindow;
2442 }
2443 LABEL_62:
2444 pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
2445 pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
2446 pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
2447 pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
2448 pWindow->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, nullstring, 0);
2449 return pWindow;
2450 }
2451 if ( uWindowType == 25 )
2452 {
2453 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 13;
2454 ptr_5076F4 = pWindow->CreateButton(
2455 0x1D7u,
2456 0x1BDu,
2457 0xA9u,
2458 0x23u,
2459 1,
2460 0,
2461 0x71u,
2462 0,
2463 0,
2464 pGlobalTXT_LocalizationStrings[80],
2465 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
2466 0);
2467 v25 = uNumDialogueNPCPortraits;
2468 v26 = 0;
2469 if ( uNumDialogueNPCPortraits > 0 )
2470 {
2471 do
2472 {
2473 uWidtha = v26 + 1;
2474 if ( v26 + 1 == v25 && uHouse_ExitPic )
2475 {
2476 v30 = pMapStats->pInfos[uHouse_ExitPic].pName;
2477 v29 = pGlobalTXT_LocalizationStrings[411];
2478 }
2479 else
2480 {
2481 if ( v26 || !dword_591080 )
2482 v27 = array_5913D8[v26 - (dword_591080 != 0)]->pName;
2483 else
2484 //v27 = (char *)p2DEvents_minus1_::08[13 * a4];
2485 v27 = (char *)p2DEvents[a4 - 1].pProprieterName;
2486 v30 = v27;
2487 v29 = pGlobalTXT_LocalizationStrings[435];
2488 }
2489 sprintfex(&byte_591180[100 * v26], v29, v30);
2490 array_5913D8[v26 + 7] = (NPCData *)pWindow->CreateButton(
2491 *(&_4E5E50_transui_x + v26 + 6 * uNumDialogueNPCPortraits - 6),
2492 *(&_4E5EE0_transui_y + v26 + 6 * uNumDialogueNPCPortraits - 6),
2493 0x3Fu,
2494 0x49u,
2495 1,
2496 0,
2497 0x19Au,
2498 v26,
2499 0,
2500 &byte_591180[100 * v26],
2501 0,
2502 0,
2503 0);
2504 ++v26;
2505 v25 = uNumDialogueNPCPortraits;
2506 }
2507 while ( uWidtha < uNumDialogueNPCPortraits );
2508 }
2509 if ( v25 == 1 )
2510 {
2511 ptr_507BC0 = &pWindowList[uNextFreeWindowID];
2512 _4B4224_UpdateNPCTopics(0);
2513 }
2514 }
2515 else
2516 {
2517 if ( uWindowType == 26 )
2518 {
2519 dword_506978 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
2520 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 18;
2521 ptr_5076F4 = pWindow->CreateButton(
2522 0x236u,
2523 0x1BDu,
2524 0x4Bu,
2525 0x21u,
2526 1,
2527 0,
2528 0x19Cu,
2529 0,
2530 0x4Eu,
2531 pGlobalTXT_LocalizationStrings[34],
2532 (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),
2533 0);
2534 ptr_5076FC = pWindow->CreateButton(
2535 0x1E6u,
2536 0x1BDu,
2537 0x4Bu,
2538 0x21u,
2539 1,
2540 0,
2541 0x19Bu,
2542 0,
2543 0x59u,
2544 pWindow->str_48,
2545 (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0),
2546 0);
2547 pWindow->CreateButton(
2548 _4E5E50_transui_x,
2549 _4E5EE0_transui_y,
2550 0x3Fu,
2551 0x49u,
2552 1,
2553 0,
2554 0x19Bu,
2555 1u,
2556 0x20u,
2557 pWindow->str_48,
2558 0);
2559 pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, 0x19Bu, 1u, 0, pWindow->str_48, 0);
2560 return pWindow;
2561 }
2562 if ( uWindowType == 27 )
2563 {
2564 pEventTimer->Pause();
2565 pAudioPlayer->StopChannels(-1, -1);
2566 pMouse->SetCursorBitmap("MICON2");
2567 ShowStatusBarString(pGlobalTXT_LocalizationStrings[39], 2u);
2568 return pWindow;
2569 }
2570 if ( uWindowType == 30 )
2571 goto LABEL_62;
2572 if ( uWindowType == 31 )
2573 {
2574 pMouse->SetCursorBitmap("MICON2");
2575 ptr_5076F4 = pWindow->CreateButton(
2576 0x188u,
2577 0x13Eu,
2578 0x4Bu,
2579 0x21u,
2580 1,
2581 0,
2582 0x71u,
2583 0,
2584 0,
2585 pGlobalTXT_LocalizationStrings[34],
2586 (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),
2587 0);
2588 ShowStatusBarString(pGlobalTXT_LocalizationStrings[39], 2u);
2589 ++pIcons_LOD->uTexturePacksCount;
2590 pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
2591 uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 23;
2592 if ( !pIcons_LOD->uNumPrevLoadedFiles )
2593 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
2594 }
2595 }
2596 return pWindow;
2597 }