Mercurial > mm7
view UIRest.cpp @ 760:7f1487b74571
some outdoor cleaning
author | Gloval |
---|---|
date | Sat, 23 Mar 2013 17:02:14 +0400 |
parents | d6236f6a9882 |
children | dfd683c4f538 |
line wrap: on
line source
#include <assert.h> #include "MM7.h" #include "MapInfo.h" #include "Game.h" #include "GUIWindow.h" #include "GUIFont.h" #include "GUIButton.h" #include "GUIProgressBar.h" #include "Party.h" #include "AudioPlayer.h" #include "Outdoor.h" #include "IndoorCamera.h" #include "Overlays.h" #include "Monsters.h" #include "Arcomage.h" #include "LOD.h" #include "Actor.h" #include "Allocator.h" #include "Events.h" #include "Viewport.h" #include "FrameTableInc.h" #include "Math.h" #include "SpriteObject.h" #include "ObjectList.h" #include "Chest.h" #include "PaletteManager.h" #include "DecorationList.h" #include "SaveLoad.h" #include "stru123.h" #include "Time.h" #include "IconFrameTable.h" #include "Awards.h" #include "Autonotes.h" #include "stru160.h" #include "stru279.h" #include "TurnEngine.h" #include "stru277.h" #include "Weather.h" #include "stru272.h" #include "stru298.h" #include "StorylineTextTable.h" #include "Events2D.h" #include "texts.h" #include "stru351.h" #include "mm7_data.h" //----- (0041F6C1) -------------------------------------------------------- void __cdecl RestUI_Initialize() { Player *v0; // eax@10 if ( !dword_506F14 ) pAudioPlayer->StopChannels(-1, -1); if ( pCurrentScreen ) { pGUIWindow_CurrentMenu->Release(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; } pEventTimer->Pause(); if ( dword_506F14 != 2 ) GUIWindow::Create(518u, 450u, 0, 0, (enum WindowType)90, (int)pBtn_Rest, 0); _506F18_num_hours_to_sleep = 0; dword_506F14 = 0; uRestUI_FoodRequiredToRest = 2; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos( pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); if ( PartyHasDragon() ) { v0 = pParty->pPlayers;//[0].uClass; while ( v0 <= &pParty->pPlayers[3] ) { ++v0; if ( v0 > &pParty->pPlayers[3] ) break; } if(v0->classType == PLAYER_CLASS_WARLOCK) ++uRestUI_FoodRequiredToRest; } if ( CheckHiredNPCSpeciality(Porter) ) --uRestUI_FoodRequiredToRest; if ( CheckHiredNPCSpeciality(QuarterMaster) ) uRestUI_FoodRequiredToRest -= 2; if ( CheckHiredNPCSpeciality(Gypsy) ) --uRestUI_FoodRequiredToRest; if ( uRestUI_FoodRequiredToRest < 1 ) uRestUI_FoodRequiredToRest = 1; if ( !_strcmpi(pCurrentMapName, "d29.blv") && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 98) ) uRestUI_FoodRequiredToRest = 0; ++pIcons_LOD->uTexturePacksCount; if ( !pIcons_LOD->uNumPrevLoadedFiles ) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; pCurrentScreen = SCREEN_REST; _507CD4_RestUI_hourglass_anim_controller = 0; uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE); uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE); uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE); uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE); uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE); uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE); LoadActualSkyFrame(); pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, (enum WindowType)16, 0, 0); pButton_RestUI_Exit = pGUIWindow_CurrentMenu->CreateButton( 280u, 297u, 154u, 37u, 1, 0, 0xA7u, 0, 0, "", (Texture *)(uTextureID_RestUI_restexit != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restexit] : 0), 0); pButton_RestUI_Main = pGUIWindow_CurrentMenu->CreateButton( 24u, 154u, 225u, 37u, 1, 0, 0x61u, 0, 0x52u, "", (Texture *)(uTextureID_RestUI_restb4 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb4] : 0), 0); pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton( 61u, 232u, 154u, 33u, 1, 0, 0x6Du, 0, 0x44u, "", (Texture *)(uTextureID_RestUI_restb1 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb1] : 0), 0); pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton( 61u, 264u, 154u, 33u, 1, 0, 0x60u, 0, 0x48u, "", (Texture *)(uTextureID_RestUI_restb2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb2] : 0), 0); pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton( 61u, 296u, 154u, 33u, 1, 0, 0x5Fu, 0, 0x4Du, "", (Texture *)(uTextureID_RestUI_restb3 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb3] : 0), 0); } //----- (0041FA01) -------------------------------------------------------- void __cdecl RestUI_Draw() { int v0; // esi@1 Player **ppPlayers; // ecx@1 Player *pPlayer; // eax@2 unsigned int v3; // eax@15 //char v4; // al@17 bool v5; // eax@21 GUIButton Dst; // [sp+8h] [bp-DCh]@19 //double v7; // [sp+C4h] [bp-20h]@17 float v8; // [sp+CCh] [bp-18h]@17 __int64 v9; // [sp+D0h] [bp-14h]@17 unsigned int v10; // [sp+D8h] [bp-Ch]@9 __int16 a9[2]; // [sp+DCh] [bp-8h]@1 int a5; // [sp+E0h] [bp-4h]@1 v0 = 0; a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xAu, 0, 0); *(int *)a9 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE6u, 0xD6u, 0xC1u); ppPlayers = &pPlayers[1]; do { pPlayer = *ppPlayers; if ( !(*ppPlayers)->pConditions[14] && !pPlayer->pConditions[16] && pPlayer->sHealth > 0 ) ++v0; ++ppPlayers; } while ( (signed int)ppPlayers <= (signed int)&pPlayers[4] ); if ( v0 ) { pRenderer->DrawTextureIndexed( 8u, 8u, (Texture *)(uTextureID_RestUI_restmain != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restmain] : 0)); v10 = pParty->uCurrentHour; dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem; if ( (signed int)pParty->uCurrentHour <= 12 ) { if ( !v10 ) v10 = 12; } else { v10 -= 12; } pRenderer->DrawTextureIndexed(16u, 26u, pTexture_RestUI_CurrentSkyFrame); if ( pTexture_RestUI_CurrentHourglassFrame ) { pTexture_RestUI_CurrentHourglassFrame->Release(); pIcons_LOD->_40F9C5(); } v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller; _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed; if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 ) { v3 = 0; _507CD4_RestUI_hourglass_anim_controller = 0; } v9 = v3; v8 = (double)v3 / 512.0 * 120.0; //v7 = v8 + 6.7553994e15; HIDWORD(v9) = floorf(v8 + 0.5f);//LODWORD(v7); hourglass_icon_idx = (int)floorf(v8 + 0.5f) % 256 + 1;//LOBYTE(v7) + 1; //hourglass_icon_idx = v4; if (hourglass_icon_idx >= 120 ) { //v4 = 1; hourglass_icon_idx = 1; } sprintf(pTmpBuf, "hglas%03d", hourglass_icon_idx); pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE); pRenderer->DrawTextureIndexed(0x10Bu, 0x9Fu, pTexture_RestUI_CurrentHourglassFrame); memset(&Dst, 0, 0xBCu); Dst.uX = 24; Dst.uY = 154; Dst.uWidth = 171; Dst.uHeight = 37; Dst.uZ = 194; Dst.uW = 190; Dst.pParent = pButton_RestUI_WaitUntilDawn->pParent; Dst.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, a5, *(int **)a9); Dst.pParent = 0; sprintf(pTmpBuf, "\r408%d", uRestUI_FoodRequiredToRest); pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, a5, pTmpBuf, 0, 0, *(unsigned int *)a9); pButton_RestUI_WaitUntilDawn->DrawLabel( pGlobalTXT_LocalizationStrings[237], pFontCreate, a5, *(int **)a9); pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, a5, *(int **)a9); pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, a5, *(int **)a9); pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, a5, *(int **)a9); memset(&Dst, 0, 0xBCu); Dst.uX = 45; Dst.uY = 199; Dst.uWidth = 185; Dst.uHeight = 30; Dst.uZ = 229; Dst.uW = 228; Dst.pParent = pButton_RestUI_WaitUntilDawn->pParent; Dst.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, a5, *(int **)a9); Dst.pParent = 0; v5 = pParty->uCurrentHour >= 0xC && pParty->uCurrentHour < 0x18; sprintf(pTmpBuf, "%d:%02d %s", v10, pParty->uCurrentMinute, aAMPMNames[v5]); pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, a5, pTmpBuf, 0, 0, *(unsigned int *)a9); sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1); pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, a5, pTmpBuf, 0, 0, *(unsigned int *)a9); sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1); pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, a5, pTmpBuf, 0, 0, *(unsigned int *)a9); sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear); pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, a5, pTmpBuf, 0, 0, *(unsigned int *)a9); if ( dword_506F14 ) Sleep6Hours(); } else { GUIWindow::Create( pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, (enum WindowType)96, (int)pButton_RestUI_Exit, (int)pGlobalTXT_LocalizationStrings[81]); } }