changeset 1675:f1cdf8c062d4

MainMenuUI_Credits_Loop() and CreditsTextureScroll
author Ritor1
date Thu, 19 Sep 2013 16:45:21 +0600
parents 2a5f2aaec367
children 483cc7f0d86c
files Render.cpp Render.h UI/UIMainMenu.cpp
diffstat 3 files changed, 94 insertions(+), 134 deletions(-) [+]
line wrap: on
line diff
--- a/Render.cpp	Thu Sep 19 09:29:30 2013 +0600
+++ b/Render.cpp	Thu Sep 19 16:45:21 2013 +0600
@@ -6914,101 +6914,61 @@
 }
 
 //----- (004A5D33) --------------------------------------------------------
-void Render::_4A5D33(unsigned int pX, unsigned int pY, int a4, int a5, RGBTexture *pTexture)
+void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture)
 {
-  Render *v6; // esi@1
   unsigned __int16 *v7; // ebx@3
-  int v8; // ecx@3
-  int v9; // edx@3
-  int v10; // ecx@3
-  int v11; // edi@3
-  signed int v12; // eax@4
-  unsigned int v13; // eax@5
-  signed int v14; // eax@6
-  unsigned int v15; // eax@7
-  unsigned int v16; // edx@8
-  int v17; // eax@10
-  unsigned int v18; // ecx@11
-  unsigned int v19; // ecx@14
-  int v20; // eax@16
-  unsigned int v21; // ecx@17
-  int v22; // eax@21
+  int full_width; // ecx@3
+  int full_height; // edi@3
   int v23; // edi@23
-  int v24; // [sp+Ch] [bp-4h]@3
-  int a2a; // [sp+18h] [bp+8h]@21
-  unsigned int teal; // [sp+1Ch] [bp+Ch]@20
-  int a4a; // [sp+20h] [bp+10h]@3
-  int a4b; // [sp+20h] [bp+10h]@21
   unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3
 
-  v6 = this;
   if ( this->uNumSceneBegins && pTexture )
   {
     v7 = &this->pTargetSurface[pX + pY * this->uTargetSurfacePitch];
-    v8 = pTexture->uWidth;
-    v24 = pTexture->uWidth;
-    v9 = a4 + a5 * v8;
-    v10 = v8 - a4;
-    a4a = v10;
-    v11 = pTexture->uHeight - a5;
-    pTexturea = &pTexture->pPixels[v9];
-    if ( v6->bClip )
-    {
-      v12 = v6->uClipX;
-      if ( (signed int)pX < v12 )
-      {
-        v13 = 2 * (v12 - pX);
-        pTexturea = (unsigned __int16 *)((char *)pTexturea + v13);
-        v10 += pX - v6->uClipX;
-        v7 = (unsigned __int16 *)((char *)v7 + v13);
-        a4a = v10;
-      }
-      v14 = v6->uClipY;
-      if ( (signed int)pY < v14 )
-      {
-        v15 = v14 - pY;
-        pTexturea += v24 * v15;
-        v11 += pY - v6->uClipY;
-        v10 = a4a;
-        v7 += v6->uTargetSurfacePitch * v15;
-      }
-      v16 = v6->uClipX;
-      if ( (signed int)v16 < (signed int)pX )
-        v16 = pX;
-      v17 = v6->uClipZ;
-      if ( (signed int)(v10 + v16) > v17 )
-      {
-        v18 = v6->uClipX;
-        if ( (signed int)v18 < (signed int)pX )
-          v18 = pX;
-        a4a = v17 - v18;
-      }
-      v19 = v6->uClipY;
-      if ( (signed int)v19 < (signed int)pY )
-        v19 = pY;
-      v20 = v6->uClipW;
-      if ( (signed int)(v11 + v19) > v20 )
-      {
-        v21 = v6->uClipY;
-        if ( (signed int)v21 < (signed int)pY )
-          v21 = pY;
-        v11 = v20 - v21;
-      }
-    }
-    teal = TargetColor(0, 0xFFu, 0xFFu);
-    if ( v11 > 0 )
-    {
-      v22 = a4a;
-      a2a = v11;
-      a4b = 2 * (v24 - a4a);
+    full_width = pTexture->uWidth - move_X;
+    full_height = pTexture->uHeight - move_Y;
+    pTexturea = &pTexture->pPixels[move_X + move_Y * pTexture->uWidth];
+    if ( this->bClip )
+    {
+      if ( pX < this->uClipX )//если кадр выходит за правую границу
+      {
+        pTexturea = (unsigned __int16 *)((char *)pTexturea + (2 * (this->uClipX - pX)));
+        full_width += pX - this->uClipX;
+        v7 = (unsigned __int16 *)((char *)v7 + (2 * (this->uClipX - pX)));
+      }
+      if ( pY < this->uClipY )//если кадр выходит за верхнюю границу
+      {
+        pTexturea += pTexture->uWidth * (this->uClipY - pY);
+        full_height += pY - this->uClipY;
+        v7 += this->uTargetSurfacePitch * (this->uClipY - pY);
+      }
+      if ( this->uClipX < pX )//если правая граница окна меньше х координаты кадра
+        this->uClipX = pX;
+      if ( this->uClipY < pY )//если верхняя граница окна меньше y координаты кадра
+        this->uClipY = pY;
+      if ( (full_width + this->uClipX) > this->uClipZ )//если ширина кадра выходит за правую границу
+      {
+        if ( this->uClipX < pX )
+          this->uClipX = pX;
+        full_width = this->uClipZ - this->uClipX;
+      }
+      if ( (full_height + this->uClipY) > this->uClipW )//если высота кадра выходит за нижнюю границу
+      {
+        if ( this->uClipY < pY )
+          this->uClipY = pY;
+        full_height = this->uClipW - this->uClipY;
+      }
+    }
+    if ( full_height > 0 )
+    {
       do
       {
-        if ( v22 > 0 )
+        if ( full_width > 0 )
         {
-          v23 = v22;
+          v23 = full_width;
           do
           {
-            if ( *pTexturea != teal )
+            if ( *pTexturea != TargetColor(0, 0xFFu, 0xFFu) )
               *v7 = *pTexturea;
             ++pTexturea;
             ++v7;
@@ -7016,11 +6976,11 @@
           }
           while ( v23 );
         }
-        v7 += v6->uTargetSurfacePitch - v22;
-        pTexturea = (unsigned __int16 *)((char *)pTexturea + a4b);
-        --a2a;
-      }
-      while ( a2a );
+        v7 += this->uTargetSurfacePitch - full_width;
+        pTexturea = (unsigned __int16 *)((char *)pTexturea + 2 * (pTexture->uWidth - full_width));
+        --full_height;
+      }
+      while ( full_height );
     }
   }
 }
