Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-12-09 23:09:12 +0000
committerStijn Buys <ingar@osirion.org>2012-12-09 23:09:12 +0000
commit66fd5337bda32d0ef04fff7514a8249ecb5c3b15 (patch)
tree8c187a18452c0f6a8f48520f3c855997ef142108 /src/core
parent2c1c377312f9c63c1bd586fb0fd290f677cd0089 (diff)
Improved info text parsing,
added specifications to the weapon info, expanded ship specifications info.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/info.cc27
-rw-r--r--src/core/info.h9
2 files changed, 34 insertions, 2 deletions
diff --git a/src/core/info.cc b/src/core/info.cc
index dbe4c76..dde1b20 100644
--- a/src/core/info.cc
+++ b/src/core/info.cc
@@ -146,13 +146,38 @@ void Info::clear_timestamp()
info_timestamp = 0;
}
-void Info::add_text(const char *text)
+void Info::add_line(const std::string & text)
+{
+ add_line(text.c_str());
+}
+
+void Info::add_line(const char *text)
{
std::string str(text);
aux::strip_quotes(str);
info_text.push_back(str);
}
+void Info::add_text(const char *text)
+{
+ std::string str(text);
+ aux::strip_quotes(str);
+
+ if (!info_text.size()) {
+ info_text.push_back(str);
+
+ } else if (str.size()) {
+ if ((*info_text.rbegin()).size()) {
+ (*info_text.rbegin()) += ' ';
+ (*info_text.rbegin()).append(str);
+ } else {
+ info_text.push_back(str);
+ }
+ } else {
+ info_text.push_back(str);
+ }
+}
+
void Info::add_text(const std::string & text)
{
add_text(text.c_str());
diff --git a/src/core/info.h b/src/core/info.h
index dfec17c..2859dac 100644
--- a/src/core/info.h
+++ b/src/core/info.h
@@ -143,11 +143,18 @@ public:
void set_timestamp(const unsigned long timestamp);
/// add a line of info text
- void add_text(const std::string & text);
+ void add_line(const std::string & text);
/// add a line of info text
+ void add_line(const char *text);
+
+ /// add info text without newline
+ void add_text(const std::string & text);
+
+ /// add info text without newline
void add_text(const char *text);
+
/// clear the info text
void clear_text();