1312
|
1 #ifdef _MSC_VER
|
|
2 #define _CRT_SECURE_NO_WARNINGS
|
|
3 #endif
|
|
4
|
|
5 #include <assert.h>
|
|
6
|
|
7 #include "..\..\MM7.h"
|
|
8 #include "..\..\Render.h"
|
|
9 #include "..\..\Mouse.h"
|
|
10 #include "..\UIBooks.h"
|
|
11 #include "..\..\GUIWindow.h"
|
|
12 #include "..\..\GUIFont.h"
|
|
13 #include "..\..\Party.h"
|
|
14 #include "..\..\AudioPlayer.h"
|
|
15 #include "..\..\LOD.h"
|
|
16 #include "..\..\Allocator.h"
|
|
17 #include "..\..\Viewport.h"
|
|
18 #include "..\..\texts.h"
|
|
19 //
|
|
20 #include "..\..\mm7_data.h"
|
|
21
|
|
22
|
|
23 std::array<char *, 9> spellbook_texture_filename_suffices = {{"f", "a", "w", "e", "s", "m", "b", "l", "d"}}; // weak
|
|
24
|
|
25 //----- (00411300) --------------------------------------------------------
|
|
26 void LoadSpellbook(unsigned int spell_school)
|
|
27 {
|
|
28 //unsigned int v1; // esi@1
|
|
29 Player *pPlayer; // ecx@1
|
|
30 char v3; // al@1
|
|
31 //int v4; // edi@5
|
|
32 //Texture *result; // eax@6
|
|
33 //unsigned char *v6; // edi@7
|
|
34 //unsigned int v7; // eax@7
|
|
35 //unsigned __int8 v8; // sf@8
|
|
36 //unsigned __int8 v9; // of@8
|
|
37 char pContainer[20]; // [sp+Ch] [bp-1Ch]@7
|
|
38 //Texture *v11; // [sp+20h] [bp-8h]@5
|
|
39 //int v12; // [sp+24h] [bp-4h]@5
|
|
40
|
|
41 byte_506550 = 0;
|
|
42 //v1 = uID;
|
|
43 pPlayer = pPlayers[uActiveCharacter];
|
|
44 v3 = pPlayer->uQuickSpell;
|
|
45 if ( v3 && (unsigned __int8)v3 / 11 == spell_school )
|
|
46 quick_spell_at_page = (unsigned __int8)v3 - 11 * spell_school;
|
|
47 else
|
|
48 quick_spell_at_page = 0;
|
|
49
|
|
50 for (uint i = 1; i < 12; ++i)
|
|
51 {
|
|
52 if (pPlayer->spellbook.pChapters[spell_school].bIsSpellAvailable[i - 1])
|
|
53 {
|
|
54 sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]);
|
|
55 dword_506408[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
|
|
56
|
|
57 sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]);
|
|
58 dword_5063D8[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
|
|
59 }
|
|
60 }
|
|
61 }
|
|
62
|
|
63
|
|
64
|
|
65 //----- (00411597) --------------------------------------------------------
|
|
66 void OnCloseSpellBook()
|
|
67 {
|
|
68 pAllocator->FreeChunk(pSpellFont);
|
|
69 pSpellFont = nullptr;
|
|
70 pAllocator->FreeChunk(pBookFont);
|
|
71 pBookFont = nullptr;
|
|
72 pAllocator->FreeChunk(pBook2Font);
|
|
73 pBook2Font = nullptr;
|
|
74 pAllocator->FreeChunk(pAutonoteFont);
|
|
75 pAutonoteFont = nullptr;
|
|
76 pTexture_mapbordr->Release();
|
|
77 pAudioPlayer->PlaySound(SOUND_CloseBook, 0, 0, -1, 0, 0, 0, 0);
|
|
78 pIcons_LOD->_4114F2();
|
|
79 dword_506364 = 0;
|
|
80 }
|
|
81
|
|
82
|
|
83
|
|
84 //----- (00412AF9) --------------------------------------------------------
|
|
85 static void BookUI_Spellbook_DrawCurrentSchoolBackground()
|
|
86 {
|
|
87 int v0; // ecx@1
|
|
88
|
|
89 v0 = 0;
|
|
90 if ( uActiveCharacter )
|
|
91 v0 = pParty->pPlayers[uActiveCharacter - 1].lastOpenedSpellbookPage;//*((char *)&pParty->pPartyBuffs[5].uExpireTime + 6972 * uActiveCharacter + 2);
|
|
92 pRenderer->DrawTextureIndexed(8, 8, pSpellBookPagesTextr[v0]);
|
|
93 pRenderer->DrawTextureIndexed(0x1DCu, 0x1C2u, pTexture_50643C);
|
|
94 pRenderer->DrawTextureIndexed(0x231u, 0x1C2u, pTexture_506448);
|
|
95 }
|
|
96
|
|
97
|
|
98
|
|
99
|
|
100
|
|
101 //----- (00412B58) --------------------------------------------------------
|
|
102 void DrawSpellBookContent(Player *player)
|
|
103 {
|
|
104 //Player *v0; // ebx@1
|
|
105 int v1; // ebp@1
|
|
106 //unsigned int v2; // eax@1
|
|
107 Texture *v3; // edi@1
|
|
108 int v4; // esi@1
|
|
109 Texture *v5; // eax@3
|
|
110 Texture *v6; // edx@5
|
|
111 int v7; // eax@8
|
|
112 int v8; // eax@11
|
|
113 POINT *v9; // esi@13
|
|
114 int v10; // eax@13
|
|
115 Texture *v11; // edx@14
|
|
116 int v12; // eax@15
|
|
117 signed int v13; // ecx@18
|
|
118 unsigned int v14; // esi@18
|
|
119 unsigned int v15; // edi@18
|
|
120 Texture *pPageTexture; // eax@21
|
|
121 unsigned int v17; // [sp-Ch] [bp-2Ch]@8
|
|
122 unsigned int v18; // [sp-Ch] [bp-2Ch]@15
|
|
123 unsigned int v19; // [sp-8h] [bp-28h]@8
|
|
124 unsigned int v20; // [sp-8h] [bp-28h]@15
|
|
125 Texture *v21; // [sp-4h] [bp-24h]@15
|
|
126 signed int v22; // [sp-4h] [bp-24h]@22
|
|
127 Texture *v23; // [sp+10h] [bp-10h]@5
|
|
128 POINT a2; // [sp+18h] [bp-8h]@13
|
|
129 POINT v24;
|
|
130 int v25;
|
|
131
|
|
132 static unsigned int texture_tab_coord1[9][2]=
|
|
133 {{406, 9}, {406, 46}, {406, 84}, {406,121}, {407,158}, {405, 196}, {405, 234}, {405, 272}, {405,309} };
|
|
134
|
|
135 static unsigned int texture_tab_coord0[9][2]=
|
|
136 {{415, 10}, {415, 46}, {415, 83}, {415,121}, {415,158}, {416, 196}, {416, 234}, {416, 271}, {416,307} };
|
|
137
|
|
138 BookUI_Spellbook_DrawCurrentSchoolBackground();
|
|
139
|
|
140 //v0 = pPlayers[uActiveCharacter];
|
|
141 v1 = 11 * player->lastOpenedSpellbookPage;
|
|
142 //v2 = pIcons_LOD->FindTextureByName("Pending");
|
|
143 v3 = pIcons_LOD->GetTexture(pIcons_LOD->FindTextureByName("Pending"));
|
|
144 pRenderer->ClearZBuffer(0, 479);
|
|
145 v4 = 1;
|
|
146 if ( __OFSUB__(v1, v1 + 11) ^ 1 )
|
|
147 {
|
|
148 do
|
|
149 {
|
|
150 if ( *(&player->_guilds_member_bits[v1 + 63] + v4) )
|
|
151 {
|
|
152 v5 = (Texture *)dword_506408[v4];
|
|
153 if ( v5 != v3 )
|
|
154 {
|
|
155 if ( quick_spell_at_page == v4 )
|
|
156 {
|
|
157 v6 = dword_5063D8[v4];
|
|
158 v23 = dword_5063D8[v4];
|
|
159 }
|
|
160 else
|
|
161 {
|
|
162 v23 = dword_506408[v4];
|
|
163 v6 = v5;
|
|
164 }
|
|
165 if ( v6->pLevelOfDetail0_prolly_alpha_mask )
|
|
166 {
|
|
167 v7 = player->lastOpenedSpellbookPage;
|
|
168 // v7 = (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v4]);
|
|
169 v19 = pViewport->uViewportTL_Y + pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Ypos;
|
|
170 v17 = pViewport->uViewportTL_X + pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos;
|
|
171 if ( BYTE1(v6->pBits) & 2 )
|
|
172 pRenderer->DrawTextureTransparent(v17, v19, v6);
|
|
173 else
|
|
174 pRenderer->DrawTextureIndexed(v17, v19, v6);
|
|
175 pRenderer->DrawMaskToZBuffer(pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos,
|
|
176 pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Ypos, v23, v4);
|
|
177 }
|
|
178 }
|
|
179 }
|
|
180 ++v4;
|
|
181 }
|
|
182 while ( v4 - 1 < 11 );
|
|
183 }
|
|
184
|
|
185
|
|
186 v9 = pMouse->GetCursorPos(&a2);
|
|
187 v10 = pRenderer->pActiveZBuffer[v9->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v24)->y]] & 0xFFFF;
|
|
188 if ( v10 )
|
|
189 {
|
|
190 v11 = dword_5063D8[v10];
|
|
191 if ( v11->pLevelOfDetail0_prolly_alpha_mask )
|
|
192 {
|
|
193 v21 = dword_5063D8[v10];
|
|
194 v12 = player->lastOpenedSpellbookPage;
|
|
195 // v12 = (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v10]);
|
|
196 v20 = pViewport->uViewportTL_Y + pIconPos[v12][pSpellbookSpellIndices[v12][v10]].Ypos;
|
|
197 v18 = pViewport->uViewportTL_X + pIconPos[v12][pSpellbookSpellIndices[v12][v10]].Xpos;
|
|
198 if ( BYTE1(v11->pBits) & 2 )
|
|
199 pRenderer->DrawTextureTransparent(v18, v20, v21);
|
|
200 else
|
|
201 pRenderer->DrawTextureIndexed(v18, v20, v21);
|
|
202 }
|
|
203 }
|
|
204 v13 = 0;
|
|
205 a2.x = (LONG)&player->pActiveSkills[12];
|
|
206 v14 = (unsigned int)&player->pActiveSkills[12];
|
|
207 v15 = (unsigned int)&player->pActiveSkills[12];
|
|
208 v25 = 0;
|
|
209 do
|
|
210 {
|
|
211 if ( *(short *)a2.x )
|
|
212 {
|
|
213 if ( player->lastOpenedSpellbookPage == v13 )
|
|
214 {
|
|
215 pPageTexture = pTextures_tabs[v13][1];
|
|
216 v14=texture_tab_coord1[v13][0];
|
|
217 v15=texture_tab_coord1[v13][1];
|
|
218 }
|
|
219 else
|
|
220 {
|
|
221 pPageTexture = pTextures_tabs[v13][0];
|
|
222 v14=texture_tab_coord0[v13][0];
|
|
223 v15=texture_tab_coord0[v13][1];
|
|
224 }
|
|
225 pRenderer->DrawTextureTransparent(v14, v15, pPageTexture);
|
|
226 v13 = v25;
|
|
227 }
|
|
228 a2.x += 2;
|
|
229 ++v13;
|
|
230 v25 = v13;
|
|
231 }
|
|
232 while ( v13 < 9 );
|
|
233 } |