Mercurial > mm7
annotate UI/UIRest.cpp @ 2237:d903816e972e
_4B254D_SkillMasteryTeacher adding case, removing nested ifs, adding some comments
author | Grumpy7 |
---|---|
date | Sun, 23 Feb 2014 14:12:07 +0100 |
parents | e9625ad08541 |
children | aff7a7b072b7 |
rev | line source |
---|---|
1299 | 1 #include "..\GUIWindow.h" |
2 #include "..\GUIFont.h" | |
3 #include "..\Party.h" | |
4 #include "..\AudioPlayer.h" | |
5 #include "..\Outdoor.h" | |
6 #include "..\LOD.h" | |
7 #include "..\Viewport.h" | |
2044 | 8 #include "..\Timer.h" |
1299 | 9 #include "..\texts.h" |
1298 | 10 |
1299 | 11 #include "..\mm7_data.h" |
1298 | 12 |
13 | |
14 | |
15 //----- (0041F6C1) -------------------------------------------------------- | |
16 void RestUI_Load() | |
17 { | |
1711 | 18 if ( !dword_506F14 ) |
19 pAudioPlayer->StopChannels(-1, -1); | |
20 if ( pCurrentScreen != SCREEN_GAME) | |
21 { | |
22 pGUIWindow_CurrentMenu->Release(); | |
23 pCurrentScreen = SCREEN_GAME; | |
24 viewparams->bRedrawGameUI = true; | |
25 } | |
26 pEventTimer->Pause(); | |
27 if ( dword_506F14 != 2 ) | |
28 GUIWindow::Create(518, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_Rest, 0); | |
29 _506F18_num_minutes_to_sleep = 0; | |
30 dword_506F14 = 0; | |
31 uRestUI_FoodRequiredToRest = 2; | |
32 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
33 uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
34 if ( PartyHasDragon() ) | |
35 { | |
36 for ( uint i = 0; i < 4; ++i ) | |
1298 | 37 { |
1711 | 38 if (pParty->pPlayers[i].classType == PLAYER_CLASS_WARLOCK) |
39 ++uRestUI_FoodRequiredToRest; | |
1298 | 40 } |
1711 | 41 } |
42 if ( CheckHiredNPCSpeciality(Porter) ) | |
43 --uRestUI_FoodRequiredToRest; | |
44 if ( CheckHiredNPCSpeciality(QuarterMaster) ) | |
45 uRestUI_FoodRequiredToRest -= 2; | |
46 if ( CheckHiredNPCSpeciality(Gypsy) ) | |
47 --uRestUI_FoodRequiredToRest; | |
48 if ( uRestUI_FoodRequiredToRest < 1 ) | |
49 uRestUI_FoodRequiredToRest = 1; | |
50 if ( !_stricmp(pCurrentMapName, "d29.blv") && _449B57_test_bit(pParty->_quest_bits, 98) )//Замок Хармондейл | |
51 uRestUI_FoodRequiredToRest = 0; | |
52 | |
53 ++pIcons_LOD->uTexturePacksCount; | |
54 if ( !pIcons_LOD->uNumPrevLoadedFiles ) | |
55 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; | |
1298 | 56 |
1711 | 57 pCurrentScreen = SCREEN_REST; |
58 _507CD4_RestUI_hourglass_anim_controller = 0; | |
59 uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE); | |
60 uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE); | |
61 uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE); | |
62 uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE); | |
63 uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE); | |
64 uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE); | |
65 LoadActualSkyFrame(); | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2153
diff
changeset
|
66 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Rest, 0, 0); |
1711 | 67 pButton_RestUI_Exit = pGUIWindow_CurrentMenu->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0); |
68 pButton_RestUI_Main = pGUIWindow_CurrentMenu->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0); | |
69 pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0); | |
70 pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0); | |
71 pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0); | |
1298 | 72 } |
73 | |
74 //----- (0041FA01) -------------------------------------------------------- | |
75 void RestUI_Draw() | |
76 { | |
1711 | 77 int live_characters; // esi@1 |
78 unsigned int v3; // eax@15 | |
79 GUIButton tmp_button; // [sp+8h] [bp-DCh]@19 | |
80 unsigned int am_pm_hours; // [sp+D8h] [bp-Ch]@9 | |
81 | |
82 live_characters = 0; | |
83 for( int i = 1; i < 5; ++i ) | |
84 if ( !pPlayers[i]->IsDead() && !pPlayers[i]->IsEradicated() && pPlayers[i]->sHealth > 0 ) | |
85 ++live_characters; | |
1298 | 86 |
1711 | 87 if ( live_characters ) |
88 { | |
89 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain)); | |
90 am_pm_hours = pParty->uCurrentHour; | |
91 dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem; | |
92 if ( (signed int)pParty->uCurrentHour <= 12 ) | |
93 { | |
94 if ( !am_pm_hours ) | |
95 am_pm_hours = 12; | |
96 } | |
97 else | |
98 am_pm_hours -= 12; | |
99 pRenderer->DrawTextureIndexed(16, 26, pTexture_RestUI_CurrentSkyFrame); | |
100 if ( pTexture_RestUI_CurrentHourglassFrame ) | |
101 { | |
102 pTexture_RestUI_CurrentHourglassFrame->Release(); | |
103 pIcons_LOD->SyncLoadedFilesCount(); | |
104 } | |
105 v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller; | |
106 _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed; | |
107 if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 ) | |
108 { | |
109 v3 = 0; | |
110 _507CD4_RestUI_hourglass_anim_controller = 0; | |
111 } | |
1713 | 112 hourglass_icon_idx = (int)floorf(((double)v3 / 512.0 * 120.0) + 0.5f) % 256 + 1; |
1711 | 113 if (hourglass_icon_idx >= 120 ) |
114 hourglass_icon_idx = 1; | |
1298 | 115 |
1711 | 116 sprintf(pTmpBuf.data(), "hglas%03d", hourglass_icon_idx); |
117 pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); | |
118 pRenderer->DrawTextureIndexed(267, 159, pTexture_RestUI_CurrentHourglassFrame); | |
119 memset(&tmp_button, 0, sizeof(GUIButton)); | |
120 tmp_button.uX = 24; | |
121 tmp_button.uY = 154; | |
122 tmp_button.uZ = 194; | |
123 tmp_button.uW = 190; | |
124 tmp_button.uWidth = 171; | |
125 tmp_button.uHeight = 37; | |
126 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent; | |
2069 | 127 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Отдых и лечение 8 часов |
1711 | 128 tmp_button.pParent = 0; |
1298 | 129 |
1711 | 130 sprintf(pTmpBuf.data(), "\r408%d", uRestUI_FoodRequiredToRest); |
2069 | 131 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); |
1711 | 132 |
2069 | 133 pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать до рассвета |
134 pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать 1 час | |
135 pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать 5 минут | |
136 pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Закончить отдыхать | |
1711 | 137 memset(&tmp_button, 0, sizeof(GUIButton)); |
138 tmp_button.uX = 45; | |
139 tmp_button.uY = 199; | |
1298 | 140 |
1711 | 141 tmp_button.uZ = 229; |
142 tmp_button.uW = 228; | |
1298 | 143 |
1711 | 144 tmp_button.uWidth = 185; |
145 tmp_button.uHeight = 30; | |
1298 | 146 |
1711 | 147 tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent; |
2069 | 148 tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать без лечения |
1711 | 149 tmp_button.pParent = 0; |
1713 | 150 sprintf(pTmpBuf.data(), "%d:%02d %s", am_pm_hours, pParty->uCurrentMinute, aAMPMNames[(pParty->uCurrentHour >= 12 && pParty->uCurrentHour < 24)? 1:0]); |
2069 | 151 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); |
1711 | 152 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1);//День |
2069 | 153 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); |
1711 | 154 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1);//Месяц |
2069 | 155 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); |
1711 | 156 sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);//Год |
2069 | 157 pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); |
1711 | 158 if ( dword_506F14 ) |
159 Sleep6Hours(); | |
160 } | |
161 else | |
162 GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn, | |
1298 | 163 (int)pButton_RestUI_Exit, pGlobalTXT_LocalizationStrings[81]); // "Exit Rest" |
1711 | 164 } |