Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] (PR#2058) user option for eye candy
Home

[Freeciv-Dev] (PR#2058) user option for eye candy

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: dspeyer@xxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#2058) user option for eye candy
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Wed, 6 Nov 2002 02:56:43 -0800
Reply-to: rt@xxxxxxxxxxxxxx

The eye candy and multi-dithering features should be user options.

This is a preliminary patch to for a view option for multi-dithering. 
Daniel, you can also use it as a template for a similar eye candy 
option.  Note it is not quite complete, since the option should be 
disabled when using a non-isometric tileset.

jason

? client/diff
? client/gui-gtk-2.0/annotate
? client/gui-gtk-2.0/diff
? client/gui-stub/stub-update.diff
Index: client//control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.85
diff -u -r1.85 control.c
--- client//control.c   2002/11/01 17:51:12     1.85
+++ client//control.c   2002/11/06 10:44:19
@@ -1105,6 +1105,18 @@
 }
 
 /**************************************************************************
+ Toggle display multi-dithering
+**************************************************************************/
+void request_toggle_multi_dithering(void)
+{
+  if (get_client_state() != CLIENT_GAME_RUNNING_STATE)
+    return;
+
+  draw_multi_dithering = !draw_multi_dithering;
+  update_map_canvas_visible();
+}
+
+/**************************************************************************
 ...
 **************************************************************************/
 void request_center_focus_unit(void)
@@ -1847,4 +1859,12 @@
 void key_fog_of_war_toggle(void)
 {
   request_toggle_fog_of_war();
+}
+
+/**************************************************************************
+  A key was pressed to toggle multi-dithering.
+**************************************************************************/
+void key_multi_dithering_toggle(void)
+{
+  request_toggle_multi_dithering();
 }
Index: client//control.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.h,v
retrieving revision 1.29
diff -u -r1.29 control.h
--- client//control.h   2002/11/01 17:51:12     1.29
+++ client//control.h   2002/11/06 10:44:19
@@ -79,6 +79,7 @@
 void request_toggle_units(void);
 void request_toggle_focus_unit(void);
 void request_toggle_fog_of_war(void);
+void request_toggle_multi_dithering(void);
 
 void wakeup_sentried_units(int x, int y);
 
@@ -112,6 +113,7 @@
 void key_units_toggle(void);
 void key_focus_unit_toggle(void);
 void key_fog_of_war_toggle(void);
+void key_multi_dithering_toggle(void);
 void key_end_turn(void);
 void key_map_grid_toggle(void);
 void key_move_north(void);
Index: client//options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.66
diff -u -r1.66 options.c
--- client//options.c   2002/11/01 18:11:42     1.66
+++ client//options.c   2002/11/06 10:44:19
@@ -131,6 +131,7 @@
 bool draw_units = TRUE;
 bool draw_focus_unit = FALSE;
 bool draw_fog_of_war = TRUE;
+bool draw_multi_dithering = TRUE;
 
 #define VIEW_OPTION(name) { #name, &name }
 #define VIEW_OPTION_TERMINATOR { NULL, NULL }
@@ -151,6 +152,7 @@
   VIEW_OPTION(draw_units),
   VIEW_OPTION(draw_focus_unit),
   VIEW_OPTION(draw_fog_of_war),
+  VIEW_OPTION(draw_multi_dithering),
   VIEW_OPTION_TERMINATOR
 };
 
Index: client//options.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.h,v
retrieving revision 1.21
diff -u -r1.21 options.h
--- client//options.h   2002/11/01 18:11:42     1.21
+++ client//options.h   2002/11/06 10:44:20
@@ -88,6 +88,7 @@
 extern bool draw_units;
 extern bool draw_focus_unit;
 extern bool draw_fog_of_war;
+extern bool draw_multi_dithering;
 
 typedef struct {
        char *name;
Index: client//tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.85
diff -u -r1.85 tilespec.c
--- client//tilespec.c  2002/09/28 01:36:20     1.85
+++ client//tilespec.c  2002/11/06 10:44:20
@@ -476,6 +476,15 @@
   if (is_isometric) {
     SET_SPRITE(black_tile, "t.black_tile");
     SET_SPRITE(dither_tile, "t.dither_tile");
+    SET_SPRITE_ALT(multi_dither_tile[0], "t.multi_dither_tile_0x0", 
"t.dither_tile");
+    SET_SPRITE_ALT(multi_dither_tile[1], "t.multi_dither_tile_0x1", 
"t.dither_tile");
+    SET_SPRITE_ALT(multi_dither_tile[2], "t.multi_dither_tile_0x2", 
"t.dither_tile");
+    SET_SPRITE_ALT(multi_dither_tile[3], "t.multi_dither_tile_1x0", 
"t.dither_tile");
+    SET_SPRITE_ALT(multi_dither_tile[4], "t.multi_dither_tile_1x1", 
"t.dither_tile");
+    SET_SPRITE_ALT(multi_dither_tile[5], "t.multi_dither_tile_1x2", 
"t.dither_tile");
+    SET_SPRITE_ALT(multi_dither_tile[6], "t.multi_dither_tile_2x0", 
"t.dither_tile");
+    SET_SPRITE_ALT(multi_dither_tile[7], "t.multi_dither_tile_2x1", 
"t.dither_tile");
+    SET_SPRITE_ALT(multi_dither_tile[8], "t.multi_dither_tile_2x2", 
"t.dither_tile");
     SET_SPRITE(coast_color, "t.coast_color");
   }
 
@@ -679,6 +688,27 @@
 
   sprites.city.tile_wall = NULL;    /* no place to initialize this variable */
   sprites.city.tile = NULL;         /* no place to initialize this variable */
+
+  /* These may or may not be here, so we accept NULLs if they're not.
+     We'll just remember the possibility at runtime */
+  for(i=0; i<T_LAST; i++){
+    sprites.tx.eyecandy[i][0]=sprites.tx.eyecandy[i][1]=NULL;
+  }
+  sprites.tx.eyecandy[T_ARCTIC][0] =  hash_lookup_data(sprite_hash, 
"ec.arctic1");
+  sprites.tx.eyecandy[T_ARCTIC][1] =  hash_lookup_data(sprite_hash, 
"ec.arctic2");
+  sprites.tx.eyecandy[T_DESERT][0] =  hash_lookup_data(sprite_hash, 
"ec.desert1");
+  sprites.tx.eyecandy[T_DESERT][1] =  hash_lookup_data(sprite_hash, 
"ec.desert2");
+  sprites.tx.eyecandy[T_GRASSLAND][0] =  hash_lookup_data(sprite_hash, 
"ec.grass1");
+  sprites.tx.eyecandy[T_GRASSLAND][1] =  hash_lookup_data(sprite_hash, 
"ec.grass2");
+  sprites.tx.eyecandy[T_JUNGLE][0] =  hash_lookup_data(sprite_hash, 
"ec.jungle1");
+  sprites.tx.eyecandy[T_JUNGLE][1] =  hash_lookup_data(sprite_hash, 
"ec.jungle2");
+  sprites.tx.eyecandy[T_PLAINS][0] =  hash_lookup_data(sprite_hash, 
"ec.plains1");
+  sprites.tx.eyecandy[T_PLAINS][1] =  hash_lookup_data(sprite_hash, 
"ec.plains2");
+  sprites.tx.eyecandy[T_SWAMP][0] =  hash_lookup_data(sprite_hash, 
"ec.swamp1");
+  sprites.tx.eyecandy[T_SWAMP][1] =  hash_lookup_data(sprite_hash, 
"ec.swamp2");
+  sprites.tx.eyecandy[T_TUNDRA][0] =  hash_lookup_data(sprite_hash, 
"ec.tundra1");
+  sprites.tx.eyecandy[T_TUNDRA][1] =  hash_lookup_data(sprite_hash, 
"ec.tundra2");
+
 }
 
 /**********************************************************************
@@ -1210,6 +1240,15 @@
                            || ttype_near[DIR8_WEST] == T_OCEAN);
        *sprs++ = sprites.tx.spec_river[tileno];
       }
+    }
+    /*The final formula is pretty random -- I don't want any visible pattern, 
but I do want
+      it to be deterministic.  Where the eyecandy goes doesn't matter, but it 
shouldn't shift
+      around with each redraw */
+    if (sprites.tx.eyecandy[ttype][0] && !tspecial && 
((x*512+y)*(x*512+y))%5==1){
+      *sprs++ = sprites.tx.eyecandy[ttype][0];
+    }
+    if (sprites.tx.eyecandy[ttype][1] && !tspecial && 
((y*512+x)*(y*512+x))%5==1){
+      *sprs++ = sprites.tx.eyecandy[ttype][1];
     }
   } else {
     *solid_bg = 1;
Index: client//tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.30
diff -u -r1.30 tilespec.h
--- client//tilespec.h  2002/09/28 01:36:20     1.30
+++ client//tilespec.h  2002/11/06 10:44:21
@@ -91,6 +91,7 @@
 
     *black_tile,      /* only used for isometric view */
     *dither_tile,     /* only used for isometric view */
+    *multi_dither_tile[9],
     *coast_color;     /* only used for isometric view */
   struct {
     struct Sprite
@@ -175,6 +176,7 @@
       *spec_river[NUM_DIRECTION_NSEW],
       *darkness[NUM_DIRECTION_NSEW],         /* first unused */
       *river_outlet[4],                /* indexed by enum direction4 */
+      *eyecandy[T_LAST][2],
       /* for isometric */
       *spec_forest[NUM_DIRECTION_NSEW],
       *spec_mountain[NUM_DIRECTION_NSEW],
Index: client//gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.127
diff -u -r1.127 mapview.c
--- client//gui-gtk/mapview.c   2002/08/25 11:20:56     1.127
+++ client//gui-gtk/mapview.c   2002/11/06 10:44:22
@@ -1964,12 +1964,12 @@
 static void dither_tile(GdkDrawable *pixmap, struct Sprite **dither,
                        int canvas_x, int canvas_y,
                        int offset_x, int offset_y,
-                       int width, int height, int fog)
+                       int width, int height, int fog, int which)
 {
   if (!width || !height)
     return;
 
-  gdk_gc_set_clip_mask(civ_gc, sprites.dither_tile->mask);
+  gdk_gc_set_clip_mask(civ_gc, sprites.multi_dither_tile[which]->mask);
   gdk_gc_set_clip_origin(civ_gc, canvas_x, canvas_y);
   assert(offset_x == 0 || offset_x == NORMAL_TILE_WIDTH/2);
   assert(offset_y == 0 || offset_y == NORMAL_TILE_HEIGHT/2);
@@ -2020,7 +2020,7 @@
 
   if (fog) {
     gdk_gc_set_clip_origin(fill_tile_gc, canvas_x, canvas_y);
-    gdk_gc_set_clip_mask(fill_tile_gc, sprites.dither_tile->mask);
+    gdk_gc_set_clip_mask(fill_tile_gc, sprites.multi_dither_tile[which]->mask);
     gdk_gc_set_foreground(fill_tile_gc, colors_standard[COLOR_STD_BLACK]);
     gdk_gc_set_stipple(fill_tile_gc, black50);
 
@@ -2148,7 +2148,7 @@
     /*** Dither base terrain ***/
     if (draw_terrain)
       dither_tile(pm, dither, canvas_x, canvas_y,
-                 offset_x, offset_y, width, height, fog);
+                 offset_x, offset_y, width, height, fog, ((x%3) * 3) + (y%3));
   }
 
   /*** Rest of terrain and specials ***/
Index: client//gui-gtk/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/menu.c,v
retrieving revision 1.69
diff -u -r1.69 menu.c
--- client//gui-gtk/menu.c      2002/06/23 16:06:24     1.69
+++ client//gui-gtk/menu.c      2002/11/06 10:44:22
@@ -92,6 +92,7 @@
   MENU_VIEW_SHOW_UNITS,
   MENU_VIEW_SHOW_FOCUS_UNIT,
   MENU_VIEW_SHOW_FOG_OF_WAR,
+  MENU_VIEW_SHOW_MULTI_DITHERING,
   MENU_VIEW_CENTER_VIEW,
 
   MENU_ORDER_BUILD_CITY,     /* shared with BUILD_WONDER */
@@ -285,6 +286,10 @@
     if (draw_fog_of_war ^ GTK_CHECK_MENU_ITEM(widget)->active)
       key_fog_of_war_toggle();
     break;
+  case MENU_VIEW_SHOW_MULTI_DITHERING:
+    if (draw_multi_dithering ^ GTK_CHECK_MENU_ITEM(widget)->active)
+      key_multi_dithering_toggle();
+    break;
   case MENU_VIEW_CENTER_VIEW:
     center_on_unit();
     break;
@@ -632,6 +637,12 @@
        view_menu_callback,     MENU_VIEW_SHOW_FOG_OF_WAR,              
"<CheckItem>"   },
   { "/" N_("View") "/sep2",                            NULL,
        NULL,                   0,                                      
"<Separator>"   },
+  { "/" N_("View") "/" N_("Varied tile borders"),      NULL,
+       view_menu_callback,     MENU_VIEW_SHOW_MULTI_DITHERING,
+       "<CheckItem>" },
+  { "/" N_("View") "/sep3",                            NULL,
+       NULL,                   0,
+       "<Separator>"   },
   { "/" N_("View") "/" N_("_Center View"),             "c",
        view_menu_callback,     MENU_VIEW_CENTER_VIEW                           
        },
   /* Orders menu ... */
