Freeciv21
Develop your civilization from humble roots to a global empire
editor.cpp File Reference
#include <QRect>
#include <QSet>
#include "bitvector.h"
#include "fcintl.h"
#include "log.h"
#include "support.h"
#include "game.h"
#include "map.h"
#include "packets.h"
#include "client_main.h"
#include "climap.h"
#include "control.h"
#include "editor.h"
#include "mapctrl_common.h"
#include "mapview_g.h"
#include "qtg_cxxside.h"
#include "tileset/tilespec.h"
#include "views/view_map_geometry.h"
+ Include dependency graph for editor.cpp:

Go to the source code of this file.

Classes

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
}
 

Functions

static void tool_set_init_value (enum editor_tool_type ett)
 Set tool to some value legal under current ruleset. More...
 
static void tool_init (enum editor_tool_type ett, const char *name, int flags, const char *tooltip)
 Initialize editor tool data. More...
 
void editor_ruleset_changed ()
 Adjust editor for changed ruleset. More...
 
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_set_tool (enum editor_tool_type ett)
 Set the current tool to be used by the editor. More...
 
enum editor_tool_type editor_get_tool ()
 Get the current tool used by the editor. More...
 
void editor_tool_set_mode (enum editor_tool_type ett, enum editor_tool_mode etm)
 Set the mode for the editor tool. 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...
 
bool editor_is_active ()
 Returns TRUE if the client is in edit mode. 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...
 
void editor_tool_set_value (enum editor_tool_type ett, int value)
 Set the value ID for the given tool. More...
 
int editor_tool_get_value (enum editor_tool_type ett)
 Get the current tool sub-value. More...
 
static void editor_start_selection_rectangle (int canvas_x, int canvas_y)
 Record the start of the selection rectangle. More...
 
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) do not in fact correspond to drawable special types. More...
 
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. More...
 
static void editor_grab_tool (const struct tile *ptile)
 Set the editor's current tool according to what exists at the given tile. More...
 
static bool can_edit_tile_properties (struct tile *ptile)
 Returns TRUE if the given tile has some objects with editable properties. More...
 
static void popup_properties (struct tile *ptile)
 Handle a request to edit the properties for the given tile. 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...
 
static void editor_end_selection_rectangle (int canvas_x, int canvas_y)
 Record and handle the end of the selection rectangle. More...
 
static void editor_draw_selrect ()
 Draws the editor selection rectangle using draw_selection_rectangle(). 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...
 
static void editor_resize_selection_rectangle (int canvas_x, int canvas_y)
 Handle a change in the size of the selection rectangle. More...
 
void editor_mouse_move (int canvas_x, int canvas_y, int modifiers)
 Handle the mouse moving over the map canvas. More...
 
void editor_notify_edit_finished ()
 Notify the server that a batch of edits has completed. 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_set_current_tile (const struct tile *ptile)
 Sets the tile currently assumed to be under the user's mouse pointer. More...
 
const struct tileeditor_get_current_tile ()
 Get the tile that the user's mouse pointer is currently over. 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...
 
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 char * editor_tool_get_name (enum editor_tool_type ett)
 Get the translated name of the given tool type. More...
 
const char * editor_tool_get_value_name (enum editor_tool_type emt, int value)
 Get the translated name of the given tool value. 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...
 
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...
 
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 ett, int player_no)
 Sets the editor tool's applied player number 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...
 
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...
 
struct uniteditor_unit_virtual_create ()
 Creates a virtual unit (like unit_virtual_create) based on the current editor state. More...
 
struct edit_bufferedit_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_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_copy (struct edit_buffer *ebuf, const struct tile *ptile)
 Append a single tile to the copy buffer. More...
 
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. More...
 
static void paste_tile (struct edit_buffer *ebuf, const struct tile *vtile, const struct tile *ptile_dest)
 Helper function for edit_buffer_paste(). 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...
 
struct edit_buffereditor_get_copy_buffer ()
 Returns the copy buffer for the given tool. 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...
 
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...
 
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...
 
void edit_buffer_set_origin (struct edit_buffer *ebuf, const struct tile *ptile)
 Set the "origin" for subsequent copy operations. More...
 
const struct tileedit_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...
 
const struct tileeditor_get_selection_center ()
 Returns the "center" tile of a group of selected tiles, or nullptr. More...
 

Variables

static struct editor_stateeditor = nullptr
 

Enumeration Type Documentation

◆ editor_tool_flags

Enumerator
ETF_NO_FLAGS 
ETF_HAS_VALUE 
ETF_HAS_SIZE 
ETF_HAS_COUNT 
ETF_HAS_APPLIED_PLAYER 
ETF_HAS_VALUE_ERASE 

Definition at line 44 of file editor.cpp.

◆ selection_modes

Enumerator
SELECTION_MODE_NEW 
SELECTION_MODE_ADD 
SELECTION_MODE_REMOVE 

Definition at line 38 of file editor.cpp.

Function Documentation

◆ can_edit_tile_properties()

static bool can_edit_tile_properties ( struct tile ptile)
inlinestatic

Returns TRUE if the given tile has some objects with editable properties.

Definition at line 619 of file editor.cpp.

Referenced by popup_properties().

◆ edit_buffer_clear()

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().

◆ edit_buffer_copy()

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().

◆ edit_buffer_copy_square()

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().

◆ edit_buffer_free()

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().

◆ edit_buffer_get_origin()

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().

◆ edit_buffer_get_status_string()

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.

◆ edit_buffer_has_type()

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.

◆ edit_buffer_new()

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().

◆ edit_buffer_paste()

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().

◆ edit_buffer_set_origin()

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().

◆ editor_apply_tool()

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().

◆ editor_apply_tool_to_selection()

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.

