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