Mercurial > mm7
comparison GUI/UI/Books/JournalBook.cpp @ 2548:87e5590d034b
All Books windows are refactored into respective classes
author | a.parshin |
---|---|
date | Tue, 12 May 2015 03:24:19 +0200 |
parents | |
children | 0c67be4ec900 |
comparison
equal
deleted
inserted
replaced
2547:fed97f15d1e1 | 2548:87e5590d034b |
---|---|
1 #include "Engine/Engine.h" | |
2 #include "Engine/LOD.h" | |
3 #include "Engine/Party.h" | |
4 #include "Engine/Timer.h" | |
5 #include "Engine/Awards.h" | |
6 #include "Engine/texts.h" | |
7 #include "Engine/Graphics/IRender.h" | |
8 #include "Engine/Graphics/Viewport.h" | |
9 #include "Engine/Tables/StorylineTextTable.h" | |
10 | |
11 #include "GUI/GUIFont.h" | |
12 #include "GUI/UI/Books/JournalBook.h" | |
13 | |
14 #include "Media/Audio/AudioPlayer.h" | |
15 | |
16 | |
17 | |
18 GUIWindow_JournalBook::GUIWindow_JournalBook() : | |
19 GUIWindow_Book() | |
20 { | |
21 this->ptr_1C = (void *)WINDOW_JournalBook; // inherited from GUIWindow::GUIWindow | |
22 BasicBookInitialization(); | |
23 | |
24 // -------------------------------- | |
25 // 004304E7 Game_EventLoop --- part | |
26 pEventTimer->Pause(); | |
27 pAudioPlayer->StopChannels(-1, -1); | |
28 pBooksButtonOverlay = new GUIWindow_BooksButtonOverlay(0x258u, 0x169u, 0, 0, (int)pBtn_History, 0); | |
29 bFlashHistoryBook = 0; | |
30 | |
31 // ---------------------------------------------- | |
32 // 00411BFC GUIWindow::InitializeBookView -- part | |
33 char *pString; // eax@12 | |
34 int pTextHeight; // eax@12 | |
35 unsigned int page_count; // esi@12 | |
36 GUIWindow journal_window; // [sp+18h] [bp-54h]@8 | |
37 | |
38 pSpellBookPagesTextr_11 = pIcons_LOD->LoadTexturePtr("sbplayrnot", TEXTURE_16BIT_PALETTE); | |
39 pTex_book_button1_on = pIcons_LOD->LoadTexturePtr("tab-an-6b", TEXTURE_16BIT_PALETTE); | |
40 pTex_book_button2_on = pIcons_LOD->LoadTexturePtr("tab-an-7b", TEXTURE_16BIT_PALETTE); | |
41 pTex_book_button1_off = pIcons_LOD->LoadTexturePtr("tab-an-6a", TEXTURE_16BIT_PALETTE); | |
42 pTex_book_button2_off = pIcons_LOD->LoadTexturePtr("tab-an-7a", TEXTURE_16BIT_PALETTE); | |
43 | |
44 pBtn_Book_1 = this->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, | |
45 pTex_book_button1_on->uTextureWidth, pTex_book_button1_on->uTextureHeight, 1, 0, | |
46 UIMSG_ClickBooksBtn, 11, 0, pGlobalTXT_LocalizationStrings[192], pTex_book_button1_on, 0); | |
47 pBtn_Book_2 = this->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_book_button2_on->uTextureHeight, | |
48 pTex_book_button2_on->uTextureHeight, 1, 0, UIMSG_ClickBooksBtn, 10, 0, | |
49 pGlobalTXT_LocalizationStrings[193], pTex_book_button2_on, 0); | |
50 | |
51 num_achieved_awards = 0; | |
52 journal_window.uFrameX = 48; | |
53 journal_window.uFrameY = 70; | |
54 journal_window.uFrameWidth = 360; | |
55 journal_window.uFrameHeight = 264; | |
56 journal_window.uFrameZ = 407; | |
57 journal_window.uFrameHeight = (LOBYTE(pAutonoteFont->uFontHeight) - 3) * 264 / LOBYTE(pAutonoteFont->uFontHeight) - 3; | |
58 journal_window.uFrameW = journal_window.uFrameHeight + 69; | |
59 memset(&achieved_awards, 0, 4000); | |
60 memset(Journal_limitation_factor.data(), 0, 100); | |
61 if (books_primary_item_per_page < 29) | |
62 { | |
63 for (int i = books_primary_item_per_page; i < books_primary_item_per_page + 29; i++) | |
64 { | |
65 if (pParty->PartyTimes.HistoryEventTimes[i] > 0) | |
66 { | |
67 if (pStorylineText->StoreLine[i + 1].pText) | |
68 { | |
69 pString = BuildDialogueString(pStorylineText->StoreLine[i + 1].pText, uActiveCharacter - 1, 0, 0, 0, &pParty->PartyTimes.HistoryEventTimes[i]); | |
70 pTextHeight = pAutonoteFont->CalcTextHeight(pString, &journal_window, 1, 0); | |
71 page_count = ((pTextHeight - (pAutonoteFont->uFontHeight - 3)) / (signed int)journal_window.uFrameHeight) + 1; | |
72 memset32((char *)&achieved_awards[num_achieved_awards], i + 1, page_count); | |
73 for (uint j = 0; j <= page_count - 1; ++j) | |
74 Journal_limitation_factor[num_achieved_awards++] = j; | |
75 } | |
76 } | |
77 } | |
78 } | |
79 full_num_items_in_book = num_achieved_awards; | |
80 num_achieved_awards = 0; | |
81 } | |
82 | |
83 | |
84 | |
85 void GUIWindow_JournalBook::Update() | |
86 { | |
87 // ----------------------------------- | |
88 // 004156F0 GUI_UpdateWindows --- part | |
89 // { | |
90 // BookUI_Draw((WindowType)(int)ptr_1C); | |
91 // } | |
92 | |
93 // ----- (00413CC6) -------------------------------------------------------- | |
94 // void BookUI_Draw(WindowType book) --- part | |
95 // { | |
96 pRenderer->DrawTextureIndexed(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId)); | |
97 // BookUI_Journal_Draw(); | |
98 | |
99 // ----- (00412E85) -------------------------------------------------------- | |
100 // void BookUI_Journal_Draw() | |
101 // { | |
102 char *pDialogueString; // eax@21 | |
103 char* pStringOnPage; // eax@22 | |
104 GUIWindow journal_window; // [sp+8h] [bp-54h]@10 | |
105 | |
106 pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_11); | |
107 if (BtnUp_flag || !books_primary_item_per_page) | |
108 pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 2, pTex_book_button1_off); | |
109 else | |
110 pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_book_button1_on); | |
111 | |
112 if (BtnDown_flag || books_primary_item_per_page + num_achieved_awards >= full_num_items_in_book) | |
113 pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 38, pTex_book_button2_off); | |
114 else | |
115 pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_book_button2_on); | |
116 | |
117 if (!Journal_limitation_factor[books_primary_item_per_page])//for title | |
118 { | |
119 journal_window.uFrameWidth = game_viewport_width; | |
120 journal_window.uFrameX = game_viewport_x; | |
121 journal_window.uFrameY = game_viewport_y; | |
122 journal_window.uFrameHeight = game_viewport_height; | |
123 journal_window.uFrameZ = game_viewport_z; | |
124 journal_window.uFrameW = game_viewport_w; | |
125 if (pStorylineText->StoreLine[achieved_awards[books_primary_item_per_page]].pPageTitle) | |
126 journal_window.DrawTitleText(pBook2Font, 0, 22, ui_book_journal_title_color, pStorylineText->StoreLine[achieved_awards[books_primary_item_per_page]].pPageTitle, 3); | |
127 } | |
128 | |
129 //for other text | |
130 journal_window.uFrameX = 48; | |
131 journal_window.uFrameY = 70; | |
132 journal_window.uFrameWidth = 360; | |
133 journal_window.uFrameHeight = 264; | |
134 journal_window.uFrameZ = 407; | |
135 journal_window.uFrameW = journal_window.uFrameHeight + 69; | |
136 if (BtnDown_flag && books_primary_item_per_page + num_achieved_awards < full_num_items_in_book)//Press bookmark next page | |
137 { | |
138 pAudioPlayer->PlaySound(SOUND_openbook, 0, 0, -1, 0, 0, 0, 0); | |
139 books_primary_item_per_page += num_achieved_awards; | |
140 books_num_items_per_page[books_page_number++] = num_achieved_awards; | |
141 } | |
142 if (BtnUp_flag && books_page_number)//Press bookmark previous page | |
143 { | |
144 pAudioPlayer->PlaySound(SOUND_openbook, 0, 0, -1, 0, 0, 0, 0); | |
145 --books_page_number; | |
146 books_primary_item_per_page -= (unsigned __int8)books_num_items_per_page[books_page_number]; | |
147 } | |
148 if (!num_achieved_awards || books_primary_item_per_page < 1) | |
149 { | |
150 books_primary_item_per_page = 0; | |
151 books_page_number = 0; | |
152 } | |
153 BtnDown_flag = 0; | |
154 BtnUp_flag = 0; | |
155 num_achieved_awards = 0; | |
156 if (achieved_awards[books_primary_item_per_page]) | |
157 { | |
158 int index = ((int)achieved_awards[books_primary_item_per_page] - 1); | |
159 pDialogueString = BuildDialogueString(pStorylineText->StoreLine[achieved_awards[books_primary_item_per_page]].pText, uActiveCharacter - 1, | |
160 0, 0, 0, &pParty->PartyTimes.HistoryEventTimes[index]); | |
161 pStringOnPage = pAutonoteFont->GetPageTop(pDialogueString, &journal_window, 1, (unsigned __int8)Journal_limitation_factor[books_primary_item_per_page]); | |
162 journal_window.DrawText(pAutonoteFont, 1, 0, ui_book_journal_text_color, pStringOnPage, 0, | |
163 journal_window.uFrameY + journal_window.uFrameHeight, ui_book_journal_text_shadow); | |
164 ++num_achieved_awards; | |
165 } | |
166 } |