Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] (PR#12622) Add canvas and sprite files for ftwl
Home

[Freeciv-Dev] (PR#12622) Add canvas and sprite files for ftwl

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12622) Add canvas and sprite files for ftwl
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Thu, 24 Mar 2005 18:17:48 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12622 >


All the normal changes you may expect. In addition I cleaned up the
general header files a tiny bit.

I will commit this tomorrow.

        Raimar

-- 
 email: i-freeciv-lists@xxxxxxxxxxxxx
  "Debugging is twice as hard as writing the code in the first place.
   Therefore, if you write the code as cleverly as possible, you are,
   by definition, not smart enough to debug it."
    -- Brian W. Kernighan

diff -Nurd -X real.clean/diff_ignore real.clean/client/gui-ftwl/canvas.c 
work/client/gui-ftwl/canvas.c
--- real.clean/client/gui-ftwl/canvas.c 1970-01-01 01:00:00.000000000 +0100
+++ work/client/gui-ftwl/canvas.c       2005-03-25 03:03:01.000000000 +0100
@@ -0,0 +1,220 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996-2005 - Freeciv Development Team
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <assert.h>
+
+#include "log.h"
+#include "back_end.h"
+#include "gui_main.h"          /* for enum_color_to_be_color() */
+#include "widget.h"
+#include "mapview.h"           /* for text_templates */
+
+#include "canvas.h"
+
+/**************************************************************************
+  ...
+**************************************************************************/
+struct canvas *canvas_create(int width, int height)
+{
+  struct canvas *result = fc_malloc(sizeof(*result));
+
+  result->osda = be_create_osda(width, height);
+  result->widget=NULL;
+  return result;
+}
+
+/**************************************************************************
+  ...
+**************************************************************************/
+void canvas_free(struct canvas *store)
+{
+  be_free_osda(store->osda);
+  assert(store->widget == NULL);
+  free(store);
+}
+
+/**************************************************************************
+  ...
+**************************************************************************/
+void canvas_copy(struct canvas *dest, struct canvas *src,
+                int src_x, int src_y, int dest_x, int dest_y, int width,
+                int height)
+{
+  struct ct_size size = { width, height };
+  struct ct_point src_pos = { src_x, src_y };
+  struct ct_point dest_pos = { dest_x, dest_y };
+
+  freelog(LOG_DEBUG, "canvas_copy(src=%p,dest=%p)",src,dest);
+
+  be_copy_osda_to_osda(dest->osda, src->osda, &size, &dest_pos, &src_pos);
+  if (dest->widget) {
+    sw_window_canvas_background_region_needs_repaint(dest->widget, NULL);
+  }
+}
+
+/**************************************************************************
+  Draw some or all of a sprite onto the mapview or citydialog canvas.
+**************************************************************************/
+void canvas_put_sprite(struct canvas *pcanvas,
+                      int canvas_x, int canvas_y,
+                      struct Sprite *sprite,
+                      int offset_x, int offset_y, int width, int height)
+{
+  struct osda *osda = pcanvas->osda;
+  struct ct_point dest_pos = { canvas_x, canvas_y };
+  struct ct_point src_pos = { offset_x, offset_y };
+  struct ct_size size = { width, height };
+
+  freelog(LOG_DEBUG, "gui_put_sprite canvas=%p",pcanvas);
+  be_draw_sprite(osda, sprite, &size, &dest_pos, &src_pos);
+  if (pcanvas->widget) {
+    sw_window_canvas_background_region_needs_repaint(pcanvas->widget,
+                                                    NULL);
+  }
+}
+
+/**************************************************************************
+  Draw a full sprite onto the mapview or citydialog canvas.
+**************************************************************************/
+void canvas_put_sprite_full(struct canvas *pcanvas,
+                           int canvas_x, int canvas_y,
+                           struct Sprite *sprite)
+{
+  struct ct_size size;
+
+  freelog(LOG_DEBUG, "gui_put_sprite_full");
+  be_sprite_get_size(&size, sprite);
+  canvas_put_sprite(pcanvas, canvas_x, canvas_y,
+                   sprite, 0, 0, size.width, size.height);
+}
+
+/****************************************************************************
+  Draw a full sprite onto the canvas.  If "fog" is specified draw it with
+  fog.
+****************************************************************************/
+void canvas_put_sprite_fogged(struct canvas *pcanvas,
+                              int canvas_x, int canvas_y,
+                              struct Sprite *psprite,
+                              bool fog, int fog_x, int fog_y)
+{
+  /* PORTME */
+}
+
+/**************************************************************************
+  Draw a filled-in colored rectangle onto the mapview or citydialog canvas.
+**************************************************************************/
+void canvas_put_rectangle(struct canvas *pcanvas,
+                         enum color_std color,
+                         int canvas_x, int canvas_y, int width, int height)
+{
+  struct ct_rect rect = { canvas_x, canvas_y, width, height };
+
+  freelog(LOG_DEBUG, "gui_put_rectangle(,%d,%d,%d,%d,%d)", color, canvas_x, 
+          canvas_y, width, height);
+  be_draw_region(pcanvas->osda, &rect, enum_color_to_be_color(color));
+  if (pcanvas->widget) {
+    sw_window_canvas_background_region_needs_repaint(pcanvas->widget,
+                                                    &rect);
+  }
+}
+
+/****************************************************************************
+  Fill the area covered by the sprite with the given color.
+****************************************************************************/
+void canvas_fill_sprite_area(struct canvas *pcanvas,
+                             struct Sprite *psprite, enum color_std color,
+                             int canvas_x, int canvas_y)
+{
+  /* PORTME */
+}
+
+/****************************************************************************
+  Fill the area covered by the sprite with the given color.
+****************************************************************************/
+void canvas_fog_sprite_area(struct canvas *pcanvas, struct Sprite *psprite,
+                            int canvas_x, int canvas_y)
+{
+  /* PORTME */
+}
+
+/**************************************************************************
+  Draw a 1-pixel-width colored line onto the mapview or citydialog canvas.
+**************************************************************************/
+void canvas_put_line(struct canvas *pcanvas, enum color_std color,
+                    enum line_type ltype, int start_x, int start_y,
+                    int dx, int dy)
+{
+  struct ct_point start = { start_x, start_y };
+  struct ct_point end = { start_x + dx, start_y + dy};
+  struct ct_rect rect;
+
+  ct_rect_fill_on_2_points(&rect,&start,&end);
+
+  freelog(LOG_DEBUG, "gui_put_line(...)");
+
+  if (ltype == LINE_NORMAL) {
+    be_draw_line(pcanvas->osda, &start, &end, 1, FALSE,
+                enum_color_to_be_color(color));
+  } else if (ltype == LINE_BORDER) {
+    be_draw_line(pcanvas->osda, &start, &end, 2, TRUE,
+                enum_color_to_be_color(color));
+  } else {
+    assert(0);
+  }
+      
+  if (pcanvas->widget) {
+    sw_window_canvas_background_region_needs_repaint(pcanvas->widget,
+                                                    &rect);
+  }
+}
+
+/****************************************************************************
+  Return the size of the given text in the given font.  This size should
+  include the ascent and descent of the text.  Either of width or height
+  may be NULL in which case those values simply shouldn't be filled out.
+****************************************************************************/
+void get_text_size(int *width, int *height,
+                  enum client_font font, const char *text)
+{
+  struct ct_size size;
+  struct ct_string *string = ct_string_clone3(text_templates[font], text);
+
+  be_string_get_size(&size, string);
+
+  if (width) {
+    *width = size.width;
+  }
+  if (height) {
+    *height = size.height;
+  }
+}
+
+/****************************************************************************
+  Draw the text onto the canvas in the given color and font.  The canvas
+  position does not account for the ascent of the text; this function must
+  take care of this manually.  The text will not be NULL but may be empty.
+****************************************************************************/
+void canvas_put_text(struct canvas *pcanvas, int canvas_x, int canvas_y,
+                    enum client_font font, enum color_std color,
+                    const char *text)
+{
+    struct ct_point position={canvas_x, canvas_y};
+    struct ct_string *string=ct_string_clone4(text_templates[font],
+                                             text,color);
+    tr_draw_string(pcanvas->osda,&position,string);
+    ct_string_destroy(string);
+}
diff -Nurd -X real.clean/diff_ignore real.clean/client/gui-ftwl/canvas.h 
work/client/gui-ftwl/canvas.h
--- real.clean/client/gui-ftwl/canvas.h 1970-01-01 01:00:00.000000000 +0100
+++ work/client/gui-ftwl/canvas.h       2005-03-25 02:50:43.000000000 +0100
@@ -0,0 +1,26 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996-2005 - Freeciv Development Team
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+#ifndef FC__CANVAS_H
+#define FC__CANVAS_H
+
+#include "canvas_g.h"
+
+struct osda;
+struct sw_widget;
+
+struct canvas {
+  struct osda *osda;
+  struct sw_widget *widget;
+};
+
+#endif  /* FC__CANVAS_H */
diff -Nurd -X real.clean/diff_ignore real.clean/client/gui-ftwl/graphics.c 
work/client/gui-ftwl/graphics.c
--- real.clean/client/gui-ftwl/graphics.c       2005-03-25 03:13:25.229980256 
+0100
+++ work/client/gui-ftwl/graphics.c     2005-03-25 02:57:11.000000000 +0100
@@ -77,68 +77,3 @@
     radar_gfx_sprite = NULL;
   }
 }
