Mercurial > mm7
annotate UI/UIGuilds.cpp @ 1682:3c451fd02fcf
OnInventoryLeftClick cleanup
author | Grumpy7 |
---|---|
date | Fri, 20 Sep 2013 10:23:54 +0200 |
parents | e1d1fe32c194 |
children | ffef0fe0b59d |
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 | |
1661 | 29 //void *v14; // ST1C_4@31 |
1300 | 30 ItemGen *v15; // ST18_4@31 |
1661 | 31 //int v16; // ST10_4@31 |
1300 | 32 int v17; // eax@31 |
33 char *v18; // edx@31 | |
34 int pActiveItem; // esi@35 | |
35 int v24; // eax@39 | |
36 int v25; // eax@40 | |
37 int v26; // ecx@47 | |
38 GUIButton *pButton; // eax@49 | |
39 int pTextHeight; // eax@55 | |
40 unsigned __int16 pTextColor; // ax@55 | |
41 int v35; // eax@58 | |
42 const char *v36; // ST20_4@61 | |
43 unsigned __int16 v37; // ST1C_2@61 | |
44 int v40; // [sp-14h] [bp-300h]@31 | |
45 int v41; // [sp-10h] [bp-2FCh]@31 | |
46 unsigned __int16 v42; // [sp-Ch] [bp-2F8h]@31 | |
47 char *v43; // [sp-8h] [bp-2F4h]@31 | |
48 unsigned int v44; // [sp-4h] [bp-2F0h]@31 | |
49 char Dest[100]; // [sp+Ch] [bp-2E0h]@3 | |
50 char v46[100]; // [sp+70h] [bp-27Ch]@3 | |
51 char v47[100]; // [sp+D4h] [bp-218h]@3 | |
52 char v48[100]; // [sp+138h] [bp-1B4h]@3 | |
53 char v49[100]; // [sp+19Ch] [bp-150h]@3 | |
54 POINT v50; // [sp+264h] [bp-88h]@30 | |
55 POINT v51; // [sp+26Ch] [bp-80h]@30 | |
56 GUIWindow working_window; // [sp+274h] [bp-78h]@1 | |
57 signed int v53; // [sp+27Ch] [bp-70h]@1 | |
58 signed int v54; // [sp+284h] [bp-68h]@1 | |
59 int pColorWhite; // [sp+2CCh] [bp-20h]@1 | |
60 int pColorYellow; // [sp+2D0h] [bp-1Ch]@1 | |
61 int v58; // [sp+2D4h] [bp-18h]@1 | |
1661 | 62 //unsigned __int8 uPlayerID; // [sp+2DBh] [bp-11h]@31 |
1300 | 63 bool pSkillFlag; // [sp+2DCh] [bp-10h]@35 |
64 int v61; // [sp+2E0h] [bp-Ch]@35 | |
65 unsigned int v62; // [sp+2E4h] [bp-8h]@13 | |
1524 | 66 int pPrice; // [sp+2E8h] [bp-4h]@1 |
1300 | 67 int all_text_height; |
1526 | 68 int pX; |
1300 | 69 |
70 memcpy(&working_window, window_SpeakInHouse, sizeof(GUIWindow)); | |
71 working_window.uFrameX = 483; | |
72 working_window.uFrameWidth = 148; | |
73 working_window.uFrameZ = 334; | |
74 pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu); | |
75 pColorYellow = TargetColor(0xFFu, 0xFFu, 0x9Bu); | |
76 base_teach_price = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * 500.0); | |
1524 | 77 pPrice = base_teach_price * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; |
78 if ( pPrice < base_teach_price / 3 ) | |
79 pPrice = base_teach_price / 3; | |
1300 | 80 strcpy(Dest, ""); |
81 strcpy(v46, ""); | |
82 strcpy(v47, ""); | |
83 strcpy(v48, ""); | |
84 strcpy(v49, ""); | |
1661 | 85 if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN ) |
1300 | 86 { |
1661 | 87 if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->_achieved_awards_bits, |
88 guild_mambership_flags[(unsigned int)window_SpeakInHouse->ptr_1C-139]) ) | |
89 { //you must me member | |
90 pTextHeight = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &working_window, 0, 0); | |
91 working_window.DrawTitleText(pFontArrus, 0, (212 - pTextHeight) / 2 + 101, pColorYellow, pNPCTopics[121].pText, 3); | |
92 pDialogueWindow->pNumPresenceButton = 0; | |
93 return; | |
94 } | |
95 if ( !HouseUI_CheckIfPlayerCanInteract() ) | |
96 return; | |
97 if ( pDialogueWindow->pStartingPosActiveItem >= pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ) | |
1300 | 98 { |
1661 | 99 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); // "Seek knowledge elsewhere %s the %s" |
100 strcat(pTmpBuf.data(), "\n \n"); | |
101 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further." | |
102 pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &working_window, 0, 0); | |
103 working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); | |
104 return; | |
105 } | |
106 v61 = 0; | |
107 pSkillFlag = false; | |
108 all_text_height = 0; | |
109 for ( int i = pDialogueWindow->pStartingPosActiveItem; | |
110 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) | |
111 { | |
112 if ( pDialogueWindow->GetControl(i)->msg_param == 18 ) | |
113 { | |
114 all_text_height += pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[400], &working_window, 0, 0); //"Buy Spells" | |
115 v61++; | |
116 } | |
117 else | |
1300 | 118 { |
1661 | 119 if( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pDialogueWindow->GetControl(i)->msg_param - 36] |
120 && !pPlayers[uActiveCharacter]->pActiveSkills[pDialogueWindow->GetControl(i)->msg_param - 36] ) | |
1300 | 121 { |
1661 | 122 all_text_height += pFontArrus->CalcTextHeight(pSkillNames[pDialogueWindow->GetControl(i)->msg_param - 36], &working_window, 0, 0); |
123 v61++; | |
124 pSkillFlag = true; | |
125 } | |
126 } | |
127 } | |
128 if ( !v61 ) | |
129 { | |
130 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); // "Seek knowledge elsewhere %s the %s" | |
131 strcat(pTmpBuf.data(), "\n \n"); | |
132 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further." | |
133 pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &working_window, 0, 0); | |
134 working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); | |
135 return; | |
136 } | |
137 if ( pSkillFlag ) | |
138 { | |
139 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pPrice); //"Skill Cost: %lu" | |
140 working_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); | |
141 } | |
142 v58 = (149 - all_text_height) / v61; | |
143 if ( v58 > 32 ) | |
144 v58 = 32; | |
145 v26 = (149 - v61 * v58 - all_text_height) / 2 - v58 / 2 + 162; | |
146 for ( int i = pDialogueWindow->pStartingPosActiveItem; | |
147 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) | |
148 { | |
149 pButton = pDialogueWindow->GetControl(i); | |
150 if ( pButton->msg_param == 18 ) | |
151 { | |
152 pButton->uY = v58 + v26; | |
153 pTextHeight = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[400], &working_window, 0, 0); | |
154 pButton->uHeight = pTextHeight; | |
155 v26 = pButton->uY + pTextHeight - 1; | |
156 pButton->uW = v26; | |
157 pTextColor = pColorYellow; | |
158 if ( pDialogueWindow->pCurrentPosActiveItem != i ) | |
159 pTextColor = pColorWhite; | |
160 working_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pGlobalTXT_LocalizationStrings[400], 3);//"Buy Spells" | |
161 } | |
162 else | |
163 { | |
164 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pButton->msg_param - 36] | |
165 && !pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param - 36] ) | |
166 { | |
167 pButton->uY = v58 + v26; | |
168 pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &working_window, 0, 0); | |
169 pButton->uHeight = pTextHeight; | |
170 v26 = pButton->uY + pTextHeight - 1; | |
171 pButton->uW = v26; | |
172 pTextColor = pColorYellow; | |
173 if ( pDialogueWindow->pCurrentPosActiveItem != i ) | |
174 pTextColor = pColorWhite; | |
175 working_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pSkillNames[pButton->msg_param - 36], 3); | |
1300 | 176 } |
177 else | |
178 { | |
1661 | 179 pButton->uW = 0; |
180 pButton->uHeight = 0; | |
181 pButton->uY = 0; | |
1300 | 182 } |
183 } | |
184 } | |
1661 | 185 return; |
186 } | |
187 if ( dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) //buy skill | |
188 { | |
1300 | 189 pRenderer->DrawTextureIndexed(8, 8, ShopTexture); |
190 v6 = 0; | |
191 v62 = 0; | |
1526 | 192 for ( pX = 32; pX < 452; pX += 70 )//расположение в верхнем ряду |
1300 | 193 { |
1526 | 194 if ( pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v6].uItemID ) |
1300 | 195 { |
1526 | 196 pRenderer->DrawTextureTransparent(pX, 90, ItemsInShopTexture[v6]); |
1300 | 197 ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 230528), ItemsInShopTexture[v6], v6 + 1); |
198 } | |
199 v62 += 280; | |
200 ++v6; | |
201 } | |
202 v62 = 1680; | |
203 v7 = 6; | |
1526 | 204 for ( pX = 32; pX < 452; pX += 70 )//расположение в нижнем ряду |
1300 | 205 { |
206 if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v7].uItemID) | |
207 { | |
1526 | 208 pRenderer->DrawTextureTransparent(pX, 250, ItemsInShopTexture[v7]); |
1300 | 209 ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 638448), ItemsInShopTexture[v7], v7 + 1); |
210 } | |
211 v62 += 280; | |
212 ++v7; | |
213 } | |
1393 | 214 if ( HouseUI_CheckIfPlayerCanInteract() ) |
1300 | 215 { |
216 v8 = 0; | |
1524 | 217 for ( v9 = 12; v9; --v9 ) |
1300 | 218 { |
1526 | 219 if ( pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v9].uItemID > 0 ) |
1300 | 220 ++v8; |
221 } | |
222 GetAsyncKeyState(17); | |
223 statusbar_string = pGlobalTXT_LocalizationStrings[195]; //"Select the Item to Buy" | |
224 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) | |
225 statusbar_string = pGlobalTXT_LocalizationStrings[196]; //"Select the Special Item to Buy" | |
226 DrawTextAtStatusBar(statusbar_string, 0); | |
227 if ( !v8 ) | |
228 { | |
1529 | 229 working_window.DrawCurrentTime(pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C] - pParty->uTimePlayed);//"Приходите через 14 дней" |
1300 | 230 return; |
231 } | |
232 v12 = pMouse->GetCursorPos(&v51); | |
233 result = v12->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v50)->y]; | |
234 v13 = pRenderer->pActiveZBuffer[result] & 0xFFFF; | |
235 if ( pRenderer->pActiveZBuffer[result] & 0xFFFF ) | |
236 { | |
1661 | 237 v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)window_SpeakInHouse->ptr_1C)); |
238 v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)window_SpeakInHouse->ptr_1C, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); | |
239 v18 = BuildDialogueString((char *)pMerchantsBuyPhrases[v17], uActiveCharacter - 1, v15, (char *)window_SpeakInHouse->ptr_1C, 2, 0); | |
240 pTextHeight = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0); | |
241 working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v18, 3); | |
1300 | 242 return; |
243 } | |
244 } | |
245 return; | |
246 } | |
1661 | 247 if ( dialog_menu_id == HOUSE_DIALOGUE_GUILD_LEARN_SKILL ) |
1300 | 248 { |
1661 | 249 if ( HouseUI_CheckIfPlayerCanInteract() ) |
1300 | 250 { |
1661 | 251 if ( pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] ) |
1300 | 252 { |
1661 | 253 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[403], pClassNames[dialog_menu_id - 16]); //"You already know the %s skill" |
254 ShowStatusBarString(pTmpBuf.data(), 2); | |
255 pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); | |
1300 | 256 } |
257 else | |
258 { | |
1661 | 259 if ( pParty->uNumGold < pPrice ) |
1300 | 260 { |
1661 | 261 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); //"You don't have enough gold" |
262 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); | |
1300 | 263 } |
264 else | |
265 { | |
1661 | 266 Party::TakeGold(pPrice); |
267 pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] = 1; | |
1300 | 268 } |
269 } | |
270 } | |
1661 | 271 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); |
272 return; | |
1300 | 273 } |
274 } | |
275 //----- (004BC8D5) -------------------------------------------------------- | |
276 void SpellBookGenerator()//for GuildDialogs | |
277 { | |
278 int pItemNum; // esi@1 | |
279 int v4; // esi@7 | |
280 | |
281 for( int i = 0; i < 12; ++i ) | |
282 { | |
283 if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType >= 5 ) | |
284 { | |
285 if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType <= 13 ) | |
286 pItemNum = rand() % word_4F0F30[(signed int)window_SpeakInHouse->par1C - 139] + 11 * p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType + 345; | |
287 else | |
288 { | |
289 if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 14 ) | |
290 v4 = rand() % 4; | |
291 else if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 15 ) | |
292 v4 = rand() % 3 + 4; | |
293 else if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 16 ) | |
294 v4 = rand() % 2 + 7; | |
295 if( p2DEvents[window_SpeakInHouse->par1C - 1].uType <= 16 ) | |
296 pItemNum = rand() % word_4F0F30[(signed int)window_SpeakInHouse->par1C - 139] + 11 * v4 + 400; | |
297 } | |
298 } | |
299 if ( pItemNum == 487 ) | |
300 { | |
301 if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) ) | |
302 pItemNum = 486; | |
303 } | |
304 ItemGen * item_spellbook = &pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i]; | |
305 item_spellbook->Reset(); | |
306 pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].uItemID = pItemNum; | |
1567
9f8b3e904e14
Player::ReceiveDamage, very small edits; prepended "Is" to item functions returning bool values (broken, indetified, stolen)
Grumpy7
parents:
1529
diff
changeset
|
307 pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].IsIdentified(); |
1300 | 308 ItemsInShopTexture[i] = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[pItemNum].pIconName, TEXTURE_16BIT_PALETTE); |
309 } | |
310 return; | |
311 } |