Author: alink
Date: Fri Apr 13 20:00:37 2007
New Revision: 16809
URL: http://svn.gna.org/viewcvs/wesnoth?rev=16809&view=rev
Log:
Add 2 utility functions: get the total time and the mean tempo of an animation.
Modified:
trunk/src/animated.cpp
trunk/src/animated.hpp
Modified: trunk/src/animated.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/animated.cpp?rev=16809&r1=16808&r2=16809&view=diff
==============================================================================
--- trunk/src/animated.cpp (original)
+++ trunk/src/animated.cpp Fri Apr 13 20:00:37 2007
@@ -177,6 +177,22 @@
}
template<typename T, typename T_void_value>
+const int animated<T,T_void_value>::get_animation_duration() const
+{
+ int duration = 0;
+ for (size_t i=0; i!=frames_.size(); i++) {
+ duration += frames_[i].duration_;
+ }
+ return duration;
+}
+
+template<typename T, typename T_void_value>
+const int animated<T,T_void_value>::get_animation_tempo() const
+{
+ return get_animation_duration() / get_frames_count();
+}
+
+template<typename T, typename T_void_value>
const T& animated<T,T_void_value>::get_current_frame() const
{
if(frames_.empty() )
Modified: trunk/src/animated.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/animated.hpp?rev=16809&r1=16808&r2=16809&view=diff
==============================================================================
--- trunk/src/animated.hpp (original)
+++ trunk/src/animated.hpp Fri Apr 13 20:00:37 2007
@@ -61,6 +61,9 @@
bool animation_finished() const;
bool animation_would_finish() const;
int get_animation_time() const;
+ const int get_animation_duration() const;
+ // get the mean tempo (total duration / number of frames)
+ const int get_animation_tempo() const;
const T& get_current_frame() const;
// get the next frame (or the current + shift frames)
const T& get_next_frame(int shift = 1) const;
_______________________________________________
Wesnoth-commits mailing list
[EMAIL PROTECTED]
https://mail.gna.org/listinfo/wesnoth-commits