@@ -996,6 +1007,8 @@
     menus_set_active("<main>/_View/Focus Unit", draw_focus_unit);
     menus_set_sensitive("<main>/_View/Focus Unit", !draw_units);
     menus_set_active("<main>/_View/Fog of War", draw_fog_of_war);
+    menus_set_active("<main>/_View/Varied tile borders",
+                    draw_multi_dithering);
 
     /* Remaining part of this function: Update Orders menu */
 
Index: client//gui-gtk-2.0/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/menu.c,v
retrieving revision 1.7
diff -u -r1.7 menu.c
--- client//gui-gtk-2.0/menu.c  2002/10/13 21:45:24     1.7
+++ client//gui-gtk-2.0/menu.c  2002/11/06 10:44:23
@@ -93,6 +93,7 @@
   MENU_VIEW_SHOW_UNITS,
   MENU_VIEW_SHOW_FOCUS_UNIT,
   MENU_VIEW_SHOW_FOG_OF_WAR,
+  MENU_VIEW_SHOW_MULTI_DITHERING,
   MENU_VIEW_CENTER_VIEW,
 
   MENU_ORDER_BUILD_CITY,     /* shared with BUILD_WONDER */
@@ -286,6 +287,10 @@
     if (draw_fog_of_war ^ GTK_CHECK_MENU_ITEM(widget)->active)
       key_fog_of_war_toggle();
     break;