-
-/**************************************************************************
-  Return a NULL-terminated, permanently allocated array of possible
-  graphics types extensions.  Extensions listed first will be checked
-  first.
-**************************************************************************/
-const char **gfx_fileextensions(void)
-{
-  /* PORTME */
-
-  /* hack to allow stub to run */
-  static const char *ext[] = {
-    "png",     /* png should be the default. */
-    /* ...etc... */
-    NULL
-  };
-
-  return ext;
-}
-
-/**************************************************************************
-  Load the given graphics file into a sprite.  This function loads an
-  entire image file, which may later be broken up into individual sprites
-  with crop_sprite.
-**************************************************************************/
-struct Sprite *load_gfxfile(const char *filename)
-{
-  return be_load_gfxfile(filename);
-}
-
-/**************************************************************************
-  Create a new sprite by cropping and taking only the given portion of
-  the image.
-**************************************************************************/
-struct Sprite *crop_sprite(struct Sprite *source,
-                          int x, int y, int width, int height,
-                          struct Sprite *mask, int mask_offset_x,
-                          int mask_offset_y)
-{
-  struct Sprite *result = be_crop_sprite(source, x, y, width, height);
-
-  if (mask) {
-    struct ct_point pos = { mask_offset_x, mask_offset_y };
-
-    be_multiply_alphas(result, mask, &pos);
-  }
-  return result;
-}
-
-/**************************************************************************
-  Free a sprite and all associated image data.
-**************************************************************************/
-void free_sprite(struct Sprite *s)
-{
-  be_free_sprite(s);
-}
-
-void get_sprite_dimensions(struct Sprite *sprite, int *width, int *height)
-{
-  struct ct_size size;
-
-  be_sprite_get_size(&size, sprite);
-  *width = size.width;
-  *height = size.height;
-}
diff -Nurd -X real.clean/diff_ignore real.clean/client/gui-ftwl/gui_main.h 
work/client/gui-ftwl/gui_main.h
--- real.clean/client/gui-ftwl/gui_main.h       2005-03-25 03:13:25.230980104 
+0100
+++ work/client/gui-ftwl/gui_main.h     2005-03-25 03:01:02.000000000 +0100
@@ -18,13 +18,6 @@
 #include "gui_main_g.h"
 #include "common_types.h"
 
