24 using namespace std::chrono_literals;
46 if(event_name ==
"scrolled")
60 it->second->write_config(cfg);
83 auto time = std::chrono::steady_clock::now();
86 (*it).second->update(time,
disp_);
92 auto time = std::chrono::steady_clock::now();
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) {
210 return static_cast<int>((((distance -
range_)
222 cfg[
"full_range"] =
range_;
236 cfg[
"full_range"] =
range_;
243 , files_(cfg[
"sounds"])
246 , loops_(cfg[
"loop"].to_int())
247 , range_(cfg[
"full_range"].to_int(3))
248 , faderange_(cfg[
"fade_range"].to_int(14))
249 , check_fogged_(cfg[
"check_fogged"].to_bool(true))
250 , 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.
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.
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 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)
std::chrono::steady_clock::time_point last_played_
void update(const std::chrono::steady_clock::time_point &time, const display &disp)
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)
positional_source(const sourcespec &spec)
static unsigned int last_id
std::chrono::milliseconds min_delay_
void update_positions(const std::chrono::steady_clock::time_point &time, const display &disp)
void write(config &cfg) const
Serializes information into cfg as a new (appended) child of key "sound_source".
std::vector< map_location > locations_
sourcespec(const std::string &id, const std::string &files, const std::chrono::milliseconds &min_delay, int chance)
Parameter-list constructor.
std::chrono::milliseconds min_delay_
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.
auto parse_duration(const config_attribute_value &val, const Duration &def=Duration{0})
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
std::string::const_iterator iterator
Encapsulates the map of the game.