Mercurial > fife-parpg
comparison engine/core/util/time/timeevent.cpp @ 484:e584b0b8b4a2
Added SoundEmitter::getDecodedLength and SoundEmitter::getDuration. The getDuration function will allow a timer to be registered to fire after the sound has been played. This is not a callback as requested but it does provide the functionality if required. I will be committing an example of it in the shooter demo shortly. [t:346]
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 30 Apr 2010 15:33:27 +0000 |
parents | 90005975cdbb |
children |
comparison
equal
deleted
inserted
replaced
483:82d44c471959 | 484:e584b0b8b4a2 |
---|---|
27 | 27 |
28 // FIFE includes | 28 // FIFE includes |
29 // These includes are split up in two parts, separated by one empty line | 29 // These includes are split up in two parts, separated by one empty line |
30 // First block: files included from the FIFE root src directory | 30 // First block: files included from the FIFE root src directory |
31 // Second block: files included from the same folder | 31 // Second block: files included from the same folder |
32 #include "timemanager.h" | |
32 #include "timeevent.h" | 33 #include "timeevent.h" |
33 | 34 |
34 namespace FIFE { | 35 namespace FIFE { |
35 | 36 |
36 TimeEvent::TimeEvent(int period): | 37 TimeEvent::TimeEvent(int period): |
37 m_period(period), | 38 m_period(period), |
38 m_last_updated(SDL_GetTicks()) { | 39 m_last_updated(TimeManager::instance()->getTime()) { |
39 } | 40 } |
40 | 41 |
41 TimeEvent::~TimeEvent() { | 42 TimeEvent::~TimeEvent() { |
42 return; | 43 return; |
43 } | 44 } |
45 void TimeEvent::managerUpdateEvent(unsigned long time) { | 46 void TimeEvent::managerUpdateEvent(unsigned long time) { |
46 int time_delta = static_cast<int>(time - m_last_updated); | 47 int time_delta = static_cast<int>(time - m_last_updated); |
47 if (m_period < 0) { | 48 if (m_period < 0) { |
48 return; | 49 return; |
49 } else if (m_period == 0 || time_delta >= m_period) { | 50 } else if (m_period == 0 || time_delta >= m_period) { |
50 updateEvent(time); | 51 updateEvent(time_delta); |
51 m_last_updated = time; | 52 m_last_updated = time; |
52 } | 53 } |
53 } | 54 } |
54 | 55 |
55 void TimeEvent::setPeriod(int period) { | 56 void TimeEvent::setPeriod(int period) { |
66 | 67 |
67 void TimeEvent::setLastUpdateTime(unsigned long ms) { | 68 void TimeEvent::setLastUpdateTime(unsigned long ms) { |
68 m_last_updated = ms; | 69 m_last_updated = ms; |
69 } | 70 } |
70 | 71 |
71 | 72 |
72 } //FIFE | 73 } //FIFE |