Mercurial > might-and-magic-trilogy
view GameUIs.cpp @ 123:05b2d9653abc
15.11.12
author | Ritor1 |
---|---|
date | Thu, 15 Nov 2012 16:36:30 +0600 |
parents | 6c42178c226e |
children | 062e8a8e09bc |
line wrap: on
line source
#include <direct.h> #include <io.h> #include <assert.h> #include "GUIWindow.h" #include "GUIFont.h" #include "LOD.h" #include "SaveLoad.h" #include "Render.h" #include "mm7_data.h" //----- (0045E361) -------------------------------------------------------- void __fastcall GameUI_DrawLoadMenu(unsigned int uDialogueType) { unsigned int v1; // ebp@5 unsigned int v2; // eax@5 //signed int v3; // ebp@11 FILE *v4; // eax@14 FILE *v5; // eax@18 unsigned int v6; // eax@25 GUIButton *v7; // eax@27 const char *v8; // [sp-8h] [bp-26Ch]@25 //char *v9; // [sp-4h] [bp-268h]@19 enum TEXTURE_TYPE v10; // [sp-4h] [bp-268h]@25 unsigned int uDialogueType_; // [sp+10h] [bp-254h]@1 //RGBTexture *pTex; // [sp+10h] [bp-254h]@12 //SavegameHeader *Dest; // [sp+14h] [bp-250h]@12 //const char *Str1; // [sp+18h] [bp-24Ch]@12 LODWriteableFile v15; // [sp+1Ch] [bp-248h]@1 int v16; // [sp+260h] [bp-4h]@1 uDialogueType_ = uDialogueType; dword_6BE138 = -1; ++pIcons_LOD->uTexturePacksCount; v16 = 0; if ( !pIcons_LOD->uNumPrevLoadedFiles ) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; memset(pSavegameUsedSlots, 0, 45 * sizeof(int)); memset(pSavegameThumbnails, 0, 45 * sizeof(RGBTexture)); uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE); uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE); uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE); uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE); uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); if ( uDialogueType_ ) { pRenderer->DrawTextureIndexed( 8u, 8u, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); if ( pCurrentScreen == 11 ) { v1 = uTextureID_save_up; v2 = uTextureID_LS_saveU; } else { v1 = uTextureID_load_up; v2 = uTextureID_LS_loadU; } pRenderer->DrawTextureIndexed(241u, 302u, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0)); pRenderer->DrawTextureIndexed(18u, 141u, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0)); pRenderer->DrawTextureIndexed( 351u, 302u, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0)); } else { pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX); } pGUIWindow_CurrentMenu = GUIWindow::Create( saveload_dlg_xs[uDialogueType_], saveload_dlg_ys[uDialogueType_], saveload_dlg_zs[uDialogueType_], saveload_dlg_ws[uDialogueType_], WINDOW_MainMenu_Load, 0, 0); pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);// "Reading..." pRenderer->Present(); pSavegameList->Initialize(0); if ( dword_6A0C9C > (signed int)uNumSavegameFiles ) { dword_6A0C9C = 0; uLoadGameUI_SelectedSlot = 0; } v15.AllocSubIndicesAndIO(0x12Cu, 0); assert(sizeof(SavegameHeader) == 0x64); //v3 = 0; for (uint i = 0; i < uNumSavegameFiles; ++i) { //Dest = pSavegameHeader; //pTex = pSavegameThumbnails; //Str1 = (const char *)pSavegameList->pSavesNames; //while ( 1 ) //{ sprintf(pTmpBuf, "saves\\%s", pSavegameList->pSavesNames[i]); if (_access(pTmpBuf, 6)) { pSavegameUsedSlots[i] = 0; strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty" continue; } v15.LoadFile(pTmpBuf, 1); v4 = v15.FindContainer("header.bin", true); if ( v4 ) fread(&pSavegameHeader[i], 0x64u, 1u, v4); if ( !_strcmpi(pSavegameList->pSavesNames[i], pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7" strcpy(pSavegameList->pSavesNames[i], pGlobalTXT_LocalizationStrings[16]);// "Autosave" v5 = v15.FindContainer("image.pcx", true); if ( !v5 ) { pSavegameUsedSlots[i] = 0; strcpy(pSavegameList->pSavesNames[i], ""); } else { pSavegameThumbnails[i].LoadFromFILE(v5, 0, true); v15.CloseWriteFile(); pSavegameUsedSlots[i] = 1; } //LABEL_23: //Str1 += 280; //++pTex; //++Dest; //++v3; //if ( v3 >= (signed int)uNumSavegameFiles ) // goto LABEL_24; //} //goto LABEL_22; } LABEL_24: v15.FreeSubIndexAndIO(); if ( pCurrentScreen == 11 ) { v6 = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); v10 = (TEXTURE_TYPE)2; v8 = "LS_saveD"; } else { v6 = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); v10 = (TEXTURE_TYPE)2; v8 = "LS_loadD"; } uTextureID_x_d = v6; uTextureID_LS_ = pIcons_LOD->LoadTexture(v8, v10); uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE); uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE); pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 191u, 18u, 1, 0, 0xA5u, 0, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21u, 219u, 191u, 18u, 1, 0, 0xA5u, 1u, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21u, 240u, 191u, 18u, 1, 0, 0xA5u, 2u, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21u, 261u, 191u, 18u, 1, 0, 0xA5u, 3u, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21u, 282u, 191u, 18u, 1, 0, 0xA5u, 4u, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21u, 303u, 191u, 18u, 1, 0, 0xA5u, 5u, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21u, 324u, 191u, 18u, 1, 0, 0xA5u, 6u, 0, "", 0); ptr_69BD64 = pGUIWindow_CurrentMenu->CreateButton( 241u, 302u, 105u, 40u, 1, 0, 0xA4u, 0, 0, "", (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0); ptr_69BD60 = pGUIWindow_CurrentMenu->CreateButton( 350u, 302u, 105u, 40u, 1, 0, 0xA6u, 0, 0, "", (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0), 0); ptr_69BD5C = pGUIWindow_CurrentMenu->CreateButton( 215u, 199u, 17u, 17u, 1, 0, 0xA2u, 0, 0, "", (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0); v7 = pGUIWindow_CurrentMenu->CreateButton( 215u, 0x143u, 0x11u, 0x11u, 1, 0, 0xA3u, uNumSavegameFiles, 0, "", (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0); v16 = -1; ptr_69BD58 = v7; } //----- (0045E93E) -------------------------------------------------------- void __cdecl GameUI_DrawSaveMenu() { unsigned int v0; // ebp@4 unsigned int v1; // eax@4 unsigned int *v2; // ebp@6 char *v3; // eax@7 FILE *v4; // eax@11 FILE *v5; // eax@11 const char *v6; // ST64_4@14 GUIButton *v7; // eax@16 char *v8; // [sp+10h] [bp-254h]@6 SavegameHeader *Dest; // [sp+14h] [bp-250h]@6 RGBTexture *this_; // [sp+18h] [bp-24Ch]@6 LODWriteableFile v11; // [sp+1Ch] [bp-248h]@1 int v12; // [sp+260h] [bp-4h]@1 ++pIcons_LOD->uTexturePacksCount; v12 = 0; if ( !pIcons_LOD->uNumPrevLoadedFiles ) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; memset(pSavegameUsedSlots, 0, 0xB4u); memset(&pSavegameThumbnails, 0, 0x708u); uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE); uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE); uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE); uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE); uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); pRenderer->DrawTextureIndexed( 8u, 8u, (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); if ( pCurrentScreen == 11 ) { v0 = uTextureID_save_up; v1 = uTextureID_LS_saveU; } else { v0 = uTextureID_load_up; v1 = uTextureID_LS_loadU; } pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0)); pRenderer->DrawTextureIndexed( 0x15Fu, 0x12Eu, (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0)); pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0)); pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0); pRenderer->Present(); pSavegameList->Initialize(1u); v11.AllocSubIndicesAndIO(0x12Cu, 0); v2 = pSavegameUsedSlots; Dest = pSavegameHeader; this_ = pSavegameThumbnails; v8 = (char *)pSavegameList->pSavesNames; do { v3 = v8; if ( !*v8 ) v3 = "1.mm7"; sprintf(pTmpBuf, "saves\\%s", v3); if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) ) { v6 = pGlobalTXT_LocalizationStrings[72]; *v2 = 0; strcpy(Dest->pName, v6); } else { v11.LoadFile(pTmpBuf, 1); v4 = v11.FindContainer("header.bin", 1); fread(Dest, 0x64u, 1u, v4); v5 = v11.FindContainer("image.pcx", 1); if ( v5 ) { this_->LoadFromFILE(v5, 0, 1u); v11.CloseWriteFile(); *v2 = 1; } else { *v2 = 0; } } v8 += 280; ++this_; ++Dest; ++v2; } while ( (signed int)v8 < (signed int)&_69FBB4_ptr_iterator_end ); v11.FreeSubIndexAndIO(); uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE); uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE); uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE); pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_Chest|WINDOW_MainMenu|0x2), 0, 0); pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, 0xA5u, 0, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, 0xA5u, 1u, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, 0xA5u, 2u, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, 0xA5u, 3u, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, 0xA5u, 4u, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, 0xA5u, 5u, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, 0xA5u, 6u, 0, "", 0); ptr_69BD64 = pGUIWindow_CurrentMenu->CreateButton( 0xF1u, 0x12Eu, 0x69u, 0x28u, 1, 0, 0xA4u, 0, 0, "", (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0); ptr_69BD60 = pGUIWindow_CurrentMenu->CreateButton( 0x15Eu, 0x12Eu, 0x69u, 0x28u, 1, 0, 0xA6u, 0, 0, "", (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0), 0); ptr_69BD5C = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0xC7u, 0x11u, 0x11u, 1, 0, 0xA2u, 0, 0, "", (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0); v7 = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0x143u, 0x11u, 0x11u, 1, 0, 0xA3u, 0x22u, 0, "", (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0); v12 = -1; ptr_69BD58 = v7; }