Mercurial > might-and-magic-trilogy
changeset 12:ab992012b95f
Слияние
author | Серик@ПончиК |
---|---|
date | Wed, 10 Oct 2012 23:56:16 +0600 |
parents | b9ab3a5a2131 (current diff) 4acbadf78023 (diff) |
children | 17150bdf321e |
files | |
diffstat | 5 files changed, 484 insertions(+), 133 deletions(-) [+] |
line wrap: on
line diff
--- a/GUIWindow.h Wed Oct 10 23:56:06 2012 +0600 +++ b/GUIWindow.h Wed Oct 10 23:56:16 2012 +0600 @@ -50,6 +50,7 @@ WINDOW_1F = 31, WINDOW_FinalWindow = 0x46, WINDOW_5A = 0x5A, + WINDOW_5E = 0x5E, WINDOW_KeyMappingOptions = 0x69, WINDOW_VideoOptions = 0x6A }; @@ -225,8 +226,8 @@ uNumMessages(0) {} - void PopMessage(enum UIMessageType *pType, int *pParam, int *a4); - void SendMessage(int a2, int a3, unsigned int a4); + void PopMessage(UIMessageType *pMsg, int *pParam, int *a4); + void SendMessage(UIMessageType msg, int param, unsigned int a4); unsigned int uNumMessages; GUIMessage pMessages[40];
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GameUIs.cpp Wed Oct 10 23:56:16 2012 +0600 @@ -0,0 +1,373 @@ +#include <direct.h> +#include <io.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 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); + if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 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 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0)); + } + else + { + pRenderer->DrawTextureRGB(0, 0, &stru_506F20); + } + 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); + v3 = 0; + if ( (signed int)uNumSavegameFiles > 0 ) + { + Dest = pSavegameHeader; + pTex = pSavegameThumbnails; + Str1 = (const char *)pSavegameList->pSavesNames; + while ( 1 ) + { + sprintf(pTmpBuf, "saves\\%s", Str1); + if ( _access(pTmpBuf, 6) ) + break; + v15.LoadFile(pTmpBuf, 1); + v4 = v15.FindContainer("header.bin", true); + if ( v4 ) + fread(Dest, 0x64u, 1u, v4); + if ( !_strcmpi(Str1, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7" + strcpy(Dest->pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave" + v5 = v15.FindContainer("image.pcx", true); + if ( !v5 ) + { + v9 = nullstring; +LABEL_22: + pSavegameUsedSlots[v3] = 0; + strcpy(Dest->pName, v9); + goto LABEL_23; + } + pTex->LoadFromFILE(v5, 0, true); + v15.CloseWriteFile(); + pSavegameUsedSlots[v3] = 1; +LABEL_23: + Str1 += 280; + ++pTex; + ++Dest; + ++v3; + if ( v3 >= (signed int)uNumSavegameFiles ) + goto LABEL_24; + } + v9 = pGlobalTXT_LocalizationStrings[72]; // "Empty" + goto LABEL_22; + } +LABEL_24: + v15.FreeSubIndexAndIO(); + if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 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, nullstring, 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 219u, 191u, 18u, 1, 0, 0xA5u, 1u, 0, nullstring, 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 240u, 191u, 18u, 1, 0, 0xA5u, 2u, 0, nullstring, 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 261u, 191u, 18u, 1, 0, 0xA5u, 3u, 0, nullstring, 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 282u, 191u, 18u, 1, 0, 0xA5u, 4u, 0, nullstring, 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 303u, 191u, 18u, 1, 0, 0xA5u, 5u, 0, nullstring, 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 324u, 191u, 18u, 1, 0, 0xA5u, 6u, 0, nullstring, 0); + ptr_69BD64 = pGUIWindow_CurrentMenu->CreateButton( + 241u, + 302u, + 105u, + 40u, + 1, + 0, + 0xA4u, + 0, + 0, + nullstring, + (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, + nullstring, + (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, + nullstring, + (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, + nullstring, + (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 ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 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"; + sprintfex(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, nullstring, 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, 0xA5u, 1u, 0, nullstring, 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, 0xA5u, 2u, 0, nullstring, 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, 0xA5u, 3u, 0, nullstring, 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, 0xA5u, 4u, 0, nullstring, 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, 0xA5u, 5u, 0, nullstring, 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, 0xA5u, 6u, 0, nullstring, 0); + ptr_69BD64 = pGUIWindow_CurrentMenu->CreateButton( + 0xF1u, + 0x12Eu, + 0x69u, + 0x28u, + 1, + 0, + 0xA4u, + 0, + 0, + nullstring, + (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, + nullstring, + (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, + nullstring, + (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, + nullstring, + (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), + 0); + v12 = -1; + ptr_69BD58 = v7; +} \ No newline at end of file
--- a/mm7_2.cpp Wed Oct 10 23:56:06 2012 +0600 +++ b/mm7_2.cpp Wed Oct 10 23:56:16 2012 +0600 @@ -13297,15 +13297,15 @@ SetCurrentMenuID(MENU_MAIN); SetForegroundWindow(hWnd); SendMessageA(hWnd, WM_ACTIVATEAPP, 1, 0); - while (uCurrentMenuID == MENU_MAIN || - uCurrentMenuID == MENU_SAVELOAD) + while (GetCurrentMenuID() == MENU_MAIN || + GetCurrentMenuID() == MENU_SAVELOAD) { POINT pt; pMouse->GetCursorPos(&pt); //uMouseX = pMouse->GetCursorPos(&v18)->x; //uMouseY = pMouse->GetCursorPos(&v19)->y; v15 = pWindow_MainMenu; - if ( uCurrentMenuID == MENU_SAVELOAD) + if ( GetCurrentMenuID() == MENU_SAVELOAD) { if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 12 ) { @@ -13441,7 +13441,7 @@ Render *v5; // ecx@14 HANDLE v6; // eax@32 Keyboard *v7; // eax@33 - HDC v9; // edi@41 + //HDC v9; // edi@41 HDC v10; // edi@50 int v11; // esi@50 char v12; // zf@132 @@ -13475,6 +13475,10 @@ int pXY[2]; // [sp+64h] [bp-8h]@261 int a2; // [sp+7Ch] [bp+10h]@50 + switch (Msg) + { + case WM_SETTEXT: return DefWindowProcW(hWnd, Msg, wParam, lParam); + }; v4 = lParam; if ( Msg > WM_SYSCOMMAND ) @@ -13996,15 +14000,18 @@ } return 0; } - if ( Msg == 1 ) - { - v9 = GetDC(hWnd); - if ( GetDeviceCaps(v9, BITSPIXEL) < 8 ) - { - ReleaseDC(hWnd, v9); - Abortf("You must be running in 256 color mode or higher. You can change the screen depth with the control panel display icon."); - } - ReleaseDC(hWnd, v9); + if (Msg == WM_CREATE) + { + auto hDC = GetDC(hWnd); + { + if (GetDeviceCaps(hDC, BITSPIXEL) < 8) + { + ReleaseDC(hWnd, hDC); + Log::Warning(L"You must be running in 256 color mode or higher."); + Abortf("You must be running in 256 color mode or higher. You can change the screen depth with the control panel display icon."); + } + } + ReleaseDC(hWnd, hDC); return 0; } if ( Msg == WM_DESTROY ) @@ -14626,13 +14633,22 @@ //----- (004651F4) -------------------------------------------------------- bool MM7_Initialize() { - //int v32; // eax@78 - //int v33; // eax@81 - //int v34; // eax@84 - //int v35; // eax@87 - //unsigned int v36; // eax@91 - //float v37; // ST2C_4@94 - //HWND v38; // [sp-Ch] [bp-170h]@3 + wchar_t pCurrentDir[1024]; + _wgetcwd(pCurrentDir, 1024); + + wchar_t pMM6IniFile[1024]; + wsprintf(pMM6IniFile, L"%s\\mm6.ini", pCurrentDir); + + bCanLoadFromCD = GetPrivateProfileIntW(L"settings", L"use_cd", 1, pMM6IniFile); + if (bNoCD) + bCanLoadFromCD = false; + if (bCanLoadFromCD) + { + if (!FindMM7CD(hWnd, &cMM7GameCDDriveLetter)) + return false; + } + + srand(GetTickCount()); /*GetDiskFreeSpaceA(0, &SectorsPerCluster, &BytesPerSector, &hdc, &TotalNumberOfClusters); @@ -14660,7 +14676,7 @@ wcxw.hIcon = wcxw.hIconSm = LoadIconW(wcxw.hInstance, L"MM7_ICON"); wcxw.lpszMenuName = nullptr; wcxw.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH); - wcxw.lpszClassName = L"Might and Magic Trilogy"; + wcxw.lpszClassName = L"M&MTrilogy"; } if (!RegisterClassExW(&wcxw)) { @@ -14701,6 +14717,7 @@ hOSMenu = nullptr, wcxw.hInstance, nullptr); + SetWindowTextW(hWnd, L"Might and Magic VII"); SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); @@ -14734,12 +14751,6 @@ return false; } - - wchar_t pCurrentDir[1024]; - _wgetcwd(pCurrentDir, 1024); - - wchar_t pMM6IniFile[1024]; - wsprintf(pMM6IniFile, L"%s\\mm6.ini", pCurrentDir); pParty = new Party; pParty->uWalkSpeed = GetPrivateProfileIntW(L"debug", L"walkspeed", 384, pMM6IniFile); @@ -14772,18 +14783,8 @@ MoveWindow(hWnd, uWindowX, uWindowY, rcClient.left - rcClient.right - rcWindow.left + rcWindow.right + 640, rcClient.top - rcClient.bottom - rcWindow.top + rcWindow.bottom + 480, 0); - - - bCanLoadFromCD = GetPrivateProfileIntW(L"settings", L"use_cd", 1, pMM6IniFile); - if (bNoCD) - bCanLoadFromCD = false; - if (bCanLoadFromCD) - { - if (!FindMM7CD(hWnd, &cMM7GameCDDriveLetter)) - return false; - } - ShowWindow(hWnd, SW_SHOWNORMAL); + pIcons_LOD = new LODFile_IconsBitmaps; if (!pIcons_LOD->LoadIconsOrEvents("data\\icons.lod")) {
--- a/mm7_5.cpp Wed Oct 10 23:56:06 2012 +0600 +++ b/mm7_5.cpp Wed Oct 10 23:56:16 2012 +0600 @@ -3457,65 +3457,53 @@ continue; } - if ( (signed int)v45 > 75 ) - { - if ( v45 > UIMSG_A3 ) - { - if ( v45 == UIMSG_A4 ) - { - v43 = 0; - v39 = (int)ptr_69BD64; - v8 = pGUIWindow_CurrentMenu->uFrameY + 302; - v37 = (WindowType)94; - v18 = pGUIWindow_CurrentMenu->uFrameX + 241; -LABEL_133: - v35 = 28; - v33 = 61; -LABEL_134: - GUIWindow::Create(v18, v8, v33, v35, v37, v39, v43); - continue; - } - if ( v45 == UIMSG_A5 ) - { - if ( pGUIWindow_CurrentMenu->field_40 == 1 ) - pKeyActionMap->_459ED1(0); - if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 11 + + switch (v45) + { + case UIMSG_A5: // WINDOW_5A + { + //main menu save/load wnd clicking on savegame lines + if (pGUIWindow_CurrentMenu->field_40 == 1) + pKeyActionMap->_459ED1(0); + if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 11 || uLoadGameUI_SelectedSlot != *(int *)uClass + dword_6A0C9C ) - { + { + //load clicked line v26 = *(int *)uClass + dword_6A0C9C; if ( dword_6BE138 == *(int *)uClass + dword_6A0C9C ) { - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_A4; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - v27 = pMessageQueue_50CBD0->uNumMessages + 1; - v28 = __OFSUB__(pMessageQueue_50CBD0->uNumMessages + 1, 40); - v12 = (signed int)pMessageQueue_50CBD0->uNumMessages - 39 < 0; - ++pMessageQueue_50CBD0->uNumMessages; - if ( v12 ^ v28 ) - { - pMessageQueue_50CBD0->pMessages[v27].eType = (UIMessageType)82; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - } - } + pMessageQueue_50CBD0->SendMessage(UIMSG_A4, 0, 0); + pMessageQueue_50CBD0->SendMessage(UIMSG_LoadGame, 0, 0); } uLoadGameUI_SelectedSlot = v26; dword_6BE138 = v26; - } - else - { + } + else + { + //typing in the line pKeyActionMap->_459E5A(0, 19, pGUIWindow_CurrentMenu); strcpy( (char *)pKeyActionMap->pPressedKeysBuffer, - (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot); + pSavegameHeader[uLoadGameUI_SelectedSlot].pName); pKeyActionMap->uNumKeysPressed = strlen((const char *)pKeyActionMap->pPressedKeysBuffer); - } - continue; - } + } + } + continue; + + + case UIMSG_A4: + { + GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 241, + pGUIWindow_CurrentMenu->uFrameY + 302, + 61, 28, WINDOW_5E, (int)ptr_69BD64, 0); + } + continue; + } + + if ( (signed int)v45 > 75 ) + { + if ( v45 > UIMSG_A3 ) + { if ( v45 == UIMSG_A6 ) { v43 = 0; @@ -3523,7 +3511,10 @@ v8 = pGUIWindow_CurrentMenu->uFrameY + 302; v37 = (WindowType)95; v18 = pGUIWindow_CurrentMenu->uFrameX + 350; - goto LABEL_133; + v35 = 28; + v33 = 61; + GUIWindow::Create(v18, v8, v33, v35, v37, v39, v43); + continue; } if ( v45 == UIMSG_AB ) { @@ -3798,7 +3789,8 @@ v35 = 0; v33 = 0; v18 = v7->uFrameX + 215; - goto LABEL_134; + GUIWindow::Create(v18, v8, v33, v35, v37, v39, v43); + continue; } } } @@ -14923,6 +14915,24 @@ case WINDOW_MainMenu_Load: GameUI_MainMenu_DrawLoad(); continue; + + case WINDOW_5E: // window that initiates savegame loading + { + if (v0->str_48 != (char *)1) + pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + auto v20 = (GUIButton *)v0->ptr_1C; + pRenderer->DrawTextureIndexed(v0->uFrameX, v0->uFrameY, v20->pTextures[0]); + v21 = v0->str_48; + viewparams->bRedrawGameUI = 1; + if ( v21 && v21 != (char *)1 ) + ((GUIButton *)v20)->DrawLabel(v21, pFontCreate, 0, 0); + v0->Release(); + if (uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11) + pMessageQueue_50CBD0->SendMessage(UIMSG_SaveGame, 0, 0); + else + pMessageQueue_50CBD0->SendMessage(UIMSG_LoadGame, 0, 0); + } + continue; } @@ -15157,34 +15167,6 @@ viewparams->bRedrawGameUI = 1; goto LABEL_134; } - if ( v19 == 1 ) - { - if ( v0->str_48 != (char *)1 ) - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); - v20 = v0->ptr_1C; - pRenderer->DrawTextureIndexed(v0->uFrameX, v0->uFrameY, *((Texture **)v20 + 15)); - v21 = v0->str_48; - viewparams->bRedrawGameUI = 1; - if ( v21 && v21 != (char *)1 ) - ((GUIButton *)v20)->DrawLabel(v21, pFontCreate, 0, 0); - v0->Release(); - if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11 ) - { - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)83; - goto LABEL_152; - } - } - else - { - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)82; - goto LABEL_152; - } - } - } } else { @@ -16462,14 +16444,8 @@ v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; } - v11 = i->uControlParam; - if ( v10 < 40 ) - { - pMessageQueue_50CBD0->pMessages[v10].eType = (UIMessageType)i->uControlID; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v11; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - } + //v11 = i->uControlParam; + pMessageQueue_50CBD0->SendMessage((UIMessageType)i->uControlID, i->uControlParam, 0); return; } goto LABEL_45;
--- a/mm7_6.cpp Wed Oct 10 23:56:06 2012 +0600 +++ b/mm7_6.cpp Wed Oct 10 23:56:16 2012 +0600 @@ -5603,7 +5603,7 @@ if ( pParty->uFlags & 0x30 && v12 != 4 || rand() % 100 >= amount && v731 != 4 ) goto LABEL_200; byte_50C0C0 = LOBYTE(v3->uPlayerID); - pMessageQueue_50CBD0->SendMessage(195, v1, v1); + pMessageQueue_50CBD0->SendMessage((UIMessageType)195, v1, v1); goto LABEL_1056; case 33: LODWORD(v733) = 604800 * v2; @@ -5613,7 +5613,7 @@ if ( pPlayer->sMana >= (signed int)uRequiredMana ) { pEventTimer->Pause(); - pMessageQueue_50CBD0->SendMessage(177, v1, v1); + pMessageQueue_50CBD0->SendMessage((UIMessageType)177, v1, v1); qword_506350 = (signed int)v733; _506348_current_lloyd_playerid = v3->uPlayerID; ::uRequiredMana = v319; @@ -7792,13 +7792,13 @@ } //----- (0042EB8D) -------------------------------------------------------- -void GUIMessageQueue::SendMessage(int a2, int a3, unsigned int a4) +void GUIMessageQueue::SendMessage(UIMessageType msg, int param, unsigned int a4) { - if ( (signed int)this->uNumMessages < 40 ) + if (uNumMessages < 40) { - this->pMessages[this->uNumMessages].eType = (UIMessageType)a2; - this->pMessages[this->uNumMessages].param = a3; - *(&this->uNumMessages + 3 * (this->uNumMessages++ + 1)) = a4; + pMessages[uNumMessages].eType = msg; + pMessages[uNumMessages].param = param; + pMessages[uNumMessages++].field_8 = a4; } }