2016-04-05 22:31:10 +00:00
|
|
|
#ifndef __PTF_UTIL_WIDGET_TIMER_HPP__
|
|
|
|
#define __PTF_UTIL_WIDGET_TIMER_HPP__
|
|
|
|
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
#include <functional>
|
|
|
|
#include "util/widget_button.hpp"
|
|
|
|
#include "manager.hpp"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Affiche le compteur de temps pouvant (ou non)
|
|
|
|
* être modifié
|
|
|
|
*/
|
|
|
|
class WidgetTimer {
|
|
|
|
private:
|
|
|
|
Manager& manager;
|
2016-04-06 13:21:46 +00:00
|
|
|
bool can_change;
|
2016-04-05 22:31:10 +00:00
|
|
|
std::function<void(int)> time_left_cb;
|
|
|
|
int time_left;
|
|
|
|
|
|
|
|
sf::RectangleShape timer_zone;
|
2016-04-06 13:21:46 +00:00
|
|
|
sf::Text timer_seconds_text;
|
|
|
|
sf::Text timer_sep_text;
|
|
|
|
sf::Text timer_minutes_text;
|
2016-04-05 22:31:10 +00:00
|
|
|
|
|
|
|
WidgetButton timer_up;
|
|
|
|
WidgetButton timer_down;
|
|
|
|
|
|
|
|
public:
|
2016-04-06 13:21:46 +00:00
|
|
|
WidgetTimer(Manager& manager, bool can_change, std::function<void(int)> time_left_cb = std::function<void(int)>());
|
2016-04-05 22:31:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Process l'événement et renvoie true si
|
|
|
|
* on s'en est servi
|
|
|
|
*/
|
|
|
|
bool processEvent(const sf::Event& event);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dessine le widget à la position (haut-gauche) donnée
|
|
|
|
*/
|
|
|
|
void draw(sf::Vector2f position);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Augmente le temps de 5 secondes
|
|
|
|
*/
|
|
|
|
void addTime();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Diminue le temps de 5 secondes
|
|
|
|
*/
|
|
|
|
void subtractTime();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifie le temps restant
|
|
|
|
*/
|
|
|
|
void setTimeLeft(int set_time_left);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|