2501
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
2541
|
6
|
|
7 #include "Engine/Engine.h"
|
|
8
|
2501
|
9 #include "..\../Engine/Objects/Items.h"
|
2502
|
10 #include "..\../GUI/GUIWindow.h"
|
2501
|
11 #include "..\../Engine/texts.h"
|
|
12 #include "UIHouses.h"
|
2502
|
13 #include "..\../GUI/GUIFont.h"
|
2501
|
14 #include "..\../Engine/Graphics/Render.h"
|
|
15 #include "..\../Engine/Party.h"
|
|
16 #include "..\../Engine/Graphics/Texture.h"
|
2502
|
17 #include "..\../IO/Mouse.h"
|
2501
|
18 #include "..\../Engine/Events2D.h"
|
2502
|
19 #include "..\../Media/Audio/AudioPlayer.h"
|
2501
|
20 #include "..\../Engine/LOD.h"
|
|
21
|
|
22 //----- (004B5D7C) --------------------------------------------------------
|
|
23 void GuildDialog()
|
|
24 {
|
|
25 signed int base_teach_price; // ebx@1
|
|
26 int v6; // esi@13
|
|
27 signed int v7; // esi@17
|
|
28 int v8; // esi@22
|
|
29 // const char *statusbar_string; // ecx@26
|
|
30 int v13; // ecx@30
|
|
31 ItemGen *v15; // ST18_4@31
|
|
32 int v17; // eax@31
|
|
33 char *v18; // edx@31
|
|
34 int v26; // ecx@47
|
|
35 GUIButton *pButton; // eax@49
|
|
36 int pTextHeight; // eax@55
|
|
37 unsigned __int16 pTextColor; // ax@55
|
|
38 POINT cursor; // [sp+26Ch] [bp-80h]@30
|
|
39 GUIWindow working_window; // [sp+274h] [bp-78h]@1
|
|
40 int v58; // [sp+2D4h] [bp-18h]@1
|
|
41 bool pSkillFlag; // [sp+2DCh] [bp-10h]@35
|
|
42 int v61; // [sp+2E0h] [bp-Ch]@35
|
|
43 unsigned int v62; // [sp+2E4h] [bp-8h]@13
|
|
44 int pPrice; // [sp+2E8h] [bp-4h]@1
|
|
45 int all_text_height;
|
|
46 int pX;
|
|
47
|
|
48 memcpy(&working_window, window_SpeakInHouse, sizeof(GUIWindow));
|
|
49 working_window.uFrameX = 483;
|
|
50 working_window.uFrameWidth = 148;
|
|
51 working_window.uFrameZ = 334;
|
|
52 base_teach_price = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * 500.0);
|
|
53 pPrice = base_teach_price * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
|
|
54 if ( pPrice < base_teach_price / 3 )
|
|
55 pPrice = base_teach_price / 3;
|
|
56 if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN )
|
|
57 {
|
|
58 if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->_achieved_awards_bits,
|
|
59 guild_mambership_flags[(unsigned int)window_SpeakInHouse->ptr_1C - 139]) )
|
|
60 { //you must me member
|
|
61 pTextHeight = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &working_window, 0, 0);
|
|
62 working_window.DrawTitleText(pFontArrus, 0, (212 - pTextHeight) / 2 + 101, Color16(0xFFu, 0xFFu, 0x9Bu), pNPCTopics[121].pText, 3);
|
|
63 pDialogueWindow->pNumPresenceButton = 0;
|
|
64 return;
|
|
65 }
|
|
66 if ( !HouseUI_CheckIfPlayerCanInteract() )
|
|
67 return;
|
|
68 if ( pDialogueWindow->pStartingPosActiveItem >= pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
|
|
69 {
|
|
70 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); // "Seek knowledge elsewhere %s the %s"
|
|
71 strcat(pTmpBuf.data(), "\n \n");
|
|
72 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further."
|
|
73 pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &working_window, 0, 0);
|
|
74 working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
|
|
75 return;
|
|
76 }
|
|
77 v61 = 0;
|
|
78 pSkillFlag = false;
|
|
79 all_text_height = 0;
|
|
80 for ( int i = pDialogueWindow->pStartingPosActiveItem;
|
|
81 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
|
|
82 {
|
|
83 if ( pDialogueWindow->GetControl(i)->msg_param == 18 )
|
|
84 {
|
|
85 all_text_height += pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[400], &working_window, 0, 0); //"Buy Spells"
|
|
86 v61++;
|
|
87 }
|
|
88 else
|
|
89 {
|
|
90 if( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pDialogueWindow->GetControl(i)->msg_param - 36]
|
|
91 && !pPlayers[uActiveCharacter]->pActiveSkills[pDialogueWindow->GetControl(i)->msg_param - 36] )
|
|
92 {
|
|
93 all_text_height += pFontArrus->CalcTextHeight(pSkillNames[pDialogueWindow->GetControl(i)->msg_param - 36], &working_window, 0, 0);
|
|
94 v61++;
|
|
95 pSkillFlag = true;
|
|
96 }
|
|
97 }
|
|
98 }
|
|
99 if ( !v61 )
|
|
100 {
|
|
101 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); // "Seek knowledge elsewhere %s the %s"
|
|
102 strcat(pTmpBuf.data(), "\n \n");
|
|
103 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further."
|
|
104 pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &working_window, 0, 0);
|
|
105 working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
|
|
106 return;
|
|
107 }
|
|
108 if ( pSkillFlag )
|
|
109 {
|
|
110 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pPrice); //"Skill Cost: %lu"
|
|
111 working_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3);
|
|
112 }
|
|
113 v58 = (149 - all_text_height) / v61;
|
|
114 if ( v58 > 32 )
|
|
115 v58 = 32;
|
|
116 v26 = (149 - v61 * v58 - all_text_height) / 2 - v58 / 2 + 162;
|
|
117 for ( int i = pDialogueWindow->pStartingPosActiveItem;
|
|
118 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
|
|
119 {
|
|
120 pButton = pDialogueWindow->GetControl(i);
|
|
121 if ( pButton->msg_param == 18 )
|
|
122 {
|
|
123 pButton->uY = v58 + v26;
|
|
124 pTextHeight = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[400], &working_window, 0, 0);
|
|
125 pButton->uHeight = pTextHeight;
|
|
126 v26 = pButton->uY + pTextHeight - 1;
|
|
127 pButton->uW = v26;
|
|
128 pTextColor = Color16(0xFFu, 0xFFu, 0x9Bu);
|
|
129 if ( pDialogueWindow->pCurrentPosActiveItem != i )
|
|
130 pTextColor = Color16(0xFFu, 0xFFu, 0xFFu);
|
|
131 working_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pGlobalTXT_LocalizationStrings[400], 3);//"Buy Spells"
|
|
132 }
|
|
133 else
|
|
134 {
|
|
135 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pButton->msg_param - 36]
|
|
136 && !pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param - 36] )
|
|
137 {
|
|
138 pButton->uY = v58 + v26;
|
|
139 pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &working_window, 0, 0);
|
|
140 pButton->uHeight = pTextHeight;
|
|
141 v26 = pButton->uY + pTextHeight - 1;
|
|
142 pButton->uW = v26;
|
|
143 pTextColor = Color16(0xFFu, 0xFFu, 0x9Bu);
|
|
144 if ( pDialogueWindow->pCurrentPosActiveItem != i )
|
|
145 pTextColor = Color16(0xFFu, 0xFFu, 0xFFu);
|
|
146 working_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pSkillNames[pButton->msg_param - 36], 3);
|
|
147 }
|
|
148 else
|
|
149 {
|
|
150 pButton->uW = 0;
|
|
151 pButton->uHeight = 0;
|
|
152 pButton->uY = 0;
|
|
153 }
|
|
154 }
|
|
155 }
|
|
156 return;
|
|
157 }
|
|
158 if ( dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) //buy skill
|
|
159 {
|
|
160 pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
|
|
161 v6 = 0;
|
|
162 v62 = 0;
|
|
163 for ( pX = 32; pX < 452; pX += 70 )//расположение в верхнем ряду
|
|
164 {
|
|
165 if ( pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v6].uItemID )
|
|
166 {
|
2524
|
167 pRenderer->DrawTextureIndexedAlpha(pX, 90, ItemsInShopTexture[v6]);
|
2501
|
168 ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 230528), ItemsInShopTexture[v6], v6 + 1);
|
|
169 }
|
|
170 v62 += 280;
|
|
171 ++v6;
|
|
172 }
|
|
173 v62 = 1680;
|
|
174 v7 = 6;
|
|
175 for ( pX = 32; pX < 452; pX += 70 )//расположение в нижнем ряду
|
|
176 {
|
|
177 if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v7].uItemID)
|
|
178 {
|
2524
|
179 pRenderer->DrawTextureIndexedAlpha(pX, 250, ItemsInShopTexture[v7]);
|
2501
|
180 ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 638448), ItemsInShopTexture[v7], v7 + 1);
|
|
181 }
|
|
182 v62 += 280;
|
|
183 ++v7;
|
|
184 }
|
|
185 if ( HouseUI_CheckIfPlayerCanInteract() )
|
|
186 {
|
|
187 v8 = 0;
|
|
188 for ( uint i = 0; i < 12; ++i )
|
|
189 {
|
|
190 if ( pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C - 139][i].uItemID > 0 )
|
|
191 ++v8;
|
|
192 }
|
|
193 GetAsyncKeyState(VK_CONTROL);
|
|
194 DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[195], 0);//"Select the Item to Buy"
|
|
195 if ( !v8 )
|
|
196 {
|
|
197 working_window.DrawShops_next_generation_time_string(pParty->PartyTimes.Shops_next_generation_time[window_SpeakInHouse->par1C - 139] - pParty->uTimePlayed);//"Приходите через 14 дней"
|
|
198 return;
|
|
199 }
|
|
200 pMouse->GetCursorPos(&cursor);
|
|
201 v13 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]] & 0xFFFF;
|
|
202 if ( v13 )
|
|
203 {
|
|
204 v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)window_SpeakInHouse->ptr_1C));
|
|
205 v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)window_SpeakInHouse->ptr_1C, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2);
|
|
206 v18 = BuildDialogueString(pMerchantsBuyPhrases[v17], uActiveCharacter - 1, v15, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
|
|
207 pTextHeight = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0);
|
|
208 working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), v18, 3);
|
|
209 return;
|
|
210 }
|
|
211 }
|
|
212 return;
|
|
213 }
|
|
214 if ( HouseUI_CheckIfPlayerCanInteract() )
|
|
215 {
|
|
216 if ( pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] )
|
|
217 {
|
|
218 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[403], pSkillNames[dialog_menu_id-36]); //"You already know the %s skill"
|
|
219 ShowStatusBarString(pTmpBuf.data(), 2);
|
|
220 pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
|
|
221 }
|
|
222 else
|
|
223 {
|
|
224 if ( pParty->uNumGold < pPrice )
|
|
225 {
|
|
226 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); //"You don't have enough gold"
|
|
227 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
|
|
228 }
|
|
229 else
|
|
230 {
|
|
231 Party::TakeGold(pPrice);
|
|
232 pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] = 1;
|
|
233 }
|
|
234 }
|
|
235 }
|
|
236 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0);
|
|
237 return;
|
|
238 }
|
|
239 //----- (004BC8D5) --------------------------------------------------------
|
|
240 void SpellBookGenerator()//for GuildDialogs
|
|
241 {
|
|
242 int pItemNum; // esi@1
|
|
243 int v4; // esi@7
|
|
244
|
|
245 for( int i = 0; i < 12; ++i )
|
|
246 {
|
|
247 if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType >= 5 )
|
|
248 {
|
|
249 if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType <= 13 )
|
|
250 pItemNum = rand() % word_4F0F30[(signed int)window_SpeakInHouse->par1C - 139] + 11 * p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType + 345;
|
|
251 else
|
|
252 {
|
|
253 if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 14 )
|
|
254 v4 = rand() % 4;
|
|
255 else if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 15 )
|
|
256 v4 = rand() % 3 + 4;
|
|
257 else if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 16 )
|
|
258 v4 = rand() % 2 + 7;
|
|
259 if( p2DEvents[window_SpeakInHouse->par1C - 1].uType <= 16 )
|
|
260 pItemNum = rand() % word_4F0F30[(signed int)window_SpeakInHouse->par1C - 139] + 11 * v4 + 400;
|
|
261 }
|
|
262 }
|
|
263 if ( pItemNum == 487 )
|
|
264 {
|
|
265 if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) )
|
|
266 pItemNum = 486;
|
|
267 }
|
|
268 ItemGen * item_spellbook = &pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i];
|
|
269 item_spellbook->Reset();
|
|
270 pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].uItemID = pItemNum;
|
|
271 pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].IsIdentified();
|
|
272 ItemsInShopTexture[i] = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[pItemNum].pIconName, TEXTURE_16BIT_PALETTE);
|
|
273 }
|
|
274 return;
|
|
275 } |