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