diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GUI/UI/Books/CalendarBook.cpp	Tue May 12 03:24:19 2015 +0200
@@ -0,0 +1,135 @@
+#include "Engine/Engine.h"
+#include "Engine/LOD.h"
+#include "Engine/Party.h"
+#include "Engine/Timer.h"
+#include "Engine/texts.h"
+#include "Engine/Graphics/IRender.h"
+#include "Engine/Graphics/Viewport.h"
+
+#include "GUI/GUIFont.h"
+#include "GUI/UI/Books/CalendarBook.h"
+
+#include "Media/Audio/AudioPlayer.h"
+
+
+
+GUIWindow_CalendarBook::GUIWindow_CalendarBook() :
+    GUIWindow_Book()
+{
+    this->ptr_1C = (void *)WINDOW_CalendarBook; // inherited from GUIWindow::GUIWindow
+    BasicBookInitialization();
+
+// --------------------------------
+// 004304E7 Game_EventLoop --- part
+    pEventTimer->Pause();
+    pAudioPlayer->StopChannels(-1, -1);
+    pBooksButtonOverlay = new GUIWindow_BooksButtonOverlay(570, 354, 0, 0, (int)pBtn_Calendar, 0);
+
+// ----------------------------------------------
+// 00411BFC GUIWindow::InitializeBookView -- part
+    pSpellBookPagesTextr_13 = pIcons_LOD->LoadTexturePtr("sbdate-time", TEXTURE_16BIT_PALETTE);
+    pTex_moon_new = pIcons_LOD->LoadTexturePtr("moon_new", TEXTURE_16BIT_PALETTE);
+    pTex_moon_4 = pIcons_LOD->LoadTexturePtr("moon_4", TEXTURE_16BIT_PALETTE);
+    pTex_moon_2 = pIcons_LOD->LoadTexturePtr("moon_2", TEXTURE_16BIT_PALETTE);
+    pTex_moon_2_2 = pIcons_LOD->LoadTexturePtr("moon_2", TEXTURE_16BIT_PALETTE);
+    pTex_moon_ful = pIcons_LOD->LoadTexturePtr("moon_ful", TEXTURE_16BIT_PALETTE);
+}
+
+
+
+//----- (00413D3C) --------------------------------------------------------
+static const char *GetDayPart()
+{
+    if (pParty->uCurrentHour > 5 && pParty->uCurrentHour < 20)
+        return pGlobalTXT_LocalizationStrings[56]; // "Day"
+    else if (pParty->uCurrentHour == 5)
+        return pGlobalTXT_LocalizationStrings[55]; // "Dawn"
+    else if (pParty->uCurrentHour == 20)
+        return pGlobalTXT_LocalizationStrings[566]; // "Dusk"
+    else
+        return pGlobalTXT_LocalizationStrings[567]; // "Night"
+}
+
+
+
+void GUIWindow_CalendarBook::Update()
+{
+// -----------------------------------
+// 004156F0 GUI_UpdateWindows --- part
+// {
+//     BookUI_Draw((WindowType)(int)ptr_1C);
+// }
+
+// ----- (00413CC6) --------------------------------------------------------
+// void BookUI_Draw(WindowType book) --- part
+// {
+    pRenderer->DrawTextureIndexed(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId));
+//     BookUI_Calendar_Draw();
+
+// ----- (00413D6F) --------------------------------------------------------
+// void BookUI_Calendar_Draw()
+// {
+    int am; // ecx@5
+    char *pMapName; // eax@6
+    GUIWindow calendar_window; // [sp+Ch] [bp-60h]@5
+    unsigned int pMapID; // [sp+60h] [bp-Ch]@1
+    unsigned int pHour;
+
+    static unsigned int pDayMoonPhase[28] = // 4E1B18
+    {
+        0, 0, 0,
+        1, 1, 1, 1,
+        2, 2, 2,
+        3, 3, 3, 3,
+        4, 4, 4,
+        3, 3, 3, 3,
+        2, 2, 2,
+        1, 1, 1, 1
+    };
+
+    pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_13);
+    pHour = pParty->uCurrentHour;
+    if ((signed int)pHour >= 12)
+    {
+        pHour -= 12;
+        if (!pHour)
+            pHour = 12;
+        am = 1;
+    }
+    else
+        am = 0;
+
+    calendar_window.uFrameX = game_viewport_x;
+    calendar_window.uFrameY = game_viewport_y;
+    calendar_window.uFrameWidth = game_viewport_width;
+    calendar_window.uFrameHeight = game_viewport_height;
+    calendar_window.uFrameZ = game_viewport_z;
+    calendar_window.uFrameW = game_viewport_w;
+    calendar_window.DrawTitleText(pBook2Font, 0, 22, ui_book_calendar_title_color, pGlobalTXT_LocalizationStrings[186], 3); // "Time in Erathia"
+
+    sprintf(pTmpBuf.data(), "%s\t100:\t110%d:%02d %s - %s", pGlobalTXT_LocalizationStrings[526], // "Time"
+        pHour, pParty->uCurrentMinute, aAMPMNames[am], GetDayPart());
+    calendar_window.DrawText(pBookFont, 70, 55, ui_book_calendar_time_color, pTmpBuf.data(), 0, 0, 0);
+
+    sprintf(pTmpBuf.data(), "%s\t100:\t110%d - %s", pGlobalTXT_LocalizationStrings[56], // "Day"
+        pParty->uDaysPlayed + 1, aDayNames[pParty->uDaysPlayed % 7]);
+    calendar_window.DrawText(pBookFont, 70, 2 * LOBYTE(pBookFont->uFontHeight) + 49, ui_book_calendar_day_color, pTmpBuf.data(), 0, 0, 0);
+
+    sprintf(pTmpBuf.data(), "%s\t100:\t110%d - %s", pGlobalTXT_LocalizationStrings[146], // "Month"
+        pParty->uCurrentMonth + 1, aMonthNames[pParty->uCurrentMonth]);
+    calendar_window.DrawText(pBookFont, 70, 4 * LOBYTE(pBookFont->uFontHeight) + 43, ui_book_calendar_month_color, pTmpBuf.data(), 0, 0, 0);
+
+    sprintf(pTmpBuf.data(), "%s\t100:\t110%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear); // "Year"
+    calendar_window.DrawText(pBookFont, 70, 6 * LOBYTE(pBookFont->uFontHeight) + 37, ui_book_calendar_year_color, pTmpBuf.data(), 0, 0, 0);
+
+    sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[530], aMoonPhaseNames[pDayMoonPhase[pParty->uDaysPlayed]]); // "Moon"
+    calendar_window.DrawText(pBookFont, 70, 8 * LOBYTE(pBookFont->uFontHeight) + 31, ui_book_calendar_moon_color, pTmpBuf.data(), 0, 0, 0);
+
+    pMapID = pMapStats->GetMapInfo(pCurrentMapName);
+    if (pMapID)
+        pMapName = pMapStats->pInfos[pMapID].pName;
+    else
+        pMapName = "Unknown";
+    sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[531], pMapName); // "Location"
+    calendar_window.DrawText(pBookFont, 70, 10 * LOBYTE(pBookFont->uFontHeight) + 25, ui_book_calendar_location_color, pTmpBuf.data(), 0, 0, 0);
+}
\ No newline at end of file