2016-04-17 21:12:19 +00:00
|
|
|
#ifndef __SKIZZLE_UTIL_WIDGET_TIMER_HPP__
|
|
|
|
#define __SKIZZLE_UTIL_WIDGET_TIMER_HPP__
|
2016-04-05 22:31:10 +00:00
|
|
|
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
#include <functional>
|
2016-04-10 12:07:21 +00:00
|
|
|
#include "widget_button.hpp"
|
2016-04-12 16:11:36 +00:00
|
|
|
|
|
|
|
class Manager;
|
2016-04-05 22:31:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|