annotate UI/Books/UISpellBook.cpp @ 1910:8d3723ca71e6

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