Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2005:
[Freeciv-Dev] (PR#13261) tech graphics in the reqtree
Home

[Freeciv-Dev] (PR#13261) tech graphics in the reqtree

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13261) tech graphics in the reqtree
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 13 Jun 2005 12:37:22 -0700
Reply-to: bugs@xxxxxxxxxxx

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

This is a preliminary patch that adds the tech graphics to the reqtree.

See http://freeciv.org/~jdorje/reqtree_sprite2.png .

Before this can go further I think I need a full set of tech graphics in
the tileset.  Then I can scale them all and try out different setups.

-jason

Index: client/reqtree.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/reqtree.c,v
retrieving revision 1.7
diff -u -r1.7 reqtree.c
--- client/reqtree.c    22 May 2005 18:12:52 -0000      1.7
+++ client/reqtree.c    13 Jun 2005 19:34:01 -0000
@@ -24,6 +24,7 @@
 #include "tech.h"
 
 #include "colors_g.h"
+#include "sprite_g.h"
 
 #include "reqtree.h"
 #include "tilespec.h"
@@ -112,8 +113,19 @@
   if (node->is_dummy) {
     *width = *height = 1;
   } else {
+    struct sprite *sprite = get_tech_sprite(tileset, node->tech);
+
     get_text_size(width, height, FONT_REQTREE_TEXT,
                  get_tech_name(game.player_ptr, node->tech));
+
+    if (sprite) {
+      int w, h;
+
+      get_sprite_dimensions(sprite, &w, &h);
+      *width = MAX(w, *width);
+      *height += h;
+    }
+
     *width += 2;
     *height += 8;
   }
@@ -781,15 +793,27 @@
     for (j = 0; j < tree->layer_size[i]; j++) {
       struct tree_node *node = tree->layers[i][j];
       int startx, starty, endx, endy, width, height;
+      int sw = 0, sh = 0;
 
       startx = node->node_x;
       starty = node->node_y;
       width = node->node_width;
       height = node->node_height;
 
+      if (!node->is_dummy) {
+       struct sprite *sprite = get_tech_sprite(tileset, node->tech);
+
+       if (sprite) {
+         get_sprite_dimensions(sprite, &sw, &sh);
+         canvas_put_sprite_full(pcanvas,
+                                startx + (width - sw) / 2,
+                                starty, sprite);
+       }
+      }
+
       canvas_put_rectangle(pcanvas,
                           get_color(tileset, COLOR_REQTREE_BACKGROUND),
-                          startx, starty, width, height);
+                          startx, starty + sh, width, height - sh);
 
       if (!node->is_dummy) {
        const char *text = get_tech_name(game.player_ptr, node->tech);
@@ -797,13 +821,13 @@
 
        /* Print color rectangle with text inside. */
        canvas_put_rectangle(pcanvas, get_color(tileset, node_color(node)),
-                            startx + 1, starty + 1,
-                            width - 2, height - 2);
+                            startx + 1, starty + sh + 1,
+                            width - 2, height - sh - 2);
        get_text_size(&text_w, &text_h, FONT_REQTREE_TEXT, text);
 
        canvas_put_text(pcanvas,
                        startx + (width - text_w) / 2,
-                       starty + (height - text_h) / 2,
+                       starty + sh + (height - sh - text_h) / 2,
                        FONT_REQTREE_TEXT,
                        get_color(tileset, COLOR_REQTREE_TEXT),
                        text);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13261) tech graphics in the reqtree, Jason Short <=