-struct osda;
-
-struct canvas {
-  struct osda *osda;
-  struct sw_widget *widget;
-};
-
 void popup_mapcanvas(void);
 void popdown_mapcanvas(void);
 
diff -Nurd -X real.clean/diff_ignore real.clean/client/gui-ftwl/Makefile.am 
work/client/gui-ftwl/Makefile.am
--- real.clean/client/gui-ftwl/Makefile.am      2005-03-25 03:13:25.228980408 
+0100
+++ work/client/gui-ftwl/Makefile.am    2005-03-25 02:56:36.000000000 +0100
@@ -8,6 +8,8 @@
 ## Above, note -I../../intl instead of -I$(top_srdir)/intl is deliberate.
 
 libguiclient_a_SOURCES = \
+       canvas.c        \
+       canvas.h        \
        chatline.c      \
        chatline.h      \
        citydlg.c       \
@@ -56,6 +58,8 @@
        repodlgs.h      \
        spaceshipdlg.c  \
        spaceshipdlg.h  \
+       sprite.c        \
+       sprite.h        \
        wldlg.c         \
        wldlg.h         \
        chat.c          \
diff -Nurd -X real.clean/diff_ignore real.clean/client/gui-ftwl/mapview.c 
work/client/gui-ftwl/mapview.c
--- real.clean/client/gui-ftwl/mapview.c        2005-03-25 03:13:25.232979800 
+0100
+++ work/client/gui-ftwl/mapview.c      2005-03-25 03:06:03.000000000 +0100
@@ -40,6 +40,7 @@
 #include "back_end.h"
 #include "timing.h"
 
