diff GUI/UI/UIPopup.cpp @ 2572:d87bfbd3bb3b

Step towards unification of Texture and RGBTexture (class Image)
author a.parshin
date Sat, 05 Mar 2016 01:51:54 +0200
parents d569340b05ff
children dd36326a9994
line wrap: on
line diff
--- a/GUI/UI/UIPopup.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/UI/UIPopup.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -31,6 +31,16 @@
 static char static_sub_417BB5_out_string[1200]; // static to a file, not sub actually
 
 
+struct Image *parchment = nullptr;
+struct Image *messagebox_corner_x = nullptr; // 5076AC
+struct Image *messagebox_corner_y = nullptr; // 5076B4
+struct Image *messagebox_corner_z = nullptr; // 5076A8
+struct Image *messagebox_corner_w = nullptr; // 5076B0
+struct Image *messagebox_border_top = nullptr; // 507698
+struct Image *messagebox_border_bottom = nullptr; // 5076A4
+struct Image *messagebox_border_left = nullptr; // 50769C
+struct Image *messagebox_border_right = nullptr; // 5076A0
+
 //----- (004179BC) --------------------------------------------------------
 void CharacterUI_DrawTooltip(const char *Title, const char *content)
 {
@@ -59,55 +69,117 @@
 }
 
 //----- (004151D9) --------------------------------------------------------
