Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-11-12 20:53:35 +0000
committerStijn Buys <ingar@osirion.org>2009-11-12 20:53:35 +0000
commit5ddb64795cc959916eeedbec8dc3f65c06f49698 (patch)
treeee7231607b0bf49528570e5d3badcdedcb33f54e /src/core/info.h
parent3605a7bd8fffebfba38d31025b6f33cb82626a3b (diff)
initial commodities and entity inventory, bump network proto version to 18
Diffstat (limited to 'src/core/info.h')
-rw-r--r--src/core/info.h98
1 files changed, 70 insertions, 28 deletions
diff --git a/src/core/info.h b/src/core/info.h
index 8395954..9f1fab8 100644
--- a/src/core/info.h
+++ b/src/core/info.h
@@ -9,7 +9,7 @@
#include <iostream>
#include <string>
-#include <map>
+#include <vector>
#include <deque>
#include "model/model.h"
@@ -18,19 +18,34 @@ namespace core
{
/**
- * an information record
+ * @brief an information record
+ * An information record holds extended information about a specific entity or item class.
+ * This information isexchanged between server and the client, and can be used to build
+ * HUD widgets/
*/
class Info
{
public:
+ /// type definition for the text description
+ typedef std::deque<std::string> Text;
+
+ /// create a new labeled information record
+ Info();
+
/// create a new labeled information record
Info(const std::string & label);
+
+ Info(const unsigned int id);
/// delete the information record
~Info();
- typedef std::deque<std::string> Text;
+ /* ---- inspectors ------------------------------------------------- */
+ inline const unsigned int id() const {
+ return info_id;
+ }
+
inline const std::string & label() const {
return info_label;
}
@@ -42,15 +57,26 @@ public:
inline const std::string & modelname() const {
return info_modelname;
}
+
+ inline const model::Model *model() const {
+ return info_model;
+ }
inline const unsigned long &timestamp() const {
return info_timestamp;
}
+ /// text description
inline Text & text() {
return info_text;
}
+ /* ---- mutators --------------------------------------------------- */
+
+ void set_label(const std::string & name);
+
+ void set_label(const char *name);
+
void set_name(const std::string & name);
void set_name(const char *name);
@@ -58,16 +84,12 @@ public:
void set_modelname(const std::string & modelname);
void set_modelname(const char *modelname);
+
+ void set_model(const model::Model *model);
/// set the timestamp
void set_timestamp(const unsigned long timestamp);
- /// clear the timestamp
- void clear_timestamp();
-
- /// add a line of info text
- void add_text(const char *text);
-
/// add a line of info text
void add_text(const std::string & text);
@@ -76,25 +98,54 @@ public:
/// print info to sys::con_out
void print() const;
+
+ /// clear the timestamp
+ void clear_timestamp();
+ /// add a line of info text
+ void add_text(const char *text);
+
+ /* ---- serializers ------------------------------------------------ */
+
/// serialize a server-to-client update on a stream
void serialize_server_update(std::ostream & os) const;
/// receive a server-to-client update from a stream
void receive_server_update(std::istream &is);
- /* ---- static info registry --------------------------------------- */
+private:
- typedef std::map<std::string, Info*> Registry;
+ unsigned int info_id;
+
+ std::string info_label;
+ std::string info_name;
+ std::string info_modelname;
+
+ const model::Model* info_model;
+
+ long info_credits;
+ unsigned long info_timestamp;
- /// add an item to the info regsitry
- static void add(Info *info);
+ Text info_text;
- /// search the info registry for a labeled item
+ /* ---- static info registry --------------------------------------- */
+
+public:
+ /// info registry type definition
+ typedef std::vector<Info*> Registry;
+
+ /// the info registry
+ static inline Registry & registry() {
+ return info_registry;
+ }
+ /// search the info registry for a labeled item
static Info *find(const char * label);
- /// search the info registry for a labeled item
+ /// search the info registry for a label
static Info *find(const std::string & label);
+
+ /// search the info registry for an id
+ static Info *find(const unsigned int id);
/// clear the info registry
static void clear();
@@ -102,21 +153,12 @@ public:
/// list the info registry
static void list();
- /// the info registry
- static inline Registry & registry() {
- return info_registry;
- }
-
private:
- std::string info_label;
- std::string info_name;
- std::string info_modelname;
- Text info_text;
-
- long info_credits;
- static Registry info_registry;
+ /// add a record to the info registry
+ static void add(Info *info);
- unsigned long info_timestamp;
+ static Registry info_registry;
+ static unsigned int static_info_id_counter;
};
}