paella/Code/include/Animation/Menu.hpp

89 lines
3.7 KiB
C++

////////////////////////////////////////////////////////////////////////////////
//
// Paella
// Copyright (C) 2015 - Thomas FORGIONE, Emilie JALRAS, Marion LENFANT, Thierry MALON, Amandine PAILLOUX
// Authors :
// Thomas FORGIONE
// Emilie JALRAS
// Marion LENFANT
// Thierry MALON
// Amandine PAILLOUX
//
// This file is part of the project Paella
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
////////////////////////////////////////////////////////////////////////////////
#ifndef MENU_HPP
#define MENU_HPP
#include <memory>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <Animation/AnimatedMesh.hpp>
///////////////////////////////////////////////////////
/// \ingroup animation
/// \brief A menu drawable with SFML for animation of meshes
///
/// Displays all patellas of the mesh and allows user to modify the angles
/// with the keyboard.
///////////////////////////////////////////////////////
class Menu : public sf::Drawable
{
public:
///////////////////////////////////////////////////////
/// \brief Usual constructor
/// \param mesh Mesh to control with the menu
/// \param nbPatellas Useless, will be removed in a future release
/// \param path Path to a font (SFML needs it)
/// \param rotationSpeed increment value for the menu
/// \param fontSize size of the font
///////////////////////////////////////////////////////
Menu(std::shared_ptr<pae::AnimatedMesh> const& mesh, unsigned int nbPatellas = 3, std::string const& path = "data/font/arial.ttf", float rotationSpeed = 1.0f, unsigned int fontSize = 20);
/////////////////////////////////////////////////////////
/// \brief Manages an event and modify the mesh of the menu status
///
/// \param event Event received
/////////////////////////////////////////////////////////
void manageEvent(sf::Event const& event);
/////////////////////////////////////////////////////////
/// \brief Draw the menu on the SFML window
///
/// \param target Target on which the menu will be drawn
/// \param states render states
/////////////////////////////////////////////////////////
void draw(sf::RenderTarget& target, sf::RenderStates states) const;
std::shared_ptr<pae::AnimatedMesh> mesh; ///< Shared pointer to the mesh
std::vector<std::vector<sf::Text>> textsMenu; ///< Texts displayed on the menu
unsigned int patellaIndex; ///< index of the patella currently modified
unsigned int nbPatellas; ///< total number of patellas (will be removed)
unsigned int angleIndex; ///< index of the angle currently modified
// std::vector<std::vector<float>> angles;
float rotationSpeed; ///< increment of the angles
sf::Font font; ///< SFML font
unsigned int fontSize; ///< size of the font
};
#endif // MENU_HPP