-void __fastcall DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight)
+void DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight)
 {
   unsigned int uNumTiles; // [sp+2Ch] [bp-Ch]@6
-  unsigned int coord_x; // [sp+2Ch] [bp-Ch]@3
-  unsigned int coord_y; // [sp+34h] [bp-4h]@5
+  int coord_x; // [sp+2Ch] [bp-Ch]@3
+  int coord_y; // [sp+34h] [bp-4h]@5
 
-  auto parchment = pIcons_LOD->GetTexture(uTextureID_Parchment);
+  if (!parchment)
+      return;
 
-  if ( parchment->uTextureWidth && parchment->uTextureHeight)
-  {
+
     pRenderer->SetUIClipRect(uX, uY, uX + uWidth, uY + uHeight);
 
-    uNumTiles = uWidth / parchment->uTextureWidth;
-    if ( uWidth % parchment->uTextureWidth )
+    unsigned int parchment_width = parchment->GetWidth();
+    unsigned int parchment_height = parchment->GetHeight();
+
+    uNumTiles = uWidth / parchment_width;
+    if ( uWidth % parchment_width)
       ++uNumTiles;
     coord_y = uY;
-    for ( uint j = 0; j <= uHeight / parchment->uTextureHeight; j++ )
+    for ( uint j = 0; j <= uHeight / parchment_height; j++ )
     {
-      coord_x = uX - parchment->uTextureWidth;
+      coord_x = uX - parchment_width;
       for ( uint i = uNumTiles + 1; i; --i )
       {
-        coord_x += parchment->uTextureWidth;
-        pRenderer->DrawTextureIndexed(coord_x, coord_y, parchment);
+        coord_x += parchment_width;
+        pRenderer->DrawTextureNew(coord_x / 640.0f, coord_y / 480.0f, parchment);
       }
-      coord_y += parchment->uTextureHeight;
+      coord_y += parchment_height;
     }
-    pRenderer->DrawTextureIndexedAlpha(uX,               uY,                pIcons_LOD->GetTexture(uTextureID_5076AC));
-    pRenderer->DrawTextureIndexedAlpha(uX,               uY + uHeight - 32, pIcons_LOD->GetTexture(uTextureID_5076B4));
-    pRenderer->DrawTextureIndexedAlpha(uX + uWidth - 32, uY,                pIcons_LOD->GetTexture(uTextureID_5076A8));
-    pRenderer->DrawTextureIndexedAlpha(uX + uWidth - 32, uY + uHeight - 32, pIcons_LOD->GetTexture(uTextureID_5076B0));
-    if ( uWidth > 64 )
+
+
+    pRenderer->DrawTextureAlphaNew(
+        uX / 640.0f,
+        uY / 480.0f,
+        messagebox_corner_x
+    );
+    pRenderer->DrawTextureAlphaNew(
+        uX / 640.0f,
+        (uY + uHeight - messagebox_corner_y->GetHeight()) / 480.0f,
+        messagebox_corner_y
+    );
+    pRenderer->DrawTextureAlphaNew(
+        (uX + uWidth - messagebox_corner_z->GetWidth()) / 640.0f,
+        uY / 480.0f,
+        messagebox_corner_z
+    );
+    pRenderer->DrawTextureAlphaNew(
+        (uX + uWidth - messagebox_corner_z->GetWidth()) / 640.0f,
+        (uY + uHeight - messagebox_corner_y->GetHeight()) / 480.0f,
+        messagebox_corner_w
+    );
+
+
+    if (uWidth > messagebox_corner_x->GetWidth() + messagebox_corner_z->GetWidth())
     {
-      pRenderer->SetUIClipRect(uX + 32, uY, uX + uWidth - 32, uY + uHeight);
-      pRenderer->DrawTextureIndexedAlpha(uX + 32, uY,                pIcons_LOD->GetTexture(uTextureID_507698));
-      pRenderer->DrawTextureIndexedAlpha(uX + 32, uY + uHeight - 10, pIcons_LOD->GetTexture(uTextureID_5076A4));
-      if ( uWidth > 512 )
+      pRenderer->SetUIClipRect(
+          uX + messagebox_corner_x->GetWidth(),
+          uY,
+          uX + uWidth - messagebox_corner_z->GetWidth(),
+          uY + uHeight
+      );
+
+      // horizontal borders
+      for (
+          unsigned int x = uX + messagebox_corner_x->GetWidth();
+          x < uX + uWidth - messagebox_corner_x->GetWidth();
+          x += messagebox_border_top->GetWidth()
+      )
       {
-        pRenderer->DrawTextureIndexedAlpha(uX + 544, uY,                pIcons_LOD->GetTexture(uTextureID_507698));
-        pRenderer->DrawTextureIndexedAlpha(uX + 544, uY + uHeight - 10, pIcons_LOD->GetTexture(uTextureID_5076A4));
+          pRenderer->DrawTextureAlphaNew(
+              x / 640.0f,
+              uY / 480.0f,
+              messagebox_border_top
+          );
+          pRenderer->DrawTextureAlphaNew(
+              x / 640.0f,
+              (uY + uHeight - messagebox_border_bottom->GetHeight()) / 480.0f,
+              messagebox_border_bottom
+          );
       }
     }
-    if ( uHeight > 64 )
+
+    // vertical borders
+    if ( uHeight > messagebox_corner_x->GetHeight() + messagebox_corner_y->GetHeight())
     {
-      pRenderer->SetUIClipRect(uX, uY + 32, uX + uWidth, uY + uHeight - 32);
-      pRenderer->DrawTextureIndexedAlpha(uX,               uY + 32, pIcons_LOD->GetTexture(uTextureID_5076A0));
-      pRenderer->DrawTextureIndexedAlpha(uX + uWidth - 10, uY + 32, pIcons_LOD->GetTexture(uTextureID_50769C));
+      pRenderer->SetUIClipRect(
+          uX,
+          uY + messagebox_corner_x->GetHeight(),
+          uX + uWidth,
+          uY + uHeight - messagebox_corner_y->GetHeight()
+      );
+
+      for (
+          unsigned int y = uY + messagebox_corner_x->GetHeight();
+          y < uY + uHeight - messagebox_corner_y->GetHeight();
+          y += messagebox_border_top->GetHeight()
+      )
+      {
+          pRenderer->DrawTextureAlphaNew(
+              uX / 640.0f,
+              y / 480.0f,
+              messagebox_border_left
+          );
+          pRenderer->DrawTextureAlphaNew(
+              (uX + uWidth - messagebox_border_right->GetWidth() - 1) / 640.0f,
+              y / 480.0f,
+              messagebox_border_right
+          );
+      }
     }
     pRenderer->ResetUIClipRect();
-  }
 }
 
 //----- (0041D895) --------------------------------------------------------