World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
UIRest.cpp
См. документацию.
1 #define _CRTDBG_MAP_ALLOC
2 #include <stdlib.h>
3 
4 #define _CRT_SECURE_NO_WARNINGS
5 
6 #include "Engine/AssetsManager.h"
7 #include "Engine/Engine.h"
8 #include "Engine/LOD.h"
9 #include "Engine/Localization.h"
10 #include "Engine/Party.h"
11 #include "Engine/Time.h"
12 
15 
16 #include "GUI/GUIButton.h"
17 #include "GUI/UI/UIRest.h"
18 #include "GUI/GUIFont.h"
19 
21 
22 #include "Platform/Api.h"
23 
24 Image *rest_ui_btn_4 = nullptr;
26 Image *rest_ui_btn_3 = nullptr;
27 Image *rest_ui_btn_1 = nullptr;
28 Image *rest_ui_btn_2 = nullptr;
30 
33 
35  __debugbreak(); // doesnt seems to get here, check stack trace & conditions
36  GUIButton GUIButton2; // [sp+28h] [bp-E0h]@133
37  GUIButton2.uZ = 197;
38  GUIButton2.uW = 197;
39  GUIButton2.uX = 27;
40  GUIButton2.uY = 161;
41  GUIButton2.uWidth = 171;
42  GUIButton2.uHeight = 37;
45  render->DrawTextureAlphaNew(uFrameX / 640.0f, uFrameY / 480.0f,
46  *((Image **)ptr_1C + 15));
48  GUIButton2.DrawLabel(localization->GetString(183), pFontCreate, 0,
49  0); // Rest & Heal 8 hrs / Отдых и лечение 8 часов
50  GUIButton2.pParent = 0;
51  Release();
52 }
53 
59  }
61  viewparams->bRedrawGameUI = true;
62  }
63  pEventTimer->Pause();
64  if (_506F14_resting_stage != 2)
65  new OnButtonClick2(518, 450, 0, 0, (int)pBtn_Rest);
73  if (PartyHasDragon()) {
74  for (uint i = 0; i < 4; ++i) {
75  if (pParty->pPlayers[i].classType == PLAYER_CLASS_WARLOCK)
77  }
78  }
83  if ((pCurrentMapName == "d29.blv") &&
85  PARTY_QUEST_HARMONDALE_REBUILT)) // d29 = Harmondale /
86  // Замок Хармондейл
88 }
89 
90 //----- (0041F6C1) --------------------------------------------------------
92  : GUIWindow(WINDOW_Rest, 0, 0, window->GetWidth(), window->GetHeight(), 0) {
95 
97  rest_ui_restmain = assets->GetImage_Alpha("restmain");
98  rest_ui_btn_1 = assets->GetImage_Alpha("restb1");
99  rest_ui_btn_2 = assets->GetImage_Alpha("restb2");
100  rest_ui_btn_3 = assets->GetImage_Alpha("restb3");
101  rest_ui_btn_4 = assets->GetImage_Alpha("restb4");
102  rest_ui_btn_exit = assets->GetImage_Alpha("restexit");
103 
105 
106  // auto wnd = new GUIWindow_Rest(0, 0, window->GetWidth(),
107  // window->GetHeight());
108  pButton_RestUI_Exit = CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest,
109  0, 0, "", {{rest_ui_btn_exit}});
110  pButton_RestUI_Main = CreateButton(24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour,
111  0, 'R', "", {{rest_ui_btn_4}});
113  CreateButton(61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "",
114  {{rest_ui_btn_1}});
116  61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", {{rest_ui_btn_2}});
118  CreateButton(61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "",
119  {{rest_ui_btn_3}});
120 }
121 
122 //----- (0041FA01) --------------------------------------------------------
124  int live_characters; // esi@1
125  unsigned int v3; // eax@15
126  GUIButton tmp_button; // [sp+8h] [bp-DCh]@19
127  unsigned int am_pm_hours; // [sp+D8h] [bp-Ch]@9
128 
129  live_characters = 0;
130  for (int i = 1; i < 5; ++i)
131  if (!pPlayers[i]->IsDead() && !pPlayers[i]->IsEradicated() &&
132  pPlayers[i]->sHealth > 0)
133  ++live_characters;
134 
135  if (live_characters) {
136  render->DrawTextureAlphaNew(8 / 640.0f, 8 / 480.0f, rest_ui_restmain);
137  am_pm_hours = pParty->uCurrentHour;
139  if ((signed int)pParty->uCurrentHour <= 12) {
140  if (!am_pm_hours) am_pm_hours = 12;
141  } else {
142  am_pm_hours -= 12;
143  }
144  render->DrawTextureAlphaNew(16 / 640.0f, 26 / 480.0f,
149  }
153  if ((unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512) {
154  v3 = 0;
156  }
158  (int)floorf(((double)v3 / 512.0 * 120.0) + 0.5f) % 256 + 1;
159  if (hourglass_icon_idx >= 120) hourglass_icon_idx = 1;
160 
161  {
163  StringPrintf("hglas%03d", hourglass_icon_idx), 0x7FF);
164  render->DrawTextureAlphaNew(267 / 640.0f, 159 / 480.0f,
166  }
167 
168  tmp_button.uX = 24;
169  tmp_button.uY = 154;
170  tmp_button.uZ = 194;
171  tmp_button.uW = 190;
172  tmp_button.uWidth = 171;
173  tmp_button.uHeight = 37;
175  tmp_button.DrawLabel(localization->GetString(183), pFontCreate,
176  Color16(10, 0, 0),
177  Color16(230, 214, 193)); //Отдых и лечение 8 часов
178  tmp_button.pParent = 0;
179 
180  auto str1 = StringPrintf("\r408%d", uRestUI_FoodRequiredToRest);
181  pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, Color16(10, 0, 0), str1, 0, 0, Color16(230, 214, 193));
182 
183  pButton_RestUI_WaitUntilDawn->DrawLabel(localization->GetString(237), pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193)); // Ждать до рассвета
184  pButton_RestUI_Wait1Hour->DrawLabel(localization->GetString(239), pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193)); // Ждать 1 час
185  pButton_RestUI_Wait5Minutes->DrawLabel(localization->GetString(238), pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193)); // Ждать 5 минут
186  pButton_RestUI_Exit->DrawLabel(localization->GetString(81), pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193)); // Закончить отдыхать
187  tmp_button.uX = 45;
188  tmp_button.uY = 199;
189 
190  tmp_button.uZ = 229;
191  tmp_button.uW = 228;
192 
193  tmp_button.uWidth = 185;
194  tmp_button.uHeight = 30;
195 
197  tmp_button.DrawLabel(localization->GetString(236), pFontCreate,
198  Color16(10, 0, 0),
199  Color16(230, 214, 193)); //Ждать без лечения
200  tmp_button.pParent = 0;
201  auto str2 = StringPrintf(
202  "%d:%02d %s", am_pm_hours, pParty->uCurrentMinute,
204  (pParty->uCurrentHour >= 12 && pParty->uCurrentHour < 24) ? 1
205  : 0));
207  Color16(10, 0, 0), str2, 0, 0,
208  Color16(230, 214, 193));
209  auto str3 = StringPrintf("%s\r190%d", localization->GetString(56),
210  pParty->uCurrentDayOfMonth + 1); //День
212  Color16(10, 0, 0), str3, 0, 0,
213  Color16(230, 214, 193));
214  auto str4 = StringPrintf("%s\r190%d", localization->GetString(146),
215  pParty->uCurrentMonth + 1); //Месяц
217  Color16(10, 0, 0), str4, 0, 0,
218  Color16(230, 214, 193));
219  auto str5 = StringPrintf("%s\r190%d", localization->GetString(245),
220  pParty->uCurrentYear); //Год
222  Color16(10, 0, 0), str5, 0, 0,
223  Color16(230, 214, 193));
225  } else {
227  (int)pButton_RestUI_Exit,
228  localization->GetString(81)); // "Exit Rest"
229  }
230 }
pButton_RestUI_Exit
GUIButton * pButton_RestUI_Exit
Definition: GUIButton.cpp:35
pButton_RestUI_Main
GUIButton * pButton_RestUI_Main
Definition: GUIButton.cpp:34
OnButtonClick2
Definition: GUIWindow.h:523
pBtn_Rest
GUIButton * pBtn_Rest
Definition: GUIButton.cpp:55
GUIWindow::DrawText
void DrawText(GUIFont *font, int x, int y, unsigned short uFontColor, const char *str, bool present_time_transparency=false, int max_text_height=0, int uFontShadowColor=0)
Definition: GUIWindow.cpp:694
Party::vPosition
Vec3_int_ vPosition
Definition: Party.h:250
rest_ui_btn_exit
Image * rest_ui_btn_exit
Definition: UIRest.cpp:25
Localization::GetString
const char * GetString(unsigned int index) const
Definition: Localization.cpp:13
Viewport.h
Timer::uTimeElapsed
unsigned int uTimeElapsed
Definition: Time.h:133
Party::uCurrentMonth
unsigned int uCurrentMonth
Definition: Party.h:272
LOD.h
hourglass_icon_idx
unsigned char hourglass_icon_idx
Definition: mm7_data.cpp:238
PartyHasDragon
bool PartyHasDragon()
Definition: NPC.cpp:750
WINDOW_Rest
@ WINDOW_Rest
Definition: GUIWindow.h:301
dword_506F1C
int dword_506F1C
Definition: mm7_data.cpp:546
GUIWindow
Definition: GUIWindow.h:433
Party::uCurrentMinute
unsigned int uCurrentMinute
Definition: Party.h:276
OutdoorLocation::GetNumFoodRequiredToRestInCurrentPos
int GetNumFoodRequiredToRestInCurrentPos(int x, signed int y, int z)
Definition: Outdoor.cpp:457
GUIButton::pParent
GUIWindow * pParent
Definition: GUIButton.h:33
pGUIWindow_CurrentMenu
GUIWindow * pGUIWindow_CurrentMenu
Definition: GUIWindow.cpp:54
_449B57_test_bit
bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2)
Definition: Party.cpp:1185
GUIWindow::CreateButton
GUIButton * CreateButton(int x, int y, int width, int height, int a6, int a7, UIMessageType msg, unsigned int msg_param, uint8_t hotkey, const String &label, const std::vector< Image * > &textures=std::vector< Image * >())
Definition: GUIWindow.cpp:717
rest_ui_btn_4
Image * rest_ui_btn_4
Definition: UIRest.cpp:24
GUIButton::uZ
unsigned int uZ
Definition: GUIButton.h:25
GUIWindow_Rest::Update
virtual void Update()
Definition: UIRest.cpp:123
AudioPlayer::PlaySound
void PlaySound(SoundID eSoundID, int pid, unsigned int uNumRepeats, int x, int y, int a7)
Definition: AudioPlayer.cpp:195
PARTY_QUEST_HARMONDALE_REBUILT
@ PARTY_QUEST_HARMONDALE_REBUILT
Definition: Party.h:25
Party::_quest_bits
unsigned __int8 _quest_bits[64]
Definition: Party.h:291
localization
Localization * localization
Definition: Localization.cpp:11
UIRest.h
Party::uCurrentHour
unsigned int uCurrentHour
Definition: Party.h:275
GUIWindow_RestWindow::Release
virtual void Release()
Party::pPlayers
std::array< Player, 4 > pPlayers
Definition: Party.h:310
GUIWindow::Release
virtual void Release()
Definition: GUIWindow.cpp:292
GUIFont.h
AssetsManager.h
pPlayers
NZIArray< struct Player *, 5 > pPlayers
Definition: Player.cpp:46
pFontCreate
GUIFont * pFontCreate
Definition: GUIFont.cpp:22
GUIButton
Definition: GUIButton.h:11
GUIWindow_Rest::GUIWindow_Rest
GUIWindow_Rest()
Definition: UIRest.cpp:91
Engine.h
current_screen_type
enum CURRENT_SCREEN current_screen_type
Definition: GUIWindow.cpp:83
Party::Sleep8Hours
static void Sleep8Hours()
Definition: Party.cpp:899
_506F14_resting_stage
int _506F14_resting_stage
Definition: mm7_data.cpp:544
rest_ui_restmain
Image * rest_ui_restmain
Definition: UIRest.cpp:29
Localization.h
rest_ui_btn_2
Image * rest_ui_btn_2
Definition: UIRest.cpp:28
rest_ui_hourglass_frame_current
Image * rest_ui_hourglass_frame_current
Definition: UIRest.cpp:32
GUIButton.h
pParty
Party * pParty
Definition: Party.cpp:30
Image
Definition: Image.h:19
GUIWindow::pCurrentPosActiveItem
int pCurrentPosActiveItem
Definition: GUIWindow.h:482
_506F18_num_minutes_to_sleep
int _506F18_num_minutes_to_sleep
Definition: mm7_data.cpp:545
Gypsy
@ Gypsy
Definition: NPC.h:54
pButton_RestUI_Wait1Hour
GUIButton * pButton_RestUI_Wait1Hour
Definition: GUIButton.cpp:38
UIMSG_ExitRest
@ UIMSG_ExitRest
Definition: GUIWindow.h:134
viewparams
struct ViewingParams * viewparams
Definition: mm7_data.cpp:22
AssetsManager::GetImage_ColorKey
Texture * GetImage_ColorKey(const String &name, uint16_t colorkey)
Definition: AssetsManager.cpp:34
AudioPlayer::StopChannels
void StopChannels(int uStartChannel, int uEndChannel)
Definition: AudioPlayer.cpp:331
Party.h
UIMSG_AlreadyResting
@ UIMSG_AlreadyResting
Definition: GUIWindow.h:92
window
EGLSurface EGLNativeWindowType * window
Definition: SDL_egl.h:1580
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
uRestUI_FoodRequiredToRest
int uRestUI_FoodRequiredToRest
Definition: mm7_data.cpp:543
pButton_RestUI_WaitUntilDawn
GUIButton * pButton_RestUI_WaitUntilDawn
Definition: GUIButton.cpp:37
LEVEL_Outdoor
@ LEVEL_Outdoor
Definition: Indoor.h:287
Timer::Pause
void Pause()
Definition: Time.cpp:19
rest_ui_sky_frame_current
Image * rest_ui_sky_frame_current
Definition: UIRest.cpp:31
GUIButton::uWidth
unsigned int uWidth
Definition: GUIButton.h:23
pCurrentMapName
String pCurrentMapName
Definition: mm7_data.cpp:712
Localization::GetAmPm
const char * GetAmPm(unsigned int index) const
Definition: Localization.h:79
rest_ui_btn_1
Image * rest_ui_btn_1
Definition: UIRest.cpp:27
GUIWindow::uFrameY
unsigned int uFrameY
Definition: GUIWindow.h:469
GUIButton::uX
unsigned int uX
Definition: GUIButton.h:21
Outdoor.h
GUIButton::uW
unsigned int uW
Definition: GUIButton.h:26
pButton_RestUI_Wait5Minutes
GUIButton * pButton_RestUI_Wait5Minutes
Definition: GUIButton.cpp:36
AudioPlayer.h
PLAYER_CLASS_WARLOCK
@ PLAYER_CLASS_WARLOCK
Definition: Player.h:247
PrepareToLoadRestUI
void PrepareToLoadRestUI()
Definition: UIRest.cpp:54
CURRENT_SCREEN::SCREEN_GAME
@ SCREEN_GAME
Party::uCurrentDayOfMonth
unsigned int uCurrentDayOfMonth
Definition: Party.h:274
OnCancel
Definition: GUIWindow.h:568
UIMSG_Wait5Minutes
@ UIMSG_Wait5Minutes
Definition: GUIWindow.h:80
UIMSG_Rest8Hour
@ UIMSG_Rest8Hour
Definition: GUIWindow.h:82
assets
AssetsManager * assets
Definition: AssetsManager.cpp:12
uint
unsigned int uint
Definition: MM7.h:4
GUIButton::DrawLabel
void DrawLabel(const String &label_text, GUIFont *pFont, int a5, int uFontShadowColor)
Definition: GUIButton.cpp:104
rest_ui_btn_3
Image * rest_ui_btn_3
Definition: UIRest.cpp:26
UIMSG_Wait1Hour
@ UIMSG_Wait1Hour
Definition: GUIWindow.h:81
v3
GLfloat GLfloat GLfloat GLfloat v3
Definition: SDL_opengl_glext.h:696
GUIButton::uY
unsigned int uY
Definition: GUIButton.h:22
__debugbreak
void __cdecl __debugbreak(void)
GUIButton::uHeight
unsigned int uHeight
Definition: GUIButton.h:24
CURRENT_SCREEN::SCREEN_REST
@ SCREEN_REST
OutdoorLocation::LoadActualSkyFrame
static void LoadActualSkyFrame()
Definition: Outdoor.cpp:2143
_507CD4_RestUI_hourglass_anim_controller
int _507CD4_RestUI_hourglass_anim_controller
Definition: mm7_data.cpp:560
GUIWindow::ptr_1C
void * ptr_1C
Definition: GUIWindow.h:476
ViewingParams::bRedrawGameUI
int bRedrawGameUI
Definition: Viewport.h:74
AssetsManager::GetImage_Alpha
Texture * GetImage_Alpha(const String &name)
Definition: AssetsManager.cpp:66
GUIWindow_RestWindow::Update
virtual void Update()
Definition: UIRest.cpp:34
uCurrentlyLoadedLevelType
LEVEL_TYPE uCurrentlyLoadedLevelType
Definition: Indoor.cpp:52
CheckHiredNPCSpeciality
bool CheckHiredNPCSpeciality(unsigned int uProfession)
Definition: NPC.cpp:754
Porter
@ Porter
Definition: NPC.h:34
GUIWindow::uFrameX
unsigned int uFrameX
Definition: GUIWindow.h:468
pAudioPlayer
AudioPlayer * pAudioPlayer
Definition: AudioPlayer.cpp:20
SOUND_StartMainChoice02
@ SOUND_StartMainChoice02
Definition: AudioPlayer.h:37
Color16
uint16_t Color16(uint32_t r, uint32_t g, uint32_t b)
Definition: Engine.cpp:148
pOutdoor
OutdoorLocation * pOutdoor
Definition: Outdoor.cpp:48
QuarterMaster
@ QuarterMaster
Definition: NPC.h:35
Party::uCurrentYear
unsigned int uCurrentYear
Definition: Party.h:271
StringPrintf
String StringPrintf(const char *fmt,...)
Definition: Strings.cpp:9
pEventTimer
Timer * pEventTimer
Definition: Time.cpp:8
Image::Release
bool Release()
Definition: Image.cpp:335
Api.h
Time.h
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52