Mercurial > mm7
comparison GUI/UI/Books/QuestBook.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 | |
10 #include "GUI/GUIFont.h" | |
11 #include "GUI/UI/Books/QuestBook.h" | |
12 | |
13 #include "Media/Audio/AudioPlayer.h" | |
14 | |
15 GUIWindow_QuestBook::GUIWindow_QuestBook() : | |
16 GUIWindow_Book() | |
17 { | |
18 this->ptr_1C = (void *)WINDOW_QuestBook; // inherited from GUIWindow::GUIWindow | |
19 BasicBookInitialization(); | |
20 | |
21 // -------------------------------- | |
22 // 004304E7 Game_EventLoop --- part | |
23 pEventTimer->Pause(); | |
24 pAudioPlayer->StopChannels(-1, -1); | |
25 pBooksButtonOverlay = new GUIWindow_BooksButtonOverlay(493u, 355u, 0, 0, (int)pBtn_Quests, 0); | |
26 bFlashQuestBook = 0; | |
27 | |
28 // ---------------------------------------------- | |
29 // 00411BFC GUIWindow::InitializeBookView -- part | |
30 pTexture_CurrentBook = pIcons_LOD->LoadTexturePtr("sbquiknot", TEXTURE_16BIT_PALETTE); | |
31 pSpellBookPagesTextr_10 = pIcons_LOD->LoadTexturePtr("divbar", TEXTURE_16BIT_PALETTE); | |
32 pTex_book_button1_on = pIcons_LOD->LoadTexturePtr("tab-an-6b", TEXTURE_16BIT_PALETTE); | |
33 pTex_book_button2_on = pIcons_LOD->LoadTexturePtr("tab-an-7b", TEXTURE_16BIT_PALETTE); | |
34 pTex_book_button1_off = pIcons_LOD->LoadTexturePtr("tab-an-6a", TEXTURE_16BIT_PALETTE); | |
35 pTex_book_button2_off = pIcons_LOD->LoadTexturePtr("tab-an-7a", TEXTURE_16BIT_PALETTE); | |
36 pBtn_Book_1 = CreateButton( | |
37 pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, | |
38 pTex_book_button1_on->uTextureWidth, pTex_book_button1_on->uTextureHeight, | |
39 1, 0, UIMSG_ClickBooksBtn, 0xBu, 0, pGlobalTXT_LocalizationStrings[192],// "Scroll Up" | |
40 pTex_book_button1_on, 0 | |
41 ); | |
42 pBtn_Book_2 = CreateButton( | |
43 pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, | |
44 pTex_book_button2_on->uTextureHeight, pTex_book_button2_on->uTextureHeight, | |
45 1, 0, UIMSG_ClickBooksBtn, 0xAu, 0, pGlobalTXT_LocalizationStrings[193],// "Scroll Down" | |
46 pTex_book_button2_on, 0 | |
47 ); | |
48 num_achieved_awards = 0; | |
49 memset(achieved_awards.data(), 0, 4000); | |
50 for (uint i = books_primary_item_per_page; i < 512; ++i) | |
51 { | |
52 if (_449B57_test_bit(pParty->_quest_bits, i) && pQuestTable[i]) | |
53 { | |
54 achieved_awards[num_achieved_awards] = (AwardType)i; | |
55 ++num_achieved_awards; | |
56 } | |
57 } | |
58 full_num_items_in_book = num_achieved_awards; | |
59 num_achieved_awards = 0; | |
60 } | |
61 | |
62 | |
63 | |
64 void GUIWindow_QuestBook::Update() | |
65 { | |
66 // ----------------------------------- | |
67 // 004156F0 GUI_UpdateWindows --- part | |
68 // { | |
69 // BookUI_Draw((WindowType)(int)ptr_1C); | |
70 // } | |
71 | |
72 // ----- (00413CC6) -------------------------------------------------------- | |
73 // void BookUI_Draw(WindowType book) --- part | |
74 // { | |
75 pRenderer->DrawTextureIndexed(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId)); | |
76 // BookUI_Questbook_Draw(); | |
77 | |
78 // ----- (00413126) -------------------------------------------------------- | |
79 // void BookUI_Questbook_Draw() | |
80 // { | |
81 int pTextHeight; // eax@19 | |
82 GUIWindow questbook_window; // [sp+Ch] [bp-54h]@9 | |
83 | |
84 pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_CurrentBook); | |
85 if (BtnUp_flag || !books_primary_item_per_page)//Bookmark Up(Закладка вверх) | |
86 pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 2, pTex_book_button1_off); | |
87 else | |
88 pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_book_button1_on); | |
89 | |
90 if (BtnDown_flag || books_primary_item_per_page + num_achieved_awards >= full_num_items_in_book)//Bookmark Down(Закладка вниз) | |
91 pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 38, pTex_book_button2_off); | |
92 else | |
93 pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_book_button2_on); | |
94 | |
95 //for title | |
96 questbook_window.uFrameWidth = game_viewport_width; | |
97 questbook_window.uFrameHeight = game_viewport_height; | |
98 questbook_window.uFrameX = game_viewport_x; | |
99 questbook_window.uFrameY = game_viewport_y; | |
100 questbook_window.uFrameZ = game_viewport_z; | |
101 questbook_window.uFrameW = game_viewport_w; | |
102 questbook_window.DrawTitleText(pBook2Font, 0, 22, ui_book_quests_title_color, pGlobalTXT_LocalizationStrings[174], 3); //"Current Quests" | |
103 | |
104 //for other text | |
105 questbook_window.uFrameX = 48; | |
106 questbook_window.uFrameY = 70; | |
107 questbook_window.uFrameWidth = 360; | |
108 questbook_window.uFrameHeight = 264; | |
109 questbook_window.uFrameZ = 407; | |
110 questbook_window.uFrameW = 333; | |
111 if (BtnDown_flag && books_primary_item_per_page + num_achieved_awards < full_num_items_in_book)//Click Bookmark Down(нажатие закладки вниз) | |
112 { | |
113 pAudioPlayer->PlaySound(SOUND_openbook, 0, 0, -1, 0, 0, 0, 0); | |
114 books_primary_item_per_page += num_achieved_awards; | |
115 books_num_items_per_page[books_page_number++] = num_achieved_awards; | |
116 } | |
117 if (BtnUp_flag && books_page_number)//Click Bookmark Up(Нажатие закладки вверх) | |
118 { | |
119 pAudioPlayer->PlaySound(SOUND_openbook, 0, 0, -1, 0, 0, 0, 0); | |
120 --books_page_number; | |
121 books_primary_item_per_page -= (unsigned __int8)books_num_items_per_page[books_page_number]; | |
122 } | |
123 if (!num_achieved_awards || !books_primary_item_per_page) | |
124 { | |
125 books_page_number = 0; | |
126 books_primary_item_per_page = 0; | |
127 } | |
128 BtnDown_flag = 0; | |
129 BtnUp_flag = 0; | |
130 num_achieved_awards = 0; | |
131 for (uint i = books_primary_item_per_page; i < full_num_items_in_book; ++i) | |
132 { | |
133 ++num_achieved_awards; | |
134 questbook_window.DrawText(pAutonoteFont, 1, 0, ui_book_quests_text_color, pQuestTable[achieved_awards[i]], 0, 0, 0); | |
135 pTextHeight = pAutonoteFont->CalcTextHeight(pQuestTable[achieved_awards[i]], &questbook_window, 1, 0); | |
136 if ((signed int)(questbook_window.uFrameY + pTextHeight) > (signed int)questbook_window.uFrameHeight) | |
137 break; | |
138 pRenderer->DrawTextureIndexedAlpha(100, (questbook_window.uFrameY + pTextHeight) + 12, pSpellBookPagesTextr_10); | |
139 questbook_window.uFrameY = (questbook_window.uFrameY + pTextHeight) + 24; | |
140 } | |
141 } |