World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
QuestBook.cpp
См. документацию.
1 #include "Engine/AssetsManager.h"
2 #include "Engine/Awards.h"
3 #include "Engine/Engine.h"
4 #include "Engine/LOD.h"
5 #include "Engine/Localization.h"
6 #include "Engine/Party.h"
7 #include "Engine/Time.h"
8 
11 
12 #include "GUI/GUIButton.h"
13 #include "GUI/GUIFont.h"
14 #include "GUI/UI/Books/QuestBook.h"
15 
17 
19 
21  this->ptr_1C =
22  (void *)WINDOW_QuestBook; // inherited from GUIWindow::GUIWindow
24 
25  // --------------------------------
26  // 004304E7 Game_EventLoop --- part
27  pEventTimer->Pause();
28  pAudioPlayer->StopChannels(-1, -1);
30  new GUIWindow_BooksButtonOverlay(493u, 355u, 0, 0, (int)pBtn_Quests);
31  bFlashQuestBook = 0;
32 
33  // ----------------------------------------------
34  // 00411BFC GUIWindow::InitializeBookView -- part
37 
42 
46  UIMSG_ClickBooksBtn, 0xBu, 0,
47  localization->GetString(192), // "Scroll Up"
48  {{ui_book_button1_on}});
49  pBtn_Book_2 = CreateButton(
52  UIMSG_ClickBooksBtn, 0xAu, 0,
53  localization->GetString(193), // "Scroll Down"
54  {{ui_book_button2_on}});
56  memset(achieved_awards.data(), 0, 4000);
57  for (uint i = books_primary_item_per_page; i < 512; ++i) {
61  }
62  }
65 }
66 
68  // -----------------------------------
69  // 004156F0 GUI_UpdateWindows --- part
70  // {
71  // BookUI_Draw((WindowType)(int)ptr_1C);
72  // }
73 
74  // ----- (00413CC6) --------------------------------------------------------
75  // void BookUI_Draw(WindowType book) --- part
76  // {
77  render->DrawTextureAlphaNew(471 / 640.0f, 445 / 480.0f,
79  // BookUI_Questbook_Draw();
80 
81  // ----- (00413126) --------------------------------------------------------
82  // void BookUI_Questbook_Draw()
83  // {
84  int pTextHeight; // eax@19
85  GUIWindow questbook_window; // [sp+Ch] [bp-54h]@9
86 
87  render->DrawTextureNew(pViewport->uViewportTL_X / 640.0f,
88  pViewport->uViewportTL_Y / 480.0f,
90  if (BtnUp_flag ||
91  !books_primary_item_per_page) // Bookmark Up(Закладка вверх)
92  render->DrawTextureAlphaNew((pViewport->uViewportTL_X + 407) / 640.0f,
93  (pViewport->uViewportTL_Y + 2) / 480.0f,
95  else
96  render->DrawTextureAlphaNew((pViewport->uViewportTL_X + 398) / 640.0f,
97  (pViewport->uViewportTL_Y + 1) / 480.0f,
99 
100  if (BtnDown_flag ||
102  full_num_items_in_book) // Bookmark Down(Закладка вниз)
103  render->DrawTextureAlphaNew((pViewport->uViewportTL_X + 407) / 640.0f,
104  (pViewport->uViewportTL_Y + 38) / 480.0f,
106  else
107  render->DrawTextureAlphaNew((pViewport->uViewportTL_X + 398) / 640.0f,
108  (pViewport->uViewportTL_Y + 38) / 480.0f,
110 
111  // for title
112  questbook_window.uFrameWidth = game_viewport_width;
113  questbook_window.uFrameHeight = game_viewport_height;
114  questbook_window.uFrameX = game_viewport_x;
115  questbook_window.uFrameY = game_viewport_y;
116  questbook_window.uFrameZ = game_viewport_z;
117  questbook_window.uFrameW = game_viewport_w;
118  questbook_window.DrawTitleText(
120  localization->GetString(174), 3); // "Current Quests"
121 
122  // for other text
123  questbook_window.uFrameX = 48;
124  questbook_window.uFrameY = 70;
125  questbook_window.uFrameWidth = 360;
126  questbook_window.uFrameHeight = 264;
127  questbook_window.uFrameZ = 407;
128  questbook_window.uFrameW = 333;
129  if (BtnDown_flag &&
131  full_num_items_in_book) { // Click Bookmark Down(нажатие закладки
132  // вниз)
133  pAudioPlayer->PlaySound(SOUND_openbook, 0, 0, -1, 0, 0);
136  }
137  if (BtnUp_flag &&
138  books_page_number) { // Click Bookmark Up(Нажатие закладки вверх)
139  pAudioPlayer->PlaySound(SOUND_openbook, 0, 0, -1, 0, 0);
143  }
145  books_page_number = 0;
147  }
148  BtnDown_flag = 0;
149  BtnUp_flag = 0;
152  ++i) {
154  questbook_window.DrawText(pAutonoteFont, 1, 0,
156  pQuestTable[achieved_awards[i]], 0, 0, 0);
157  pTextHeight = pAutonoteFont->CalcTextHeight(
158  pQuestTable[achieved_awards[i]], questbook_window.uFrameWidth, 1);
159  if ((signed int)(questbook_window.uFrameY + pTextHeight) >
160  (signed int)questbook_window.uFrameHeight)
161  break;
162 
163  render->DrawTextureAlphaNew(
164  100 / 640.0f,
165  ((questbook_window.uFrameY + pTextHeight) + 12) / 480.0f,
167 
168  questbook_window.uFrameY =
169  (questbook_window.uFrameY + pTextHeight) + 24;
170  }
171 }
ui_book_quests_text_color
unsigned int ui_book_quests_text_color
Definition: UICharacter.cpp:78
GUIWindow::DrawText
void DrawText(GUIFont *font, int x, int y, unsigned short uFontColor, const char *str, bool present_time_transparency=false, int max_text_height=0, int uFontShadowColor=0)
Definition: GUIWindow.cpp:694
GUIWindow::uFrameW
unsigned int uFrameW
Definition: GUIWindow.h:473
pAutonoteFont
GUIFont * pAutonoteFont
Definition: GUIFont.cpp:16
Localization::GetString
const char * GetString(unsigned int index) const
Definition: Localization.cpp:13
Viewport.h
LOD.h
Image::GetHeight
unsigned int GetHeight()
Definition: Image.cpp:230
GUIWindow
Definition: GUIWindow.h:433
AssetsManager::GetImage_Solid
Texture * GetImage_Solid(const String &name)
Definition: AssetsManager.cpp:51
QuestBook.h
ui_exit_cancel_button_background
Image * ui_exit_cancel_button_background
Definition: GUIWindow.cpp:89
Viewport::uViewportTL_Y
int uViewportTL_Y
Definition: Viewport.h:23
GUIWindow_BooksButtonOverlay
Definition: UIBooks.h:19
_449B57_test_bit
bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2)
Definition: Party.cpp:1185
GUIWindow::CreateButton
GUIButton * CreateButton(int x, int y, int width, int height, int a6, int a7, UIMessageType msg, unsigned int msg_param, uint8_t hotkey, const String &label, const std::vector< Image * > &textures=std::vector< Image * >())
Definition: GUIWindow.cpp:717
ui_book_button1_on
Image * ui_book_button1_on
Definition: UIBooks.cpp:34
AudioPlayer::PlaySound
void PlaySound(SoundID eSoundID, int pid, unsigned int uNumRepeats, int x, int y, int a7)
Definition: AudioPlayer.cpp:195
game_viewport_width
unsigned int game_viewport_width
Definition: mm7_data.cpp:194
pBtn_Book_1
GUIButton * pBtn_Book_1
Definition: GUIButton.cpp:23
num_achieved_awards
int num_achieved_awards
Definition: mm7_data.cpp:28
Party::_quest_bits
unsigned __int8 _quest_bits[64]
Definition: Party.h:291
localization
Localization * localization
Definition: Localization.cpp:11
game_viewport_x
int game_viewport_x
Definition: mm7_data.cpp:196
BtnDown_flag
int BtnDown_flag
Definition: mm7_data.cpp:528
ui_book_quest_div_bar
Image * ui_book_quest_div_bar
Definition: UIBooks.cpp:38
GUIWindow::DrawTitleText
void DrawTitleText(GUIFont *font, int horizontal_margin, int vertical_margin, unsigned __int16 uDefaultColor, const char *pInString, int line_spacing)
Definition: GUIWindow.cpp:665
GUIFont.h
AssetsManager.h
GUIWindow::uFrameWidth
unsigned int uFrameWidth
Definition: GUIWindow.h:470
game_viewport_height
unsigned int game_viewport_height
Definition: mm7_data.cpp:195
GUIWindow::uFrameZ
unsigned int uFrameZ
Definition: GUIWindow.h:472
Engine.h
pBtn_Quests
GUIButton * pBtn_Quests
Definition: GUIButton.cpp:60
game_viewport_y
int game_viewport_y
Definition: mm7_data.cpp:197
Localization.h
Image::GetWidth
unsigned int GetWidth()
Definition: Image.cpp:217
GUIWindow_QuestBook::GUIWindow_QuestBook
GUIWindow_QuestBook()
Definition: QuestBook.cpp:20
GUIButton.h
pParty
Party * pParty
Definition: Party.cpp:30
Image
Definition: Image.h:19
IRender.h
ui_book_button2_on
Image * ui_book_button2_on
Definition: UIBooks.cpp:32
ui_book_quests_background
Image * ui_book_quests_background
Definition: QuestBook.cpp:18
GUIWindow::uFrameHeight
unsigned int uFrameHeight
Definition: GUIWindow.h:471
pBook2Font
GUIFont * pBook2Font
Definition: GUIFont.cpp:20
BtnUp_flag
int BtnUp_flag
Definition: mm7_data.cpp:529
GUIWindow_QuestBook::Update
virtual void Update()
Definition: QuestBook.cpp:67
pBtn_Book_2
GUIButton * pBtn_Book_2
Definition: GUIButton.cpp:22
AudioPlayer::StopChannels
void StopChannels(int uStartChannel, int uEndChannel)
Definition: AudioPlayer.cpp:331
GUIFont::CalcTextHeight
unsigned int CalcTextHeight(const String &str, unsigned int width, int x_offset, bool return_on_carriage=false)
Definition: GUIFont.cpp:246
achieved_awards
std::array< AwardType, 1000 > achieved_awards
Definition: mm7_data.cpp:27
pQuestTable
std::array< const char *, 513 > pQuestTable
Definition: mm7_data.cpp:741
Party.h
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
Timer::Pause
void Pause()
Definition: Time.cpp:19
bFlashQuestBook
char bFlashQuestBook
Definition: mm7_data.cpp:549
WINDOW_QuestBook
@ WINDOW_QuestBook
Definition: GUIWindow.h:336
AwardType
AwardType
Definition: Awards.h:15
GUIWindow::uFrameY
unsigned int uFrameY
Definition: GUIWindow.h:469
game_viewport_w
int game_viewport_w
Definition: mm7_data.cpp:199
ui_book_button1_off
Image * ui_book_button1_off
Definition: UIBooks.cpp:33
AudioPlayer.h
pViewport
struct Viewport * pViewport
Definition: mm7_data.cpp:21
pBooksButtonOverlay
GUIWindow * pBooksButtonOverlay
Definition: GUIWindow.cpp:59
GUIWindow_Book
Definition: UIBooks.h:4
ui_book_button2_off
Image * ui_book_button2_off
Definition: UIBooks.cpp:31
GUIWindow_Book::BasicBookInitialization
void BasicBookInitialization()
Definition: UIBooks.cpp:67
Awards.h
assets
AssetsManager * assets
Definition: AssetsManager.cpp:12
uint
unsigned int uint
Definition: MM7.h:4
books_primary_item_per_page
int books_primary_item_per_page
Definition: mm7_data.cpp:521
ui_book_quests_title_color
unsigned int ui_book_quests_title_color
Definition: UICharacter.cpp:77
books_page_number
int books_page_number
Definition: mm7_data.cpp:520
GUIWindow::ptr_1C
void * ptr_1C
Definition: GUIWindow.h:476
AssetsManager::GetImage_Alpha
Texture * GetImage_Alpha(const String &name)
Definition: AssetsManager.cpp:66
UIMSG_ClickBooksBtn
@ UIMSG_ClickBooksBtn
Definition: GUIWindow.h:57
books_num_items_per_page
std::array< char, 777 > books_num_items_per_page
Definition: mm7_data.cpp:512
SOUND_openbook
@ SOUND_openbook
Definition: AudioPlayer.h:93
GUIWindow::uFrameX
unsigned int uFrameX
Definition: GUIWindow.h:468
pAudioPlayer
AudioPlayer * pAudioPlayer
Definition: AudioPlayer.cpp:20
full_num_items_in_book
int full_num_items_in_book
Definition: mm7_data.cpp:29
Viewport::uViewportTL_X
int uViewportTL_X
Definition: Viewport.h:22
game_viewport_z
int game_viewport_z
Definition: mm7_data.cpp:198
pEventTimer
Timer * pEventTimer
Definition: Time.cpp:8
Time.h
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52