diff mm7_2.cpp @ 2278:0cd17b0d36c2

MMT_MainMenu
author Ritor1
date Fri, 14 Mar 2014 17:59:06 +0600
parents b9adf4f414f6
children a01d3cf9ff83
line wrap: on
line diff
--- 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";
   };
 };