Utilisation des nouvelles barres d'outils
This commit is contained in:
parent
18fb9a9419
commit
3c3bbe5e96
|
@ -1,7 +1,8 @@
|
||||||
#ifndef __SKIZZLE_EDITOR_HPP__
|
#ifndef __SKIZZLE_EDITOR_HPP__
|
||||||
#define __SKIZZLE_EDITOR_HPP__
|
#define __SKIZZLE_EDITOR_HPP__
|
||||||
|
|
||||||
#include "../gui/toolbar.hpp"
|
#include "../gui/action_toolbar.hpp"
|
||||||
|
#include "../gui/object_toolbar.hpp"
|
||||||
#include "level.hpp"
|
#include "level.hpp"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +23,8 @@ private:
|
||||||
|
|
||||||
DragMode drag_mode;
|
DragMode drag_mode;
|
||||||
|
|
||||||
Toolbar toolbar;
|
ActionToolbar action_toolbar;
|
||||||
|
ObjectToolbar object_toolbar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoie l'objet pointé à la position donnée
|
* Renvoie l'objet pointé à la position donnée
|
||||||
|
|
|
@ -33,13 +33,44 @@ inline sf::Vector2f roundVectorToGrid(sf::Vector2f input) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Editor::Editor(Manager& manager) : Level(manager),
|
Editor::Editor(Manager& manager) : Level(manager),
|
||||||
drag_control_point(nullptr), drag_mode(Editor::DragMode::NONE),
|
drag_control_point(nullptr), drag_mode(Editor::DragMode::NONE) {
|
||||||
toolbar(*this) {
|
|
||||||
getManager().addWidget(toolbar.getWindow());
|
// ajout des boutons dans la barre d'action
|
||||||
|
action_toolbar.addButton(
|
||||||
|
*ResourceManager::get().getImage("toolbar/icon_back.tga"),
|
||||||
|
std::bind(&Manager::popState, &getManager())
|
||||||
|
);
|
||||||
|
|
||||||
|
action_toolbar.addButton(
|
||||||
|
*ResourceManager::get().getImage("toolbar/icon_music.tga")
|
||||||
|
);
|
||||||
|
|
||||||
|
action_toolbar.addButton(
|
||||||
|
*ResourceManager::get().getImage("toolbar/icon_no_music.tga")
|
||||||
|
);
|
||||||
|
|
||||||
|
action_toolbar.addButton(
|
||||||
|
*ResourceManager::get().getImage("toolbar/icon_save.tga"),
|
||||||
|
std::bind(&Editor::save, this)
|
||||||
|
);
|
||||||
|
|
||||||
|
action_toolbar.addButton(
|
||||||
|
*ResourceManager::get().getImage("toolbar/icon_test.tga"),
|
||||||
|
std::bind(&Editor::test, this)
|
||||||
|
);
|
||||||
|
|
||||||
|
action_toolbar.addButton(
|
||||||
|
*ResourceManager::get().getImage("toolbar/icon_gear.tga")
|
||||||
|
);
|
||||||
|
|
||||||
|
// signalement des sous-widgets
|
||||||
|
getManager().addWidget(action_toolbar.getWindow());
|
||||||
|
getManager().addWidget(object_toolbar.getWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
Editor::~Editor() {
|
Editor::~Editor() {
|
||||||
getManager().removeWidget(toolbar.getWindow());
|
getManager().removeWidget(action_toolbar.getWindow());
|
||||||
|
getManager().removeWidget(object_toolbar.getWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::enable() {
|
void Editor::enable() {
|
||||||
|
@ -52,9 +83,9 @@ void Editor::enable() {
|
||||||
// joue la musique de l'éditeur
|
// joue la musique de l'éditeur
|
||||||
ResourceManager::get().playMusic("editor.ogg");
|
ResourceManager::get().playMusic("editor.ogg");
|
||||||
|
|
||||||
// on affiche la toolbar de l'éditeur
|
// on affiche les barres d'outils
|
||||||
toolbar.update();
|
action_toolbar.getWindow()->Show(true);
|
||||||
toolbar.getWindow()->Show(true);
|
object_toolbar.getWindow()->Show(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::processEvent(const sf::Event& event) {
|
void Editor::processEvent(const sf::Event& event) {
|
||||||
|
@ -320,10 +351,17 @@ void Editor::draw() {
|
||||||
window.draw(selection_rect);
|
window.draw(selection_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// on redimensionne la toolbar pour qu'elle occupe l'espace droite
|
// on positionne les barres d'outils au bon endroit
|
||||||
toolbar.getWindow()->SetAllocation(sf::FloatRect(
|
action_toolbar.getWindow()->SetAllocation(sf::FloatRect(
|
||||||
window_size.x - toolbar.getWidth(), 0,
|
0, 0, window_size.x,
|
||||||
toolbar.getWidth(), window_size.y
|
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()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +392,7 @@ sf::Vector2f* Editor::getControlPoint(sf::Vector2f position) {
|
||||||
Object::Ptr Editor::addObject(sf::Vector2f position) {
|
Object::Ptr Editor::addObject(sf::Vector2f position) {
|
||||||
// on arrondit à l'unité de grille la plus proche
|
// on arrondit à l'unité de grille la plus proche
|
||||||
position = roundVectorToGrid(position);
|
position = roundVectorToGrid(position);
|
||||||
Object::Ptr created_object = toolbar.createObject();
|
Object::Ptr created_object = object_toolbar.createObject();
|
||||||
|
|
||||||
if (created_object == nullptr) {
|
if (created_object == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
Loading…
Reference in New Issue