21 #include <SDL2/SDL_timer.h>
46 if(event_name ==
"scrolled")
60 it->second->write_config(cfg);
83 unsigned int time = SDL_GetTicks();
86 (*it).second->update(time,
disp_);
92 unsigned int time = SDL_GetTicks();
95 (*it).second->update_positions(time,
disp_);
105 child[
"id"] =
i->first;
106 i->second->write_config(child);
112 min_delay_(spec.minimum_delay()),
113 chance_(spec.chance()),
114 loops_(spec.loops()),
116 range_(spec.full_range()),
117 faderange_(spec.fade_range()),
118 check_fogged_(spec.check_fogged()),
119 check_shrouded_(spec.check_shrouded()),
120 files_(spec.files()),
121 locations_(spec.get_locations())
157 if(v < distance_volume) {
178 if(v < distance_volume) {
206 return static_cast<int>((((distance -
range_)
218 cfg[
"full_range"] =
range_;
232 cfg[
"full_range"] =
range_;
239 files_(cfg[
"sounds"]),
243 range_(cfg[
"full_range"].to_int(3)),
244 faderange_(cfg[
"fade_range"].to_int(14)),
245 check_fogged_(cfg[
"check_fogged"].to_bool(true)),
246 check_shrouded_(cfg[
"check_shrouded"].to_bool(true)),
A config object defines a single node in a WML file, with access to child nodes.
config & add_child(config_key_type key)
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
const map_location hex_clicked_on(int x, int y) const
given x,y co-ordinates of an onscreen pixel, will return the location of the hex that this pixel corr...
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
events::generic_event & scroll_event() const
Expose the event, so observers can be notified about map scrolling.
rect map_area() const
Returns the area used for the map.
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
virtual bool attach_handler(observer *obs)
static rng & default_instance()
int get_random_int(int min, int max)
void handle_generic_event(const std::string &event_name)
sourcespec get(const std::string &id)
positional_source_map sources_
positional_source_map::iterator positional_source_iterator
manager(const display &disp)
void write_sourcespecs(config &cfg) const
Serializes information into cfg as new children of key "sound_source", appended to existing content.
void add(const sourcespec &source)
positional_source_map::const_iterator positional_source_const_iterator
bool contains(const std::string &id)
void remove(const std::string &id)
unsigned int last_played_
void write_config(config &cfg) const
Serializes attributes as WML config.
std::vector< map_location > locations_
int calculate_volume(const map_location &loc, const display &disp)
void update(unsigned int time, const display &disp)
void update_positions(unsigned int time, const display &disp)
positional_source(const sourcespec &spec)
static unsigned int last_id
sourcespec(const std::string &id, const std::string &files, int min_delay, int chance)
Parameter-list constructor.
void write(config &cfg) const
Serializes information into cfg as a new (appended) child of key "sound_source".
std::vector< map_location > locations_
const std::string & id() const
map_display and display: classes which take care of displaying the map and game-data on the screen.
std::size_t distance_between(const map_location &a, const map_location &b)
Function which gives the number of hexes between two tiles (i.e.
void write_locations(const std::vector< map_location > &locs, config &cfg)
Write a vector of locations into a config adding keys x=x1,x2,..,xn and y=y1,y2,.....
void read_locations(const config &cfg, std::vector< map_location > &locs)
Parse x,y keys of a config into a vector of locations.
void play_sound_positioned(const std::string &files, int id, int repeats, unsigned int distance)
bool is_sound_playing(int id)
void reposition_sound(int id, unsigned int distance)
const unsigned DEFAULT_CHANCE
const unsigned DEFAULT_DELAY
std::string::const_iterator iterator
Encapsulates the map of the game.