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