706
|
1 #include <assert.h>
|
|
2
|
|
3 #include "MM7.h"
|
|
4
|
|
5 #include "MapInfo.h"
|
|
6 #include "Game.h"
|
|
7 #include "GUIWindow.h"
|
|
8 #include "GUIFont.h"
|
|
9 #include "GUIProgressBar.h"
|
|
10 #include "Party.h"
|
|
11 #include "AudioPlayer.h"
|
|
12 #include "Outdoor.h"
|
|
13 #include "IndoorCamera.h"
|
|
14 #include "Overlays.h"
|
|
15 #include "Monsters.h"
|
|
16 #include "Arcomage.h"
|
|
17 #include "LOD.h"
|
|
18 #include "Actor.h"
|
|
19 #include "Allocator.h"
|
|
20 #include "Events.h"
|
|
21 #include "Viewport.h"
|
|
22 #include "FrameTableInc.h"
|
|
23 #include "Math.h"
|
|
24 #include "SpriteObject.h"
|
|
25 #include "ObjectList.h"
|
|
26 #include "Chest.h"
|
|
27 #include "PaletteManager.h"
|
|
28 #include "DecorationList.h"
|
|
29 #include "SaveLoad.h"
|
|
30 #include "stru123.h"
|
|
31 #include "Time.h"
|
|
32 #include "IconFrameTable.h"
|
|
33 #include "Awards.h"
|
|
34 #include "Autonotes.h"
|
|
35 #include "stru160.h"
|
|
36 #include "stru279.h"
|
|
37 #include "TurnEngine.h"
|
|
38 #include "stru277.h"
|
|
39 #include "Weather.h"
|
|
40 #include "stru272.h"
|
|
41 #include "stru298.h"
|
|
42 #include "StorylineTextTable.h"
|
|
43 #include "Events2D.h"
|
|
44 #include "texts.h"
|
|
45 #include "stru351.h"
|
|
46
|
|
47 #include "mm7_data.h"
|
|
48
|
|
49
|
|
50 //----- (004601B7) --------------------------------------------------------
|
|
51 void GameUI_MainMenu_DoDrawLoad(int a1)
|
|
52 {
|
|
53 unsigned __int16 v1; // bx@1
|
|
54 unsigned int v2; // edi@4
|
|
55 unsigned int v3; // eax@4
|
|
56 unsigned int v4; // eax@8
|
|
57 int v5; // edi@8
|
|
58 unsigned int v6; // eax@8
|
|
59 unsigned int pMapID; // eax@10
|
|
60 signed __int64 v8; // qax@10
|
|
61 unsigned int v9; // ebx@10
|
|
62 unsigned __int64 v10; // qax@10
|
|
63 __int64 v11; // qax@10
|
|
64 char v12; // di@10
|
|
65 unsigned __int64 v13; // qtt@10
|
|
66 unsigned int v14; // ecx@10
|
|
67 __int64 pOurHour; // qax@10
|
|
68 int v16; // edi@10
|
|
69 signed int pHour; // ebx@22
|
|
70 //const char *v18; // ST14_4@32
|
|
71 int v19; // eax@32
|
|
72 const char *v20; // ST18_4@32
|
|
73 int v21; // eax@32
|
|
74 //const char *v22; // ST14_4@32
|
|
75 int v23; // eax@32
|
|
76 const char *pSlotName; // edi@36
|
|
77 int v25; // eax@43
|
|
78 GUIWindow pWindow; // [sp+Ch] [bp-78h]@8
|
|
79 /*unsigned int Dst; // [sp+Ch] [bp-78h]@8
|
|
80 unsigned int v27; // [sp+10h] [bp-74h]@8
|
|
81 int v28; // [sp+14h] [bp-70h]@8
|
|
82 int v29; // [sp+18h] [bp-6Ch]@8
|
|
83 unsigned int v30; // [sp+1Ch] [bp-68h]@8
|
|
84 unsigned int v31; // [sp+20h] [bp-64h]@8*/
|
|
85 int pMinutes; // [sp+60h] [bp-24h]@10
|
|
86 int pMonthNum; // [sp+68h] [bp-1Ch]@10
|
|
87 unsigned int pSaveFiles; // [sp+70h] [bp-14h]@10
|
|
88 __int64 pAMPM2; // [sp+74h] [bp-10h]@10
|
|
89 int pYear; // [sp+7Ch] [bp-8h]@10
|
|
90 int a4; // [sp+80h] [bp-4h]@1
|
|
91 int pFilesID;
|
|
92
|
|
93 v1 = 255;
|
|
94 a4 = a1;
|
|
95 GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0xFF);
|
|
96 GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0x9B);
|
|
97 pRenderer->BeginScene();
|
|
98 if ( GetCurrentMenuID() != MENU_SAVELOAD && GetCurrentMenuID() != MENU_LOADINGPROC )
|
|
99 {
|
|
100 pRenderer->DrawTextureIndexed(8, 8, uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0);
|
|
101 if ( a4 )
|
|
102 {
|
|
103 v2 = uTextureID_save_up;
|
|
104 v3 = uTextureID_LS_saveU;
|
|
105 }
|
|
106 else
|
|
107 {
|
|
108 v2 = uTextureID_load_up;
|
|
109 v3 = uTextureID_LS_loadU;
|
|
110 }
|
|
111 pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0));
|
|
112 pRenderer->DrawTextureIndexed(18, 139, (Texture *)(v2 != -1 ? &pIcons_LOD->pTextures[v2] : 0));
|
|
113 pRenderer->DrawTextureIndexed(351, 302, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0));
|
|
114 v1 = 255;
|
|
115 }
|
|
116 if ( pSavegameUsedSlots[uLoadGameUI_SelectedSlot] )
|
|
117 {
|
|
118 memset(&pWindow, 0, 0x54);
|
|
119 pWindow.uFrameX = pGUIWindow_CurrentMenu->uFrameX + 240;
|
|
120 v4 = pGUIWindow_CurrentMenu->uFrameY - pFontSmallnum->uFontHeight;
|
|
121 pWindow.uFrameWidth = 220;
|
|
122 v4 += 157;
|
|
123 pWindow.uFrameY = v4;
|
|
124 v5 = pFontSmallnum->uFontHeight;
|
|
125 pWindow.uFrameZ = pWindow.uFrameX + 219;
|
|
126 pWindow.uFrameHeight = v5;
|
|
127 pWindow.uFrameW = v5 + v4 - 1;
|
|
128 v6 = uLoadGameUI_SelectedSlot;
|
|
129 if (pSavegameThumbnails[uLoadGameUI_SelectedSlot].pPixels)
|
|
130 {
|
|
131 pRenderer->DrawTextureRGB(pGUIWindow_CurrentMenu->uFrameX + 276, pGUIWindow_CurrentMenu->uFrameY + 171, pSavegameThumbnails + uLoadGameUI_SelectedSlot);
|
|
132 v6 = uLoadGameUI_SelectedSlot;
|
|
133 }
|
|
134 pMapID = pMapStats->GetMapInfo(pSavegameHeader[v6].pLocationName);
|
|
135 pWindow.DrawTitleText(pFontSmallnum, 0, 0, 0, pMapStats->pInfos[pMapID].pName, 3);
|
|
136 v8 = (signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60;
|
|
137 pMinutes = (int)((signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60) >> 32;
|
|
138 v9 = v8;
|
|
139 v8 /= 60i64;
|
|
140 pAMPM2 = v8;
|
|
141 v10 = (unsigned int)v8 / 24;
|
|
142 pSaveFiles = v10;
|
|
143 v11 = (unsigned int)(v10 / 7);
|
|
144 v12 = v11;
|
|
145 LODWORD(v13) = (unsigned int)v11 >> 2;
|
|
146 HIDWORD(v13) = HIDWORD(v11);
|
|
147 pMonthNum = v13 % 12;
|
|
148 pYear = v13 / 12;
|
|
149 pMinutes = (int)__PAIR__(pMinutes, v9) % 60;
|
|
150 pOurHour = pAMPM2 % 24;
|
|
151 v14 = (unsigned __int64)(pAMPM2 % 24) >> 32;
|
|
152 LODWORD(pAMPM2) = pAMPM2 % 24;
|
|
153 HIDWORD(pOurHour) = pSaveFiles % 28;
|
|
154 pYear += game_starting_year;
|
|
155 v16 = v12 & 3;
|
|
156 pWindow.uFrameY = pGUIWindow_CurrentMenu->uFrameY + 261;
|
|
157 HIDWORD(pAMPM2) = v14 == 0 && ((signed int)v14 > 0 || (unsigned int)pOurHour >= 12)
|
|
158 && (signed int)v14 <= 0 && (v14 != 0 || (unsigned int)pOurHour < 24);
|
|
159 if ( v14 != 0 || (signed int)v14 <= 0 && (unsigned int)pOurHour <= 12 )
|
|
160 {
|
|
161 if ( !(v14 | (unsigned int)pOurHour) )
|
|
162 {
|
|
163 pSaveFiles = 0;
|
|
164 pHour = 12;
|
|
165 goto LABEL_23;
|
|
166 }
|
|
167 }
|
|
168 else
|
|
169 {
|
|
170 v14 = (__PAIR__(v14, (unsigned int)pOurHour) - 12) >> 32;
|
|
171 LODWORD(pOurHour) = pOurHour - 12;
|
|
172 }
|
|
173 pHour = pOurHour;
|
|
174 pSaveFiles = v14;
|
|
175 LABEL_23:
|
|
176 auto day = aDayNames[HIDWORD(pOurHour) % 7];
|
|
177 auto ampm = aAMPMNames[HIDWORD(pAMPM2)];
|
|
178 auto month = aMonthNames[pMonthNum];
|
|
179 //sprintf(pTmpBuf, "%s %d:%02d%s\n%d %s %d", _d, v17, (int)32, _a, 3, _m, pFilesID);
|
|
180 sprintf(pTmpBuf, "%s %d:%02d%s\n%d %s %d", day, pHour, pMinutes, ampm, 7 * v16 + HIDWORD(pOurHour) % 7 + 1, month, pYear);
|
|
181 pWindow.DrawTitleText(pFontSmallnum, 0, 0, 0, pTmpBuf, 3u);
|
|
182 v1 = 255;
|
|
183 }
|
|
184 if ( pGUIWindow_CurrentMenu->field_40 == 2 )
|
|
185 {
|
|
186 pGUIWindow_CurrentMenu->field_40 = 0;
|
|
187 strcpy((char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot, (const char *)pKeyActionMap->pPressedKeysBuffer);
|
|
188 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
|
|
189 {
|
|
190 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)83;
|
|
191 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
|
|
192 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
|
|
193 ++pMessageQueue_50CBD0->uNumMessages;
|
|
194 }*/
|
|
195 pMessageQueue_50CBD0->AddMessage(UIMSG_SaveGame, 0, 0);
|
|
196 }
|
|
197 else
|
|
198 {
|
|
199 if ( pGUIWindow_CurrentMenu->field_40 == 3 )
|
|
200 pGUIWindow_CurrentMenu->field_40 = 0;
|
|
201 }
|
|
202 if (GetCurrentMenuID() == MENU_LOADINGPROC)
|
|
203 {
|
|
204 //v18 = pGlobalTXT_LocalizationStrings[135];
|
|
205 v19 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[135]);//"Загрузка"
|
|
206 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v19 + 25, 220, 0, pGlobalTXT_LocalizationStrings[135], 0, 0, 0);
|
|
207 v20 = (const char *)(pSavegameHeader + uLoadGameUI_SelectedSlot);
|
|
208 v21 = pFontSmallnum->AlignText_Center(0xBA, (const char *)pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
|
|
209 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v21 + 25, 0x106, 0, v20, 185, 0);
|
|
210 //v22 = pGlobalTXT_LocalizationStrings[165];
|
|
211 v23 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[165]);//"Пожалуйста, пожождите"
|
|
212 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v23 + 25, 304, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0);
|
|
213 }
|
|
214 else
|
|
215 {
|
|
216 if ( a4 )
|
|
217 pSaveFiles = 40;
|
|
218 else
|
|
219 pSaveFiles = uNumSavegameFiles;
|
|
220 a4 = 199;
|
|
221 pFilesID = pSaveListPosition;
|
|
222 pSlotName = (const char *)(&pSavegameHeader[pSaveListPosition]);//draw name for save slot
|
|
223 do
|
|
224 {
|
|
225 if ( pFilesID >= (signed int)pSaveFiles )
|
|
226 break;
|
|
227 short clr;
|
|
228 HIDWORD(pAMPM2) = clr = (pFilesID == uLoadGameUI_SelectedSlot ? GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v1, v1, 0x64) : 0);
|
|
229 if ( pGUIWindow_CurrentMenu->field_40 != 1 || pFilesID != uLoadGameUI_SelectedSlot )
|
|
230 {
|
|
231 pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 0x1B, a4, clr, pSlotName, 185, 0);
|
|
232 }
|
|
233 else
|
|
234 {
|
|
235 v25 = pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 0x1B, a4, clr, (const char *)pKeyActionMap->pPressedKeysBuffer, 175, 1);
|
|
236 pGUIWindow_CurrentMenu->DrawFlashingInputCursor(v25 + 27, a4, pFontSmallnum);
|
|
237 }
|
|
238 a4 += 21;
|
|
239 ++pFilesID;
|
|
240 pSlotName += 100;
|
|
241 }
|
|
242 while ( a4 < 346 );
|
|
243 }
|
|
244 pRenderer->EndScene();
|
|
245 }
|
|
246 // 6A0C9C: using guessed type int dword_6A0C9C;
|
|
247
|
|
248 //----- (004606F7) --------------------------------------------------------
|
|
249 void __cdecl GameUI_MainMenu_DrawLoad()
|
|
250 {
|
|
251 GameUI_MainMenu_DoDrawLoad(0);
|
|
252 }
|
|
253
|
|
254 //----- (004606FE) --------------------------------------------------------
|
|
255 void __cdecl sub_4606FE()
|
|
256 {
|
|
257 GameUI_MainMenu_DoDrawLoad(1);
|
|
258 }
|
|
259
|
|
260
|
|
261 void __cdecl FreeSavegameThumbnails()
|
|
262 {
|
|
263 for (int i = 0; i < 40; ++i)
|
|
264 //pAllocator->FreeChunk(pSavegameThumbnails[i].pPixels);
|
|
265 pSavegameThumbnails[i].Release();
|
|
266 }
|