Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2003:
[Freeciv-Dev] Re: (PR#1870) FreecivAC: borders patch
Home

[Freeciv-Dev] Re: (PR#1870) FreecivAC: borders patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ben@xxxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#1870) FreecivAC: borders patch
From: "Rafa³ Bursig" <bursig@xxxxxxxxx>
Date: Sat, 28 Jun 2003 05:25:40 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Hi all

Dnia 2003.06.27 21:52, Jason Short napisa³(a):
> 
> - In gui-sdl, draw the borders to pBufSurface instead of pDest.  For
> fogged tiles these two are not the same.
> 
I attach patch which add proper draw support of borders for SDLClient.
Diff it under border code and add new graphic to used tileset (maybe 
DELUXE :) ).

When code will be in cvs, I will try add more advanced support.

Rafal
diff -u -r fc_bord_serv/client/gui-sdl/gui_tilespec.c 
fc_bord_client/client/gui-sdl/gui_tilespec.c
--- fc_bord_serv/client/gui-sdl/gui_tilespec.c  Mon Jun  9 01:06:06 2003
+++ fc_bord_client/client/gui-sdl/gui_tilespec.c        Sat Jun 28 00:09:48 2003
@@ -496,7 +496,11 @@
   assert(pDitherMask != NULL);   
   /* ------------------------------ */
 
-
+  /* Map Borders */
+  load_theme_surface(pBuf, NWEST_BORDER_Icon, "theme.normal_border_iso_west");
+  load_theme_surface(pBuf, NNORTH_BORDER_Icon, 
"theme.normal_border_iso_north");
+  load_theme_surface(pBuf, NSOUTH_BORDER_Icon, 
"theme.normal_border_iso_south");
+  load_theme_surface(pBuf, NEAST_BORDER_Icon, "theme.normal_border_iso_east");
 
   return;
 }
@@ -621,6 +625,12 @@
    
   FREESURFACE(pDitherMask);
        
+  /* Map Borders */
+  FREESURFACE(pTheme->NWEST_BORDER_Icon);
+  FREESURFACE(pTheme->NNORTH_BORDER_Icon);
+  FREESURFACE(pTheme->NSOUTH_BORDER_Icon);
+  FREESURFACE(pTheme->NEAST_BORDER_Icon);
+       
   FREE(pTheme);
   return;
 }
diff -u -r fc_bord_serv/client/gui-sdl/gui_tilespec.h 
fc_bord_client/client/gui-sdl/gui_tilespec.h
--- fc_bord_serv/client/gui-sdl/gui_tilespec.h  Mon Jun  9 01:06:06 2003
+++ fc_bord_client/client/gui-sdl/gui_tilespec.h        Sat Jun 28 00:05:00 2003
@@ -71,6 +71,12 @@
         SDL_Surface *OK_PACT_Icon;
        SDL_Surface *CANCEL_PACT_Icon;
        
+       /* borders */
+       SDL_Surface *NWEST_BORDER_Icon;
+       SDL_Surface *NNORTH_BORDER_Icon;
+       SDL_Surface *NSOUTH_BORDER_Icon;
+       SDL_Surface *NEAST_BORDER_Icon;
+       
        /* orders icons */
        SDL_Surface *Order_Icon;
        SDL_Surface *ODisband_Icon;
diff -u -r fc_bord_serv/client/gui-sdl/mapview.c 
fc_bord_client/client/gui-sdl/mapview.c
--- fc_bord_serv/client/gui-sdl/mapview.c       Fri Jun 27 19:38:55 2003
+++ fc_bord_client/client/gui-sdl/mapview.c     Sat Jun 28 12:52:00 2003
@@ -91,6 +91,7 @@
 static SDL_Surface *pBlinkSurfaceB;
 
 static SDL_Surface *pMapGrid[3][2];
+static SDL_Surface ***pMapBorders = NULL;
 static bool UPDATE_OVERVIEW_MAP = FALSE;
 int OVERVIEW_START_X;
 int OVERVIEW_START_Y;
@@ -103,6 +104,8 @@
 
 static void init_dither_tiles(void);
 static void free_dither_tiles(void);
+static void init_borders_tiles(void);
+static void free_borders_tiles(void);
 static void fill_dither_buffers(SDL_Surface **pDitherBufs, int x, int y,
                                        enum tile_terrain_type terrain);
 
@@ -1111,9 +1117,15 @@
   if (pMMap) {
     del_widget_from_gui_list(pMMap);
   }
-  
-  free_dither_tiles();
-  init_dither_tiles();
+
+  /* this is here becouse I need function that is call after game start */
+  if(is_isometric) {  
+    free_dither_tiles();
+    init_dither_tiles();
+
+    free_borders_tiles();
+    init_borders_tiles();
+  }
   
   draw_city_names = TRUE;
   
@@ -1770,17 +1786,54 @@
     SDL_BlitSurface(pMapGrid[color2][1], NULL, pBufSurface, &des);
     des = dst;
   }
-
+  
   /* Draw national borders */