+  case MENU_VIEW_SHOW_MULTI_DITHERING:
+    if (draw_multi_dithering ^ GTK_CHECK_MENU_ITEM(widget)->active)
+      key_multi_dithering_toggle();
+    break;
   case MENU_VIEW_CENTER_VIEW:
     center_on_unit();
     break;
@@ -633,6 +638,12 @@
        view_menu_callback,     MENU_VIEW_SHOW_FOG_OF_WAR,              
"<CheckItem>"   },
   { "/" N_("View") "/sep2",                            NULL,
        NULL,                   0,                                      
"<Separator>"   },
+  { "/" N_("View") "/" N_("Varied tile borders"),      NULL,
+       view_menu_callback,     MENU_VIEW_SHOW_MULTI_DITHERING,
+       "<CheckItem>" },
+  { "/" N_("View") "/sep3",                            NULL,
+       NULL,                   0,
+       "<Separator>"   },
   { "/" N_("View") "/" N_("_Center View"),             "c",
        view_menu_callback,     MENU_VIEW_CENTER_VIEW                           
        },
   /* Orders menu ... */
@@ -991,6 +1002,8 @@
     menus_set_active("<main>/_View/Focus Unit", draw_focus_unit);
     menus_set_sensitive("<main>/_View/Focus Unit", !draw_units);
     menus_set_active("<main>/_View/Fog of War", draw_fog_of_war);
