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