![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include "fc_types.h"
Include dependency graph for editor.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Macros | |
| #define | edit_buffer_type_iterate(ARG_ebuf, NAME_type) |
| #define | edit_buffer_type_iterate_end |
Enumerations | |
| enum | editor_object_type { OBJTYPE_TILE = 0 , OBJTYPE_STARTPOS , OBJTYPE_UNIT , OBJTYPE_CITY , OBJTYPE_PLAYER , OBJTYPE_GAME , NUM_OBJTYPES } |
| enum | editor_tool_type { ETT_TERRAIN = 0 , ETT_TERRAIN_RESOURCE , ETT_TERRAIN_SPECIAL , ETT_ROAD , ETT_MILITARY_BASE , ETT_UNIT , ETT_CITY , ETT_VISION , ETT_TERRITORY , ETT_STARTPOS , ETT_COPYPASTE , NUM_EDITOR_TOOL_TYPES } |
| enum | editor_tool_mode { ETM_PAINT = 0 , ETM_ERASE , ETM_COPY , ETM_PASTE , NUM_EDITOR_TOOL_MODES } |
| enum | editor_keyboard_modifiers { EKM_NONE = 0 , EKM_SHIFT = 1 << 0 , EKM_ALT = 1 << 1 , EKM_CTRL = 1 << 2 } |
| enum | mouse_button_values { MOUSE_BUTTON_OTHER = 0 , MOUSE_BUTTON_LEFT = 1 , MOUSE_BUTTON_MIDDLE = 2 , MOUSE_BUTTON_RIGHT = 3 } |
| enum | edit_buffer_types { EBT_TERRAIN = 1 << 0 , EBT_RESOURCE = 1 << 1 , EBT_SPECIAL = 1 << 2 , EBT_BASE = 1 << 3 , EBT_ROAD = 1 << 4 , EBT_UNIT = 1 << 5 , EBT_CITY = 1 << 6 , EBT_ALL = (1 << 7) - 1 } |
Functions | |
| void | editor_init () |
| Initialize the client's editor state information to some suitable default values. More... | |
| void | editor_clear () |
| Clear the editor data which is game dependent. More... | |
| void | editor_free () |
| Free the client's editor. More... | |
| void | editor_ruleset_changed () |
| Adjust editor for changed ruleset. More... | |
| bool | editor_is_active () |
| Returns TRUE if the client is in edit mode. More... | |
| enum editor_tool_type | editor_get_tool () |
| Get the current tool used by the editor. More... | |
| void | editor_set_tool (enum editor_tool_type emt) |
| Set the current tool to be used by the editor. More... | |
| const struct tile * | editor_get_current_tile () |
| Get the tile that the user's mouse pointer is currently over. More... | |
| void | editor_set_current_tile (const struct tile *ptile) |
| Sets the tile currently assumed to be under the user's mouse pointer. More... | |
| bool | editor_tool_has_mode (enum editor_tool_type ett, enum editor_tool_mode etm) |
| Return TRUE if the given tool supports the given mode. More... | |
| enum editor_tool_mode | editor_tool_get_mode (enum editor_tool_type ett) |
| Get the mode for the tool. More... | |
| void | editor_tool_set_mode (enum editor_tool_type ett, enum editor_tool_mode etm) |
| Set the mode for the editor tool. More... | |
| void | editor_tool_toggle_mode (enum editor_tool_type ett, enum editor_tool_mode etm) |
| Toggle the current tool mode between the given mode and ETM_PAINT (or ETM_COPY for the copy & paste tool). More... | |
| void | editor_tool_cycle_mode (enum editor_tool_type ett) |
| Set the editor tool mode to the next available mode. More... | |
| const char * | editor_tool_get_mode_name (enum editor_tool_type ett, enum editor_tool_mode etm) |
| Returns the translated string name for the given mode. More... | |
| bool | editor_tool_has_size (enum editor_tool_type ett) |
| Return TRUE if the given editor tool uses the 'size' parameter. More... | |
| int | editor_tool_get_size (enum editor_tool_type ett) |
| Returns the current size parameter for the given editor tools. More... | |
| void | editor_tool_set_size (enum editor_tool_type ett, int size) |
| Sets the size parameter for the given tool. More... | |
| bool | editor_tool_has_count (enum editor_tool_type ett) |
| Return TRUE if it is meaningful for the given tool to use the 'count' parameter. More... | |
| int | editor_tool_get_count (enum editor_tool_type ett) |
| Returns the 'count' parameter for the editor tool. More... | |
| void | editor_tool_set_count (enum editor_tool_type ett, int count) |
| Sets the 'count' parameter of the tool to the given value. More... | |
| bool | editor_tool_has_applied_player (enum editor_tool_type ett) |
| Returns TRUE if the given tool makes use of the editor's applied player number. More... | |
| int | editor_tool_get_applied_player (enum editor_tool_type ett) |
| Returns the current applied player number for the editor tool. More... | |
| void | editor_tool_set_applied_player (enum editor_tool_type, int player_no) |
| Sets the editor tool's applied player number to the given value. More... | |
| bool | editor_tool_is_usable (enum editor_tool_type ett) |
| Returns TRUE if the given tool should be made available to the user via the editor GUI. More... | |
| bool | editor_tool_has_value (enum editor_tool_type ett) |
| Returns TRUE if the given tool type has sub-values (e.g. More... | |
| bool | editor_tool_has_value_erase (enum editor_tool_type ett) |
| Returns TRUE if erase mode for the given tool erases by sub-value instead of any object corresponding to the tool type. More... | |
| int | editor_tool_get_value (enum editor_tool_type ett) |
| Get the current tool sub-value. More... | |
| void | editor_tool_set_value (enum editor_tool_type ett, int value) |
| Set the value ID for the given tool. More... | |
| const char * | editor_tool_get_value_name (enum editor_tool_type ett, int value) |
| Get the translated name of the given tool value. More... | |
| const char * | editor_tool_get_name (enum editor_tool_type ett) |
| Get the translated name of the given tool type. More... | |
| QPixmap * | editor_tool_get_sprite (enum editor_tool_type ett) |
| Returns a sprite containing an icon for the given tool type. More... | |
| const char * | editor_tool_get_tooltip (enum editor_tool_type ett) |
| Returns a translated "tooltip" description for the given tool type. More... | |
| const char * | editor_get_mode_tooltip (enum editor_tool_mode etm) |
| Returns a translated tooltip string assumed to be used for the toggle button for this tool mode in the editor gui. More... | |
| QPixmap * | editor_get_mode_sprite (enum editor_tool_mode etm) |
| Returns the editor sprite corresponding to the tool mode. More... | |
| struct edit_buffer * | editor_get_copy_buffer () |
| Returns the copy buffer for the given tool. More... | |
| void | editor_mouse_button_press (int canvas_x, int canvas_y, int button, int modifiers) |
| Handle a user's mouse button press at the given point on the map canvas. More... | |
| void | editor_mouse_button_release (int canvas_x, int canvas_y, int button, int modifiers) |
| Handle the release of a mouse button click. More... | |
| void | editor_mouse_move (int canvas_x, int canvas_y, int modifiers) |
| Handle the mouse moving over the map canvas. More... | |
| void | editor_apply_tool (const struct tile *ptile, bool part_of_selection) |
| Apply the current editor tool to the given tile. More... | |
| void | editor_notify_edit_finished () |
| Notify the server that a batch of edits has completed. More... | |
| void | editor_selection_clear () |
| Unselect all selected tiles. More... | |
| void | editor_selection_add (const struct tile *ptile) |
| Add the given tile to the current selection. More... | |
| void | editor_selection_remove (const struct tile *ptile) |
| Remove the given tile from the current selection. More... | |
| bool | editor_tile_is_selected (const struct tile *ptile) |
| Returns TRUE if the given tile is selected. More... | |
| void | editor_apply_tool_to_selection () |
| Apply the current editor tool to all tiles in the current selection. More... | |
| const struct tile * | editor_get_selection_center () |
| Returns the "center" tile of a group of selected tiles, or nullptr. More... | |
| struct unit * | editor_unit_virtual_create () |
| Creates a virtual unit (like unit_virtual_create) based on the current editor state. More... | |
| struct edit_buffer * | edit_buffer_new (int type_flags) |
| Create a new edit buffer corresponding to all types set in 'type_flags'. More... | |
| void | edit_buffer_free (struct edit_buffer *ebuf) |
| Free all memory allocated for the edit buffer. More... | |
| void | edit_buffer_clear (struct edit_buffer *ebuf) |
| Remove all copy data stored in the edit buffer. More... | |
| void | edit_buffer_set_origin (struct edit_buffer *ebuf, const struct tile *ptile) |
| Set the "origin" for subsequent copy operations. More... | |
| const struct tile * | edit_buffer_get_origin (const struct edit_buffer *ebuf) |
| Return the previously set origin, or nullptr if none. More... | |
| bool | edit_buffer_has_type (const struct edit_buffer *ebuf, int type) |
| Returns TRUE if the edit buffer was created with the given type flag. More... | |
| void | edit_buffer_copy (struct edit_buffer *ebuf, const struct tile *ptile) |
| Append a single tile to the copy buffer. More... | |
| void | edit_buffer_copy_square (struct edit_buffer *ebuf, const struct tile *center, int radius) |
| Copy from a square region of half-width 'radius' centered around 'center' into the buffer. More... | |
| void | edit_buffer_paste (struct edit_buffer *ebuf, const struct tile *dest) |
| Paste the entire contents of the edit buffer using 'dest' as the origin. More... | |
| int | edit_buffer_get_status_string (const struct edit_buffer *ebuf, char *buf, int buflen) |
| Fill the supplied buffer with a translated string describing the edit buffer's current state. More... | |
| #define edit_buffer_type_iterate | ( | ARG_ebuf, | |
| NAME_type | |||
| ) |
| #define edit_buffer_type_iterate_end |
| enum edit_buffer_types |
| enum editor_object_type |
| enum editor_tool_mode |
| enum editor_tool_type |
| enum mouse_button_values |
| void edit_buffer_clear | ( | struct edit_buffer * | ebuf | ) |
Remove all copy data stored in the edit buffer.
Definition at line 1449 of file editor.cpp.
Referenced by editor_apply_tool(), editor_apply_tool_to_selection(), and editor_clear().
| void edit_buffer_copy | ( | struct edit_buffer * | ebuf, |
| const struct tile * | ptile | ||
| ) |
Append a single tile to the copy buffer.
Definition at line 1484 of file editor.cpp.
Referenced by edit_buffer_copy_square(), and editor_apply_tool().
| void edit_buffer_copy_square | ( | struct edit_buffer * | ebuf, |
| const struct tile * | center, | ||
| int | radius | ||
| ) |
Copy from a square region of half-width 'radius' centered around 'center' into the buffer.
Definition at line 1466 of file editor.cpp.
Referenced by editor_apply_tool().
| void edit_buffer_free | ( | struct edit_buffer * | ebuf | ) |
Free all memory allocated for the edit buffer.
Definition at line 1431 of file editor.cpp.
Referenced by editor_free().
| const struct tile* edit_buffer_get_origin | ( | const struct edit_buffer * | ebuf | ) |
Return the previously set origin, or nullptr if none.
Definition at line 1912 of file editor.cpp.
Referenced by edit_buffer_paste().
| int edit_buffer_get_status_string | ( | const struct edit_buffer * | ebuf, |
| char * | buf, | ||
| int | buflen | ||
| ) |
Fill the supplied buffer with a translated string describing the edit buffer's current state.
Returns the number of bytes used.
Definition at line 1872 of file editor.cpp.
| bool edit_buffer_has_type | ( | const struct edit_buffer * | ebuf, |
| int | type | ||
| ) |
Returns TRUE if the edit buffer was created with the given type flag.
Definition at line 1923 of file editor.cpp.
| struct edit_buffer* edit_buffer_new | ( | int | type_flags | ) |
Create a new edit buffer corresponding to all types set in 'type_flags'.
Definition at line 1413 of file editor.cpp.
Referenced by editor_init().
| void edit_buffer_paste | ( | struct edit_buffer * | ebuf, |
| const struct tile * | dest | ||
| ) |
Paste the entire contents of the edit buffer using 'dest' as the origin.
Definition at line 1734 of file editor.cpp.
Referenced by editor_apply_tool().
| void edit_buffer_set_origin | ( | struct edit_buffer * | ebuf, |
| const struct tile * | ptile | ||
| ) |
Set the "origin" for subsequent copy operations.
This controls the x and y offset of newly created virtual tiles in the buffer.
Definition at line 1900 of file editor.cpp.
Referenced by edit_buffer_clear(), edit_buffer_copy_square(), and editor_apply_tool_to_selection().
| void editor_apply_tool | ( | const struct tile * | ptile, |
| bool | part_of_selection | ||
| ) |
Apply the current editor tool to the given tile.
This function is suitable to called over multiple tiles at once. Once the batch of operations is finished you should call editor_notify_edit_finished. The 'part_of_selection' parameter should be TRUE if the tool is being applied to a tile from a selection.
Definition at line 904 of file editor.cpp.
Referenced by editor_apply_tool_to_selection(), editor_mouse_button_press(), and editor_mouse_move().
| void editor_apply_tool_to_selection | ( | ) |
Apply the current editor tool to all tiles in the current selection.
Definition at line 1120 of file editor.cpp.
| void editor_clear | ( | ) |
Clear the editor data which is game dependent.
Definition at line 236 of file editor.cpp.
Referenced by client_state().
| void editor_free | ( | ) |
| struct edit_buffer* editor_get_copy_buffer | ( | ) |
Returns the copy buffer for the given tool.
Definition at line 1768 of file editor.cpp.
Referenced by editor_apply_tool(), and editor_apply_tool_to_selection().
| const struct tile* editor_get_current_tile | ( | ) |
Get the tile that the user's mouse pointer is currently over.
Definition at line 1021 of file editor.cpp.
Referenced by editor_mouse_move().
| QPixmap* editor_get_mode_sprite | ( | enum editor_tool_mode | etm | ) |
Returns the editor sprite corresponding to the tool mode.
Definition at line 1839 of file editor.cpp.
| const char* editor_get_mode_tooltip | ( | enum editor_tool_mode | etm | ) |
Returns a translated tooltip string assumed to be used for the toggle button for this tool mode in the editor gui.
Definition at line 1817 of file editor.cpp.
| const struct tile* editor_get_selection_center | ( | ) |
Returns the "center" tile of a group of selected tiles, or nullptr.
The center is calculated as the vector sum divided by the number of tiles, i.e. the average of the map distance vectors of the selected tiles.
Definition at line 1936 of file editor.cpp.
Referenced by editor_apply_tool_to_selection().
| enum editor_tool_type editor_get_tool | ( | ) |
Get the current tool used by the editor.
Definition at line 260 of file editor.cpp.
Referenced by editor_apply_tool(), editor_apply_tool_to_selection(), and editor_grab_applied_player().
| void editor_init | ( | ) |
Initialize the client's editor state information to some suitable default values.
This only needs to be done once at client start.
Definition at line 184 of file editor.cpp.
Referenced by client_main().
| bool editor_is_active | ( | ) |
Returns TRUE if the client is in edit mode.
Definition at line 335 of file editor.cpp.
Referenced by freeciv::layer_editor::fill_sprite_array(), handle_research_info(), put_one_tile(), and freeciv::tileset_debugger::set_tile().
| void editor_mouse_button_press | ( | int | canvas_x, |
| int | canvas_y, | ||
| int | button, | ||
| int | modifiers | ||
| ) |
Handle a user's mouse button press at the given point on the map canvas.
Definition at line 659 of file editor.cpp.
| void editor_mouse_button_release | ( | int | canvas_x, |
| int | canvas_y, | ||
| int | button, | ||
| int | modifiers | ||
| ) |
Handle the release of a mouse button click.
Definition at line 792 of file editor.cpp.
| void editor_mouse_move | ( | int | canvas_x, |
| int | canvas_y, | ||
| int | modifiers | ||
| ) |
Handle the mouse moving over the map canvas.
Definition at line 860 of file editor.cpp.
| void editor_notify_edit_finished | ( | ) |
Notify the server that a batch of edits has completed.
This is used as a hint for the server to now do any checks it has saved while the batch was being processed.
Definition at line 892 of file editor.cpp.
Referenced by editor_apply_tool_to_selection(), editor_mouse_button_press(), and editor_mouse_move().
| void editor_ruleset_changed | ( | ) |
Adjust editor for changed ruleset.
Definition at line 171 of file editor.cpp.
Referenced by handle_rulesets_ready().
| void editor_selection_add | ( | const struct tile * | ptile | ) |
Add the given tile to the current selection.
Definition at line 1087 of file editor.cpp.
Referenced by editor_end_selection_rectangle().
| void editor_selection_clear | ( | ) |
Unselect all selected tiles.
Definition at line 1076 of file editor.cpp.
Referenced by editor_start_selection_rectangle().
| void editor_selection_remove | ( | const struct tile * | ptile | ) |
Remove the given tile from the current selection.
Definition at line 1098 of file editor.cpp.
Referenced by editor_end_selection_rectangle().
| void editor_set_current_tile | ( | const struct tile * | ptile | ) |
Sets the tile currently assumed to be under the user's mouse pointer.
Definition at line 1009 of file editor.cpp.
Referenced by editor_mouse_button_press(), editor_mouse_button_release(), and editor_mouse_move().
| void editor_set_tool | ( | enum editor_tool_type | emt | ) |
Set the current tool to be used by the editor.
Definition at line 260 of file editor.cpp.
Referenced by editor_grab_tool().
| bool editor_tile_is_selected | ( | const struct tile * | ptile | ) |
Returns TRUE if the given tile is selected.
Definition at line 1109 of file editor.cpp.
Referenced by freeciv::layer_editor::fill_sprite_array(), popup_properties(), put_one_tile(), and freeciv::tileset_debugger::set_tile().
| void editor_tool_cycle_mode | ( | enum editor_tool_type | ett | ) |
Set the editor tool mode to the next available mode.
Definition at line 1050 of file editor.cpp.
| int editor_tool_get_applied_player | ( | enum editor_tool_type | ett | ) |
Returns the current applied player number for the editor tool.
May return a player number for which player_by_number returns nullptr.
Definition at line 1333 of file editor.cpp.
Referenced by editor_apply_tool(), and editor_unit_virtual_create().
| int editor_tool_get_count | ( | enum editor_tool_type | ett | ) |
Returns the 'count' parameter for the editor tool.
Definition at line 1244 of file editor.cpp.
Referenced by editor_apply_tool().
| enum editor_tool_mode editor_tool_get_mode | ( | enum editor_tool_type | ett | ) |
Get the mode for the tool.
Definition at line 302 of file editor.cpp.
Referenced by editor_apply_tool(), editor_apply_tool_to_selection(), editor_tool_cycle_mode(), and editor_tool_toggle_mode().
| const char* editor_tool_get_mode_name | ( | enum editor_tool_type | ett, |
| enum editor_tool_mode | etm | ||
| ) |
Returns the translated string name for the given mode.
Definition at line 1779 of file editor.cpp.
| const char* editor_tool_get_name | ( | enum editor_tool_type | ett | ) |
Get the translated name of the given tool type.
Definition at line 1151 of file editor.cpp.
| int editor_tool_get_size | ( | enum editor_tool_type | ett | ) |
Returns the current size parameter for the given editor tools.
Definition at line 1210 of file editor.cpp.
Referenced by editor_apply_tool().
| QPixmap* editor_tool_get_sprite | ( | enum editor_tool_type | ett | ) |
Returns a sprite containing an icon for the given tool type.
Returns nullptr if no such sprite exists.
Definition at line 1267 of file editor.cpp.
| const char* editor_tool_get_tooltip | ( | enum editor_tool_type | ett | ) |
Returns a translated "tooltip" description for the given tool type.
Definition at line 1319 of file editor.cpp.
| int editor_tool_get_value | ( | enum editor_tool_type | ett | ) |
Get the current tool sub-value.
Definition at line 395 of file editor.cpp.
Referenced by editor_apply_tool(), and editor_unit_virtual_create().
| const char* editor_tool_get_value_name | ( | enum editor_tool_type | emt, |
| int | value | ||
| ) |
Get the translated name of the given tool value.
If no such name exists, returns an empty string.
Definition at line 1164 of file editor.cpp.
| bool editor_tool_has_applied_player | ( | enum editor_tool_type | ett | ) |
Returns TRUE if the given tool makes use of the editor's applied player number.
Definition at line 1356 of file editor.cpp.
Referenced by editor_apply_tool().
| bool editor_tool_has_count | ( | enum editor_tool_type | ett | ) |
Return TRUE if it is meaningful for the given tool to use the 'count' parameter.
Definition at line 1233 of file editor.cpp.
| bool editor_tool_has_mode | ( | enum editor_tool_type | ett, |
| enum editor_tool_mode | etm | ||
| ) |
Return TRUE if the given tool supports the given mode.
Definition at line 302 of file editor.cpp.
Referenced by editor_tool_cycle_mode(), editor_tool_set_mode(), and editor_tool_toggle_mode().
| bool editor_tool_has_size | ( | enum editor_tool_type | ett | ) |
Return TRUE if the given editor tool uses the 'size' parameter.
Definition at line 1199 of file editor.cpp.
| bool editor_tool_has_value | ( | enum editor_tool_type | ett | ) |
Returns TRUE if the given tool type has sub-values (e.g.
the terrain tool has values corresponding to the terrain types).
Definition at line 371 of file editor.cpp.
Referenced by editor_grab_tool(), editor_tool_get_value(), and editor_tool_set_value().
| bool editor_tool_has_value_erase | ( | enum editor_tool_type | ett | ) |
Returns TRUE if erase mode for the given tool erases by sub-value instead of any object corresponding to the tool type.
Definition at line 1368 of file editor.cpp.
Referenced by editor_tool_get_mode_name().
| bool editor_tool_is_usable | ( | enum editor_tool_type | ett | ) |
Returns TRUE if the given tool should be made available to the user via the editor GUI.
For example, this will return FALSE for ETT_MILITARY_BASE if there are no bases defined in the ruleset.
NB: This depends on the ruleset information received from the server, so it will return FALSE if the client does not have it yet.
Definition at line 345 of file editor.cpp.
| void editor_tool_set_applied_player | ( | enum | editor_tool_type, |
| int | player_no | ||
| ) |
Sets the editor tool's applied player number to the given value.
Definition at line 1344 of file editor.cpp.
Referenced by editor_grab_applied_player().
| void editor_tool_set_count | ( | enum editor_tool_type | ett, |
| int | count | ||
| ) |
Sets the 'count' parameter of the tool to the given value.
Definition at line 1255 of file editor.cpp.
| void editor_tool_set_mode | ( | enum editor_tool_type | ett, |
| enum editor_tool_mode | etm | ||
| ) |
Set the mode for the editor tool.
Definition at line 288 of file editor.cpp.
Referenced by editor_tool_cycle_mode(), and editor_tool_toggle_mode().
| void editor_tool_set_size | ( | enum editor_tool_type | ett, |
| int | size | ||
| ) |
Sets the size parameter for the given tool.
Definition at line 1221 of file editor.cpp.
| void editor_tool_set_value | ( | enum editor_tool_type | ett, |
| int | value | ||
| ) |
Set the value ID for the given tool.
How the value is interpreted depends on the tool type.
Definition at line 383 of file editor.cpp.
Referenced by editor_grab_tool().
| void editor_tool_toggle_mode | ( | enum editor_tool_type | ett, |
| enum editor_tool_mode | etm | ||
| ) |
Toggle the current tool mode between the given mode and ETM_PAINT (or ETM_COPY for the copy & paste tool).
Definition at line 1034 of file editor.cpp.
| struct unit* editor_unit_virtual_create | ( | ) |
Creates a virtual unit (like unit_virtual_create) based on the current editor state.
You should free() the unit when it is no longer needed. If creation is not possible, then nullptr is returned.
The virtual unit has no homecity or tile. It is owned by the player corresponding to the current 'applied player' parameter and has unit type given by the sub-value of the unit tool (ETT_UNIT).
Definition at line 1385 of file editor.cpp.