view GUI/UI/Books/LloydsBook.cpp @ 2562:b8a56afc6ba1

new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
author Ritor1
date Sun, 17 May 2015 22:42:13 +0600
parents 87e5590d034b
children d87bfbd3bb3b
line wrap: on
line source

#include "Engine/Engine.h"
#include "Engine/LOD.h"
#include "Engine/Party.h"
#include "Engine/texts.h"
#include "Engine/Graphics/IRender.h"

#include "GUI/GUIFont.h"
#include "GUI/UI/Books/LloydsBook.h"


std::array<unsigned int, 5> pLloydsBeaconsPreviewXs = { { 61, 281, 61, 281, 171 } }; // 004E249C
std::array<unsigned int, 5> pLloydsBeaconsPreviewYs = { { 84, 84, 228, 228, 155 } };
std::array<unsigned int, 5> pLloydsBeacons_SomeXs = { { 59, 279, 59, 279, 169 } };
std::array<unsigned int, 5> pLloydsBeacons_SomeYs = { { 82, 82, 226, 226, 153 } };

GUIWindow_LloydsBook::GUIWindow_LloydsBook() :
    GUIWindow_Book()
{
    this->ptr_1C = (void *)WINDOW_LloydsBeacon; // inherited from GUIWindow::GUIWindow
    BasicBookInitialization();

// ----------------------------------------------
// 00411BFC GUIWindow::InitializeBookView -- part
    byte_506360 = 0;
    pTexture_CurrentBook = pIcons_LOD->LoadTexturePtr("lb_bordr", TEXTURE_16BIT_PALETTE);
    pTexture_LloydBeacons[0] = pIcons_LOD->LoadTexturePtr("sbmap", TEXTURE_16BIT_PALETTE);
    pTexture_LloydBeacons[1] = pIcons_LOD->LoadTexturePtr("sbmap", TEXTURE_16BIT_PALETTE);
    pTex_book_button1_on = pIcons_LOD->LoadTexturePtr("tab-an-6b", TEXTURE_16BIT_PALETTE);
    pTex_book_button1_off = pIcons_LOD->LoadTexturePtr("tab-an-6a", TEXTURE_16BIT_PALETTE);

    pBtn_Book_1 = CreateButton(415, 13, 39, 36, 1, 0, UIMSG_LloydsBeacon_FlippingBtn, 0, 0, pGlobalTXT_LocalizationStrings[375], 0); // Set Beacon
    pBtn_Book_2 = CreateButton(415, 48, 39, 36, 1, 0, UIMSG_LloydsBeacon_FlippingBtn, 1, 0, pGlobalTXT_LocalizationStrings[523], 0); // Recall Beacon

    int max_beacons = 1;
    int v18 = pParty->pPlayers[_506348_current_lloyd_playerid].pActiveSkills[PLAYER_SKILL_WATER];
    if (v18 & 0x100 || (v18 & 0x80))
        max_beacons = 5;
    else if (v18 & 0x40)
        max_beacons = 3;

    for (int i = 0; i < max_beacons; ++i)
        CreateButton(
            pLloydsBeaconsPreviewXs[i], pLloydsBeaconsPreviewYs[i],
            92, 68, 1, 180, UIMSG_InstallBeacon, i, 0, "", 0
        );

    for (int i = 0; i < 5; ++i)
    {
        if (pParty->pPlayers[_506348_current_lloyd_playerid].pInstalledBeacons[i].uBeaconTime >= (signed __int64)pParty->uTimePlayed)
            LoadThumbnailLloydTexture(i, _506348_current_lloyd_playerid + 1);
        else
            memset(&pParty->pPlayers[_506348_current_lloyd_playerid].pInstalledBeacons[i], 0, sizeof(LloydBeacon));
    }
}


void GUIWindow_LloydsBook::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));
//     DrawLloydBeaconsScreen();

