2501
|
1 #define _CRT_SECURE_NO_WARNINGS
|
|
2 #include "..\..\..\Engine/MM7.h"
|
|
3 #include "..\..\..\Engine/Graphics/Render.h"
|
2502
|
4 #include "..\..\..\IO/Mouse.h"
|
2501
|
5 #include "..\UIBooks.h"
|
2502
|
6 #include "..\..\..\GUI/GUIWindow.h"
|
|
7 #include "..\..\..\GUI/GUIFont.h"
|
2501
|
8 #include "..\..\..\Engine/Party.h"
|
2502
|
9 #include "..\..\..\Media/Audio/AudioPlayer.h"
|
2501
|
10 #include "..\..\..\Engine/LOD.h"
|
|
11 #include "..\..\..\Engine/Graphics/Viewport.h"
|
|
12 #include "..\..\..\Engine/texts.h"
|
|
13 #include "..\..\..\Engine/mm7_data.h"
|
|
14
|
|
15 std::array<char *, 9> spellbook_texture_filename_suffices = {{"f", "a", "w", "e", "s", "m", "b", "l", "d"}}; // weak
|
|
16
|
|
17 //----- (00411300) --------------------------------------------------------
|
|
18 void LoadSpellbook(unsigned int spell_school)
|
|
19 {
|
|
20 char pContainer[20]; // [sp+Ch] [bp-1Ch]@7
|
|
21
|
|
22 byte_506550 = 0;
|
|
23 if ( pPlayers[uActiveCharacter]->uQuickSpell && (unsigned __int8)pPlayers[uActiveCharacter]->uQuickSpell / 11 == spell_school )
|
|
24 quick_spell_at_page = (unsigned __int8)pPlayers[uActiveCharacter]->uQuickSpell - 11 * spell_school;
|
|
25 else
|
|
26 quick_spell_at_page = 0;
|
|
27
|
|
28 for (uint i = 1; i <= 11; ++i)
|
|
29 {
|
|
30 if (pPlayers[uActiveCharacter]->spellbook.pChapters[spell_school].bIsSpellAvailable[i - 1])
|
|
31 {
|
|
32 sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]);
|
|
33 SBPageSSpellsTextureList[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
|
|
34
|
|
35 sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]);
|
|
36 SBPageCSpellsTextureList[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
|
|
37 }
|
|
38 }
|
|
39 }
|
|
40
|
|
41 //----- (00411597) --------------------------------------------------------
|
|
42 void OnCloseBook()
|
|
43 {
|
|
44 free(pSpellFont);
|
|
45 pSpellFont = nullptr;
|
|
46 free(pBookFont);
|
|
47 pBookFont = nullptr;
|
|
48 free(pBook2Font);
|
|
49 pBook2Font = nullptr;
|
|
50 free(pAutonoteFont);
|
|
51 pAutonoteFont = nullptr;
|
|
52 pTexture_mapbordr->Release();
|
|
53 pAudioPlayer->PlaySound(SOUND_CloseBook, 0, 0, -1, 0, 0, 0, 0);
|
|
54 pIcons_LOD->RemoveTexturesPackFromTextureList();
|
|
55 dword_506364 = 0;
|
|
56 }
|
|
57
|
|
58 //----- (00412AF9) --------------------------------------------------------
|
|
59 static void BookUI_Spellbook_DrawCurrentSchoolBackground()
|
|
60 {
|
|
61 int pTexID = 0;
|
|
62 if ( uActiveCharacter )
|
|
63 pTexID = pParty->pPlayers[uActiveCharacter - 1].lastOpenedSpellbookPage;
|
|
64 pRenderer->DrawTextureIndexed(8, 8, pSpellBookPagesTextr[pTexID]);
|
|
65 pRenderer->DrawTextureIndexed(476, 450, pSBQuickSpellBtnTextr);
|
|
66 pRenderer->DrawTextureIndexed(561, 450, pSpellBookCloseBtnTextr);
|
|
67 }
|
|
68
|
|
69 //----- (00412B58) --------------------------------------------------------
|
|
70 void DrawSpellBookContent(Player *player)
|
|
71 {
|
|
72 Texture *PendingTexture; // edi@1
|
|
73 Texture *pTexture; // edx@5
|
|
74 int v10; // eax@13
|
|
75 unsigned int pX_coord; // esi@18
|
|
76 unsigned int pY_coord; // edi@18
|
|
77 Texture *pPageTexture; // eax@21
|
|
78 // signed int v22; // [sp-4h] [bp-24h]@22
|
|
79 POINT a2; // [sp+18h] [bp-8h]@13
|
|
80
|
|
81 static unsigned int texture_tab_coord1[9][2]=
|
|
82 {{406, 9}, {406, 46}, {406, 84}, {406,121}, {407,158}, {405, 196}, {405, 234}, {405, 272}, {405,309} };
|
|
83
|
|
84 static unsigned int texture_tab_coord0[9][2]=
|
|
85 {{415, 10}, {415, 46}, {415, 83}, {415,121}, {415,158}, {416, 196}, {416, 234}, {416, 271}, {416,307} };
|
|
86
|
|
87 BookUI_Spellbook_DrawCurrentSchoolBackground();
|
|
88
|
|
89 PendingTexture = pIcons_LOD->GetTexture(pIcons_LOD->FindTextureByName("Pending"));
|
|
90 pRenderer->ClearZBuffer(0, 479);
|
|
91 if ( (11 * player->lastOpenedSpellbookPage) || ((11 * player->lastOpenedSpellbookPage) + 11) )//??? maybe structure need fix
|
|
92 {
|
|
93 for ( uint i = 1; i <= 11; ++i )
|
|
94 {
|
|
95 if (player->_achieved_awards_bits[(11 * player->lastOpenedSpellbookPage) + i + 63] )
|
|
96 {
|
|
97 if ( SBPageSSpellsTextureList[i] != PendingTexture )
|
|
98 {
|
|
99 if ( quick_spell_at_page == i )
|
|
100 pTexture = SBPageCSpellsTextureList[i];
|
|
101 else
|
|
102 pTexture = SBPageSSpellsTextureList[i];
|
|
103 if ( pTexture->pLevelOfDetail0_prolly_alpha_mask )
|
|
104 {
|
|
105 pX_coord = pViewport->uViewportTL_X + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Xpos;
|
|
106 pY_coord = pViewport->uViewportTL_Y + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Ypos;
|
|
107 if ( pTexture->pBits & 0x200 )
|
|
108 pRenderer->DrawTextureTransparent(pX_coord, pY_coord, pTexture);
|
|
109 else
|
|
110 pRenderer->DrawTextureIndexed(pX_coord, pY_coord, pTexture);
|
|
111 pRenderer->DrawMaskToZBuffer(pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Xpos,
|
|
112 pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Ypos, pTexture, i);
|
|
113 }
|
|
114 }
|
|
115 }
|
|
116 }
|
|
117 }
|
|
118
|
|
119 pMouse->GetCursorPos(&a2);
|
|
120 v10 = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF;
|
|
121 if ( v10 )
|
|
122 {
|
|
123 if ( SBPageCSpellsTextureList[v10]->pLevelOfDetail0_prolly_alpha_mask )
|
|
124 {
|
|
125 pX_coord = pViewport->uViewportTL_X + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][v10]].Xpos;
|
|
126 pY_coord = pViewport->uViewportTL_Y + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][v10]].Ypos;
|
|
127 if ( SBPageCSpellsTextureList[v10]->pBits & 0x200 )
|
|
128 pRenderer->DrawTextureTransparent(pX_coord, pY_coord, SBPageCSpellsTextureList[v10]);
|
|
129 else
|
|
130 pRenderer->DrawTextureIndexed(pX_coord, pY_coord, SBPageCSpellsTextureList[v10]);
|
|
131 }
|
|
132 }
|
|
133 //pX_coord = (unsigned int)&player->pActiveSkills[PLAYER_SKILL_FIRE];
|
|
134 //pY_coord = (unsigned int)&player->pActiveSkills[PLAYER_SKILL_FIRE];
|
|
135 for ( uint i = 0; i < 9; i++ )
|
|
136 {
|
|
137 if ( player->pActiveSkills[PLAYER_SKILL_FIRE + i] )
|
|
138 {
|
|
139 if ( player->lastOpenedSpellbookPage == i )
|
|
140 {
|
|
141 pPageTexture = pTextures_tabs[i][1];
|
|
142 pX_coord = texture_tab_coord1[i][0];
|
|
143 pY_coord = texture_tab_coord1[i][1];
|
|
144 }
|
|
145 else
|
|
146 {
|
|
147 pPageTexture = pTextures_tabs[i][0];
|
|
148 pX_coord = texture_tab_coord0[i][0];
|
|
149 pY_coord = texture_tab_coord0[i][1];
|
|
150 }
|
|
151 pRenderer->DrawTextureTransparent(pX_coord, pY_coord, pPageTexture);
|
|
152 }
|
|
153 }
|
|
154 } |