comparison GUI/UI/Books/LloydsBook.cpp @ 2548:87e5590d034b

All Books windows are refactored into respective classes
author a.parshin
date Tue, 12 May 2015 03:24:19 +0200
parents
children d87bfbd3bb3b
comparison
equal deleted inserted replaced
2547:fed97f15d1e1 2548:87e5590d034b
1 #include "Engine/Engine.h"
2 #include "Engine/LOD.h"
3 #include "Engine/Party.h"
4 #include "Engine/texts.h"
5 #include "Engine/Graphics/IRender.h"
6
7 #include "GUI/GUIFont.h"
8 #include "GUI/UI/Books/LloydsBook.h"
9
10
11 std::array<unsigned int, 5> pLloydsBeaconsPreviewXs = { { 61, 281, 61, 281, 171 } }; // 004E249C
12 std::array<unsigned int, 5> pLloydsBeaconsPreviewYs = { { 84, 84, 228, 228, 155 } };
13 std::array<unsigned int, 5> pLloydsBeacons_SomeXs = { { 59, 279, 59, 279, 169 } };
14 std::array<unsigned int, 5> pLloydsBeacons_SomeYs = { { 82, 82, 226, 226, 153 } };
15
16 GUIWindow_LloydsBook::GUIWindow_LloydsBook() :
17 GUIWindow_Book()
18 {
19 this->ptr_1C = (void *)WINDOW_LloydsBeacon; // inherited from GUIWindow::GUIWindow
20 BasicBookInitialization();
21
22 // ----------------------------------------------
23 // 00411BFC GUIWindow::InitializeBookView -- part
24 byte_506360 = 0;
25 pTexture_CurrentBook = pIcons_LOD->LoadTexturePtr("lb_bordr", TEXTURE_16BIT_PALETTE);
26 pTexture_LloydBeacons[0] = pIcons_LOD->LoadTexturePtr("sbmap", TEXTURE_16BIT_PALETTE);
27 pTexture_LloydBeacons[1] = pIcons_LOD->LoadTexturePtr("sbmap", TEXTURE_16BIT_PALETTE);
28 pTex_book_button1_on = pIcons_LOD->LoadTexturePtr("tab-an-6b", TEXTURE_16BIT_PALETTE);
29 pTex_book_button1_off = pIcons_LOD->LoadTexturePtr("tab-an-6a", TEXTURE_16BIT_PALETTE);
30
31 pBtn_Book_1 = CreateButton(415, 13, 39, 36, 1, 0, UIMSG_LloydsBeacon_FlippingBtn, 0, 0, pGlobalTXT_LocalizationStrings[375], 0); // Set Beacon
32 pBtn_Book_2 = CreateButton(415, 48, 39, 36, 1, 0, UIMSG_LloydsBeacon_FlippingBtn, 1, 0, pGlobalTXT_LocalizationStrings[523], 0); // Recall Beacon
33
34 int max_beacons = 1;
35 int v18 = pParty->pPlayers[_506348_current_lloyd_playerid].pActiveSkills[PLAYER_SKILL_WATER];
36 if (v18 & 0x100 || (v18 & 0x80))
37 max_beacons = 5;
38 else if (v18 & 0x40)
39 max_beacons = 3;
40
41 for (int i = 0; i < max_beacons; ++i)
42 CreateButton(
43 pLloydsBeaconsPreviewXs[i], pLloydsBeaconsPreviewYs[i],
44 92, 68, 1, 180, UIMSG_InstallBeacon, i, 0, "", 0
45 );
46
47 for (int i = 0; i < 5; ++i)
48 {
49 if (pParty->pPlayers[_506348_current_lloyd_playerid].pInstalledBeacons[i].uBeaconTime >= (signed __int64)pParty->uTimePlayed)
50 LoadThumbnailLloydTexture(i, _506348_current_lloyd_playerid + 1);
51 else
52 memset(&pParty->pPlayers[_506348_current_lloyd_playerid].pInstalledBeacons[i], 0, sizeof(LloydBeacon));
53 }
54 }
55
56
57 void GUIWindow_LloydsBook::Update()
58 {
59 // -----------------------------------
60 // 004156F0 GUI_UpdateWindows --- part
61 // {
62 // BookUI_Draw((WindowType)(int)ptr_1C);
63 // }
64
65 // ----- (00413CC6) --------------------------------------------------------
66 // void BookUI_Draw(WindowType book) --- part
67 // {
68 pRenderer->DrawTextureIndexed(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId));
69 // DrawLloydBeaconsScreen();
70
71 // ----- (00410DEC) --------------------------------------------------------
72 // unsigned int DrawLloydBeaconsScreen()
73 // {
74 Player *pPlayer; // esi@1
75 const char *pText; // eax@1
76 int pTextHeight; // eax@14
77 int RemainingTime; // kr08_8@14
78 unsigned int pHours; // esi@14
79 unsigned int pDays; // eax@14
80 const char *pSelectionText; // eax@19
81 Texture *v19; // [sp-4h] [bp-8Ch]@4
82 GUIWindow pWindow; // [sp+Ch] [bp-7Ch]@1
83 char *Str; // [sp+74h] [bp-14h]@14
84 int BeaconID; // [sp+78h] [bp-10h]@11
85 int uNumMaxBeacons; // [sp+84h] [bp-4h]@6
86
87 pPlayer = &pParty->pPlayers[_506348_current_lloyd_playerid];
88 pRenderer->DrawTextureIndexed(8, 8, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]);
89 pText = pGlobalTXT_LocalizationStrings[523]; // Recall Beacon
90 pWindow.uFrameX = game_viewport_x;
91 pWindow.uFrameY = game_viewport_y;
92 pWindow.uFrameWidth = 428;
93 pWindow.uFrameHeight = game_viewport_height;
94 pWindow.uFrameZ = 435;
95 pWindow.uFrameW = game_viewport_w;
96 if (!bRecallingBeacon)
97 pText = pGlobalTXT_LocalizationStrings[375]; // Set Beacon
98 sprintf(pTmpBuf.data(), "%s", pText);
99 pWindow.DrawTitleText(pBook2Font, 0, 22, 0, pTmpBuf.data(), 3);
100 if (bRecallingBeacon)
101 {
102 pRenderer->DrawTextureIndexedAlpha(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_book_button1_on);
103 v19 = pTex_book_button1_off;
104 }
105 else
106 {
107 pRenderer->DrawTextureIndexedAlpha(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_book_button1_off);
108 v19 = pTex_book_button1_on;
109 }
110 pRenderer->DrawTextureIndexedAlpha(pBtn_Book_2->uX, pBtn_Book_2->uY, v19);
111 uNumMaxBeacons = 1;
112 if (HIBYTE(pPlayer->pActiveSkills[PLAYER_SKILL_WATER]) & 1 || (pPlayer->pActiveSkills[PLAYER_SKILL_WATER] & 0x80u) != 0)
113 {
114 uNumMaxBeacons = 5;
115 }
116 else
117 {
118 if (pPlayer->pActiveSkills[PLAYER_SKILL_WATER] & 0x40)
119 uNumMaxBeacons = 3;
120 }
121 if (uNumMaxBeacons > 0)
122 {
123 for (BeaconID = 0; BeaconID < uNumMaxBeacons; BeaconID++)
124 {
125 pWindow.uFrameWidth = 92;
126 pWindow.uFrameHeight = 68;
127 pWindow.uFrameY = pLloydsBeaconsPreviewYs[BeaconID];
128 pWindow.uFrameX = pLloydsBeaconsPreviewXs[BeaconID];
129 pWindow.uFrameW = pWindow.uFrameY + 67;
130 pWindow.uFrameZ = pLloydsBeaconsPreviewXs[BeaconID] + 91;
131 //if ( pSavegameThumbnails[BeaconID].pPixels != 0 )
132 if (pPlayer->pInstalledBeacons[BeaconID].SaveFileID != 0)
133 {
134 pRenderer->DrawTextureIndexedAlpha(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
135 pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[BeaconID], pLloydsBeaconsPreviewYs[BeaconID], &pSavegameThumbnails[BeaconID]);
136 Str = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(pPlayer->pInstalledBeacons[BeaconID].SaveFileID)].pName;
137 pTextHeight = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0);
138 pWindow.uFrameY += -6 - pTextHeight;
139 pWindow.DrawTitleText(pSpellFont, 0, 0, 1, Str, 3);
140 RemainingTime = pPlayer->pInstalledBeacons[BeaconID].uBeaconTime - pParty->uTimePlayed;
141 pHours = (signed __int64)((double)RemainingTime * 0.234375) / 60 / 60;
142 pDays = pHours / 24;
143 if (pDays)
144 {
145 sprintf(pTmpBuf.data(), "%lu %s", pDays + 1, pGlobalTXT_LocalizationStrings[57]);//days
146 pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
147 pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
148 continue;
149 }
150 else
151 {
152 if (pHours + 1 <= 23)
153 {
154 if (pHours < 1)
155 pSelectionText = pGlobalTXT_LocalizationStrings[109];// Hour
156 else
157 pSelectionText = pGlobalTXT_LocalizationStrings[110];// Hours
158 sprintf(pTmpBuf.data(), "%lu %s", pHours + 1, pSelectionText);
159 pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
160 pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
161 continue;
162 }
163 }
164 sprintf(pTmpBuf.data(), "%lu %s", pDays + 1, pGlobalTXT_LocalizationStrings[56]);//Day
165 pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
166 pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
167 continue;
168 }
169 if (!bRecallingBeacon)
170 {
171 pRenderer->DrawTextureIndexedAlpha(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
172 pTextHeight = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0);
173 pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - pTextHeight / 2, 1, pGlobalTXT_LocalizationStrings[19], 3);//Доступно
174 }
175 }
176 }
177 if (byte_506360)
178 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_CloseAfterInstallBeacon, 0, 0);
179 }