1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
15 #include <fc_config.h>
24 #include "gtkpixcomm.h"
41 #include "mapview_g.h"
45 /* client/gui-gtk-2.0 */
50 struct sprite
*intro_gfx_sprite
;
51 struct sprite
*radar_gfx_sprite
;
53 GdkCursor
*fc_cursors
[CURSOR_LAST
][NUM_CURSOR_FRAMES
];
55 /***************************************************************************
56 Returns TRUE to indicate that gtk2-client supports given view type
57 ***************************************************************************/
58 bool is_view_supported(enum ts_type type
)
69 #define COLOR_MOTTO_FACE_R 0x2D
70 #define COLOR_MOTTO_FACE_G 0x71
71 #define COLOR_MOTTO_FACE_B 0xE3
73 /**************************************************************************
74 Draw string with shadow
75 **************************************************************************/
76 void gtk_draw_shadowed_string(GdkDrawable
*drawable
,
79 gint x
, gint y
, PangoLayout
*layout
)
81 gdk_draw_layout(drawable
, black_gc
, x
+ 1, y
+ 1, layout
);
82 gdk_draw_layout(drawable
, white_gc
, x
, y
, layout
);
85 /***************************************************************************
87 ***************************************************************************/
88 void load_cursors(void)
90 enum cursor_type cursor
;
91 GdkDisplay
*display
= gdk_display_get_default();
94 for (cursor
= 0; cursor
< CURSOR_LAST
; cursor
++) {
95 for (frame
= 0; frame
< NUM_CURSOR_FRAMES
; frame
++) {
98 = get_cursor_sprite(tileset
, cursor
, &hot_x
, &hot_y
, frame
);
99 GdkPixbuf
*pixbuf
= sprite_get_pixbuf(sprite
);
101 fc_cursors
[cursor
][frame
] = gdk_cursor_new_from_pixbuf(display
, pixbuf
,
107 /***************************************************************************
108 Put unit sprite to canvas
109 ***************************************************************************/
110 void create_overlay_unit(struct canvas
*pcanvas
, struct unit_type
*punittype
,
111 enum direction8 facing
)
115 struct sprite
*sprite
= get_unittype_sprite(tileset
, punittype
,
119 sprite_get_bounding_box(sprite
, &x1
, &y1
, &x2
, &y2
);
120 if (pcanvas
->type
== CANVAS_PIXBUF
) {
121 width
= gdk_pixbuf_get_width(pcanvas
->v
.pixbuf
);
122 height
= gdk_pixbuf_get_height(pcanvas
->v
.pixbuf
);
123 gdk_pixbuf_fill(pcanvas
->v
.pixbuf
, 0x00000000);
125 if (pcanvas
->type
== CANVAS_PIXCOMM
) {
126 gtk_pixcomm_clear(pcanvas
->v
.pixcomm
);
130 width
= tileset_full_tile_width(tileset
);
131 height
= tileset_full_tile_height(tileset
);
134 /* Finally, put a picture of the unit in the tile */
135 canvas_put_sprite(pcanvas
, 0, 0, sprite
,
136 (x2
+ x1
- width
) / 2, (y1
+ y2
- height
) / 2,
137 tileset_full_tile_width(tileset
) - (x2
+ x1
- width
) / 2,
138 tileset_full_tile_height(tileset
) - (y1
+ y2
- height
) / 2);
141 /***************************************************************************
142 This function is so that packhand.c can be gui-independent, and
143 not have to deal with Sprites itself.
144 ***************************************************************************/
145 void free_intro_radar_sprites(void)
147 if (intro_gfx_sprite
) {
148 free_sprite(intro_gfx_sprite
);
149 intro_gfx_sprite
=NULL
;
151 if (radar_gfx_sprite
) {
152 free_sprite(radar_gfx_sprite
);
153 radar_gfx_sprite
=NULL
;