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