World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
JournalBook.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 
13 
14 #include "GUI/GUIButton.h"
15 #include "GUI/GUIFont.h"
17 
19 
21 
24  this->ptr_1C = (void *)WINDOW_JournalBook; // inherited from GUIWindow::GUIWindow
26 
27  pEventTimer->Pause();
28  pAudioPlayer->StopChannels(-1, -1);
29  pBooksButtonOverlay = new GUIWindow_BooksButtonOverlay(0x258u, 0x169u, 0, 0,
30  (int)pBtn_History);
32 
33  int pTextHeight; // eax@12
34  unsigned int page_count; // esi@12
35  GUIWindow journal_window; // [sp+18h] [bp-54h]@8
36 
37  ui_book_journal_background = assets->GetImage_ColorKey("sbplayrnot", 0x7FF);
38 
43 
44  pBtn_Book_1 = this->CreateButton(
48  {{ui_book_button1_on}});
49  pBtn_Book_2 = this->CreateButton(
53  {{ui_book_button2_on}});
54 
56  journal_window.uFrameX = 48;
57  journal_window.uFrameY = 70;
58  journal_window.uFrameWidth = 360;
59  journal_window.uFrameHeight = 264;
60  journal_window.uFrameZ = 407;
61  journal_window.uFrameHeight =
62  (pAutonoteFont->GetHeight() - 3) * 264 / pAutonoteFont->GetHeight() - 3;
63  journal_window.uFrameW = journal_window.uFrameHeight + 69;
64  memset(&achieved_awards, 0, 4000);
65  memset(Journal_limitation_factor.data(), 0, 100);
66  if (books_primary_item_per_page < 29) {
67  for (int i = books_primary_item_per_page;
68  i < books_primary_item_per_page + 29; i++) {
69  if (pParty->PartyTimes.HistoryEventTimes[i].Valid()) {
70  if (pStorylineText->StoreLine[i + 1].pText) {
71  auto str = BuildDialogueString(
73  uActiveCharacter - 1, 0, 0, 0,
75  pTextHeight = pAutonoteFont->CalcTextHeight(
76  str, journal_window.uFrameWidth, 1);
77  page_count =
78  ((pTextHeight - (pAutonoteFont->GetHeight() - 3)) /
79  (signed int)journal_window.uFrameHeight) +
80  1;
82  i + 1, page_count);
83  for (uint j = 0; j <= page_count - 1; ++j)
85  }
86  }
87  }
88  }
91 }
92 
94  // -----------------------------------
95  // 004156F0 GUI_UpdateWindows --- part
96  // {
97  // BookUI_Draw((WindowType)(int)ptr_1C);
98  // }
99 
100  // ----- (00413CC6) --------------------------------------------------------
101  // void BookUI_Draw(WindowType book) --- part
102  // {
103  render->DrawTextureAlphaNew(471 / 640.0f, 445 / 480.0f,
105  // BookUI_Journal_Draw();
106 
107  // ----- (00412E85) --------------------------------------------------------
108  // void BookUI_Journal_Draw()
109  // {
110  // char *pDialogueString; // eax@21
111  GUIWindow journal_window; // [sp+8h] [bp-54h]@10
112 
113  render->DrawTextureAlphaNew(pViewport->uViewportTL_X / 640.0f,
114  pViewport->uViewportTL_Y / 480.0f,
117  render->DrawTextureAlphaNew((pViewport->uViewportTL_X + 407) / 640.0f,
118  (pViewport->uViewportTL_Y + 2) / 480.0f,
120  else
121  render->DrawTextureAlphaNew((pViewport->uViewportTL_X + 398) / 640.0f,
122  (pViewport->uViewportTL_Y + 1) / 480.0f,
124 
127  render->DrawTextureAlphaNew((pViewport->uViewportTL_X + 407) / 640.0f,
128  (pViewport->uViewportTL_Y + 38) / 480.0f,
130  else
131  render->DrawTextureAlphaNew((pViewport->uViewportTL_X + 398) / 640.0f,
132  (pViewport->uViewportTL_Y + 38) / 480.0f,
134 
136  journal_window.uFrameWidth = game_viewport_width;
137  journal_window.uFrameX = game_viewport_x;
138  journal_window.uFrameY = game_viewport_y;
139  journal_window.uFrameHeight = game_viewport_height;
140  journal_window.uFrameZ = game_viewport_z;
141  journal_window.uFrameW = game_viewport_w;
142  if (pStorylineText
144  .pPageTitle)
145  journal_window.DrawTitleText(
149  .pPageTitle,
150  3);
151  }
152 
153  // for other text
154  journal_window.uFrameX = 48;
155  journal_window.uFrameY = 70;
156  journal_window.uFrameWidth = 360;
157  journal_window.uFrameHeight = 264;
158  journal_window.uFrameZ = 407;
159  journal_window.uFrameW = journal_window.uFrameHeight + 69;
161  full_num_items_in_book) { // Press bookmark next page
162  pAudioPlayer->PlaySound(SOUND_openbook, 0, 0, -1, 0, 0);
165  }
166  if (BtnUp_flag && books_page_number) { // Press bookmark previous page
167  pAudioPlayer->PlaySound(SOUND_openbook, 0, 0, -1, 0, 0);
171  }
174  books_page_number = 0;
175  }
176  BtnDown_flag = 0;
177  BtnUp_flag = 0;
181  auto str = BuildDialogueString(
184  .pText,
185  uActiveCharacter - 1, 0, 0, 0,
187  String pStringOnPage = pAutonoteFont->GetPageTop(
188  str.c_str(), &journal_window, 1,
189  (unsigned __int8)
191  journal_window.DrawText(
192  pAutonoteFont, 1, 0, ui_book_journal_text_color, pStringOnPage, 0,
193  journal_window.uFrameY + journal_window.uFrameHeight,
196  }
197 }
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
ui_book_journal_text_shadow
unsigned int ui_book_journal_text_shadow
Definition: UICharacter.cpp:94
GUIWindow
Definition: GUIWindow.h:433
WINDOW_JournalBook
@ WINDOW_JournalBook
Definition: GUIWindow.h:340
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
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
StorylineRecord::pText
char * pText
Definition: StorylineTextTable.h:7
pBtn_Book_1
GUIButton * pBtn_Book_1
Definition: GUIButton.cpp:23
num_achieved_awards
int num_achieved_awards
Definition: mm7_data.cpp:28
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_journal_text_color
unsigned int ui_book_journal_text_color
Definition: UICharacter.cpp:93
PartyTimeStruct::HistoryEventTimes
std::array< GameTime, 29 > HistoryEventTimes
Definition: Party.h:146
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
GUIFont::GetHeight
unsigned int GetHeight() const
Definition: GUIFont.cpp:84
AssetsManager.h
index
GLuint index
Definition: SDL_opengl_glext.h:663
GUIWindow_JournalBook::GUIWindow_JournalBook
GUIWindow_JournalBook()
Definition: JournalBook.cpp:22
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
Party::PartyTimes
PartyTimeStruct PartyTimes
Definition: Party.h:249
game_viewport_y
int game_viewport_y
Definition: mm7_data.cpp:197
Localization.h
Image::GetWidth
unsigned int GetWidth()
Definition: Image.cpp:217
GUIButton.h
pParty
Party * pParty
Definition: Party.cpp:30
Image
Definition: Image.h:19
JournalBook.h
IRender.h
bFlashHistoryBook
char bFlashHistoryBook
Definition: mm7_data.cpp:547
GUIWindow_JournalBook::Update
virtual void Update()
Definition: JournalBook.cpp:93
ui_book_button2_on
Image * ui_book_button2_on
Definition: UIBooks.cpp:32
ui_book_journal_background
Image * ui_book_journal_background
Definition: JournalBook.cpp:20
AssetsManager::GetImage_ColorKey
Texture * GetImage_ColorKey(const String &name, uint16_t colorkey)
Definition: AssetsManager.cpp:34
GUIWindow::uFrameHeight
unsigned int uFrameHeight
Definition: GUIWindow.h:471
StorylineText::StoreLine
StorylineRecord StoreLine[29]
Definition: StorylineTextTable.h:20
pBook2Font
GUIFont * pBook2Font
Definition: GUIFont.cpp:20
BtnUp_flag
int BtnUp_flag
Definition: mm7_data.cpp:529
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
Party.h
GUIFont::GetPageTop
String GetPageTop(const String &pInString, GUIWindow *pWindow, unsigned int uX, int a5)
Definition: GUIFont.cpp:211
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
Journal_limitation_factor
std::array< char, 100 > Journal_limitation_factor
Definition: mm7_data.cpp:648
Timer::Pause
void Pause()
Definition: Time.cpp:19
pStorylineText
struct StorylineText * pStorylineText
Definition: StorylineTextTable.cpp:8
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
memset32
void memset32(void *ptr, uint32_t value, int count)
Definition: MM7.h:14
BuildDialogueString
String BuildDialogueString(const char *lpsz, unsigned __int8 uPlayerID, ItemGen *a3, char *a4, int a5, GameTime *a6)
Definition: GUIWindow.cpp:2189
AudioPlayer.h
pViewport
struct Viewport * pViewport
Definition: mm7_data.cpp:21
ui_book_journal_title_color
unsigned int ui_book_journal_title_color
Definition: UICharacter.cpp:92
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
uActiveCharacter
unsigned int uActiveCharacter
Definition: mm7_data.cpp:555
books_page_number
int books_page_number
Definition: mm7_data.cpp:520
GUIWindow::eWindowType
WindowType eWindowType
Definition: GUIWindow.h:474
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
pBtn_History
GUIButton * pBtn_History
Definition: GUIButton.cpp:56
Viewport::uViewportTL_X
int uViewportTL_X
Definition: Viewport.h:22
game_viewport_z
int game_viewport_z
Definition: mm7_data.cpp:198
StorylineTextTable.h
String
std::string String
Definition: Strings.h:10
pEventTimer
Timer * pEventTimer
Definition: Time.cpp:8
Time.h
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52