Move dump of C code for Huffman tables to stderr to avoid conflict with
[xiph/unicode.git] / planarity / graph.h
blob83ef24f266b24d0b6776817c4d957abe7bb0383a
1 /*
3 * gPlanarity:
4 * The geeky little puzzle game with a big noodly crunch!
5 *
6 * gPlanarity copyright (C) 2005 Monty <monty@xiph.org>
7 * Original Flash game by John Tantalo <john.tantalo@case.edu>
8 * Original game concept by Mary Radcliffe
10 * gPlanarity is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
15 * gPlanarity is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Postfish; see the file COPYING. If not, write to the
22 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 #define V_RADIUS_SQ (V_RADIUS*V_RADIUS)
28 #define min(a,b) ((a)<(b)?(a):(b))
29 #define max(a,b) ((a)>(b)?(a):(b))
31 typedef struct vertex {
32 int num;
33 int x;
34 int y;
35 int orig_x;
36 int orig_y;
38 int active;
39 int selected_volatile;
40 int selected;
41 int grabbed;
42 int attached_to_grabbed;
43 int fading;
44 struct edge_list *edges;
45 struct vertex *next;
46 } vertex;
48 typedef struct intersection {
49 struct intersection *prev;
50 struct intersection *next;
51 struct intersection *paired;
52 double x;
53 double y;
54 } intersection;
56 typedef struct edge{
57 vertex *A;
58 vertex *B;
60 int active;
62 intersection i; // correct, not a pointer
63 struct edge *next;
64 } edge;
66 typedef struct edge_list{
67 edge *edge;
68 struct edge_list *next;
69 } edge_list;
71 typedef struct graph {
72 vertex *verticies;
73 int vertex_num;
74 edge *edges;
75 long active_intersections;
77 int num_edges;
78 int num_edges_active;
80 int width;
81 int height;
82 int orig_width;
83 int orig_height;
85 // scoring related metadata
86 long original_intersections;
87 float intersection_mult;
88 int objective;
89 int objective_lessthan;
90 float objective_mult;
92 } graph;
94 typedef struct graphmeta{
95 int num;
96 char *id;
97 char *desc;
98 void (*gen)(graph *,int arg);
99 int gen_arg;
100 int unlock_plus;
101 } graphmeta;
103 #include <stdio.h>
105 extern vertex *new_board(graph *g, int num_v);
106 extern vertex *find_vertex(graph *g, int x, int y);
108 extern edge_list *add_edge_to_list(edge_list *l, edge *e);
109 extern void release_edge_list(edge_list *el);
110 extern edge *new_edge(vertex *A, vertex *B);
111 extern void release_edge_list(edge_list *el);
112 extern void insert_edge(graph *g, edge *e);
113 extern int intersectsV(vertex *L1, vertex *L2, vertex *M1, vertex *M2,
114 double *xo, double *yo);
115 extern int intersects(int L1x, int L1y, int L2x, int L2y,
116 int M1x, int M1y, int M2x, int M2y,
117 double *xo, double *yo);
118 extern void move_vertex(graph *g, vertex *v, int x, int y);
119 extern void grab_vertex(graph *g, vertex *v);
120 extern void grab_selected(graph *g);
121 extern void ungrab_vertex(graph *g,vertex *v);
122 extern void ungrab_verticies(graph *g);
123 extern void activate_vertex(graph *g, vertex *v);
124 extern void deactivate_vertex(graph *g, vertex *v);
125 extern void select_verticies(graph *g, int x1, int y1, int x2, int y2);
126 extern void deselect_verticies(graph *g);
127 extern void move_selected_verticies(graph *g, int dx, int dy);
128 extern void scale_verticies(graph *g, float amount);
129 extern void randomize_verticies(graph *g);
130 extern edge *add_edge(graph *g,vertex *A, vertex *B);
131 extern int exists_edge(vertex *a, vertex *b);
132 extern int num_selected_verticies(graph *g);
133 extern void check_verticies(graph *g);
134 extern void impress_location(graph *g);
135 extern void commit_volatile_selection(graph *g);
136 extern void activate_verticies(graph *g);
137 extern int graph_write(graph *g, FILE *f);
138 extern int graph_read(graph *g, FILE *f);
139 extern void graph_release(graph *g);
141 extern int graphscore_get_score(graph *g);
142 extern int graphscore_get_raw_score(graph *g);
143 extern int graphscore_get_multiplier_percent(graph *g);
144 extern int graphscore_get_bonus(graph *g);
145 extern char *graphscore_objective_string(graph *g);
146 extern void graph_resize(graph *g, int width, int height);