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