[Freeciv-Dev] (PR#13588) images for techtree
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13588 >
> [jdorje - Tue Aug 02 02:37:55 2005]:
>
> The techtree images should be optional. It should be easy to
> enable/disable them with a flip of a checkbox right in the dialog.
>
> The reason is for experienced players (i.e., me) the techtree is a
> faster way to set your tech goal and current research (compared to
> drop-down menus). But pictures get in the way by making it
> unnecessarily much larger (in particular, it makes it scroll in both
> directions).
>
> I realize this may not be too easy.
>
> -jason
>
>
Here's a patch
--
mateusz
Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.141
diff -u -r1.141 options.c
--- client/options.c 25 Aug 2005 19:26:36 -0000 1.141
+++ client/options.c 30 Aug 2005 19:55:10 -0000
@@ -34,6 +34,7 @@
#include "civclient.h"
#include "clinet.h"
#include "cma_fec.h"
+#include "dialogs_g.h"
#include "mapview_common.h"
#include "options.h"
#include "overview_common.h"
@@ -80,6 +81,8 @@
/* This option is currently set by the client - not by the user. */
bool update_city_text_in_refresh_tile = TRUE;
+static void reqtree_show_icons_callback(struct client_option *option);
+
const char *client_option_class_names[COC_MAX] = {
N_("Graphics"),
N_("Overview"),
@@ -168,6 +171,13 @@
"city name and attributes, a large amount of data "
"will be drawn beneach each city in the 'citybar'."),
COC_GRAPHICS, mapview_redraw_callback),
+ GEN_BOOL_OPTION_CB(reqtree_show_icons,
+ N_("Show icons in the technology tree"),
+ N_("If this options is set then there will be icons "
+ "displayed on the technology tree diagram. Turning "
+ "this option off makes the technology tree "
+ "more compact."),
+ COC_GRAPHICS, reqtree_show_icons_callback),
GEN_BOOL_OPTION_CB(draw_unit_shields, N_("Draw shield graphics for units"),
N_("If set, then special shield graphics will be drawn "
"as the flags on units. If unset, the full flag will "
@@ -274,6 +284,7 @@
bool draw_full_citybar = TRUE;
bool draw_unit_shields = TRUE;
bool player_dlg_show_dead_players = TRUE;
+bool reqtree_show_icons = TRUE;
#define VIEW_OPTION(name) { #name, &name }
#define VIEW_OPTION_TERMINATOR { NULL, NULL }
@@ -689,3 +700,14 @@
{
update_map_canvas_visible();
}
+
+/****************************************************************************
+ Callback when the reqtree show icons option is changed.
+ The tree is recalculated.
+****************************************************************************/
+static void reqtree_show_icons_callback(struct client_option *option)
+{
+ /* This will close research dialog, when it's open again the techtree will
+ * be recalculated */
+ popdown_all_game_dialogs();
+}
Index: client/options.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.h,v
retrieving revision 1.55
diff -u -r1.55 options.h
--- client/options.h 30 Jul 2005 06:39:37 -0000 1.55
+++ client/options.h 30 Aug 2005 19:55:10 -0000
@@ -146,6 +146,8 @@
extern bool player_dlg_show_dead_players;
+extern bool reqtree_show_icons;
+
typedef struct {
const char *name;
bool *p_value;
Index: client/reqtree.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/reqtree.c,v
retrieving revision 1.9
diff -u -r1.9 reqtree.c
--- client/reqtree.c 26 Jul 2005 08:21:43 -0000 1.9
+++ client/reqtree.c 30 Aug 2005 19:55:18 -0000
@@ -32,6 +32,7 @@
#include "reqtree.h"
#include "tilespec.h"
+#include "options.h"
/****************************************************************************
This structure desribes a node in a technology tree diagram.
@@ -130,43 +131,45 @@
max_icon_height = 0;
icons_width_sum = 5;
- /* units */
- unit_type_iterate(unit) {
- if (unit->tech_requirement != node->tech) {
- continue;
- }
- sprite = get_unittype_sprite(tileset, unit);
- get_sprite_dimensions(sprite, &swidth, &sheight);
- max_icon_height = MAX(max_icon_height, sheight);
- icons_width_sum += swidth + 2;
- } unit_type_iterate_end;
+ if (reqtree_show_icons) {
+ /* units */
+ unit_type_iterate(unit) {
+ if (unit->tech_requirement != node->tech) {
+ continue;
+ }
+ sprite = get_unittype_sprite(tileset, unit);
+ get_sprite_dimensions(sprite, &swidth, &sheight);
+ max_icon_height = MAX(max_icon_height, sheight);
+ icons_width_sum += swidth + 2;
+ } unit_type_iterate_end;
- /* buildings */
- impr_type_iterate(impr_type) {
- struct impr_type* impr = get_improvement_type(impr_type);
- requirement_vector_iterate(&(impr->reqs), preq) {
- if (preq->source.type == REQ_TECH
- && preq->source.value.tech == node->tech) {
- sprite = get_building_sprite(tileset, impr_type);
- get_sprite_dimensions(sprite, &swidth, &sheight);
- max_icon_height = MAX(max_icon_height, sheight);
- icons_width_sum += swidth + 2;
- }
- } requirement_vector_iterate_end;
- } impr_type_iterate_end;
+ /* buildings */
+ impr_type_iterate(impr_type) {
+ struct impr_type* impr = get_improvement_type(impr_type);
+ requirement_vector_iterate(&(impr->reqs), preq) {
+ if (preq->source.type == REQ_TECH
+ && preq->source.value.tech == node->tech) {
+ sprite = get_building_sprite(tileset, impr_type);
+ get_sprite_dimensions(sprite, &swidth, &sheight);
+ max_icon_height = MAX(max_icon_height, sheight);
+ icons_width_sum += swidth + 2;
+ }
+ } requirement_vector_iterate_end;
+ } impr_type_iterate_end;
- /* governments */
- government_iterate(gov) {
- requirement_vector_iterate(&(gov->reqs), preq) {
- if (preq->source.type == REQ_TECH
- && preq->source.value.tech == node->tech) {
- sprite = get_government_sprite(tileset, gov);
- get_sprite_dimensions(sprite, &swidth, &sheight);
- max_icon_height = MAX(max_icon_height, sheight);
- icons_width_sum += swidth + 2;
- }
- } requirement_vector_iterate_end;
- } government_iterate_end;
+ /* governments */
+ government_iterate(gov) {
+ requirement_vector_iterate(&(gov->reqs), preq) {
+ if (preq->source.type == REQ_TECH
+ && preq->source.value.tech == node->tech) {
+ sprite = get_government_sprite(tileset, gov);
+ get_sprite_dimensions(sprite, &swidth, &sheight);
+ max_icon_height = MAX(max_icon_height, sheight);
+ icons_width_sum += swidth + 2;
+ }
+ } requirement_vector_iterate_end;
+ } government_iterate_end;
+ }
*height += max_icon_height;
if (*width < icons_width_sum) {
@@ -868,52 +871,55 @@
get_color(tileset, COLOR_REQTREE_TEXT),
text);
icon_startx = startx + 5;
- unit_type_iterate(unit) {
- if (unit->tech_requirement != node->tech) {
- continue;
- }
- sprite = get_unittype_sprite(tileset, unit);
- get_sprite_dimensions(sprite, &swidth, &sheight);
- canvas_put_sprite_full(pcanvas,
- icon_startx,
- starty + text_h + 4
- + (height - text_h - 4 - sheight) / 2,
- sprite);
- icon_startx += swidth + 2;
- } unit_type_iterate_end;
+
+ if (reqtree_show_icons) {
+ unit_type_iterate(unit) {
+ if (unit->tech_requirement != node->tech) {
+ continue;
+ }
+ sprite = get_unittype_sprite(tileset, unit);
+ get_sprite_dimensions(sprite, &swidth, &sheight);
+ canvas_put_sprite_full(pcanvas,
+ icon_startx,
+ starty + text_h + 4
+ + (height - text_h - 4 - sheight) / 2,
+ sprite);
+ icon_startx += swidth + 2;
+ } unit_type_iterate_end;
- impr_type_iterate(impr_type) {
- struct impr_type* impr = get_improvement_type(impr_type);
- requirement_vector_iterate(&(impr->reqs), preq) {
- if (preq->source.type == REQ_TECH
- && preq->source.value.tech == node->tech) {
- sprite = get_building_sprite(tileset, impr_type);
- get_sprite_dimensions(sprite, &swidth, &sheight);
- canvas_put_sprite_full(pcanvas,
- icon_startx,
- starty + text_h + 4
- + (height - text_h - 4 - sheight) / 2,
- sprite);
- icon_startx += swidth + 2;
- }
- } requirement_vector_iterate_end;
- } impr_type_iterate_end;
+ impr_type_iterate(impr_type) {
+ struct impr_type* impr = get_improvement_type(impr_type);
+ requirement_vector_iterate(&(impr->reqs), preq) {
+ if (preq->source.type == REQ_TECH
+ && preq->source.value.tech == node->tech) {
+ sprite = get_building_sprite(tileset, impr_type);
+ get_sprite_dimensions(sprite, &swidth, &sheight);
+ canvas_put_sprite_full(pcanvas,
+ icon_startx,
+ starty + text_h + 4
+ + (height - text_h - 4 - sheight) / 2,
+ sprite);
+ icon_startx += swidth + 2;
+ }
+ } requirement_vector_iterate_end;
+ } impr_type_iterate_end;
- government_iterate(gov) {
- requirement_vector_iterate(&(gov->reqs), preq) {
- if (preq->source.type == REQ_TECH
- && preq->source.value.tech == node->tech) {
- sprite = get_government_sprite(tileset, gov);
- canvas_put_sprite_full(pcanvas,
- icon_startx,
- starty + text_h + 4
- + (height - text_h - 4 - sheight) / 2,
- sprite);
- get_sprite_dimensions(sprite, &swidth, &sheight);
- icon_startx += swidth + 2;
- }
- } requirement_vector_iterate_end;
- } government_iterate_end;
+ government_iterate(gov) {
+ requirement_vector_iterate(&(gov->reqs), preq) {
+ if (preq->source.type == REQ_TECH
+ && preq->source.value.tech == node->tech) {
+ sprite = get_government_sprite(tileset, gov);
+ canvas_put_sprite_full(pcanvas,
+ icon_startx,
+ starty + text_h + 4
+ + (height - text_h - 4 - sheight) / 2,
+ sprite);
+ get_sprite_dimensions(sprite, &swidth, &sheight);
+ icon_startx += swidth + 2;
+ }
+ } requirement_vector_iterate_end;
+ } government_iterate_end;
+ }
}
|
|