comparison UI/UIRest.cpp @ 1711:69efd5d1ab5c

RestUI_Draw()
author Ritor1
date Tue, 24 Sep 2013 23:18:38 +0600
parents c4ab816fcc5e
children e013b92030e3
comparison
equal deleted inserted replaced
1699:33c7cc2d48d5 1711:69efd5d1ab5c
17 17
18 18
19 //----- (0041F6C1) -------------------------------------------------------- 19 //----- (0041F6C1) --------------------------------------------------------
20 void RestUI_Load() 20 void RestUI_Load()
21 { 21 {
22 Player *v0; // eax@10 22 if ( !dword_506F14 )
23 pAudioPlayer->StopChannels(-1, -1);
24 if ( pCurrentScreen != SCREEN_GAME)
25 {
26 pGUIWindow_CurrentMenu->Release();
27 pCurrentScreen = SCREEN_GAME;
28 viewparams->bRedrawGameUI = true;
29 }
30 pEventTimer->Pause();
31 if ( dword_506F14 != 2 )
32 GUIWindow::Create(518, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_Rest, 0);
33 _506F18_num_minutes_to_sleep = 0;
34 dword_506F14 = 0;
35 uRestUI_FoodRequiredToRest = 2;
36 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
37 uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
38 if ( PartyHasDragon() )
39 {
40 for ( uint i = 0; i < 4; ++i )
41 {
42 if (pParty->pPlayers[i].classType == PLAYER_CLASS_WARLOCK)
43 ++uRestUI_FoodRequiredToRest;
44 }
45 }
46 if ( CheckHiredNPCSpeciality(Porter) )
47 --uRestUI_FoodRequiredToRest;
48 if ( CheckHiredNPCSpeciality(QuarterMaster) )
49 uRestUI_FoodRequiredToRest -= 2;
50 if ( CheckHiredNPCSpeciality(Gypsy) )
51 --uRestUI_FoodRequiredToRest;
52 if ( uRestUI_FoodRequiredToRest < 1 )
53 uRestUI_FoodRequiredToRest = 1;
54 if ( !_stricmp(pCurrentMapName, "d29.blv") && _449B57_test_bit(pParty->_quest_bits, 98) )//Замок Хармондейл
55 uRestUI_FoodRequiredToRest = 0;
23 56
24 if ( !dword_506F14 ) 57 ++pIcons_LOD->uTexturePacksCount;
25 pAudioPlayer->StopChannels(-1, -1); 58 if ( !pIcons_LOD->uNumPrevLoadedFiles )
26 if ( pCurrentScreen != SCREEN_GAME) 59 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
27 {
28 pGUIWindow_CurrentMenu->Release();
29 pCurrentScreen = SCREEN_GAME;
30 viewparams->bRedrawGameUI = true;
31 }
32 pEventTimer->Pause();
33 if ( dword_506F14 != 2 )
34 GUIWindow::Create(518, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_Rest, 0);
35 _506F18_num_minutes_to_sleep = 0;
36 dword_506F14 = 0;
37 uRestUI_FoodRequiredToRest = 2;
38 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
39 uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
40 if ( PartyHasDragon() )
41 {
42 v0 = pParty->pPlayers;//[0].uClass;
43 while ( v0 <= &pParty->pPlayers[3] )
44 {
45 ++v0;
46 if ( v0 > &pParty->pPlayers[3] )
47 break;
48 }
49 if(v0->classType == PLAYER_CLASS_WARLOCK)
50 ++uRestUI_FoodRequiredToRest;
51 }
52 if ( CheckHiredNPCSpeciality(Porter) )
53 --uRestUI_FoodRequiredToRest;
54 if ( CheckHiredNPCSpeciality(QuarterMaster) )
55 uRestUI_FoodRequiredToRest -= 2;
56 if ( CheckHiredNPCSpeciality(Gypsy) )
57 --uRestUI_FoodRequiredToRest;
58 if ( uRestUI_FoodRequiredToRest < 1 )
59 uRestUI_FoodRequiredToRest = 1;
60 if ( !_stricmp(pCurrentMapName, "d29.blv") && _449B57_test_bit(pParty->_quest_bits, 98) )
61 uRestUI_FoodRequiredToRest = 0;
62 60
63 ++pIcons_LOD->uTexturePacksCount; 61 pCurrentScreen = SCREEN_REST;
64 if ( !pIcons_LOD->uNumPrevLoadedFiles ) 62 _507CD4_RestUI_hourglass_anim_controller = 0;
65 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; 63 uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE);
66 64 uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE);
67 pCurrentScreen = SCREEN_REST; 65 uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE);
68 _507CD4_RestUI_hourglass_anim_controller = 0; 66 uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE);
69 uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE); 67 uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE);
70 uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE); 68 uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE);
71 uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE); 69 LoadActualSkyFrame();
72 uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE); 70 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Rest, 0, 0);
73 uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE); 71 pButton_RestUI_Exit = pGUIWindow_CurrentMenu->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0);
74 uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE); 72 pButton_RestUI_Main = pGUIWindow_CurrentMenu->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0);
75 73 pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0);
76 LoadActualSkyFrame(); 74 pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0);
77 75 pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0);
78 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Rest, 0, 0);
79 pButton_RestUI_Exit = pGUIWindow_CurrentMenu->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0);
80 pButton_RestUI_Main = pGUIWindow_CurrentMenu->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0);
81 pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0);
82 pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0);
83 pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0);
84 } 76 }
85 77
86 //----- (0041FA01) -------------------------------------------------------- 78 //----- (0041FA01) --------------------------------------------------------
87 void RestUI_Draw() 79 void RestUI_Draw()
88 { 80 {
89 int live_characters; // esi@1 81 int live_characters; // esi@1
90 unsigned int v3; // eax@15 82 unsigned int v3; // eax@15
91 //char v4; // al@17 83 bool v5; // eax@21
92 bool v5; // eax@21 84 GUIButton tmp_button; // [sp+8h] [bp-DCh]@19
93 GUIButton tmp_button; // [sp+8h] [bp-DCh]@19 85 float v8; // [sp+CCh] [bp-18h]@17
94 //double v7; // [sp+C4h] [bp-20h]@17 86 //__int64 v9; // [sp+D0h] [bp-14h]@17
95 float v8; // [sp+CCh] [bp-18h]@17 87 unsigned int am_pm_hours; // [sp+D8h] [bp-Ch]@9
96 __int64 v9; // [sp+D0h] [bp-14h]@17 88 __int16 shadow_color; // [sp+DCh] [bp-8h]@1
97 unsigned int am_pm_hours; // [sp+D8h] [bp-Ch]@9 89 int text_color; // [sp+E0h] [bp-4h]@1
98 __int16 shadow_color; // [sp+DCh] [bp-8h]@1
99 int text_color; // [sp+E0h] [bp-4h]@1
100 90
101 live_characters = 0; 91 live_characters = 0;
102 text_color = TargetColor(10, 0, 0); 92 text_color = TargetColor(10, 0, 0);
103 shadow_color = TargetColor(230, 214, 193); 93 shadow_color = TargetColor(230, 214, 193);
104 for(int i=1; i<5; ++i) 94 for( int i = 1; i < 5; ++i )
105 if ( !pPlayers[i]->IsDead() && !pPlayers[i]->IsEradicated() && pPlayers[i]->sHealth > 0 ) 95 if ( !pPlayers[i]->IsDead() && !pPlayers[i]->IsEradicated() && pPlayers[i]->sHealth > 0 )
106 ++live_characters; 96 ++live_characters;
107 97
108 if ( live_characters ) 98 if ( live_characters )
109 { 99 {
110 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain)); 100 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain));
111 am_pm_hours = pParty->uCurrentHour; 101 am_pm_hours = pParty->uCurrentHour;
112 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem; 102 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
113 if ( (signed int)pParty->uCurrentHour <= 12 ) 103 if ( (signed int)pParty->uCurrentHour <= 12 )
114 { 104 {
115 if ( !am_pm_hours ) 105 if ( !am_pm_hours )
116 am_pm_hours = 12; 106 am_pm_hours = 12;
117 } 107 }
118 else 108 else
119 { 109 am_pm_hours -= 12;
120 am_pm_hours -= 12; 110 pRenderer->DrawTextureIndexed(16, 26, pTexture_RestUI_CurrentSkyFrame);
121 } 111 if ( pTexture_RestUI_CurrentHourglassFrame )
122 pRenderer->DrawTextureIndexed(16u, 26u, pTexture_RestUI_CurrentSkyFrame); 112 {
123 if ( pTexture_RestUI_CurrentHourglassFrame ) 113 pTexture_RestUI_CurrentHourglassFrame->Release();
124 { 114 pIcons_LOD->SyncLoadedFilesCount();
125 pTexture_RestUI_CurrentHourglassFrame->Release(); 115 }
126 pIcons_LOD->SyncLoadedFilesCount(); 116 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller;
127 } 117 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed;
128 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller; 118 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 )
129 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed; 119 {
130 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 ) 120 v3 = 0;
131 { 121 _507CD4_RestUI_hourglass_anim_controller = 0;
132 v3 = 0; 122 }
133 _507CD4_RestUI_hourglass_anim_controller = 0; 123 //v9 = v3;
134 } 124 v8 = (double)v3 / 512.0 * 120.0;
135 v9 = v3; 125 //v7 = v8 + 6.7553994e15;
136 v8 = (double)v3 / 512.0 * 120.0; 126 //HIDWORD(v9) = floorf(v8 + 0.5f);//LODWORD(v7);
137 //v7 = v8 + 6.7553994e15; 127 hourglass_icon_idx = (int)floorf(v8 + 0.5f) % 256 + 1;//LOBYTE(v7) + 1;
138 HIDWORD(v9) = floorf(v8 + 0.5f);//LODWORD(v7); 128 //hourglass_icon_idx = v4;
139 hourglass_icon_idx = (int)floorf(v8 + 0.5f) % 256 + 1;//LOBYTE(v7) + 1; 129 if (hourglass_icon_idx >= 120 )
140 //hourglass_icon_idx = v4; 130 hourglass_icon_idx = 1;
141 if (hourglass_icon_idx >= 120 )
142 hourglass_icon_idx = 1;
143 131
144 sprintf(pTmpBuf.data(), "hglas%03d", hourglass_icon_idx); 132 sprintf(pTmpBuf.data(), "hglas%03d", hourglass_icon_idx);
145 pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); 133 pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE);
146 pRenderer->DrawTextureIndexed(267, 159, pTexture_RestUI_CurrentHourglassFrame); 134 pRenderer->DrawTextureIndexed(267, 159, pTexture_RestUI_CurrentHourglassFrame);
147 memset(&tmp_button, 0, sizeof(GUIButton)); 135 memset(&tmp_button, 0, sizeof(GUIButton));
148 tmp_button.uX = 24; 136 tmp_button.uX = 24;
149 tmp_button.uY = 154; 137 tmp_button.uY = 154;
138 tmp_button.uZ = 194;
139 tmp_button.uW = 190;
140 tmp_button.uWidth = 171;
141 tmp_button.uHeight = 37;
142 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent;
143 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, text_color, shadow_color);//Отдых и лечение 8 часов
144 tmp_button.pParent = 0;
150 145
151 tmp_button.uZ = 194; 146 sprintf(pTmpBuf.data(), "\r408%d", uRestUI_FoodRequiredToRest);
152 tmp_button.uW = 190; 147 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, text_color, pTmpBuf.data(), 0, 0, shadow_color);
153 148
154 tmp_button.uWidth = 171; 149 pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, text_color, shadow_color);//Ждать до рассвета
155 tmp_button.uHeight = 37; 150 pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, text_color, shadow_color);//Ждать 1 час
151 pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, text_color, shadow_color);//Ждать 5 минут
152 pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, text_color, shadow_color);//Закончить отдыхать
153 memset(&tmp_button, 0, sizeof(GUIButton));
154 tmp_button.uX = 45;
155 tmp_button.uY = 199;
156 156
157 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent; 157 tmp_button.uZ = 229;
158 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, text_color, shadow_color); 158 tmp_button.uW = 228;
159 tmp_button.pParent = 0;
160 sprintf(pTmpBuf.data(), "\r408%d", uRestUI_FoodRequiredToRest);
161 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, text_color, pTmpBuf.data(), 0, 0, shadow_color);
162 pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, text_color, shadow_color);
163 pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, text_color, shadow_color);
164 pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, text_color, shadow_color);
165 pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, text_color, shadow_color);
166 memset(&tmp_button, 0, sizeof(GUIButton));
167 tmp_button.uX = 45;
168 tmp_button.uY = 199;
169 159
170 tmp_button.uZ = 229; 160 tmp_button.uWidth = 185;
171 tmp_button.uW = 228; 161 tmp_button.uHeight = 30;
172 162
173 tmp_button.uWidth = 185; 163 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent;
174 tmp_button.uHeight = 30; 164 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, text_color, shadow_color);//Ждать без лечения
175 165 tmp_button.pParent = 0;
176 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent; 166 v5 = (pParty->uCurrentHour >= 12 && pParty->uCurrentHour < 24)? 1:0;
177 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, text_color, shadow_color); 167 sprintf(pTmpBuf.data(), "%d:%02d %s", am_pm_hours, pParty->uCurrentMinute, aAMPMNames[v5]);
178 tmp_button.pParent = 0; 168 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, text_color, pTmpBuf.data(), 0, 0, shadow_color);
179 v5 = (pParty->uCurrentHour >= 12 && pParty->uCurrentHour < 24)? 1:0; 169 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1);//День
180 sprintf(pTmpBuf.data(), "%d:%02d %s", am_pm_hours, pParty->uCurrentMinute, aAMPMNames[v5]); 170 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, text_color, pTmpBuf.data(), 0, 0, shadow_color);
181 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, text_color, pTmpBuf.data(), 0, 0, shadow_color); 171 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1);//Месяц
182 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1); 172 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, text_color, pTmpBuf.data(), 0, 0, shadow_color);
183 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, text_color, pTmpBuf.data(), 0, 0, shadow_color); 173 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);//Год
184 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1); 174 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, text_color, pTmpBuf.data(), 0, 0, shadow_color);
185 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, text_color, pTmpBuf.data(), 0, 0, shadow_color); 175 if ( dword_506F14 )
186 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear); 176 Sleep6Hours();
187 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, text_color, pTmpBuf.data(), 0, 0, shadow_color); 177 }
188 if ( dword_506F14 ) 178 else
189 Sleep6Hours(); 179 GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn,
190 }
191 else
192 GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn,
193 (int)pButton_RestUI_Exit, pGlobalTXT_LocalizationStrings[81]); // "Exit Rest" 180 (int)pButton_RestUI_Exit, pGlobalTXT_LocalizationStrings[81]); // "Exit Rest"
194 } 181 }