// ----- (00410DEC) --------------------------------------------------------
// unsigned int DrawLloydBeaconsScreen()
// {
    Player *pPlayer; // esi@1
    const char *pText; // eax@1
    int pTextHeight; // eax@14
    int RemainingTime; // kr08_8@14
    unsigned int pHours; // esi@14
    unsigned int pDays; // eax@14
    const char *pSelectionText; // eax@19
    Texture *v19; // [sp-4h] [bp-8Ch]@4
    GUIWindow pWindow; // [sp+Ch] [bp-7Ch]@1
    char *Str; // [sp+74h] [bp-14h]@14
    int BeaconID; // [sp+78h] [bp-10h]@11
    int uNumMaxBeacons; // [sp+84h] [bp-4h]@6

    pPlayer = &pParty->pPlayers[_506348_current_lloyd_playerid];
    pRenderer->DrawTextureIndexed(8, 8, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]);
    pText = pGlobalTXT_LocalizationStrings[523];     // Recall Beacon
    pWindow.uFrameX = game_viewport_x;
    pWindow.uFrameY = game_viewport_y;
    pWindow.uFrameWidth = 428;
    pWindow.uFrameHeight = game_viewport_height;
    pWindow.uFrameZ = 435;
    pWindow.uFrameW = game_viewport_w;
    if (!bRecallingBeacon)
        pText = pGlobalTXT_LocalizationStrings[375];   // Set Beacon
    sprintf(pTmpBuf.data(), "%s", pText);
    pWindow.DrawTitleText(pBook2Font, 0, 22, 0, pTmpBuf.data(), 3);
    if (bRecallingBeacon)
    {
        pRenderer->DrawTextureIndexedAlpha(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_book_button1_on);
        v19 = pTex_book_button1_off;
    }
    else
    {
        pRenderer->DrawTextureIndexedAlpha(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_book_button1_off);
        v19 = pTex_book_button1_on;
    }
    pRenderer->DrawTextureIndexedAlpha(pBtn_Book_2->uX, pBtn_Book_2->uY, v19);
    uNumMaxBeacons = 1;
    if (HIBYTE(pPlayer->pActiveSkills[PLAYER_SKILL_WATER]) & 1 || (pPlayer->pActiveSkills[PLAYER_SKILL_WATER] & 0x80u) != 0)
    {
        uNumMaxBeacons = 5;
    }
    else
    {
        if (pPlayer->pActiveSkills[PLAYER_SKILL_WATER] & 0x40)
            uNumMaxBeacons = 3;
    }
    if (uNumMaxBeacons > 0)
    {
        for (BeaconID = 0; BeaconID < uNumMaxBeacons; BeaconID++)
        {
            pWindow.uFrameWidth = 92;
            pWindow.uFrameHeight = 68;
            pWindow.uFrameY = pLloydsBeaconsPreviewYs[BeaconID];
            pWindow.uFrameX = pLloydsBeaconsPreviewXs[BeaconID];
            pWindow.uFrameW = pWindow.uFrameY + 67;
            pWindow.uFrameZ = pLloydsBeaconsPreviewXs[BeaconID] + 91;
            //if ( pSavegameThumbnails[BeaconID].pPixels != 0 )
            if (pPlayer->pInstalledBeacons[BeaconID].SaveFileID != 0)
            {
                pRenderer->DrawTextureIndexedAlpha(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
                pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[BeaconID], pLloydsBeaconsPreviewYs[BeaconID], &pSavegameThumbnails[BeaconID]);
                Str = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(pPlayer->pInstalledBeacons[BeaconID].SaveFileID)].pName;
                pTextHeight = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0);
                pWindow.uFrameY += -6 - pTextHeight;
                pWindow.DrawTitleText(pSpellFont, 0, 0, 1, Str, 3);
                RemainingTime = pPlayer->pInstalledBeacons[BeaconID].uBeaconTime - pParty->uTimePlayed;
                pHours = (signed __int64)((double)RemainingTime * 0.234375) / 60 / 60;
                pDays = pHours / 24;
                if (pDays)
                {
                    sprintf(pTmpBuf.data(), "%lu %s", pDays + 1, pGlobalTXT_LocalizationStrings[57]);//days
                    pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
                    pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
                    continue;
                }
                else
                {
                    if (pHours + 1 <= 23)
                    {
                        if (pHours < 1)
                            pSelectionText = pGlobalTXT_LocalizationStrings[109];// Hour
                        else
                            pSelectionText = pGlobalTXT_LocalizationStrings[110];// Hours
                        sprintf(pTmpBuf.data(), "%lu %s", pHours + 1, pSelectionText);
                        pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
                        pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
                        continue;
                    }
                }
                sprintf(pTmpBuf.data(), "%lu %s", pDays + 1, pGlobalTXT_LocalizationStrings[56]);//Day
                pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
                pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
                continue;
            }
            if (!bRecallingBeacon)
            {
                pRenderer->DrawTextureIndexedAlpha(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
                pTextHeight = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0);
                pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - pTextHeight / 2, 1, pGlobalTXT_LocalizationStrings[19], 3);//Доступно
            }
        }
    }
    if (byte_506360)
        pMessageQueue_50CBD0->AddGUIMessage(UIMSG_CloseAfterInstallBeacon, 0, 0);
}