Mercurial > mm7
annotate UI/UIGuilds.cpp @ 1569:5cc08e71a308
m
author | Ritor1 |
---|---|
date | Mon, 02 Sep 2013 18:49:18 +0600 |
parents | ff2118028c71 |
children | 19f1735fca80 |
rev | line source |
---|---|
1300 | 1 #include "..\Items.h" |
2 #include "..\GUIWindow.h" | |
3 #include "..\mm7_data.h" | |
4 #include "..\texts.h" | |
5 #include "UIHouses.h" | |
6 #include "..\GUIFont.h" | |
7 #include "..\Render.h" | |
8 #include "..\Party.h" | |
9 #include "..\Texture.h" | |
10 #include "..\Mouse.h" | |
11 #include "..\Events2D.h" | |
12 #include "..\AudioPlayer.h" | |
13 #include "..\LOD.h" | |
14 | |
15 //----- (004B5D7C) -------------------------------------------------------- | |
16 void GuildDialog() | |
17 { | |
18 signed int base_teach_price; // ebx@1 | |
19 int v3; // edi@6 | |
20 int result; // eax@11 | |
21 int v6; // esi@13 | |
22 signed int v7; // esi@17 | |
23 int v8; // esi@22 | |
24 signed int v9; // ecx@22 | |
25 char *v10; // eax@22 | |
26 const char *statusbar_string; // ecx@26 | |
27 POINT *v12; // esi@30 | |
28 int v13; // ecx@30 | |
29 void *v14; // ST1C_4@31 | |
30 ItemGen *v15; // ST18_4@31 | |
31 int v16; // ST10_4@31 | |
32 int v17; // eax@31 | |
33 char *v18; // edx@31 | |
34 int v19; // eax@32 | |
35 int pActiveItem; // esi@35 | |
36 int v22; // eax@35 | |
37 unsigned int v23; // eax@36 | |
38 int v24; // eax@39 | |
39 int v25; // eax@40 | |
40 int v26; // ecx@47 | |
41 GUIButton *pButton; // eax@49 | |
42 unsigned int v29; // eax@49 | |
43 char *pText; // eax@52 | |
44 int pTextHeight; // eax@55 | |
45 unsigned int v32; // ecx@55 | |
46 int v33; // eax@55 | |
47 unsigned __int16 pTextColor; // ax@55 | |
48 int v35; // eax@58 | |
49 const char *v36; // ST20_4@61 | |
50 unsigned __int16 v37; // ST1C_2@61 | |
51 int v38; // eax@61 | |
52 int v40; // [sp-14h] [bp-300h]@31 | |
53 int v41; // [sp-10h] [bp-2FCh]@31 | |
54 unsigned __int16 v42; // [sp-Ch] [bp-2F8h]@31 | |
55 char *v43; // [sp-8h] [bp-2F4h]@31 | |
56 unsigned int v44; // [sp-4h] [bp-2F0h]@31 | |
57 char Dest[100]; // [sp+Ch] [bp-2E0h]@3 | |
58 char v46[100]; // [sp+70h] [bp-27Ch]@3 | |
59 char v47[100]; // [sp+D4h] [bp-218h]@3 | |
60 char v48[100]; // [sp+138h] [bp-1B4h]@3 | |
61 char v49[100]; // [sp+19Ch] [bp-150h]@3 | |
62 POINT v50; // [sp+264h] [bp-88h]@30 | |
63 POINT v51; // [sp+26Ch] [bp-80h]@30 | |
64 GUIWindow working_window; // [sp+274h] [bp-78h]@1 | |
65 signed int v53; // [sp+27Ch] [bp-70h]@1 | |
66 signed int v54; // [sp+284h] [bp-68h]@1 | |
67 int pColorWhite; // [sp+2CCh] [bp-20h]@1 | |
68 int pColorYellow; // [sp+2D0h] [bp-1Ch]@1 | |
69 int v58; // [sp+2D4h] [bp-18h]@1 | |
70 unsigned __int8 uPlayerID; // [sp+2DBh] [bp-11h]@31 | |
71 bool pSkillFlag; // [sp+2DCh] [bp-10h]@35 | |
72 int v61; // [sp+2E0h] [bp-Ch]@35 | |
73 int pItemNum; | |
74 unsigned int v62; // [sp+2E4h] [bp-8h]@13 | |
75 int v63; // [sp+2E8h] [bp-4h]@1 | |
76 int pNumActivItem; | |
77 int all_text_height; | |
78 | |
79 memcpy(&working_window, window_SpeakInHouse, sizeof(GUIWindow)); | |
80 working_window.uFrameX = 483; | |
81 working_window.uFrameWidth = 148; | |
82 working_window.uFrameZ = 334; | |
83 pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu); | |
84 pColorYellow = TargetColor(0xFFu, 0xFFu, 0x9Bu); | |
85 base_teach_price = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * 500.0); | |
86 v63 = base_teach_price * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; | |
87 if ( v63 < base_teach_price / 3 ) | |
88 v63 = base_teach_price / 3; | |
89 strcpy(Dest, ""); | |
90 strcpy(v46, ""); | |
91 strcpy(v47, ""); | |
92 strcpy(v48, ""); | |
93 strcpy(v49, ""); | |
94 if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN ) | |
95 { | |
96 if ( dialog_menu_id != HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) //buy skill | |
97 { | |
1393 | 98 if ( HouseUI_CheckIfPlayerCanInteract() ) |
1300 | 99 { |
100 if ( pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] ) | |
101 { | |
102 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[403], pClassNames[dialog_menu_id - 16]); //"You already know the %s skill" | |
103 ShowStatusBarString(pTmpBuf.data(), 2); | |
104 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); | |
105 } | |
106 else | |
107 { | |
108 if ( pParty->uNumGold < v63 ) | |
109 { | |
110 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); //"You don't have enough gold" | |
111 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); | |
112 } | |
113 else | |
114 { | |
115 Party::TakeGold(v63); | |
116 pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] = 1; | |
117 } | |
118 } | |
119 } | |
120 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); | |
121 return; | |
122 } | |
123 pRenderer->DrawTextureIndexed(8, 8, ShopTexture); | |
124 v6 = 0; | |
125 v62 = 0; | |
126 v63 = 32; | |
127 do | |
128 { | |
129 if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v6].uItemID) | |
130 { | |
131 pRenderer->DrawTextureTransparent(v63, 0x5Au, ItemsInShopTexture[v6]); | |
132 ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 230528), ItemsInShopTexture[v6], v6 + 1); | |
133 } | |
134 v63 += 70; | |
135 v62 += 280; | |
136 ++v6; | |
137 } | |
138 while ( v63 < 452 ); | |
139 v62 = 1680; | |
140 v7 = 6; | |
141 v63 = 32; | |
142 do | |
143 { | |
144 if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v7].uItemID) | |
145 { | |
146 pRenderer->DrawTextureTransparent(v63, 0xFAu, ItemsInShopTexture[v7]); | |
147 ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 638448), ItemsInShopTexture[v7], v7 + 1); | |
148 } | |
149 v63 += 70; | |
150 v62 += 280; | |
151 ++v7; | |
152 } | |
153 while ( v63 < 452 ); | |
1393 | 154 if ( HouseUI_CheckIfPlayerCanInteract() ) |
1300 | 155 { |
156 v8 = 0; | |
1569 | 157 for ( v9 = 12; v9; --v9 ) |
1300 | 158 { |
159 if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v9].uItemID ) | |
160 ++v8; | |
161 } | |
162 GetAsyncKeyState(17); | |
163 statusbar_string = pGlobalTXT_LocalizationStrings[195]; //"Select the Item to Buy" | |
164 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) | |
165 statusbar_string = pGlobalTXT_LocalizationStrings[196]; //"Select the Special Item to Buy" | |
166 DrawTextAtStatusBar(statusbar_string, 0); | |
167 if ( !v8 ) | |
168 { | |
169 working_window.DrawCurrentTime(__PAIR__( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)window_SpeakInHouse->ptr_1C + 44472], | |
170 *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)window_SpeakInHouse->ptr_1C + 44468]) - pParty->uTimePlayed); | |
171 return; | |
172 } | |
173 v12 = pMouse->GetCursorPos(&v51); | |
174 result = v12->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v50)->y]; | |
175 v13 = pRenderer->pActiveZBuffer[result] & 0xFFFF; | |
176 if ( pRenderer->pActiveZBuffer[result] & 0xFFFF ) | |
177 { | |
178 v14 = window_SpeakInHouse->ptr_1C; | |
179 v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)v14)); | |
180 v16 = (int)window_SpeakInHouse->ptr_1C; | |
181 uPlayerID = uActiveCharacter - 1; | |
1411 | 182 v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, BuildingType_MagicShop, v16, 2); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1393
diff
changeset
|
183 v18 = BuildDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0); |
1300 | 184 v19 = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0); |
185 working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, pColorWhite, v18, 3); | |
186 return; | |
187 } | |
188 } | |
189 return; | |
190 } | |
1460
ff2118028c71
renaming _guilds_member_bits to _achieved_awards_bits
Gloval
parents:
1411
diff
changeset
|
191 if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->_achieved_awards_bits, |
1300 | 192 guild_mambership_flags[(unsigned int)window_SpeakInHouse->ptr_1C-139]) ) |
193 { //you must me member | |
194 v38 = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &working_window, 0, 0); | |
195 working_window.DrawTitleText(pFontArrus, 0, (212 - v38) / 2 + 101, pColorYellow, pNPCTopics[121].pText, 3u); | |
196 pDialogueWindow->pNumPresenceButton = 0; | |
197 return; | |
198 } | |
1393 | 199 if ( !HouseUI_CheckIfPlayerCanInteract() ) |
1300 | 200 return; |
201 v61 = 0; | |
202 pSkillFlag = false; | |
203 pActiveItem = pDialogueWindow->pStartingPosActiveItem; | |
204 v22 = pActiveItem + pDialogueWindow->pNumPresenceButton; | |
205 pItemNum = 0; | |
206 if ( pDialogueWindow->pStartingPosActiveItem >= pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ) | |
207 { | |
208 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); // "Seek knowledge elsewhere %s the %s" | |
209 strcat(pTmpBuf.data(), "\n \n"); | |
210 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further." | |
211 v19 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &working_window, 0, 0); | |
212 working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); | |
213 return; | |
214 } | |
215 all_text_height = 0; | |
216 do | |
217 { | |
218 v23 = pDialogueWindow->GetControl(pActiveItem)->msg_param; | |
219 if ( v23 == 18 ) | |
220 { | |
221 all_text_height += pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[400], &working_window, 0, 0); //"Buy Spells" | |
222 v61++; | |
223 } | |
224 else | |
225 { | |
226 if( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v23 - 36] | |
227 && !pPlayers[uActiveCharacter]->pActiveSkills[v23 - 36] ) | |
228 { | |
229 all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v23 - 36], &working_window, 0, 0); | |
230 v61++; | |
231 pSkillFlag = true; | |
232 } | |
233 } | |
234 ++pActiveItem; | |
235 } | |
236 while ( pActiveItem < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); | |
237 if ( !v61 ) | |
238 { | |
239 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); // "Seek knowledge elsewhere %s the %s" | |
240 strcat(pTmpBuf.data(), "\n \n"); | |
241 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further." | |
242 v19 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &working_window, 0, 0); | |
243 working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); | |
244 return; | |
245 } | |
246 if ( pSkillFlag ) | |
247 { | |
248 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v63); //"Skill Cost: %lu" | |
249 working_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); | |
250 } | |
251 v58 = (149 - all_text_height) / v61; | |
252 if ( v58 > 32 ) | |
253 v58 = 32; | |
254 v26 = (149 - v61 * v58 - all_text_height) / 2 - v58 / 2 + 162; | |
255 pNumActivItem = pDialogueWindow->pStartingPosActiveItem; | |
256 if (pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ) | |
257 { | |
258 pItemNum = 2; | |
259 do | |
260 { | |
261 pButton = pDialogueWindow->GetControl(pItemNum); | |
262 v29 = pButton->msg_param; | |
263 if ( v29 == 18 ) | |
264 { | |
265 pText = pGlobalTXT_LocalizationStrings[400]; //"Buy Spells" | |
266 pButton->uY = v58 + v26; | |
267 pTextHeight = pFontArrus->CalcTextHeight(pText, &working_window, 0, 0); | |
268 v32 = pButton->uY; | |
269 pButton->uHeight = pTextHeight; | |
270 v33 = v32 + pTextHeight - 1; | |
271 pButton->uW = v33; | |
272 v26 = v33; | |
273 pTextColor = pColorYellow; | |
274 if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) | |
275 pTextColor = pColorWhite; | |
276 working_window.DrawTitleText(pFontArrus, 0, v32, pTextColor, pText, 3); | |
277 } | |
278 else | |
279 { | |
280 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v29 - 36] | |
281 && !pPlayers[uActiveCharacter]->pActiveSkills[v29 - 36] ) | |
282 { | |
283 pButton->uY = v58 + v26; | |
284 pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v29 - 36], &working_window, 0, 0); | |
285 v32 = pButton->uY; | |
286 pButton->uHeight = pTextHeight; | |
287 v33 = v32 + pTextHeight - 1; | |
288 pButton->uW = v33; | |
289 v26 = v33; | |
290 pTextColor = pColorYellow; | |
291 if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) | |
292 pTextColor = pColorWhite; | |
293 working_window.DrawTitleText(pFontArrus, 0, v32, pTextColor, pSkillNames[v29 - 36], 3); | |
294 } | |
295 else | |
296 { | |
297 pButton->uW = 0; | |
298 pButton->uHeight = 0; | |
299 pButton->uY = 0; | |
300 } | |
301 } | |
302 ++pItemNum; | |
303 } | |
304 while ( pItemNum < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); | |
305 } | |
306 return; | |
307 } | |
308 //----- (004BC8D5) -------------------------------------------------------- | |
309 void SpellBookGenerator()//for GuildDialogs | |
310 { | |
311 int pItemNum; // esi@1 | |
312 int v4; // esi@7 | |
313 | |
314 for( int i = 0; i < 12; ++i ) | |
315 { | |
316 if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType >= 5 ) | |
317 { | |
318 if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType <= 13 ) | |
319 pItemNum = rand() % word_4F0F30[(signed int)window_SpeakInHouse->par1C - 139] + 11 * p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType + 345; | |
320 else | |
321 { | |
322 if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 14 ) | |
323 v4 = rand() % 4; | |
324 else if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 15 ) | |
325 v4 = rand() % 3 + 4; | |
326 else if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 16 ) | |
327 v4 = rand() % 2 + 7; | |
328 if( p2DEvents[window_SpeakInHouse->par1C - 1].uType <= 16 ) | |
329 pItemNum = rand() % word_4F0F30[(signed int)window_SpeakInHouse->par1C - 139] + 11 * v4 + 400; | |
330 } | |
331 } | |
332 if ( pItemNum == 487 ) | |
333 { | |
334 if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) ) | |
335 pItemNum = 486; | |
336 } | |
337 ItemGen * item_spellbook = &pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i]; | |
338 item_spellbook->Reset(); | |
339 pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].uItemID = pItemNum; | |
340 pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].Identified(); | |
341 ItemsInShopTexture[i] = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[pItemNum].pIconName, TEXTURE_16BIT_PALETTE); | |
342 } | |
343 return; | |
344 } |