◆ editor_clear()

void editor_clear ( )

Clear the editor data which is game dependent.

Definition at line 236 of file editor.cpp.

Referenced by client_state().

◆ editor_draw_selrect()

static void editor_draw_selrect ( )
static

Draws the editor selection rectangle using draw_selection_rectangle().

Definition at line 776 of file editor.cpp.

Referenced by editor_resize_selection_rectangle().

◆ editor_end_selection_rectangle()

static void editor_end_selection_rectangle ( int  canvas_x,
int  canvas_y 
)
static

Record and handle the end of the selection rectangle.

Definition at line 719 of file editor.cpp.

Referenced by editor_mouse_button_release().

◆ editor_free()

void editor_free ( )

Free the client's editor.

Definition at line 247 of file editor.cpp.

Referenced by client_exit().

◆ editor_get_copy_buffer()

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().

◆ editor_get_current_tile()

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().

◆ editor_get_mode_sprite()

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.

◆ editor_get_mode_tooltip()

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.

◆ editor_get_selection_center()

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().

◆ editor_get_tool()

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().

◆ editor_grab_applied_player()

static void editor_grab_applied_player ( const struct tile ptile)
static

Set the editor's current applied player number according to what exists on the given tile.

Definition at line 453 of file editor.cpp.

Referenced by editor_mouse_button_press().

◆ editor_grab_tool()

static void editor_grab_tool ( const struct tile ptile)
static

Set the editor's current tool according to what exists at the given tile.

Definition at line 485 of file editor.cpp.

Referenced by editor_mouse_button_press().

◆ editor_init()

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().

◆ editor_is_active()

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().

◆ editor_mouse_button_press()

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.

◆ editor_mouse_button_release()

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.

◆ editor_mouse_move()

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.

◆ editor_notify_edit_finished()

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().

◆ editor_resize_selection_rectangle()

static void editor_resize_selection_rectangle ( int  canvas_x,
int  canvas_y 
)
static

Handle a change in the size of the selection rectangle.

The given point is the new extremity of the rectangle.

Definition at line 820 of file editor.cpp.

Referenced by editor_mouse_move().

◆ editor_ruleset_changed()

void editor_ruleset_changed ( )

Adjust editor for changed ruleset.

Definition at line 171 of file editor.cpp.

Referenced by handle_rulesets_ready().

◆ editor_selection_add()

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().

◆ editor_selection_clear()

void editor_selection_clear ( )

Unselect all selected tiles.

Definition at line 1076 of file editor.cpp.

Referenced by editor_start_selection_rectangle().

◆ editor_selection_remove()

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().

◆ editor_set_current_tile()

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().

◆ editor_set_tool()

void editor_set_tool ( enum editor_tool_type  ett)

Set the current tool to be used by the editor.

Definition at line 260 of file editor.cpp.

Referenced by editor_grab_tool().

◆ editor_start_selection_rectangle()

static void editor_start_selection_rectangle ( int  canvas_x,
int  canvas_y 
)
static

Record the start of the selection rectangle.

Definition at line 408 of file editor.cpp.

Referenced by editor_mouse_button_press().

◆ editor_tile_is_selected()

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().

◆ editor_tool_cycle_mode()

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.

◆ editor_tool_get_applied_player()

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().

◆ editor_tool_get_count()

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().

◆ editor_tool_get_mode()

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().

◆ editor_tool_get_mode_name()

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.

◆ editor_tool_get_name()

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.

◆ editor_tool_get_size()

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().

◆ editor_tool_get_sprite()

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.

◆ editor_tool_get_tooltip()

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.

◆ editor_tool_get_value()

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().

◆ editor_tool_get_value_name()

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.

◆ editor_tool_has_applied_player()

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().

◆ editor_tool_has_count()

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.

◆ editor_tool_has_mode()

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().

◆ editor_tool_has_size()

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.

◆ editor_tool_has_value()

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().

◆ editor_tool_has_value_erase()

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().

◆ editor_tool_is_usable()

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.

◆ editor_tool_set_applied_player()

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 1344 of file editor.cpp.

Referenced by editor_grab_applied_player().

◆ editor_tool_set_count()

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.

◆ editor_tool_set_mode()

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().

◆ editor_tool_set_size()

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.

◆ editor_tool_set_value()

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().

◆ editor_tool_toggle_mode()

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.

◆ editor_unit_virtual_create()

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.

◆ fill_tile_edit_packet()

static void fill_tile_edit_packet ( struct packet_edit_tile *  packet,
const struct tile ptile 
)
static

Helper function to fill in an edit packet with the tile's current values.

Definition at line 1598 of file editor.cpp.

Referenced by paste_tile().

◆ paste_tile()

static void paste_tile ( struct edit_buffer ebuf,
const struct tile vtile,
const struct tile ptile_dest 
)
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 1632 of file editor.cpp.

Referenced by edit_buffer_paste().

◆ popup_properties()

static void popup_properties ( struct tile ptile)
static

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 629 of file editor.cpp.

Referenced by editor_mouse_button_press().

◆ tile_really_has_any_specials()

static bool tile_really_has_any_specials ( const struct tile ptile)
inlinestatic

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 432 of file editor.cpp.

Referenced by editor_grab_tool().

◆ tool_init()

static void tool_init ( enum editor_tool_type  ett,
const char *  name,
int  flags,
const char *  tooltip 
)
static

Initialize editor tool data.

Definition at line 142 of file editor.cpp.

Referenced by editor_init().

◆ tool_set_init_value()

static void tool_set_init_value ( enum editor_tool_type  ett)
static

Set tool to some value legal under current ruleset.

Definition at line 96 of file editor.cpp.

Referenced by editor_ruleset_changed(), and tool_init().

Variable Documentation

◆ editor