Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] (PR#2385) unification of draw_part and draw_type
Home

[Freeciv-Dev] (PR#2385) unification of draw_part and draw_type

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#2385) unification of draw_part and draw_type
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Fri, 22 Nov 2002 23:37:24 -0800
Reply-to: rt@xxxxxxxxxxxxxx

This function moves enum draw_part and enum draw_type into
mapview_common.  The code is pretty simple.

I've also added extensively to the comments about it.  If these comments
are not clear (which wouldn't be the first time it's happened), now is
the time to correct them.

jason

Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.11
diff -u -r1.11 mapview_common.h
--- client/mapview_common.h     2002/11/22 18:52:12     1.11
+++ client/mapview_common.h     2002/11/23 07:32:57
@@ -41,6 +41,79 @@
 */
 #define EXTRA_BOTTOM_ROW (is_isometric ? 6 : 1)
 
+/* When drawing a tile (currently only in isometric mode), there are six
+ * relevant parts we can draw.  Each of these is a rectangle
+ * of size NORMAL_TILE_WIDTH/2 x NORMAL_TILE_HEIGHT/2.
+ *
+ * -----------------
+ * |       |       |
+ * | D_T_L | D_T_R |
+ * |       |       |
+ * -----------------
+ * |       |       |
+ * | D_M_L | D_M_R |
+ * |       |       |
+ * -----------------
+ * |       |       |
+ * | D_B_L | D_B_R |
+ * |       |       |
+ * -----------------
+ *
+ * The figure above shows the six drawing areas.  The tile itself occupies
+ * the bottom four rectangles (if it is isometric it will actually fill
+ * only half of each rectangle).  But the sprites for the tile may extend
+ * up above it an additional NORMAL_TILE_HEIGHT/2 pixels.  To get the
+ * Painter's Algorithm (draw stuff in the background before stuff in the
+ * foreground) to work, sometimes we only draw some of these rectangles.
+ * For instance, in isometric view after drawing D_B_L for one tile we have
+ * to draw D_M_R for the tile just down-left from it, then D_T_L for the
+ * tile below it.
+ *
+ * This concept currently only applies to the isometric drawing code, and
+ * currently the D_T_L and D_T_R rectangles are not used.  But either of
+ * these could change in the future.
+ *
+ * T: area above the actual tile.
+ * M: the top of the actual tile.
+ * B: the bottom of the actual tile.
+ * L: left.
+ * R: right.
+ *
+ * These values are used as a mask; see enum draw_type.
+ */
+enum draw_part {
+  D_T_L = 1,
+  D_T_R = 2,
+  D_M_L = 4,
+  D_M_R = 8,
+  D_B_L = 16,
+  D_B_R = 32
+};
+
+/* As explained above, when drawing a tile we will sometimes only draw
+ * parts of the tile.  This is an enumeration of which sets of rectangles
+ * can be used together in isometric view.  If non-isometric view were
+ * to use a similar system it would have a smaller set of rectangles.
+ *
+ * Format: D_[TMB]+_[LR]+.
+ *
+ * Note that each of these sets of rectangles must itelf make up a larger
+ * rectangle.  However, not all 18 possible sub-rectangles are needed.
+ */
+enum draw_type {
+  D_FULL = D_T_L | D_T_R | D_M_L | D_M_R | D_B_L | D_B_R,
+  D_B_LR = D_B_L | D_B_R,
+  D_MB_L = D_M_L | D_B_L,
+  D_MB_R = D_M_R | D_B_R,
+  D_TM_L = D_T_L | D_M_L,
+  D_TM_R = D_T_R | D_M_R,
+  D_T_LR = D_T_L | D_T_R,
+  D_TMB_L = D_T_L | D_M_L | D_B_L,
+  D_TMB_R = D_T_R | D_M_R | D_B_R,
+  D_M_LR = D_M_L | D_M_R,
+  D_MB_LR = D_M_L | D_M_R | D_B_L | D_B_R
+};
+
 void refresh_tile_mapcanvas(int x, int y, bool write_to_screen);
 enum color_std get_grid_color(int x1, int y1, int x2, int y2);
 
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.134
diff -u -r1.134 mapview.c
--- client/gui-gtk/mapview.c    2002/11/22 18:52:12     1.134
+++ client/gui-gtk/mapview.c    2002/11/23 07:32:58
@@ -52,35 +52,6 @@
 /* contains the x0, y0 coordinates of the upper left corner block */
 int map_view_x0, map_view_y0;
 
-/* T: area above the actual tile.
-   M: the top of the actual tile.
-   B: the bottom of the actual tile.
-   L: left.
-   R: right.
-*/
-enum draw_part {
-  D_T_L = 1, D_T_R = 2, D_M_L = 4, D_M_R = 8, D_B_L = 16, D_B_R = 32
-};
-
-/* Format: D_[TMB]+_[LR]+.
-   The drawing algorithm don't take all possible combinations into account,
-   but only those that are rectangles.
-*/
-/* Some usefull definitions: */
-enum draw_type {
-  D_FULL = D_T_L | D_T_R | D_M_L | D_M_R | D_B_L | D_B_R,
-  D_B_LR = D_B_L | D_B_R,
-  D_MB_L = D_M_L | D_B_L,
-  D_MB_R = D_M_R | D_B_R,
-  D_TM_L = D_T_L | D_M_L,
-  D_TM_R = D_T_R | D_M_R,
-  D_T_LR = D_T_L | D_T_R,
-  D_TMB_L = D_T_L | D_M_L | D_B_L,
-  D_TMB_R = D_T_R | D_M_R | D_B_R,
-  D_M_LR = D_M_L | D_M_R,
-  D_MB_LR = D_M_L | D_M_R | D_B_L | D_B_R
-};
-
 static void pixmap_put_overlay_tile(GdkDrawable *pixmap,
                                    int canvas_x, int canvas_y,
                                    struct Sprite *ssprite);
Index: client/gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.22
diff -u -r1.22 mapview.c
--- client/gui-gtk-2.0/mapview.c        2002/11/22 18:52:13     1.22
+++ client/gui-gtk-2.0/mapview.c        2002/11/23 07:32:59
@@ -51,35 +51,6 @@
 /* contains the x0, y0 coordinates of the upper left corner block */
 int map_view_x0, map_view_y0;
 
-/* T: area above the actual tile.
-   M: the top of the actual tile.
-   B: the bottom of the actual tile.
-   L: left.
-   R: right.
-*/
-enum draw_part {
-  D_T_L = 1, D_T_R = 2, D_M_L = 4, D_M_R = 8, D_B_L = 16, D_B_R = 32
-};
-
-/* Format: D_[TMB]+_[LR]+.
-   The drawing algorithm don't take all possible combinations into account,
-   but only those that are rectangles.
-*/
-/* Some usefull definitions: */
-enum draw_type {
-  D_FULL = D_T_L | D_T_R | D_M_L | D_M_R | D_B_L | D_B_R,
-  D_B_LR = D_B_L | D_B_R,
-  D_MB_L = D_M_L | D_B_L,
-  D_MB_R = D_M_R | D_B_R,
-  D_TM_L = D_T_L | D_M_L,
-  D_TM_R = D_T_R | D_M_R,
-  D_T_LR = D_T_L | D_T_R,
-  D_TMB_L = D_T_L | D_M_L | D_B_L,
-  D_TMB_R = D_T_R | D_M_R | D_B_R,
-  D_M_LR = D_M_L | D_M_R,
-  D_MB_LR = D_M_L | D_M_R | D_B_L | D_B_R
-};
-
 static void pixmap_put_overlay_tile(GdkDrawable *pixmap,
                                    int canvas_x, int canvas_y,
                                    struct Sprite *ssprite);
Index: client/gui-mui/graphics.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/graphics.h,v
retrieving revision 1.7
diff -u -r1.7 graphics.h
--- client/gui-mui/graphics.h   2002/03/17 10:48:58     1.7
+++ client/gui-mui/graphics.h   2002/11/23 07:32:59
@@ -67,30 +67,6 @@
 VOID MyBltBitMapRastPort( CONST struct BitMap *srcBitMap, LONG xSrc, LONG 
ySrc, struct RastPort *destRP, LONG xDest, LONG yDest, LONG xSize, LONG ySize, 
ULONG minterm );
 VOID MyBltMaskBitMapRastPort(struct BitMap *srcBitMap, LONG xSrc, LONG ySrc, 
struct RastPort *destRP, LONG xDest, LONG yDest, LONG xSize, LONG ySize, ULONG 
minterm, APTR bltMask);
 
-enum draw_part {
-  D_T_L = 1, D_T_R = 2, D_M_L = 4, D_M_R = 8, D_B_L = 16, D_B_R = 32
-};
-
-/* Format: D_[TMB]+_[LR]+.
-   The drawing algorithm don't take all possible combinations into account,
-   but only those that are rectangles.
-*/
-/* Some usefull definitions: */
-enum draw_type {
-  D_FULL = D_T_L | D_T_R | D_M_L | D_M_R | D_B_L | D_B_R,
-  D_B_LR = D_B_L | D_B_R,
-  D_MB_L = D_M_L | D_B_L,
-  D_MB_R = D_M_R | D_B_R,
-  D_TM_L = D_T_L | D_M_L,
-  D_TM_R = D_T_R | D_M_R,
-  D_T_LR = D_T_L | D_T_R,
-  D_TMB_L = D_T_L | D_M_L | D_B_L,
-  D_TMB_R = D_T_R | D_M_R | D_B_R,
-  D_M_LR = D_M_L | D_M_R,
-  D_MB_LR = D_M_L | D_M_R | D_B_L | D_B_R
-};
-
-
 void really_draw_segment(struct RastPort *rp, int dest_x_add, int dest_y_add,
                          int src_x, int src_y, int dir, bool force);
 void put_one_tile(struct RastPort *rp, int x, int y, enum draw_type draw);
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.36
diff -u -r1.36 mapview.c
--- client/gui-win32/mapview.c  2002/11/19 20:13:39     1.36
+++ client/gui-win32/mapview.c  2002/11/23 07:33:00
@@ -45,29 +45,6 @@
 #include "gui_main.h"
 #include "mapview.h"
 
-enum draw_part {
-  D_T_L = 1, D_T_R = 2, D_M_L = 4, D_M_R = 8, D_B_L = 16, D_B_R = 32
-};
-
-/* Format: D_[TMB]+_[LR]+.
-   The drawing algorithm don't take all possible combinations into account,
-   but only those that are rectangles.
-*/
-/* Some usefull definitions: */
-enum draw_type {
-  D_FULL = D_T_L | D_T_R | D_M_L | D_M_R | D_B_L | D_B_R,
-  D_B_LR = D_B_L | D_B_R,
-  D_MB_L = D_M_L | D_B_L,
-  D_MB_R = D_M_R | D_B_R,
-  D_TM_L = D_T_L | D_M_L,
-  D_TM_R = D_T_R | D_M_R,
-  D_T_LR = D_T_L | D_T_R,
-  D_TMB_L = D_T_L | D_M_L | D_B_L,
-  D_TMB_R = D_T_R | D_M_R | D_B_R,
-  D_M_LR = D_M_L | D_M_R,
-  D_MB_LR = D_M_L | D_M_R | D_B_L | D_B_R
-};
-
 static struct Sprite *indicator_sprite[3];
 
 HDC overviewstoredc;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#2385) unification of draw_part and draw_type, Jason Short via RT <=