29 static QString coerceInternalName(
const QString &
name)
31 return name.toLower().remove(QRegExp(
"[^a-z0-9]"));
42 void setInternalName(
const QString &name)
44 internalName = coerceInternalName(name);
55 DMFlag::DMFlag(
const QString &internalName,
unsigned value)
58 d->setInternalName(internalName);
62 DMFlag::DMFlag(
const QString &internalName,
unsigned value,
const QString &name)
65 d->setInternalName(internalName);
75 return d->internalName;
95 DClass<DMFlagsSection>
100 QVector<DMFlag> flags;
102 void setInternalName(
const QString &name)
104 internalName = coerceInternalName(name);
110 DMFlagsSection::DMFlagsSection()
114 DMFlagsSection::DMFlagsSection(
const QString &internalName)
117 d->setInternalName(internalName);
120 DMFlagsSection::DMFlagsSection(
const QString &internalName,
const QString &name)
123 d->setInternalName(internalName);
126 DMFlagsSection::~DMFlagsSection()
138 foreach (
const DMFlag& flag, d->flags)
140 result |= flag.
value();
148 copy.d->flags.clear();
154 return d->flags.count();
159 return d->internalName;
174 return d->flags[index];
179 return d->flags[index];
183 const QList<DMFlagsSection> &original,
184 const QList<DMFlagsSection> &removals)
186 QList<DMFlagsSection> copy;
189 bool removed =
false;
194 copy << section.
removed(removal);
210 foreach (
const DMFlag &removal, removals.d->flags)
212 QMutableVectorIterator<DMFlag> i(copy.d->flags);
242 GameCVar::GameCVar(
const QString &name,
const QString &command)
245 d->command = command;
248 GameCVar::GameCVar(
const QString &name,
const QString &command,
const QVariant &value)
251 d->command = command;
255 GameCVar::~GameCVar()
266 return value().isValid();
271 return !command().isEmpty();
291 DClass<GameCVarProvider>
297 GameCVarProvider::GameCVarProvider()
301 GameCVarProvider::~GameCVarProvider()
307 return QList<GameCVar>();
335 GameMode::~GameMode()
342 result.setTeamGame(
false);
353 return ffaGame(SGM_Cooperative, QObject::tr(
"Cooperative"));
358 return ffaGame(SGM_Deathmatch, QObject::tr(
"Deathmatch"));
361 GameMode GameMode::mkTeamDeathmatch()
363 return teamGame(SGM_TeamDeathmatch, QObject::tr(
"Team DM"));
366 GameMode GameMode::mkCaptureTheFlag()
368 return teamGame(SGM_CTF, QObject::tr(
"CTF"));
373 return ffaGame(SGM_Unknown, QObject::tr(
"Unknown"));
388 return !d->name.isEmpty();
391 void GameMode::setTeamGame(
bool b)
399 result.setTeamGame(
true);
414 PWad::PWad(
const QString &name,
bool optional)
417 d->optional = optional;
void add(const DMFlag &flag)
Append a new DMFlag to this section.
const QString & name() const
Nice name to display to user in Create Game dialog and in other widgets.
const QString & name() const
User-friendly name to display for game mode.
const QString & internalName() const
static GameMode ffaGame(int index, const QString &name)
Construct a custom FFA game where players don't belong to any teams.
GameMode()
Constructs an invalid GameMode object.
void setValue(const QVariant &value)
Assign value() to this GameCVar.
bool isValid() const
'Null' objects are invalid.
A group of DMFlag objects that can be safely OR'ed together to form a meaningful value.
A game setting that is a part of a group of settings that can be OR'ed logically as a single integer...
const QVariant & value() const
Passed as the second argument, following command().
int count() const
Number of DMFlag objects inside the collection.
virtual QList< GameCVar > get(const QVariant &context)
Default implementation creates empty set.
bool isTeamGame() const
Is this GameMode based on rivaling teams?
bool hasValue() const
Is any value assigned to this GameCVar.
const QString & internalName() const
Uniquely identifiable name within its DMFlagsSection, ex. "Jump is allowed" or "jumpisallowed".
bool isValid() const
'Null' objects are invalid.
const DMFlag & operator[](int index) const
Access DMFlag at specific index with '[]' operator.
const QString & name() const
Server's name.
Game mode representation.
DMFlagsSection removed(const DMFlagsSection &removals) const
Returns a copy of this list with specified DMFlags removed.
unsigned combineValues() const
Logical OR of all DMFlag::value() results in this collection.
unsigned value() const
Bits that represent this flag (usually just a single '1' bit).
int index() const
Index, either a StandardGameMode or custom defined by plugin.
const QString & name() const
User-displayable name of this section, ex. "Compatibility flags".
bool isValid() const
Valid objects have value() greater than zero.
bool isOptional() const
Is this WAD required to join the server?
static GameMode teamGame(int index, const QString &name)
Game mode based on rivaling teams.
DMFlagsSection copyEmpty() const
Copies section maintaining its properties but removing all flags.
const QString & name() const
User-displayable, translateable name of the DMFlag, ex. "Jump is allowed".
bool isEmpty() const
Does this section contain any dmflag?
A general game setting or variable (like fraglimit).
const QString & command() const
Command-line argument that sets this GameCVar.
static QList< DMFlagsSection > removedBySection(const QList< DMFlagsSection > &original, const QList< DMFlagsSection > &removals)
Matches sections by internalName() and calls removed() on them.
const QString & name() const
File name of the WAD.