53 if(event_name ==
"scrolled")
74 it->second->write_config(cfg);
93 unsigned int time = SDL_GetTicks();
96 (*it).second->update(time,
disp_);
102 unsigned int time = SDL_GetTicks();
105 (*it).second->update_positions(time,
disp_);
115 child[
"id"] =
i->first;
116 i->second->write_config(child);
122 min_delay_(spec.minimum_delay()),
123 chance_(spec.chance()),
124 loops_(spec.loops()),
126 range_(spec.full_range()),
127 faderange_(spec.fade_range()),
128 check_fogged_(spec.check_fogged()),
129 check_shrouded_(spec.check_shrouded()),
130 files_(spec.files()),
131 locations_(spec.get_locations())
152 int i = rand() % 100 + 1;
167 if(v < distance_volume) {
188 if(v < distance_volume) {
216 return static_cast<int>((((distance -
range_)
228 cfg[
"full_range"] =
range_;
235 files_(cfg[
"sounds"]),
236 min_delay_(cfg[
"delay"].to_int(DEFAULT_DELAY)),
237 chance_(cfg[
"chance"].to_int(DEFAULT_CHANCE)),
239 range_(cfg[
"full_range"].to_int(3)),
240 faderange_(cfg[
"fade_range"].to_int(14)),
241 check_fogged_(cfg[
"check_fogged"].to_bool(true)),
242 check_shrouded_(cfg[
"check_shrouded"].to_bool(true)),
int calculate_volume(const map_location &loc, const display &disp)
void read_locations(const config &cfg, std::vector< map_location > &locs)
Parse x,y keys of a config into a vector of locations.
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
bool is_sound_playing(int id)
void play_sound_positioned(const std::string &files, int id, int repeats, unsigned int distance)
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...
void remove(const std::string &id)
events::generic_event & scroll_event() const
Expose the event, so observers can be notified about map scrolling.
const std::string & id() const
void reposition_sound(int id, unsigned int distance)
unsigned int last_played_
positional_source_map::iterator positional_source_iterator
void update(unsigned int time, const display &disp)
void handle_generic_event(const std::string &event_name)
std::vector< map_location > locations_
positional_source_map sources_
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_config(config &cfg) const
Serializes attributes as WML config.
config & add_child(const std::string &key)
map_display and display: classes which take care of displaying the map and game-data on the screen...
void update_positions(unsigned int time, const display &disp)
Encapsulates the map of the game.
std::vector< map_location > locations_
virtual bool attach_handler(observer *obs)
void add(const sourcespec &source)
const unsigned DEFAULT_CHANCE
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
positional_source(const sourcespec &spec)
sourcespec(const std::string &id, const std::string &files, int min_delay, int chance)
Parameter-list constructor.
manager(const display &disp)
const SDL_Rect & map_area() const
Returns the area used for the map.
Standard logging facilities (interface).
const unsigned DEFAULT_DELAY
A config object defines a single node in a WML file, with access to child nodes.
config get(const std::string &id)
GLsizei const GLcharARB ** string
positional_source_map::const_iterator positional_source_const_iterator
static unsigned int last_id
void write_sourcespecs(config &cfg) const
Serializes information into cfg as new children of key "sound_source", appended to existing content...
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,..,yn.