World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
GameOver.cpp
См. документацию.
2 
3 #include "Engine/AssetsManager.h"
4 #include "Engine/Engine.h"
5 #include "Engine/LOD.h"
6 #include "Engine/Localization.h"
7 #include "Engine/Party.h"
8 #include "Engine/SaveLoad.h"
9 #include "Engine/Time.h"
10 
13 
14 #include "IO/Keyboard.h"
15 #include "IO/Mouse.h"
16 
18 #include "Media/MediaPlayer.h"
19 
20 #include "GUI/GUIButton.h"
21 #include "GUI/GUIFont.h"
22 #include "GUI/GUIWindow.h"
23 #include "GUI/UI/UIPartyCreation.h"
24 #include "GUI/UI/UIStatusBar.h"
25 
26 //----- (004BF91E) --------------------------------------------------------
27 void Application::GameOver_Loop(int v15) {
28  const char *v1; // eax@2
29  unsigned int result; // eax@3
30  const char *v7; // edx@10
31  const char *v8; // ecx@12
32  const char *v9; // eax@14
33  // unsigned int v10; // eax@25
34  GUIWindow pWindow; // [sp+34h] [bp-9Ch]@1
35  unsigned int v14; // [sp+A4h] [bp-2Ch]@5
36  const char *pInString; // [sp+ACh] [bp-24h]@5
37  unsigned int v17; // [sp+B0h] [bp-20h]@5
38  unsigned int v18; // [sp+B4h] [bp-1Ch]@5
39  unsigned int v19; // [sp+B8h] [bp-18h]@5
40  int v20; // [sp+BCh] [bp-14h]@7
41  GUIFont *pFont; // [sp+C4h] [bp-Ch]@1
42  unsigned __int64 v23; // [sp+C8h] [bp-8h]@5
43 
44  dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_4000;
45  bGameoverLoop = true;
46  pAudioPlayer->StopChannels(-1, -1);
47  render->BeginScene();
48  render->ClearBlack();
49  render->EndScene();
50  render->Present();
51  // pMediaPlayer->pResetflag = 0;
53 
54  Image *background = assets->GetImage_PCXFromIconsLOD("winbg.pcx");
55  {
56  render->BeginScene();
57  render->DrawTextureNew(0, 0, background);
58  render->EndScene();
59  }
60  background->Release();
61  background = nullptr;
62 
63  window_SpeakInHouse = new GUIWindow(WINDOW_Unknown, 0, 0, window->GetWidth(), window->GetHeight(), 0);
64  pWindow.uFrameX = 75;
65  pWindow.uFrameY = 60;
66  pWindow.uFrameWidth = 469;
67  pWindow.uFrameHeight = 338;
68  pWindow.uFrameZ = 543;
69  pWindow.uFrameW = 397;
70  pFont = GUIFont::LoadFont("endgame.fnt", "FONTPAL", NULL);
71  if (pParty->IsPartyGood())
73  675); // "Splendid job! With the activation of the Gate, a thousand
74  // worlds lie at your feet. Perhaps on one of them you will
75  // find the Ancients themselves, and return with the fruits
76  // their great civilization has to offer your world and your
77  // kingdom."
78  else if (pParty->IsPartyEvil())
80  676); // "Brilliant! The completion of the Heavenly Forge has
81  // provided enough Ancient weapons to crush all resistance to
82  // your plans. Soon the world will bow to your every whim!
83  // Still, you can't help but wonder what was beyond the Gate
84  // the other side was trying so hard to build."
85  else
86  return;
87  pInString = v1;
88 
89  auto play_time = pParty->GetPlayingTime();
90  play_time.SubtractHours(9); // game begins at 9 am
91 
92  v19 = play_time.GetDays();
93  v14 = play_time.GetYears();
94  v18 = play_time.GetMonthsOfYear();
95  v17 = play_time.GetDaysOfMonth();
96  if (!v19) v19 = 1;
97  render->BeginScene();
98  pWindow.DrawTitleText(pFont, 1, 0x23, 1, localization->GetString(9),
99  3); // Congratulations!
100  v23 = 0ull;
101  v20 = 0;
102  for (uint i = 0; i < 4; i++) {
103  pWindow.DrawTitleText(
104  pFont, 1,
105  i * ((unsigned char)pFont->GetHeight() - 2) +
106  (unsigned char)pFont->GetHeight() + 46,
107  1,
109  129, pParty->pPlayers[i].pName,
110  pParty->pPlayers[i].GetBaseLevel(),
112  pParty->pPlayers[i].classType)), 3); // %s the Level %u %s
113  v23 += pParty->pPlayers[i]
114  .uExperience; // __PAIR__(*(int *)(i - 4), *(int *)(i - 8));
115  }
116  v23 = (signed __int64)v23 / v19;
117  String v6 = pFont->FitTextInAWindow(pInString, pWindow.uFrameWidth, 12);
118  pWindow.DrawTitleText(pFont, 1, 5 * (pFont->GetHeight() + 11), 1, v6, 0);
119 
120  v7 = localization->GetString(56);
121  if (v17 != 1) v7 = localization->GetString(57);
122 
123  v8 = localization->GetString(146); // Month
124  if (v18 != 1) v8 = localization->GetString(148); // Months
125 
126  v9 = localization->GetString(245);
127  if (v14 != 1) v9 = localization->GetString(132);
128 
129  pWindow.DrawTitleText(pFont, 1,
130  pWindow.uFrameHeight - 2 * pFont->GetHeight() - 5, 1,
131  localization->GetString(37) +
132  StringPrintf(" %lu %s, %lu %s, %lu %s ", v14, v9,
133  v18, v8, v17, v7), // Total Time:
134  3);
135 
136  pWindow.DrawTitleText(pFont, 1, pWindow.uFrameHeight, 1,
137  localization->FormatString(94, v23), 3);
138  dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000;
139  render->EndScene();
140  render->Present();
141  // if ( render->pRenderD3D )
142  render->pBeforePresentFunction();
143  render->SaveWinnersCertificate("MM7_Win.Pcx");
144  free(pFont);
147  if (v15 == 2) {
149  } else {
150  HEXRAYS_LODWORD(v23) = OS_GetTime() + 5000;
151  while ((unsigned int)v23 > OS_GetTime());
152 
153  window->PeekMessageLoop();
154 
158  do {
159  window->PeekMessageLoop();
160  } while (!pKeyActionMap->uLastKeyPressed);
162  }
163  if (v15) {
164  /*if ( (signed int)result < 40 )
165  {
166  pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_Quit;
167  }*/
168  pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Quit, 1, 0);
169  } else {
170  pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ShowFinalWindow, 1, 0);
171  /*if ( (signed int)result < 40 )
172  {
173  pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_C5;
174  pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param
175  = 1; result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
176  *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
177  ++pMessageQueue_50CBD0->uNumMessages;
178  }*/
179  }
180  bGameoverLoop = false;
181 }
GameOver.h
GUIWindow::uFrameW
unsigned int uFrameW
Definition: GUIWindow.h:473
Localization::GetString
const char * GetString(unsigned int index) const
Definition: Localization.cpp:13
Viewport.h
LOD.h
Party::GetPlayingTime
GameTime & GetPlayingTime()
Definition: Party.h:230
UIMSG_Quit
@ UIMSG_Quit
Definition: GUIWindow.h:114
UIMSG_ShowFinalWindow
@ UIMSG_ShowFinalWindow
Definition: GUIWindow.h:165
GUIFont
Definition: GUIFont.h:8
GUIWindow
Definition: GUIWindow.h:433
UIPartyCreation.h
WINDOW_Unknown
@ WINDOW_Unknown
Definition: GUIWindow.h:342
_449B57_test_bit
bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2)
Definition: Party.cpp:1185
GUIMessageQueue::Flush
void Flush()
Definition: GUIWindow.cpp:159
Party::_quest_bits
unsigned __int8 _quest_bits[64]
Definition: Party.h:291
localization
Localization * localization
Definition: Localization.cpp:11
ull
unsigned long long ull
Definition: MM7.h:23
Party::pPlayers
std::array< Player, 4 > pPlayers
Definition: Party.h:310
GUIWindow::DrawTitleText
void DrawTitleText(GUIFont *font, int horizontal_margin, int vertical_margin, unsigned __int16 uDefaultColor, const char *pInString, int line_spacing)
Definition: GUIWindow.cpp:665
AssetsManager::GetImage_PCXFromIconsLOD
Texture * GetImage_PCXFromIconsLOD(const String &name)
Definition: AssetsManager.cpp:81
GUIWindow::Release
virtual void Release()
Definition: GUIWindow.cpp:292
GUIFont.h
GUIFont::GetHeight
unsigned int GetHeight() const
Definition: GUIFont.cpp:84
AssetsManager.h
GUIWindow::uFrameWidth
unsigned int uFrameWidth
Definition: GUIWindow.h:470
GUIWindow::uFrameZ
unsigned int uFrameZ
Definition: GUIWindow.h:472
Engine.h
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9435
Localization.h
window_SpeakInHouse
GUIWindow * window_SpeakInHouse
Definition: GUIWindow.cpp:51
GUIButton.h
pParty
Party * pParty
Definition: Party.cpp:30
Image
Definition: Image.h:19
IRender.h
OS_GetTime
unsigned int OS_GetTime()
Definition: Lin.cpp:12
SaveLoad.h
GUIWindow::uFrameHeight
unsigned int uFrameHeight
Definition: GUIWindow.h:471
v1
GLfloat GLfloat v1
Definition: SDL_opengl_glext.h:694
GUIFont::LoadFont
static GUIFont * LoadFont(const char *pFontFile, const char *pFontPalette,...)
Definition: GUIFont.cpp:56
AudioPlayer::StopChannels
void StopChannels(int uStartChannel, int uEndChannel)
Definition: AudioPlayer.cpp:331
MediaPlayer.h
Party.h
Party::IsPartyGood
bool IsPartyGood()
Definition: Party.cpp:1141
window
EGLSurface EGLNativeWindowType * window
Definition: SDL_egl.h:1580
KeyboardActionMapping::ResetKeys
void ResetKeys()
Definition: Keyboard.cpp:176
GUIWindow::uFrameY
unsigned int uFrameY
Definition: GUIWindow.h:469
AudioPlayer.h
KeyboardActionMapping::uLastKeyPressed
unsigned int uLastKeyPressed
Definition: Keyboard.h:60
UIStatusBar.h
pKeyActionMap
struct KeyboardActionMapping * pKeyActionMap
Definition: Keyboard.cpp:35
assets
AssetsManager * assets
Definition: AssetsManager.cpp:12
uint
unsigned int uint
Definition: MM7.h:4
bGameoverLoop
int bGameoverLoop
Definition: mm7_data.cpp:785
Localization::FormatString
String FormatString(unsigned int index,...) const
Definition: Localization.cpp:17
Party::IsPartyEvil
bool IsPartyEvil()
Definition: Party.cpp:1139
GUIFont::FitTextInAWindow
String FitTextInAWindow(const String &inString, unsigned int width, int uX, bool return_on_carriage=false)
Definition: GUIFont.cpp:311
dword_6BE364_game_settings_1
int dword_6BE364_game_settings_1
Definition: mm7_data.cpp:714
Application::GameOver_Loop
void GameOver_Loop(int)
GUIMessageQueue::qMessages
std::queue< GUIMessage > qMessages
Definition: GUIWindow.h:664
GameTime::SubtractHours
void SubtractHours(int hours)
Definition: Time.h:48
GUIWindow::uFrameX
unsigned int uFrameX
Definition: GUIWindow.h:468
pAudioPlayer
AudioPlayer * pAudioPlayer
Definition: AudioPlayer.cpp:20
Localization::GetClassName
const char * GetClassName(unsigned int index) const
Definition: Localization.h:35
GUIWindow.h
pMessageQueue_50CBD0
struct GUIMessageQueue * pMessageQueue_50CBD0
Definition: GUIWindow.cpp:86
StringPrintf
String StringPrintf(const char *fmt,...)
Definition: Strings.cpp:9
String
std::string String
Definition: Strings.h:10
Keyboard.h
Image::Release
bool Release()
Definition: Image.cpp:335
Mouse.h
Time.h
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52