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