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