annotate GUI/UI/UIBooks.cpp @ 2541:a902abdfc7f2

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