Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/descriptions.h')
-rw-r--r--src/core/descriptions.h128
1 files changed, 128 insertions, 0 deletions
diff --git a/src/core/descriptions.h b/src/core/descriptions.h
new file mode 100644
index 0000000..345d354
--- /dev/null
+++ b/src/core/descriptions.h
@@ -0,0 +1,128 @@
+/*
+ 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 <string>
+#include <list>
+#include <iostream>
+
+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};
+
+ ButtonDescription();
+ ~ButtonDescription();
+
+ /* -- inspectors ------------------------------------------- */
+
+ /// button text
+ inline const std::string & text() const { return button_text; }
+
+ /// 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);
+
+ /// set button name
+ void set_modelname(const std::string &modelname);
+
+ /// set text alignment
+ void set_alignment(Align align);
+
+private:
+ std::string button_text;
+ 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<ButtonDescription *> 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__
+
+