/* core/descriptions.h This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2 */ #ifndef __INCLUDED_CORE_DESCRIPTIONS_H__ #define __INCLUDED_CORE_DESCRIPTIONS_H__ #include #include #include namespace core { class ButtonDescription; class MenuDescription; } #include "core/entity.h" #include "model/model.h" #include "filesystem/inifile.h" namespace core { /// description of a menu button class ButtonDescription { public: enum Align {Center = 0, Left = 1, Right = 2}; enum CommandType {CommandNone = 0, CommandGame = 1, CommandMenu = 2}; ButtonDescription(); ~ButtonDescription(); /* -- inspectors ------------------------------------------- */ /// button text inline const std::string & text() const { return button_text; } /// button command type inline const CommandType command_type() const { return button_commandtype; } /// button command inline const std::string & command() const { return button_command; } /// button info view model name inline const std::string & modelname() const { return button_modelname; } /// button info view model inline const model::Model *model() { return button_model; } /// button text alignment inline Align alignment() const { return button_align; } /* -- mutators -------------------------------------------- */ /// set button text void set_text(const std::string &text); /// set button command void set_command(const std::string &command, const CommandType command_type); /// set button name void set_modelname(const std::string &modelname); /// set text alignment void set_alignment(Align align); private: std::string button_text; CommandType button_commandtype; std::string button_command; std::string button_modelname; Align button_align; model::Model *button_model; }; /// description of an entity menu class MenuDescription { public: MenuDescription(); ~MenuDescription(); typedef std::list Buttons; /* -- inspectors ------------------------------------------- */ /// menu label inline const std::string & label() const { return menu_label; } /// menu text inline const std::string & text() const { return menu_text; } /// menu buttons inline Buttons &buttons() { return menu_buttons; } /* -- mutators -------------------------------------------- */ /// set menu text void set_text(const std::string &text); /// set menu label void set_label(const std::string &label); /// add a menu button void add_button(ButtonDescription *button); private: std::string menu_label; std::string menu_text; Buttons menu_buttons; }; /// descriptions loader class class Descriptions { public: /// read entity menus from ini file static bool load_entity_menus(core::Entity *entity, const std::string &menufilename); /// serialize entity menus to a stream static void serialize(MenuDescription *menu, std::ostream & os); /// read entity menus from a stream static MenuDescription * receive(std::istream &is); }; } #endif // __INCLUDED_CORE_DESCRIPTIONS_H__