+#include "canvas.h"
 #include "gui_text.h"
 #include "mapctrl.h"
 #include "mapview.h"
@@ -139,7 +140,7 @@
   } style[MAX_CITY_DESCR_STYLES];
 } city_descr_styles;
 
-static struct ct_string *text_templates[FONT_COUNT];
+struct ct_string *text_templates[FONT_COUNT];
 
 /**************************************************************************
   Typically an info box is provided to tell the player about the state
@@ -274,25 +275,6 @@
 }
 
 /**************************************************************************
-  ...
-**************************************************************************/
-void canvas_copy(struct canvas *dest, struct canvas *src,
-                int src_x, int src_y, int dest_x, int dest_y, int width,
-                int height)
-{
-  struct ct_size size = { width, height };
-  struct ct_point src_pos = { src_x, src_y };
-  struct ct_point dest_pos = { dest_x, dest_y };
-
-  freelog(LOG_DEBUG, "canvas_copy(src=%p,dest=%p)",src,dest);
-
-  be_copy_osda_to_osda(dest->osda, src->osda, &size, &dest_pos, &src_pos);
-  if (dest->widget) {
-    sw_window_canvas_background_region_needs_repaint(dest->widget, NULL);
-  }
-}
-
-/**************************************************************************
   Refresh (update) the entire map overview.
 **************************************************************************/
 #if 0
@@ -441,91 +423,6 @@
 #endif
 
 /**************************************************************************
-  Draw some or all of a sprite onto the mapview or citydialog canvas.
-**************************************************************************/
-void canvas_put_sprite(struct canvas *pcanvas,
-                      int canvas_x, int canvas_y,
-                      struct Sprite *sprite,
-                      int offset_x, int offset_y, int width, int height)
-{
-  struct osda *osda = pcanvas->osda;
-  struct ct_point dest_pos = { canvas_x, canvas_y };
-  struct ct_point src_pos = { offset_x, offset_y };
-  struct ct_size size = { width, height };
-
-  freelog(LOG_DEBUG, "gui_put_sprite canvas=%p",pcanvas);
-  be_draw_sprite(osda, sprite, &size, &dest_pos, &src_pos);
-  if (pcanvas->widget) {
-    sw_window_canvas_background_region_needs_repaint(pcanvas->widget,
-                                                    NULL);
-  }
-}
-
-/**************************************************************************
-  Draw a full sprite onto the mapview or citydialog canvas.
-**************************************************************************/
-void canvas_put_sprite_full(struct canvas *pcanvas,
-                           int canvas_x, int canvas_y,
-                           struct Sprite *sprite)
-{
-  struct ct_size size;
-
-  freelog(LOG_DEBUG, "gui_put_sprite_full");
-  be_sprite_get_size(&size, sprite);
-  canvas_put_sprite(pcanvas, canvas_x, canvas_y,
-                   sprite, 0, 0, size.width, size.height);
-}
-
-/**************************************************************************
-  Draw a filled-in colored rectangle onto the mapview or citydialog canvas.
-**************************************************************************/
-void canvas_put_rectangle(struct canvas *pcanvas,
-                         enum color_std color,
-                         int canvas_x, int canvas_y, int width, int height)
-{
-  struct ct_rect rect = { canvas_x, canvas_y, width, height };
-
-  freelog(LOG_DEBUG, "gui_put_rectangle(,%d,%d,%d,%d,%d)", color, canvas_x, 
-          canvas_y, width, height);
-  be_draw_region(pcanvas->osda, &rect, enum_color_to_be_color(color));
-  if (pcanvas->widget) {
-    sw_window_canvas_background_region_needs_repaint(pcanvas->widget,
-                                                    &rect);
-  }
-}
-
-/**************************************************************************
-  Draw a 1-pixel-width colored line onto the mapview or citydialog canvas.
-**************************************************************************/
-void canvas_put_line(struct canvas *pcanvas, enum color_std color,
-                    enum line_type ltype, int start_x, int start_y,
-                    int dx, int dy)
-{
-  struct ct_point start = { start_x, start_y };
-  struct ct_point end = { start_x + dx, start_y + dy};
-  struct ct_rect rect;
-
-  ct_rect_fill_on_2_points(&rect,&start,&end);
-
-  freelog(LOG_DEBUG, "gui_put_line(...)");
-
-  if (ltype == LINE_NORMAL) {
-    be_draw_line(pcanvas->osda, &start, &end, 1, FALSE,
-                enum_color_to_be_color(color));
-  } else if (ltype == LINE_BORDER) {
-    be_draw_line(pcanvas->osda, &start, &end, 2, TRUE,
-                enum_color_to_be_color(color));
-  } else {
-    assert(0);
-  }
-      
-  if (pcanvas->widget) {
-    sw_window_canvas_background_region_needs_repaint(pcanvas->widget,
-                                                    &rect);
-  }
-}
-
-/**************************************************************************
   Flush the given part of the canvas buffer (if there is one) to the
   screen.
 **************************************************************************/
