diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-21 03:29:17 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-21 03:29:17 +0100 |
commit | 196f41688d01b7f0a79567c617fd6dd3171150ff (patch) | |
tree | a39f679bfc3011ccd6ac42c217967dfda24e8a2d /src | |
parent | 32f1cc8a22f62c18ba350eea440dee3c560fbc19 (diff) | |
download | usdx-196f41688d01b7f0a79567c617fd6dd3171150ff.tar.gz usdx-196f41688d01b7f0a79567c617fd6dd3171150ff.tar.xz usdx-196f41688d01b7f0a79567c617fd6dd3171150ff.zip |
menu/timer: use base/timestamp
Diffstat (limited to 'src')
-rw-r--r-- | src/menu/software_mouse_pointer.cpp | 2 | ||||
-rw-r--r-- | src/menu/timer.cpp | 14 | ||||
-rw-r--r-- | src/menu/timer.hpp | 8 |
3 files changed, 9 insertions, 15 deletions
diff --git a/src/menu/software_mouse_pointer.cpp b/src/menu/software_mouse_pointer.cpp index a532379d..e4d51d8e 100644 --- a/src/menu/software_mouse_pointer.cpp +++ b/src/menu/software_mouse_pointer.cpp @@ -34,7 +34,7 @@ namespace usdx SoftwareMousePointer::SoftwareMousePointer(Container* parent, EventManager* event_manager) : DrawableControl(parent), color(255,255,255,100), down(false) { - fade_inactive = new Timer(this, 2000, true); + fade_inactive = new Timer(this, 2, true); this->vertices[0] = 0.0f; this->vertices[1] = 40.0f; diff --git a/src/menu/timer.cpp b/src/menu/timer.cpp index 24da0c68..d091aed5 100644 --- a/src/menu/timer.cpp +++ b/src/menu/timer.cpp @@ -23,12 +23,11 @@ */ #include "timer.hpp" -#include <SDL/SDL.h> namespace usdx { - Timer::Timer(Control* owner, uint32_t duration, bool init) : - Control(owner), duration(duration), last_update(0), ready(init) + Timer::Timer(Control* owner, float duration, bool init) : + Control(owner), duration(duration), ready(init), last_update() { } @@ -36,15 +35,10 @@ namespace usdx { } - uint32_t Timer::now(void) const - { - return SDL_GetTicks(); - } - void Timer::update(void) { ready = false; - last_update = now(); + last_update.update(); } bool Timer::is_ready(void) @@ -52,7 +46,7 @@ namespace usdx if (ready) return true; - if ((now() - last_update) > duration) + if (!last_update.since(duration)) { ready = true; return true; diff --git a/src/menu/timer.hpp b/src/menu/timer.hpp index 17426332..a76a4411 100644 --- a/src/menu/timer.hpp +++ b/src/menu/timer.hpp @@ -27,20 +27,20 @@ #include <stdint.h> #include "control.hpp" +#include "base/timestamp.hpp" namespace usdx { class Timer : public Control { private: - uint32_t duration; - uint32_t last_update; + float duration; bool ready; - uint32_t now(void) const; + Timestamp last_update; public: - Timer(Control*, uint32_t, bool = false); + Timer(Control*, float, bool = false); virtual ~Timer(); void update(void); |