Freeciv-3.2
|
#include <stdarg.h>
#include <string.h>
#include "bitvector.h"
#include "fcintl.h"
#include "log.h"
#include "support.h"
#include "game.h"
#include "map.h"
#include "movement.h"
#include "packets.h"
#include "client_main.h"
#include "climap.h"
#include "control.h"
#include "editor.h"
#include "mapctrl_common.h"
#include "tilespec.h"
#include "zoom.h"
#include "editgui_g.h"
#include "mapview_g.h"
Go to the source code of this file.
Data Structures | |
struct | edit_buffer |
struct | editor_tool |
struct | editor_state |
Enumerations | |
enum | selection_modes { SELECTION_MODE_NEW = 0 , SELECTION_MODE_ADD , SELECTION_MODE_REMOVE } |
enum | editor_tool_flags { ETF_NO_FLAGS = 0 , ETF_HAS_VALUE = 1<<0 , ETF_HAS_SIZE = 1<<1 , ETF_HAS_COUNT = 1<<2 , ETF_HAS_APPLIED_PLAYER = 1<<3 , ETF_HAS_VALUE_ERASE = 1<<4 } |
Variables | |
static struct editor_state * | editor = NULL |
Returns TRUE if the given tile has some objects with editable properties.
Definition at line 621 of file editor.c.
Referenced by popup_properties().
void edit_buffer_clear | ( | struct edit_buffer * | ebuf | ) |
Remove all copy data stored in the edit buffer.
Definition at line 1470 of file editor.c.
Referenced by editor_apply_tool(), editor_apply_tool_to_selection(), and editor_clear().
Append a single tile to the copy buffer.
Definition at line 1505 of file editor.c.
Referenced by edit_buffer_copy_square(), and editor_apply_tool().
Copy from a square region of half-width 'radius' centered around 'center' into the buffer.
Definition at line 1488 of file editor.c.
Referenced by editor_apply_tool().
void edit_buffer_free | ( | struct edit_buffer * | ebuf | ) |
Free all memory allocated for the edit buffer.
Definition at line 1451 of file editor.c.
Referenced by editor_free().
Return the previously set origin, or NULL if none.
Definition at line 1910 of file editor.c.
Referenced by edit_buffer_paste().
Fill the supplied buffer with a translated string describing the edit buffer's current state. Returns the number of bytes used.
Definition at line 1870 of file editor.c.
Referenced by editinfobox_refresh().
bool edit_buffer_has_type | ( | const struct edit_buffer * | ebuf, |
int | type | ||
) |
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 1433 of file editor.c.
Referenced by editor_init().
Paste the entire contents of the edit buffer using 'dest' as the origin.
Definition at line 1735 of file editor.c.
Referenced by editor_apply_tool().
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 1898 of file editor.c.
Referenced by edit_buffer_clear(), edit_buffer_copy_square(), and editor_apply_tool_to_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 909 of file editor.c.
Referenced by editor_apply_tool_to_selection(), editor_mouse_button_press(), and editor_mouse_move().
Apply the current editor tool to all tiles in the current selection.
Definition at line 1128 of file editor.c.
Referenced by handle_edit_key_press(), and handle_edit_key_press().
Clear the editor data which is game dependent.
Definition at line 246 of file editor.c.
Referenced by set_client_state().
Draws the editor selection rectangle using draw_selection_rectangle().
Definition at line 780 of file editor.c.
Referenced by editor_resize_selection_rectangle().
Record and handle the end of the selection rectangle.
Definition at line 722 of file editor.c.
Referenced by editor_mouse_button_release().
struct edit_buffer * editor_get_copy_buffer | ( | void | ) |
Returns the copy buffer for the given tool.
Definition at line 1767 of file editor.c.
Referenced by editinfobox_refresh(), editor_apply_tool(), and editor_apply_tool_to_selection().
Get the tile that the user's mouse pointer is currently over.
Definition at line 1028 of file editor.c.
Referenced by editor_mouse_move().
struct sprite * editor_get_mode_sprite | ( | enum editor_tool_mode | etm | ) |
Returns the editor sprite corresponding to the tool mode.
Definition at line 1837 of file editor.c.
Referenced by editbar_add_mode_button(), and get_tool_mode_pixbuf().
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 1815 of file editor.c.
Referenced by editbar_add_mode_button().
Returns the "center" tile of a group of selected tiles, or NULL. 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 1934 of file editor.c.
Referenced by editor_apply_tool_to_selection().
enum editor_tool_type editor_get_tool | ( | void | ) |
Get the current tool used by the editor.
Definition at line 286 of file editor.c.
Referenced by editbar_mode_button_toggled(), editinfobox_handle_mode_image_button_press(), editinfobox_handle_mode_image_button_press(), editinfobox_handle_tool_image_button_press(), editinfobox_handle_tool_image_button_press(), editinfobox_refresh(), editinfobox_spin_button_value_changed(), editinfobox_tool_applied_player_changed(), editor_apply_tool(), editor_apply_tool_to_selection(), editor_grab_applied_player(), handle_edit_key_press(), handle_edit_key_press(), handle_edit_key_press_with_shift(), handle_edit_key_press_with_shift(), refresh_all_buttons(), and refresh_tool_applied_player_combo().
Set the editor's current applied player number according to what exists on the given tile.
Definition at line 465 of file editor.c.
Referenced by editor_mouse_button_press().
Set the editor's current tool according to what exists at the given tile.
Definition at line 497 of file editor.c.
Referenced by editor_mouse_button_press().
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 193 of file editor.c.
Referenced by default_tileset_select().
Returns TRUE if the client is in edit mode.
Definition at line 346 of file editor.c.
Referenced by butt_down_mapcanvas(), butt_release_mapcanvas(), editbar_refresh(), editgui_notify_object_changed(), editgui_notify_object_created(), editgui_refresh(), editinfobox_refresh(), fill_sprite_array(), handle_research_info(), handle_unknown_research(), left_butt_down_mapcanvas(), left_butt_up_mapcanvas(), middle_butt_down_mapcanvas(), move_mapcanvas(), move_mapcanvas(), put_one_tile(), real_menus_update(), refresh_tool_value_selector(), right_butt_down_mapcanvas(), right_butt_up_mapcanvas(), toplevel_key_press_handler(), toplevel_key_press_handler(), and toplevel_key_release_handler().
Handle a user's mouse button press at the given point on the map canvas.
Definition at line 661 of file editor.c.
Referenced by handle_edit_mouse_button_press(), and handle_edit_mouse_button_press().
Handle the release of a mouse button click.
Definition at line 798 of file editor.c.
Referenced by handle_edit_mouse_button_release(), and handle_edit_mouse_button_release().
Handle the mouse moving over the map canvas.
Definition at line 866 of file editor.c.
Referenced by handle_edit_mouse_move(), and handle_edit_mouse_move().
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 897 of file editor.c.
Referenced by editor_apply_tool_to_selection(), editor_mouse_button_press(), and editor_mouse_move().
Handle a change in the size of the selection rectangle. The given point is the new extremity of the rectangle.
Definition at line 826 of file editor.c.
Referenced by editor_mouse_move().
Adjust editor for changed ruleset.
Definition at line 180 of file editor.c.
Referenced by handle_rulesets_ready().
Add the given tile to the current selection.
Definition at line 1095 of file editor.c.
Referenced by editor_end_selection_rectangle().
Unselect all selected tiles.
Definition at line 1084 of file editor.c.
Referenced by editor_start_selection_rectangle().
Returns the number of currently selected tiles.
Definition at line 1388 of file editor.c.
Referenced by editor_apply_tool_to_selection(), and editor_start_selection_rectangle().
Remove the given tile from the current selection.
Definition at line 1106 of file editor.c.
Referenced by editor_end_selection_rectangle().
Sets the tile currently assumed to be under the user's mouse pointer.
Definition at line 1016 of file editor.c.
Referenced by editor_mouse_button_press(), editor_mouse_button_release(), and editor_mouse_move().
void editor_set_tool | ( | enum editor_tool_type | ett | ) |
Set the current tool to be used by the editor.
Definition at line 270 of file editor.c.
Referenced by editor_grab_tool(), handle_edit_key_press_with_shift(), handle_edit_key_press_with_shift(), and try_to_set_editor_tool().
Record the start of the selection rectangle.
Definition at line 422 of file editor.c.
Referenced by editor_mouse_button_press().
Returns TRUE if the given tile is selected.
Definition at line 1117 of file editor.c.
Referenced by fill_sprite_array(), popup_properties(), and put_one_tile().
void editor_tool_cycle_mode | ( | enum editor_tool_type | ett | ) |
Set the editor tool mode to the next available mode.
Definition at line 1058 of file editor.c.
Referenced by editinfobox_handle_mode_image_button_press(), and editinfobox_handle_mode_image_button_press().
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 NULL.
Definition at line 1341 of file editor.c.
Referenced by editor_apply_tool(), editor_unit_virtual_create(), property_page_create_objects(), and refresh_tool_applied_player_combo().
int editor_tool_get_count | ( | enum editor_tool_type | ett | ) |
Returns the 'count' parameter for the editor tool.
Definition at line 1252 of file editor.c.
Referenced by editinfobox_refresh(), editor_apply_tool(), handle_edit_key_press(), handle_edit_key_press(), and property_page_create_objects().
enum editor_tool_mode editor_tool_get_mode | ( | enum editor_tool_type | ett | ) |
Get the mode for the tool.
Definition at line 335 of file editor.c.
Referenced by editinfobox_refresh(), editor_apply_tool(), editor_apply_tool_to_selection(), editor_tool_cycle_mode(), editor_tool_toggle_mode(), and refresh_all_buttons().
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 1778 of file editor.c.
Referenced by editinfobox_refresh().
const char * editor_tool_get_name | ( | enum editor_tool_type | ett | ) |
Get the translated name of the given tool type.
Definition at line 1159 of file editor.c.
Referenced by create_tool_value_selector(), editinfobox_refresh(), and try_to_set_editor_tool().
int editor_tool_get_size | ( | enum editor_tool_type | ett | ) |
Returns the current size parameter for the given editor tools.
Definition at line 1218 of file editor.c.
Referenced by editinfobox_refresh(), editor_apply_tool(), handle_edit_key_press(), handle_edit_key_press(), and property_page_create_objects().
struct sprite * editor_tool_get_sprite | ( | enum editor_tool_type | ett | ) |
Returns a sprite containing an icon for the given tool type. Returns NULL if no such sprite exists.
Definition at line 1275 of file editor.c.
Referenced by editbar_add_tool_button(), and editinfobox_refresh().
const char * editor_tool_get_tooltip | ( | enum editor_tool_type | ett | ) |
Returns a translated "tooltip" description for the given tool type.
Definition at line 1327 of file editor.c.
Referenced by editbar_add_tool_button().
int editor_tool_get_value | ( | enum editor_tool_type | ett | ) |
Get the current tool sub-value.
Definition at line 409 of file editor.c.
Referenced by editinfobox_refresh(), editor_apply_tool(), editor_unit_virtual_create(), property_page_create_objects(), and refresh_tool_value_selector().
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 1172 of file editor.c.
Referenced by editinfobox_refresh().
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 1365 of file editor.c.
Referenced by editor_apply_tool(), and refresh_tool_applied_player_combo().
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 1241 of file editor.c.
Referenced by editinfobox_refresh(), handle_edit_key_press(), and handle_edit_key_press().
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 313 of file editor.c.
Referenced by editor_tool_cycle_mode(), editor_tool_set_mode(), editor_tool_toggle_mode(), and refresh_all_buttons().
bool editor_tool_has_size | ( | enum editor_tool_type | ett | ) |
Return TRUE if the given editor tool uses the 'size' parameter.
Definition at line 1207 of file editor.c.
Referenced by editinfobox_refresh(), handle_edit_key_press(), and handle_edit_key_press().
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 385 of file editor.c.
Referenced by editbar_add_tool_button(), editgui_run_tool_selection(), editor_grab_tool(), editor_tool_get_value(), editor_tool_set_value(), refresh_all_tool_value_selectors(), and refresh_tool_value_selector().
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 1377 of file editor.c.
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 359 of file editor.c.
Referenced by try_to_set_editor_tool().
void editor_tool_set_applied_player | ( | enum editor_tool_type | ett, |
int | player_no | ||
) |
Sets the editor tool's applied player number to the given value.
Definition at line 1352 of file editor.c.
Referenced by editinfobox_tool_applied_player_changed(), editor_grab_applied_player(), and refresh_tool_applied_player_combo().
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 1263 of file editor.c.
Referenced by editinfobox_spin_button_value_changed(), handle_edit_key_press(), and handle_edit_key_press().
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 298 of file editor.c.
Referenced by editbar_mode_button_toggled(), 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 1229 of file editor.c.
Referenced by editinfobox_spin_button_value_changed(), handle_edit_key_press(), and handle_edit_key_press().
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 397 of file editor.c.
Referenced by editgui_run_tool_selection(), and 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 1041 of file editor.c.
Referenced by handle_edit_key_press_with_shift(), and handle_edit_key_press_with_shift().
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 NULL 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 1405 of file editor.c.
Referenced by can_create_unit_at_tile().
|
static |
Helper function to fill in an edit packet with the tile's current values.
Definition at line 1607 of file editor.c.
Referenced by paste_tile().
|
static |
Helper function for edit_buffer_paste(). Do a single paste of the stuff set in the buffer on the virtual tile to the destination tile 'ptile_dest'.
Definition at line 1645 of file editor.c.
Referenced by edit_buffer_paste().
Handle a request to edit the properties for the given tile. If the tile is part of a selection, then all selected tiles are passed to the property editor.
Definition at line 631 of file editor.c.
Referenced by editor_mouse_button_press().
Temporary convenience function to work-around the fact that certain special values (S_RESOURCE_VALID) do not in fact correspond to drawable special types.
Definition at line 446 of file editor.c.
Referenced by editor_grab_tool().
|
static |
Set tool to some value legal under current ruleset.
Definition at line 105 of file editor.c.
Referenced by editor_ruleset_changed(), and tool_init().
|
static |
Definition at line 100 of file editor.c.
Referenced by add_global_worklist(), add_target_to_production(), add_target_to_worklist(), change_production(), create_and_append_worklist_page(), create_worklist(), editor_apply_tool(), editor_apply_tool_to_selection(), editor_clear(), editor_draw_selrect(), editor_end_selection_rectangle(), editor_free(), editor_get_copy_buffer(), editor_get_current_tile(), editor_get_selection_center(), editor_get_tool(), editor_grab_applied_player(), editor_grab_tool(), editor_init(), editor_mouse_button_press(), editor_mouse_button_release(), editor_mouse_move(), editor_resize_selection_rectangle(), editor_selection_add(), editor_selection_clear(), editor_selection_count(), editor_selection_remove(), editor_set_current_tile(), editor_set_tool(), editor_start_selection_rectangle(), editor_tile_is_selected(), editor_tool_get_applied_player(), editor_tool_get_count(), editor_tool_get_mode(), editor_tool_get_name(), editor_tool_get_size(), editor_tool_get_tooltip(), editor_tool_get_value(), editor_tool_get_value_name(), editor_tool_has_applied_player(), editor_tool_has_count(), editor_tool_has_mode(), editor_tool_has_size(), editor_tool_has_value(), editor_tool_has_value_erase(), editor_tool_is_usable(), editor_tool_set_applied_player(), editor_tool_set_count(), editor_tool_set_mode(), editor_tool_set_size(), editor_tool_set_value(), insert_worklist(), ok_worklist_editor_callback(), popdown_worklist_editor(), popup_properties(), popup_worklist(), popup_worklist_editor(), refresh_production_label(), refresh_worklist(), refresh_worklist_count_label(), remove_item_from_worklist(), rename_worklist_editor_callback(), reset_city_worklist(), reset_global_worklist(), set_global_worklist(), swap_item_down_from_worklist(), swap_item_up_from_worklist(), tool_init(), tool_set_init_value(), and worklist_editor_targets_callback().