annotate GUI/UI/Books/UISpellBook.cpp @ 2502:a77c34acdbc9

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