2013-01-25 04:19:06 +00:00
|
|
|
#ifndef GAMESETTINGS_HPP
|
|
|
|
#define GAMESETTINGS_HPP
|
|
|
|
|
2013-01-26 17:19:04 +00:00
|
|
|
#include <QMap>
|
2013-01-25 04:19:06 +00:00
|
|
|
|
2013-01-26 17:19:04 +00:00
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
|
|
|
|
class QTextStream;
|
|
|
|
class QStringList;
|
|
|
|
class QString;
|
|
|
|
|
|
|
|
namespace Files { typedef std::vector<boost::filesystem::path> PathContainer;
|
|
|
|
struct ConfigurationManager;}
|
|
|
|
|
|
|
|
class GameSettings
|
2013-01-25 04:19:06 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-01-26 17:19:04 +00:00
|
|
|
GameSettings(Files::ConfigurationManager &cfg);
|
2013-01-25 04:19:06 +00:00
|
|
|
~GameSettings();
|
|
|
|
|
2013-01-26 17:19:04 +00:00
|
|
|
inline QString value(const QString &key, const QString &defaultValue = QString())
|
|
|
|
{
|
|
|
|
return mSettings.value(key).isEmpty() ? defaultValue : mSettings.value(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void setValue(const QString &key, const QString &value)
|
|
|
|
{
|
|
|
|
mSettings.insert(key, value);
|
|
|
|
}
|
|
|
|
|
2013-02-18 22:10:50 +00:00
|
|
|
inline void setMultiValue(const QString &key, const QString &value)
|
|
|
|
{
|
|
|
|
QStringList values = mSettings.values(key);
|
|
|
|
if (!values.contains(value))
|
|
|
|
mSettings.insertMulti(key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void remove(const QString &key)
|
|
|
|
{
|
|
|
|
mSettings.remove(key);
|
|
|
|
}
|
|
|
|
|
2013-02-20 18:27:04 +00:00
|
|
|
inline void clear()
|
|
|
|
{
|
|
|
|
mSettings.clear();
|
|
|
|
}
|
|
|
|
|
2013-01-26 17:19:04 +00:00
|
|
|
inline QStringList getDataDirs() { return mDataDirs; }
|
|
|
|
inline void addDataDir(const QString &dir) { if(!dir.isEmpty()) mDataDirs.append(dir); }
|
|
|
|
inline QString getDataLocal() {return mDataLocal; }
|
|
|
|
|
|
|
|
QStringList values(const QString &key, const QStringList &defaultValues = QStringList());
|
|
|
|
bool readFile(QTextStream &stream);
|
|
|
|
bool writeFile(QTextStream &stream);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Files::ConfigurationManager &mCfgMgr;
|
|
|
|
|
|
|
|
void validatePaths();
|
|
|
|
QMap<QString, QString> mSettings;
|
|
|
|
|
|
|
|
QStringList mDataDirs;
|
|
|
|
QString mDataLocal;
|
2013-01-25 04:19:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GAMESETTINGS_HPP
|