Correction màj icône musique

This commit is contained in:
Mattéo Delabre 2016-04-29 02:57:23 +02:00
parent 0f5cbc6d9e
commit 853976f56d
2 changed files with 15 additions and 7 deletions

View File

@ -38,6 +38,7 @@ private:
std::vector<sf::Vector2f> zone; std::vector<sf::Vector2f> zone;
sfg::Button::Ptr mute_button; sfg::Button::Ptr mute_button;
bool previously_muted_state;
protected: protected:
ActionToolbar action_toolbar; ActionToolbar action_toolbar;

View File

@ -49,7 +49,8 @@ namespace {
} }
Level::Level(Manager& manager) : State(manager), Level::Level(Manager& manager) : State(manager),
gravity_direction(Utility::Direction::SOUTH) { gravity_direction(Utility::Direction::SOUTH),
previously_muted_state(!ResourceManager::get().isMuted()) {
// métadonnées par défaut // métadonnées par défaut
setName(sf::String("Nouveau niveau")); setName(sf::String("Nouveau niveau"));
@ -282,12 +283,18 @@ void Level::frame() {
sf::Vector2i window_size = (sf::Vector2i) window.getSize(); sf::Vector2i window_size = (sf::Vector2i) window.getSize();
// mise à jour de l'icône du mute en fonction de l'état // mise à jour de l'icône du mute en fonction de l'état
if (ResourceManager::get().isMuted()) { if (previously_muted_state != ResourceManager::get().isMuted()) {
std::static_pointer_cast<sfg::Image>(mute_button->GetChild()) if (ResourceManager::get().isMuted()) {
->SetImage(*ResourceManager::get().getImage("no_music.tga")); previously_muted_state = true;
} else { mute_button->SetImage(sfg::Image::Create(
std::static_pointer_cast<sfg::Image>(mute_button->GetChild()) *ResourceManager::get().getImage("no_music.tga")
->SetImage(*ResourceManager::get().getImage("music.tga")); ));
} else {
previously_muted_state = false;
mute_button->SetImage(sfg::Image::Create(
*ResourceManager::get().getImage("music.tga")
));
}
} }
// positionnement de la barre d'actions // positionnement de la barre d'actions