diff UIRest.cpp @ 1026:6afa77761a00

Слияние
author Ritor1
date Tue, 21 May 2013 12:43:08 +0600
parents e865f349aa41
children 3a5c8df8381d
line wrap: on
line diff
--- a/UIRest.cpp	Tue May 21 12:42:57 2013 +0600
+++ b/UIRest.cpp	Tue May 21 12:43:08 2013 +0600
@@ -4,6 +4,7 @@
 
 #include "MapInfo.h"
 #include "Game.h"
+#include "Player.h"
 #include "GUIWindow.h"
 #include "GUIFont.h"
 #include "GUIProgressBar.h"
@@ -113,114 +114,111 @@
 //----- (0041FA01) --------------------------------------------------------
 void __cdecl RestUI_Draw()
     {
-    int v0; // esi@1
-    Player **ppPlayers; // ecx@1
-    Player *pPlayer; // eax@2
+    int live_characters; // esi@1
     unsigned int v3; // eax@15
     //char v4; // al@17
     bool v5; // eax@21
-    GUIButton Dst; // [sp+8h] [bp-DCh]@19
+    GUIButton tmp_button; // [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
+    unsigned int am_pm_hours; // [sp+D8h] [bp-Ch]@9
+    __int16 shadow_color; // [sp+DCh] [bp-8h]@1
+    int text_color; // [sp+E0h] [bp-4h]@1
 
-    v0 = 0;
-    a5 = TargetColor(0xAu, 0, 0);
-    *(int *)a9 = TargetColor(0xE6u, 0xD6u, 0xC1u);
-    ppPlayers = &pPlayers[1];
-    do
+    live_characters = 0;
+    text_color =   TargetColor(10, 0, 0);
+    shadow_color = TargetColor(230, 214, 193);
+    for(int i=1; i<5; ++i)
+        if ( !pPlayers[i]->pConditions[Player::Condition_Dead] && !pPlayers[i]->pConditions[Player::Condition_Eradicated] && pPlayers[i]->sHealth > 0 )
+            ++live_characters;
+
+    if ( live_characters )
         {
-        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(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain));
+        am_pm_hours = pParty->uCurrentHour;
+        dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
+        if ( (signed int)pParty->uCurrentHour <= 12 )
             {
-            pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain));
-            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();
+            if ( !am_pm_hours )
+                am_pm_hours = 12;
             }
         else
+            {
+            am_pm_hours -= 12;
+            }
+        pRenderer->DrawTextureIndexed(16u, 26u, pTexture_RestUI_CurrentSkyFrame);
+        if ( pTexture_RestUI_CurrentHourglassFrame )
+            {
+            pTexture_RestUI_CurrentHourglassFrame->Release();
+            pIcons_LOD->SyncLoadedFilesCount();
+            }
+        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 )
+            hourglass_icon_idx = 1;
+
+        sprintf(pTmpBuf, "hglas%03d", hourglass_icon_idx);
+        pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE);
+        pRenderer->DrawTextureIndexed(267, 159, pTexture_RestUI_CurrentHourglassFrame);
+        memset(&tmp_button, 0, sizeof(GUIButton));
+        tmp_button.uX = 24;
+        tmp_button.uY = 154;
+
+        tmp_button.uZ = 194;
+        tmp_button.uW = 190;
+
+        tmp_button.uWidth = 171;
+        tmp_button.uHeight = 37;
+
+        tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent;
+        tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, text_color, shadow_color);
+        tmp_button.pParent = 0;
+        sprintf(pTmpBuf, "\r408%d", uRestUI_FoodRequiredToRest);
+        pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, text_color, pTmpBuf, 0, 0, shadow_color);
+        pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, text_color, shadow_color);
+        pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, text_color, shadow_color);
+        pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, text_color, shadow_color);
+        pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, text_color, shadow_color);
+        memset(&tmp_button, 0, sizeof(GUIButton));
+        tmp_button.uX = 45;
+        tmp_button.uY = 199;
+
+        tmp_button.uZ = 229;
+        tmp_button.uW = 228;
+
+        tmp_button.uWidth = 185;
+        tmp_button.uHeight = 30;
+
+        tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent;
+        tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, text_color, shadow_color);
+        tmp_button.pParent = 0;
+        v5 = (pParty->uCurrentHour >= 12 && pParty->uCurrentHour < 24)? 1:0;
+        sprintf(pTmpBuf, "%d:%02d %s", am_pm_hours, pParty->uCurrentMinute, aAMPMNames[v5]);
+        pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, text_color, pTmpBuf, 0, 0, shadow_color);
+        sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1);
+        pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, text_color, pTmpBuf, 0, 0, shadow_color);
+        sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1);
+        pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, text_color, pTmpBuf, 0, 0, shadow_color);
+        sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);
+        pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, text_color, pTmpBuf, 0, 0, shadow_color);
+        if ( dword_506F14 )
+            Sleep6Hours();
+        }
+    else
         {
-          GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn,
-           (int)pButton_RestUI_Exit, (int)pGlobalTXT_LocalizationStrings[81]);
+        GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn,
+            (int)pButton_RestUI_Exit, (int)pGlobalTXT_LocalizationStrings[81]);
         }
     }
\ No newline at end of file