188 max_icon_height =
MAX(max_icon_height, sheight);
189 icons_width_sum += swidth + 2;
196 if (VUT_ADVANCE == preq->source.kind
202 max_icon_height =
MAX(max_icon_height, sheight);
203 icons_width_sum += swidth + 2;
213 if (VUT_ADVANCE == preq->source.kind
217 max_icon_height =
MAX(max_icon_height, sheight);
218 icons_width_sum += swidth + 2;
224 *
height += max_icon_height;
225 if (*
width < icons_width_sum) {
226 *
width = icons_width_sum;
240 for (layer = 0; layer < tree->
num_layers; layer++) {
241 for (i = 0; i < tree->
layer_size[layer]; i++) {
249 for (j = 0; j < node->
nrequire; j++) {
274 if (i < tree->layer_size[
layer] - 1) {
294 int i,
layer, layer_offs;
315 if (i < tree->layer_size[
layer] - 1) {
340 node->
node_x = layer_offs;
345 layer_offs += max_width * 5 / 4 + 80;
347 layer_offs += max_width + 10;
405 if (pplayer && !show_all
424 if (nodes[tech] == NULL) {
431 if (!show_all &&
A_NONE != tech_one
433 && (nodes[tech_one] == NULL || nodes[tech_two] == NULL)) {
458 tree->
nodes[j++] = nodes[tech];
477 free(tree->
nodes[i]);
499 if (node->
layer != -1) {
503 for (i = 0; i < node->
nrequire; i++) {
506 node->
layer = max + 1;
518 if (tree->
nodes[i]) {
530 int max = node->
layer;
532 for (i = 0; i < node->
nprovide; i++) {
547 int num_dummy_nodes = 0;
554 if (tree->
nodes[i] == NULL) {
559 num_dummy_nodes += mpl - tree->
nodes[i]->
layer - 1;
580 for (i = 0; i < num_dummy_nodes; i++) {
596 if (mpl > node->
layer + 1) {
598 for (j = node->
layer + 2; j < mpl; j++) {
602 for (j = node->
layer + 1; j < mpl; j++) {
608 for (j = 0; j < node->
nprovide; j++) {
611 if (provide_y == node->
layer + 1) {
618 new_tree->
nodes[k + provide_y - node->
layer - 2]);
622 if (mpl > node->
layer + 1) {
623 k += mpl - node->
layer - 1;
655 for (i = 0; i < num_layers; i++) {
663 for (i = 0; i < num_layers; i++) {
689 if (a->
value > b->value) {
692 if (a->
value < b->value) {
709 for (i = 0; i < tree->layer_size[layer]; i++) {
714 for (j = 0; j < node->
nrequire; j++) {
722 qsort(
T, tree->layer_size[
layer],
sizeof(*
T),
725 for (i = 0; i < tree->layer_size[
layer]; i++) {
743 for (i = 0; i < layer2_size; i++) {
747 for (i = 0; i < layer1_size; i++) {
750 for (j = 0; j < node->
nprovide; j++) {
753 for (j = 0; j < node->
nprovide; j++) {
773 node1->
order = order2;
774 node2->
order = order1;
784 int crossings[layers - 1];
785 int i, x1, x2,
layer;
787 for (i = 0; i < layers - 1; i++) {
796 layer_sum += crossings[
layer - 1];
798 if (
layer < layers - 1) {
799 layer_sum += crossings[
layer];
802 for (x1 = 0; x1 < layer_size; x1++) {
803 for (x2 = x1 + 1; x2 < layer_size; x2++) {
804 int new_crossings = 0;
805 int new_crossings_before = 0;
811 if (
layer < layers - 1) {
814 if (new_crossings + new_crossings_before > layer_sum) {
817 layer_sum = new_crossings + new_crossings_before;
819 crossings[
layer - 1] = new_crossings_before;
821 if (
layer < layers - 1) {
822 crossings[
layer] = new_crossings;
848 for (j = 0; j < 20; j++) {
855 for (j = 0; j < 20; j++) {
887 return COLOR_REQTREE_KNOWN;
891 return COLOR_REQTREE_UNREACHABLE;
897 return COLOR_REQTREE_GOAL_NOT_GETTABLE;
899 return COLOR_REQTREE_NOT_GETTABLE;
904 return COLOR_REQTREE_RESEARCHING;
908 return COLOR_REQTREE_KNOWN;
915 return COLOR_REQTREE_GOAL_PREREQS_KNOWN;
917 return COLOR_REQTREE_GOAL_UNKNOWN;
923 return COLOR_REQTREE_PREREQS_KNOWN;
926 return COLOR_REQTREE_UNKNOWN;
928 return COLOR_REQTREE_BACKGROUND;
942 if (dest_node == NULL) {
960 for (i = 0; i < dest_node->
nprovide; ++i) {
1014 return COLOR_REQTREE_RESEARCHING;
1016 return COLOR_REQTREE_GOAL_UNKNOWN;
1019 return COLOR_REQTREE_TEXT;
1021 return COLOR_REQTREE_PREREQS_KNOWN;
1023 return COLOR_REQTREE_EDGE;
1035 int tt_x,
int tt_y,
int w,
int h)
1038 int swidth, sheight;
1058 startx, starty,
width, 0);
1071 startx + 1, starty + 1,
1081 startx + (
width - text_w) / 2,
1086 icon_startx = startx + 5;
1098 + (
height - text_h - 4 - sheight) / 2,
1100 icon_startx += swidth + 2;
1106 if (VUT_ADVANCE == preq->source.kind
1115 + (
height - text_h - 4 - sheight) / 2,
1117 icon_startx += swidth + 2;
1126 if (VUT_ADVANCE == preq->source.kind
1133 + (
height - text_h - 4 - sheight) / 2,
1135 icon_startx += swidth + 2;
1145 for (k = 0; k < node->
nprovide; k++) {
1150 endx = dest_node->
node_x;
1155 startx, starty, endx - startx,
1159 startx, starty, endx - startx,
1194 int *x,
int *y,
int *w,
int *h)
struct canvas int int struct sprite int int int int height
struct canvas int int canvas_y
struct canvas int canvas_x
struct canvas int int struct sprite bool int int fog_y struct canvas struct sprite struct color int int canvas_y canvas_put_curved_line
struct canvas int int struct sprite int int int width
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
#define governments_iterate(NAME_pgov)
#define governments_iterate_end
void canvas_put_rectangle(struct canvas *pcanvas, struct color *pcolor, int canvas_x, int canvas_y, int width, int height)
void canvas_put_sprite_full(struct canvas *pcanvas, int canvas_x, int canvas_y, struct sprite *sprite)
void get_text_size(int *width, int *height, enum client_font font, const char *text)
void canvas_put_line(struct canvas *pcanvas, struct color *pcolor, enum line_type ltype, int start_x, int start_y, int dx, int dy)
void get_sprite_dimensions(struct sprite *sprite, int *width, int *height)
const struct impr_type * valid_improvement(const struct impr_type *pimprove)
#define improvement_iterate_end
#define improvement_iterate(_p)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_action(condition, action)
#define fc_calloc(n, esz)
#define fc_realloc(ptr, sz)
struct client_options gui_options
static int max_provide_layer(struct tree_node *node)
static int longest_path(struct tree_node *node)
static void barycentric_sort(struct reqtree *tree, int layer)
static int cmp_func(const void *_a, const void *_b)
void draw_reqtree(struct reqtree *tree, struct canvas *pcanvas, int canvas_x, int canvas_y, int tt_x, int tt_y, int w, int h)
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
static void node_rectangle_minimum_size(struct tree_node *node, int *width, int *height)
static void add_requirement(struct tree_node *node, struct tree_node *req)
static enum color_std node_color(struct tree_node *node)
static int count_crossings(struct reqtree *tree, int layer)
static void improve(struct reqtree *tree)
static void symmetrize(struct reqtree *tree)
static struct reqtree * add_dummy_nodes(struct reqtree *tree)
static void set_layers(struct reqtree *tree)
static void longest_path_layering(struct reqtree *tree)
static void calculate_diagram_layout(struct reqtree *tree)
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
bool find_tech_on_reqtree(struct reqtree *tree, Tech_type_id tech, int *x, int *y, int *w, int *h)
static void swap(struct reqtree *tree, int layer, int order1, int order2)
static enum reqtree_edge_type get_edge_type(struct tree_node *node, struct tree_node *dest_node)
static enum color_std edge_color(struct tree_node *node, struct tree_node *dest_node)
static struct tree_node * new_tree_node(void)
void destroy_reqtree(struct reqtree *tree)
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
static struct reqtree * create_dummy_reqtree(struct player *pplayer, bool show_all)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
bool research_goal_tech_req(const struct research *presearch, Tech_type_id goal, Tech_type_id tech)
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
struct research * research_get(const struct player *pplayer)
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
bool reqtree_curved_lines
struct tree_node ** nodes
struct tree_node *** layers
struct tree_node ** provide
struct tree_node ** require
struct advance * valid_advance_by_number(const Tech_type_id id)
Tech_type_id advance_required(const Tech_type_id tech, enum tech_req require)
Tech_type_id advance_number(const struct advance *padvance)
#define advance_index_iterate_max(_start, _index, _max)
#define advance_index_iterate_max_end
static Tech_type_id advance_count(void)
struct sprite * get_government_sprite(const struct tileset *t, const struct government *gov)
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum direction8 facing)
#define unit_type_iterate(_p)
#define unit_type_iterate_end