MàJ du bouton de mute en fonction de l'état
This commit is contained in:
		
							parent
							
								
									8c91ba7a54
								
							
						
					
					
						commit
						b7ebc8e91d
					
				| 
						 | 
					@ -21,7 +21,7 @@ public:
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Ajoute un nouveau bouton d'action à la barre d'outils
 | 
					     * Ajoute un nouveau bouton d'action à la barre d'outils
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    void addButton(
 | 
					    sfg::Button::Ptr addButton(
 | 
				
			||||||
        sf::Image image,
 | 
					        sf::Image image,
 | 
				
			||||||
        std::function<void()> callback = std::function<void()>()
 | 
					        std::function<void()> callback = std::function<void()>()
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
| 
						 | 
					@ -29,7 +29,9 @@ public:
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Ajoute un nouvel espaceur
 | 
					     * Ajoute un nouvel espaceur
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    void addSpacer(float width, bool expand, bool fill);
 | 
					    sfg::Alignment::Ptr addSpacer(
 | 
				
			||||||
 | 
					        float width, bool expand, bool fill
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Récupère la fenêtre de la barre d'outils
 | 
					     * Récupère la fenêtre de la barre d'outils
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,6 +25,7 @@ private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ActionToolbar action_toolbar;
 | 
					    ActionToolbar action_toolbar;
 | 
				
			||||||
    ObjectToolbar object_toolbar;
 | 
					    ObjectToolbar object_toolbar;
 | 
				
			||||||
 | 
					    sfg::Button::Ptr mute_button;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Renvoie l'objet pointé à la position donnée
 | 
					     * Renvoie l'objet pointé à la position donnée
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,7 +12,9 @@ ActionToolbar::ActionToolbar() {
 | 
				
			||||||
    toolbar_window->SetId("action_toolbar");
 | 
					    toolbar_window->SetId("action_toolbar");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ActionToolbar::addButton(sf::Image image, std::function<void()> callback) {
 | 
					sfg::Button::Ptr ActionToolbar::addButton(
 | 
				
			||||||
 | 
					    sf::Image image, std::function<void()> callback
 | 
				
			||||||
 | 
					) {
 | 
				
			||||||
    // création d'un bouton avec pour image l'image passée
 | 
					    // création d'un bouton avec pour image l'image passée
 | 
				
			||||||
    sfg::Button::Ptr button = sfg::Button::Create("");
 | 
					    sfg::Button::Ptr button = sfg::Button::Create("");
 | 
				
			||||||
    button->SetImage(sfg::Image::Create(image));
 | 
					    button->SetImage(sfg::Image::Create(image));
 | 
				
			||||||
| 
						 | 
					@ -25,14 +27,18 @@ void ActionToolbar::addButton(sf::Image image, std::function<void()> callback) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // ajout du bouton à la barre
 | 
					    // ajout du bouton à la barre
 | 
				
			||||||
    toolbar_box->PackEnd(button, false, false);
 | 
					    toolbar_box->PackEnd(button, false, false);
 | 
				
			||||||
 | 
					    return button;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ActionToolbar::addSpacer(float width, bool expand, bool fill) {
 | 
					sfg::Alignment::Ptr ActionToolbar::addSpacer(
 | 
				
			||||||
 | 
					    float width, bool expand, bool fill
 | 
				
			||||||
 | 
					) {
 | 
				
			||||||
    sfg::Alignment::Ptr spacer = sfg::Alignment::Create();
 | 
					    sfg::Alignment::Ptr spacer = sfg::Alignment::Create();
 | 
				
			||||||
    spacer->SetRequisition(sf::Vector2f(width, 1.f));
 | 
					    spacer->SetRequisition(sf::Vector2f(width, 1.f));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // ajout de l'espaceur à la barre
 | 
					    // ajout de l'espaceur à la barre
 | 
				
			||||||
    toolbar_box->PackEnd(spacer, expand, fill);
 | 
					    toolbar_box->PackEnd(spacer, expand, fill);
 | 
				
			||||||
 | 
					    return spacer;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
sfg::Window::Ptr ActionToolbar::getWindow() {
 | 
					sfg::Window::Ptr ActionToolbar::getWindow() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,7 +41,7 @@ Editor::Editor(Manager& manager) : Level(manager),
 | 
				
			||||||
        std::bind(&Manager::popState, &getManager())
 | 
					        std::bind(&Manager::popState, &getManager())
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    action_toolbar.addButton(
 | 
					    mute_button = action_toolbar.addButton(
 | 
				
			||||||
        *ResourceManager::get().getImage("toolbar/icon_music.tga"),
 | 
					        *ResourceManager::get().getImage("toolbar/icon_music.tga"),
 | 
				
			||||||
        []() {
 | 
					        []() {
 | 
				
			||||||
            // on inverse le drapeau de muet
 | 
					            // on inverse le drapeau de muet
 | 
				
			||||||
| 
						 | 
					@ -290,17 +290,12 @@ void Editor::processEvent(const sf::Event& event) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Editor::frame() {
 | 
					void Editor::frame() {
 | 
				
			||||||
    // dessin de la frame
 | 
					 | 
				
			||||||
    draw();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // màj du titre de la fenêtre
 | 
					 | 
				
			||||||
    getManager().setTitle(sf::String(L"Édition de ") + getName());
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void Editor::draw() {
 | 
					 | 
				
			||||||
    sf::RenderWindow& window = getManager().getWindow();
 | 
					    sf::RenderWindow& window = getManager().getWindow();
 | 
				
			||||||
    sf::Vector2i window_size = (sf::Vector2i) window.getSize();
 | 
					    sf::Vector2i window_size = (sf::Vector2i) window.getSize();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // dessin de la frame
 | 
				
			||||||
 | 
					    draw();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // scroll de la caméra lorsque la souris se situe sur les bords
 | 
					    // scroll de la caméra lorsque la souris se situe sur les bords
 | 
				
			||||||
    if (window.hasFocus()) {
 | 
					    if (window.hasFocus()) {
 | 
				
			||||||
        sf::View camera = getCamera();
 | 
					        sf::View camera = getCamera();
 | 
				
			||||||
| 
						 | 
					@ -320,6 +315,37 @@ void Editor::draw() {
 | 
				
			||||||
        setCamera(camera);
 | 
					        setCamera(camera);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // mise à jour de l'icône du mute
 | 
				
			||||||
 | 
					    sf::Image image;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (ResourceManager::get().isMuted()) {
 | 
				
			||||||
 | 
					        image = *ResourceManager::get().getImage("toolbar/icon_no_music.tga");
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        image = *ResourceManager::get().getImage("toolbar/icon_music.tga");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mute_button->SetImage(sfg::Image::Create(image));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // màj du titre de la fenêtre
 | 
				
			||||||
 | 
					    getManager().setTitle(sf::String(L"Édition de ") + getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // positionnement des barres d'outils au bon endroit
 | 
				
			||||||
 | 
					    action_toolbar.getWindow()->SetAllocation(sf::FloatRect(
 | 
				
			||||||
 | 
					        0, 0, window_size.x,
 | 
				
			||||||
 | 
					        action_toolbar.getHeight()
 | 
				
			||||||
 | 
					    ));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    object_toolbar.getWindow()->SetAllocation(sf::FloatRect(
 | 
				
			||||||
 | 
					        window_size.x - object_toolbar.getWidth(),
 | 
				
			||||||
 | 
					        action_toolbar.getHeight(),
 | 
				
			||||||
 | 
					        object_toolbar.getWidth(),
 | 
				
			||||||
 | 
					        window_size.y - action_toolbar.getHeight()
 | 
				
			||||||
 | 
					    ));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Editor::draw() {
 | 
				
			||||||
 | 
					    sf::RenderWindow& window = getManager().getWindow();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // dessin des objets du niveau
 | 
					    // dessin des objets du niveau
 | 
				
			||||||
    Level::draw();
 | 
					    Level::draw();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -360,19 +386,6 @@ void Editor::draw() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        window.draw(selection_rect);
 | 
					        window.draw(selection_rect);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    // on positionne les barres d'outils au bon endroit
 | 
					 | 
				
			||||||
    action_toolbar.getWindow()->SetAllocation(sf::FloatRect(
 | 
					 | 
				
			||||||
        0, 0, window_size.x,
 | 
					 | 
				
			||||||
        action_toolbar.getHeight()
 | 
					 | 
				
			||||||
    ));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    object_toolbar.getWindow()->SetAllocation(sf::FloatRect(
 | 
					 | 
				
			||||||
        window_size.x - object_toolbar.getWidth(),
 | 
					 | 
				
			||||||
        action_toolbar.getHeight(),
 | 
					 | 
				
			||||||
        object_toolbar.getWidth(),
 | 
					 | 
				
			||||||
        window_size.y - action_toolbar.getHeight()
 | 
					 | 
				
			||||||
    ));
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Object::Ptr Editor::getObject(sf::Vector2f position) {
 | 
					Object::Ptr Editor::getObject(sf::Vector2f position) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue