annotate UI/UIBooks.cpp @ 2438:c10c639f8365

* Fixed releasing movie for movie-less transitions.
author a.parshin
date Thu, 24 Jul 2014 00:31:49 +0300
parents f4af3b203f65
children 5abd8fc8f1c6
rev   line source
2415
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2253
diff changeset
1 #define _CRTDBG_MAP_ALLOC
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2253
diff changeset
2 #include <stdlib.h>
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2253
diff changeset
3 #include <crtdbg.h>
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2253
diff changeset
4
2253
aff7a7b072b7 adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents: 2153
diff changeset
5 #define _CRT_SECURE_NO_WARNINGS
1299
8c2f689b5f0b folder UI
Ritor1
parents: 1298
diff changeset
6 #include "..\MM7.h"
1310
0665a061132b autonotes and quest tables overflow fixed
Gloval
parents: 1299
diff changeset
7 #include "UIBooks.h"
1312
ae435824ac4d books code splitted to separate files
Gloval
parents: 1310
diff changeset
8 #include "..\Render.h"
1299
8c2f689b5f0b folder UI
Ritor1
parents: 1298
diff changeset
9 #include "..\GUIWindow.h"
8c2f689b5f0b folder UI
Ritor1
parents: 1298
diff changeset
10 #include "..\GUIFont.h"
8c2f689b5f0b folder UI
Ritor1
parents: 1298
diff changeset
11 #include "..\AudioPlayer.h"
8c2f689b5f0b folder UI
Ritor1
parents: 1298
diff changeset
12 #include "..\LOD.h"
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
13
1299
8c2f689b5f0b folder UI
Ritor1
parents: 1298
diff changeset
14 #include "..\mm7_data.h"
1298
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
15
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
16 //----- (00413CC6) --------------------------------------------------------
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
17 void BookUI_Draw(WindowType book)
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
18 {
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
19 pRenderer->DrawTextureIndexed(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId));
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
20 switch (book)
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
21 {
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
22 case WINDOW_QuestBook: BookUI_Questbook_Draw(); break;
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
23 case WINDOW_AutonotesBook: BookUI_Autonotes_Draw(); break;
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
24 case WINDOW_MapsBook: BookUI_Map_Draw(); break;
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
25 case WINDOW_CalendarBook: BookUI_Calendar_Draw(); break;
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
26 case WINDOW_JournalBook: BookUI_Journal_Draw(); break;
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
27
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
28 case WINDOW_LloydsBeacon: DrawLloydBeaconsScreen(); break;
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
29 case WINDOW_TownPortal: BookUI_DrawTownPortalMap(); break;
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
30 }
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
31 }
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
32
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
33 //----- (0041192C) --------------------------------------------------------
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
34 void InitializeBookTextures()
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
35 {
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
36 pAudioPlayer->StopChannels(-1, -1);
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
37 ++pIcons_LOD->uTexturePacksCount;
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
38 if ( !pIcons_LOD->uNumPrevLoadedFiles )
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
39 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
40 pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
41 pSpellBookPagesTextr_9 = pIcons_LOD->LoadTexturePtr("book", TEXTURE_16BIT_PALETTE);
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
42 pTexture_pagemask = pIcons_LOD->LoadTexturePtr("pagemask", TEXTURE_16BIT_PALETTE);
1402
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
43 pSpellBookCloseBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m5-u", TEXTURE_16BIT_PALETTE);
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
44 pSpellBookClickCloseBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m5-d", TEXTURE_16BIT_PALETTE);
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
45 pSBQuickSpellBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m6-u",TEXTURE_16BIT_PALETTE);
1298
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
46
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
47 static const char *texNames[9] = // 004E24EC
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
48 {
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
49 "SBFB00", "SBAB00", "SBWB00", "SBEB00",
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
50 "SBSB00", "SBMB00", "SBBB00", "SBLB00", "SBDB00"
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
51 };
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
52
1402
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
53 pSBClickQuickSpellBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m6-d",TEXTURE_16BIT_PALETTE);
1455
bfe342ae0c1f DrawPaperdoll cleaning
Ritor1
parents: 1451
diff changeset
54 for ( uint i = 0; i < 9; ++i )
1298
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
55 {
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
56 pSpellBookPagesTextr[i] = pIcons_LOD->LoadTexturePtr(texNames[i], TEXTURE_16BIT_PALETTE);
1455
bfe342ae0c1f DrawPaperdoll cleaning
Ritor1
parents: 1451
diff changeset
57 sprintf(pTmpBuf.data(), "tab%da", i + 1);
1298
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
58 pTextures_tabs[i][0] = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE);
1455
bfe342ae0c1f DrawPaperdoll cleaning
Ritor1
parents: 1451
diff changeset
59 sprintf(pTmpBuf.data(), "tab%db", i + 1);
1298
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
60 pTextures_tabs[i][1] = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE);
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
61 }
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
62 }
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
63
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
64 //----- (00411AAA) --------------------------------------------------------
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
65 void InitializeBookFonts()
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
66 {
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
67 pAudioPlayer->StopChannels(-1, -1);
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
68 ++pIcons_LOD->uTexturePacksCount;
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
69 if ( !pIcons_LOD->uNumPrevLoadedFiles )
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
70 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
71 pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
72 pTexture_mapbordr = pIcons_LOD->LoadTexturePtr("mapbordr", TEXTURE_16BIT_PALETTE);
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
73 pBookFont = LoadFont("book.fnt", "FONTPAL", NULL);
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
74 pBook2Font = LoadFont("book2.fnt", "FONTPAL", NULL);
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
75 pAutonoteFont = LoadFont("autonote.fnt", "FONTPAL", NULL);
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
76 pSpellFont = LoadFont("spell.fnt", "FONTPAL", NULL);
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
77 }
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
78
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
79 //----- (0041140B) --------------------------------------------------------
1402
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
80 void OnCloseSpellBookPage()
1298
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
81 {
1402
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
82 GUIButton *pNextButton; // esi@4
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
83 for ( uint i = 1; i <= 11; i++ )
1298
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
84 {
1402
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
85 SBPageCSpellsTextureList[i]->Release();
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
86 SBPageSSpellsTextureList[i]->Release();
1298
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
87 }
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
88 pIcons_LOD->SyncLoadedFilesCount();
1402
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
89 if ( pGUIWindow_CurrentMenu->pControlsHead )
1298
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
90 {
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
91 do
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
92 {
1402
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
93 pNextButton = pGUIWindow_CurrentMenu->pControlsHead->pNext;
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
94 free(pGUIWindow_CurrentMenu->pControlsHead);
1402
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
95 pGUIWindow_CurrentMenu->pControlsHead = pNextButton;
1298
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
96 }
1402
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
97 while ( pNextButton );
1298
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
98 }
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
99 pGUIWindow_CurrentMenu->pControlsHead = 0;
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
100 pGUIWindow_CurrentMenu->pControlsTail = 0;
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
101 pGUIWindow_CurrentMenu->uNumControls = 0;
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
102 }
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
103
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
104 //----- (00411473) --------------------------------------------------------
1402
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
105 void OnCloseSpellBook()
1298
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
106 {
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
107 pTexture_pagemask->Release();
1402
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
108 pSpellBookCloseBtnTextr->Release();
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1312
diff changeset
109 pSBQuickSpellBtnTextr->Release();
1455
bfe342ae0c1f DrawPaperdoll cleaning
Ritor1
parents: 1451
diff changeset
110 for ( uint i = 0; i < 9; ++i )
1403
Ritor1
parents: 1402
diff changeset
111 {
Ritor1
parents: 1402
diff changeset
112 pSpellBookPagesTextr[i]->Release();
Ritor1
parents: 1402
diff changeset
113 pTextures_tabs[i][0]->Release();
Ritor1
parents: 1402
diff changeset
114 pTextures_tabs[i][1]->Release();
Ritor1
parents: 1402
diff changeset
115 }
1298
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
116 pAudioPlayer->PlaySound(SOUND_CloseBook, 0, 0, -1, 0, 0, 0, 0);
1405
c0b273d33338 RemoveTexturesPackFromTextureList and RemoveTexturesFromTextureList
Ritor1
parents: 1404
diff changeset
117 pIcons_LOD->RemoveTexturesPackFromTextureList();
1298
b97d0cdd6c79 new folder UI
Ritor1
parents:
diff changeset
118 }