Mercurial > mm7
comparison UIRest.cpp @ 1055:010a844ef4a0
Слияние
author | Ritor1 |
---|---|
date | Wed, 22 May 2013 22:23:04 +0600 |
parents | 3a5c8df8381d |
children | 5d5c78088274 |
comparison
equal
deleted
inserted
replaced
1054:5520fdca7a74 | 1055:010a844ef4a0 |
---|---|
2 | 2 |
3 #include "MM7.h" | 3 #include "MM7.h" |
4 | 4 |
5 #include "MapInfo.h" | 5 #include "MapInfo.h" |
6 #include "Game.h" | 6 #include "Game.h" |
7 #include "Player.h" | |
7 #include "GUIWindow.h" | 8 #include "GUIWindow.h" |
8 #include "GUIFont.h" | 9 #include "GUIFont.h" |
9 #include "GUIProgressBar.h" | 10 #include "GUIProgressBar.h" |
10 #include "Party.h" | 11 #include "Party.h" |
11 #include "AudioPlayer.h" | 12 #include "AudioPlayer.h" |
44 #include "mm7_data.h" | 45 #include "mm7_data.h" |
45 | 46 |
46 | 47 |
47 | 48 |
48 //----- (0041F6C1) -------------------------------------------------------- | 49 //----- (0041F6C1) -------------------------------------------------------- |
49 void __cdecl RestUI_Initialize() | 50 void RestUI_Load() |
50 { | 51 { |
51 Player *v0; // eax@10 | 52 Player *v0; // eax@10 |
52 | 53 |
53 if ( !dword_506F14 ) | 54 if ( !dword_506F14 ) |
54 pAudioPlayer->StopChannels(-1, -1); | 55 pAudioPlayer->StopChannels(-1, -1); |
55 if ( pCurrentScreen ) | 56 if ( pCurrentScreen != SCREEN_GAME) |
56 { | 57 { |
57 pGUIWindow_CurrentMenu->Release(); | 58 pGUIWindow_CurrentMenu->Release(); |
58 pCurrentScreen = SCREEN_GAME; | 59 pCurrentScreen = SCREEN_GAME; |
59 viewparams->bRedrawGameUI = 1; | 60 viewparams->bRedrawGameUI = true; |
60 } | 61 } |
61 pEventTimer->Pause(); | 62 pEventTimer->Pause(); |
62 if ( dword_506F14 != 2 ) | 63 if ( dword_506F14 != 2 ) |
63 GUIWindow::Create(518, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_Rest, 0); | 64 GUIWindow::Create(518, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_Rest, 0); |
64 _506F18_num_hours_to_sleep = 0; | 65 _506F18_num_hours_to_sleep = 0; |
65 dword_506F14 = 0; | 66 dword_506F14 = 0; |
84 uRestUI_FoodRequiredToRest -= 2; | 85 uRestUI_FoodRequiredToRest -= 2; |
85 if ( CheckHiredNPCSpeciality(Gypsy) ) | 86 if ( CheckHiredNPCSpeciality(Gypsy) ) |
86 --uRestUI_FoodRequiredToRest; | 87 --uRestUI_FoodRequiredToRest; |
87 if ( uRestUI_FoodRequiredToRest < 1 ) | 88 if ( uRestUI_FoodRequiredToRest < 1 ) |
88 uRestUI_FoodRequiredToRest = 1; | 89 uRestUI_FoodRequiredToRest = 1; |
89 if ( !_strcmpi(pCurrentMapName, "d29.blv") && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 98) ) | 90 if ( !_strcmpi(pCurrentMapName, "d29.blv") && _449B57_test_bit(pParty->_quest_bits, 98) ) |
90 uRestUI_FoodRequiredToRest = 0; | 91 uRestUI_FoodRequiredToRest = 0; |
92 | |
91 ++pIcons_LOD->uTexturePacksCount; | 93 ++pIcons_LOD->uTexturePacksCount; |
92 if ( !pIcons_LOD->uNumPrevLoadedFiles ) | 94 if ( !pIcons_LOD->uNumPrevLoadedFiles ) |
93 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; | 95 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; |
96 | |
94 pCurrentScreen = SCREEN_REST; | 97 pCurrentScreen = SCREEN_REST; |
95 _507CD4_RestUI_hourglass_anim_controller = 0; | 98 _507CD4_RestUI_hourglass_anim_controller = 0; |
96 uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE); | 99 uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE); |
97 uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE); | 100 uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE); |
98 uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE); | 101 uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE); |
101 uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE); | 104 uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE); |
102 | 105 |
103 LoadActualSkyFrame(); | 106 LoadActualSkyFrame(); |
104 | 107 |
105 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Rest, 0, 0); | 108 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Rest, 0, 0); |
106 pButton_RestUI_Exit = pGUIWindow_CurrentMenu->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0); | 109 pButton_RestUI_Exit = pGUIWindow_CurrentMenu->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0); |
107 pButton_RestUI_Main = pGUIWindow_CurrentMenu->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 0x52u, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0); | 110 pButton_RestUI_Main = pGUIWindow_CurrentMenu->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0); |
108 pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 0x44u, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0); | 111 pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0); |
109 pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 0x48u, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0); | 112 pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0); |
110 pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 0x4Du, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0); | 113 pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0); |
111 } | 114 } |
112 | 115 |
113 //----- (0041FA01) -------------------------------------------------------- | 116 //----- (0041FA01) -------------------------------------------------------- |
114 void __cdecl RestUI_Draw() | 117 void RestUI_Draw() |
115 { | 118 { |
116 int v0; // esi@1 | 119 int live_characters; // esi@1 |
117 Player **ppPlayers; // ecx@1 | |
118 Player *pPlayer; // eax@2 | |
119 unsigned int v3; // eax@15 | 120 unsigned int v3; // eax@15 |
120 //char v4; // al@17 | 121 //char v4; // al@17 |
121 bool v5; // eax@21 | 122 bool v5; // eax@21 |
122 GUIButton Dst; // [sp+8h] [bp-DCh]@19 | 123 GUIButton tmp_button; // [sp+8h] [bp-DCh]@19 |
123 //double v7; // [sp+C4h] [bp-20h]@17 | 124 //double v7; // [sp+C4h] [bp-20h]@17 |
124 float v8; // [sp+CCh] [bp-18h]@17 | 125 float v8; // [sp+CCh] [bp-18h]@17 |
125 __int64 v9; // [sp+D0h] [bp-14h]@17 | 126 __int64 v9; // [sp+D0h] [bp-14h]@17 |
126 unsigned int v10; // [sp+D8h] [bp-Ch]@9 | 127 unsigned int am_pm_hours; // [sp+D8h] [bp-Ch]@9 |
127 __int16 a9[2]; // [sp+DCh] [bp-8h]@1 | 128 __int16 shadow_color; // [sp+DCh] [bp-8h]@1 |
128 int a5; // [sp+E0h] [bp-4h]@1 | 129 int text_color; // [sp+E0h] [bp-4h]@1 |
129 | 130 |
130 v0 = 0; | 131 live_characters = 0; |
131 a5 = TargetColor(0xAu, 0, 0); | 132 text_color = TargetColor(10, 0, 0); |
132 *(int *)a9 = TargetColor(0xE6u, 0xD6u, 0xC1u); | 133 shadow_color = TargetColor(230, 214, 193); |
133 ppPlayers = &pPlayers[1]; | 134 for(int i=1; i<5; ++i) |
134 do | 135 if ( !pPlayers[i]->pConditions[Player::Condition_Dead] && !pPlayers[i]->pConditions[Player::Condition_Eradicated] && pPlayers[i]->sHealth > 0 ) |
136 ++live_characters; | |
137 | |
138 if ( live_characters ) | |
135 { | 139 { |
136 pPlayer = *ppPlayers; | 140 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain)); |
137 if ( !(*ppPlayers)->pConditions[14] && !pPlayer->pConditions[16] && pPlayer->sHealth > 0 ) | 141 am_pm_hours = pParty->uCurrentHour; |
138 ++v0; | 142 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem; |
139 ++ppPlayers; | 143 if ( (signed int)pParty->uCurrentHour <= 12 ) |
144 { | |
145 if ( !am_pm_hours ) | |
146 am_pm_hours = 12; | |
147 } | |
148 else | |
149 { | |
150 am_pm_hours -= 12; | |
151 } | |
152 pRenderer->DrawTextureIndexed(16u, 26u, pTexture_RestUI_CurrentSkyFrame); | |
153 if ( pTexture_RestUI_CurrentHourglassFrame ) | |
154 { | |
155 pTexture_RestUI_CurrentHourglassFrame->Release(); | |
156 pIcons_LOD->SyncLoadedFilesCount(); | |
157 } | |
158 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller; | |
159 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed; | |
160 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 ) | |
161 { | |
162 v3 = 0; | |
163 _507CD4_RestUI_hourglass_anim_controller = 0; | |
164 } | |
165 v9 = v3; | |
166 v8 = (double)v3 / 512.0 * 120.0; | |
167 //v7 = v8 + 6.7553994e15; | |
168 HIDWORD(v9) = floorf(v8 + 0.5f);//LODWORD(v7); | |
169 hourglass_icon_idx = (int)floorf(v8 + 0.5f) % 256 + 1;//LOBYTE(v7) + 1; | |
170 //hourglass_icon_idx = v4; | |
171 if (hourglass_icon_idx >= 120 ) | |
172 hourglass_icon_idx = 1; | |
173 | |
174 sprintf(pTmpBuf, "hglas%03d", hourglass_icon_idx); | |
175 pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE); | |
176 pRenderer->DrawTextureIndexed(267, 159, pTexture_RestUI_CurrentHourglassFrame); | |
177 memset(&tmp_button, 0, sizeof(GUIButton)); | |
178 tmp_button.uX = 24; | |
179 tmp_button.uY = 154; | |
180 | |
181 tmp_button.uZ = 194; | |
182 tmp_button.uW = 190; | |
183 | |
184 tmp_button.uWidth = 171; | |
185 tmp_button.uHeight = 37; | |
186 | |
187 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent; | |
188 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, text_color, shadow_color); | |
189 tmp_button.pParent = 0; | |
190 sprintf(pTmpBuf, "\r408%d", uRestUI_FoodRequiredToRest); | |
191 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, text_color, pTmpBuf, 0, 0, shadow_color); | |
192 pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, text_color, shadow_color); | |
193 pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, text_color, shadow_color); | |
194 pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, text_color, shadow_color); | |
195 pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, text_color, shadow_color); | |
196 memset(&tmp_button, 0, sizeof(GUIButton)); | |
197 tmp_button.uX = 45; | |
198 tmp_button.uY = 199; | |
199 | |
200 tmp_button.uZ = 229; | |
201 tmp_button.uW = 228; | |
202 | |
203 tmp_button.uWidth = 185; | |
204 tmp_button.uHeight = 30; | |
205 | |
206 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent; | |
207 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, text_color, shadow_color); | |
208 tmp_button.pParent = 0; | |
209 v5 = (pParty->uCurrentHour >= 12 && pParty->uCurrentHour < 24)? 1:0; | |
210 sprintf(pTmpBuf, "%d:%02d %s", am_pm_hours, pParty->uCurrentMinute, aAMPMNames[v5]); | |
211 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, text_color, pTmpBuf, 0, 0, shadow_color); | |
212 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1); | |
213 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, text_color, pTmpBuf, 0, 0, shadow_color); | |
214 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1); | |
215 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, text_color, pTmpBuf, 0, 0, shadow_color); | |
216 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear); | |
217 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, text_color, pTmpBuf, 0, 0, shadow_color); | |
218 if ( dword_506F14 ) | |
219 Sleep6Hours(); | |
140 } | 220 } |
141 while ( (signed int)ppPlayers <= (signed int)&pPlayers[4] ); | 221 else |
142 if ( v0 ) | 222 GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn, (int)pButton_RestUI_Exit, (int)pGlobalTXT_LocalizationStrings[81]); // "Exit Rest" |
143 { | |
144 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain)); | |
145 v10 = pParty->uCurrentHour; | |
146 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem; | |
147 if ( (signed int)pParty->uCurrentHour <= 12 ) | |
148 { | |
149 if ( !v10 ) | |
150 v10 = 12; | |
151 } | |
152 else | |
153 { | |
154 v10 -= 12; | |
155 } | |
156 pRenderer->DrawTextureIndexed(16u, 26u, pTexture_RestUI_CurrentSkyFrame); | |
157 if ( pTexture_RestUI_CurrentHourglassFrame ) | |
158 { | |
159 pTexture_RestUI_CurrentHourglassFrame->Release(); | |
160 pIcons_LOD->_40F9C5(); | |
161 } | |
162 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller; | |
163 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed; | |
164 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 ) | |
165 { | |
166 v3 = 0; | |
167 _507CD4_RestUI_hourglass_anim_controller = 0; | |
168 } | |
169 v9 = v3; | |
170 v8 = (double)v3 / 512.0 * 120.0; | |
171 //v7 = v8 + 6.7553994e15; | |
172 HIDWORD(v9) = floorf(v8 + 0.5f);//LODWORD(v7); | |
173 hourglass_icon_idx = (int)floorf(v8 + 0.5f) % 256 + 1;//LOBYTE(v7) + 1; | |
174 //hourglass_icon_idx = v4; | |
175 if (hourglass_icon_idx >= 120 ) | |
176 { | |
177 //v4 = 1; | |
178 hourglass_icon_idx = 1; | |
179 } | |
180 sprintf(pTmpBuf, "hglas%03d", hourglass_icon_idx); | |
181 pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE); | |
182 pRenderer->DrawTextureIndexed(0x10Bu, 0x9Fu, pTexture_RestUI_CurrentHourglassFrame); | |
183 memset(&Dst, 0, 0xBCu); | |
184 Dst.uX = 24; | |
185 Dst.uY = 154; | |
186 Dst.uWidth = 171; | |
187 Dst.uHeight = 37; | |
188 Dst.uZ = 194; | |
189 Dst.uW = 190; | |
190 Dst.pParent = pButton_RestUI_WaitUntilDawn->pParent; | |
191 Dst.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, a5, *(int **)a9); | |
192 Dst.pParent = 0; | |
193 sprintf(pTmpBuf, "\r408%d", uRestUI_FoodRequiredToRest); | |
194 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, a5, pTmpBuf, 0, 0, *(unsigned int *)a9); | |
195 pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, a5, *(int **)a9); | |
196 pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, a5, *(int **)a9); | |
197 pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, a5, *(int **)a9); | |
198 pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, a5, *(int **)a9); | |
199 memset(&Dst, 0, 0xBCu); | |
200 Dst.uX = 45; | |
201 Dst.uY = 199; | |
202 Dst.uWidth = 185; | |
203 Dst.uHeight = 30; | |
204 Dst.uZ = 229; | |
205 Dst.uW = 228; | |
206 Dst.pParent = pButton_RestUI_WaitUntilDawn->pParent; | |
207 Dst.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, a5, *(int **)a9); | |
208 Dst.pParent = 0; | |
209 v5 = pParty->uCurrentHour >= 0xC && pParty->uCurrentHour < 0x18; | |
210 sprintf(pTmpBuf, "%d:%02d %s", v10, pParty->uCurrentMinute, aAMPMNames[v5]); | |
211 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, a5, pTmpBuf, 0, 0, *(unsigned int *)a9); | |
212 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1); | |
213 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, a5, pTmpBuf, 0, 0, *(unsigned int *)a9); | |
214 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1); | |
215 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, a5, pTmpBuf, 0, 0, *(unsigned int *)a9); | |
216 sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear); | |
217 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, a5, pTmpBuf, 0, 0, *(unsigned int *)a9); | |
218 if ( dword_506F14 ) | |
219 Sleep6Hours(); | |
220 } | |
221 else | |
222 { | |
223 GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn, | |
224 (int)pButton_RestUI_Exit, (int)pGlobalTXT_LocalizationStrings[81]); | |
225 } | |
226 } | 223 } |