@@ -1312,28 +1209,6 @@
 /**************************************************************************
   ...
 **************************************************************************/
-struct canvas *canvas_create(int width, int height)
-{
-  struct canvas *result = fc_malloc(sizeof(*result));
-
-  result->osda = be_create_osda(width, height);
-  result->widget=NULL;
-  return result;
-}
-
-/**************************************************************************
-  ...
-**************************************************************************/
-void canvas_free(struct canvas *store)
-{
-  be_free_osda(store->osda);
-  assert(store->widget == NULL);
-  free(store);
-}
-
-/**************************************************************************
-  ...
-**************************************************************************/
 static void unshow_actions(void)
 {
   int i;
@@ -1588,37 +1463,6 @@
   /* Nothing */
 }
 
-/****************************************************************************
-  Draw a full sprite onto the canvas.  If "fog" is specified draw it with
-  fog.
-****************************************************************************/
-void canvas_put_sprite_fogged(struct canvas *pcanvas,
-                              int canvas_x, int canvas_y,
-                              struct Sprite *psprite,
-                              bool fog, int fog_x, int fog_y)
-{
-  /* PORTME */
-}
-
-/****************************************************************************
-  Fill the area covered by the sprite with the given color.
-****************************************************************************/
-void canvas_fill_sprite_area(struct canvas *pcanvas,
-                             struct Sprite *psprite, enum color_std color,
-                             int canvas_x, int canvas_y)
-{
-  /* PORTME */
-}
-
-/****************************************************************************
-  Fill the area covered by the sprite with the given color.
-****************************************************************************/
-void canvas_fog_sprite_area(struct canvas *pcanvas, struct Sprite *psprite,
-                            int canvas_x, int canvas_y)
-{
-  /* PORTME */
-}
-
 struct tile *focus_tile;
 
 /****************************************************************************
@@ -1660,43 +1504,6 @@
 }
 
 /****************************************************************************
-  Return the size of the given text in the given font.  This size should
-  include the ascent and descent of the text.  Either of width or height
-  may be NULL in which case those values simply shouldn't be filled out.
-****************************************************************************/
-void get_text_size(int *width, int *height,
-                  enum client_font font, const char *text)
-{
-  struct ct_size size;
-  struct ct_string *string = ct_string_clone3(text_templates[font], text);
-
-  be_string_get_size(&size, string);
-
-  if (width) {
-    *width = size.width;
-  }
-  if (height) {
-    *height = size.height;
-  }
-}
-
-/****************************************************************************
-  Draw the text onto the canvas in the given color and font.  The canvas
-  position does not account for the ascent of the text; this function must
-  take care of this manually.  The text will not be NULL but may be empty.
-****************************************************************************/
-void canvas_put_text(struct canvas *pcanvas, int canvas_x, int canvas_y,
-                    enum client_font font, enum color_std color,
-                    const char *text)
-{
-    struct ct_point position={canvas_x, canvas_y};
-    struct ct_string *string=ct_string_clone4(text_templates[font],
-                                             text,color);
-    tr_draw_string(pcanvas->osda,&position,string);
-    ct_string_destroy(string);
-}
-
-/****************************************************************************
   Called by the tileset code to set the font size that should be used to
   draw the city names and productions.
 ****************************************************************************/
diff -Nurd -X real.clean/diff_ignore real.clean/client/gui-ftwl/mapview.h 
work/client/gui-ftwl/mapview.h
--- real.clean/client/gui-ftwl/mapview.h        2005-03-25 03:13:25.233979648 
+0100
+++ work/client/gui-ftwl/mapview.h      2005-03-25 03:02:33.000000000 +0100
@@ -22,4 +22,6 @@
 void clear_focus_tile(void);
 struct tile *get_focus_tile(void);
 
+extern struct ct_string *text_templates[FONT_COUNT];
+
 #endif                         /* FC__MAPVIEW_H */
