allow changing of music volume through WML,
...slightly modified from patch #1640 by lfernando
This commit is contained in:
parent
cf090e0750
commit
d7f3239c2f
4 changed files with 25 additions and 0 deletions
|
@ -47,6 +47,7 @@ Version 1.9.0-svn:
|
|||
* Add [replace_schedule] tag, which replaces the time of day schedule
|
||||
* Trying to include a missing macro/file is now a fatal error
|
||||
* Extended #ifdef so that it also tests for files and directories
|
||||
* Add [music_volume] tag, which permits modifications to music volume during scenario
|
||||
* Miscellaneous and bug fixes:
|
||||
* Defaulted log level to warning again
|
||||
* New option to auto-set delay shroud update on game start
|
||||
|
|
|
@ -711,6 +711,25 @@ WML_HANDLER_FUNCTION(music, /*event_info*/, cfg)
|
|||
sound::play_music_config(cfg.get_parsed_config());
|
||||
}
|
||||
|
||||
WML_HANDLER_FUNCTION(music_volume, /*event_info*/, cfg)
|
||||
{
|
||||
std::string absolute = cfg["value"];
|
||||
std::string relative = cfg["relative"];
|
||||
int vol = sound::get_music_volume();
|
||||
|
||||
if(!absolute.empty()) {
|
||||
vol = atoi(absolute.c_str());
|
||||
}
|
||||
|
||||
if(!relative.empty()) {
|
||||
const float rel = atof(relative.c_str());
|
||||
vol = static_cast<int>(rel*vol/100.0);
|
||||
}
|
||||
|
||||
sound::set_music_volume(vol);
|
||||
}
|
||||
|
||||
|
||||
WML_HANDLER_FUNCTION(sound, /*event_info*/, cfg)
|
||||
{
|
||||
play_controller *controller = resources::controller;
|
||||
|
|
|
@ -808,6 +808,10 @@ void play_UI_sound(const std::string& files)
|
|||
}
|
||||
}
|
||||
|
||||
int get_music_volume()
|
||||
{
|
||||
return Mix_VolumeMusic(-1);
|
||||
}
|
||||
|
||||
void set_music_volume(int vol)
|
||||
{
|
||||
|
|
|
@ -87,6 +87,7 @@ class music_thinker : public events::pump_monitor {
|
|||
// Save music playlist for snapshot
|
||||
void write_music_play_list(config& snapshot);
|
||||
|
||||
int get_music_volume();
|
||||
void set_music_volume(int vol);
|
||||
void set_sound_volume(int vol);
|
||||
void set_bell_volume(int vol);
|
||||
|
|
Loading…
Add table
Reference in a new issue