Stop sharing requirement_unit_state_ereq().
[freeciv.git] / client / editor.h
blob3cc0c91ce5df354e28fcc3b52d43888cc030ef08
1 /**********************************************************************
2 Freeciv - Copyright (C) 2005 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
14 #ifndef FC__TOOLS_H
15 #define FC__TOOLS_H
17 #ifdef __cplusplus
18 extern "C" {
19 #endif /* __cplusplus */
21 #include "fc_types.h"
23 /* See client/gui-gtk-3.0/editprop.c for instructions
24 * on how to add more object types. */
25 enum editor_object_type {
26 OBJTYPE_TILE = 0,
27 OBJTYPE_STARTPOS,
28 OBJTYPE_UNIT,
29 OBJTYPE_CITY,
30 OBJTYPE_PLAYER,
31 OBJTYPE_GAME,
33 NUM_OBJTYPES
36 enum editor_tool_type {
37 ETT_TERRAIN = 0,
38 ETT_TERRAIN_RESOURCE,
39 ETT_TERRAIN_SPECIAL,
40 ETT_ROAD,
41 ETT_MILITARY_BASE,
42 ETT_UNIT,
43 ETT_CITY,
44 ETT_VISION,
45 ETT_TERRITORY,
46 ETT_STARTPOS,
47 ETT_COPYPASTE,
49 NUM_EDITOR_TOOL_TYPES
52 enum editor_tool_mode {
53 ETM_PAINT = 0,
54 ETM_ERASE,
55 ETM_COPY,
56 ETM_PASTE,
58 NUM_EDITOR_TOOL_MODES
61 void editor_init(void);
62 void editor_clear(void);
63 void editor_free(void);
65 void editor_ruleset_changed(void);
67 bool editor_is_active(void);
68 enum editor_tool_type editor_get_tool(void);
69 void editor_set_tool(enum editor_tool_type emt);
70 const struct tile *editor_get_current_tile(void);
71 void editor_set_current_tile(const struct tile *ptile);
73 bool editor_tool_has_mode(enum editor_tool_type ett,
74 enum editor_tool_mode etm);
75 enum editor_tool_mode editor_tool_get_mode(enum editor_tool_type ett);
76 void editor_tool_set_mode(enum editor_tool_type ett,
77 enum editor_tool_mode etm);
78 void editor_tool_toggle_mode(enum editor_tool_type ett,
79 enum editor_tool_mode etm);
80 void editor_tool_cycle_mode(enum editor_tool_type ett);
81 const char *editor_tool_get_mode_name(enum editor_tool_type ett,
82 enum editor_tool_mode etm);
84 bool editor_tool_has_size(enum editor_tool_type ett);
85 int editor_tool_get_size(enum editor_tool_type ett);
86 void editor_tool_set_size(enum editor_tool_type ett, int size);
88 bool editor_tool_has_count(enum editor_tool_type ett);
89 int editor_tool_get_count(enum editor_tool_type ett);
90 void editor_tool_set_count(enum editor_tool_type ett, int count);
92 bool editor_tool_has_applied_player(enum editor_tool_type ett);
93 int editor_tool_get_applied_player(enum editor_tool_type ett);
94 void editor_tool_set_applied_player(enum editor_tool_type,
95 int player_no);
97 bool editor_tool_is_usable(enum editor_tool_type ett);
98 bool editor_tool_has_value(enum editor_tool_type ett);
99 bool editor_tool_has_value_erase(enum editor_tool_type ett);
100 int editor_tool_get_value(enum editor_tool_type ett);
101 void editor_tool_set_value(enum editor_tool_type ett, int value);
102 const char *editor_tool_get_value_name(enum editor_tool_type ett,
103 int value);
105 const char *editor_tool_get_name(enum editor_tool_type ett);
106 struct sprite *editor_tool_get_sprite(enum editor_tool_type ett);
107 const char *editor_tool_get_tooltip(enum editor_tool_type ett);
109 const char *editor_get_mode_tooltip(enum editor_tool_mode etm);
110 struct sprite *editor_get_mode_sprite(enum editor_tool_mode etm);
112 struct edit_buffer;
113 struct edit_buffer *editor_get_copy_buffer(void);
116 enum editor_keyboard_modifiers {
117 EKM_NONE = 0,
118 EKM_SHIFT = 1<<0,
119 EKM_ALT = 1<<1,
120 EKM_CTRL = 1<<2
123 enum mouse_button_values {
124 MOUSE_BUTTON_OTHER = 0,
126 MOUSE_BUTTON_LEFT = 1,
127 MOUSE_BUTTON_MIDDLE = 2,
128 MOUSE_BUTTON_RIGHT = 3
131 void editor_mouse_button_press(int canvas_x, int canvas_y,
132 int button, int modifiers);
133 void editor_mouse_button_release(int canvas_x, int canvas_y,
134 int button, int modifiers);
135 void editor_mouse_move(int canvas_x, int canvas_y, int modifiers);
137 void editor_apply_tool(const struct tile *ptile,
138 bool part_of_selection);
139 void editor_notify_edit_finished(void);
141 void editor_selection_clear(void);
142 void editor_selection_add(const struct tile *ptile);
143 void editor_selection_remove(const struct tile *ptile);
144 bool editor_tile_is_selected(const struct tile *ptile);
145 void editor_apply_tool_to_selection(void);
146 int editor_selection_count(void);
147 const struct tile *editor_get_selection_center(void);
149 struct unit *editor_unit_virtual_create(void);
152 /* These type flags determine what an edit buffer
153 * will copy from its source tiles. Multiple flags
154 * may be set via bitwise OR. */
155 enum edit_buffer_types {
156 EBT_TERRAIN = 1<<0,
157 EBT_RESOURCE = 1<<1,
158 EBT_SPECIAL = 1<<2,
159 EBT_BASE = 1<<3,
160 EBT_ROAD = 1<<4,
161 EBT_UNIT = 1<<5,
162 EBT_CITY = 1<<6,
164 /* Equal to the bitwise OR of all preceding flags. */
165 EBT_ALL = (1<<7) - 1
168 struct edit_buffer *edit_buffer_new(int type_flags);
169 void edit_buffer_free(struct edit_buffer *ebuf);
170 void edit_buffer_clear(struct edit_buffer *ebuf);
171 void edit_buffer_set_origin(struct edit_buffer *ebuf,
172 const struct tile *ptile);
173 const struct tile *edit_buffer_get_origin(const struct edit_buffer *ebuf);
174 bool edit_buffer_has_type(const struct edit_buffer *ebuf, int type);
175 void edit_buffer_copy(struct edit_buffer *ebuf, const struct tile *ptile);
176 void edit_buffer_copy_square(struct edit_buffer *ebuf,
177 const struct tile *center,
178 int radius);
179 void edit_buffer_paste(struct edit_buffer *ebuf, const struct tile *dest);
180 int edit_buffer_get_status_string(const struct edit_buffer *ebuf,
181 char *buf, int buflen);
183 /* Iterates over all type flags set for the given buffer. */
184 #define edit_buffer_type_iterate(ARG_ebuf, NAME_type) \
185 do {\
186 int NAME_type;\
187 if (!(ARG_ebuf)) {\
188 break;\
190 for (NAME_type = 1; NAME_type < EBT_ALL; NAME_type <<= 1) {\
191 if (!(edit_buffer_has_type((ARG_ebuf), NAME_type))) {\
192 continue;\
195 #define edit_buffer_type_iterate_end \
197 } while (FALSE)
199 #ifdef __cplusplus
201 #endif /* __cplusplus */
203 #endif /* FC__TOOLS_H */