comparison GUI/UI/Books/CalendarBook.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/texts.h"
6 #include "Engine/Graphics/IRender.h"
7 #include "Engine/Graphics/Viewport.h"
8
9 #include "GUI/GUIFont.h"
10 #include "GUI/UI/Books/CalendarBook.h"
11
12 #include "Media/Audio/AudioPlayer.h"
13
14
15
16 GUIWindow_CalendarBook::GUIWindow_CalendarBook() :
17 GUIWindow_Book()
18 {
19 this->ptr_1C = (void *)WINDOW_CalendarBook; // inherited from GUIWindow::GUIWindow
20 BasicBookInitialization();
21
22 // --------------------------------
23 // 004304E7 Game_EventLoop --- part
24 pEventTimer->Pause();
25 pAudioPlayer->StopChannels(-1, -1);
26 pBooksButtonOverlay = new GUIWindow_BooksButtonOverlay(570, 354, 0, 0, (int)pBtn_Calendar, 0);
27
28 // ----------------------------------------------
29 // 00411BFC GUIWindow::InitializeBookView -- part
30 pSpellBookPagesTextr_13 = pIcons_LOD->LoadTexturePtr("sbdate-time", TEXTURE_16BIT_PALETTE);
31 pTex_moon_new = pIcons_LOD->LoadTexturePtr("moon_new", TEXTURE_16BIT_PALETTE);
32 pTex_moon_4 = pIcons_LOD->LoadTexturePtr("moon_4", TEXTURE_16BIT_PALETTE);
33 pTex_moon_2 = pIcons_LOD->LoadTexturePtr("moon_2", TEXTURE_16BIT_PALETTE);
34 pTex_moon_2_2 = pIcons_LOD->LoadTexturePtr("moon_2", TEXTURE_16BIT_PALETTE);
35 pTex_moon_ful = pIcons_LOD->LoadTexturePtr("moon_ful", TEXTURE_16BIT_PALETTE);
36 }
37
38
39
40 //----- (00413D3C) --------------------------------------------------------
41 static const char *GetDayPart()
42 {
43 if (pParty->uCurrentHour > 5 && pParty->uCurrentHour < 20)
44 return pGlobalTXT_LocalizationStrings[56]; // "Day"
45 else if (pParty->uCurrentHour == 5)
46 return pGlobalTXT_LocalizationStrings[55]; // "Dawn"
47 else if (pParty->uCurrentHour == 20)
48 return pGlobalTXT_LocalizationStrings[566]; // "Dusk"
49 else
50 return pGlobalTXT_LocalizationStrings[567]; // "Night"
51 }
52
53
54
55 void GUIWindow_CalendarBook::Update()
56 {
57 // -----------------------------------
58 // 004156F0 GUI_UpdateWindows --- part
59 // {
60 // BookUI_Draw((WindowType)(int)ptr_1C);
61 // }
62
63 // ----- (00413CC6) --------------------------------------------------------
64 // void BookUI_Draw(WindowType book) --- part
65 // {
66 pRenderer->DrawTextureIndexed(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId));
67 // BookUI_Calendar_Draw();
68
69 // ----- (00413D6F) --------------------------------------------------------
70 // void BookUI_Calendar_Draw()
71 // {
72 int am; // ecx@5
73 char *pMapName; // eax@6
74 GUIWindow calendar_window; // [sp+Ch] [bp-60h]@5
75 unsigned int pMapID; // [sp+60h] [bp-Ch]@1
76 unsigned int pHour;
77
78 static unsigned int pDayMoonPhase[28] = // 4E1B18
79 {
80 0, 0, 0,
81 1, 1, 1, 1,
82 2, 2, 2,
83 3, 3, 3, 3,
84 4, 4, 4,
85 3, 3, 3, 3,
86 2, 2, 2,
87 1, 1, 1, 1
88 };
89
90 pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_13);
91 pHour = pParty->uCurrentHour;
92 if ((signed int)pHour >= 12)
93 {
94 pHour -= 12;
95 if (!pHour)
96 pHour = 12;
97 am = 1;
98 }
99 else
100 am = 0;
101
102 calendar_window.uFrameX = game_viewport_x;
103 calendar_window.uFrameY = game_viewport_y;
104 calendar_window.uFrameWidth = game_viewport_width;
105 calendar_window.uFrameHeight = game_viewport_height;
106 calendar_window.uFrameZ = game_viewport_z;
107 calendar_window.uFrameW = game_viewport_w;
108 calendar_window.DrawTitleText(pBook2Font, 0, 22, ui_book_calendar_title_color, pGlobalTXT_LocalizationStrings[186], 3); // "Time in Erathia"
109
110 sprintf(pTmpBuf.data(), "%s\t100:\t110%d:%02d %s - %s", pGlobalTXT_LocalizationStrings[526], // "Time"
111 pHour, pParty->uCurrentMinute, aAMPMNames[am], GetDayPart());
112 calendar_window.DrawText(pBookFont, 70, 55, ui_book_calendar_time_color, pTmpBuf.data(), 0, 0, 0);
113
114 sprintf(pTmpBuf.data(), "%s\t100:\t110%d - %s", pGlobalTXT_LocalizationStrings[56], // "Day"
115 pParty->uDaysPlayed + 1, aDayNames[pParty->uDaysPlayed % 7]);
116 calendar_window.DrawText(pBookFont, 70, 2 * LOBYTE(pBookFont->uFontHeight) + 49, ui_book_calendar_day_color, pTmpBuf.data(), 0, 0, 0);
117
118 sprintf(pTmpBuf.data(), "%s\t100:\t110%d - %s", pGlobalTXT_LocalizationStrings[146], // "Month"
119 pParty->uCurrentMonth + 1, aMonthNames[pParty->uCurrentMonth]);
120 calendar_window.DrawText(pBookFont, 70, 4 * LOBYTE(pBookFont->uFontHeight) + 43, ui_book_calendar_month_color, pTmpBuf.data(), 0, 0, 0);
121
122 sprintf(pTmpBuf.data(), "%s\t100:\t110%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear); // "Year"
123 calendar_window.DrawText(pBookFont, 70, 6 * LOBYTE(pBookFont->uFontHeight) + 37, ui_book_calendar_year_color, pTmpBuf.data(), 0, 0, 0);
124
125 sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[530], aMoonPhaseNames[pDayMoonPhase[pParty->uDaysPlayed]]); // "Moon"
126 calendar_window.DrawText(pBookFont, 70, 8 * LOBYTE(pBookFont->uFontHeight) + 31, ui_book_calendar_moon_color, pTmpBuf.data(), 0, 0, 0);
127
128 pMapID = pMapStats->GetMapInfo(pCurrentMapName);
129 if (pMapID)
130 pMapName = pMapStats->pInfos[pMapID].pName;
131 else
132 pMapName = "Unknown";
133 sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[531], pMapName); // "Location"
134 calendar_window.DrawText(pBookFont, 70, 10 * LOBYTE(pBookFont->uFontHeight) + 25, ui_book_calendar_location_color, pTmpBuf.data(), 0, 0, 0);
135 }