summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/crsm.cpp2
-rw-r--r--src/crsm.hpp46
2 files changed, 44 insertions, 4 deletions
diff --git a/src/crsm.cpp b/src/crsm.cpp
index 34feba2..cd4ed77 100644
--- a/src/crsm.cpp
+++ b/src/crsm.cpp
@@ -11,7 +11,7 @@
#define MGMT_BUFFER_FILENAME "CRSM-MGMT-Buffer"
CRSM::CRSM(QObject *parent) :
- QObject(parent)
+ QObject(parent), Session(this)
{
qsrand(QDateTime::currentMSecsSinceEpoch());
codec = QTextCodec::codecForName("Windows-1252");
diff --git a/src/crsm.hpp b/src/crsm.hpp
index 9351db8..d9434d6 100644
--- a/src/crsm.hpp
+++ b/src/crsm.hpp
@@ -49,6 +49,39 @@ public:
ScenarioSettings(const QString& name, bool league = false) : name(name), league(league) {}
ScenarioSettings(const QString& name, const ClientInfo& client, bool league = false) : name(name), league(league), wishClient(client) {}
+ ScenarioSettings() {}
+ inline bool operator ==(const ScenarioSettings& other) const
+ {
+ return name == other.name && league == other.league && randomLeague == other.randomLeague && wishClient == other.wishClient;
+ }
+};
+
+template<>
+class CRSMConfigValue<ScenarioSettings> : public CRSMConfigValueBase {
+ ScenarioSettings& config;
+
+public:
+ CRSMConfigValue(ScenarioSettings& config) : config(config) { }
+
+ void setValue(const QString& val)
+ {
+ QStringList parts = val.split(':', QString::KeepEmptyParts);
+ if(parts.length() < 3)
+ {
+ throw CRSMConfigException("Cannot read corrupt ScenarioSettings");
+ }
+ else
+ {
+ config.name = CRSMConfigValueBase::getValue<QString>(parts.first());
+ parts.removeFirst();
+ config.league = CRSMConfigValueBase::getValue<bool>(parts.first());
+ parts.removeFirst();
+ config.randomLeague = false;
+ config.wishClient = CRSMConfigValueBase::getValue<ClientInfo>(parts.join(':'));
+ }
+ }
+
+ QString value() { return CRSMConfigValueBase::getStringValue(config.name) + ":" + CRSMConfigValueBase::getStringValue(config.league) + ":" + CRSMConfigValueBase::getStringValue(config.wishClient); }
};
class CRSM : public QObject
@@ -84,9 +117,9 @@ public:
~CRSM();
void start();
bool isOk();
-
+
signals:
-
+
private slots:
void readServerOutput();
void readInput();
@@ -147,7 +180,14 @@ private:
ConfigValue(IRC.Admin),
ConfigValue(IRC.UseIngameChat),
}) {}
- } Session;
+
+ CRSMSession(CRSM* crsm) : CRSMSession()
+ {
+ addConfigValue("Hosting.UserWishes", mkConfigValue(crsm->userlist, false));
+ }
+ };
+
+ CRSMSession Session;
QList<ScenarioSettings> userlist;
QList<ScenarioSettings> autolist;