annotate GUI/UI/UIBooks.cpp @ 2553:48708da03b7f

Party Creation UI logic separated from MainMenu
author a.parshin
date Wed, 13 May 2015 02:20:05 +0200
parents 3121fb54a110
children dd36326a9994
rev   line source
2501
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
1 #define _CRTDBG_MAP_ALLOC
2548
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
2 #define _CRT_SECURE_NO_WARNINGS
2501
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
3 #include <stdlib.h>
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
4 #include <crtdbg.h>
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
5
2548
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
6 #include "Engine/Engine.h"
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
7 #include "Engine/Graphics/Render.h"
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
8 #include "Engine/LOD.h"
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
9 #include "Engine/texts.h"
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
10 #include "Engine/Awards.h"
2541
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2534
diff changeset
11
2548
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
12 #include "GUI/GUIFont.h"
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
13 #include "GUI/UI/UIBooks.h"
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
14
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
15 #include "Media/Audio/AudioPlayer.h"
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
16
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
17
2541
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2534
diff changeset
18
2548
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
19 //----- (00411597) --------------------------------------------------------
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
20 void GUIWindow_Book::Release()
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
21 {
2549
3121fb54a110 Rest & Spelbook refactored into class
a.parshin
parents: 2548
diff changeset
22 // -----------------------------------------
3121fb54a110 Rest & Spelbook refactored into class
a.parshin
parents: 2548
diff changeset
23 // 0041C26A void GUIWindow::Release --- part
2548
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
24 free(pSpellFont);
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
25 pSpellFont = nullptr;
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
26 free(pBookFont);
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
27 pBookFont = nullptr;
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
28 free(pBook2Font);
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
29 pBook2Font = nullptr;
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
30 free(pAutonoteFont);
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
31 pAutonoteFont = nullptr;
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
32 pTexture_mapbordr->Release();
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
33 pAudioPlayer->PlaySound(SOUND_closebook, 0, 0, -1, 0, 0, 0, 0);
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
34 pIcons_LOD->RemoveTexturesPackFromTextureList();
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
35 dword_506364 = 0;
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
36
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
37 GUIWindow::Release();
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
38 }
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
39
2501
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
40
2548
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
41 GUIWindow_Book::GUIWindow_Book() :
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
42 GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, nullptr)
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
43 {
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
44 }
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
45
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
46 void GUIWindow_Book::BasicBookInitialization()
2501
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
47 {
2548
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
48 // ----- (00411BFC) --------------------------------------------------------
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
49 // void GUIWindow::InitializeBookView() --- part
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
50 // {
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
51 pAudioPlayer->StopChannels(-1, -1);
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
52 InitializeFonts();
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
53 CreateButton(475, 445, 158, 34, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0); // Close
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
54 current_screen_type = SCREEN_BOOKS;
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
55 full_num_items_in_book = 0;
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
56 books_primary_item_per_page = 0;
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
57 books_page_number = 0;
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
58 num_achieved_awards = 0;
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
59 }
2501
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
60
2548
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
61 //----- (00411AAA) --------------------------------------------------------
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
62 void GUIWindow_Book::InitializeFonts()
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
63 {
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
64 pAudioPlayer->StopChannels(-1, -1);
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
65 ++pIcons_LOD->uTexturePacksCount;
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
66 if (!pIcons_LOD->uNumPrevLoadedFiles)
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
67 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
68 pAudioPlayer->PlaySound(SOUND_openbook, 0, 0, -1, 0, 0, 0, 0);
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
69 pTexture_mapbordr = pIcons_LOD->LoadTexturePtr("mapbordr", TEXTURE_16BIT_PALETTE);
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
70 pBookFont = LoadFont("book.fnt", "FONTPAL", NULL);
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
71 pBook2Font = LoadFont("book2.fnt", "FONTPAL", NULL);
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
72 pAutonoteFont = LoadFont("autonote.fnt", "FONTPAL", NULL);
87e5590d034b All Books windows are refactored into respective classes
a.parshin
parents: 2541
diff changeset
73 pSpellFont = LoadFont("spell.fnt", "FONTPAL", NULL);
2501
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
74 }
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
75
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
76
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
77 //----- (0041140B) --------------------------------------------------------
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
78 void OnCloseSpellBookPage()
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
79 {
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
80 GUIButton *pNextButton; // esi@4
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
81 for ( uint i = 1; i <= 11; i++ )
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
82 {
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
83 SBPageCSpellsTextureList[i]->Release();
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
84 SBPageSSpellsTextureList[i]->Release();
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
85 }
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
86 pIcons_LOD->SyncLoadedFilesCount();
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
87 if ( pGUIWindow_CurrentMenu->pControlsHead )
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
88 {
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
89 do
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
90 {
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
91 pNextButton = pGUIWindow_CurrentMenu->pControlsHead->pNext;
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
92 free(pGUIWindow_CurrentMenu->pControlsHead);
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
93 pGUIWindow_CurrentMenu->pControlsHead = pNextButton;
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
94 }
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
95 while ( pNextButton );
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
96 }
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
97 pGUIWindow_CurrentMenu->pControlsHead = 0;
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
98 pGUIWindow_CurrentMenu->pControlsTail = 0;
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
99 pGUIWindow_CurrentMenu->uNumControls = 0;
0ff6a9e9bf7f GUI folger
Ritor1
parents:
diff changeset
100 }