World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
CalendarBook.cpp
См. документацию.
2 
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 
16 
18 
24 
26  this->ptr_1C =
27  (void *)WINDOW_CalendarBook; // inherited from GUIWindow::GUIWindow
29 
30  // --------------------------------
31  // 004304E7 Game_EventLoop --- part
32  pEventTimer->Pause();
33  pAudioPlayer->StopChannels(-1, -1);
35  new GUIWindow_BooksButtonOverlay(570, 354, 0, 0, (int)pBtn_Calendar);
36 
37  // ----------------------------------------------
38  // 00411BFC GUIWindow::InitializeBookView -- part
40  assets->GetImage_ColorKey("sbdate-time", 0x7FF);
46 }
47 
48 //----- (00413D3C) --------------------------------------------------------
49 static const char *GetDayPart() {
50  if (pParty->uCurrentHour > 5 && pParty->uCurrentHour < 20)
51  return localization->GetString(56); // "Day"
52  else if (pParty->uCurrentHour == 5)
53  return localization->GetString(55); // "Dawn"
54  else if (pParty->uCurrentHour == 20)
55  return localization->GetString(566); // "Dusk"
56  else
57  return localization->GetString(567); // "Night"
58 }
59 
61  render->DrawTextureAlphaNew(471 / 640.0f, 445 / 480.0f, ui_exit_cancel_button_background);
62 
63  int am; // ecx@5
64  GUIWindow calendar_window; // [sp+Ch] [bp-60h]@5
65  unsigned int pMapID; // [sp+60h] [bp-Ch]@1
66  unsigned int pHour;
67 
68  static unsigned int pDayMoonPhase[28] = { // 4E1B18
69  0, 0, 0,
70  1, 1, 1, 1,
71  2, 2, 2,
72  3, 3, 3, 3,
73  4, 4, 4,
74  3, 3, 3, 3,
75  2, 2, 2,
76  1, 1, 1, 1
77  };
78 
79  render->DrawTextureAlphaNew(pViewport->uViewportTL_X / 640.0f, pViewport->uViewportTL_Y / 480.0f, ui_book_calendar_background);
80  pHour = pParty->uCurrentHour;
81  if ((int)pHour >= 12) {
82  pHour -= 12;
83  if (!pHour)
84  pHour = 12;
85  am = 1;
86  } else {
87  am = 0;
88  }
89 
90  calendar_window.uFrameX = game_viewport_x;
91  calendar_window.uFrameY = game_viewport_y;
92  calendar_window.uFrameWidth = game_viewport_width;
93  calendar_window.uFrameHeight = game_viewport_height;
94  calendar_window.uFrameZ = game_viewport_z;
95  calendar_window.uFrameW = game_viewport_w;
96  calendar_window.DrawTitleText(pBook2Font, 0, 22, ui_book_calendar_title_color, localization->GetString(186), 3); // "Time in Erathia"
97 
98  auto str = StringPrintf(
99  "%s\t100:\t110%d:%02d %s - %s",
100  localization->GetString(526), // "Time"
102  calendar_window.DrawText(pBookFont, 70, 55, ui_book_calendar_time_color, str, 0, 0, 0);
103 
104  str = StringPrintf(
105  "%s\t100:\t110%d - %s",
106  localization->GetString(56), // "Day"
109  calendar_window.DrawText(pBookFont, 70, 2 * pBookFont->GetHeight() + 49, ui_book_calendar_day_color, str, 0, 0, 0);
110 
111  str = StringPrintf(
112  "%s\t100:\t110%d - %s",
113  localization->GetString(146), // "Month"
114  pParty->uCurrentMonth + 1,
116  calendar_window.DrawText(pBookFont, 70, 4 * pBookFont->GetHeight() + 43, ui_book_calendar_month_color, str, 0, 0, 0);
117 
118  str = StringPrintf("%s\t100:\t110%d", localization->GetString(245), pParty->uCurrentYear); // "Year"
119  calendar_window.DrawText(pBookFont, 70, 6 * pBookFont->GetHeight() + 37, ui_book_calendar_year_color, str, 0, 0, 0);
120 
121  str = StringPrintf(
122  "%s\t100:\t110%s",
123  localization->GetString(530), // Moon
125  calendar_window.DrawText(pBookFont, 70, 8 * (unsigned char)pBookFont->GetHeight() + 31, ui_book_calendar_moon_color, str, 0, 0, 0);
126 
128  String pMapName;
129  if (pMapID)
130  pMapName = pMapStats->pInfos[pMapID].pName;
131  else
132  pMapName = "Unknown";
133 
134  str = StringPrintf("%s\t100:\t110%s", localization->GetString(531), pMapName.c_str()); // "Location"
135  calendar_window.DrawText(pBookFont, 70, 10 * (unsigned char)pBookFont->GetHeight() + 25, ui_book_calendar_location_color, str, 0, 0, 0);
136 }
ui_book_calendar_time_color
unsigned int ui_book_calendar_time_color
Definition: UICharacter.cpp:85
ui_book_calendar_moon_new
Image * ui_book_calendar_moon_new
Definition: CalendarBook.cpp:19
ui_book_calendar_day_color
unsigned int ui_book_calendar_day_color
Definition: UICharacter.cpp:86
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
ui_book_calendar_title_color
unsigned int ui_book_calendar_title_color
Definition: UICharacter.cpp:84
GUIWindow::uFrameW
unsigned int uFrameW
Definition: GUIWindow.h:473
Localization::GetString
const char * GetString(unsigned int index) const
Definition: Localization.cpp:13
Viewport.h
Party::uCurrentMonth
unsigned int uCurrentMonth
Definition: Party.h:272
MapStats::pInfos
MapInfo pInfos[77]
Definition: MapInfo.h:79
LOD.h
GUIWindow
Definition: GUIWindow.h:433
Party::uCurrentMinute
unsigned int uCurrentMinute
Definition: Party.h:276
ui_book_calendar_moon_2_2
Image * ui_book_calendar_moon_2_2
Definition: CalendarBook.cpp:22
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_CalendarBook::GUIWindow_CalendarBook
GUIWindow_CalendarBook()
Definition: CalendarBook.cpp:25
MapStats::GetMapInfo
MAP_TYPE GetMapInfo(const String &Str2)
Definition: MapInfo.cpp:225
GetDayPart
static const char * GetDayPart()
Definition: CalendarBook.cpp:49
game_viewport_width
unsigned int game_viewport_width
Definition: mm7_data.cpp:194
localization
Localization * localization
Definition: Localization.cpp:11
game_viewport_x
int game_viewport_x
Definition: mm7_data.cpp:196
Party::uCurrentHour
unsigned int uCurrentHour
Definition: Party.h:275
ui_book_calendar_moon_4
Image * ui_book_calendar_moon_4
Definition: CalendarBook.cpp:20
pBtn_Calendar
GUIButton * pBtn_Calendar
Definition: GUIButton.cpp:57
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
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
ui_book_calendar_month_color
unsigned int ui_book_calendar_month_color
Definition: UICharacter.cpp:87
pMapStats
struct MapStats * pMapStats
Definition: mm7_data.cpp:20
game_viewport_y
int game_viewport_y
Definition: mm7_data.cpp:197
ui_book_calendar_moon_color
unsigned int ui_book_calendar_moon_color
Definition: UICharacter.cpp:89
Localization.h
Localization::GetMoonPhaseName
const char * GetMoonPhaseName(unsigned int index) const
Definition: Localization.h:23
GUIButton.h
ui_book_calendar_moon_full
Image * ui_book_calendar_moon_full
Definition: CalendarBook.cpp:23
pParty
Party * pParty
Definition: Party.cpp:30
Image
Definition: Image.h:19
IRender.h
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
pBook2Font
GUIFont * pBook2Font
Definition: GUIFont.cpp:20
ui_book_calendar_location_color
unsigned int ui_book_calendar_location_color
Definition: UICharacter.cpp:90
AudioPlayer::StopChannels
void StopChannels(int uStartChannel, int uEndChannel)
Definition: AudioPlayer.cpp:331
Party.h
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
CalendarBook.h
MapInfo::pName
String pName
Definition: MapInfo.h:38
Timer::Pause
void Pause()
Definition: Time.cpp:19
pCurrentMapName
String pCurrentMapName
Definition: mm7_data.cpp:712
Localization::GetAmPm
const char * GetAmPm(unsigned int index) const
Definition: Localization.h:79
pBookFont
GUIFont * pBookFont
Definition: GUIFont.cpp:21
GUIWindow::uFrameY
unsigned int uFrameY
Definition: GUIWindow.h:469
game_viewport_w
int game_viewport_w
Definition: mm7_data.cpp:199
GUIWindow_CalendarBook::Update
virtual void Update()
Definition: CalendarBook.cpp:60
AudioPlayer.h
pViewport
struct Viewport * pViewport
Definition: mm7_data.cpp:21
Party::uCurrentDayOfMonth
unsigned int uCurrentDayOfMonth
Definition: Party.h:274
ui_book_calendar_background
Image * ui_book_calendar_background
Definition: CalendarBook.cpp:17
pBooksButtonOverlay
GUIWindow * pBooksButtonOverlay
Definition: GUIWindow.cpp:59
ui_book_calendar_moon_2
Image * ui_book_calendar_moon_2
Definition: CalendarBook.cpp:21
GUIWindow_Book
Definition: UIBooks.h:4
ui_book_calendar_year_color
unsigned int ui_book_calendar_year_color
Definition: UICharacter.cpp:88
Localization::GetMonthName
const char * GetMonthName(unsigned int index) const
Definition: Localization.h:19
GUIWindow_Book::BasicBookInitialization
void BasicBookInitialization()
Definition: UIBooks.cpp:67
assets
AssetsManager * assets
Definition: AssetsManager.cpp:12
GUIWindow::ptr_1C
void * ptr_1C
Definition: GUIWindow.h:476
Localization::GetDayName
const char * GetDayName(unsigned int index) const
Definition: Localization.h:15
GUIWindow::uFrameX
unsigned int uFrameX
Definition: GUIWindow.h:468
pAudioPlayer
AudioPlayer * pAudioPlayer
Definition: AudioPlayer.cpp:20
Party::uCurrentYear
unsigned int uCurrentYear
Definition: Party.h:271
WINDOW_CalendarBook
@ WINDOW_CalendarBook
Definition: GUIWindow.h:339
StringPrintf
String StringPrintf(const char *fmt,...)
Definition: Strings.cpp:9
Viewport::uViewportTL_X
int uViewportTL_X
Definition: Viewport.h:22
game_viewport_z
int game_viewport_z
Definition: mm7_data.cpp:198
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