Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/editor.h Source File

Freeciv-3.1

Loading...
Searching...
No Matches
editor.h
Go to the documentation of this file.
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.
7
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***********************************************************************/
13
14#ifndef FC__TOOLS_H
15#define FC__TOOLS_H
16
17#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
21#include "fc_types.h"
22
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,
32
33 NUM_OBJTYPES
34};
35
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,
48
49 NUM_EDITOR_TOOL_TYPES
50};
51
52 enum editor_tool_mode {
53 ETM_PAINT = 0,
54 ETM_ERASE,
55 ETM_COPY,
56 ETM_PASTE,
57
58 NUM_EDITOR_TOOL_MODES
59};
60
61void editor_init(void);
62void editor_clear(void);
63void editor_free(void);
64
65void editor_ruleset_changed(void);
66
67bool editor_is_active(void);
68enum editor_tool_type editor_get_tool(void);
69void editor_set_tool(enum editor_tool_type emt);
70const struct tile *editor_get_current_tile(void);
71void editor_set_current_tile(const struct tile *ptile);
72
73bool editor_tool_has_mode(enum editor_tool_type ett,
74 enum editor_tool_mode etm);
75enum editor_tool_mode editor_tool_get_mode(enum editor_tool_type ett);
76void editor_tool_set_mode(enum editor_tool_type ett,
77 enum editor_tool_mode etm);
78void editor_tool_toggle_mode(enum editor_tool_type ett,
79 enum editor_tool_mode etm);
80void editor_tool_cycle_mode(enum editor_tool_type ett);
81const char *editor_tool_get_mode_name(enum editor_tool_type ett,
82 enum editor_tool_mode etm);
83
84bool editor_tool_has_size(enum editor_tool_type ett);
85int editor_tool_get_size(enum editor_tool_type ett);
86void editor_tool_set_size(enum editor_tool_type ett, int size);
87
88bool editor_tool_has_count(enum editor_tool_type ett);
89int editor_tool_get_count(enum editor_tool_type ett);
90void editor_tool_set_count(enum editor_tool_type ett, int count);
91
92bool editor_tool_has_applied_player(enum editor_tool_type ett);
93int editor_tool_get_applied_player(enum editor_tool_type ett);
94void editor_tool_set_applied_player(enum editor_tool_type,
95 int player_no);
96
97bool editor_tool_is_usable(enum editor_tool_type ett);
98bool editor_tool_has_value(enum editor_tool_type ett);
99bool editor_tool_has_value_erase(enum editor_tool_type ett);
100int editor_tool_get_value(enum editor_tool_type ett);
101void editor_tool_set_value(enum editor_tool_type ett, int value);
102const char *editor_tool_get_value_name(enum editor_tool_type ett,
103 int value);
104
105const char *editor_tool_get_name(enum editor_tool_type ett);
106struct sprite *editor_tool_get_sprite(enum editor_tool_type ett);
107const char *editor_tool_get_tooltip(enum editor_tool_type ett);
108
109const char *editor_get_mode_tooltip(enum editor_tool_mode etm);
110struct sprite *editor_get_mode_sprite(enum editor_tool_mode etm);
111
112struct edit_buffer;
113struct edit_buffer *editor_get_copy_buffer(void);
114
115
116 enum editor_keyboard_modifiers {
117 EKM_NONE = 0,
118 EKM_SHIFT = 1<<0,
119 EKM_ALT = 1<<1,
120 EKM_CTRL = 1<<2
121};
122
123 enum mouse_button_values {
124 MOUSE_BUTTON_OTHER = 0,
125
126 MOUSE_BUTTON_LEFT = 1,
127 MOUSE_BUTTON_MIDDLE = 2,
128 MOUSE_BUTTON_RIGHT = 3
129};
130
131void editor_mouse_button_press(int canvas_x, int canvas_y,
132 int button, int modifiers);
133void editor_mouse_button_release(int canvas_x, int canvas_y,
134 int button, int modifiers);
135void editor_mouse_move(int canvas_x, int canvas_y, int modifiers);
136
137void editor_apply_tool(const struct tile *ptile,
138 bool part_of_selection);
139void editor_notify_edit_finished(void);
140
141void editor_selection_clear(void);
142void editor_selection_add(const struct tile *ptile);
143void editor_selection_remove(const struct tile *ptile);
144bool editor_tile_is_selected(const struct tile *ptile);
145void editor_apply_tool_to_selection(void);
146int editor_selection_count(void);
147const struct tile *editor_get_selection_center(void);
148
149struct unit *editor_unit_virtual_create(void);
150
151
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,
163
164 /* Equal to the bitwise OR of all preceding flags. */
165 EBT_ALL = (1<<7) - 1
166};
167
168struct edit_buffer *edit_buffer_new(int type_flags);
169void edit_buffer_free(struct edit_buffer *ebuf);
170void edit_buffer_clear(struct edit_buffer *ebuf);
171void edit_buffer_set_origin(struct edit_buffer *ebuf,
172 const struct tile *ptile);
173const struct tile *edit_buffer_get_origin(const struct edit_buffer *ebuf);
174bool edit_buffer_has_type(const struct edit_buffer *ebuf, int type);
175void edit_buffer_copy(struct edit_buffer *ebuf, const struct tile *ptile);
176void edit_buffer_copy_square(struct edit_buffer *ebuf,
177 const struct tile *center,
178 int radius);
179void edit_buffer_paste(struct edit_buffer *ebuf, const struct tile *dest);
180int edit_buffer_get_status_string(const struct edit_buffer *ebuf,
181 char *buf, int buflen);
182
183/* Iterates over all type flags set for the given buffer. */
184#define edit_buffer_type_iterate(ARG_ebuf, NAME_type) \
185do {\
186 int NAME_type;\
187 if (!(ARG_ebuf)) {\
188 break;\
189 }\
190 for (NAME_type = 1; NAME_type < EBT_ALL; NAME_type <<= 1) {\
191 if (!(edit_buffer_has_type((ARG_ebuf), NAME_type))) {\
192 continue;\
193 }
194
195#define edit_buffer_type_iterate_end \
196 }\
197} while (FALSE)
198
199#ifdef __cplusplus
200}
201#endif /* __cplusplus */
202
203#endif /* FC__TOOLS_H */
canvas_y
struct canvas int int canvas_y
Definition canvas_g.h:43
canvas_x
struct canvas int canvas_x
Definition canvas_g.h:43
edit_buffer_get_status_string
int edit_buffer_get_status_string(const struct edit_buffer *ebuf, char *buf, int buflen)
Definition editor.c:1870
editor_is_active
bool editor_is_active(void)
Definition editor.c:346
editor_selection_remove
void editor_selection_remove(const struct tile *ptile)
Definition editor.c:1106
edit_buffer_has_type
bool edit_buffer_has_type(const struct edit_buffer *ebuf, int type)
Definition editor.c:1921
editor_tool_get_size
int editor_tool_get_size(enum editor_tool_type ett)
Definition editor.c:1218
editor_tool_mode
editor_tool_mode
Definition editor.h:52
ETM_PASTE
@ ETM_PASTE
Definition editor.h:56
NUM_EDITOR_TOOL_MODES
@ NUM_EDITOR_TOOL_MODES
Definition editor.h:58
ETM_ERASE
@ ETM_ERASE
Definition editor.h:54
ETM_PAINT
@ ETM_PAINT
Definition editor.h:53
ETM_COPY
@ ETM_COPY
Definition editor.h:55
edit_buffer_types
edit_buffer_types
Definition editor.h:155
EBT_RESOURCE
@ EBT_RESOURCE
Definition editor.h:157
EBT_CITY
@ EBT_CITY
Definition editor.h:162
EBT_UNIT
@ EBT_UNIT
Definition editor.h:161
EBT_BASE
@ EBT_BASE
Definition editor.h:159
EBT_ALL
@ EBT_ALL
Definition editor.h:165
EBT_ROAD
@ EBT_ROAD
Definition editor.h:160
EBT_TERRAIN
@ EBT_TERRAIN
Definition editor.h:156
EBT_SPECIAL
@ EBT_SPECIAL
Definition editor.h:158
editor_mouse_button_press
void editor_mouse_button_press(int canvas_x, int canvas_y, int button, int modifiers)
Definition editor.c:661
editor_set_current_tile
void editor_set_current_tile(const struct tile *ptile)
Definition editor.c:1016
editor_mouse_move
void editor_mouse_move(int canvas_x, int canvas_y, int modifiers)
Definition editor.c:866
editor_tool_get_mode
enum editor_tool_mode editor_tool_get_mode(enum editor_tool_type ett)
Definition editor.c:335
editor_tool_has_value_erase
bool editor_tool_has_value_erase(enum editor_tool_type ett)
Definition editor.c:1377
editor_tool_set_count
void editor_tool_set_count(enum editor_tool_type ett, int count)
Definition editor.c:1263
editor_tool_toggle_mode
void editor_tool_toggle_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:1041
editor_selection_add
void editor_selection_add(const struct tile *ptile)
Definition editor.c:1095
editor_notify_edit_finished
void editor_notify_edit_finished(void)
Definition editor.c:897
editor_init
void editor_init(void)
Definition editor.c:193
editor_tool_get_value
int editor_tool_get_value(enum editor_tool_type ett)
Definition editor.c:409
editor_tool_set_applied_player
void editor_tool_set_applied_player(enum editor_tool_type, int player_no)
Definition editor.c:1352
edit_buffer_new
struct edit_buffer * edit_buffer_new(int type_flags)
Definition editor.c:1433
editor_get_copy_buffer
struct edit_buffer * editor_get_copy_buffer(void)
Definition editor.c:1767
editor_tool_get_mode_name
const char * editor_tool_get_mode_name(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:1778
editor_set_tool
void editor_set_tool(enum editor_tool_type emt)
Definition editor.c:270
editor_clear
void editor_clear(void)
Definition editor.c:246
editor_tool_cycle_mode
void editor_tool_cycle_mode(enum editor_tool_type ett)
Definition editor.c:1058
editor_tool_get_count
int editor_tool_get_count(enum editor_tool_type ett)
Definition editor.c:1252
edit_buffer_get_origin
const struct tile * edit_buffer_get_origin(const struct edit_buffer *ebuf)
Definition editor.c:1910
edit_buffer_copy
void edit_buffer_copy(struct edit_buffer *ebuf, const struct tile *ptile)
Definition editor.c:1505
editor_selection_count
int editor_selection_count(void)
Definition editor.c:1388
editor_tool_set_size
void editor_tool_set_size(enum editor_tool_type ett, int size)
Definition editor.c:1229
editor_get_mode_tooltip
const char * editor_get_mode_tooltip(enum editor_tool_mode etm)
Definition editor.c:1815
editor_tool_is_usable
bool editor_tool_is_usable(enum editor_tool_type ett)
Definition editor.c:359
editor_get_tool
enum editor_tool_type editor_get_tool(void)
Definition editor.c:286
editor_tool_has_applied_player
bool editor_tool_has_applied_player(enum editor_tool_type ett)
Definition editor.c:1365
editor_tool_has_size
bool editor_tool_has_size(enum editor_tool_type ett)
Definition editor.c:1207
edit_buffer_clear
void edit_buffer_clear(struct edit_buffer *ebuf)
Definition editor.c:1470
editor_tool_set_value
void editor_tool_set_value(enum editor_tool_type ett, int value)
Definition editor.c:397
editor_tool_has_value
bool editor_tool_has_value(enum editor_tool_type ett)
Definition editor.c:385
mouse_button_values
mouse_button_values
Definition editor.h:123
MOUSE_BUTTON_OTHER
@ MOUSE_BUTTON_OTHER
Definition editor.h:124
MOUSE_BUTTON_LEFT
@ MOUSE_BUTTON_LEFT
Definition editor.h:126
MOUSE_BUTTON_RIGHT
@ MOUSE_BUTTON_RIGHT
Definition editor.h:128
MOUSE_BUTTON_MIDDLE
@ MOUSE_BUTTON_MIDDLE
Definition editor.h:127
editor_tool_get_tooltip
const char * editor_tool_get_tooltip(enum editor_tool_type ett)
Definition editor.c:1327
editor_selection_clear
void editor_selection_clear(void)
Definition editor.c:1084
editor_mouse_button_release
void editor_mouse_button_release(int canvas_x, int canvas_y, int button, int modifiers)
Definition editor.c:798
edit_buffer_copy_square
void edit_buffer_copy_square(struct edit_buffer *ebuf, const struct tile *center, int radius)
Definition editor.c:1488
editor_tool_get_sprite
struct sprite * editor_tool_get_sprite(enum editor_tool_type ett)
Definition editor.c:1275
editor_get_current_tile
const struct tile * editor_get_current_tile(void)
Definition editor.c:1028
editor_apply_tool_to_selection
void editor_apply_tool_to_selection(void)
Definition editor.c:1128
editor_tool_get_value_name
const char * editor_tool_get_value_name(enum editor_tool_type ett, int value)
Definition editor.c:1172
editor_apply_tool
void editor_apply_tool(const struct tile *ptile, bool part_of_selection)
Definition editor.c:909
editor_tile_is_selected
bool editor_tile_is_selected(const struct tile *ptile)
Definition editor.c:1117
edit_buffer_set_origin
void edit_buffer_set_origin(struct edit_buffer *ebuf, const struct tile *ptile)
Definition editor.c:1898
editor_free
void editor_free(void)
Definition editor.c:257
edit_buffer_paste
void edit_buffer_paste(struct edit_buffer *ebuf, const struct tile *dest)
Definition editor.c:1735
editor_get_selection_center
const struct tile * editor_get_selection_center(void)
Definition editor.c:1934
editor_tool_has_mode
bool editor_tool_has_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:313
editor_unit_virtual_create
struct unit * editor_unit_virtual_create(void)
Definition editor.c:1405
editor_object_type
editor_object_type
Definition editor.h:25
OBJTYPE_PLAYER
@ OBJTYPE_PLAYER
Definition editor.h:30
OBJTYPE_UNIT
@ OBJTYPE_UNIT
Definition editor.h:28
OBJTYPE_STARTPOS
@ OBJTYPE_STARTPOS
Definition editor.h:27
OBJTYPE_GAME
@ OBJTYPE_GAME
Definition editor.h:31
NUM_OBJTYPES
@ NUM_OBJTYPES
Definition editor.h:33
OBJTYPE_CITY
@ OBJTYPE_CITY
Definition editor.h:29
OBJTYPE_TILE
@ OBJTYPE_TILE
Definition editor.h:26
editor_ruleset_changed
void editor_ruleset_changed(void)
Definition editor.c:180
editor_tool_get_applied_player
int editor_tool_get_applied_player(enum editor_tool_type ett)
Definition editor.c:1341
editor_keyboard_modifiers
editor_keyboard_modifiers
Definition editor.h:116
EKM_CTRL
@ EKM_CTRL
Definition editor.h:120
EKM_SHIFT
@ EKM_SHIFT
Definition editor.h:118
EKM_ALT
@ EKM_ALT
Definition editor.h:119
EKM_NONE
@ EKM_NONE
Definition editor.h:117
editor_tool_has_count
bool editor_tool_has_count(enum editor_tool_type ett)
Definition editor.c:1241
editor_get_mode_sprite
struct sprite * editor_get_mode_sprite(enum editor_tool_mode etm)
Definition editor.c:1837
editor_tool_type
editor_tool_type
Definition editor.h:36
ETT_ROAD
@ ETT_ROAD
Definition editor.h:40
ETT_TERRAIN_SPECIAL
@ ETT_TERRAIN_SPECIAL
Definition editor.h:39
ETT_UNIT
@ ETT_UNIT
Definition editor.h:42
ETT_VISION
@ ETT_VISION
Definition editor.h:44
ETT_STARTPOS
@ ETT_STARTPOS
Definition editor.h:46
ETT_TERRITORY
@ ETT_TERRITORY
Definition editor.h:45
NUM_EDITOR_TOOL_TYPES
@ NUM_EDITOR_TOOL_TYPES
Definition editor.h:49
ETT_CITY
@ ETT_CITY
Definition editor.h:43
ETT_COPYPASTE
@ ETT_COPYPASTE
Definition editor.h:47
ETT_TERRAIN_RESOURCE
@ ETT_TERRAIN_RESOURCE
Definition editor.h:38
ETT_MILITARY_BASE
@ ETT_MILITARY_BASE
Definition editor.h:41
ETT_TERRAIN
@ ETT_TERRAIN
Definition editor.h:37
editor_tool_get_name
const char * editor_tool_get_name(enum editor_tool_type ett)
Definition editor.c:1159
edit_buffer_free
void edit_buffer_free(struct edit_buffer *ebuf)
Definition editor.c:1451
editor_tool_set_mode
void editor_tool_set_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:298
fc_types.h
type
GType type
Definition repodlgs.c:1312
size
size_t size
Definition specvec.h:72
edit_buffer
Definition editor.c:62
edit_buffer::type_flags
int type_flags
Definition editor.c:63
sprite
Definition sprite.h:22
tile
Definition tile.h:49
unit
Definition unit.h:138