Mercurial > mm7
annotate GUI/UI/UIRest.cpp @ 2546:4087cbc62706
GameMenu logic moved to GUIWindow_GameMenu
the same for game menu options
author | a.parshin |
---|---|
date | Mon, 11 May 2015 17:45:02 +0200 |
parents | e06a3fe9ad6e |
children | 3121fb54a110 |
rev | line source |
---|---|
2501 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
5 #define _CRT_SECURE_NO_WARNINGS | |
2541 | 6 |
7 #include "Engine/Engine.h" | |
8 | |
2545 | 9 #include "Engine/Graphics/Outdoor.h" |
10 #include "Engine/LOD.h" | |
11 #include "Engine/Graphics/Viewport.h" | |
12 #include "Engine/Timer.h" | |
13 #include "Engine/texts.h" | |
14 #include "Engine/Party.h" | |
15 | |
16 #include "GUI/UI/UIRest.h" | |
17 #include "GUI/GUIFont.h" | |
18 | |
19 #include "Media/Audio/AudioPlayer.h" | |
20 | |
21 | |
2501 | 22 |
2545 | 23 void GUIWindow_RestWindow::Update() |
24 { | |
25 __debugbreak(); // doesnt seems to get here, check stack trace & conditions | |
26 GUIButton GUIButton2; // [sp+28h] [bp-E0h]@133 | |
27 memset(&GUIButton2, 0, sizeof(GUIButton2)); | |
28 GUIButton2.uZ = 197; | |
29 GUIButton2.uW = 197; | |
30 GUIButton2.uX = 27; | |
31 GUIButton2.uY = 161; | |
32 GUIButton2.uWidth = 171; | |
33 GUIButton2.uHeight = 37; | |
34 GUIButton2.pParent = pButton_RestUI_WaitUntilDawn->pParent; | |
35 pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0); | |
36 pRenderer->DrawTextureIndexed(uFrameX, uFrameY, *((Texture **)ptr_1C + 15)); | |
37 viewparams->bRedrawGameUI = 1; | |
38 GUIButton2.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0); // Rest & Heal 8 hrs / Отдых и лечение 8 часов | |
39 GUIButton2.pParent = 0; | |
40 Release(); | |
41 } | |
2501 | 42 |
43 | |
2543 | 44 void PrepareToLoadRestUI() |
2501 | 45 { |
2543 | 46 if (!_506F14_resting_stage) |
47 pAudioPlayer->StopChannels(-1, -1); | |
48 if (current_screen_type != SCREEN_GAME) | |
49 { | |
50 pGUIWindow_CurrentMenu->Release(); | |
51 current_screen_type = SCREEN_GAME; | |
52 viewparams->bRedrawGameUI = true; | |
53 } | |
54 pEventTimer->Pause(); | |
55 if (_506F14_resting_stage != 2) | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2543
diff
changeset
|
56 new OnButtonClick2(518, 450, 0, 0, (int)pBtn_Rest, 0); |
2543 | 57 _506F18_num_minutes_to_sleep = 0; |
58 _506F14_resting_stage = 0; | |
59 uRestUI_FoodRequiredToRest = 2; | |
60 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
61 uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
62 if (PartyHasDragon()) | |
2501 | 63 { |
2543 | 64 for (uint i = 0; i < 4; ++i) |
65 { | |
66 if (pParty->pPlayers[i].classType == PLAYER_CLASS_WARLOCK) | |
67 ++uRestUI_FoodRequiredToRest; | |
68 } | |
2501 | 69 } |
2543 | 70 if (CheckHiredNPCSpeciality(Porter)) |
71 --uRestUI_FoodRequiredToRest; | |
72 if (CheckHiredNPCSpeciality(QuarterMaster)) | |
73 uRestUI_FoodRequiredToRest -= 2; | |
74 if (CheckHiredNPCSpeciality(Gypsy)) | |
75 --uRestUI_FoodRequiredToRest; | |
76 if (uRestUI_FoodRequiredToRest < 1) | |
77 uRestUI_FoodRequiredToRest = 1; | |
78 if (!_stricmp(pCurrentMapName, "d29.blv") && _449B57_test_bit(pParty->_quest_bits, 98))//Замок Хармондейл | |
79 uRestUI_FoodRequiredToRest = 0; | |
2501 | 80 |
2543 | 81 ++pIcons_LOD->uTexturePacksCount; |
82 if (!pIcons_LOD->uNumPrevLoadedFiles) | |
83 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; | |
84 } | |
85 //----- (0041F6C1) -------------------------------------------------------- | |
86 GUIWindow *RestUI_Load() | |
87 { | |
2501 | 88 _507CD4_RestUI_hourglass_anim_controller = 0; |
89 uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE); | |
90 uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE); | |
91 uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE); | |
92 uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE); | |
93 uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE); | |
94 uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE); | |
2543 | 95 |
2501 | 96 OutdoorLocation::LoadActualSkyFrame(); |
2543 | 97 |
2545 | 98 auto wnd = new GUIWindow_Rest(0, 0, window->GetWidth(), window->GetHeight()); |
2543 | 99 pButton_RestUI_Exit = wnd->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0); |
100 pButton_RestUI_Main = wnd->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0); | |
101 pButton_RestUI_WaitUntilDawn = wnd->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0); | |
102 pButton_RestUI_Wait1Hour = wnd->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0); | |
103 pButton_RestUI_Wait5Minutes = wnd->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0); | |
104 | |
105 return wnd; | |
2501 | 106 } |
107 | |
2545 | 108 |
109 | |
2501 | 110 //----- (0041FA01) -------------------------------------------------------- |
2545 | 111 void GUIWindow_Rest::Update() |
2501 | 112 { |
113 int live_characters; // esi@1 | |
114 unsigned int v3; // eax@15 | |
115 GUIButton tmp_button; // [sp+8h] [bp-DCh]@19 | |
116 unsigned int am_pm_hours; // [sp+D8h] [bp-Ch]@9 | |
117 | |
118 live_characters = 0; | |
119 for( int i = 1; i < 5; ++i ) | |
120 if ( !pPlayers[i]->IsDead() && !pPlayers[i]->IsEradicated() && pPlayers[i]->sHealth > 0 ) | |
121 ++live_characters; | |
122 | |
123 if ( live_characters ) | |
124 { | |
125 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain)); | |
126 am_pm_hours = pParty->uCurrentHour; | |
127 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem; | |
128 if ( (signed int)pParty->uCurrentHour <= 12 ) | |
129 { | |
130 if ( !am_pm_hours ) | |
131 am_pm_hours = 12; | |
132 } | |
133 else | |
134 am_pm_hours -= 12; | |
135 pRenderer->DrawTextureIndexed(16, 26, pTexture_RestUI_CurrentSkyFrame); | |
136 if ( pTexture_RestUI_CurrentHourglassFrame ) | |
137 { | |
138 pTexture_RestUI_CurrentHourglassFrame->Release(); | |
139 pIcons_LOD->SyncLoadedFilesCount(); | |
140 } | |
141 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller; | |
142 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed; | |
143 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 ) | |
144 { | |
145 v3 = 0; | |
146 _507CD4_RestUI_hourglass_anim_controller = 0; | |
147 } | |
148 hourglass_icon_idx = (int)floorf(((double)v3 / 512.0 * 120.0) + 0.5f) % 256 + 1; | |
149 if (hourglass_icon_idx >= 120 ) | |
150 hourglass_icon_idx = 1; | |
151 | |
152 sprintf(pTmpBuf.data(), "hglas%03d", hourglass_icon_idx); | |
153 pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); | |
154 pRenderer->DrawTextureIndexed(267, 159, pTexture_RestUI_CurrentHourglassFrame); | |
155 memset(&tmp_button, 0, sizeof(GUIButton)); | |
156 tmp_button.uX = 24; | |
157 tmp_button.uY = 154; | |
158 tmp_button.uZ = 194; | |
159 tmp_button.uW = 190; | |
160 tmp_button.uWidth = 171; | |
161 tmp_button.uHeight = 37; | |
162 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent; | |
163 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Отдых и лечение 8 часов | |
164 tmp_button.pParent = 0; | |
165 | |
166 sprintf(pTmpBuf.data(), "\r408%d", uRestUI_FoodRequiredToRest); | |
167 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); | |
168 | |
169 pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать до рассвета | |
170 pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать 1 час | |
171 pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать 5 минут | |
172 pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Закончить отдыхать | |
173 memset(&tmp_button, 0, sizeof(GUIButton)); | |
174 tmp_button.uX = 45; | |
175 tmp_button.uY = 199; | |
176 | |
177 tmp_button.uZ = 229; | |
178 tmp_button.uW = 228; | |
179 | |
180 tmp_button.uWidth = 185; | |
181 tmp_button.uHeight = 30; | |
182 | |
183 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent; | |
184 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать без лечения | |
185 tmp_button.pParent = 0; | |
186 sprintf(pTmpBuf.data(), "%d:%02d %s", am_pm_hours, pParty->uCurrentMinute, aAMPMNames[(pParty->uCurrentHour >= 12 && pParty->uCurrentHour < 24)? 1:0]); | |
187 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); | |
188 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1);//День | |
189 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); | |
190 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1);//Месяц | |
191 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); | |
192 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);//Год | |
193 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); | |
2543 | 194 if ( _506F14_resting_stage ) |
2501 | 195 Party::Sleep6Hours(); |
196 } | |
197 else | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2543
diff
changeset
|
198 new OnCancel(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, (int)pButton_RestUI_Exit, pGlobalTXT_LocalizationStrings[81]); // "Exit Rest" |
2501 | 199 } |