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