The Battle for Wesnoth  1.19.7+dev
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
arrow Class Reference

Arrows destined to be drawn on the map. More...

#include <arrow.hpp>

Public Member Functions

 arrow (const arrow &)=delete
 
arrowoperator= (const arrow &)=delete
 
 arrow (bool hidden=false)
 
 ~arrow ()
 
void hide ()
 Sets the arrow's visibility. More...
 
void show ()
 
void set_path (const arrow_path_t &path)
 
void reset ()
 invalidates and clears the present path, forgets the previous path, clears the symbols map More...
 
void set_color (const std::string &color)
 The string color parameter is in the same format expected by the image::locator modifiers parameter. More...
 
std::string get_color () const
 
std::string get_style () const
 The style is simply the name of a subdirectory under images/arrows, that holds an alternate copy of the arrow graphics. More...
 
void set_style (const std::string &style)
 
const arrow_path_tget_path () const
 
const arrow_path_tget_previous_path () const
 
bool path_contains (const map_location &hex) const
 
image::locator get_image_for_loc (const map_location &hex) const
 
void notify_arrow_changed ()
 

Static Public Member Functions

static bool valid_path (const arrow_path_t &path)
 Checks that the path is not of length 0 or 1. More...
 
static void invalidate_arrow_path (const arrow_path_t &path)
 Invalidates every hex along the given path. More...
 

Static Public Attributes

static const std::string STYLE_STANDARD = "standard"
 If you add more styles, you should look at move::update_arrow_style() More...
 
static const std::string STYLE_HIGHLIGHTED = "highlighted"
 
static const std::string STYLE_FOCUS = "focus"
 
static const std::string STYLE_FOCUS_INVALID = "focus_invalid"
 

Private Types

typedef std::map< map_location, image::locatorarrow_symbols_map_t
 

Private Member Functions

void update_symbols ()
 Calculate the symbols to place along the arrow path. More...
 

Private Attributes

std::string color_
 
std::string style_
 represents the subdirectory that holds images for this arrow style More...
 
arrow_path_t path_
 
arrow_path_t previous_path_
 
arrow_symbols_map_t symbols_map_
 
bool hidden_
 

Detailed Description

Arrows destined to be drawn on the map.

Created for the whiteboard system.

Definition at line 30 of file arrow.hpp.

Member Typedef Documentation

◆ arrow_symbols_map_t

Definition at line 101 of file arrow.hpp.

Constructor & Destructor Documentation

◆ arrow() [1/2]

arrow::arrow ( const arrow )
delete

◆ arrow() [2/2]

arrow::arrow ( bool  hidden = false)
explicit

Definition at line 32 of file arrow.cpp.

References show().

◆ ~arrow()

arrow::~arrow ( )

Definition at line 44 of file arrow.cpp.

References hide().

Member Function Documentation

◆ get_color()

std::string arrow::get_color ( ) const
inline

Definition at line 56 of file arrow.hpp.

References color_.

◆ get_image_for_loc()

image::locator arrow::get_image_for_loc ( const map_location hex) const

Definition at line 138 of file arrow.cpp.

References symbols_map_.

Referenced by display::draw_hex().

◆ get_path()

const arrow_path_t & arrow::get_path ( ) const

Definition at line 122 of file arrow.cpp.

References path_.

Referenced by display::add_arrow(), display::remove_arrow(), and display::update_arrow().

◆ get_previous_path()

const arrow_path_t & arrow::get_previous_path ( ) const

Definition at line 127 of file arrow.cpp.

References previous_path_.

Referenced by display::update_arrow().

◆ get_style()

std::string arrow::get_style ( ) const
inline

The style is simply the name of a subdirectory under images/arrows, that holds an alternate copy of the arrow graphics.

If it doesn't exist or has missing images, you'll get "under construction" symbols instead of arrow graphics.

Definition at line 64 of file arrow.hpp.

References style_.

◆ hide()

void arrow::hide ( )

Sets the arrow's visibility.

Definition at line 49 of file arrow.cpp.

References display::get_singleton(), hidden_, invalidate_arrow_path(), and path_.

Referenced by ~arrow().

◆ invalidate_arrow_path()

void arrow::invalidate_arrow_path ( const arrow_path_t path)
static

Invalidates every hex along the given path.

Definition at line 282 of file arrow.cpp.

References display::get_singleton(), loc, and game_config::path.

