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