[Freeciv-Dev] (PR#8482) heights in gtk2 production dialog
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8482 >
> [dspeyer@xxxxxxxxxxx - Sat May 29 12:58:48 2004]:
>
> So, does everyone like 8842? If so, what else is it waiting for?
I cleaned up your patch to fit doc/CodingStyle, added a missing include,
s/NORMAL_TILE_WIDTH/UNIT_TILE_WIDTH/, made the improvement rows have the
same height as the unit rows, removed the +4 padding (it broke your code
when using the overhead view 'trident' tileset).
If there are no further comments, this should be commited Tuesday.
Index: client/gui-gtk-2.0/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/dialogs.c,v
retrieving revision 1.67
diff -u -r1.67 dialogs.c
--- client/gui-gtk-2.0/dialogs.c 17 May 2004 01:29:47 -0000 1.67
+++ client/gui-gtk-2.0/dialogs.c 29 May 2004 18:29:13 -0000
@@ -51,6 +51,7 @@
#include "tilespec.h"
#include "dialogs.h"
+#include "wldlg.h"
/******************************************************************/
GtkWidget *message_dialog_start(GtkWindow *parent, const gchar *name,
@@ -1877,8 +1878,13 @@
if (races_shell) {
gtk_widget_destroy(races_shell);
}
+
+ /* We're probably starting a new game, maybe with a new ruleset.
+ So we warn the worklist dialog. */
+ blank_max_unit_size();
}
+
/****************************************************************
...
*****************************************************************/
Index: client/gui-gtk-2.0/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/graphics.c,v
retrieving revision 1.25
diff -u -r1.25 graphics.c
--- client/gui-gtk-2.0/graphics.c 2 Apr 2004 13:03:59 -0000 1.25
+++ client/gui-gtk-2.0/graphics.c 29 May 2004 18:29:13 -0000
@@ -385,32 +385,35 @@
void create_overlay_unit(struct canvas *pcanvas, int i)
{
enum color_std bg_color;
-
+ int x1, x2, y1, y2;
+ int width, height;
+ struct unit_type *type = get_unit_type(i);
+
+ sprite_get_bounding_box(type->sprite, &x1, &y1, &x2, &y2);
+ if (pcanvas->type == CANVAS_PIXBUF) {
+ width = gdk_pixbuf_get_width(pcanvas->v.pixbuf);
+ height = gdk_pixbuf_get_height(pcanvas->v.pixbuf);
+ } else {
+ /* Guess */
+ width = UNIT_TILE_WIDTH;
+ height = UNIT_TILE_HEIGHT;
+ }
+
/* Give tile a background color, based on the type of unit */
- switch (get_unit_type(i)->move_type) {
+ switch (type->move_type) {
case LAND_MOVING: bg_color = COLOR_STD_GROUND; break;
case SEA_MOVING: bg_color = COLOR_STD_OCEAN; break;
case HELI_MOVING: bg_color = COLOR_STD_YELLOW; break;
case AIR_MOVING: bg_color = COLOR_STD_CYAN; break;
default: bg_color = COLOR_STD_BLACK; break;
}
- canvas_put_rectangle(pcanvas, bg_color,
- 0, 0, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
-
-
- /* If we're using flags, put one on the tile */
- if(!solid_color_behind_units) {
- struct Sprite *flag=get_nation_by_plr(game.player_ptr)->flag_sprite;
-
- canvas_put_sprite_full(pcanvas, 0, 0, flag);
- }
+ canvas_put_rectangle(pcanvas, bg_color, 0, 0, width, height);
/* Finally, put a picture of the unit in the tile */
- if(i<game.num_unit_types) {
- struct Sprite *s=get_unit_type(i)->sprite;
-
- canvas_put_sprite_full(pcanvas, 0, 0, s);
- }
+ canvas_put_sprite(pcanvas, 0, 0, type->sprite,
+ (x2 + x1 - width) / 2, (y1 + y2 - height) / 2,
+ UNIT_TILE_WIDTH - (x2 + x1 - width) / 2,
+ UNIT_TILE_HEIGHT - (y1 + y2 - height) / 2);
}
/***************************************************************************
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.126
diff -u -r1.126 mapview.c
--- client/gui-gtk-2.0/mapview.c 24 May 2004 22:48:08 -0000 1.126
+++ client/gui-gtk-2.0/mapview.c 29 May 2004 18:29:14 -0000
@@ -1125,4 +1125,5 @@
{
reset_city_dialogs();
reset_unit_table();
+ blank_max_unit_size();
}
Index: client/gui-gtk-2.0/wldlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/wldlg.c,v
retrieving revision 1.35
diff -u -r1.35 wldlg.c
--- client/gui-gtk-2.0/wldlg.c 11 May 2004 17:52:25 -0000 1.35
+++ client/gui-gtk-2.0/wldlg.c 29 May 2004 18:29:16 -0000
@@ -55,6 +55,7 @@
static GtkListStore *worklists_store;
+static int max_unit_height = -1, max_unit_width = -1;
static void popup_worklist(struct worklist *pwl);
static void popdown_worklist(struct worklist *pwl);
@@ -63,6 +64,34 @@
/****************************************************************
...
*****************************************************************/
+void blank_max_unit_size(void)
+{
+ max_unit_height = -1;
+ max_unit_width = -1;
+}
+
+/****************************************************************
+...
+*****************************************************************/
+static void update_max_unit_size(void)
+{
+ max_unit_height = 0;
+ max_unit_width = 0;
+
+ unit_type_iterate(i) {
+ struct unit_type *type = get_unit_type(i);
+ int x1, x2, y1, y2;
+
+ sprite_get_bounding_box(type->sprite, &x1, &y1, &x2, &y2);
+ max_unit_width = MAX(max_unit_width, x2 - x1);
+ max_unit_height = MAX(max_unit_height, y2 - y1);
+ } unit_type_iterate_end;
+}
+
+
+/****************************************************************
+...
+*****************************************************************/
static void worklists_destroy_callback(GtkWidget *w, gpointer data)
{
worklists_shell = NULL;
@@ -896,7 +925,7 @@
struct canvas store;
pix = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8,
- UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
+ max_unit_width, max_unit_height);
store.type = CANVAS_PIXBUF;
store.v.pixbuf = pix;
@@ -966,7 +995,11 @@
i, titles[i], rend, cell_render_func, ppcity, NULL);
col = gtk_tree_view_get_column(view, i);
- if (!show_task_icons) {
+ if (show_task_icons) {
+ if (max_unit_width == -1 || max_unit_height == -1) {
+ update_max_unit_size();
+ }
+ } else {
g_object_set(col, "visible", FALSE, NULL);
}
} else {
@@ -989,7 +1022,7 @@
}
}
if (show_task_icons) {
- g_object_set(rend, "height", UNIT_TILE_HEIGHT, NULL);
+ g_object_set(rend, "height", max_unit_height, NULL);
}
}
}
Index: client/gui-gtk-2.0/wldlg.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/wldlg.h,v
retrieving revision 1.5
diff -u -r1.5 wldlg.h
--- client/gui-gtk-2.0/wldlg.h 13 May 2003 20:38:33 -0000 1.5
+++ client/gui-gtk-2.0/wldlg.h 29 May 2004 18:29:16 -0000
@@ -33,4 +33,6 @@
void add_worklist_dnd_target(GtkWidget *w);
+void blank_max_unit_size(void);
+
#endif /* FC__WLDLG_H */
|
|