Mercurial > mm7
annotate Game/GameOver.cpp @ 2565:117c219bf913
Party, items and stuff are abstracted from savegame file representation
author | a.parshin |
---|---|
date | Wed, 20 May 2015 15:12:33 +0200 |
parents | c674d547cc7c |
children | d87bfbd3bb3b |
rev | line source |
---|---|
2543 | 1 #include "Engine/Engine.h" |
2 #include "Engine/Timer.h" | |
3 #include "Engine/texts.h" | |
4 #include "Engine/Party.h" | |
5 #include "Engine/LOD.h" | |
6 #include "Engine/SaveLoad.h" | |
7 #include "Engine/Graphics/IRender.h" | |
8 #include "Engine/Graphics/Viewport.h" | |
9 | |
10 #include "IO/Mouse.h" | |
11 #include "IO/Keyboard.h" | |
12 | |
13 #include "Media/Audio/AudioPlayer.h" | |
14 | |
15 #include "GUI/GUIWindow.h" | |
16 #include "GUI/GUIButton.h" | |
17 #include "GUI/GUIFont.h" | |
18 #include "GUI/UI/UIPartyCreation.h" | |
19 | |
20 | |
21 //----- (004BF91E) -------------------------------------------------------- | |
22 void GameOver_Loop(int v15) | |
23 { | |
24 const char *v1; // eax@2 | |
25 unsigned int result; // eax@3 | |
26 const char *v6; // eax@10 | |
27 const char *v7; // edx@10 | |
28 const char *v8; // ecx@12 | |
29 const char *v9; // eax@14 | |
30 unsigned int v10; // eax@25 | |
31 GUIWindow pWindow; // [sp+34h] [bp-9Ch]@1 | |
32 unsigned int v14; // [sp+A4h] [bp-2Ch]@5 | |
33 const char *pInString; // [sp+ACh] [bp-24h]@5 | |
34 unsigned int v17; // [sp+B0h] [bp-20h]@5 | |
35 unsigned int v18; // [sp+B4h] [bp-1Ch]@5 | |
36 unsigned int v19; // [sp+B8h] [bp-18h]@5 | |
37 int v20; // [sp+BCh] [bp-14h]@7 | |
38 GUIFont *pFont; // [sp+C4h] [bp-Ch]@1 | |
39 unsigned __int64 v23; // [sp+C8h] [bp-8h]@5 | |
40 MSG msg; | |
41 | |
42 RGBTexture _this; // [sp+Ch] [bp-C4h]@1 | |
43 //RGBTexture::RGBTexture(&this); | |
44 | |
45 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_4000; | |
46 bGameoverLoop = true; | |
47 pMediaPlayer->bStopBeforeSchedule = 0; | |
48 pAudioPlayer->StopChannels(-1, -1); | |
49 pRenderer->BeginScene(); | |
50 pRenderer->ClearBlack(); | |
51 pRenderer->EndScene(); | |
52 pRenderer->Present(); | |
53 //pMediaPlayer->pResetflag = 0; | |
54 _449B57_test_bit(pParty->_quest_bits, 99); | |
55 _this.Load("winbg.pcx", 2); | |
56 pRenderer->BeginScene(); | |
57 pRenderer->DrawTextureRGB(0, 0, &_this); | |
58 pRenderer->EndScene(); | |
59 free(_this.pPixels); | |
60 _this.pPixels = 0; | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2543
diff
changeset
|
61 window_SpeakInHouse = new GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, 0); |
2543 | 62 pWindow.uFrameX = 75; |
63 pWindow.uFrameY = 60; | |
64 pWindow.uFrameWidth = 469; | |
65 pWindow.uFrameHeight = 338; | |
66 pWindow.uFrameZ = 543; | |
67 pWindow.uFrameW = 397; | |
68 pFont = LoadFont("endgame.fnt", "FONTPAL", NULL); | |
69 if (pParty->IsPartyGood()) | |
70 v1 = pGlobalTXT_LocalizationStrings[675];//"Splendid job! With the activation of the Gate, a thousand worlds lie at your feet. Perhaps on one of them you will find the Ancients themselves, and return with the fruits their great civilization has to offer your world and your kingdom." | |
71 else if (pParty->IsPartyEvil()) | |
72 v1 = pGlobalTXT_LocalizationStrings[676];//"Brilliant! The completion of the Heavenly Forge has provided enough Ancient weapons to crush all resistance to your plans. Soon the world will bow to your every whim! Still, you can't help but wonder what was beyond the Gate the other side was trying so hard to build." | |
73 else return; | |
74 pInString = v1; | |
75 v23 = pParty->uTimePlayed - 138240; | |
76 v19 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24; | |
77 v14 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24 / 0x1C / 0xC; | |
78 v18 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24 / 0x1C % 0xC; | |
79 v17 = v19 % 0x1C; | |
80 if (!v19) | |
81 v19 = 1; | |
82 pRenderer->BeginScene(); | |
83 pWindow.DrawTitleText(pFont, 1, 0x23, 1, pGlobalTXT_LocalizationStrings[9], 3);//Congratulations! | |
84 v23 = 0i64; | |
85 v20 = 0; | |
86 for (uint i = 0; i < 4; i++) | |
87 { | |
88 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[129], pParty->pPlayers[i].pName, pParty->pPlayers[i].GetBaseLevel(), pClassNames[pParty->pPlayers[i].classType]);//%s the Level %u %s | |
89 pWindow.DrawTitleText(pFont, 1, i * (LOBYTE(pFont->uFontHeight) - 2) + LOBYTE(pFont->uFontHeight) + 46, 1, pTmpBuf.data(), 3); | |
90 v23 += pParty->pPlayers[i].uExperience;//__PAIR__(*(int *)(i - 4), *(int *)(i - 8)); | |
91 } | |
92 v23 = (signed __int64)v23 / v19; | |
93 v6 = FitTextInAWindow(pInString, pFont, &pWindow, 0xC, 0); | |
94 pWindow.DrawTitleText(pFont, 1, 5 * (LOBYTE(pFont->uFontHeight) + 11), 1, v6, 0); | |
95 strcpy(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[37]);//Total Time: | |
96 | |
97 v7 = pGlobalTXT_LocalizationStrings[56]; | |
98 if (v17 != 1) | |
99 v7 = pGlobalTXT_LocalizationStrings[57]; | |
100 | |
101 v8 = pGlobalTXT_LocalizationStrings[146];//Month | |
102 if (v18 != 1) | |
103 v8 = pGlobalTXT_LocalizationStrings[148];//Months | |
104 | |
105 v9 = pGlobalTXT_LocalizationStrings[245]; | |
106 if (v14 != 1) | |
107 v9 = pGlobalTXT_LocalizationStrings[132]; | |
108 | |
109 sprintf(pTmpBuf2.data(), " %lu %s, %lu %s, %lu %s ", v14, v9, v18, v8, v17, v7); | |
110 strcat(pTmpBuf.data(), pTmpBuf2.data()); | |
111 pWindow.DrawTitleText(pFont, 1, pWindow.uFrameHeight - 2 * LOBYTE(pFont->uFontHeight) - 5, 1, pTmpBuf.data(), 3); | |
112 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[94], v23); | |
113 pWindow.DrawTitleText(pFont, 1, pWindow.uFrameHeight, 1, pTmpBuf.data(), 3); | |
114 dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; | |
115 pRenderer->EndScene(); | |
116 pRenderer->Present(); | |
117 //if ( pRenderer->pRenderD3D ) | |
118 pRenderer->pBeforePresentFunction(); | |
119 pRenderer->SaveWinnersCertificate("MM7_Win.Pcx"); | |
120 free(pFont); | |
121 window_SpeakInHouse->Release(); | |
122 window_SpeakInHouse = 0; | |
123 if (v15 == 2) | |
124 result = pMessageQueue_50CBD0->uNumMessages; | |
125 else | |
126 { | |
127 LODWORD(v23) = GetTickCount() + 5000; | |
128 while ((unsigned int)v23 > GetTickCount()) | |
129 ; | |
130 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) | |
131 { | |
132 if (msg.message == WM_QUIT) | |
133 Engine_DeinitializeAndTerminate(0); | |
134 TranslateMessage(&msg); | |
135 DispatchMessage(&msg); | |
136 } | |
137 if (pMessageQueue_50CBD0->uNumMessages) | |
138 { | |
139 LOBYTE(v10) = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
140 pMessageQueue_50CBD0->uNumMessages = v10; | |
141 } | |
142 pKeyActionMap->ResetKeys(); | |
143 pKeyActionMap->uLastKeyPressed = 0; | |
144 do | |
145 { | |
146 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) | |
147 { | |
148 if (msg.message == WM_QUIT) | |
149 Engine_DeinitializeAndTerminate(0); | |
150 TranslateMessage(&msg); | |
151 DispatchMessage(&msg); | |
152 } | |
153 } while (!pKeyActionMap->uLastKeyPressed); | |
154 if (pMessageQueue_50CBD0->uNumMessages) | |
155 { | |
156 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
157 } | |
158 } | |
159 if (v15) | |
160 { | |
161 /*if ( (signed int)result < 40 ) | |
162 { | |
163 pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_Quit; | |
164 }*/ | |
165 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Quit, 1, 0); | |
166 } | |
167 else | |
168 { | |
169 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ShowFinalWindow, 1, 0); | |
170 /*if ( (signed int)result < 40 ) | |
171 { | |
172 pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_C5; | |
173 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; | |
174 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; | |
175 *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; | |
176 ++pMessageQueue_50CBD0->uNumMessages; | |
177 }*/ | |
178 } | |
179 bGameoverLoop = false; | |
180 } |