rt300@0: // rt300@0: // CountdownText.h rt300@0: // tweakathlon rt300@0: // rt300@0: // Created by Robert Tubb on 10/03/2014. rt300@0: // rt300@0: // rt300@0: rt300@0: #ifndef __tweakathlon__CountdownText__ rt300@0: #define __tweakathlon__CountdownText__ rt300@0: rt300@0: #include rt300@0: rt300@0: #include "ofMain.h" rt300@0: #include "UIElement.h" rt300@0: #include "timeController.h" rt300@0: #include "boost/function.hpp" rt300@0: #include "boost/bind.hpp" rt300@0: // actuall a countdown box rt300@0: extern TimeController timeController; rt300@0: class CountdownText : public UIElement{ rt300@0: public: rt300@0: rt300@0: CountdownText(string text, int x, int y,int w,int h, const UIProps& props); rt300@0: void draw(); rt300@0: rt300@0: ofColor foregroundHi; rt300@0: ofColor backgroundHi; rt300@0: ofColor foregroundLo; rt300@0: ofColor backgroundLo; rt300@0: rt300@0: bool handleMyTouch(int x, int y, touchType ttype, int touchID){ rt300@0: return false; rt300@0: } rt300@0: rt300@0: void showAndStart(int sec){ rt300@0: show(); rt300@0: stringstream s; rt300@0: s << sec; rt300@0: numSecondsText = s.str(); rt300@0: t = sec; rt300@0: timeController.scheduleEvent(tcb, 1000); rt300@0: }; rt300@0: rt300@0: void secPassed(){ rt300@0: t--; rt300@0: if(t <= 0){ rt300@0: //finish rt300@0: numSecondsText = "0!"; rt300@0: }else{ rt300@0: stringstream ts; rt300@0: ts << t; rt300@0: numSecondsText = ts.str(); rt300@0: timeController.scheduleEvent(tcb, 1000); rt300@0: } rt300@0: }; rt300@0: void setTestTypeString(string s){ rt300@0: testTypeString = s; rt300@0: } rt300@0: private: rt300@0: int t; rt300@0: TimerCallbackFunction tcb; rt300@0: string testTypeString; rt300@0: string numSecondsText; rt300@0: }; rt300@0: rt300@0: rt300@0: rt300@0: #endif /* defined(__tweakathlon__CountdownText__) */