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