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