Author: boucman
Date: Fri Apr 23 16:55:31 2010
New Revision: 42227
URL: http://svn.gna.org/viewcvs/wesnoth?rev=42227&view=rev
Log:
allow changing of music volume through WML, slightly modified from patch #1640
by lfernando
Modified:
trunk/changelog
trunk/src/game_events.cpp
trunk/src/sound.cpp
trunk/src/sound.hpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=42227&r1=42226&r2=42227&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Fri Apr 23 16:55:31 2010
@@ -47,6 +47,7 @@
* 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
Modified: trunk/src/game_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=42227&r1=42226&r2=42227&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Fri Apr 23 16:55:31 2010
@@ -711,6 +711,25 @@
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;
Modified: trunk/src/sound.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sound.cpp?rev=42227&r1=42226&r2=42227&view=diff
==============================================================================
--- trunk/src/sound.cpp (original)
+++ trunk/src/sound.cpp Fri Apr 23 16:55:31 2010
@@ -808,6 +808,10 @@
}
}
+int get_music_volume()
+{
+ return Mix_VolumeMusic(-1);
+}
void set_music_volume(int vol)
{
Modified: trunk/src/sound.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sound.hpp?rev=42227&r1=42226&r2=42227&view=diff
==============================================================================
--- trunk/src/sound.hpp (original)
+++ trunk/src/sound.hpp Fri Apr 23 16:55:31 2010
@@ -87,6 +87,7 @@
// 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);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits