129 if (first !=
nullptr) {
191 _(
"Change tile terrain.\nShortcut: t\n"
192 "Select terrain type: shift+t or right-click here."));
195 _(
"Change tile terrain resources.\nShortcut: r\n"
196 "Select resource type: shift+r or right-click here."));
199 _(
"Modify tile specials.\nShortcut: s\n"
200 "Select special type: shift+s or right-click here."));
203 _(
"Modify roads on tile.\nShortcut: p\n"
204 "Select road type: shift+p or right-click here."));
207 _(
"Create a military base.\nShortcut: m\n"
208 "Select base type: shift+m or right-click here."));
212 _(
"Create unit.\nShortcut: u\nSelect unit "
213 "type: shift+u or right-click here."));
215 _(
"Create city.\nShortcut: c"));
217 _(
"Modify player's tile knowledge.\nShortcut: v"));
219 _(
"Place a start position which allows any nation to "
220 "start at the tile. To allow only certain nations to "
221 "start there, middle click on the start position on "
222 "the map and use the property editor.\nShortcut: b"));
225 _(
"Copy and paste tiles.\n"
226 "Shortcut for copy mode: shift-c\n"
227 "Shoftcut for paste mode: shift-v"));
468 }
else if (unit_list_size(ptile->
units) > 0) {
469 struct unit *punit = unit_list_get(ptile->
units, 0);
487 int ett = -1, value = 0;
521 first_resource = pextra;
534 }
else if (unit_list_size(ptile->
units) > 0) {
535 int max_score = 0, score;
536 struct unit *grabbed_punit =
nullptr;
553 if (score > max_score) {
555 grabbed_punit = punit;
564 }
else if (first_base !=
nullptr) {
568 }
else if (first_road !=
nullptr) {
579 specials_array[count++] = s;
585 for (i = count - 1; i >= 0; i--) {
587 special = specials_array[i];
592 if (special !=
nullptr) {
621 return ptile !=
nullptr;
631 struct tile_list *tiles;
637 tiles = tile_list_new();
642 tile_list_append(tiles,
const_cast<tile *
>(sel_tile));
647 tile_list_append(tiles, ptile);
653 tile_list_destroy(tiles);
669 if (ptile ==
nullptr) {
695 }
else if (modifiers ==
EKM_ALT) {
753 if (!it.has_tile()) {
843 if (xl == xr || yt == yb) {
863 const struct tile *ptile, *old;
908 int value,
size, count, apno,
tile, id;
912 if (
editor ==
nullptr || ptile ==
nullptr) {
938 if (part_of_selection) {
951 if (part_of_selection && ett !=
ETT_CITY) {
960 dsend_packet_edit_tile_terrain(my_conn,
tile, erase ? 0 : value,
size);
967 dsend_packet_edit_tile_extra(my_conn,
tile, value, erase, apno,
size);
972 dsend_packet_edit_unit_remove(my_conn, apno,
tile, value, count);
974 dsend_packet_edit_unit_create(my_conn, apno,
tile, value, count, 0);
981 if (pcity !=
nullptr) {
983 dsend_packet_edit_city_remove(my_conn,
id);
986 dsend_packet_edit_city_create(my_conn, apno,
tile,
size, 0);
993 dsend_packet_edit_player_vision(my_conn,
id,
tile, !erase,
size);
998 dsend_packet_edit_startpos(my_conn,
tile, erase, 0);
1294 return sprites->
road;
1298 return sprites->
unit;
1301 return sprites->
city;
1423 ebuf->
vtiles = tile_list_new();
1440 tile_list_destroy(ebuf->
vtiles);
1451 if (!ebuf || !ebuf->
vtiles) {
1457 tile_list_clear(ebuf->
vtiles);
1467 const struct tile *center,
int radius)
1469 if (!ebuf || !center || radius < 1) {
1488 bool copied =
false;
1490 if (!ebuf || !ptile) {
1554 vunit->
hp = punit->hp;
1555 unit_list_append(vtile->
units, vunit);
1562 struct city *pcity, *vcity;
1589 tile_list_append(ebuf->
vtiles, vtile);
1599 const struct tile *ptile)
1602 const struct terrain *pterrain;
1604 if (!packet || !ptile) {
1621 if (ptile->
label ==
nullptr) {
1622 packet->label[0] =
'\0';
1633 const struct tile *ptile_dest)
1636 struct packet_edit_tile tile_packet;
1639 bool send_edit_tile =
false;
1641 if (!ebuf || !vtile || !ptile_dest) {
1657 dsend_packet_edit_tile_terrain(my_conn,
tile, value, 1);
1664 send_edit_tile =
true;
1675 send_edit_tile =
true;
1686 send_edit_tile =
true;
1697 send_edit_tile =
true;
1707 dsend_packet_edit_unit_create(my_conn,
owner,
tile, value, 1, 0);
1718 dsend_packet_edit_city_create(my_conn,
owner,
tile, value, 0);
1726 if (send_edit_tile) {
1727 send_packet_edit_tile(my_conn, &tile_packet);
1737 const struct tile *origin, *ptile;
1740 if (!ebuf || !dest) {
1792 return _(
"Erase Value");
1804 qCritical(
"Unrecognized editor tool mode %d "
1805 "in editor_tool_get_mode_name().",
1821 return _(
"Toggle erase mode.\nShortcut: shift-d");
1824 return _(
"Toggle copy mode.\nShortcut: shift-c");
1827 return _(
"Toggle paste mode.\nShortcut: shift-v");
1850 return sprites->
brush;
1853 return sprites->
erase;
1856 return sprites->
copy;
1859 return sprites->
paste;
1878 if (!buf || buflen < 1) {
1882 ret =
fc_strlcpy(buf,
_(
"Buffer empty."), buflen);
1883 if (!ebuf || !ebuf->
vtiles) {
1887 total = tile_list_size(ebuf->
vtiles);
1889 fmt =
PL_(
"%d tile copied.",
"%d tiles copied.", total);
1901 const struct tile *ptile)
1939 const struct tile *origin, *center;
1941 int xsum = 0, ysum = 0;
Base_type_id base_count()
Return the number of base_types.
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Return TRUE iff the city has this building in it.
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
void city_size_set(struct city *pcity, citizens size)
Set the city size.
void city_add_improvement(struct city *pcity, const struct impr_type *pimprove)
Adds an improvement (and its effects) to a city.
struct city * create_city_virtual(struct player *pplayer, struct tile *ptile, const char *name)
Create virtual skeleton for a city.
citizens city_size_get(const struct city *pcity)
Get the city size.
Iterates over all map tiles that intersect with a rectangle in GUI coordinates.
bool next()
Iterates to the next item.
int client_player_number()
Returns number of player attached to client.
bool client_has_player()
Either controlling or observing.
bool client_is_global_observer()
Returns whether client is global observer.
struct player * client_player()
Either controlling or observing.
bool can_conn_edit(const struct connection *pconn)
Return TRUE iff the connection is currently allowed to edit.
void connection_do_buffer(struct connection *pc)
Turn on buffering, using a counter so that calls may be nested.
void connection_do_unbuffer(struct connection *pc)
Turn off buffering if internal counter of number of times buffering was turned on falls to zero,...
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.
void editor_selection_remove(const struct tile *ptile)
Remove the given tile from the current selection.
const struct tile * editor_get_current_tile()
Get the tile that the user's mouse pointer is currently over.
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.
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.
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 th...
int editor_tool_get_size(enum editor_tool_type ett)
Returns the current size parameter for the given editor tools.
static void paste_tile(struct edit_buffer *ebuf, const struct tile *vtile, const struct tile *ptile_dest)
Helper function for edit_buffer_paste().
void editor_set_tool(enum editor_tool_type ett)
Set the current tool to be used by the editor.
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.
void editor_set_current_tile(const struct tile *ptile)
Sets the tile currently assumed to be under the user's mouse pointer.
void editor_mouse_move(int canvas_x, int canvas_y, int modifiers)
Handle the mouse moving over the map canvas.
enum editor_tool_mode editor_tool_get_mode(enum editor_tool_type ett)
Get the mode for the tool.
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...
void editor_tool_set_count(enum editor_tool_type ett, int count)
Sets the 'count' parameter of the tool to the given value.
struct edit_buffer * editor_get_copy_buffer()
Returns the copy buffer for the given 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 t...
static void tool_init(enum editor_tool_type ett, const char *name, int flags, const char *tooltip)
Initialize editor tool data.
void editor_selection_add(const struct tile *ptile)
Add the given tile to the current selection.
int editor_tool_get_value(enum editor_tool_type ett)
Get the current tool sub-value.
static void editor_end_selection_rectangle(int canvas_x, int canvas_y)
Record and handle the end of the selection rectangle.
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.
void editor_tool_cycle_mode(enum editor_tool_type ett)
Set the editor tool mode to the next available mode.
static void editor_grab_applied_player(const struct tile *ptile)
Set the editor's current applied player number according to what exists on the given tile.
void editor_free()
Free the client's editor.
void editor_ruleset_changed()
Adjust editor for changed ruleset.
int editor_tool_get_count(enum editor_tool_type ett)
Returns the 'count' parameter for the editor tool.
void edit_buffer_copy(struct edit_buffer *ebuf, const struct tile *ptile)
Append a single tile to the copy buffer.
void editor_tool_set_size(enum editor_tool_type ett, int size)
Sets the size parameter for the given tool.
const char * editor_tool_get_tooltip(enum editor_tool_type ett)
Returns a translated "tooltip" description for the given tool type.
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.
void editor_init()
Initialize the client's editor state information to some suitable default values.
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.
const struct tile * edit_buffer_get_origin(const struct edit_buffer *ebuf)
Return the previously set origin, or nullptr if none.
void editor_notify_edit_finished()
Notify the server that a batch of edits has completed.
bool editor_tool_has_size(enum editor_tool_type ett)
Return TRUE if the given editor tool uses the 'size' parameter.
void edit_buffer_clear(struct edit_buffer *ebuf)
Remove all copy data stored in the edit buffer.
void editor_clear()
Clear the editor data which is game dependent.
QPixmap * editor_get_mode_sprite(enum editor_tool_mode etm)
Returns the editor sprite corresponding to the tool mode.
void editor_tool_set_value(enum editor_tool_type ett, int value)
Set the value ID for the given tool.
bool editor_tool_has_value(enum editor_tool_type ett)
Returns TRUE if the given tool type has sub-values (e.g.
static void popup_properties(struct tile *ptile)
Handle a request to edit the properties for the given tile.
void editor_mouse_button_release(int canvas_x, int canvas_y, int button, int modifiers)
Handle the release of a mouse button click.
const char * editor_tool_get_name(enum editor_tool_type ett)
Get the translated name of the given tool type.
static void editor_grab_tool(const struct tile *ptile)
Set the editor's current tool according to what exists at the given tile.
enum editor_tool_type editor_get_tool()
Get the current tool used by the editor.
static bool tile_really_has_any_specials(const struct tile *ptile)
Temporary convenience function to work-around the fact that certain special values (S_RESOURCE_VALID)...
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.
static void editor_start_selection_rectangle(int canvas_x, int canvas_y)
Record the start of the selection rectangle.
static void editor_draw_selrect()
Draws the editor selection rectangle using draw_selection_rectangle().
void editor_apply_tool_to_selection()
Apply the current editor tool to all tiles in the current selection.
void editor_apply_tool(const struct tile *ptile, bool part_of_selection)
Apply the current editor tool to the given tile.
bool editor_tile_is_selected(const struct tile *ptile)
Returns TRUE if the given tile is selected.
void edit_buffer_set_origin(struct edit_buffer *ebuf, const struct tile *ptile)
Set the "origin" for subsequent copy operations.
bool editor_is_active()
Returns TRUE if the client is in edit mode.
const char * editor_tool_get_value_name(enum editor_tool_type emt, int value)
Get the translated name of the given tool value.
static bool can_edit_tile_properties(struct tile *ptile)
Returns TRUE if the given tile has some objects with editable properties.
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.
const struct tile * editor_get_selection_center()
Returns the "center" tile of a group of selected tiles, or nullptr.
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.
int editor_tool_get_applied_player(enum editor_tool_type ett)
Returns the current applied player number for the editor tool.
void editor_selection_clear()
Unselect all selected tiles.
struct edit_buffer * edit_buffer_new(int type_flags)
Create a new edit buffer corresponding to all types set in 'type_flags'.
struct unit * editor_unit_virtual_create()
Creates a virtual unit (like unit_virtual_create) based on the current editor state.
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.
static void editor_resize_selection_rectangle(int canvas_x, int canvas_y)
Handle a change in the size of the selection rectangle.
static void fill_tile_edit_packet(struct packet_edit_tile *packet, const struct tile *ptile)
Helper function to fill in an edit packet with the tile's current values.
static void tool_set_init_value(enum editor_tool_type ett)
Set tool to some value legal under current ruleset.
static struct editor_state * editor
void edit_buffer_free(struct edit_buffer *ebuf)
Free all memory allocated for the edit buffer.
QPixmap * editor_tool_get_sprite(enum editor_tool_type ett)
Returns a sprite containing an icon for the given tool type.
void editor_tool_set_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Set the mode for the editor tool.
#define edit_buffer_type_iterate_end
#define edit_buffer_type_iterate(ARG_ebuf, NAME_type)
#define PL_(String1, String2, n)
void editgui_popup_properties(const struct tile_list *tiles, int objtype)
Stub for editor function.
void editgui_refresh()
Stub for editor function.
bool is_improvement(const struct impr_type *pimprove)
Is this building a regular improvement?
#define improvement_iterate_end
#define improvement_iterate(_p)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Return the tile for the given cartesian (map) position.
void map_distance_vector(int *dx, int *dy, const struct tile *tile0, const struct tile *tile1)
Topology function to find the vector which has the minimum "real" distance between the map positions ...
#define square_iterate(nmap, center_tile, radius, tile_itr)
#define square_iterate_end
#define MAP_TILE_OWNER_NULL
#define index_to_map_pos(pmap_x, pmap_y, mindex)
void recenter_button_pressed(int canvas_x, int canvas_y)
Recenter the map on the canvas location, on user request.
void flush_dirty(void)
Flush all regions that have been previously marked as dirty.
void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
Area Selection.
struct player * player_by_number(const int player_id)
Return struct player pointer for the given player index.
int player_number(const struct player *pplayer)
Return the player index/number/id.
Road_type_id road_count()
Return the number of road_types.
struct packet_ruleset_control control
const struct tile * origin
struct tile_list * vtiles
QPixmap * terrain_resource
QPixmap * terrain_special
enum selection_modes selection_mode
struct editor_tool tools[NUM_EDITOR_TOOL_TYPES]
struct edit_buffer * copybuf
QSet< const struct tile * > * selected_tile_table
enum editor_tool_type tool
const struct tile * current_tile
struct player * extras_owner
struct veteran_system * veteran
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
size_t fc_strlcpy(char *dest, const char *src, size_t n)
fc_strlcpy() provides utf-8 version of (non-standard) function strlcpy() It is intended as more user-...
#define sz_strlcpy(dest, src)
Terrain_type_id terrain_count()
Return the number of terrains.
struct terrain * terrain_by_number(const Terrain_type_id type)
Return the terrain for the given terrain index.
const char * terrain_name_translation(const struct terrain *pterrain)
Return the (translated) name of the terrain.
Terrain_type_id terrain_number(const struct terrain *pterrain)
Return the terrain index.
void tile_add_extra(struct tile *ptile, const struct extra_type *pextra)
Adds extra to tile.
void tile_set_terrain(struct tile *ptile, struct terrain *pterrain)
Set the given terrain at the specified tile.
void tile_virtual_destroy(struct tile *vtile)
Frees all memory used by the virtual tile, including freeing virtual units in the tile's unit list an...
void tile_set_resource(struct tile *ptile, struct extra_type *presource)
Set the given resource at the specified tile.
enum known_type tile_get_known(const struct tile *ptile, const struct player *pplayer)
Return a known_type enumeration value for the tile.
void tile_set_worked(struct tile *ptile, struct city *pcity)
Set the city/worker on the tile (may be nullptr).
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
struct tile * tile_virtual_new(const struct tile *ptile)
Returns a virtual tile.
#define tile_resource(_tile)
#define tile_list_iterate(tile_list, ptile)
#define tile_terrain(_tile)
#define tile_list_iterate_end
static const bv_extras * tile_extras(const struct tile *ptile)
#define tile_has_extra(ptile, pextra)
#define tile_owner(_tile)
int tileset_tile_height(const struct tileset *t)
Return the tile height of the current tileset.
int tileset_tile_width(const struct tileset *t)
Return the tile width of the current tileset.
const struct editor_sprites * get_editor_sprites(const struct tileset *t)
Return all the sprites used for editor icons, images, etc.
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Create a virtual unit skeleton.
bool unit_transported(const struct unit *pcargo)
Returns TRUE iff the unit is transported.
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
struct unit_type * utype_by_number(const Unit_type_id id)
Return a pointer for the unit type struct for the given unit type id.
enum unit_move_type utype_move_type(const struct unit_type *punittype)
Return move type of the unit type.
Unit_type_id utype_count()
Return the number of unit types.
struct unit_class * unit_class_get(const struct unit *punit)
Returns unit class pointer for a unit.
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
Unit_type_id utype_number(const struct unit_type *punittype)
Return the unit type index.
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
struct tile * canvas_pos_to_tile(float canvas_x, float canvas_y)
Finds the tile corresponding to pixel coordinates.
void refresh_tile_mapcanvas(const tile *ptile, bool full_refresh)
Refreshes a single tile on the map canvas.
void update_map_canvas(int canvas_x, int canvas_y, int width, int height)
Update (refresh) the map canvas starting at the given tile (in map coordinates) and with the given di...
void update_map_canvas_visible()
Schedules an update of (only) the visible part of the map at the next unqueue_mapview_update().