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