Browse Source

add back dialog shadow effect from original version

Pal Lockheart 7 years ago
parent
commit
9f9b818ec5
4 changed files with 96 additions and 3 deletions
  1. 25 1
      palcommon.c
  2. 9 1
      palcommon.h
  3. 43 0
      ui.c
  4. 19 1
      ui.h

+ 25 - 1
palcommon.c

@@ -25,12 +25,31 @@
 #include "global.h"
 #include "palcfg.h"
 
+BYTE
+PAL_CalcShadowColor(
+   BYTE bSourceColor
+)
+{
+    return ((bSourceColor&0xF0)|((bSourceColor&0x0F)>>1));
+}
+
 INT
 PAL_RLEBlitToSurface(
    LPCBITMAPRLE      lpBitmapRLE,
    SDL_Surface      *lpDstSurface,
    PAL_POS           pos
 )
+{
+    return PAL_RLEBlitToSurfaceWithShadow ( lpBitmapRLE, lpDstSurface, pos, FALSE );
+}
+
+INT
+PAL_RLEBlitToSurfaceWithShadow(
+   LPCBITMAPRLE      lpBitmapRLE,
+   SDL_Surface      *lpDstSurface,
+   PAL_POS           pos,
+   BOOL              bShadow
+)
 /*++
   Purpose:
 
@@ -45,6 +64,8 @@ PAL_RLEBlitToSurface(
 
     [IN]  pos - position of the destination area.
 
+    [IN]  bShadow - flag to mention whether blit source color or just shadow.
+
   Return value:
 
     0 = success, -1 = error.
@@ -138,7 +159,10 @@ PAL_RLEBlitToSurface(
             //
             // Put the pixel onto the surface (FIXME: inefficient).
             //
-            ((LPBYTE)lpDstSurface->pixels)[y * lpDstSurface->pitch + x] = lpBitmapRLE[j];
+            if(bShadow)
+               ((LPBYTE)lpDstSurface->pixels)[y * lpDstSurface->pitch + x] = PAL_CalcShadowColor(((LPBYTE)lpDstSurface->pixels)[y * lpDstSurface->pitch + x]);
+            else
+               ((LPBYTE)lpDstSurface->pixels)[y * lpDstSurface->pitch + x] = lpBitmapRLE[j];
          }
          lpBitmapRLE += T;
          i += T;

+ 9 - 1
palcommon.h

@@ -50,7 +50,7 @@ typedef enum tagPALDIRECTION
    kDirEast,
    kDirUnknown
 } PALDIRECTION, *LPPALDIRECTION;
-
+    
 INT
 PAL_RLEBlitToSurface(
    LPCBITMAPRLE      lpBitmapRLE,
@@ -58,6 +58,14 @@ PAL_RLEBlitToSurface(
    PAL_POS           pos
 );
 
+INT
+PAL_RLEBlitToSurfaceWithShadow(
+   LPCBITMAPRLE      lpBitmapRLE,
+   SDL_Surface      *lpDstSurface,
+   PAL_POS           pos,
+   BOOL              bShadow
+);
+
 INT
 PAL_RLEBlitWithColorShift(
    LPCBITMAPRLE      lpBitmapRLE,

+ 43 - 0
ui.c

@@ -100,6 +100,19 @@ PAL_CreateBox(
    INT            iStyle,
    BOOL           fSaveScreen
 )
+{
+    return PAL_CreateBoxWithShadow( pos, nRows, nColumns, iStyle, fSaveScreen, 6 );
+}
+
+LPBOX
+PAL_CreateBoxWithShadow(
+   PAL_POS        pos,
+   INT            nRows,
+   INT            nColumns,
+   INT            iStyle,
+   BOOL           fSaveScreen,
+   INT            nShadowOffset
+)
 /*++
   Purpose:
 
@@ -214,6 +227,7 @@ PAL_CreateBox(
       for (j = 0; j < nColumns; j++)
       {
          n = (j == 0) ? 0 : ((j == nColumns - 1) ? 2 : 1);
+         PAL_RLEBlitToSurfaceWithShadow(rglpBorderBitmap[m][n], gpScreen, PAL_XY(x+nShadowOffset, rect.y+nShadowOffset),TRUE);
          PAL_RLEBlitToSurface(rglpBorderBitmap[m][n], gpScreen, PAL_XY(x, rect.y));
          x += PAL_RLEGetWidth(rglpBorderBitmap[m][n]);
       }
@@ -230,6 +244,17 @@ PAL_CreateSingleLineBox(
    INT            nLen,
    BOOL           fSaveScreen
 )
+{
+    return PAL_CreateSingleLineBoxWithShadow(pos, nLen, fSaveScreen, 6);
+}
+
+LPBOX
+PAL_CreateSingleLineBoxWithShadow(
+   PAL_POS        pos,
+   INT            nLen,
+   BOOL           fSaveScreen,
+   INT            nShadowOffset
+)
 /*++
   Purpose:
 
@@ -261,6 +286,7 @@ PAL_CreateSingleLineBox(
    SDL_Rect              rect;
    LPBOX                 lpBox = NULL;
    int                   i;
+   int                   xSaved;
 
    //
    // Get the bitmaps
@@ -312,7 +338,24 @@ PAL_CreateSingleLineBox(
       lpBox->wHeight = (WORD)rect.w;
       lpBox->wWidth = (WORD)rect.h;
    }
+   xSaved = rect.x;
+
+   //
+   // Draw the shadow
+   //
+   PAL_RLEBlitToSurfaceWithShadow(lpBitmapLeft, gpScreen, PAL_XY(rect.x+nShadowOffset, rect.y+nShadowOffset), TRUE);
+
+   rect.x += PAL_RLEGetWidth(lpBitmapLeft);
+
+   for (i = 0; i < nLen; i++)
+   {
+      PAL_RLEBlitToSurfaceWithShadow(lpBitmapMid, gpScreen, PAL_XY(rect.x+nShadowOffset, rect.y+nShadowOffset), TRUE);
+      rect.x += PAL_RLEGetWidth(lpBitmapMid);
+   }
+
+   PAL_RLEBlitToSurfaceWithShadow(lpBitmapRight, gpScreen, PAL_XY(rect.x+nShadowOffset, rect.y+nShadowOffset), TRUE);
 
+   rect.x = xSaved;
    //
    // Draw the box
    //

+ 19 - 1
ui.h

@@ -189,6 +189,16 @@ PAL_CreateBox(
    INT            iStyle,
    BOOL           fSaveScreen
 );
+    
+LPBOX
+PAL_CreateBoxWithShadow(
+   PAL_POS        pos,
+   INT            nRows,
+   INT            nColumns,
+   INT            iStyle,
+   BOOL           fSaveScreen,
+   INT            nShadowOffset
+);
 
 LPBOX
 PAL_CreateSingleLineBox(
@@ -196,7 +206,15 @@ PAL_CreateSingleLineBox(
    INT            nLen,
    BOOL           fSaveScreen
 );
-
+    
+LPBOX
+PAL_CreateSingleLineBoxWithShadow(
+   PAL_POS        pos,
+   INT            nLen,
+   BOOL           fSaveScreen,
+   INT            nShadowOffset
+);
+    
 VOID
 PAL_DeleteBox(
    LPBOX          lpBox