Mercurial > mm7
view GameUIs.cpp @ 418:913675aac25b
Merge
author | Nomad |
---|---|
date | Sat, 23 Feb 2013 19:34:05 +0200 |
parents | a4a5996fea5b |
children | 88c30918eef7 |
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 "texts.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 pLODFile; // [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, sizeof(pSavegameUsedSlots)); 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(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); if ( pCurrentScreen == SCREEN_SAVEGAME ) { v1 = uTextureID_save_up; v2 = uTextureID_LS_saveU; } else { v1 = uTextureID_load_up; v2 = uTextureID_LS_loadU; } pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0)); pRenderer->DrawTextureIndexed(18, 141, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0)); pRenderer->DrawTextureIndexed(351, 302, (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 ( pSaveListPosition > (signed int)uNumSavegameFiles ) { pSaveListPosition = 0; uLoadGameUI_SelectedSlot = 0; } pLODFile.AllocSubIndicesAndIO(0x12C, 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->pFileList[i].pSaveFileName); if (_access(pTmpBuf, 6)) { pSavegameUsedSlots[i] = 0; strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty" continue; } pLODFile.LoadFile(pTmpBuf, 1); v4 = pLODFile.FindContainer("header.bin", true); if ( v4 ) fread(&pSavegameHeader[i], 0x64, 1, v4); if ( !_strcmpi(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7" strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave" v5 = pLODFile.FindContainer("image.pcx", true); if ( !v5 ) { pSavegameUsedSlots[i] = 0; strcpy(pSavegameList->pFileList[i].pSaveFileName, ""); } else { pSavegameThumbnails[i].LoadFromFILE(v5, 0, true); pLODFile.CloseWriteFile(); pSavegameUsedSlots[i] = 1; } //LABEL_23: //Str1 += 280; //++pTex; //++Dest; //++v3; //if ( v3 >= (signed int)uNumSavegameFiles ) // goto LABEL_24; //} //goto LABEL_22; } //LABEL_24: pLODFile.FreeSubIndexAndIO(); if ( pCurrentScreen == SCREEN_SAVEGAME ) { 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(21, 198, 191, 18, 1, 0, 0xA5, 0, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21, 219, 191, 18, 1, 0, 0xA5, 1, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21, 240, 191, 18, 1, 0, 0xA5, 2, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21, 261, 191, 18, 1, 0, 0xA5, 3, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21, 282, 191, 18, 1, 0, 0xA5, 4, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21, 303, 191, 18, 1, 0, 0xA5, 5, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(21, 324, 191, 18, 1, 0, 0xA5, 6, 0, "", 0); pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, 0xA4, 0, 0, "", (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0); pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, 0xA6, 0, 0, "", (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0), 0); pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, 0xA2, 0, 0, "", (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0); pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 0x143, 0x11, 0x11, 1, 0, 0xA3, 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 GameUI_DrawSaveMenu() { unsigned int v0; // ebp@4 unsigned int v1; // eax@4 char *v3; // eax@7 FILE *v4; // eax@11 FILE *v5; // eax@11 LODWriteableFile v11; // [sp+1Ch] [bp-248h]@1 ++pIcons_LOD->uTexturePacksCount; 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 == SCREEN_SAVEGAME ) { 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; for (uint i = 0; i < 40; ++i) { v3 = pSavegameList->pFileList[i].pSaveFileName; if ( !pSavegameList->pFileList[i].pSaveFileName ) v3 = "1.mm7"; sprintf(pTmpBuf, "saves\\%s", v3); if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) ) { pSavegameUsedSlots[i] = 0; strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[LOCSTR_EMPTY]); } else { v11.LoadFile(pTmpBuf, 1); v4 = v11.FindContainer("header.bin", 1); fread(&pSavegameHeader[i], 100, 1u, v4); v5 = v11.FindContainer("image.pcx", 1); if ( v5 ) { pSavegameThumbnails[i].LoadFromFILE(v5, 0, 1u); v11.CloseWriteFile(); pSavegameUsedSlots[i] = 1; } else { pSavegameUsedSlots[i] = 0; } } } 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); pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0x69u, 0x28u, 1, 0, 0xA4u, 0, 0, "", (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0); pBtnCancel = 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); pBtnArrowUp = 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); pBtnDownArrow = 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); }