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