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