changeset 2278:0cd17b0d36c2

MMT_MainMenu
author Ritor1
date Fri, 14 Mar 2014 17:59:06 +0600
parents b9adf4f414f6
children a01d3cf9ff83
files GUIButton.cpp GUIWindow.cpp GUIWindow.h Game.cpp Texture.cpp VideoPlayer.cpp mm7_2.cpp mm7_unsorted_subs.h
diffstat 8 files changed, 175 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/GUIButton.cpp	Fri Mar 14 13:58:51 2014 +0600
+++ b/GUIButton.cpp	Fri Mar 14 17:59:06 2014 +0600
@@ -58,6 +58,13 @@
 struct GUIButton *pBtn_Quests;
 
 
+struct GUIButton *pMMT_MainMenu_BtnMM6;
+struct GUIButton *pMMT_MainMenu_BtnMM7;
+struct GUIButton *pMMT_MainMenu_BtnMM8;
+struct GUIButton *pMMT_MainMenu_BtnContinue;
+struct GUIButton *pMMT_MainMenu_BtnExit;
+
+
 struct GUIButton *pMainMenu_BtnExit;
 struct GUIButton *pMainMenu_BtnCredits;
 struct GUIButton *pMainMenu_BtnLoad;
--- a/GUIWindow.cpp	Fri Mar 14 13:58:51 2014 +0600
+++ b/GUIWindow.cpp	Fri Mar 14 17:59:06 2014 +0600
@@ -61,6 +61,7 @@
 
 
 int pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[1]; // idb
+struct GUIWindow *pWindow_MMT_MainMenu;
 struct GUIWindow *pWindow_MainMenu;
 std::array<struct GUIWindow, 20> pWindowList;
 
--- a/GUIWindow.h	Fri Mar 14 13:58:51 2014 +0600
+++ b/GUIWindow.h	Fri Mar 14 17:59:06 2014 +0600
@@ -205,6 +205,12 @@
   UIMSG_ToggleColoredLights = 423,
   UIMSG_ToggleTint = 424,
   UIMSG_1A9 = 425,
+
+  UIMSG_MMT_MainMenu_MM6 = 426,
+  UIMSG_MMT_MainMenu_MM7 = 427,
+  UIMSG_MMT_MainMenu_MM8 = 428,
+  UIMSG_MMT_MainMenu_Continue = 429,
+
 };
 
 
@@ -223,6 +229,7 @@
   MENU_LoadingProcInMainMenu = 9,
   MENU_DebugBLVLevel = 10,
   MENU_CREDITSCLOSE = 11,
+  MENU_MMT_MAIN_MENU = 12,
 };
 
 
@@ -463,6 +470,7 @@
 
 
 extern int pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[]; // idb
+extern struct GUIWindow *pWindow_MMT_MainMenu;
 extern struct GUIWindow *pWindow_MainMenu;
 extern std::array<struct GUIWindow, 20> pWindowList;
 
@@ -689,6 +697,12 @@
 extern struct GUIButton *pBtn_Quests;
 
 
+extern struct GUIButton *pMMT_MainMenu_BtnMM6;
+extern struct GUIButton *pMMT_MainMenu_BtnMM7;
+extern struct GUIButton *pMMT_MainMenu_BtnMM8;
+extern struct GUIButton *pMMT_MainMenu_BtnContinue;
+extern struct GUIButton *pMMT_MainMenu_BtnExit;
+
 extern struct GUIButton *pMainMenu_BtnExit;
 extern struct GUIButton *pMainMenu_BtnCredits;
 extern struct GUIButton *pMainMenu_BtnLoad;
