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