Mercurial > mm7
annotate UI/Books/UISpellBook.cpp @ 2309:a07bf9afa652
ActorDamageFromMonster minor cleanups
author | Grumpy7 |
---|---|
date | Mon, 17 Mar 2014 22:49:54 +0100 |
parents | aff7a7b072b7 |
children | ddb803517a48 |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2212
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
1312 | 2 #include "..\..\MM7.h" |
3 #include "..\..\Render.h" | |
4 #include "..\..\Mouse.h" | |
5 #include "..\UIBooks.h" | |
6 #include "..\..\GUIWindow.h" | |
7 #include "..\..\GUIFont.h" | |
8 #include "..\..\Party.h" | |
9 #include "..\..\AudioPlayer.h" | |
10 #include "..\..\LOD.h" | |
11 #include "..\..\Viewport.h" | |
12 #include "..\..\texts.h" | |
13 #include "..\..\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) | |
1402 | 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; | |
1312 | 27 |
1402 | 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); | |
1312 | 34 |
1402 | 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); | |
1312 | 37 } |
1402 | 38 } |
39 } | |
1312 | 40 |
41 //----- (00411597) -------------------------------------------------------- | |
1402 | 42 void OnCloseBook() |
1451 | 43 { |
1583 | 44 free(pSpellFont); |
1451 | 45 pSpellFont = nullptr; |
1583 | 46 free(pBookFont); |
1451 | 47 pBookFont = nullptr; |
1583 | 48 free(pBook2Font); |
1451 | 49 pBook2Font = nullptr; |
1583 | 50 free(pAutonoteFont); |
1451 | 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 } | |
1312 | 57 |
58 //----- (00412AF9) -------------------------------------------------------- | |
59 static void BookUI_Spellbook_DrawCurrentSchoolBackground() | |
60 { | |
1455 | 61 int pTexID = 0; |
1312 | 62 if ( uActiveCharacter ) |
1455 | 63 pTexID = pParty->pPlayers[uActiveCharacter - 1].lastOpenedSpellbookPage; |
64 pRenderer->DrawTextureIndexed(8, 8, pSpellBookPagesTextr[pTexID]); | |
1402 | 65 pRenderer->DrawTextureIndexed(476, 450, pSBQuickSpellBtnTextr); |
66 pRenderer->DrawTextureIndexed(561, 450, pSpellBookCloseBtnTextr); | |
1312 | 67 } |
68 | |
69 //----- (00412B58) -------------------------------------------------------- | |
70 void DrawSpellBookContent(Player *player) | |
71 { | |
1402 | 72 Texture *PendingTexture; // edi@1 |
73 Texture *pTexture; // edx@5 | |
1312 | 74 int v10; // eax@13 |
1402 | 75 unsigned int pX_coord; // esi@18 |
76 unsigned int pY_coord; // edi@18 | |
1312 | 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 | |
1402 | 89 PendingTexture = pIcons_LOD->GetTexture(pIcons_LOD->FindTextureByName("Pending")); |
1312 | 90 pRenderer->ClearZBuffer(0, 479); |
1402 | 91 if ( (11 * player->lastOpenedSpellbookPage) || ((11 * player->lastOpenedSpellbookPage) + 11) )//??? maybe structure need fix |
1312 | 92 { |
1402 | 93 for ( uint i = 1; i <= 11; ++i ) |
1312 | 94 { |
1460
ff2118028c71
renaming _guilds_member_bits to _achieved_awards_bits
Gloval
parents:
1455
diff
changeset
|
95 if (player->_achieved_awards_bits[(11 * player->lastOpenedSpellbookPage) + i + 63] ) |
1312 | 96 { |
1402 | 97 if ( SBPageSSpellsTextureList[i] != PendingTexture ) |
1312 | 98 { |
1402 | 99 if ( quick_spell_at_page == i ) |
100 pTexture = SBPageCSpellsTextureList[i]; | |
101 else | |
102 pTexture = SBPageSSpellsTextureList[i]; | |
103 if ( pTexture->pLevelOfDetail0_prolly_alpha_mask ) | |
1312 | 104 { |
1402 | 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; | |
2212 | 107 if ( pTexture->pBits & 0x200 ) |
1402 | 108 pRenderer->DrawTextureTransparent(pX_coord, pY_coord, pTexture); |
1312 | 109 else |
1402 | 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); | |
1312 | 113 } |
114 } | |
115 } | |
116 } | |
117 } | |
118 | |
1402 | 119 pMouse->GetCursorPos(&a2); |
1397 | 120 v10 = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF; |
1312 | 121 if ( v10 ) |
122 { | |
1402 | 123 if ( SBPageCSpellsTextureList[v10]->pLevelOfDetail0_prolly_alpha_mask ) |
1312 | 124 { |
1402 | 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; | |
2212 | 127 if ( SBPageCSpellsTextureList[v10]->pBits & 0x200 ) |
1402 | 128 pRenderer->DrawTextureTransparent(pX_coord, pY_coord, SBPageCSpellsTextureList[v10]); |
1312 | 129 else |
1402 | 130 pRenderer->DrawTextureIndexed(pX_coord, pY_coord, SBPageCSpellsTextureList[v10]); |
1312 | 131 } |
132 } | |
2197 | 133 //pX_coord = (unsigned int)&player->pActiveSkills[PLAYER_SKILL_FIRE]; |
134 //pY_coord = (unsigned int)&player->pActiveSkills[PLAYER_SKILL_FIRE]; | |
1402 | 135 for ( uint i = 0; i < 9; i++ ) |
1312 | 136 { |
2197 | 137 if ( player->pActiveSkills[PLAYER_SKILL_FIRE + i] ) |
1312 | 138 { |
1402 | 139 if ( player->lastOpenedSpellbookPage == i ) |
1312 | 140 { |
1402 | 141 pPageTexture = pTextures_tabs[i][1]; |
142 pX_coord = texture_tab_coord1[i][0]; | |
143 pY_coord = texture_tab_coord1[i][1]; | |
1312 | 144 } |
145 else | |
146 { | |
1402 | 147 pPageTexture = pTextures_tabs[i][0]; |
148 pX_coord = texture_tab_coord0[i][0]; | |
149 pY_coord = texture_tab_coord0[i][1]; | |
1312 | 150 } |
1402 | 151 pRenderer->DrawTextureTransparent(pX_coord, pY_coord, pPageTexture); |
1312 | 152 } |
153 } | |
154 } |