Mercurial > mm7
annotate UIRest.cpp @ 1278:ce8ea73e7678
changed Player::_4B6FF9 to Player::IsPlayerHealableByTemple
author | Grumpy7 |
---|---|
date | Sat, 15 Jun 2013 07:52:05 +0200 |
parents | 2929c4406d2c |
children |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
4 |
706 | 5 #include <assert.h> |
6 | |
7 | |
8 #include "GUIWindow.h" | |
9 #include "GUIFont.h" | |
10 #include "Party.h" | |
11 #include "AudioPlayer.h" | |
12 #include "Outdoor.h" | |
13 #include "LOD.h" | |
14 #include "Viewport.h" | |
15 #include "Time.h" | |
16 #include "texts.h" | |
17 | |
18 #include "mm7_data.h" | |
19 | |
20 | |
21 | |
22 //----- (0041F6C1) -------------------------------------------------------- | |
1033 | 23 void RestUI_Load() |
938 | 24 { |
706 | 25 Player *v0; // eax@10 |
26 | |
27 if ( !dword_506F14 ) | |
28 pAudioPlayer->StopChannels(-1, -1); | |
1033 | 29 if ( pCurrentScreen != SCREEN_GAME) |
30 { | |
706 | 31 pGUIWindow_CurrentMenu->Release(); |
32 pCurrentScreen = SCREEN_GAME; | |
1033 | 33 viewparams->bRedrawGameUI = true; |
34 } | |
706 | 35 pEventTimer->Pause(); |
36 if ( dword_506F14 != 2 ) | |
962 | 37 GUIWindow::Create(518, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_Rest, 0); |
706 | 38 _506F18_num_hours_to_sleep = 0; |
39 dword_506F14 = 0; | |
40 uRestUI_FoodRequiredToRest = 2; | |
41 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
962 | 42 uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); |
706 | 43 if ( PartyHasDragon() ) |
44 { | |
45 v0 = pParty->pPlayers;//[0].uClass; | |
46 while ( v0 <= &pParty->pPlayers[3] ) | |
47 { | |
48 ++v0; | |
49 if ( v0 > &pParty->pPlayers[3] ) | |
50 break; | |
51 } | |
52 if(v0->classType == PLAYER_CLASS_WARLOCK) | |
53 ++uRestUI_FoodRequiredToRest; | |
54 } | |
55 if ( CheckHiredNPCSpeciality(Porter) ) | |
56 --uRestUI_FoodRequiredToRest; | |
57 if ( CheckHiredNPCSpeciality(QuarterMaster) ) | |
58 uRestUI_FoodRequiredToRest -= 2; | |
59 if ( CheckHiredNPCSpeciality(Gypsy) ) | |
60 --uRestUI_FoodRequiredToRest; | |
61 if ( uRestUI_FoodRequiredToRest < 1 ) | |
62 uRestUI_FoodRequiredToRest = 1; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
63 if ( !_stricmp(pCurrentMapName.data(), "d29.blv") && _449B57_test_bit(pParty->_quest_bits, 98) ) |
706 | 64 uRestUI_FoodRequiredToRest = 0; |
1033 | 65 |
706 | 66 ++pIcons_LOD->uTexturePacksCount; |
67 if ( !pIcons_LOD->uNumPrevLoadedFiles ) | |
68 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; | |
1033 | 69 |
706 | 70 pCurrentScreen = SCREEN_REST; |
71 _507CD4_RestUI_hourglass_anim_controller = 0; | |
72 uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE); | |
73 uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE); | |
74 uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE); | |
75 uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE); | |
76 uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE); | |
77 uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE); | |
948 | 78 |
706 | 79 LoadActualSkyFrame(); |
948 | 80 |
81 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Rest, 0, 0); | |
1033 | 82 pButton_RestUI_Exit = pGUIWindow_CurrentMenu->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0); |
83 pButton_RestUI_Main = pGUIWindow_CurrentMenu->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0); | |
84 pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0); | |
85 pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0); | |
86 pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0); | |
948 | 87 } |
706 | 88 |
89 //----- (0041FA01) -------------------------------------------------------- | |
1033 | 90 void RestUI_Draw() |
91 { | |
1006 | 92 int live_characters; // esi@1 |
706 | 93 unsigned int v3; // eax@15 |
94 //char v4; // al@17 | |
95 bool v5; // eax@21 | |
1006 | 96 GUIButton tmp_button; // [sp+8h] [bp-DCh]@19 |
706 | 97 //double v7; // [sp+C4h] [bp-20h]@17 |
98 float v8; // [sp+CCh] [bp-18h]@17 | |
99 __int64 v9; // [sp+D0h] [bp-14h]@17 | |
1006 | 100 unsigned int am_pm_hours; // [sp+D8h] [bp-Ch]@9 |
101 __int16 shadow_color; // [sp+DCh] [bp-8h]@1 | |
102 int text_color; // [sp+E0h] [bp-4h]@1 | |
706 | 103 |
1006 | 104 live_characters = 0; |
105 text_color = TargetColor(10, 0, 0); | |
106 shadow_color = TargetColor(230, 214, 193); | |
107 for(int i=1; i<5; ++i) | |
108 if ( !pPlayers[i]->pConditions[Player::Condition_Dead] && !pPlayers[i]->pConditions[Player::Condition_Eradicated] && pPlayers[i]->sHealth > 0 ) | |
109 ++live_characters; | |
110 | |
111 if ( live_characters ) | |
706 | 112 { |
1006 | 113 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain)); |
114 am_pm_hours = pParty->uCurrentHour; | |
115 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem; | |
116 if ( (signed int)pParty->uCurrentHour <= 12 ) | |
706 | 117 { |
1006 | 118 if ( !am_pm_hours ) |
119 am_pm_hours = 12; | |
706 | 120 } |
121 else | |
1006 | 122 { |
123 am_pm_hours -= 12; | |
124 } | |
125 pRenderer->DrawTextureIndexed(16u, 26u, pTexture_RestUI_CurrentSkyFrame); | |
126 if ( pTexture_RestUI_CurrentHourglassFrame ) | |
127 { | |
128 pTexture_RestUI_CurrentHourglassFrame->Release(); | |
129 pIcons_LOD->SyncLoadedFilesCount(); | |
130 } | |
131 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller; | |
132 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed; | |
133 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 ) | |
134 { | |
135 v3 = 0; | |
136 _507CD4_RestUI_hourglass_anim_controller = 0; | |
137 } | |
138 v9 = v3; | |
139 v8 = (double)v3 / 512.0 * 120.0; | |
140 //v7 = v8 + 6.7553994e15; | |
141 HIDWORD(v9) = floorf(v8 + 0.5f);//LODWORD(v7); | |
142 hourglass_icon_idx = (int)floorf(v8 + 0.5f) % 256 + 1;//LOBYTE(v7) + 1; | |
143 //hourglass_icon_idx = v4; | |
144 if (hourglass_icon_idx >= 120 ) | |
145 hourglass_icon_idx = 1; | |
146 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
147 sprintf(pTmpBuf.data(), "hglas%03d", hourglass_icon_idx); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
148 pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); |
1006 | 149 pRenderer->DrawTextureIndexed(267, 159, pTexture_RestUI_CurrentHourglassFrame); |
150 memset(&tmp_button, 0, sizeof(GUIButton)); | |
151 tmp_button.uX = 24; | |
152 tmp_button.uY = 154; | |
153 | |
154 tmp_button.uZ = 194; | |
155 tmp_button.uW = 190; | |
156 | |
157 tmp_button.uWidth = 171; | |
158 tmp_button.uHeight = 37; | |
159 | |
160 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent; | |
161 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, text_color, shadow_color); | |
162 tmp_button.pParent = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
163 sprintf(pTmpBuf.data(), "\r408%d", uRestUI_FoodRequiredToRest); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
164 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, text_color, pTmpBuf.data(), 0, 0, shadow_color); |
1006 | 165 pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, text_color, shadow_color); |
166 pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, text_color, shadow_color); | |
167 pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, text_color, shadow_color); | |
168 pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, text_color, shadow_color); | |
169 memset(&tmp_button, 0, sizeof(GUIButton)); | |
170 tmp_button.uX = 45; | |
171 tmp_button.uY = 199; | |
172 | |
173 tmp_button.uZ = 229; | |
174 tmp_button.uW = 228; | |
175 | |
176 tmp_button.uWidth = 185; | |
177 tmp_button.uHeight = 30; | |
178 | |
179 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent; | |
180 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, text_color, shadow_color); | |
181 tmp_button.pParent = 0; | |
182 v5 = (pParty->uCurrentHour >= 12 && pParty->uCurrentHour < 24)? 1:0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
183 sprintf(pTmpBuf.data(), "%d:%02d %s", am_pm_hours, pParty->uCurrentMinute, aAMPMNames[v5]); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
184 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, text_color, pTmpBuf.data(), 0, 0, shadow_color); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
185 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
186 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, text_color, pTmpBuf.data(), 0, 0, shadow_color); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
187 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
188 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, text_color, pTmpBuf.data(), 0, 0, shadow_color); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
189 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
190 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, text_color, pTmpBuf.data(), 0, 0, shadow_color); |
1006 | 191 if ( dword_506F14 ) |
192 Sleep6Hours(); | |
193 } | |
194 else | |
1268 | 195 GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn, |
196 (int)pButton_RestUI_Exit, pGlobalTXT_LocalizationStrings[81]); // "Exit Rest" | |
706 | 197 } |