@@ -8392,9 +8352,9 @@
       SetUserInterface(pParty->alignment, true);
       if ( pVideoPlayer->pVideoFrame.pPixels )
         pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1);
-      if ( uCurrentMenuID != 6 )
-      {
-        if ( uCurrentMenuID == 8 )
+      if ( uCurrentMenuID != MENU_CREATEPARTY )
+      {
+        if ( uCurrentMenuID == MENU_CREDITSPROC )
           dword_A74C88 = 1; 
       }
       else
--- a/Render.h	Thu Sep 19 09:29:30 2013 +0600
+++ b/Render.h	Thu Sep 19 16:45:21 2013 +0600
@@ -341,7 +341,7 @@
   void SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
   void ResetTextureClipRect();
   void DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4);
-  void _4A5D33(unsigned int a2, unsigned int a3, int a4, int a5, RGBTexture *pTexture);
+  void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture);
   void DrawTextureIndexed(unsigned int uX, unsigned int uY, struct Texture *a4);
   void ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5);
   void DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, struct Texture *pTexture, int zVal);
--- a/UI/UIMainMenu.cpp	Thu Sep 19 09:29:30 2013 +0600
+++ b/UI/UIMainMenu.cpp	Thu Sep 19 16:45:21 2013 +0600
@@ -194,73 +194,73 @@
 //----- (004979D2) --------------------------------------------------------
 MENU_STATE MainMenuUI_Credits_Loop()
 {
-  char *v1; // edi@5
+  char *cred_texturet; // edi@5
   FILE *pFile; // eax@5
   unsigned int pSize; // esi@7
-  __int16 pHeight; // ax@9
-  void *v7; // eax@9
-  unsigned int v10; // ST2C_4@19
   MSG Msg; // [sp+84h] [bp-B8h]@10
-  int v17; // [sp+A0h] [bp-9Ch]@9
   GUIWindow credit_window;
-  int a5; // [sp+128h] [bp-14h]@1
+  int move_Y; // [sp+128h] [bp-14h]@1
   char *pString; // [sp+12Ch] [bp-10h]@9
-  char *ptr; // [sp+130h] [bp-Ch]@5
   GUIFont *pFontQuick; // [sp+134h] [bp-8h]@1
   GUIFont *pFontCChar; // [sp+138h] [bp-4h]@1
-  RGBTexture pTexture; // [sp+54h] [bp-E8h]@1
-  RGBTexture pTexture2; // [sp+100h] [bp-3Ch]@1
-  Texture pTexture3; // [sp+Ch] [bp-130h]@5
+  RGBTexture mm6title_texture; // [sp+54h] [bp-E8h]@1
+  RGBTexture cred_texture; // [sp+100h] [bp-3Ch]@1
+  Texture pTemporaryTexture; // [sp+Ch] [bp-130h]@5
 
-  a5 = 0;
   pFontQuick = LoadFont("quick.fnt", "FONTPAL", NULL);
   pFontCChar = LoadFont("cchar.fnt", "FONTPAL", NULL);
+
   if ( pMessageQueue_50CBD0->uNumMessages )
     pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
   ++pIcons_LOD->uTexturePacksCount;
   if ( !pIcons_LOD->uNumPrevLoadedFiles )
     pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-  dword_A74C88 = 0;
+  //dword_A74C88 = 0;//??? часть дальнейшего кода отсутствует, там использовалась данная переменная
+
   pAudioPlayer->PlayMusicTrack(MUSIC_Credits);
-  pTexture.Load("mm6title.pcx", 0);
-  ptr = (char *)pEvents_LOD->LoadRaw("credits.txt", 0);
-  v1 = ptr;
+
+  mm6title_texture.Load("mm6title.pcx", 0);
+  cred_texturet = (char *)pEvents_LOD->LoadRaw("credits.txt", 0);
   pFile = pEvents_LOD->FindContainer("credits.txt", 0);
   if ( !pFile )
     Error(pGlobalTXT_LocalizationStrings[63]); // "Might and Magic VII is having trouble loading files. 
 
   // Please re-install to fix this problem. Note: Re-installing will not destroy your save games."
-  fread(&pTexture3, 1, 0x30, pFile);
-  pSize = pTexture3.uDecompressedSize;
-  if ( !pTexture3.uDecompressedSize )
-    pSize = pTexture3.uTextureSize;
-  memset(&pTexture3, 0, 0x48);
-  v1[pSize] = 0;
+
+  //для получения размера-----------------------
+  fread(&pTemporaryTexture, 1, 0x30, pFile);
+  pSize = pTemporaryTexture.uDecompressedSize;
+  if ( !pSize )
+    pSize = pTemporaryTexture.uTextureSize;
+  memset(&pTemporaryTexture, 0, 0x48);//обнуление
+  cred_texturet[pSize] = 0;//конец текста
 
   credit_window.uFrameWidth = 250;
   credit_window.uFrameHeight = 440;
   credit_window.uFrameX = 389;
   credit_window.uFrameY = 19;
 
-  pTexture2.uWidth = 250;
-  pHeight = pFontQuick->GetStringHeight2(pFontCChar, v1, &credit_window, 0, 1);
-  pTexture2.uHeight = pHeight + 2 * credit_window.uFrameHeight;
-  pTexture2.uNumPixels = (signed __int16)pTexture2.uWidth * (signed __int16)pTexture2.uHeight;
-  v7 = malloc(2 * pTexture2.uNumPixels);//, "scrollermap");
-  pTexture2.pPixels = (unsigned __int16 *)v7;
-  fill_pixels_fast(TargetColor(0, 0xFFu, 0xFFu), pTexture2.pPixels, pTexture2.uNumPixels);
-  pTexture2._allocation_flags = 0;
+  cred_texture.uWidth = 250;
+  cred_texture.uHeight = pFontQuick->GetStringHeight2(pFontCChar, cred_texturet, &credit_window, 0, 1) + 2 * credit_window.uFrameHeight;
+  cred_texture.uNumPixels = cred_texture.uWidth * cred_texture.uHeight;
+  cred_texture.pPixels = (unsigned __int16 *)malloc(2 * cred_texture.uNumPixels);
+  fill_pixels_fast(TargetColor(0, 0xFFu, 0xFFu), cred_texture.pPixels, cred_texture.uNumPixels);
+  cred_texture._allocation_flags = 0;
+
+  //дать шрифт и цвета тексту
   pString = (char *)malloc(2 * pSize);
-  strncpy(pString, ptr, pSize);
-  pString[pSize]=0;
-  pFontQuick->_44D2FD_prolly_draw_credits_entry(pFontCChar, 0, credit_window.uFrameHeight, (signed __int16)pTexture2.uWidth,
-       (signed __int16)pTexture2.uHeight, TargetColor(0x70u, 0x8Fu, 0xFEu), TargetColor(0xECu, 0xE6u, 0x9Cu), pString, pTexture2.pPixels,
-       (signed __int16)pTexture2.uWidth);
+  strncpy(pString, cred_texturet, pSize);
+  pString[pSize] = 0;
+  pFontQuick->_44D2FD_prolly_draw_credits_entry(pFontCChar, 0, credit_window.uFrameHeight, cred_texture.uWidth,
+    cred_texture.uHeight, TargetColor(0x70u, 0x8Fu, 0xFEu), TargetColor(0xECu, 0xE6u, 0x9Cu), pString, cred_texture.pPixels, cred_texture.uWidth);
   free(pString);
-  pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, ptr);
-  pWindow_MainMenu->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_Escape, 0, 0x1Bu, "", 0);
+
+  pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, cred_texturet);
+  pWindow_MainMenu->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_Escape, 0, 27, "", 0);
   pCurrentScreen = SCREEN_CREATORS;
   SetCurrentMenuID(MENU_CREDITSPROC);