diff -Nurd -X real.clean/diff_ignore real.clean/client/gui-ftwl/sprite.c 
work/client/gui-ftwl/sprite.c
--- real.clean/client/gui-ftwl/sprite.c 1970-01-01 01:00:00.000000000 +0100
+++ work/client/gui-ftwl/sprite.c       2005-03-25 03:04:22.000000000 +0100
@@ -0,0 +1,86 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996-2005 - Freeciv Development Team
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>            /* for NULL */
+
+#include "back_end.h"
+
+#include "sprite.h"
+
+/**************************************************************************
+  Return a NULL-terminated, permanently allocated array of possible
+  graphics types extensions.  Extensions listed first will be checked
+  first.
+**************************************************************************/
+const char **gfx_fileextensions(void)
+{
+  static const char *ext[] = {
+    "png",     /* png should be the default. */
+    NULL
+  };
+
+  return ext;
+}
+
+/**************************************************************************
+  Load the given graphics file into a sprite.  This function loads an
+  entire image file, which may later be broken up into individual sprites
+  with crop_sprite.
+**************************************************************************/
+struct Sprite *load_gfxfile(const char *filename)
+{
+  return be_load_gfxfile(filename);
+}
+
+/**************************************************************************
+  Create a new sprite by cropping and taking only the given portion of
+  the image.
+**************************************************************************/
+struct Sprite *crop_sprite(struct Sprite *source,
+                          int x, int y, int width, int height,
+                          struct Sprite *mask, int mask_offset_x,
+                          int mask_offset_y)
+{
+  struct Sprite *result = be_crop_sprite(source, x, y, width, height);
+
+  if (mask) {
+    struct ct_point pos = { mask_offset_x, mask_offset_y };
+
+    be_multiply_alphas(result, mask, &pos);
+  }
+  return result;
+}
+
+/****************************************************************************
+  Find the dimensions of the sprite.
+****************************************************************************/
+void get_sprite_dimensions(struct Sprite *sprite, int *width, int *height)
+{
+  struct ct_size size;
+
+  be_sprite_get_size(&size, sprite);
+  *width = size.width;
+  *height = size.height;
+}
+
+/**************************************************************************
+  Free a sprite and all associated image data.
+**************************************************************************/
+void free_sprite(struct Sprite *s)
+{
+  be_free_sprite(s);
+}
diff -Nurd -X real.clean/diff_ignore real.clean/client/gui-ftwl/sprite.h 
work/client/gui-ftwl/sprite.h
--- real.clean/client/gui-ftwl/sprite.h 1970-01-01 01:00:00.000000000 +0100
+++ work/client/gui-ftwl/sprite.h       2005-03-25 02:56:16.000000000 +0100
@@ -0,0 +1,21 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996-2005 - Freeciv Development Team
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+#ifndef FC__SPRITE_H
+#define FC__SPRITE_H
+
+#include "sprite_g.h"
+
+/* struct Sprite is backend specific */
+
+#endif  /* FC__SPRITE_H */
+
diff -Nurd -X real.clean/diff_ignore real.clean/client/include/canvas_g.h 
work/client/include/canvas_g.h
--- real.clean/client/include/canvas_g.h        2005-03-25 03:13:25.233979648 
+0100
+++ work/client/include/canvas_g.h      2005-03-25 02:59:03.000000000 +0100
@@ -13,12 +13,12 @@
 #ifndef FC__CANVAS_G_H
 #define FC__CANVAS_G_H
 
-#include "fc_types.h"
+#include "shared.h"            /* bool type */
 
 #include "colors_g.h"
-#include "sprite_g.h"
 
-struct canvas;
+struct Sprite;
+struct canvas;                 /* opaque type, real type is gui-dep */
 
 /* Creator and destructor */
 struct canvas *canvas_create(int width, int height);
diff -Nurd -X real.clean/diff_ignore real.clean/client/include/sprite_g.h 
work/client/include/sprite_g.h
--- real.clean/client/include/sprite_g.h        2005-03-25 03:13:25.234979496 
+0100
+++ work/client/include/sprite_g.h      2005-03-25 02:43:42.000000000 +0100
@@ -13,8 +13,6 @@
 #ifndef FC__SPRITE_G_H
 #define FC__SPRITE_G_H
 
-#include "shared.h"            /* bool type */
-
 struct Sprite;                 /* opaque type, real type is gui-dep */
 
 const char **gfx_fileextensions(void);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12622) Add canvas and sprite files for ftwl, Raimar Falke <=