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