Referenced by hide(), reset(), set_path(), and update_symbols().

◆ notify_arrow_changed()

void arrow::notify_arrow_changed ( )

Definition at line 291 of file arrow.cpp.

References display::get_singleton().

Referenced by reset(), and set_path().

◆ operator=()

arrow& arrow::operator= ( const arrow )
delete

◆ path_contains()

bool arrow::path_contains ( const map_location hex) const

Definition at line 132 of file arrow.cpp.

References utils::contains(), and symbols_map_.

◆ reset()

void arrow::reset ( )

invalidates and clears the present path, forgets the previous path, clears the symbols map

Definition at line 89 of file arrow.cpp.

References invalidate_arrow_path(), notify_arrow_changed(), path_, previous_path_, and symbols_map_.

◆ set_color()

void arrow::set_color ( const std::string &  color)

The string color parameter is in the same format expected by the image::locator modifiers parameter.

Examples: red is "red" or "FF0000" or "255,0,0". Feel free to add another method that accepts an uint32_t as a parameter instead.

Definition at line 99 of file arrow.cpp.

References color_, path_, update_symbols(), and valid_path().

◆ set_path()

void arrow::set_path ( const arrow_path_t path)

◆ set_style()

void arrow::set_style ( const std::string &  style)

Definition at line 113 of file arrow.cpp.

References path_, style_, update_symbols(), and valid_path().

◆ show()

void arrow::show ( )

Definition at line 62 of file arrow.cpp.

References display::get_singleton(), and hidden_.

Referenced by arrow().

◆ update_symbols()

void arrow::update_symbols ( )
private

Calculate the symbols to place along the arrow path.

Invalidates every hex along the path.

Definition at line 152 of file arrow.cpp.

References color_, ERR_ARR, image::exists(), map_location::indeterminate, invalidate_arrow_path(), game_config::images::missing, path_, editor::start(), style_, symbols_map_, tiles_adjacent(), valid_path(), map_location::write_direction(), and WRN_ARR.

Referenced by set_color(), set_path(), and set_style().

◆ valid_path()

bool arrow::valid_path ( const arrow_path_t path)
static

Checks that the path is not of length 0 or 1.

Definition at line 147 of file arrow.cpp.

References game_config::path.

Referenced by wb::manager::save_temp_move(), set_color(), set_path(), set_style(), and update_symbols().

Member Data Documentation

◆ color_

std::string arrow::color_
private

Definition at line 94 of file arrow.hpp.

Referenced by get_color(), set_color(), and update_symbols().

◆ hidden_

bool arrow::hidden_
private

Definition at line 104 of file arrow.hpp.

Referenced by hide(), set_path(), and show().

◆ path_

arrow_path_t arrow::path_
private

Definition at line 98 of file arrow.hpp.

Referenced by get_path(), hide(), reset(), set_color(), set_path(), set_style(), and update_symbols().

◆ previous_path_

arrow_path_t arrow::previous_path_
private

Definition at line 99 of file arrow.hpp.

Referenced by get_previous_path(), reset(), and set_path().

◆ style_

std::string arrow::style_
private

represents the subdirectory that holds images for this arrow style

Definition at line 96 of file arrow.hpp.

Referenced by get_style(), set_style(), and update_symbols().

◆ STYLE_FOCUS

const std::string arrow::STYLE_FOCUS = "focus"
static

Definition at line 69 of file arrow.hpp.

Referenced by wb::move::init(), and wb::move::update_arrow_style().

◆ STYLE_FOCUS_INVALID

const std::string arrow::STYLE_FOCUS_INVALID = "focus_invalid"
static

Definition at line 70 of file arrow.hpp.

Referenced by wb::move::init(), and wb::move::update_arrow_style().

◆ STYLE_HIGHLIGHTED

const std::string arrow::STYLE_HIGHLIGHTED = "highlighted"
static

◆ STYLE_STANDARD

const std::string arrow::STYLE_STANDARD = "standard"
static

If you add more styles, you should look at move::update_arrow_style()

Definition at line 67 of file arrow.hpp.

Referenced by wb::move::init(), wb::move::move(), and wb::move::update_arrow_style().

◆ symbols_map_

arrow_symbols_map_t arrow::symbols_map_
private

Definition at line 102 of file arrow.hpp.

Referenced by get_image_for_loc(), path_contains(), reset(), and update_symbols().


The documentation for this class was generated from the following files: