Mercurial > mm7
comparison UISaveLoad.cpp @ 847:e398541aee60
fixed party save position
author | Gloval |
---|---|
date | Sat, 30 Mar 2013 19:36:05 +0400 |
parents | dfd683c4f538 |
children | a78f08dbeb88 |
comparison
equal
deleted
inserted
replaced
846:39503542470c | 847:e398541aee60 |
---|---|
1 #include <assert.h> | 1 #include <assert.h> |
2 | 2 #include <io.h> |
3 #include "MM7.h" | 3 #include "MM7.h" |
4 | 4 |
5 #include "MapInfo.h" | 5 #include "MapInfo.h" |
6 #include "Game.h" | 6 #include "Game.h" |
7 #include "GUIWindow.h" | 7 #include "GUIWindow.h" |
132 v6 = uLoadGameUI_SelectedSlot; | 132 v6 = uLoadGameUI_SelectedSlot; |
133 } | 133 } |
134 pMapID = pMapStats->GetMapInfo(pSavegameHeader[v6].pLocationName); | 134 pMapID = pMapStats->GetMapInfo(pSavegameHeader[v6].pLocationName); |
135 pWindow.DrawTitleText(pFontSmallnum, 0, 0, 0, pMapStats->pInfos[pMapID].pName, 3); | 135 pWindow.DrawTitleText(pFontSmallnum, 0, 0, 0, pMapStats->pInfos[pMapID].pName, 3); |
136 v8 = (signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60; | 136 v8 = (signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60; |
137 pMinutes = (int)((signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60) >> 32; | 137 pMinutes = (int)(((signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60) >> 32); |
138 v9 = v8; | 138 v9 = v8; |
139 v8 /= 60i64; | 139 v8 /= 60i64; |
140 pAMPM2 = v8; | 140 pAMPM2 = v8; |
141 v10 = (unsigned int)v8 / 24; | 141 v10 = (unsigned int)v8 / 24; |
142 pSaveFiles = v10; | 142 pSaveFiles = v10; |
154 pYear += game_starting_year; | 154 pYear += game_starting_year; |
155 v16 = v12 & 3; | 155 v16 = v12 & 3; |
156 pWindow.uFrameY = pGUIWindow_CurrentMenu->uFrameY + 261; | 156 pWindow.uFrameY = pGUIWindow_CurrentMenu->uFrameY + 261; |
157 HIDWORD(pAMPM2) = v14 == 0 && ((signed int)v14 > 0 || (unsigned int)pOurHour >= 12) | 157 HIDWORD(pAMPM2) = v14 == 0 && ((signed int)v14 > 0 || (unsigned int)pOurHour >= 12) |
158 && (signed int)v14 <= 0 && (v14 != 0 || (unsigned int)pOurHour < 24); | 158 && (signed int)v14 <= 0 && (v14 != 0 || (unsigned int)pOurHour < 24); |
159 if ( v14 != 0 || (signed int)v14 <= 0 && (unsigned int)pOurHour <= 12 ) | 159 if ( v14 != 0 || ((signed int)v14 <= 0) && (unsigned int)pOurHour <= 12 ) |
160 { | 160 { |
161 if ( !(v14 | (unsigned int)pOurHour) ) | 161 if ( !(v14 | (unsigned int)pOurHour) ) |
162 { | 162 { |
163 pSaveFiles = 0; | 163 pSaveFiles = 0; |
164 pHour = 12; | 164 pHour = 12; |
262 { | 262 { |
263 for (int i = 0; i < 40; ++i) | 263 for (int i = 0; i < 40; ++i) |
264 //pAllocator->FreeChunk(pSavegameThumbnails[i].pPixels); | 264 //pAllocator->FreeChunk(pSavegameThumbnails[i].pPixels); |
265 pSavegameThumbnails[i].Release(); | 265 pSavegameThumbnails[i].Release(); |
266 } | 266 } |
267 | |
268 //----- (0045E361) -------------------------------------------------------- | |
269 void __fastcall GameUI_DrawLoadMenu(unsigned int uDialogueType) | |
270 { | |
271 unsigned int v1; // ebp@5 | |
272 unsigned int v2; // eax@5 | |
273 //signed int v3; // ebp@11 | |
274 FILE *v4; // eax@14 | |
275 FILE *v5; // eax@18 | |
276 unsigned int v6; // eax@25 | |
277 GUIButton *v7; // eax@27 | |
278 const char *v8; // [sp-8h] [bp-26Ch]@25 | |
279 //char *v9; // [sp-4h] [bp-268h]@19 | |
280 enum TEXTURE_TYPE v10; // [sp-4h] [bp-268h]@25 | |
281 unsigned int uDialogueType_; // [sp+10h] [bp-254h]@1 | |
282 //RGBTexture *pTex; // [sp+10h] [bp-254h]@12 | |
283 //SavegameHeader *Dest; // [sp+14h] [bp-250h]@12 | |
284 //const char *Str1; // [sp+18h] [bp-24Ch]@12 | |
285 LODWriteableFile pLODFile; // [sp+1Ch] [bp-248h]@1 | |
286 int v16; // [sp+260h] [bp-4h]@1 | |
287 | |
288 uDialogueType_ = uDialogueType; | |
289 dword_6BE138 = -1; | |
290 pIcons_LOD->_inlined_sub2(); | |
291 | |
292 memset(pSavegameUsedSlots, 0, sizeof(pSavegameUsedSlots)); | |
293 memset(pSavegameThumbnails, 0, 45 * sizeof(RGBTexture)); | |
294 uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE); | |
295 uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE); | |
296 uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE); | |
297 uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE); | |
298 uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); | |
299 uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); | |
300 if ( uDialogueType_ ) | |
301 { | |
302 pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); | |
303 if ( pCurrentScreen == SCREEN_SAVEGAME ) | |
304 { | |
305 v1 = uTextureID_save_up; | |
306 v2 = uTextureID_LS_saveU; | |
307 } | |
308 else | |
309 { | |
310 v1 = uTextureID_load_up; | |
311 v2 = uTextureID_LS_loadU; | |
312 } | |
313 pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0)); | |
314 pRenderer->DrawTextureIndexed(18, 141, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0)); | |
315 pRenderer->DrawTextureIndexed(351, 302, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0)); | |
316 } | |
317 else | |
318 { | |
319 pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX); | |
320 } | |
321 pGUIWindow_CurrentMenu = GUIWindow::Create(saveload_dlg_xs[uDialogueType_], saveload_dlg_ys[uDialogueType_], saveload_dlg_zs[uDialogueType_], | |
322 saveload_dlg_ws[uDialogueType_], WINDOW_MainMenu_Load, 0, 0); | |
323 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);// "Reading..." | |
324 pRenderer->Present(); | |
325 pSavegameList->Initialize(0); | |
326 if ( pSaveListPosition > (signed int)uNumSavegameFiles ) | |
327 { | |
328 pSaveListPosition = 0; | |
329 uLoadGameUI_SelectedSlot = 0; | |
330 } | |
331 pLODFile.AllocSubIndicesAndIO(0x12C, 0); | |
332 assert(sizeof(SavegameHeader) == 0x64); | |
333 //v3 = 0; | |
334 for (uint i = 0; i < uNumSavegameFiles; ++i) | |
335 { | |
336 | |
337 sprintf(pTmpBuf, "saves\\%s", pSavegameList->pFileList[i].pSaveFileName); | |
338 if (_access(pTmpBuf, 6)) | |
339 { | |
340 pSavegameUsedSlots[i] = 0; | |
341 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty" | |
342 continue; | |
343 } | |
344 pLODFile.LoadFile(pTmpBuf, 1); | |
345 v4 = pLODFile.FindContainer("header.bin", true); | |
346 if ( v4 ) | |
347 fread(&pSavegameHeader[i], 0x64, 1, v4); | |
348 if ( !_strcmpi(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7" | |
349 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave" | |
350 v5 = pLODFile.FindContainer("image.pcx", true); | |
351 if ( !v5 ) | |
352 { | |
353 pSavegameUsedSlots[i] = 0; | |
354 strcpy(pSavegameList->pFileList[i].pSaveFileName, ""); | |
355 } | |
356 else | |
357 { | |
358 pSavegameThumbnails[i].LoadFromFILE(v5, 0, true); | |
359 pLODFile.CloseWriteFile(); | |
360 pSavegameUsedSlots[i] = 1; | |
361 } | |
362 } | |
363 | |
364 //LABEL_24: | |
365 pLODFile.FreeSubIndexAndIO(); | |
366 if ( pCurrentScreen == SCREEN_SAVEGAME ) | |
367 { | |
368 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); | |
369 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD",TEXTURE_16BIT_PALETTE); | |
370 } | |
371 else | |
372 { | |
373 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); | |
374 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_loadD",TEXTURE_16BIT_PALETTE); | |
375 } | |
376 uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE); | |
377 uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE); | |
378 pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0); | |
379 pGUIWindow_CurrentMenu->CreateButton(21, 219, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0); | |
380 pGUIWindow_CurrentMenu->CreateButton(21, 240, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0); | |
381 pGUIWindow_CurrentMenu->CreateButton(21, 261, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0); | |
382 pGUIWindow_CurrentMenu->CreateButton(21, 282, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0); | |
383 pGUIWindow_CurrentMenu->CreateButton(21, 303, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0); | |
384 pGUIWindow_CurrentMenu->CreateButton(21, 324, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0); | |
385 pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_LoadSlot, 0, 0, "", | |
386 pIcons_LOD->GetTexture(uTextureID_LS_), 0); | |
387 pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", | |
388 pIcons_LOD->GetTexture(uTextureID_x_d), 0); | |
389 pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", | |
390 pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0); | |
391 pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 0x143, 0x11, 0x11, 1, 0, UIMSG_DownArrow, uNumSavegameFiles, 0, "", | |
392 pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0); | |
393 | |
394 } | |
395 | |
396 //----- (0045E93E) -------------------------------------------------------- | |
397 void GameUI_DrawSaveMenu() | |
398 { | |
399 unsigned int v0; // ebp@4 | |
400 unsigned int v1; // eax@4 | |
401 char *v3; // eax@7 | |
402 FILE *v4; // eax@11 | |
403 FILE *v5; // eax@11 | |
404 LODWriteableFile v11; // [sp+1Ch] [bp-248h]@1 | |
405 | |
406 ++pIcons_LOD->uTexturePacksCount; | |
407 if ( !pIcons_LOD->uNumPrevLoadedFiles ) | |
408 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; | |
409 memset(pSavegameUsedSlots, 0, 0xB4u); | |
410 memset(&pSavegameThumbnails, 0, 0x708u); | |
411 uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE); | |
412 uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE); | |
413 uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE); | |
414 uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE); | |
415 uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); | |
416 uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); | |
417 pRenderer->DrawTextureIndexed( 8u, 8u, | |
418 (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); | |
419 if ( pCurrentScreen == SCREEN_SAVEGAME ) | |
420 { | |
421 v0 = uTextureID_save_up; | |
422 v1 = uTextureID_LS_saveU; | |
423 } | |
424 else | |
425 { | |
426 v0 = uTextureID_load_up; | |
427 v1 = uTextureID_LS_loadU; | |
428 } | |
429 pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0)); | |
430 pRenderer->DrawTextureIndexed(0x15Fu, 0x12Eu, | |
431 (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0)); | |
432 pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0)); | |
433 pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0); | |
434 pRenderer->Present(); | |
435 pSavegameList->Initialize(1u); | |
436 v11.AllocSubIndicesAndIO(0x12Cu, 0); | |
437 //v2 = pSavegameUsedSlots; | |
438 // Dest = pSavegameHeader; | |
439 // this_ = pSavegameThumbnails; | |
440 // v8 = (char *)pSavegameList->pSavesNames; | |
441 for (uint i = 0; i < 40; ++i) | |
442 { | |
443 v3 = pSavegameList->pFileList[i].pSaveFileName; | |
444 if ( !*pSavegameList->pFileList[i].pSaveFileName ) | |
445 v3 = "1.mm7"; | |
446 sprintf(pTmpBuf, "saves\\%s", v3); | |
447 if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) ) | |
448 { | |
449 pSavegameUsedSlots[i] = 0; | |
450 strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[LOCSTR_EMPTY]); | |
451 } | |
452 else | |
453 { | |
454 v11.LoadFile(pTmpBuf, 1); | |
455 v4 = v11.FindContainer("header.bin", 1); | |
456 fread(&pSavegameHeader[i], 100, 1u, v4); | |
457 v5 = v11.FindContainer("image.pcx", 1); | |
458 if ( v5 ) | |
459 { | |
460 pSavegameThumbnails[i].LoadFromFILE(v5, 0, 1u); | |
461 v11.CloseWriteFile(); | |
462 pSavegameUsedSlots[i] = 1; | |
463 } | |
464 else | |
465 { | |
466 pSavegameUsedSlots[i] = 0; | |
467 } | |
468 } | |
469 | |
470 } | |
471 | |
472 v11.FreeSubIndexAndIO(); | |
473 uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); | |
474 uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE); | |
475 uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE); | |
476 uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE); | |
477 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_17, 0, 0); | |
478 pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0); | |
479 pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 1u, 0, "", 0); | |
480 pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 2u, 0, "", 0); | |
481 pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 3u, 0, "", 0); | |
482 pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 4u, 0, "", 0); | |
483 pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 5u, 0, "", 0); | |
484 pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 6u, 0, "", 0); | |
485 pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0x69u, 0x28u, 1, 0, UIMSG_LoadSlot, 0, 0, "", | |
486 (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0); | |
487 pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(0x15Eu, 0x12Eu, 0x69u, 0x28u, 1, 0, UIMSG_Cancel, 0, 0, "", | |
488 (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0), 0); | |
489 pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0xC7u, 0x11u, 0x11u, 1, 0, UIMSG_ArrowUp, 0, 0, "", | |
490 (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0); | |
491 pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0x143u, 0x11u, 0x11u, 1, 0, UIMSG_DownArrow, 0x22u, 0, "", | |
492 (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0); | |
493 } |