-  if (draw_borders) {
-    struct canvas_store canv;
-    canv.map = pDest;
-    tile_draw_borders_iso(&canv, map_col, map_row, map_x, map_y, D_FULL);
-  }
+  if (draw_borders && (game.borders != 0)) {
+    struct tile *pBorder_Tile;
+    struct player *this_owner = pTile->owner;
+    int x1, y1;
 
+    /* left side */
+    if (this_owner && MAPSTEP(x1, y1, map_col, map_row, DIR8_WEST)
+      && (pBorder_Tile = map_get_tile(x1, y1))
+      && (this_owner != pBorder_Tile->owner)
+      && pBorder_Tile->known) {
+      SDL_BlitSurface(pMapBorders[this_owner->player_no][0], NULL, 
pBufSurface, &des);
+      des = dst;
+    }
+
+    /* top side */
+    if (this_owner && MAPSTEP(x1, y1, map_col, map_row, DIR8_NORTH)
+      && (pBorder_Tile = map_get_tile(x1, y1))
+      && (this_owner != pBorder_Tile->owner)
+      && pBorder_Tile->known) {
+      SDL_BlitSurface(pMapBorders[this_owner->player_no][1], NULL, 
pBufSurface, &des);
+      des = dst;
+    }
+    
+    /* right side */
+    if (this_owner && MAPSTEP(x1, y1, map_col, map_row, DIR8_EAST)
+      && (pBorder_Tile = map_get_tile(x1, y1))
+      && (this_owner != pBorder_Tile->owner)
+      && pBorder_Tile->known) {
+      SDL_BlitSurface(pMapBorders[this_owner->player_no][2], NULL, 
pBufSurface, &des);
+      des = dst;
+    }
+    
+    /* bottom side */
+    if (this_owner && MAPSTEP(x1, y1, map_col, map_row, DIR8_SOUTH)
+      && (pBorder_Tile = map_get_tile(x1, y1))
+      && (this_owner != pBorder_Tile->owner)
+      && pBorder_Tile->known) {
+      SDL_BlitSurface(pMapBorders[this_owner->player_no][3], NULL, 
pBufSurface, &des);
+      des = dst;
+    }
+    
+  }
+  
   /* this option is pure nonsens for me and will be removed soon */
   if (draw_coastline && !draw_terrain) {
-    enum tile_terrain_type t1 = pTile->terrain , t2;
+    enum tile_terrain_type t1 = pTile->terrain, t2;
     int x1, y1;
     Uint32 coast_color = SDL_MapRGB(pBufSurface->format, 255, 255, 0);
     x1 = map_col;
@@ -2601,6 +2670,68 @@
     }
   }
 }
+/* ================================================================ */
+
+/**************************************************************************
+  ...
+**************************************************************************/
+static void init_borders_tiles(void)
+{
+  int i;
+  SDL_Color *color;
+  
+  pMapBorders = CALLOC(game.nplayers + 1, sizeof(SDL_Surface **));
+  for(i=0; i<game.nplayers; i++) {
+    
+    color = get_game_colorRGB(COLOR_STD_RACE0 +
+                       (i % (COLOR_STD_RACE13 - COLOR_STD_RACE0 + 1)));
+    color->unused = 192;
+    
+    pMapBorders[i] = CALLOC(4, sizeof(SDL_Surface *));
+    
+    pMapBorders[i][0] = SDL_DisplayFormat(pTheme->NWEST_BORDER_Icon);
+    SDL_FillRectAlpha(pMapBorders[i][0], NULL, color);
+    SDL_SetColorKey(pMapBorders[i][0], SDL_SRCCOLORKEY|SDL_RLEACCEL,
+                                       get_first_pixel(pMapBorders[i][0]));
+    
+    pMapBorders[i][1] = SDL_DisplayFormat(pTheme->NNORTH_BORDER_Icon);
+    SDL_FillRectAlpha(pMapBorders[i][1], NULL, color);
+    SDL_SetColorKey(pMapBorders[i][1], SDL_SRCCOLORKEY|SDL_RLEACCEL,
+                                       get_first_pixel(pMapBorders[i][1]));
+    
+    pMapBorders[i][2] = SDL_DisplayFormat(pTheme->NEAST_BORDER_Icon);
+    SDL_FillRectAlpha(pMapBorders[i][2], NULL, color);
+    SDL_SetColorKey(pMapBorders[i][2], SDL_SRCCOLORKEY|SDL_RLEACCEL,
+                                       get_first_pixel(pMapBorders[i][2]));
+        
+    pMapBorders[i][3] = SDL_DisplayFormat(pTheme->NSOUTH_BORDER_Icon);
+    SDL_FillRectAlpha(pMapBorders[i][3], NULL, color);
+    SDL_SetColorKey(pMapBorders[i][3], SDL_SRCCOLORKEY|SDL_RLEACCEL,
+                                       get_first_pixel(pMapBorders[i][3]));
+            
+    color->unused = 255;
+  }
+  
+}
+
+/**************************************************************************
+  ...
+**************************************************************************/
+static void free_borders_tiles(void)
+{
+  if(pMapBorders) {
+    int i = 0;
+    while(pMapBorders[i]) {
+      FREESURFACE(pMapBorders[i][0]);
+      FREESURFACE(pMapBorders[i][1]);
+      FREESURFACE(pMapBorders[i][2]);
+      FREESURFACE(pMapBorders[i][3]);
+      FREE(pMapBorders[i]);
+      i++;
+    }
+    FREE(pMapBorders);
+  }
+}
 
 /**************************************************************************
   ...

PNG image

[spec]

; Format and options of this spec file:
options = "+spec2"

[info]

artists = "
   Womoks <s-ren@xxxxxxxxxx>
"

[file]
gfx = "deluxe/NTerritory64"

[grid_main]

x_top_left = 0
y_top_left = 0
dx = 64
dy = 32
is_pixel_border = 0

tiles = { "row", "column","tag"
; Normal Nations Borders

 0,  0, "theme.normal_border_iso_west"
 0,  1, "theme.normal_border_iso_north"
 0,  2, "theme.normal_border_iso_south"
 0,  3, "theme.normal_border_iso_east"

}

[Prev in Thread] Current Thread [Next in Thread]