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