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)
|
1402
|
27 {
|
|
28 char pContainer[20]; // [sp+Ch] [bp-1Ch]@7
|
|
29
|
|
30 byte_506550 = 0;
|
|
31 if ( pPlayers[uActiveCharacter]->uQuickSpell && (unsigned __int8)pPlayers[uActiveCharacter]->uQuickSpell / 11 == spell_school )
|
|
32 quick_spell_at_page = (unsigned __int8)pPlayers[uActiveCharacter]->uQuickSpell - 11 * spell_school;
|
|
33 else
|
|
34 quick_spell_at_page = 0;
|
1312
|
35
|
1402
|
36 for (uint i = 1; i <= 11; ++i)
|
|
37 {
|
|
38 if (pPlayers[uActiveCharacter]->spellbook.pChapters[spell_school].bIsSpellAvailable[i - 1])
|
|
39 {
|
|
40 sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]);
|
|
41 SBPageSSpellsTextureList[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
|
1312
|
42
|
1402
|
43 sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]);
|
|
44 SBPageCSpellsTextureList[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
|
1312
|
45 }
|
1402
|
46 }
|
|
47 }
|
1312
|
48
|
|
49
|
|
50
|
|
51 //----- (00411597) --------------------------------------------------------
|
1402
|
52 void OnCloseBook()
|
1312
|
53 {
|
|
54 pAllocator->FreeChunk(pSpellFont);
|
|
55 pSpellFont = nullptr;
|
|
56 pAllocator->FreeChunk(pBookFont);
|
|
57 pBookFont = nullptr;
|
|
58 pAllocator->FreeChunk(pBook2Font);
|
|
59 pBook2Font = nullptr;
|
|
60 pAllocator->FreeChunk(pAutonoteFont);
|
|
61 pAutonoteFont = nullptr;
|
|
62 pTexture_mapbordr->Release();
|
|
63 pAudioPlayer->PlaySound(SOUND_CloseBook, 0, 0, -1, 0, 0, 0, 0);
|
|
64 pIcons_LOD->_4114F2();
|
|
65 dword_506364 = 0;
|
|
66 }
|
|
67
|
|
68
|
|
69
|
|
70 //----- (00412AF9) --------------------------------------------------------
|
|
71 static void BookUI_Spellbook_DrawCurrentSchoolBackground()
|
|
72 {
|
|
73 int v0; // ecx@1
|
|
74
|
|
75 v0 = 0;
|
|
76 if ( uActiveCharacter )
|
|
77 v0 = pParty->pPlayers[uActiveCharacter - 1].lastOpenedSpellbookPage;//*((char *)&pParty->pPartyBuffs[5].uExpireTime + 6972 * uActiveCharacter + 2);
|
|
78 pRenderer->DrawTextureIndexed(8, 8, pSpellBookPagesTextr[v0]);
|
1402
|
79 pRenderer->DrawTextureIndexed(476, 450, pSBQuickSpellBtnTextr);
|
|
80 pRenderer->DrawTextureIndexed(561, 450, pSpellBookCloseBtnTextr);
|
1312
|
81 }
|
|
82
|
|
83 //----- (00412B58) --------------------------------------------------------
|
|
84 void DrawSpellBookContent(Player *player)
|
|
85 {
|
1402
|
86 Texture *PendingTexture; // edi@1
|
|
87 Texture *pTexture; // edx@5
|
1312
|
88 int v10; // eax@13
|
1402
|
89 unsigned int pX_coord; // esi@18
|
|
90 unsigned int pY_coord; // edi@18
|
1312
|
91 Texture *pPageTexture; // eax@21
|
|
92 signed int v22; // [sp-4h] [bp-24h]@22
|
|
93 POINT a2; // [sp+18h] [bp-8h]@13
|
|
94
|
|
95 static unsigned int texture_tab_coord1[9][2]=
|
|
96 {{406, 9}, {406, 46}, {406, 84}, {406,121}, {407,158}, {405, 196}, {405, 234}, {405, 272}, {405,309} };
|
|
97
|
|
98 static unsigned int texture_tab_coord0[9][2]=
|
|
99 {{415, 10}, {415, 46}, {415, 83}, {415,121}, {415,158}, {416, 196}, {416, 234}, {416, 271}, {416,307} };
|
|
100
|
|
101 BookUI_Spellbook_DrawCurrentSchoolBackground();
|
|
102
|
1402
|
103 PendingTexture = pIcons_LOD->GetTexture(pIcons_LOD->FindTextureByName("Pending"));
|
1312
|
104 pRenderer->ClearZBuffer(0, 479);
|
1402
|
105 if ( (11 * player->lastOpenedSpellbookPage) || ((11 * player->lastOpenedSpellbookPage) + 11) )//??? maybe structure need fix
|
1312
|
106 {
|
1402
|
107 for ( uint i = 1; i <= 11; ++i )
|
1312
|
108 {
|
1402
|
109 if (player->_guilds_member_bits[(11 * player->lastOpenedSpellbookPage) + i + 63] )
|
1312
|
110 {
|
1402
|
111 if ( SBPageSSpellsTextureList[i] != PendingTexture )
|
1312
|
112 {
|
1402
|
113 if ( quick_spell_at_page == i )
|
|
114 pTexture = SBPageCSpellsTextureList[i];
|
|
115 else
|
|
116 pTexture = SBPageSSpellsTextureList[i];
|
|
117 if ( pTexture->pLevelOfDetail0_prolly_alpha_mask )
|
1312
|
118 {
|
1402
|
119 pX_coord = pViewport->uViewportTL_X + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Xpos;
|
|
120 pY_coord = pViewport->uViewportTL_Y + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Ypos;
|
|
121 if ( BYTE1(pTexture->pBits) & 2 )
|
|
122 pRenderer->DrawTextureTransparent(pX_coord, pY_coord, pTexture);
|
1312
|
123 else
|
1402
|
124 pRenderer->DrawTextureIndexed(pX_coord, pY_coord, pTexture);
|
|
125 pRenderer->DrawMaskToZBuffer(pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Xpos,
|
|
126 pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Ypos, pTexture, i);
|
1312
|
127 }
|
|
128 }
|
|
129 }
|
|
130 }
|
|
131 }
|
|
132
|
1402
|
133 pMouse->GetCursorPos(&a2);
|
1397
|
134 v10 = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF;
|
1312
|
135 if ( v10 )
|
|
136 {
|
1402
|
137 if ( SBPageCSpellsTextureList[v10]->pLevelOfDetail0_prolly_alpha_mask )
|
1312
|
138 {
|
1402
|
139 pX_coord = pViewport->uViewportTL_X + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][v10]].Xpos;
|
|
140 pY_coord = pViewport->uViewportTL_Y + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][v10]].Ypos;
|
|
141 if ( BYTE1(SBPageCSpellsTextureList[v10]->pBits) & 2 )
|
|
142 pRenderer->DrawTextureTransparent(pX_coord, pY_coord, SBPageCSpellsTextureList[v10]);
|
1312
|
143 else
|
1402
|
144 pRenderer->DrawTextureIndexed(pX_coord, pY_coord, SBPageCSpellsTextureList[v10]);
|
1312
|
145 }
|
|
146 }
|
1402
|
147 pX_coord = (unsigned int)&player->pActiveSkills[12];
|
|
148 pY_coord = (unsigned int)&player->pActiveSkills[12];
|
|
149 for ( uint i = 0; i < 9; i++ )
|
1312
|
150 {
|
1402
|
151 if ( player->pActiveSkills[12 + i] )
|
1312
|
152 {
|
1402
|
153 if ( player->lastOpenedSpellbookPage == i )
|
1312
|
154 {
|
1402
|
155 pPageTexture = pTextures_tabs[i][1];
|
|
156 pX_coord = texture_tab_coord1[i][0];
|
|
157 pY_coord = texture_tab_coord1[i][1];
|
1312
|
158 }
|
|
159 else
|
|
160 {
|
1402
|
161 pPageTexture = pTextures_tabs[i][0];
|
|
162 pX_coord = texture_tab_coord0[i][0];
|
|
163 pY_coord = texture_tab_coord0[i][1];
|
1312
|
164 }
|
1402
|
165 pRenderer->DrawTextureTransparent(pX_coord, pY_coord, pPageTexture);
|
1312
|
166 }
|
|
167 }
|
|
168 } |