--- a/Game.cpp	Fri Mar 14 13:58:51 2014 +0600
+++ b/Game.cpp	Fri Mar 14 17:59:06 2014 +0600
@@ -4274,6 +4274,10 @@
 
       switch (pUIMessageType) // For buttons of window MainMenu
       {
+        case UIMSG_MMT_MainMenu_MM7:
+          SetCurrentMenuID(MENU_MAIN);
+          break;
+
         case UIMSG_MainMenu_ShowPartyCreationWnd:
           GUIWindow::Create(495, 172, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnNew, 0);
           SetCurrentMenuID(MENU_NEWGAME);
--- a/Texture.cpp	Fri Mar 14 13:58:51 2014 +0600
+++ b/Texture.cpp	Fri Mar 14 17:59:06 2014 +0600
@@ -517,7 +517,7 @@
 //----- (0040F414) --------------------------------------------------------
 int RGBTexture::Load(const char *pContainer, int mode)
 {
-  FILE *v4; // eax@1
+  FILE *file; // eax@1
   void *v6; // ebx@5
   char color_map[48]; // [sp+Ch] [bp-98h]@7
   Texture DstBuf; // [sp+3Ch] [bp-68h]@1
@@ -526,18 +526,25 @@
   size_t Count; // [sp+A0h] [bp-4h]@4
   char *Str1a; // [sp+ACh] [bp+8h]@5
 
+  file = pIcons_LOD->FindContainer(pContainer, 0);
+  if ( !file )
+  {
+    //char pContainerName[64];
 
-  v4 = pIcons_LOD->FindContainer(pContainer, 0);
-  if ( !v4 )
-    Error("Unable to load %s", pContainer);
+    //sprintf(pContainerName, "data\\New_Icons/%s", pContainer);
+    //MMT_Texture.LoadPCXFile(pContainerName, 0);
+    if ( !file )
+      Error("Unable to load %s", pContainer);
+    //fclose(file);
+  }
 
-  fread(&DstBuf, 1u, 0x30u, v4);
+  fread(&DstBuf, 1, 0x30u, file);
   Count = DstBuf.uTextureSize;
   if ( DstBuf.uDecompressedSize )
   {
     Str1a = (char *)malloc(DstBuf.uDecompressedSize);
     v6 = malloc(DstBuf.uTextureSize);
-    fread(v6, 1, Count, v4);
+    fread(v6, 1, Count, file);
     zlib::MemUnzip(Str1a, &DstBuf.uDecompressedSize, v6, DstBuf.uTextureSize);
     DstBuf.uTextureSize = DstBuf.uDecompressedSize;
     free(v6);
@@ -545,7 +552,7 @@
   else
   {
     Str1a = (char *)malloc(DstBuf.uTextureSize);
-    fread(Str1a, 1, Count, v4);
+    fread(Str1a, 1, Count, file);
   }
   memcpy(&header1, Str1a, 0x10u);
   memcpy(color_map, Str1a + 16, 0x30u);
--- a/VideoPlayer.cpp	Fri Mar 14 13:58:51 2014 +0600
+++ b/VideoPlayer.cpp	Fri Mar 14 17:59:06 2014 +0600
@@ -302,7 +302,11 @@
       }
     }
   }
-  tex.Load("mm6title.pcx", 2);
+  char pContainerName[64];
+
+  sprintf(pContainerName, "data\\New_Icons/%s", "MMTTITLE.pcx");
+  tex.LoadPCXFile(pContainerName, 0);
+  //tex.Load("MMTTITLE.pcx", 2);
   pRenderer->BeginScene();
   pRenderer->DrawTextureRGB(0, 0, &tex);
   free(tex.pPixels);
--- a/mm7_2.cpp	Fri Mar 14 13:58:51 2014 +0600
+++ b/mm7_2.cpp	Fri Mar 14 17:59:06 2014 +0600
@@ -2356,6 +2356,133 @@
       event_triggers[num_event_triggers++] = i;
 }
 
