2501
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
2541
|
6
|
|
7 #include "Engine/Engine.h"
|
|
8
|
2501
|
9 #include "UIBooks.h"
|
|
10 #include "..\../Engine/Graphics/Render.h"
|
2502
|
11 #include "..\../GUI/GUIWindow.h"
|
|
12 #include "..\../GUI/GUIFont.h"
|
|
13 #include "..\../Media/Audio/AudioPlayer.h"
|
2501
|
14 #include "..\../Engine/LOD.h"
|
|
15
|
|
16 //----- (00413CC6) --------------------------------------------------------
|
|
17 void BookUI_Draw(WindowType book)
|
|
18 {
|
|
19 pRenderer->DrawTextureIndexed(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId));
|
|
20 switch (book)
|
|
21 {
|
|
22 case WINDOW_QuestBook: BookUI_Questbook_Draw(); break;
|
|
23 case WINDOW_AutonotesBook: BookUI_Autonotes_Draw(); break;
|
|
24 case WINDOW_MapsBook: BookUI_Map_Draw(); break;
|
|
25 case WINDOW_CalendarBook: BookUI_Calendar_Draw(); break;
|
|
26 case WINDOW_JournalBook: BookUI_Journal_Draw(); break;
|
|
27
|
|
28 case WINDOW_LloydsBeacon: DrawLloydBeaconsScreen(); break;
|
|
29 case WINDOW_TownPortal: BookUI_DrawTownPortalMap(); break;
|
|
30 }
|
|
31 }
|
|
32
|
|
33 //----- (0041192C) --------------------------------------------------------
|
|
34 void InitializeBookTextures()
|
|
35 {
|
|
36 pAudioPlayer->StopChannels(-1, -1);
|
|
37 ++pIcons_LOD->uTexturePacksCount;
|
|
38 if ( !pIcons_LOD->uNumPrevLoadedFiles )
|
|
39 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
|
2534
|
40 pAudioPlayer->PlaySound(SOUND_openbook, 0, 0, -1, 0, 0, 0, 0);
|
2501
|
41 pSpellBookPagesTextr_9 = pIcons_LOD->LoadTexturePtr("book", TEXTURE_16BIT_PALETTE);
|
|
42 pTexture_pagemask = pIcons_LOD->LoadTexturePtr("pagemask", TEXTURE_16BIT_PALETTE);
|
|
43 pSpellBookCloseBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m5-u", TEXTURE_16BIT_PALETTE);
|
|
44 pSpellBookClickCloseBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m5-d", TEXTURE_16BIT_PALETTE);
|
|
45 pSBQuickSpellBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m6-u",TEXTURE_16BIT_PALETTE);
|
|
46
|
|
47 static const char *texNames[9] = // 004E24EC
|
|
48 {
|
|
49 "SBFB00", "SBAB00", "SBWB00", "SBEB00",
|
|
50 "SBSB00", "SBMB00", "SBBB00", "SBLB00", "SBDB00"
|
|
51 };
|
|
52
|
|
53 pSBClickQuickSpellBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m6-d",TEXTURE_16BIT_PALETTE);
|
|
54 for ( uint i = 0; i < 9; ++i )
|
|
55 {
|
|
56 pSpellBookPagesTextr[i] = pIcons_LOD->LoadTexturePtr(texNames[i], TEXTURE_16BIT_PALETTE);
|
|
57 sprintf(pTmpBuf.data(), "tab%da", i + 1);
|
|
58 pTextures_tabs[i][0] = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE);
|
|
59 sprintf(pTmpBuf.data(), "tab%db", i + 1);
|
|
60 pTextures_tabs[i][1] = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE);
|
|
61 }
|
|
62 }
|
|
63
|
|
64 //----- (00411AAA) --------------------------------------------------------
|
|
65 void InitializeBookFonts()
|
|
66 {
|
|
67 pAudioPlayer->StopChannels(-1, -1);
|
|
68 ++pIcons_LOD->uTexturePacksCount;
|
|
69 if ( !pIcons_LOD->uNumPrevLoadedFiles )
|
|
70 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
|
2534
|
71 pAudioPlayer->PlaySound(SOUND_openbook, 0, 0, -1, 0, 0, 0, 0);
|
2501
|
72 pTexture_mapbordr = pIcons_LOD->LoadTexturePtr("mapbordr", TEXTURE_16BIT_PALETTE);
|
|
73 pBookFont = LoadFont("book.fnt", "FONTPAL", NULL);
|
|
74 pBook2Font = LoadFont("book2.fnt", "FONTPAL", NULL);
|
|
75 pAutonoteFont = LoadFont("autonote.fnt", "FONTPAL", NULL);
|
|
76 pSpellFont = LoadFont("spell.fnt", "FONTPAL", NULL);
|
|
77 }
|
|
78
|
|
79 //----- (0041140B) --------------------------------------------------------
|
|
80 void OnCloseSpellBookPage()
|
|
81 {
|
|
82 GUIButton *pNextButton; // esi@4
|
|
83 for ( uint i = 1; i <= 11; i++ )
|
|
84 {
|
|
85 SBPageCSpellsTextureList[i]->Release();
|
|
86 SBPageSSpellsTextureList[i]->Release();
|
|
87 }
|
|
88 pIcons_LOD->SyncLoadedFilesCount();
|
|
89 if ( pGUIWindow_CurrentMenu->pControlsHead )
|
|
90 {
|
|
91 do
|
|
92 {
|
|
93 pNextButton = pGUIWindow_CurrentMenu->pControlsHead->pNext;
|
|
94 free(pGUIWindow_CurrentMenu->pControlsHead);
|
|
95 pGUIWindow_CurrentMenu->pControlsHead = pNextButton;
|
|
96 }
|
|
97 while ( pNextButton );
|
|
98 }
|
|
99 pGUIWindow_CurrentMenu->pControlsHead = 0;
|
|
100 pGUIWindow_CurrentMenu->pControlsTail = 0;
|
|
101 pGUIWindow_CurrentMenu->uNumControls = 0;
|
|
102 }
|
|
103
|
|
104 //----- (00411473) --------------------------------------------------------
|
|
105 void OnCloseSpellBook()
|
|
106 {
|
|
107 pTexture_pagemask->Release();
|
|
108 pSpellBookCloseBtnTextr->Release();
|
|
109 pSBQuickSpellBtnTextr->Release();
|
|
110 for ( uint i = 0; i < 9; ++i )
|
|
111 {
|
|
112 pSpellBookPagesTextr[i]->Release();
|
|
113 pTextures_tabs[i][0]->Release();
|
|
114 pTextures_tabs[i][1]->Release();
|
|
115 }
|
2534
|
116 pAudioPlayer->PlaySound(SOUND_openbook, 0, 0, -1, 0, 0, 0, 0);
|
2501
|
117 pIcons_LOD->RemoveTexturesPackFromTextureList();
|
|
118 }
|