Mercurial > mm7
annotate GUI/UI/UIShops.cpp @ 2553:48708da03b7f
Party Creation UI logic separated from MainMenu
author | a.parshin |
---|---|
date | Wed, 13 May 2015 02:20:05 +0200 |
parents | c674d547cc7c |
children | 0c67be4ec900 |
rev | line source |
---|---|
2501 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
5 #define _CRT_SECURE_NO_WARNINGS | |
2541 | 6 |
7 #include "Engine/Engine.h" | |
8 | |
2501 | 9 #include "UIShops.h" |
10 #include "..\../Engine/Objects/Items.h" | |
2502 | 11 #include "..\../GUI/GUIWindow.h" |
2501 | 12 #include "..\../Engine/texts.h" |
13 #include "UIHouses.h" | |
2502 | 14 #include "..\../GUI/GUIFont.h" |
2501 | 15 #include "..\../Engine/Graphics/Render.h" |
16 #include "..\../Engine/Party.h" | |
17 #include "..\../Engine/Graphics/Texture.h" | |
2502 | 18 #include "..\../IO/Mouse.h" |
2501 | 19 #include "..\../Engine/Events2D.h" |
2502 | 20 #include "..\../Media/Audio/AudioPlayer.h" |
2501 | 21 #include "..\../Engine/MapInfo.h" |
22 #include "..\../Engine/Graphics/Viewport.h" | |
23 #include "..\../Engine/Graphics/Outdoor.h" | |
24 #include "..\../Engine/Graphics/Indoor.h" | |
25 | |
26 | |
27 | |
28 //----- (004B910F) -------------------------------------------------------- | |
29 void WeaponShopDialog() | |
30 { | |
31 int phrases_id; // eax@16 | |
32 int v19; // edi@25 | |
33 GUIButton *pButton; // esi@27 | |
34 unsigned int pColorText; // ax@27 | |
35 signed int v32; // esi@41 | |
36 const char *pText; // ecx@84 | |
37 int all_text_height; // esi@96 | |
38 ItemGen *item; | |
39 int pItemID; | |
40 POINT mouse; // [sp+64h] [bp-94h]@8 | |
41 GUIWindow dialog_window; // [sp+7Ch] [bp-7Ch]@1 | |
42 __int32 v103; // [sp+D4h] [bp-24h]@25 | |
43 int pPrice; // [sp+ECh] [bp-Ch]@26 | |
44 unsigned int v109; | |
45 int pNumString; | |
46 int item_X; | |
47 | |
48 memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); | |
49 dialog_window.uFrameX = 483; | |
50 dialog_window.uFrameWidth = 148; | |
51 dialog_window.uFrameZ = 334; | |
52 | |
53 switch(dialog_menu_id) | |
54 { | |
55 case HOUSE_DIALOGUE_MAIN: | |
56 { | |
57 if ( HouseUI_CheckIfPlayerCanInteract() ) | |
58 { | |
59 pShopOptions[0] = const_cast<char *>(pGlobalTXT_LocalizationStrings[134]); | |
60 pShopOptions[1] = const_cast<char *>(pGlobalTXT_LocalizationStrings[152]); | |
61 pShopOptions[2] = const_cast<char *>(pGlobalTXT_LocalizationStrings[159]); | |
62 pShopOptions[3] = const_cast<char *>(pGlobalTXT_LocalizationStrings[160]); | |
63 all_text_height = 0; | |
64 for ( int i = 0; i < 4; ++i ) | |
65 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); | |
66 v103 = (174 - all_text_height) / 4; | |
67 v19 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138; | |
68 pNumString = 0; | |
69 for ( int i = pDialogueWindow->pStartingPosActiveItem; i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) | |
70 { | |
71 pButton = pDialogueWindow->GetControl(i); | |
72 pButton->uY = v103 + v19; | |
73 pButton->uHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0); | |
74 v19 = pButton->uY + pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0) - 1; | |
75 pButton->uW = v19; | |
76 pColorText = Color16(0xE1u, 0xCDu, 0x23u); | |
77 if ( pDialogueWindow->pCurrentPosActiveItem != i ) | |
78 pColorText = Color16(0xFFu, 0xFFu, 0xFFu); | |
79 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pShopOptions[pNumString], 3); | |
80 ++pNumString; | |
81 } | |
82 } | |
83 break; | |
84 } | |
85 case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: | |
86 { | |
87 pRenderer->DrawTextureIndexed(8, 8, ShopTexture); | |
88 item_X = 0; | |
89 for ( uint i = 0; i < 6; ++i ) | |
90 { | |
91 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID) | |
92 { | |
2524 | 93 pRenderer->DrawTextureIndexedAlpha((60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X, weapons_Ypos[i] + 30, ItemsInShopTexture[i]); |
2501 | 94 ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[(60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X + window->GetWidth() * (weapons_Ypos[i] + 30)], ItemsInShopTexture[i], i + 1); |
95 } | |
96 item_X += 70; | |
97 } | |
98 if ( HouseUI_CheckIfPlayerCanInteract() ) | |
99 { | |
100 uint item_num = 0; | |
101 for ( uint i = 0; i < 6; ++i ) | |
102 { | |
103 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID) | |
104 ++item_num; | |
105 } | |
106 if ( GetAsyncKeyState(VK_CONTROL) && pPlayers[uActiveCharacter]->CanSteal() ) | |
107 pText = pGlobalTXT_LocalizationStrings[185];//Украсть предмет | |
108 else | |
109 pText = pGlobalTXT_LocalizationStrings[195];//Выберите предмет для покупки | |
110 DrawTextAtStatusBar(pText, 0); | |
111 if ( item_num ) | |
112 { | |
113 pMouse->GetCursorPos(&mouse); | |
114 if ( pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF ) | |
115 { | |
116 item = &pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1]; | |
117 if ( !GetAsyncKeyState(VK_CONTROL) || !pPlayers[uActiveCharacter]->CanSteal() ) | |
118 { | |
119 pText = BuildDialogueString(pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 2)], | |
120 uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); | |
121 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
122 } | |
123 else | |
124 { | |
125 pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); | |
126 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
127 } | |
128 } | |
129 } | |
130 else | |
131 dialog_window.DrawShops_next_generation_time_string(pParty->PartyTimes.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);//Приходите через 7 дней | |
132 } | |
133 break; | |
134 } | |
135 | |
136 case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: | |
137 { | |
138 pRenderer->DrawTextureIndexed(8, 8, ShopTexture); | |
139 item_X = 0; | |
140 for ( uint i = 0; i < 6; ++i ) | |
141 { | |
142 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID) | |
143 { | |
2524 | 144 pRenderer->DrawTextureIndexedAlpha((60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X, weapons_Ypos[i] + 30, ItemsInShopTexture[i]); |
2501 | 145 ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[(60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X + window->GetWidth() * (weapons_Ypos[i] + 30)], ItemsInShopTexture[i], i + 1); |
146 } | |
147 item_X += 70; | |
148 } | |
149 if ( HouseUI_CheckIfPlayerCanInteract() ) | |
150 { | |
151 uint item_num = 0; | |
152 for ( uint i = 0; i < 6; ++i ) | |
153 { | |
154 if ( pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID ) | |
155 ++item_num; | |
156 } | |
157 if ( GetAsyncKeyState(VK_CONTROL) && pPlayers[uActiveCharacter]->CanSteal() ) | |
158 pText = pGlobalTXT_LocalizationStrings[185]; | |
159 else | |
160 pText = pGlobalTXT_LocalizationStrings[196]; | |
161 DrawTextAtStatusBar(pText, 0); | |
162 if ( item_num ) | |
163 { | |
164 pMouse->GetCursorPos(&mouse); | |
165 if ( pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF ) | |
166 { | |
167 item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1]; | |
168 if ( !GetAsyncKeyState(VK_CONTROL) || !pPlayers[uActiveCharacter]->CanSteal() ) | |
169 { | |
170 pText = BuildDialogueString(pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 2)], | |
171 uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); | |
172 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
173 } | |
174 else | |
175 { | |
176 pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); | |
177 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
178 } | |
179 } | |
180 } | |
181 else | |
182 dialog_window.DrawShops_next_generation_time_string(pParty->PartyTimes.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); | |
183 } | |
184 break; | |
185 } | |
186 | |
187 case HOUSE_DIALOGUE_SHOP_SELL: | |
188 { | |
189 draw_leather(); | |
190 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
191 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0); | |
192 if ( !HouseUI_CheckIfPlayerCanInteract() ) | |
193 return; | |
194 pMouse->GetCursorPos(&mouse); | |
195 v109 = ((mouse.x + 14) >> 5) + 14 * ((mouse.y - 17) >> 5); | |
196 if( mouse.x <= 13 || mouse.x >= 462 ) | |
197 return; | |
198 pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v109); | |
199 if ( !pItemID ) | |
200 return; | |
201 item = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1]; | |
202 phrases_id = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3); | |
203 pText = BuildDialogueString(pMerchantsSellPhrases[phrases_id], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0); | |
204 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
205 break; | |
206 } | |
207 case HOUSE_DIALOGUE_SHOP_IDENTIFY: | |
208 { | |
209 draw_leather(); | |
210 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
211 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); | |
212 if ( !HouseUI_CheckIfPlayerCanInteract() ) | |
213 return; | |
214 pMouse->GetCursorPos(&mouse); | |
215 v109 = ((mouse.x - 14) >> 5) + 14 * ((mouse.y - 17) >> 5); | |
216 if( mouse.x <= 13 || mouse.x >= 462 ) | |
217 return; | |
218 pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v109); | |
219 if ( !pItemID ) | |
220 return; | |
221 item = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1]; | |
222 if (!item->IsIdentified()) | |
223 { | |
224 phrases_id = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4); | |
225 pText = BuildDialogueString(pMerchantsIdentifyPhrases[phrases_id], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); | |
226 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
227 } | |
228 else | |
229 { | |
230 pText = BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); | |
231 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
232 } | |
233 break; | |
234 } | |
235 | |
236 case HOUSE_DIALOGUE_SHOP_REPAIR: | |
237 { | |
238 draw_leather(); | |
239 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
240 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0); | |
241 if ( !HouseUI_CheckIfPlayerCanInteract()) | |
242 return; | |
243 pMouse->GetCursorPos(&mouse); | |
244 v109 = ((mouse.x - 14) >> 5) + 14 * (mouse.y - 17) >> 5; | |
245 if( ( mouse.x <= 13) || mouse.x >= 462 ) | |
246 return; | |
247 pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v109); | |
248 if ( !pItemID || (!(pPlayers[uActiveCharacter]->pOwnItems[pItemID - 1].uAttributes & 2)) ) | |
249 return; | |
250 item = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1]; | |
251 phrases_id = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5); | |
252 pText = BuildDialogueString(pMerchantsRepairPhrases[phrases_id], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0); | |
253 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
254 return; | |
255 } | |
256 break; | |
257 | |
258 case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: | |
259 { | |
260 draw_leather(); | |
261 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
262 pShopOptions[0] = const_cast<char *>(pGlobalTXT_LocalizationStrings[200]);//sell | |
263 pShopOptions[1] = const_cast<char *>(pGlobalTXT_LocalizationStrings[113]);//identify | |
264 pShopOptions[2] = const_cast<char *>(pGlobalTXT_LocalizationStrings[179]);//repair | |
265 all_text_height = 0; | |
266 for ( int i = 0; i < 3; ++i ) | |
267 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); | |
268 v103 = (174 - all_text_height) / 3; | |
269 v19 = (3 * (58 - (signed int)v103) - all_text_height) / 2 - ((174 - all_text_height) / 3) / 2 + 138; | |
270 pNumString = 0; | |
271 for ( int i = pDialogueWindow->pStartingPosActiveItem; i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) | |
272 { | |
273 pButton = pDialogueWindow->GetControl(i); | |
274 pButton->uY = v103 + v19; | |
275 pButton->uHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0); | |
276 v19 = pButton->uY + pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0) - 1; | |
277 pButton->uW = v19; | |
278 pColorText = Color16(0xE1u, 0xCDu, 0x23u); | |
279 if ( pDialogueWindow->pCurrentPosActiveItem != i ) | |
280 pColorText = Color16(0xFFu, 0xFFu, 0xFFu); | |
281 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pShopOptions[pNumString], 3); | |
282 ++pNumString; | |
283 } | |
284 break; | |
285 } | |
286 | |
287 case HOUSE_DIALOGUE_LEARN_SKILLS: | |
288 { | |
289 if (!HouseUI_CheckIfPlayerCanInteract()) | |
290 return; | |
291 uint item_num = 0; | |
292 all_text_height = 0; | |
293 v32 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); | |
294 pPrice = v32 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; | |
295 if ( pPrice < v32 / 3 ) | |
296 pPrice = v32 / 3; | |
297 for ( int i = pDialogueWindow->pStartingPosActiveItem; | |
298 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) | |
299 { | |
300 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pDialogueWindow->GetControl(i)->msg_param - 36] | |
301 && !pPlayers[uActiveCharacter]->pActiveSkills[pDialogueWindow->GetControl(i)->msg_param - 36] ) | |
302 { | |
303 all_text_height += pFontArrus->CalcTextHeight(pSkillNames[pDialogueWindow->GetControl(i)->msg_param - 36], &dialog_window, 0, 0); | |
304 item_num++; | |
305 } | |
306 } | |
307 if ( item_num ) | |
308 { | |
309 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pPrice);//Стоимость навыка: %lu | |
310 dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); | |
311 v103 = (149 - all_text_height) / item_num; | |
312 if ( (149 - all_text_height) / item_num > 32 ) | |
313 v103 = 32; | |
314 v19 = (149 - item_num * v103 - all_text_height) / 2 - v103 / 2 + 162; | |
315 for ( uint i = pDialogueWindow->pStartingPosActiveItem; | |
316 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) | |
317 { | |
318 pButton = pDialogueWindow->GetControl(i); | |
319 if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pButton->msg_param - 36] || pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param - 36] ) | |
320 { | |
321 pButton->uW = 0; | |
322 pButton->uHeight = 0; | |
323 pButton->uY = 0; | |
324 } | |
325 else | |
326 { | |
327 pButton->uY = v103 + v19; | |
328 pButton->uHeight = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0); | |
329 v19 = pButton->uY + pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0) - 1; | |
330 pButton->uW = v19; | |
331 pColorText = Color16(0xE1u, 0xCDu, 0x23u); | |
332 if ( pDialogueWindow->pCurrentPosActiveItem != i ) | |
333 pColorText = Color16(0xFFu, 0xFFu, 0xFFu); | |
334 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[pButton->msg_param - 36], 3); | |
335 } | |
336 } | |
337 break; | |
338 } | |
339 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); | |
340 strcat(pTmpBuf.data(), "\n \n"); | |
341 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);//Больше ничего не могу предложить. | |
342 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, Color16(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3); | |
343 return; | |
344 } | |
345 default: | |
346 { | |
347 __debugbreak(); | |
348 break; | |
349 } | |
350 } | |
351 } | |
352 | |
353 //----- (004BA928) -------------------------------------------------------- | |
354 void ArmorShopDialog() | |
355 { | |
356 int phrases_id; // eax@20 | |
357 int all_text_height; // ebx@22 | |
358 int v146; // [sp+E4h] [bp-20h]@24 | |
359 int v23; // ebx@24 | |
360 GUIButton *pButton; // eax@26 | |
361 signed int v38; // esi@42 | |
362 int v59; // eax@68 | |
363 const char *pText; // ecx@91 | |
364 ItemGen *selected_item; // ecx@99 | |
365 int pNumString; // edx@109 | |
366 unsigned __int16 pTextColor; // ax@109 | |
367 POINT mouse; // [sp+4Ch] [bp-B8h]@97 | |
368 GUIWindow dialog_window; // [sp+8Ch] [bp-78h]@1 | |
369 __int32 pItemCount; // [sp+F0h] [bp-14h]@8 | |
370 int item_x; // [sp+100h] [bp-4h]@44 | |
371 int pPrice; | |
372 unsigned int v153; | |
373 | |
374 memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); | |
375 dialog_window.uFrameX = 483; | |
376 dialog_window.uFrameWidth = 148; | |
377 dialog_window.uFrameZ = 334; | |
378 switch (dialog_menu_id) | |
379 { | |
380 case HOUSE_DIALOGUE_MAIN: | |
381 { | |
382 if ( !HouseUI_CheckIfPlayerCanInteract() ) | |
383 return; | |
384 pShopOptions[0] = const_cast<char *>(pGlobalTXT_LocalizationStrings[134]); //"Buy Standard" | |
385 pShopOptions[1] = const_cast<char *>(pGlobalTXT_LocalizationStrings[152]); //"Buy Special" | |
386 pShopOptions[2] = const_cast<char *>(pGlobalTXT_LocalizationStrings[159]); //"Display Inventory" | |
387 pShopOptions[3] = const_cast<char *>(pGlobalTXT_LocalizationStrings[160]); | |
388 all_text_height = 0; | |
389 for( int i = 0; i < 4; ++i ) | |
390 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); | |
391 v146 = ( 174 - all_text_height ) / 4; | |
392 v23 = ( 174 - 4 * ( 174 - all_text_height ) / 4 - all_text_height ) / 2 - ( 174 - all_text_height ) / 4 / 2 + 138; | |
393 pNumString = 0; | |
394 for (int i = pDialogueWindow->pStartingPosActiveItem; | |
395 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i) | |
396 { | |
397 pButton = pDialogueWindow->GetControl(i); | |
398 pButton->uY = v146 + v23; | |
399 pButton->uHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0); | |
400 v23 = pButton->uY + pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0) - 1; | |
401 pButton->uW = v23; | |
402 pTextColor = Color16(0xE1u, 0xCDu, 0x23u); | |
403 if ( pDialogueWindow->pCurrentPosActiveItem != i ) | |
404 pTextColor = Color16(0xFFu, 0xFFu, 0xFFu); | |
405 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[pNumString], 3); | |
406 ++pNumString; | |
407 } | |
408 } | |
409 break; | |
410 | |
411 case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: | |
412 { | |
413 pRenderer->DrawTextureIndexed(8, 8, ShopTexture);// подложка | |
414 item_x = 0; | |
415 for ( int i = 0; i < 8; ++i )// разместить вещи | |
416 { | |
417 if ( pParty->StandartItemsInShops[window_SpeakInHouse->par1C][i].uItemID) | |
418 { | |
419 if ( i >= 4 ) //low row | |
420 { | |
2524 | 421 pRenderer->DrawTextureIndexedAlpha((90 - (ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x - 420, 126, ItemsInShopTexture[i]); |
2501 | 422 v59 = (90 - (ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x + 80220; |
423 } | |
424 else | |
425 { | |
2524 | 426 pRenderer->DrawTextureIndexedAlpha(( 86 - (ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x, 98 - ItemsInShopTexture[i]->uTextureHeight, ItemsInShopTexture[i]); |
2501 | 427 v59 = item_x + (86 - (ItemsInShopTexture[i]->uTextureWidth / 2)) + window->GetWidth() * (98 - ItemsInShopTexture[i]->uTextureHeight); |
428 } | |
429 ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v59], ItemsInShopTexture[i], i + 1); | |
430 } | |
431 item_x += 105; | |
432 } | |
433 if ( !HouseUI_CheckIfPlayerCanInteract() ) | |
434 return; | |
435 pItemCount = 0; | |
436 for ( int i = 0; i < 8; ++i ) | |
437 { | |
438 if ( pParty->StandartItemsInShops[window_SpeakInHouse->par1C][i].uItemID ) | |
439 ++pItemCount; | |
440 } | |
441 if ( GetAsyncKeyState(VK_CONTROL) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 ) | |
442 pText = pGlobalTXT_LocalizationStrings[195]; //"Select the Item to Buy" | |
443 else | |
444 pText = pGlobalTXT_LocalizationStrings[185];//"Steal item" | |
445 DrawTextAtStatusBar(pText, 0); | |
446 if ( pItemCount ) | |
447 { | |
448 pMouse->GetCursorPos(&mouse); | |
449 if ( !(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) ) | |
450 return; | |
451 selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1]; | |
452 if ( !GetAsyncKeyState(VK_CONTROL) || !pPlayers[uActiveCharacter]->CanSteal()) | |
453 { | |
454 pText = BuildDialogueString(pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2)], | |
455 uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); | |
456 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
457 } | |
458 else | |
459 { | |
460 pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); //"Steal %24" | |
461 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
462 } | |
463 return; | |
464 } | |
465 dialog_window.DrawShops_next_generation_time_string(pParty->PartyTimes.Shops_next_generation_time[window_SpeakInHouse->par1C]- pParty->uTimePlayed); | |
466 return; | |
467 } | |
468 break; | |
469 | |
470 case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: | |
471 { | |
472 pRenderer->DrawTextureIndexed(8, 8, ShopTexture); | |
473 item_x = 0; | |
474 for ( int i = 0; i < 8; ++i ) | |
475 { | |
476 if ( pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][i].uItemID ) | |
477 { | |
478 if ( i >= 4 ) | |
479 { | |
2524 | 480 pRenderer->DrawTextureIndexedAlpha(item_x + (90 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) - 420, 126, ItemsInShopTexture[i]); |
2501 | 481 v59 = item_x + (90 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + 80220; |
482 } | |
483 else | |
484 { | |
2524 | 485 pRenderer->DrawTextureIndexedAlpha(86 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2) + item_x, 98 - ItemsInShopTexture[i]->uTextureHeight, ItemsInShopTexture[i]); |
2501 | 486 v59 = (86 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x + window->GetWidth() * (98 - ItemsInShopTexture[i]->uTextureHeight); |
487 } | |
488 ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v59], ItemsInShopTexture[i], i + 1); | |
489 } | |
490 item_x += 105; | |
491 } | |
492 if ( !HouseUI_CheckIfPlayerCanInteract() ) | |
493 return; | |
494 pItemCount = 0; | |
495 for ( uint i = 0; i < 6; ++i ) | |
496 { | |
497 if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][i].uItemID) | |
498 ++pItemCount; | |
499 } | |
500 if ( !GetAsyncKeyState(VK_CONTROL) || !pPlayers[uActiveCharacter]->CanSteal() ) | |
501 pText = pGlobalTXT_LocalizationStrings[196]; //Select the Special Item to Buy" | |
502 else | |
503 pText = pGlobalTXT_LocalizationStrings[185]; | |
504 DrawTextAtStatusBar(pText, 0); | |
505 if ( pItemCount ) | |
506 { | |
507 pMouse->GetCursorPos(&mouse); | |
508 if ( !(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) ) | |
509 return; | |
510 pItemCount = (pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1; | |
511 if ( dialog_menu_id == 2 ) | |
512 selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1]; | |
513 else | |
514 selected_item = &pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1]; | |
515 if ( !GetAsyncKeyState(VK_CONTROL) || !pPlayers[uActiveCharacter]->CanSteal() ) | |
516 { | |
517 pText = BuildDialogueString(pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2)], | |
518 uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); | |
519 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
520 } | |
521 else | |
522 { | |
523 pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);//"Steal %24" | |
524 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
525 } | |
526 return; | |
527 } | |
528 dialog_window.DrawShops_next_generation_time_string(pParty->PartyTimes.Shops_next_generation_time[window_SpeakInHouse->par1C]- pParty->uTimePlayed); | |
529 return; | |
530 } | |
531 break; | |
532 | |
533 case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: | |
534 { | |
535 draw_leather(); | |
536 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
537 pShopOptions[0] = const_cast<char *>(pGlobalTXT_LocalizationStrings[200]); //"Sell" | |
538 pShopOptions[1] = const_cast<char *>(pGlobalTXT_LocalizationStrings[113]); //"Identify" | |
539 pShopOptions[2] = const_cast<char *>(pGlobalTXT_LocalizationStrings[179]); //"Repair" | |
540 all_text_height = 0; | |
541 for ( int i = 0; i < 3; ++i ) | |
542 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); | |
543 v146 = (174 - all_text_height) / 3; | |
544 v23 = (3 * (58 - v146) - all_text_height) / 2 - v146 / 2 + 138; | |
545 pNumString = 0; | |
546 for ( int i = pDialogueWindow->pStartingPosActiveItem; | |
547 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) | |
548 { | |
549 pButton = pDialogueWindow->GetControl(i); | |
550 pButton->uY = v146 + v23; | |
551 pButton->uHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0); | |
552 v23 = pButton->uY + pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0) - 1; | |
553 pButton->uW = v23; | |
554 pTextColor = Color16(0xE1u, 0xCDu, 0x23u); | |
555 if ( pDialogueWindow->pCurrentPosActiveItem != i ) | |
556 pTextColor = Color16(0xFFu, 0xFFu, 0xFFu); | |
557 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[pNumString], 3); | |
558 ++pNumString; | |
559 } | |
560 return; | |
561 } | |
562 break; | |
563 | |
564 case HOUSE_DIALOGUE_SHOP_SELL: | |
565 { | |
566 draw_leather(); | |
567 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
568 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);//"Select the Item to Sell" | |
569 if ( !HouseUI_CheckIfPlayerCanInteract()) | |
570 return; | |
571 pMouse->GetCursorPos(&mouse); | |
572 v153 = ((mouse.x - 14) >> 5) + 14 * ((mouse.y - 17) >> 5); | |
573 if ( mouse.x <= 13 || mouse.x >= 462 ) | |
574 return; | |
575 if ( !pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) ) | |
576 return; | |
577 selected_item = &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) - 1]; | |
578 pText = BuildDialogueString(pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 3)], | |
579 uActiveCharacter - 1, selected_item, (char *) window_SpeakInHouse->par1C, 3, 0); | |
580 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
581 return; | |
582 } | |
583 break; | |
584 case HOUSE_DIALOGUE_SHOP_IDENTIFY: | |
585 { | |
586 draw_leather(); | |
587 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
588 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); //"Select the Item to Identify" | |
589 if ( HouseUI_CheckIfPlayerCanInteract() ) | |
590 { | |
591 pMouse->GetCursorPos(&mouse); | |
592 v153 = ((mouse.x - 14) >> 5) + 14 * ((mouse.y - 17) >> 5); | |
593 if ( mouse.x > 13 && mouse.x < 462 ) | |
594 { | |
595 if ( pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) ) | |
596 { | |
597 selected_item = &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153)-1]; | |
598 if (selected_item->IsIdentified()) | |
599 pText = BuildDialogueString("%24", uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); | |
600 else | |
601 pText = BuildDialogueString(pMerchantsIdentifyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, | |
602 (int)window_SpeakInHouse->ptr_1C, 4)], uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); | |
603 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
604 return; | |
605 } | |
606 } | |
607 } | |
608 } | |
609 break; | |
610 case HOUSE_DIALOGUE_SHOP_REPAIR: | |
611 { | |
612 draw_leather(); | |
613 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
614 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0); | |
615 if ( !HouseUI_CheckIfPlayerCanInteract()) | |
616 return; | |
617 pMouse->GetCursorPos(&mouse); | |
618 v153 = ((mouse.x -14) >> 5) + 14 * ((mouse.y - 17) >> 5); | |
619 if( mouse.x <= 13 || mouse.x >= 462 ) | |
620 return; | |
621 if ( !pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) | |
622 || (!(pPlayers[uActiveCharacter]->pOwnItems[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) - 1].uAttributes& 2)) ) | |
623 return; | |
624 selected_item = &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) - 1]; | |
625 phrases_id = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) - 1], | |
626 BuildingType_ArmorShop, window_SpeakInHouse->par1C, 5); | |
627 pText = BuildDialogueString(pMerchantsRepairPhrases[phrases_id], uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 5, 0); | |
628 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
629 return; | |
630 } | |
631 break; | |
632 | |
633 case HOUSE_DIALOGUE_LEARN_SKILLS: | |
634 { | |
635 if (!HouseUI_CheckIfPlayerCanInteract() ) | |
636 return; | |
637 uint item_num = 0; | |
638 v38 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); | |
639 pPrice = v38 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; | |
640 if ( (signed int)pPrice < v38 / 3 ) | |
641 pPrice = v38 / 3; | |
642 all_text_height = 0; | |
643 for ( int i = pDialogueWindow->pStartingPosActiveItem; | |
644 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) | |
645 { | |
646 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pDialogueWindow->GetControl(i)->msg_param - 36] | |
647 && !pPlayers[uActiveCharacter]->pActiveSkills[pDialogueWindow->GetControl(i)->msg_param - 36] ) | |
648 { | |
649 all_text_height += pFontArrus->CalcTextHeight(pSkillNames[pDialogueWindow->GetControl(i)->msg_param - 36], &dialog_window, 0, 0); | |
650 item_num ++; | |
651 } | |
652 } | |
653 if ( item_num ) | |
654 { | |
655 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pPrice); | |
656 dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); | |
657 v146 = (149 - all_text_height) / item_num; | |
658 if ( (149 - all_text_height) / item_num > 32 ) | |
659 v146 = 32; | |
660 v23 = (149 - v146 * item_num - all_text_height) / 2 - v146 / 2 + 162; | |
661 for ( int i = pDialogueWindow->pStartingPosActiveItem; | |
662 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) | |
663 { | |
664 pButton = pDialogueWindow->GetControl(i); | |
665 if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pButton->msg_param - 36] | |
666 || pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param - 36] ) | |
667 { | |
668 pButton->uW = 0; | |
669 pButton->uHeight = 0; | |
670 pButton->uY = 0; | |
671 } | |
672 else | |
673 { | |
674 pButton->uY = v146 + v23; | |
675 pButton->uHeight = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0); | |
676 v23 = pButton->uY + pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0) - 1; | |
677 pButton->uW = v23; | |
678 pTextColor = Color16(0xE1u, 0xCDu, 0x23u); | |
679 if ( pDialogueWindow->pCurrentPosActiveItem != i ) | |
680 pTextColor = Color16(0xFFu, 0xFFu, 0xFFu); | |
681 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pSkillNames[pButton->msg_param - 36], 3); | |
682 } | |
683 } | |
684 return; | |
685 } | |
686 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); //"Seek knowledge elsewhere %s the %s" | |
687 strcat(pTmpBuf.data(), "\n \n"); | |
688 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further." | |
689 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, Color16(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3); | |
690 return; | |
691 } | |
692 break; | |
693 default: | |
694 __debugbreak(); | |
695 } | |
696 } | |
697 //----- (004B9CC6) -------------------------------------------------------- | |
698 void AlchemistDialog() | |
699 { | |
700 int index; // eax@7 | |
701 signed int v5; // esi@9 | |
702 int v18; // eax@23 | |
703 const char *pText; // edx@29 | |
704 unsigned int product_height_1row; // edi@55 | |
705 unsigned int product_width_1row; // esi@57 | |
706 unsigned int product_height_2row; // edi@67 | |
707 unsigned int product_width_2row; // esi@69 | |
708 ItemGen *item; // esi@118 | |
709 int v71; // eax@123 | |
710 int all_text_height; // edi@125 | |
711 GUIButton *pButton; // esi@129 | |
712 unsigned int pColorText; // ax@129 | |
713 POINT mouse; // [sp+2Ch] [bp-ACh]@117 | |
714 GUIWindow dialog_window; // [sp+5Ch] [bp-7Ch]@1 | |
715 int v105; // [sp+B0h] [bp-28h]@19 | |
716 int pNumString; // [sp+C8h] [bp-10h]@9 | |
717 int item_num; // [sp+D4h] [bp-4h]@11 | |
718 int pPrice; | |
719 | |
720 memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); | |
721 dialog_window.uFrameX = 483; | |
722 dialog_window.uFrameWidth = 148; | |
723 dialog_window.uFrameZ = 334; | |
724 switch(dialog_menu_id) | |
725 { | |
726 case HOUSE_DIALOGUE_MAIN: | |
727 { | |
728 if ( HouseUI_CheckIfPlayerCanInteract() ) | |
729 { | |
730 pShopOptions[0] = const_cast<char *>(pGlobalTXT_LocalizationStrings[134]); | |
731 pShopOptions[1] = const_cast<char *>(pGlobalTXT_LocalizationStrings[152]); | |
732 pShopOptions[2] = const_cast<char *>(pGlobalTXT_LocalizationStrings[159]); | |
733 pShopOptions[3] = const_cast<char *>(pGlobalTXT_LocalizationStrings[160]); | |
734 all_text_height = 0; | |
735 for ( int i = 0; i < 4; ++i ) | |
736 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); | |
737 v18 = (174 - all_text_height) / 4; | |
738 v105 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138; | |
739 pNumString = 0; | |
740 for ( int i = pDialogueWindow->pStartingPosActiveItem; | |
741 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) | |
742 { | |
743 pButton = pDialogueWindow->GetControl(i); | |
744 pButton->uY = v18 + v105; | |
745 pButton->uHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0); | |
746 v105 = pButton->uY + pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0) - 1; | |
747 pButton->uW = v105; | |
748 pColorText = Color16(0xE1u, 0xCDu, 0x23u); | |
749 if ( pDialogueWindow->pCurrentPosActiveItem != i ) | |
750 pColorText = Color16(0xFFu, 0xFFu, 0xFFu); | |
751 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pShopOptions[pNumString], 3); | |
752 ++pNumString; | |
753 } | |
754 } | |
755 return; | |
756 } | |
757 | |
758 case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: | |
759 { | |
760 pRenderer->DrawTextureIndexed(8, 8, ShopTexture); | |
761 for ( uint i = 0; i < 6; ++i ) | |
762 { | |
763 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID ) | |
764 { | |
765 product_height_1row = 152 - ItemsInShopTexture[i]->uTextureHeight; | |
766 if ( (signed int)product_height_1row < 1 ) | |
767 product_height_1row = 0; | |
768 product_width_1row = 75 * i - ItemsInShopTexture[i]->uTextureWidth / 2 + 40; | |
769 if ( i ) | |
770 { | |
771 if ( i == 5 ) | |
772 { | |
773 if ( (signed int)product_width_1row > 457 - ItemsInShopTexture[5]->uTextureWidth ) | |
774 product_width_1row = 457 - ItemsInShopTexture[5]->uTextureWidth; | |
775 } | |
776 } | |
777 else if ( (signed int)product_width_1row < 18 ) | |
778 product_width_1row = 18; | |
2524 | 779 pRenderer->DrawTextureIndexedAlpha(product_width_1row, product_height_1row, ItemsInShopTexture[i]); |
2501 | 780 ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + window->GetWidth() * product_height_1row], ItemsInShopTexture[i], i + 1); |
781 } | |
782 } | |
783 for ( uint i = 0; i < 6; ++i ) | |
784 { | |
785 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i + 6].uItemID ) | |
786 { | |
787 product_height_2row = 308 - ItemsInShopTexture[i + 6]->uTextureHeight; | |
788 if ( (signed int)product_height_2row < 1 ) | |
789 product_height_2row = 0; | |
790 product_width_2row = 75 * i - ItemsInShopTexture[i + 6]->uTextureWidth / 2 + 40; | |
791 if ( i ) | |
792 { | |
793 if ( i == 5 ) | |
794 { | |
795 if ( (signed int)product_width_2row > 457 - ItemsInShopTexture[11]->uTextureWidth ) | |
796 product_width_2row = 457 - ItemsInShopTexture[11]->uTextureWidth; | |
797 } | |
798 } | |
799 else | |
800 { | |
801 if ( (signed int)product_width_2row < 18 ) | |
802 product_width_2row = 18; | |
803 } | |
2524 | 804 pRenderer->DrawTextureIndexedAlpha(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]); |
2501 | 805 ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + window->GetWidth() * product_height_2row], ItemsInShopTexture[i + 6], i + 7); |
806 } | |
807 } | |
808 if ( HouseUI_CheckIfPlayerCanInteract() ) | |
809 { | |
810 item_num = 0; | |
811 for ( uint i = 0; i < 12; ++i ) | |
812 { | |
813 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID) | |
814 ++item_num; | |
815 } | |
816 if ( GetAsyncKeyState(VK_CONTROL) && pPlayers[uActiveCharacter]->CanSteal() ) | |
817 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[185], 0); | |
818 else | |
819 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[195], 0); | |
820 if ( !item_num ) | |
821 { | |
822 dialog_window.DrawShops_next_generation_time_string(pParty->PartyTimes.Shops_next_generation_time[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); | |
823 return; | |
824 } | |
825 pMouse->GetCursorPos(&mouse); | |
826 if ( pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF ) | |
827 { | |
828 item = &pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1]; | |
829 if ( !GetAsyncKeyState(VK_CONTROL) || !pPlayers[uActiveCharacter]->CanSteal() ) | |
830 { | |
831 v71 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2); | |
832 pText = BuildDialogueString(pMerchantsBuyPhrases[v71], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); | |
833 } | |
834 else | |
835 pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); | |
836 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
837 return ; | |
838 } | |
839 } | |
840 return; | |
841 } | |
842 | |
843 case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: | |
844 { | |
845 pRenderer->DrawTextureIndexed(8, 8, ShopTexture); | |
846 for ( uint i = 0; i < 6; ++i ) | |
847 { | |
848 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID) | |
849 { | |
850 product_height_1row = 152 - ItemsInShopTexture[i]->uTextureHeight; | |
851 if ( (signed int)product_height_1row < 1 ) | |
852 product_height_1row = 0; | |
853 product_width_1row = 75 * i - ItemsInShopTexture[i]->uTextureWidth / 2 + 40; | |
854 if ( i ) | |
855 { | |
856 if ( i == 5 ) | |
857 { | |
858 if ( (signed int)product_width_1row > 457 - ItemsInShopTexture[5]->uTextureWidth ) | |
859 product_width_1row = 457 - ItemsInShopTexture[5]->uTextureWidth; | |
860 } | |
861 } | |
862 else | |
863 { | |
864 if ( (signed int)product_width_1row < 18 ) | |
865 product_width_1row = 18; | |
866 } | |
2524 | 867 pRenderer->DrawTextureIndexedAlpha(product_width_1row, product_height_1row, ItemsInShopTexture[i]); |
2501 | 868 ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + window->GetWidth() * product_height_1row], ItemsInShopTexture[i], i + 1); |
869 } | |
870 } | |
871 for ( uint i = 0; i < 6; ++i ) | |
872 { | |
873 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)i + 6].uItemID) //not itemid | |
874 { | |
875 product_height_2row = 308 - ItemsInShopTexture[i + 6]->uTextureHeight; | |
876 if ( (signed int)product_height_2row < 1 ) | |
877 product_height_2row = 0; | |
878 product_width_2row = 75 * i - ItemsInShopTexture[i + 6]->uTextureWidth / 2 + 40; | |
879 if ( i ) | |
880 { | |
881 if ( i == 5 ) | |
882 { | |
883 if ( (signed int)product_width_2row > 457 - ItemsInShopTexture[11]->uTextureWidth ) | |
884 product_width_2row = 457 - ItemsInShopTexture[11]->uTextureWidth; | |
885 } | |
886 } | |
887 else | |
888 { | |
889 if ( (signed int)product_width_2row < 18 ) | |
890 product_width_2row = 18; | |
891 } | |
2524 | 892 pRenderer->DrawTextureIndexedAlpha(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]); |
2501 | 893 ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + window->GetWidth() * product_height_2row], ItemsInShopTexture[i + 6], i + 7); |
894 } | |
895 } | |
896 if ( HouseUI_CheckIfPlayerCanInteract() ) | |
897 { | |
898 item_num = 0; | |
899 for ( uint i = 0; i < 12; ++i ) | |
900 { | |
901 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID) | |
902 ++item_num; | |
903 } | |
904 if ( GetAsyncKeyState(VK_CONTROL) && pPlayers[uActiveCharacter]->CanSteal() ) | |
905 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[185], 0); | |
906 else | |
907 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[196], 0); | |
908 if ( !item_num ) | |
909 { | |
910 dialog_window.DrawShops_next_generation_time_string(pParty->PartyTimes.Shops_next_generation_time[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); | |
911 return; | |
912 } | |
913 pMouse->GetCursorPos(&mouse); | |
914 if ( pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF ) | |
915 { | |
916 item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1]; | |
917 if ( !GetAsyncKeyState(VK_CONTROL) || !pPlayers[uActiveCharacter]->CanSteal() ) | |
918 { | |
919 v71 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2); | |
920 pText = BuildDialogueString(pMerchantsBuyPhrases[v71], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); | |
921 } | |
922 else | |
923 pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); | |
924 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
925 return; | |
926 } | |
927 } | |
928 return; | |
929 } | |
930 | |
931 case HOUSE_DIALOGUE_SHOP_SELL: | |
932 { | |
933 draw_leather(); | |
934 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
935 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0); | |
936 if ( !HouseUI_CheckIfPlayerCanInteract() ) | |
937 return; | |
938 pMouse->GetCursorPos(&mouse); | |
939 index = ((mouse.x - 14) >> 5) + 14 * ((mouse.y - 17) >> 5); | |
940 if ( mouse.x <= 13 || mouse.x >= 462 ) | |
941 return; | |
942 if ( !pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&index) ) | |
943 return; | |
944 v71 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&index) - 1], | |
945 BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3); | |
946 pText = BuildDialogueString(pMerchantsSellPhrases[v71], uActiveCharacter - 1, &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&index) - 1], | |
947 (char *)window_SpeakInHouse->ptr_1C, 3, 0); | |
948 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
949 return; | |
950 } | |
951 | |
952 case HOUSE_DIALOGUE_SHOP_IDENTIFY: | |
953 { | |
954 draw_leather(); | |
955 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
956 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); | |
957 if ( HouseUI_CheckIfPlayerCanInteract() ) | |
958 return; | |
959 pMouse->GetCursorPos(&mouse); | |
960 index = ((mouse.x - 14) >> 5) + 14 * ((mouse.y - 17) >> 5); | |
961 if ( mouse.x <= 13 || mouse.x >= 462 ) | |
962 return; | |
963 if ( !pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&index) ) | |
964 return; | |
965 item = &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&index) - 1]; | |
966 if (!item->IsIdentified()) | |
967 { | |
968 v71 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 4); | |
969 pText = BuildDialogueString(pMerchantsIdentifyPhrases[v71], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); | |
970 } | |
971 else | |
972 pText = BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); | |
973 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3); | |
974 return; | |
975 } | |
976 | |
977 case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: | |
978 { | |
979 draw_leather(); | |
980 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
981 pShopOptions[0] = const_cast<char *>(pGlobalTXT_LocalizationStrings[200]); | |
982 pShopOptions[1] = const_cast<char *>(pGlobalTXT_LocalizationStrings[113]); | |
983 all_text_height = 0; | |
984 for ( int i = 0; i < 2; ++i ) | |
985 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); | |
986 v18 = (174 - all_text_height) / 2; | |
987 v105 = (2 * (87 - (174 - all_text_height) / 2) - all_text_height) / 2 - (174 - all_text_height) / 2 / 2 + 138; | |
988 pNumString = 0; | |
989 for ( int i = pDialogueWindow->pStartingPosActiveItem; | |
990 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) | |
991 { | |
992 pButton = pDialogueWindow->GetControl(i); | |
993 pButton->uY = v18 + v105; | |
994 pButton->uHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0); | |
995 v105 = pButton->uY + pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0) - 1; | |
996 pButton->uW = v105; | |
997 pColorText = Color16(0xE1u, 0xCDu, 0x23u); | |
998 if ( pDialogueWindow->pCurrentPosActiveItem != i ) | |
999 pColorText = Color16(0xFFu, 0xFFu, 0xFFu); | |
1000 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pShopOptions[pNumString], 3); | |
1001 ++pNumString; | |
1002 } | |
1003 return; | |
1004 } | |
1005 | |
1006 case HOUSE_DIALOGUE_LEARN_SKILLS: | |
1007 { | |
1008 if (!HouseUI_CheckIfPlayerCanInteract()) | |
1009 return; | |
1010 all_text_height = 0; | |
1011 v5 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); | |
1012 pPrice = v5 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; | |
1013 if ( pPrice < v5 / 3 ) | |
1014 pPrice = v5 / 3; | |
1015 item_num = 0; | |
1016 for ( int i = pDialogueWindow->pStartingPosActiveItem; | |
1017 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) | |
1018 { | |
1019 pButton = pDialogueWindow->GetControl(i); | |
1020 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pButton->msg_param - 36] | |
1021 && !pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param - 36] ) | |
1022 { | |
1023 all_text_height = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0); | |
1024 ++item_num; | |
1025 } | |
1026 } | |
1027 if ( !item_num ) | |
1028 { | |
1029 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); | |
1030 strcat(pTmpBuf.data(), "\n \n"); | |
1031 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); | |
1032 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, Color16(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3); | |
1033 return; | |
1034 } | |
1035 if ( item_num ) | |
1036 { | |
1037 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pPrice); | |
1038 dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); | |
1039 v18 = (149 - all_text_height) / item_num; | |
1040 if ( (149 - all_text_height) / item_num > 32 ) | |
1041 v18 = 32; | |
1042 v105 = (149 - item_num * v18 - all_text_height) / 2 - v18 / 2 + 162; | |
1043 for ( int i = pDialogueWindow->pStartingPosActiveItem; | |
1044 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; i++ ) | |
1045 { | |
1046 pButton = pDialogueWindow->GetControl(i); | |
1047 if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pButton->msg_param - 36] | |
1048 || pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param - 36] ) | |
1049 { | |
1050 pButton->uW = 0; | |
1051 pButton->uHeight = 0; | |
1052 pButton->uY = 0; | |
1053 } | |
1054 else | |
1055 { | |
1056 pButton->uY = v18 + v105; | |
1057 pButton->uHeight = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0); | |
1058 v105 = pButton->uY + pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0) - 1; | |
1059 pButton->uW = v105; | |
1060 pColorText = Color16(0xE1u, 0xCDu, 0x23u); | |
1061 if ( pDialogueWindow->pCurrentPosActiveItem != i ) | |
1062 pColorText = Color16(0xFFu, 0xFFu, 0xFFu); | |
1063 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[pButton->msg_param - 36], 3); | |
1064 } | |
1065 } | |
1066 return; | |
1067 } | |
1068 } | |
1069 default: | |
1070 __debugbreak(); | |
1071 } | |
1072 } | |
1073 | |
1074 //----- (004B4FCF) -------------------------------------------------------- | |
1075 void MagicShopDialog() | |
1076 { | |
1077 int all_text_height; // edi@21 | |
1078 GUIButton *control_button; // esi@25 | |
1079 int v23; // eax@25 | |
1080 unsigned __int16 text_color; // ax@25 | |
1081 char *v30; // edx@35 | |
1082 signed int v33; // esi@40 | |
1083 unsigned int product_height_1row; // edi@64 | |
1084 unsigned int product_width_1row; // esi@66 | |
1085 unsigned int product_height_2row; // edi@76 | |
1086 unsigned int product_width_2row; // esi@76 | |
1087 int v75; // eax@130 | |
1088 POINT mouse; // [sp+6Ch] [bp-8Ch]@30 | |
1089 GUIWindow dialog_window; // [sp+7Ch] [bp-7Ch]@1 | |
1090 int item_num; // [sp+E0h] [bp-18h]@8 | |
1091 int v117; // [sp+E4h] [bp-14h]@40 | |
1092 int pPrice; // [sp+E8h] [bp-10h]@24 | |
1093 int one_string; // [sp+ECh] [bp-Ch]@1 | |
1094 int pSrtingNum; | |
1095 ItemGen *item; | |
1096 | |
1097 memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); | |
1098 dialog_window.uFrameX = 483; | |
1099 dialog_window.uFrameWidth = 148; | |
1100 dialog_window.uFrameZ = 334; | |
1101 if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN) | |
1102 { | |
1103 if ( !HouseUI_CheckIfPlayerCanInteract() ) | |
1104 return; | |
1105 pShopOptions[0] = const_cast<char *>(pGlobalTXT_LocalizationStrings[134]); //"Buy Standard" | |
1106 pShopOptions[1] = const_cast<char *>(pGlobalTXT_LocalizationStrings[152]); //"Buy Special" | |
1107 pShopOptions[2] = const_cast<char *>(pGlobalTXT_LocalizationStrings[159]); //"Display Inventory" | |
1108 pShopOptions[3] = const_cast<char *>(pGlobalTXT_LocalizationStrings[160]); | |
1109 all_text_height = 0; | |
1110 for ( int i = 0; i < 4; ++i ) | |
1111 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); | |
1112 one_string = (174 - all_text_height) / 4; | |
1113 v23 = (174 - 4 * one_string - all_text_height) / 2 - one_string / 2 + 138; | |
1114 int pNumString = 0; | |
1115 for (int i = pDialogueWindow->pStartingPosActiveItem; | |
1116 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i) | |
1117 { | |
1118 control_button = pDialogueWindow->GetControl(i); | |
1119 control_button->uY = one_string + v23; | |
1120 control_button->uHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0); | |
1121 v23 = control_button->uY + control_button->uHeight - 1; | |
1122 control_button->uW = v23; | |
1123 text_color = Color16(225, 205, 35); | |
1124 if ( pDialogueWindow->pCurrentPosActiveItem != i ) | |
1125 text_color = Color16(255, 255, 255); | |
1126 dialog_window.DrawTitleText(pFontArrus, 0, control_button->uY, text_color, pShopOptions[pNumString], 3); | |
1127 ++pNumString; | |
1128 } | |
1129 return; | |
1130 } | |
1131 | |
1132 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) | |
1133 { | |
1134 pRenderer->DrawTextureIndexed(8, 8, ShopTexture); | |
1135 for ( uint i = 0; i < 6; ++i ) | |
1136 { | |
1137 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID) | |
1138 { | |
1139 product_height_1row = 152 - ItemsInShopTexture[i]->uTextureHeight; | |
1140 if ( (signed int)product_height_1row < 1 ) | |
1141 product_height_1row = 0; | |
1142 product_width_1row = 75 * i - ItemsInShopTexture[i]->uTextureWidth / 2 + 40; | |
1143 if ( i ) | |
1144 { | |
1145 if ( i == 5 ) | |
1146 { | |
1147 if ( (signed int)product_width_1row > 457 - ItemsInShopTexture[5]->uTextureWidth ) | |
1148 product_width_1row = 457 - ItemsInShopTexture[5]->uTextureWidth; | |
1149 } | |
1150 } | |
1151 else | |
1152 { | |
1153 if ( (signed int)product_width_1row < 18 ) | |
1154 product_width_1row = 18; | |
1155 } | |
2524 | 1156 pRenderer->DrawTextureIndexedAlpha(product_width_1row, product_height_1row, ItemsInShopTexture[i]); |
2501 | 1157 ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + window->GetWidth() * product_height_1row], ItemsInShopTexture[i], i + 1); |
1158 } | |
1159 } | |
1160 for ( uint i = 0; i < 6; ++i ) | |
1161 { | |
1162 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i + 6].uItemID) | |
1163 { | |
1164 product_height_2row = 306 - ItemsInShopTexture[i + 6]->uTextureHeight; | |
1165 product_width_2row = 75 * i - ItemsInShopTexture[i + 6]->uTextureWidth / 2 + 40; | |
1166 if ( i ) | |
1167 { | |
1168 if ( i == 5 ) | |
1169 { | |
1170 if ( (signed int)product_width_2row > 457 - ItemsInShopTexture[11]->uTextureWidth ) | |
1171 product_width_2row = 457 - ItemsInShopTexture[11]->uTextureWidth; | |
1172 } | |
1173 } | |
1174 else | |
1175 { | |
1176 if ( (signed int)product_width_2row < 18 ) | |
1177 product_width_2row = 18; | |
1178 } | |
2524 | 1179 pRenderer->DrawTextureIndexedAlpha(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]); |
2501 | 1180 ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + window->GetWidth() * product_height_2row], ItemsInShopTexture[i + 6], i + 7); |
1181 } | |
1182 } | |
1183 if ( HouseUI_CheckIfPlayerCanInteract() ) | |
1184 { | |
1185 item_num = 0; | |
1186 for ( uint i = 0; i < 12; ++i ) | |
1187 { | |
1188 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID ) | |
1189 ++item_num; | |
1190 } | |
1191 if ( GetAsyncKeyState(VK_CONTROL) && pPlayers[uActiveCharacter]->CanSteal() ) | |
1192 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[185], 0);// "Steal item" | |
1193 else | |
1194 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[195], 0);// "Select the Item to Buy" | |
1195 if ( !item_num ) | |
1196 { | |
1197 dialog_window.DrawShops_next_generation_time_string(pParty->PartyTimes.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); | |
1198 return; | |
1199 } | |
1200 pMouse->GetCursorPos(&mouse); | |
1201 if ( pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF ) | |
1202 { | |
1203 item = &pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1]; | |
1204 if ( GetAsyncKeyState(VK_CONTROL) && pPlayers[uActiveCharacter]->CanSteal() ) | |
1205 v30 = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);// "Steal %24" | |
1206 else | |
1207 { | |
1208 v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); | |
1209 v30 = BuildDialogueString(pMerchantsBuyPhrases[v75], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); | |
1210 } | |
1211 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, Color16(255, 255, 255), v30, 3); | |
1212 return; | |
1213 } | |
1214 } | |
1215 return; | |
1216 } | |
1217 | |
1218 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_SPECIAL) | |
1219 { | |
1220 pRenderer->DrawTextureIndexed(8, 8, ShopTexture); | |
1221 for ( uint i = 0; i < 6; ++i ) | |
1222 { | |
1223 if ( pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID ) | |
1224 { | |
1225 product_height_1row = 152 - ItemsInShopTexture[i]->uTextureHeight; | |
1226 if ( (signed int)product_height_1row < 1 ) | |
1227 product_height_1row = 0; | |
1228 product_width_1row = 75 * i - ItemsInShopTexture[i]->uTextureWidth / 2 + 40; | |
1229 if ( i ) | |
1230 { | |
1231 if ( i == 5 ) | |
1232 { | |
1233 if ( (signed int)product_width_1row > 457 - ItemsInShopTexture[5]->uTextureWidth ) | |
1234 product_width_1row = 457 - ItemsInShopTexture[5]->uTextureWidth; | |
1235 } | |
1236 } | |
1237 else | |
1238 { | |
1239 if ( (signed int)product_width_1row < 18 ) | |
1240 product_width_1row = 18; | |
1241 } | |
2524 | 1242 pRenderer->DrawTextureIndexedAlpha(product_width_1row, product_height_1row, ItemsInShopTexture[i]); |
2501 | 1243 ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + window->GetWidth() * product_height_1row], ItemsInShopTexture[i], i + 1); |
1244 } | |
1245 } | |
1246 for ( uint i = 0; i < 6; ++i ) | |
1247 { | |
1248 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i + 6].uItemID) | |
1249 { | |
1250 product_height_2row = 306 - ItemsInShopTexture[i + 6]->uTextureHeight; | |
1251 if ( (signed int)product_height_2row < 1 ) | |
1252 product_height_2row = 0; | |
1253 product_width_2row = 75 * i - ItemsInShopTexture[i + 6]->uTextureWidth / 2 + 40; | |
1254 if ( i ) | |
1255 { | |
1256 if ( i == 5 ) | |
1257 { | |
1258 if ( (signed int)product_width_2row > 457 - ItemsInShopTexture[11]->uTextureWidth ) | |
1259 product_width_2row = 457 - ItemsInShopTexture[11]->uTextureWidth; | |
1260 } | |
1261 } | |
1262 else | |
1263 { | |
1264 if ( (signed int)product_width_2row < 18 ) | |
1265 product_width_2row = 18; | |
1266 } | |
2524 | 1267 pRenderer->DrawTextureIndexedAlpha(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]); |
2501 | 1268 ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + window->GetWidth() * product_height_2row], ItemsInShopTexture[i + 6], i + 7); |
1269 } | |
1270 } | |
1271 if ( HouseUI_CheckIfPlayerCanInteract() ) | |
1272 { | |
1273 item_num = 0; | |
1274 for ( uint i = 0; i < 12; ++i ) | |
1275 { | |
1276 if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID) | |
1277 ++item_num; | |
1278 } | |
1279 if ( GetAsyncKeyState(VK_CONTROL) && pPlayers[uActiveCharacter]->CanSteal() ) | |
1280 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[185], 0);// "Steal item" | |
1281 else | |
1282 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[196], 0);// "Select the Special Item to Buy" | |
1283 if ( !item_num ) | |
1284 { | |
1285 dialog_window.DrawShops_next_generation_time_string( pParty->PartyTimes.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); | |
1286 return; | |
1287 } | |
1288 pMouse->GetCursorPos(&mouse); | |
1289 if ( pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF ) | |
1290 { | |
1291 item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1]; | |
1292 if ( GetAsyncKeyState(VK_CONTROL) && pPlayers[uActiveCharacter]->CanSteal() ) | |
1293 v30 = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);// "Steal %24" | |
1294 else | |
1295 { | |
1296 v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); | |
1297 v30 = BuildDialogueString(pMerchantsBuyPhrases[v75], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); | |
1298 } | |
1299 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, Color16(255, 255, 255), v30, 3); | |
1300 return; | |
1301 } | |
1302 } | |
1303 return; | |
1304 } | |
1305 | |
1306 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT ) | |
1307 { | |
1308 draw_leather(); | |
1309 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
1310 pShopOptions[0] = const_cast<char *>(pGlobalTXT_LocalizationStrings[200]);// "Sell" | |
1311 pShopOptions[1] = const_cast<char *>(pGlobalTXT_LocalizationStrings[113]);// "Identify" | |
1312 pShopOptions[2] = const_cast<char *>(pGlobalTXT_LocalizationStrings[179]);// "Repair" | |
1313 all_text_height = 0; | |
1314 for ( uint i = 0; i < 3; ++i ) | |
1315 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); | |
1316 one_string = ((174 - all_text_height) / 3); | |
1317 v23 = (3 * (58 - (signed int)one_string) - all_text_height) / 2 - (174 - all_text_height) / 3 / 2 + 138; | |
1318 pSrtingNum = 0; | |
1319 for ( int i = pDialogueWindow->pStartingPosActiveItem; | |
1320 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) | |
1321 { | |
1322 control_button = pDialogueWindow->GetControl(i); | |
1323 control_button->uY = one_string + v23; | |
1324 control_button->uHeight = pFontArrus->CalcTextHeight(pShopOptions[pSrtingNum], &dialog_window, 0, 0); | |
1325 v23 = control_button->uHeight + control_button->uY - 1; | |
1326 control_button->uW = v23; | |
1327 text_color = Color16(225, 205, 35); | |
1328 if ( pDialogueWindow->pCurrentPosActiveItem != i ) | |
1329 text_color = Color16(255, 255, 255); | |
1330 dialog_window.DrawTitleText(pFontArrus, 0, control_button->uY, text_color, pShopOptions[pSrtingNum], 3); | |
1331 ++pSrtingNum; | |
1332 } | |
1333 return; | |
1334 } | |
1335 | |
1336 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_SELL) | |
1337 { | |
1338 draw_leather(); | |
1339 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
1340 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);// "Select the Item to Sell" | |
1341 if ( !HouseUI_CheckIfPlayerCanInteract() ) | |
1342 return; | |
1343 pMouse->GetCursorPos(&mouse); | |
1344 v117 = ((mouse.x - 14) >> 5) + 14 * ((mouse.y - 17) >> 5); | |
1345 if ( mouse.x <= 13 || mouse.x >= 462 ) | |
1346 return; | |
1347 if ( !pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117) ) | |
1348 return; | |
1349 item = &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117) - 1]; | |
1350 v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 3); | |
1351 v30 = BuildDialogueString(pMerchantsSellPhrases[v75], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0); | |
1352 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, Color16(255, 255, 255), v30, 3); | |
1353 return; | |
1354 } | |
1355 | |
1356 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_IDENTIFY) | |
1357 { | |
1358 draw_leather(); | |
1359 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
1360 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);// "Select the Item to Identify" | |
1361 if ( HouseUI_CheckIfPlayerCanInteract() ) | |
1362 { | |
1363 pMouse->GetCursorPos(&mouse); | |
1364 v117 = ((mouse.x -14) >> 5) + 14 * ((mouse.y - 17) >> 5); | |
1365 if ( mouse.x > 13 && mouse.x < 462 ) | |
1366 { | |
1367 if ( pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117) ) | |
1368 { | |
1369 item = &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117) - 1]; | |
1370 if ( item->uAttributes & ITEM_IDENTIFIED ) | |
1371 { | |
1372 dialog_window.DrawTitleText(pFontArrus, 0, (212 - pFontArrus->CalcTextHeight(BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0), &dialog_window, 0, 0)) / 2 + 101, | |
1373 Color16(255, 255, 255), BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0), 3); | |
1374 return; | |
1375 } | |
1376 v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 4); | |
1377 v30 = BuildDialogueString(pMerchantsIdentifyPhrases[v75], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); | |
1378 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, Color16(255, 255, 255), v30, 3); | |
1379 return; | |
1380 } | |
1381 } | |
1382 } | |
1383 return; | |
1384 } | |
1385 | |
1386 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_REPAIR) | |
1387 { | |
1388 draw_leather(); | |
1389 CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); | |
1390 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);// "Select the Item to Repair" | |
1391 if ( !HouseUI_CheckIfPlayerCanInteract() ) | |
1392 return; | |
1393 pMouse->GetCursorPos(&mouse); | |
1394 v117 = ((mouse.x - 14) >> 5) + 14 * ((mouse.y - 17) >> 5); | |
1395 if ( mouse.x <= 13 || mouse.x >= 462 ) | |
1396 return; | |
1397 if ( !pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117) | |
1398 || !(pPlayers[uActiveCharacter]->pOwnItems[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117)-1].uAttributes& 2) ) | |
1399 return; | |
1400 item = &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117) - 1]; | |
1401 v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117) - 1], | |
1402 BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 5); | |
1403 v30 = BuildDialogueString(pMerchantsRepairPhrases[v75], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0); | |
1404 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, Color16(255, 255, 255), v30, 3); | |
1405 return; | |
1406 } | |
1407 | |
1408 if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS ) | |
1409 { | |
1410 if ( HouseUI_CheckIfPlayerCanInteract() ) | |
1411 { | |
1412 all_text_height = 0; | |
1413 v33 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); | |
1414 pPrice = v33 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; | |
1415 if ( pPrice < v33 / 3 ) | |
1416 pPrice = v33 / 3; | |
1417 item_num = 0; | |
1418 for ( int i = pDialogueWindow->pStartingPosActiveItem; | |
1419 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) | |
1420 { | |
1421 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pDialogueWindow->GetControl(i)->msg_param - 36] | |
1422 && !pPlayers[uActiveCharacter]->pActiveSkills[pDialogueWindow->GetControl(i)->msg_param - 36] ) | |
1423 { | |
1424 all_text_height += pFontArrus->CalcTextHeight(pSkillNames[pDialogueWindow->GetControl(i)->msg_param - 36], &dialog_window, 0, 0); | |
1425 ++item_num; | |
1426 } | |
1427 } | |
1428 if ( !item_num ) | |
1429 { | |
1430 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);// | |
1431 // "Seek knowledge elsewhere %s the %s" | |
1432 strcat(pTmpBuf.data(), "\n \n"); | |
1433 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further." | |
1434 dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, Color16(225, 205, 35), pTmpBuf.data(), 3); | |
1435 return; | |
1436 } | |
1437 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pPrice);// "Skill Cost: %lu" | |
1438 dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); | |
1439 one_string = (149 - all_text_height) / item_num; | |
1440 if ( one_string > 32 ) | |
1441 one_string = 32; | |
1442 v23 = (149 - item_num * one_string - all_text_height) / 2 - one_string / 2 + 162; | |
1443 for ( int i = pDialogueWindow->pStartingPosActiveItem; | |
1444 i < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton; ++i) | |
1445 { | |
1446 control_button = pDialogueWindow->GetControl(i); | |
1447 if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][control_button->msg_param - 36] | |
1448 || pPlayers[uActiveCharacter]->pActiveSkills[control_button->msg_param - 36] ) | |
1449 { | |
1450 control_button->uW = 0; | |
1451 control_button->uHeight = 0; | |
1452 control_button->uY = 0; | |
1453 } | |
1454 else | |
1455 { | |
1456 control_button->uY = one_string + v23; | |
1457 control_button->uHeight = pFontArrus->CalcTextHeight(pSkillNames[control_button->msg_param - 36], &dialog_window, 0, 0); | |
1458 v23 = control_button->uY + control_button->uHeight - 1; | |
1459 control_button->uW = v23; | |
1460 text_color = Color16(225, 205, 35); | |
1461 if ( pDialogueWindow->pCurrentPosActiveItem != i ) | |
1462 text_color = Color16(255, 255, 255); | |
1463 dialog_window.DrawTitleText(pFontArrus, 0, control_button->uY, text_color, pSkillNames[control_button->msg_param - 36], 3); | |
1464 } | |
1465 } | |
1466 } | |
1467 return; | |
1468 } | |
1469 return; | |
1470 } | |
1471 //----- (004BDB56) -------------------------------------------------------- | |
1472 void UIShop_Buy_Identify_Repair() | |
1473 { | |
1474 int v8; // eax@15 | |
1475 unsigned int pItemID; // esi@20 | |
1476 ItemGen *item; // esi@21 | |
1477 unsigned int v15; // eax@33 | |
1478 POINT *pCursorPos; // esi@37 | |
1479 int v18; // ecx@37 | |
1480 float pPriceMultiplier; // ST1C_4@38 | |
1481 int taken_item; // eax@40 | |
1482 ItemGen *bought_item; // esi@51 | |
1483 int party_reputation; // eax@55 | |
1484 int v39; // eax@63 | |
1485 int v42; // esi@74 | |
1486 signed int v43; // ebx@74 | |
1487 unsigned __int16 *pSkill; // esi@77 | |
1488 int v55; // [sp+0h] [bp-B4h]@26 | |
1489 POINT cursor; // [sp+40h] [bp-74h]@37 | |
1490 int a6; // [sp+98h] [bp-1Ch]@57 | |
1491 int a3; // [sp+9Ch] [bp-18h]@53 | |
1492 unsigned int uNumSeconds; // [sp+A4h] [bp-10h]@53 | |
1493 unsigned int v79; // [sp+A8h] [bp-Ch]@9 | |
1494 int uPriceItemService; // [sp+ACh] [bp-8h]@12 | |
1495 | |
2541 | 1496 if ( current_screen_type == SCREEN_E ) |
2501 | 1497 { |
1498 pPlayers[uActiveCharacter]->OnInventoryLeftClick(); | |
1499 return; | |
1500 } | |
1501 if ( !HouseUI_CheckIfPlayerCanInteract() ) | |
1502 { | |
1503 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0); | |
1504 return; | |
1505 } | |
1506 | |
1507 switch(dialog_menu_id) | |
1508 { | |
1509 case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: | |
1510 { | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2541
diff
changeset
|
1511 current_character_screen_window = WINDOW_CharacterWindow_Inventory; |
2501 | 1512 pPlayers[uActiveCharacter]->OnInventoryLeftClick(); |
1513 break; | |
1514 } | |
1515 case HOUSE_DIALOGUE_GUILD_BUY_BOOKS: | |
1516 { | |
1517 pMouse->GetCursorPos(&cursor); | |
1518 v18 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]] & 0xFFFF; | |
1519 if ( !v18 ) | |
1520 return; | |
1521 bought_item = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C)); | |
1522 pPriceMultiplier = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; | |
1523 uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), pPriceMultiplier); | |
1524 GetAsyncKeyState(VK_CONTROL); | |
1525 if ( pParty->uNumGold < uPriceItemService ) | |
1526 { | |
1527 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); | |
1528 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); | |
1529 return; | |
1530 } | |
1531 taken_item = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID); | |
1532 if ( taken_item ) | |
1533 { | |
1534 bought_item->SetIdentified(); | |
1535 memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[taken_item - 1], bought_item, 0x24u); | |
1536 dword_F8B1E4 = 1; | |
1537 Party::TakeGold(uPriceItemService); | |
1538 viewparams->bRedrawGameUI = 1; | |
1539 bought_item->Reset(); | |
1540 pRenderer->ClearZBuffer(0, 479); | |
1541 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); | |
1542 return; | |
1543 } | |
1544 pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); | |
1545 ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 5); // "Pack is Full!" | |
1546 break; | |
1547 } | |
1548 case HOUSE_DIALOGUE_SHOP_SELL: | |
1549 { | |
1550 v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5); | |
1551 if ( pMouse->GetCursorPos(&cursor)->x <= 13 | |
1552 || pMouse->GetCursorPos(&cursor)->x >= 462 | |
1553 || (v15 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79), !v15) ) | |
1554 return; | |
1555 if ( pPlayers[uActiveCharacter]->pInventoryItemList[v15 - 1].MerchandiseTest((int)window_SpeakInHouse->ptr_1C) ) | |
1556 { | |
1557 dword_F8B1E4 = 1; | |
1558 pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)window_SpeakInHouse->ptr_1C); | |
1559 viewparams->bRedrawGameUI = 1; | |
1560 pRenderer->ClearZBuffer(0, 479); | |
1561 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)77, 0); | |
1562 return; | |
1563 } | |
1564 pPlayers[uActiveCharacter]->PlaySound(SPEECH_79, 0); | |
1565 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0); | |
1566 break; | |
1567 } | |
1568 case HOUSE_DIALOGUE_SHOP_IDENTIFY: | |
1569 { | |
1570 pMouse->GetCursorPos(&cursor); | |
1571 v79 = ((cursor.x - 14) >> 5) + 14 * ((cursor.y - 17) >> 5); | |
1572 if (cursor.x > 13 && cursor.x < 462) | |
1573 { | |
1574 pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); | |
1575 if ( pItemID ) | |
1576 { | |
1577 uPriceItemService = pPlayers[uActiveCharacter]->GetPriceIdentification(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); | |
1578 item = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1]; | |
1579 if ( !(item->uAttributes & ITEM_IDENTIFIED) ) | |
1580 { | |
1581 if ( item->MerchandiseTest((int)window_SpeakInHouse->ptr_1C) ) | |
1582 { | |
1583 if ( pParty->uNumGold >= uPriceItemService ) | |
1584 { | |
1585 dword_F8B1E4 = 1; | |
1586 Party::TakeGold(uPriceItemService); | |
1587 item->uAttributes |= ITEM_IDENTIFIED; | |
1588 pPlayers[uActiveCharacter]->PlaySound(SPEECH_73, 0); | |
1589 ShowStatusBarString(pGlobalTXT_LocalizationStrings[569], 2); | |
1590 return; | |
1591 } | |
1592 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); | |
1593 return; | |
1594 } | |
1595 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0); | |
1596 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0); | |
1597 return; | |
1598 } | |
1599 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)76, 0); | |
1600 return; | |
1601 } | |
1602 } | |
1603 break; | |
1604 } | |
1605 case HOUSE_DIALOGUE_SHOP_REPAIR: | |
1606 { | |
1607 v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5); | |
1608 if ( pMouse->GetCursorPos(&cursor)->x > 13 ) | |
1609 { | |
1610 if ( pMouse->GetCursorPos(&cursor)->x < 462 ) | |
1611 { | |
1612 pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); | |
1613 if ( pItemID ) | |
1614 { | |
1615 item = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1]; | |
1616 pPriceMultiplier = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; | |
1617 ItemGen* _v = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1]; | |
1618 uPriceItemService = pPlayers[uActiveCharacter]->GetPriceRepair(_v->GetValue(), pPriceMultiplier); | |
1619 if ( item->uAttributes & ITEM_BROKEN ) | |
1620 { | |
1621 if ( item->MerchandiseTest((int)window_SpeakInHouse->ptr_1C) ) | |
1622 { | |
1623 if ( pParty->uNumGold >= uPriceItemService ) | |
1624 { | |
1625 dword_F8B1E4 = 1; | |
1626 Party::TakeGold(uPriceItemService); | |
1627 v8 = item->uAttributes; | |
1628 LOBYTE(v8) = item->uAttributes & 0xFD; | |
1629 item->uAttributes = v8 | 1; | |
1630 pPlayers[uActiveCharacter]->PlaySound(SPEECH_74, 0); | |
1631 ShowStatusBarString(pGlobalTXT_LocalizationStrings[570], 2); | |
1632 return; | |
1633 } | |
1634 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); | |
1635 return; | |
1636 } | |
1637 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0); | |
1638 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0); | |
1639 return; | |
1640 } | |
1641 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)76, 0); | |
1642 return; | |
1643 } | |
1644 } | |
1645 } | |
1646 break; | |
1647 } | |
1648 case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: | |
1649 case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: | |
1650 { | |
1651 pCursorPos = pMouse->GetCursorPos(&cursor); | |
1652 v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pCursorPos->y]] & 0xFFFF; | |
1653 if ( !v18 ) | |
1654 return; | |
1655 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) | |
1656 bought_item = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1]; | |
1657 else | |
1658 bought_item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1]; | |
1659 uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); | |
1660 uNumSeconds = 0; | |
1661 a3 = 0; | |
1662 if ( pMapStats->GetMapInfo(pCurrentMapName) ) | |
1663 a3 = pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)]._steal_perm; | |
1664 party_reputation = pParty->GetPartyReputation(); | |
1665 if (pPlayers[uActiveCharacter]->CanSteal() && GetAsyncKeyState(VK_CONTROL)) | |
1666 { | |
1667 uNumSeconds = pPlayers[uActiveCharacter]->StealFromShop(bought_item, a3, party_reputation, 0, &a6); | |
1668 if ( !uNumSeconds ) | |
1669 { | |
1670 sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, 0, a6); | |
1671 return; | |
1672 } | |
1673 } | |
1674 else if (pParty->uNumGold < uPriceItemService) | |
1675 { | |
1676 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); | |
1677 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" | |
1678 return; | |
1679 } | |
1680 v39 = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID); | |
1681 if ( v39 ) | |
1682 { | |
1683 bought_item->SetIdentified(); | |
1684 memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v39 - 1], bought_item, sizeof(ItemGen)); | |
1685 if (uNumSeconds != 0) | |
1686 { | |
1687 pPlayers[uActiveCharacter]->pInventoryItemList[v39 - 1].SetStolen(); | |
1688 sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, uNumSeconds, a6); | |
1689 } | |
1690 else | |
1691 { | |
1692 dword_F8B1E4 = 1; | |
1693 Party::TakeGold(uPriceItemService); | |
1694 } | |
1695 viewparams->bRedrawGameUI = 1; | |
1696 bought_item->Reset(); | |
1697 pRenderer->ClearZBuffer(0, 479); | |
1698 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); | |
1699 return; | |
1700 } | |
1701 else | |
1702 { | |
1703 pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); | |
1704 ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 2); // "Pack is Full!" | |
1705 return; | |
1706 } | |
1707 break; | |
1708 } | |
1709 default:// if click video screen in shop | |
1710 { | |
1711 __debugbreak(); // please do record these dialogue ids to the HOUSE_DIALOGUE_MENU enum | |
1712 if( dialog_menu_id >= 36 && dialog_menu_id <= 72 ) | |
1713 { | |
1714 v42 = dialog_menu_id - 36; | |
1715 //v43 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0); | |
1716 v43 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); | |
1717 uPriceItemService = v43 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; | |
1718 if ( uPriceItemService < v43 / 3 ) | |
1719 uPriceItemService = v43 / 3; | |
1720 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v42] ) | |
1721 { | |
1722 pSkill = &pPlayers[uActiveCharacter]->pActiveSkills[v42]; | |
1723 if ( !*pSkill ) | |
1724 { | |
1725 if ( pParty->uNumGold < uPriceItemService ) | |
1726 { | |
1727 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" | |
1728 if ( in_current_building_type == BuildingType_Training ) | |
1729 v55 = 4; | |
1730 else | |
1731 v55 = 2; | |
1732 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v55); | |
1733 return; | |
1734 } | |
1735 Party::TakeGold(uPriceItemService); | |
1736 dword_F8B1E4 = 1; | |
1737 *pSkill = 1; | |
1738 pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)78, 0); | |
1739 return; | |
1740 } | |
1741 } | |
1742 } | |
1743 break; | |
1744 } | |
1745 } | |
1746 } | |
1747 //----- (004B1A2D) -------------------------------------------------------- | |
1748 void ShowPopupShopItem() | |
1749 { | |
1750 int v3; // ecx@5 | |
1751 // unsigned int v6; // eax@13 | |
1752 ItemGen *v7; // ecx@13 | |
1753 POINT cursor; // [sp+30h] [bp-1Ch]@17 | |
1754 | |
1755 if ( in_current_building_type <= 0 ) | |
1756 return; | |
1757 if ( dialog_menu_id < HOUSE_DIALOGUE_SHOP_BUY_STANDARD) | |
1758 return; | |
1759 if ( in_current_building_type <= BuildingType_AlchemistShop ) | |
1760 { | |
1761 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD || dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_SPECIAL ) | |
1762 { | |
1763 pMouse->GetCursorPos(&cursor); | |
1764 v3 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]] & 0xFFFF; | |
1765 if ( !v3 ) | |
1766 return; | |
1767 v7 = &pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v3 - 1]; | |
1768 if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_SPECIAL) | |
1769 v7 = &pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v3 - 1]; | |
1770 GameUI_DrawItemInfo(v7); | |
1771 return; | |
1772 } | |
1773 | |
1774 if ( dialog_menu_id >= HOUSE_DIALOGUE_SHOP_SELL && dialog_menu_id <= HOUSE_DIALOGUE_SHOP_REPAIR | |
1775 || dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT ) | |
1776 { | |
1777 pMouse->GetCursorPos(&cursor); | |
1778 v3 = ((cursor.x - 14) >> 5) + 14 * ((cursor.y - 17) >> 5); | |
1779 if ( cursor.x <= 13 || cursor.x >= 462 | |
1780 || !pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&v3) ) | |
1781 return; | |
1782 GameUI_DrawItemInfo(&pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&v3) - 1]); | |
1783 return; | |
1784 } | |
1785 } | |
1786 if ( in_current_building_type <= BuildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) | |
1787 { | |
1788 pMouse->GetCursorPos(&cursor); | |
1789 v3 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]] & 0xFFFF; | |
1790 if ( v3 ) | |
1791 { | |
1792 unsigned int guildId = (unsigned int)window_SpeakInHouse->ptr_1C - 139; | |
1793 sub_4B1523_showSpellbookInfo(pParty->SpellBooksInGuilds[guildId][v3].uItemID); | |
1794 } | |
1795 } | |
1796 } | |
1797 | |
1798 //----- (004B1523) -------------------------------------------------------- | |
1799 void sub_4B1523_showSpellbookInfo(int spellItemId) | |
1800 { | |
1801 int spellId; // esi@1 | |
1802 int spellLevel; // edx@1 | |
1803 unsigned int v3; // eax@2 | |
1804 int v4; // eax@4 | |
1805 LONG v5; // ecx@4 | |
1806 int v6; // eax@10 | |
1807 char *v7; // ST44_4@12 | |
1808 unsigned __int16 v8; // ax@12 | |
1809 GUIWindow a1; // [sp+Ch] [bp-68h]@4 | |
1810 unsigned int spellSchool; // [sp+60h] [bp-14h]@1 | |
1811 POINT a2; // [sp+64h] [bp-10h]@1 | |
1812 int v13; // [sp+6Ch] [bp-8h]@4 | |
1813 int v14; // [sp+70h] [bp-4h]@4 | |
1814 | |
1815 spellId = spellItemId - 399; | |
1816 spellLevel = (spellItemId - 400) % 11 + 1; | |
1817 spellSchool = 4 * (spellItemId - 400) / 11; | |
1818 // sprintf(pTmpBuf.data(), "%s%03d", spellbook_texture_filename_suffices[v11 / 4], v2); not used | |
1819 if ( pMouse->GetCursorPos(&a2)->y <= 320 ) | |
1820 v3 = pMouse->GetCursorPos(&a2)->y + 30; | |
1821 else | |
1822 v3 = 30; | |
1823 a1.Hint = nullptr; | |
1824 a1.uFrameY = v3; | |
1825 a1.uFrameWidth = 328; | |
1826 a1.uFrameHeight = 68; | |
1827 a1.uFrameX = 90; | |
1828 a1.uFrameZ = 417; | |
1829 a1.uFrameW = v3 + 67; | |
1830 a2.y = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[431]); | |
1831 v14 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[433]); | |
1832 v13 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[432]); | |
1833 v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[96]); | |
1834 v5 = a2.y; | |
1835 if ( v14 > a2.y ) | |
1836 v5 = v14; | |
1837 if ( v13 > v5 ) | |
1838 v5 = v13; | |
1839 if ( v4 > v5 ) | |
1840 v5 = v4; | |
1841 sprintf(pTmpBuf2.data(), "%s\n\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s", | |
1842 pSpellStats->pInfos[spellId].pDescription, pGlobalTXT_LocalizationStrings[431], // "Normal" | |
1843 v5 + 3, v5 + 10, pSpellStats->pInfos[spellId].pBasicSkillDesc, pGlobalTXT_LocalizationStrings[433], // "Expert" | |
1844 v5 + 3, v5 + 10, pSpellStats->pInfos[spellId].pExpertSkillDesc, pGlobalTXT_LocalizationStrings[432], // "Master" | |
1845 v5 + 3, v5 + 10, pSpellStats->pInfos[spellId].pMasterSkillDesc, pGlobalTXT_LocalizationStrings[96], // "Grand" | |
1846 v5 + 3, v5 + 10, pSpellStats->pInfos[spellId].pGrandmasterSkillDesc); | |
1847 v6 = pFontSmallnum->CalcTextHeight(pTmpBuf2.data(), &a1, 0, 0); | |
1848 a1.uFrameHeight += v6; | |
1849 if ( (signed int)a1.uFrameHeight < 150 ) | |
1850 a1.uFrameHeight = 150; | |
1851 a1.uFrameWidth = game_viewport_width; | |
1852 a1.DrawMessageBox(0); | |
1853 a1.uFrameWidth -= 12; | |
1854 a1.uFrameHeight -= 12; | |
1855 v7 = pSpellStats->pInfos[spellId].pName; | |
1856 a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1; | |
1857 a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1; | |
1858 v8 = Color16(0xFFu, 0xFFu, 0x9Bu); | |
1859 a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u); | |
1860 a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2.data(), 0, 0, 0); | |
1861 a1.uFrameZ = a1.uFrameX + 107; | |
1862 a1.uFrameWidth = 108; | |
1863 a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[spellSchool / 4 + 12], 3u); | |
1864 sprintfex(pTmpBuf.data(), "%s\n%d", pGlobalTXT_LocalizationStrings[522], *(&pSpellDatas[0].uNormalLevelMana + 10 * spellId)); | |
1865 a1.DrawTitleText(pFontComic, 0xCu, a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16, 0, pTmpBuf.data(), 3); | |
1866 } | |
1867 //----- (004B1D27) -------------------------------------------------------- | |
1868 void GetHouseGoodbyeSpeech() | |
1869 { | |
1870 signed int v2; // edi@10 | |
1871 signed int v5; // edi@20 | |
1872 int v7[4]; // [sp+Ch] [bp-10h]@12 | |
1873 | |
1874 if ( in_current_building_type > 0 ) | |
1875 { | |
1876 if ( in_current_building_type > BuildingType_MagicShop ) | |
1877 { | |
1878 if ( in_current_building_type == BuildingType_Bank ) | |
1879 { | |
1880 if ( !dword_F8B1E4 ) | |
1881 return; | |
1882 } | |
1883 else | |
1884 { | |
1885 if ( in_current_building_type != BuildingType_Temple ) | |
1886 return; | |
1887 } | |
1888 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Greeting_2); | |
1889 return; | |
1890 } | |
1891 if ( (signed __int64)pParty->PartyTimes._shop_ban_times[(unsigned int)window_SpeakInHouse->ptr_1C]<= (signed __int64)pParty->uTimePlayed ) | |
1892 { | |
1893 if ( pParty->uNumGold <= 10000 ) | |
1894 { | |
1895 if ( !dword_F8B1E4 ) | |
1896 return; | |
1897 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Goodbye); | |
1898 return; | |
1899 } | |
1900 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)(dword_F8B1E4 + 3)); | |
1901 if ( !dword_F8B1E4 && !_A750D8_player_speech_timer ) | |
1902 { | |
1903 v5 = 0; | |
1904 for ( uint i = 1; i <= 4; ++i ) | |
1905 { | |
1906 if ( pPlayers[i]->CanAct() ) | |
1907 v7[v5++] = i; | |
1908 } | |
1909 if ( v5 ) | |
1910 { | |
1911 _A750D8_player_speech_timer = 256i64; | |
1912 PlayerSpeechID = SPEECH_80; | |
1913 uSpeakingCharacter = v7[rand() % v5]; | |
1914 return; | |
1915 } | |
1916 } | |
1917 } | |
1918 else | |
1919 { | |
1920 if ( !_A750D8_player_speech_timer ) | |
1921 { | |
1922 v2 = 0; | |
1923 for ( uint i = 1; i <= 4; ++i ) | |
1924 { | |
1925 if ( pPlayers[i]->CanAct() ) | |
1926 v7[v2++] = i; | |
1927 } | |
1928 if ( v2 ) | |
1929 { | |
1930 _A750D8_player_speech_timer = 256i64; | |
1931 PlayerSpeechID = SPEECH_80; | |
1932 uSpeakingCharacter = v7[rand() % v2]; | |
1933 return; | |
1934 } | |
1935 } | |
1936 } | |
1937 } | |
1938 } | |
1939 | |
1940 //----- (004B1447) -------------------------------------------------------- | |
1941 void sub_4B1447_party_fine(int shopId, int stealingResult, int fineToAdd) | |
1942 { | |
1943 signed int v3; // esi@1 | |
1944 DDM_DLV_Header *v7; // eax@14 | |
1945 | |
1946 if (stealingResult == 0 || stealingResult == 1) | |
1947 { | |
1948 if (pParty->uFine < 4000000) | |
1949 { | |
1950 if (fineToAdd + pParty->uFine < 0) | |
1951 pParty->uFine = 0; | |
1952 else if (fineToAdd + pParty->uFine > 4000000) | |
1953 pParty->uFine = 4000000; | |
1954 else | |
1955 pParty->uFine += fineToAdd; | |
1956 } | |
1957 if (pParty->uFine) | |
1958 { | |
1959 for (uint i = 1; i <= 4; ++i) | |
1960 { | |
1961 if (!_449B57_test_bit(pPlayers[i]->_achieved_awards_bits, 1)) | |
1962 _449B7E_toggle_bit(pPlayers[i]->_achieved_awards_bits, 1, 1); | |
1963 } | |
1964 } | |
1965 if (stealingResult == 1) | |
1966 v3 = 2; | |
1967 else | |
1968 v3 = 1; | |
1969 } | |
1970 else | |
1971 v3 = 2; | |
1972 pParty->PartyTimes._shop_ban_times[shopId] = pParty->uTimePlayed + 368640; | |
1973 pParty->InTheShopFlags[shopId] = 1; | |
1974 v7 = &pOutdoor->ddm; | |
1975 if (uCurrentlyLoadedLevelType != LEVEL_Outdoor) | |
1976 v7 = &pIndoor->dlv; | |
1977 v7->uReputation += v3; | |
1978 if (v7->uReputation > 10000) | |
1979 v7->uReputation = 10000; | |
1980 } |