+
+  move_Y = 0;
   do
   {
     while ( PeekMessageA(&Msg, 0, 0, 0, 1) )
@@ -277,14 +277,14 @@
     else
     {
       pRenderer->BeginScene();
-      pRenderer->DrawTextureRGB(0, 0, &pTexture);
+      pRenderer->DrawTextureRGB(0, 0, &mm6title_texture);
       pRenderer->SetTextureClipRect(credit_window.uFrameX, credit_window.uFrameY, credit_window.uFrameX + credit_window.uFrameWidth,
            credit_window.uFrameY + credit_window.uFrameHeight);
-      pRenderer->_4A5D33(credit_window.uFrameX, credit_window.uFrameY, 0, a5, &pTexture2);
+      pRenderer->CreditsTextureScroll(credit_window.uFrameX, credit_window.uFrameY, 0, move_Y, &cred_texture);
       pRenderer->ResetTextureClipRect();
       pRenderer->EndScene();
-      ++a5;
-      if ( a5 >= (signed __int16)pTexture2.uHeight )
+      ++move_Y;
+      if ( move_Y >= cred_texture.uHeight )
         SetCurrentMenuID(MENU_MAIN);
       pRenderer->Present();
       pCurrentScreen = SCREEN_GAME;//Ritor1: temporarily, must be corrected GUI_MainMenuMessageProc()
@@ -293,12 +293,12 @@
   }
   while ( GetCurrentMenuID() == MENU_CREDITSPROC );
   pAudioPlayer->_4AA258(1);
-  free(ptr);
+  free(cred_texturet);
   free(pFontQuick);
   free(pFontCChar);
   pWindow_MainMenu->Release();
   pIcons_LOD->RemoveTexturesPackFromTextureList();
-  pTexture.Release();
-  pTexture2.Release();
+  mm6title_texture.Release();
+  cred_texture.Release();
   return MENU_MAIN;     // return MENU_Main
 }
\ No newline at end of file