diff GUI/UI/UIRest.cpp @ 2543:b6140dfeac27

GameOver h/cpp
author a.parshin
date Sun, 10 May 2015 03:21:14 +0200
parents a902abdfc7f2
children c674d547cc7c
line wrap: on
line diff
--- a/GUI/UI/UIRest.cpp	Sun May 10 02:04:52 2015 +0200
+++ b/GUI/UI/UIRest.cpp	Sun May 10 03:21:14 2015 +0200
@@ -18,49 +18,50 @@
 
 
 
-//----- (0041F6C1) --------------------------------------------------------
-void RestUI_Load()
+void PrepareToLoadRestUI()
 {
-  if ( !dword_506F14 )
-    pAudioPlayer->StopChannels(-1, -1);
-  if ( current_screen_type != SCREEN_GAME)
-  {
-    pGUIWindow_CurrentMenu->Release();
-    current_screen_type = SCREEN_GAME;
-    viewparams->bRedrawGameUI = true;
-  }
-  pEventTimer->Pause();
-  if ( dword_506F14 != 2 )
-    GUIWindow::Create(518, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_Rest, 0);
-  _506F18_num_minutes_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() )
-  {
-    for ( uint i = 0; i < 4; ++i )
+    if (!_506F14_resting_stage)
+        pAudioPlayer->StopChannels(-1, -1);
+    if (current_screen_type != SCREEN_GAME)
+    {
+        pGUIWindow_CurrentMenu->Release();
+        current_screen_type = SCREEN_GAME;
+        viewparams->bRedrawGameUI = true;
+    }
+    pEventTimer->Pause();
+    if (_506F14_resting_stage != 2)
+        GUIWindow::Create(518, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_Rest, 0);
+    _506F18_num_minutes_to_sleep = 0;
+    _506F14_resting_stage = 0;
+    uRestUI_FoodRequiredToRest = 2;
+    if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+        uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
+    if (PartyHasDragon())
     {
-      if (pParty->pPlayers[i].classType == PLAYER_CLASS_WARLOCK)
-        ++uRestUI_FoodRequiredToRest;
+        for (uint i = 0; i < 4; ++i)
+        {
+            if (pParty->pPlayers[i].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 ( !_stricmp(pCurrentMapName, "d29.blv") && _449B57_test_bit(pParty->_quest_bits, 98) )//Замок Хармондейл
-    uRestUI_FoodRequiredToRest = 0;
+    if (CheckHiredNPCSpeciality(Porter))
+        --uRestUI_FoodRequiredToRest;
+    if (CheckHiredNPCSpeciality(QuarterMaster))
+        uRestUI_FoodRequiredToRest -= 2;
+    if (CheckHiredNPCSpeciality(Gypsy))
+        --uRestUI_FoodRequiredToRest;
+    if (uRestUI_FoodRequiredToRest < 1)
+        uRestUI_FoodRequiredToRest = 1;
+    if (!_stricmp(pCurrentMapName, "d29.blv") && _449B57_test_bit(pParty->_quest_bits, 98))//Замок Хармондейл
+        uRestUI_FoodRequiredToRest = 0;
 
-  ++pIcons_LOD->uTexturePacksCount;
-  if ( !pIcons_LOD->uNumPrevLoadedFiles )
-    pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-
-  current_screen_type = SCREEN_REST;
+    ++pIcons_LOD->uTexturePacksCount;
+    if (!pIcons_LOD->uNumPrevLoadedFiles)
+        pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
+}
+//----- (0041F6C1) --------------------------------------------------------
+GUIWindow *RestUI_Load()
+{
   _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);
@@ -68,13 +69,17 @@
   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);
+
   OutdoorLocation::LoadActualSkyFrame();
-  pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Rest, 0, 0);
-  pButton_RestUI_Exit          = pGUIWindow_CurrentMenu->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest,       0,   0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0);
-  pButton_RestUI_Main          = pGUIWindow_CurrentMenu->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour,      0, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0);
-  pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0);
-  pButton_RestUI_Wait1Hour     = pGUIWindow_CurrentMenu->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour,      0, 'H', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0);
-  pButton_RestUI_Wait5Minutes  = pGUIWindow_CurrentMenu->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes,   0, 'M', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0);
+
+  auto wnd = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Rest, 0, 0);
+  pButton_RestUI_Exit =          wnd->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0);
+  pButton_RestUI_Main =          wnd->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0);
+  pButton_RestUI_WaitUntilDawn = wnd->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0);
+  pButton_RestUI_Wait1Hour =     wnd->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0);
+  pButton_RestUI_Wait5Minutes =  wnd->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0);
+
+  return wnd;
 }
 
 //----- (0041FA01) --------------------------------------------------------
@@ -161,7 +166,7 @@
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193));
     sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);//Год
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193));
-    if ( dword_506F14 )
+    if ( _506F14_resting_stage )
       Party::Sleep6Hours();
   }
   else