Freeciv-3.1
|
#include <stdarg.h>
#include <string.h>
#include "log.h"
#include "government.h"
#include "improvement.h"
#include "research.h"
#include "tech.h"
#include "client_main.h"
#include "options.h"
#include "tilespec.h"
#include "reqtree.h"
#include "colors_g.h"
#include "sprite_g.h"
Go to the source code of this file.
Data Structures | |
struct | tree_node |
struct | reqtree |
struct | node_and_float |
Enumerations | |
enum | reqtree_edge_type { REQTREE_EDGE = 0 , REQTREE_READY_EDGE , REQTREE_KNOWN_EDGE , REQTREE_ACTIVE_EDGE , REQTREE_GOAL_EDGE } |
Functions | |
static void | add_requirement (struct tree_node *node, struct tree_node *req) |
static struct tree_node * | new_tree_node (void) |
static void | node_rectangle_minimum_size (struct tree_node *node, int *width, int *height) |
static void | symmetrize (struct reqtree *tree) |
static void | calculate_diagram_layout (struct reqtree *tree) |
static struct reqtree * | create_dummy_reqtree (struct player *pplayer, bool show_all) |
void | destroy_reqtree (struct reqtree *tree) |
static int | longest_path (struct tree_node *node) |
static void | longest_path_layering (struct reqtree *tree) |
static int | max_provide_layer (struct tree_node *node) |
static struct reqtree * | add_dummy_nodes (struct reqtree *tree) |
static void | set_layers (struct reqtree *tree) |
static int | cmp_func (const void *_a, const void *_b) |
static void | barycentric_sort (struct reqtree *tree, int layer) |
static int | count_crossings (struct reqtree *tree, int layer) |
static void | swap (struct reqtree *tree, int layer, int order1, int order2) |
static void | improve (struct reqtree *tree) |
struct reqtree * | create_reqtree (struct player *pplayer, bool show_all) |
void | get_reqtree_dimensions (struct reqtree *reqtree, int *width, int *height) |
static enum color_std | node_color (struct tree_node *node) |
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) |
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) |
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) |
enum reqtree_edge_type |
Create new tree which has dummy nodes added. The source tree is completely copied, you can freely deallocate it.
Definition at line 544 of file reqtree.c.
Referenced by create_reqtree().
Add requirement edge to node and provide edge to req
Definition at line 121 of file reqtree.c.
Referenced by add_dummy_nodes(), and create_dummy_reqtree().
|
static |
Simple heuristic: Sort nodes on the given layer by the average x-value of its parents.
Definition at line 702 of file reqtree.c.
Referenced by create_reqtree().
|
static |
Calculate rectangles position and size from the tree. Logical order should already be calculated.
Definition at line 292 of file reqtree.c.
Referenced by create_reqtree().
|
static |
Comparison function used by barycentric_sort.
Definition at line 685 of file reqtree.c.
Referenced by barycentric_sort().
|
static |
Create a "dummy" tech tree from current ruleset. This tree is then fleshed out further (see create_reqtree() ). This tree doesn't include dummy edges. Layering and ordering isn't done also.
If pplayer is given, add only techs reachable by that player to tree.
Definition at line 390 of file reqtree.c.
Referenced by create_reqtree().
Generate optimized tech_tree from current ruleset. You should free it by destroy_reqtree().
If pplayer is not NULL, techs unreachable to that player are not shown.
Definition at line 836 of file reqtree.c.
Referenced by research_diagram::reset(), and science_diagram_data().
void destroy_reqtree | ( | struct reqtree * | tree | ) |
Free all memory used by tech_tree struct
Definition at line 470 of file reqtree.c.
Referenced by create_reqtree(), research_diagram::reset(), science_diagram_data(), and research_diagram::~research_diagram().
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 | ||
) |
Draw the reqtree diagram!
This draws the given portion of the reqtree diagram (given by (tt_x,tt_y) and (w,h) onto the canvas at position (canvas_x, canvas_y).
Definition at line 1033 of file reqtree.c.
Referenced by science_diagram_update(), science_diagram_update(), and research_diagram::update_reqtree().
Return a stroke color for an edge between two nodes if node is a dummy, dest_node can be NULL
Definition at line 1007 of file reqtree.c.
Referenced by draw_reqtree().
bool find_tech_on_reqtree | ( | struct reqtree * | tree, |
Tech_type_id | tech, | ||
int * | x, | ||
int * | y, | ||
int * | w, | ||
int * | h | ||
) |
Return the position of the given tech on the reqtree. Return TRUE iff it was found.
Definition at line 1193 of file reqtree.c.
Referenced by science_diagram_center().
|
static |
Return the type for an edge between two nodes if node is a dummy, dest_node can be NULL
Definition at line 937 of file reqtree.c.
Referenced by edge_color(), and get_edge_type().
void get_reqtree_dimensions | ( | struct reqtree * | reqtree, |
int * | width, | ||
int * | height | ||
) |
Give the dimensions of the reqtree.
Definition at line 867 of file reqtree.c.
Referenced by research_diagram::reset(), science_diagram_center(), science_diagram_data(), science_diagram_update(), and science_diagram_update().
Tech_type_id get_tech_on_reqtree | ( | struct reqtree * | tree, |
int | x, | ||
int | y | ||
) |
Return the tech ID at the given position of the reqtree (or A_NONE).
Definition at line 1170 of file reqtree.c.
Referenced by research_diagram::mousePressEvent(), science_diagram_button_release_callback(), science_diagram_left_button_up(), and science_diagram_right_button_up().
|
static |
Try to reduce the number of crossings by swapping two nodes and checking if it improves the situation.
Definition at line 781 of file reqtree.c.
Referenced by create_reqtree().
|
static |
Compute the longest path from this tree_node to the node with no requirements. Store the result in node->layer.
Definition at line 495 of file reqtree.c.
Referenced by longest_path(), and longest_path_layering().
|
static |
Compute longest_path for all nodes, thus prepare longest path layering
Definition at line 513 of file reqtree.c.
Referenced by create_reqtree().
|
static |
Find the largest value of layer amongst children of the given node
Definition at line 527 of file reqtree.c.
Referenced by add_dummy_nodes().
|
static |
Allocate and initialize new tree node
Definition at line 142 of file reqtree.c.
Referenced by add_dummy_nodes(), and create_dummy_reqtree().
|
static |
Return a background color of node's rectangle
Definition at line 881 of file reqtree.c.
Referenced by draw_reqtree().
|
static |
Return minimum size of the rectangle in pixels on the diagram which corresponds to the given node
Definition at line 159 of file reqtree.c.
Referenced by calculate_diagram_layout().
|
static |
Calculate layers[] and layer_size[] fields of tree. There should be layer value calculated for each node. Nodes will be put into layers in no particular order.
Definition at line 637 of file reqtree.c.
Referenced by create_reqtree().
|
static |
|
static |
Move nodes up and down without changing order but making it more symmetrical. Gravitate towards parents average position.
Definition at line 235 of file reqtree.c.
Referenced by calculate_diagram_layout().