diff options
| author | Markus Mittendrein <git@maxmitti.tk> | 2015-10-08 20:48:57 +0200 |
|---|---|---|
| committer | Markus Mittendrein <git@maxmitti.tk> | 2015-10-08 20:48:57 +0200 |
| commit | 1ebfb61ce4c997e7fc2aa52ecc34e9dbe0a8968d (patch) | |
| tree | 9f1f8ca4a5e5458d9403142c4a42ce2fcefb274f /src | |
| parent | 8180123884cb0a00f710333dec7d503b43ed5070 (diff) | |
| download | manager-1ebfb61ce4c997e7fc2aa52ecc34e9dbe0a8968d.tar.gz manager-1ebfb61ce4c997e7fc2aa52ecc34e9dbe0a8968d.zip | |
Store UserWishes in Session-file
Diffstat (limited to 'src')
| -rw-r--r-- | src/crsm.cpp | 2 | ||||
| -rw-r--r-- | src/crsm.hpp | 46 |
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; |