+void MMT_MainMenu_Loop()
+{
+  GUIButton *pButton; // eax@27
+  unsigned int pControlParam; // ecx@35
+  int v10; // ecx@36
+  int v11; // ecx@37
+  unsigned int pX;
+  unsigned int pY; // [sp-18h] [bp-54h]@39
+  Texture *pTexture; // [sp-14h] [bp-50h]@39
+  GUIButton *pButton2; // [sp+0h] [bp-3Ch]@27
+  //GUIWindow *pWindow; // [sp+4h] [bp-38h]@11
+  
+  pCurrentScreen = SCREEN_GAME;
+
+  pGUIWindow2 = 0;
+  pAudioPlayer->StopChannels(-1, -1);//остановить/подготовить канал
+  pMouse->RemoveHoldingItem();//избавить курсор от вещи
+
+  pIcons_LOD->_inlined_sub2();
+
+  pWindow_MMT_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0);
+  Texture* MMT_MM6 = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE);
+  Texture* MMT_MM7 = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE);
+  Texture* MMT_MM8 = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE);
+  Texture* MMT_Continue = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE);
+  Texture* MMT_Exit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE);
+
+  pMMT_MainMenu_BtnMM6      = pWindow_MMT_MainMenu->CreateButton((window->GetWidth() / 4) - 100,                window->GetHeight() / 4, MMT_MM6->uTextureWidth,        MMT_MM6->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM6,           0, 0, "", MMT_MM6, 0);
+  pMMT_MainMenu_BtnMM7      = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - (window->GetWidth()  / 4), window->GetHeight() / 4, MMT_MM7->uTextureWidth,        MMT_MM7->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM7,           1, 0, "", MMT_MM7, 0);
+  pMMT_MainMenu_BtnMM8      = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - (window->GetWidth()  / 4), window->GetHeight() - ((window->GetHeight() / 4) + 50), MMT_MM8->uTextureWidth,     MMT_MM8->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM8,           2, 0, "", MMT_MM8, 0);
+  pMMT_MainMenu_BtnContinue = pWindow_MMT_MainMenu->CreateButton((window->GetWidth() / 4) - 100,                 window->GetHeight() - ((window->GetHeight() / 4) + 50), MMT_Continue->uTextureWidth, MMT_Continue->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_Continue, 3, 0, "", MMT_Continue, 0);
+  pMMT_MainMenu_BtnExit     = pWindow_MMT_MainMenu->CreateButton(495, 437, MMT_Exit->uTextureWidth,    MMT_Exit->uTextureHeight,    1, 0, UIMSG_ExitToWindows,          4, 0, "", MMT_Exit, 0);
+
+  pTexture_PCX.Release();
+  //pTexture_PCX.Load("MMTTITLE.pcx", 0);
+  char pContainerName[64];
+
+  sprintf(pContainerName, "data\\New_Icons/%s", "MMTTITLE.pcx");
+  pTexture_PCX.LoadPCXFile(pContainerName, 0);
+  SetCurrentMenuID(MENU_MMT_MAIN_MENU);
+  SetForegroundWindow(window->GetApiHandle());
+  SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0);
+  while (GetCurrentMenuID() == MENU_MMT_MAIN_MENU )
+  {
+    POINT cursor;
+    pMouse->GetCursorPos(&cursor);
+
+    for (MSG msg; PeekMessageW(&msg, 0, 0, 0, PM_REMOVE);)
+    {
+      if (msg.message == WM_QUIT)
+        Game_DeinitializeAndTerminate(0);
+      TranslateMessage(&msg);
+      DispatchMessageW(&msg);
+    }
+
+    if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE)
+    {
+      WaitMessage();
+      continue;
+    }
+
+      pRenderer->BeginScene();
+      pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
+
+      GUI_MainMenuMessageProc();
+      GUI_UpdateWindows();
+
+      if ( !pModalWindow )// ???
+      {
+          pButton = pWindow_MMT_MainMenu->pControlsHead;
+          for ( pButton = pWindow_MMT_MainMenu->pControlsHead; pButton; pButton = pButton->pNext )
+          {
+           if ( cursor.x >= (signed int)pButton->uX && cursor.x <= (signed int)pButton->uZ
+             && cursor.y >= (signed int)pButton->uY && cursor.y <= (signed int)pButton->uW )
+           {
+            pControlParam = pButton->msg_param;
+            switch (pControlParam) // подсветка кнопок
+            {
+              case 0:
+                pTexture = MMT_MM6;
+                pX = (window->GetWidth() / 4) - 100;
+                pY = window->GetHeight() / 4;
+                break;
+              case 1:
+                pTexture = MMT_MM7;
+                pX = window->GetWidth() - (window->GetWidth() / 4);
+                pY = window->GetHeight() / 4;
+                break;
+              case 2:
+                pTexture = MMT_MM8;
+                pX = window->GetWidth() - (window->GetWidth() / 4);
+                pY = window->GetHeight() - ((window->GetHeight() / 4) + 50);
+                break;
+              case 3:
+                pTexture = MMT_Continue;
+                pX = (window->GetWidth() / 4) - 100;
+                pY = window->GetHeight() - ((window->GetHeight() / 4) + 50);
+                break;
+              case 4:
+                pTexture = MMT_Exit;
+                pX = 495;
+                pY = 437;
+                break;
+            }
+            pRenderer->DrawTextureIndexed(pX, pY, pTexture); //подсветка кнопок
+           }
+          }
+        }
+      //}
+      pRenderer->EndScene();
+      pRenderer->Present();
+  }
+  GUI_MainMenuMessageProc();
+  pRenderer->BeginScene();
+  GUI_UpdateWindows();
+  pRenderer->EndScene();
+  pRenderer->Present();
+  pTexture_PCX.Release();
+  if ( pGUIWindow2 )
+  {
+    pGUIWindow2->Release();
+    pGUIWindow2 = 0;
+  }
+  pWindow_MMT_MainMenu->Release();
+  pIcons_LOD->RemoveTexturesPackFromTextureList();
+}
+
 //----- (004627B7) --------------------------------------------------------
 void MainMenu_Loop()
 {
@@ -3675,6 +3802,7 @@
   SecondaryInitialization();
   pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1);
   FinalInitialization();
+  MMT_MainMenu_Loop();
   Log::Warning(L"MM: entering main loop");
   while ( 1 )
   {
@@ -3975,6 +4103,7 @@
     case MENU_LoadingProcInMainMenu: return L"MENU_LoadingProcInMainMenu";
     case MENU_DebugBLVLevel:           return L"MENU_DebugBLVLevel";
     case MENU_CREDITSCLOSE: return L"MENU_CREDITSCLOSE";
+    case MENU_MMT_MAIN_MENU: return L"MENU_MMT_MAIN_MENU";
     default:                return L"unk";
   };
 };
--- a/mm7_unsorted_subs.h	Fri Mar 14 13:58:51 2014 +0600
+++ b/mm7_unsorted_subs.h	Fri Mar 14 17:59:06 2014 +0600
@@ -126,6 +126,7 @@
 void PrepareToLoadBLV(unsigned int bLoading);
 void __fastcall PrepareToLoadODM(unsigned int bLoading, struct ODMRenderParams *a2);
 void _461103_load_level_sub();
+void MMT_MainMenu_Loop();
 void MainMenu_Loop();
 char sub_4637E0_is_there_popup_onscreen();
 void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();