Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2005:
[Freeciv-Dev] Re: (PR#14639) Patch for SDL client
Home

[Freeciv-Dev] Re: (PR#14639) Patch for SDL client

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#14639) Patch for SDL client
From: "Christian Prochaska" <cp.ml.freeciv.dev@xxxxxxxxxxxxxx>
Date: Tue, 29 Nov 2005 14:38:45 -0800
Reply-to: bugs@xxxxxxxxxxx

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

Jason Short wrote:

><URL: http://bugs.freeciv.org/Ticket/Display.html?id=14639 >
>
>The next thing to do is fix the cursors code.  The new cursor interface
>in tilespec.h should be used, rather than copying over duplicates of the
>cursor xbm files.
>
>-jason
>
>
>  
>
Patch attached (it also includes "themes.c" which is needed for
compiling the client).

(Sorry for triple post. The first two posts didn't appear on the mailing list, 
because my email suffix was automatically changed to
googlemail.com and so the address wasn't recognized as being subscribed to the 
list anymore)





diff -u -r -b -B -N -X devel/diff_ignore 
devel_distclean/client/gui-sdl/graphics.c devel/client/gui-sdl/graphics.c
--- devel_distclean/client/gui-sdl/graphics.c   2005-11-27 01:35:27.000000000 
+0100
+++ devel/client/gui-sdl/graphics.c     2005-11-27 13:29:28.000000000 +0100
@@ -67,15 +67,6 @@
 
 /* ------------------------------ */
 
-#include "cursors/goto_cursor.xbm"
-#include "cursors/goto_cursor_mask.xbm"
-#include "cursors/drop_cursor.xbm"
-#include "cursors/drop_cursor_mask.xbm"
-#include "cursors/nuke_cursor.xbm"
-#include "cursors/nuke_cursor_mask.xbm"
-#include "cursors/patrol_cursor.xbm"
-#include "cursors/patrol_cursor_mask.xbm"
-
 struct main Main;
 
 static SDL_Surface *pIntro_gfx = NULL;
@@ -86,49 +77,9 @@
 SDL_Cursor *pNuke_Cursor;
 SDL_Cursor *pPatrol_Cursor;
 
-static SDL_Cursor *init_cursor(const char *image_data,
-                              const char *image_mask, int width,
-                              int height, int hot_x, int hot_y);
-
 /* ============ FreeCiv sdl graphics function =========== */
 
 /**************************************************************************
-  Convert cursor from "xbm" format to SDL_Cursor format and create them.
-**************************************************************************/
-static SDL_Cursor *init_cursor(const char *image_data,
-                              const char *image_mask, int width,
-                              int height, int hot_x, int hot_y)
-{
-  Uint8 *data;
-  Uint8 *mask;
-  SDL_Cursor *mouse;
-  int i = 0;
-  size_t size = height << 2;
-
-  data = MALLOC(size);
-  mask = MALLOC(size);
-
-  while (i != size) {
-    data[i] = image_data[i + 3];
-    mask[i] = image_mask[i + 3];
-    data[i + 1] = image_data[i + 2];
-    mask[i + 1] = image_mask[i + 2];
-    data[i + 2] = image_data[i + 1];
-    mask[i + 2] = image_mask[i + 1];
-    data[i + 3] = image_data[i];
-    mask[i + 3] = image_mask[i];
-    i += 4;
-  }
-
-  mouse = SDL_CreateCursor(data, mask, width, height, hot_x, hot_y);
-  
-  FREE( data );
-  FREE( mask );
-  
-  return mouse;
-}
-
-/**************************************************************************
   Create new surface (pRect->w x pRect->h size) and copy pRect area of
   pSource.
   if pRect == NULL then create copy of entire pSource.
@@ -3525,29 +3476,27 @@
 **************************************************************************/
 void load_cursors(void)
 {
+  struct sprite *cursor_sprite;
+  int hot_x, hot_y;
+    
   /* standart */
   pStd_Cursor = SDL_GetCursor();
 
   /* goto */
-  pGoto_Cursor = init_cursor(goto_cursor_bits, goto_cursor_mask_bits,
-                            goto_cursor_width, goto_cursor_height,
-                       /*     goto_cursor_x_hot, goto_cursor_y_hot);*/
-                               2, 2);
+  cursor_sprite = get_cursor_sprite(tileset, CURSOR_GOTO, &hot_x, &hot_y);
+  pGoto_Cursor = SurfaceToCursor(GET_SURF(cursor_sprite), hot_x, hot_y);
 
   /* drop */
-  pDrop_Cursor = init_cursor(drop_cursor_bits, drop_cursor_mask_bits,
-                            drop_cursor_width, drop_cursor_height,
-                            drop_cursor_x_hot, drop_cursor_y_hot);
+  cursor_sprite = get_cursor_sprite(tileset, CURSOR_PARADROP, &hot_x, &hot_y);
+  pDrop_Cursor = SurfaceToCursor(GET_SURF(cursor_sprite), hot_x, hot_y);
 
   /* nuke */
-  pNuke_Cursor = init_cursor(nuke_cursor_bits, nuke_cursor_mask_bits,
-                            nuke_cursor_width, nuke_cursor_height,
-                            nuke_cursor_x_hot, nuke_cursor_y_hot);
+  cursor_sprite = get_cursor_sprite(tileset, CURSOR_NUKE, &hot_x, &hot_y);  
+  pNuke_Cursor = SurfaceToCursor(GET_SURF(cursor_sprite), hot_x, hot_y);
 
   /* patrol */
-  pPatrol_Cursor = init_cursor(patrol_cursor_bits, patrol_cursor_mask_bits,
-                              patrol_cursor_width, patrol_cursor_height,
-                              patrol_cursor_x_hot, patrol_cursor_y_hot);
+  cursor_sprite = get_cursor_sprite(tileset, CURSOR_PATROL, &hot_x, &hot_y);  
+  pPatrol_Cursor = SurfaceToCursor(GET_SURF(cursor_sprite), hot_x, hot_y);
 }
 
 /**************************************************************************
diff -u -r -b -B -N -X devel/diff_ignore 
devel_distclean/client/gui-sdl/gui_main.c devel/client/gui-sdl/gui_main.c
--- devel_distclean/client/gui-sdl/gui_main.c   2005-11-27 01:35:27.000000000 
+0100
+++ devel/client/gui-sdl/gui_main.c     2005-11-27 13:24:35.000000000 +0100
@@ -938,7 +938,6 @@
                        CF_DRAW_PLAYERS_PEACE_STATUS|
                        CF_DRAW_PLAYERS_ALLIANCE_STATUS);
   
-  load_cursors();
   tilespec_setup_theme();
   tilespec_setup_anim();
   tilespec_setup_city_gfx();
@@ -946,6 +945,8 @@
 
   tileset_load_tiles(tileset);
       
+  load_cursors();  
+
   clear_double_messages_call();
     
   create_units_order_widgets();
diff -u -r -b -B -N -X devel/diff_ignore 
devel_distclean/client/gui-sdl/gui_tilespec.c 
devel/client/gui-sdl/gui_tilespec.c
--- devel_distclean/client/gui-sdl/gui_tilespec.c       2005-11-27 
01:35:27.000000000 +0100
+++ devel/client/gui-sdl/gui_tilespec.c 2005-11-27 13:18:53.000000000 +0100
@@ -451,7 +451,7 @@
 }
 
 /* Code come from SDL-dev list */
-static SDL_Cursor *SurfaceToCursor(SDL_Surface *image, int hx, int hy) {
+SDL_Cursor *SurfaceToCursor(SDL_Surface *image, int hx, int hy) {
         int             w, x, y;
         Uint8           *data, *mask, *d, *m, r, g, b;
         Uint32          color;
diff -u -r -b -B -N -X devel/diff_ignore 
devel_distclean/client/gui-sdl/gui_tilespec.h 
devel/client/gui-sdl/gui_tilespec.h
--- devel_distclean/client/gui-sdl/gui_tilespec.h       2005-11-27 
01:35:27.000000000 +0100
+++ devel/client/gui-sdl/gui_tilespec.h 2005-11-27 13:18:46.000000000 +0100
@@ -208,4 +208,6 @@
 SDL_Surface * get_city_gfx(void);
 SDL_Surface * get_citizen_surface(enum citizen_category type,
                                  int citizen_index);
+SDL_Cursor *SurfaceToCursor(SDL_Surface *image, int hx, int hy);
+
 #endif  /* FC__GUI_TILESPEC_H */
diff -u -r -b -B -N -X devel/diff_ignore 
devel_distclean/client/gui-sdl/themes.c devel/client/gui-sdl/themes.c
--- devel_distclean/client/gui-sdl/themes.c     1970-01-01 01:00:00.000000000 
+0100
+++ devel/client/gui-sdl/themes.c       2005-11-27 02:18:39.000000000 +0100
@@ -0,0 +1,59 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 2005 The Freeciv 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 "themes_common.h"
+#include "themes_g.h"
+
+/*****************************************************************************
+  Loads a gtk theme directory/theme_name
+*****************************************************************************/
+void gui_load_theme(const char *directory, const char *theme_name)
+{
+  /* Nothing */
+}
+
+/*****************************************************************************
+  Clears a theme (sets default system theme)
+*****************************************************************************/
+void gui_clear_theme(void)
+{
+  /* Nothing */
+}
+
+/*****************************************************************************
+  Each gui has its own themes directories.
+
+  Returns an array containing these strings and sets array size in count.
+  The caller is responsible for freeing the array and the paths.
+*****************************************************************************/
+char **get_gui_specific_themes_directories(int *count)
+{
+  *count = 0;
+  
+  return fc_malloc(sizeof(char*) * 0);
+}
+
+/*****************************************************************************
+  Return an array of names of usable themes in the given directory.
+  Array size is stored in count.
+  Useable theme for gtk+ is a directory which contains file gtk-2.0/gtkrc.
+  The caller is responsible for freeing the array and the names
+*****************************************************************************/
+char **get_useable_themes_in_directory(const char *directory, int *count)
+{
+  *count = 0;
+  return fc_malloc(sizeof(char*) * 0);
+}









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