+    menus_set_active("<main>/_View/Varied tile borders",
+                    draw_multi_dithering);
 
     /* Remaining part of this function: Update Orders menu */
 
Index: client//gui-xaw/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/menu.c,v
retrieving revision 1.49
diff -u -r1.49 menu.c
--- client//gui-xaw/menu.c      2002/02/11 13:55:48     1.49
+++ client//gui-xaw/menu.c      2002/11/06 10:44:23
@@ -143,6 +143,9 @@
     { { N_("Focus Unit"), 0           },      "", MENU_VIEW_SHOW_FOCUS_UNIT, 0 
},
     { { N_("Fog of War"), 0           },      "", MENU_VIEW_SHOW_FOG_OF_WAR, 0 
},
     { { 0                             },      "", MENU_SEPARATOR_LINE, 0 },
+    { { N_("Varied tile borders"), 0  },      "",
+      MENU_VIEW_SHOW_MULTI_DITHERING, 0},
+    { { 0                             },      "", MENU_SEPARATOR_LINE, 0 },
     { { N_("Center View"), 0          },     "c", MENU_VIEW_CENTER_VIEW, 0 },
     { { 0,                            },       0, MENU_END_OF_LIST, 0 }
 };
@@ -288,6 +291,7 @@
     menu_entry_sensitive(MENU_VIEW, MENU_VIEW_SHOW_UNITS, 1);
     menu_entry_sensitive(MENU_VIEW, MENU_VIEW_SHOW_FOCUS_UNIT, !draw_units);
     menu_entry_sensitive(MENU_VIEW, MENU_VIEW_SHOW_FOG_OF_WAR, 1);
+    menu_entry_sensitive(MENU_VIEW, MENU_VIEW_MULTI_DITHERING, 1);
 
     menu_entry_sensitive(MENU_GAME, MENU_GAME_OPTIONS, 1);
     menu_entry_sensitive(MENU_GAME, MENU_GAME_MSG_OPTIONS, 1);
@@ -543,6 +547,9 @@
     break;
   case MENU_VIEW_SHOW_FOG_OF_WAR:
     key_fog_of_war_toggle();
+    break;
+  case MENU_VIEW_MULTI_DITHERING:
+    key_multi_dithering_toggle();
     break;
   case MENU_VIEW_CENTER_VIEW:
     request_center_focus_unit();
Index: client//gui-xaw/menu.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/menu.h,v
retrieving revision 1.13
diff -u -r1.13 menu.h
--- client//gui-xaw/menu.h      2001/04/20 22:16:01     1.13
+++ client//gui-xaw/menu.h      2002/11/06 10:44:23
@@ -63,6 +63,7 @@
   MENU_VIEW_SHOW_UNITS,
   MENU_VIEW_SHOW_FOCUS_UNIT,
   MENU_VIEW_SHOW_FOG_OF_WAR,
+  MENU_VIEW_SHOW_MULTI_DITHERING,
   MENU_VIEW_CENTER_VIEW,
 
   MENU_ORDER_BUILD_CITY,

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#2058) user option for eye candy, Jason Short via RT <=