28 #define ERR_ARR LOG_STREAM(err, log_arrows) 29 #define WRN_ARR LOG_STREAM(warn, log_arrows) 30 #define LOG_ARR LOG_STREAM(info, log_arrows) 31 #define DBG_ARR LOG_STREAM(debug, log_arrows) 36 , style_(STYLE_STANDARD)
60 disp->remove_arrow(*
this);
72 disp->add_arrow(*
this);
152 return (path.size() >= 2);
159 WRN_ARR <<
"arrow::update_symbols called with invalid path";
166 const std::string mods =
"~RC(FF00FF>"+
color_ +
")";
168 const std::string dirname =
"arrows/";
169 std::string prefix =
"";
170 std::string suffix =
"";
171 std::string image_filename =
"";
172 arrow_path_t::const_iterator
const arrow_start_hex =
path_.begin();
173 arrow_path_t::const_iterator
const arrow_pre_end_hex =
path_.end() - 2;
174 arrow_path_t::const_iterator
const arrow_end_hex =
path_.end() - 1;
175 bool teleport_out =
false;
178 for (hex =
path_.begin(); hex !=
path_.end(); ++hex)
184 bool pre_end =
false;
188 bool teleport_in = teleport_out;
189 teleport_out =
false;
192 if (hex == arrow_start_hex)
194 if (hex == arrow_pre_end_hex)
196 else if (hex == arrow_end_hex)
203 if (!start && !teleport_in)
205 enter_dir = hex->get_relative_dir(*(hex-1));
208 if (!end && !teleport_out)
210 exit_dir = hex->get_relative_dir(*(hex+1));
216 prefix =
"teleport-out";
222 else if (teleport_in)
224 prefix =
"teleport-in";
236 suffix = suffix +
"_ending";
246 std::string enter, exit;
251 exit = exit +
"_ending";
254 assert(std::abs(enter_dir - exit_dir) > 1);
255 if (enter_dir < exit_dir)
267 image_filename = dirname +
style_ +
"/" + prefix;
270 image_filename += (
"-" + suffix);
272 image_filename +=
".png";
273 assert(!image_filename.empty());
276 if (!image.file_exists())
278 ERR_ARR <<
"Image " << image_filename <<
" not found.";
289 disp->invalidate(loc);
297 disp->update_arrow(*
this);
Drawing functions, for drawing things on the screen.
static void invalidate_arrow_path(const arrow_path_t &path)
Invalidates every hex along the given path.
std::string style_
represents the subdirectory that holds images for this arrow style
virtual void notify_arrow_changed()
Arrows destined to be drawn on the map.
static display * get_singleton()
Returns the display object if a display object exists.
void hide()
Sets the arrow's visibility.
const arrow_path_t & get_path() const
static rect scaled_to_zoom(const SDL_Rect &r)
Scale the width and height of a rect by the current zoom factor.
bool path_contains(const map_location &hex) const
virtual void draw_hex(const map_location &hex)
arrow_symbols_map_t symbols_map_
virtual void set_path(const arrow_path_t &path)
std::vector< map_location > arrow_path_t
arrow(const arrow &)=delete
bool contains(const Container &container, const Value &value)
Returns true iff value is found in container.
static const std::string STYLE_HIGHLIGHTED
static const std::string STYLE_FOCUS
const arrow_path_t & get_previous_path() const
void drawing_buffer_add(const drawing_layer layer, const map_location &loc, decltype(draw_helper::do_draw) draw_func)
Add an item to the drawing buffer.
EXIT_STATUS start(const std::string &filename, bool take_screenshot, const std::string &screenshot_filename)
Main interface for launching the editor from the title screen.
display::drawing_layer layer_
virtual void update_symbols()
Calculate the symbols to place along the arrow path.
static const std::string STYLE_FOCUS_INVALID
Generic locator abstracting the location of an image.
Encapsulates the map of the game.
bool tiles_adjacent(const map_location &a, const map_location &b)
Function which tells if two locations are adjacent.
virtual void reset()
invalidates and clears the present path, forgets the previous path, clears the symbols map ...
virtual void set_color(const std::string &color)
The string color parameter is in the same format expected by the image::locator modifiers parameter...
An abstract description of a rectangle with integer coordinates.
DIRECTION
Valid directions which can be moved in our hexagonal world.
void blit(const texture &tex, const SDL_Rect &dst)
Draws a texture, or part of a texture, at the given location.
Functions to load and save images from/to disk.
static lg::log_domain log_arrows("arrows")
Standard logging facilities (interface).
static const std::string STYLE_STANDARD
If you add more styles, you should look at move::update_arrow_style()
void set_style(const std::string &style)
texture get_texture(const image::locator &i_locator, TYPE type, bool skip_cache)
Returns an image texture suitable for hardware-accelerated rendering.
static bool valid_path(const arrow_path_t &path)
Checks that the path is not of length 0 or 1.
static std::string write_direction(DIRECTION dir)
std::string::const_iterator iterator
arrow_path_t previous_path_