VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
LevelProgression.h
1 /*
2  * Copyright (C) 2014 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef LEVELPROGRESSION_H
18 #define LEVELPROGRESSION_H
19 
20 #include <QObject>
21 #include <QQmlListProperty>
22 
23 class Environment;
24 class LevelInfo;
25 
34 class LevelProgression : public QObject {
35  Q_OBJECT
36 
40  Q_PROPERTY(QString name READ getName WRITE setName NOTIFY nameChanged)
44  Q_PROPERTY(bool multiplayer READ isMultiplayer WRITE setMultiplayer NOTIFY multiplayerChanged)
53  Q_PROPERTY(int numLevels READ getNumLevels)
65 
66 public:
71  explicit LevelProgression(QObject* parent = nullptr);
72 
76  const QString& getName() const { return mName; }
81  void setName(const QString& value);
85  bool isMultiplayer() const { return mMultiplayer; }
90  void setMultiplayer(bool value);
98  QList<Environment*>& getEnvironments() { return mEnvironments; }
102  const QList<Environment*>& getEnvironments() const { return mEnvironments; }
106  int getNumLevels() const;
110  const QString& getScreenshotFileName() const { return mScreenshotFileName; }
115  void setScreenshotFileName(const QString& value);
120  return mAchievementToUnlockOnPerfection;
121  }
126  void setAchievementToUnlockOnPerfection(const QString& value);
127 
131  Q_INVOKABLE bool isSinglePlayer() const { return !mMultiplayer; }
136  Q_INVOKABLE bool hasLevel(const QString& levelName) const;
141  Q_INVOKABLE LevelInfo* getLevelInfoByName(const QString& levelName) const;
145  Q_INVOKABLE LevelInfo* getStartingLevelInfo() const;
150  Q_INVOKABLE Environment* getEnvironmentByName(const QString& environmentName) const;
156  Q_INVOKABLE int getIndexOfEnvironment(const QString& environmentName) const;
162  Q_INVOKABLE Environment* getEnvironmentFromLevelName(const QString& levelName) const;
168  Q_INVOKABLE int getIndexOfEnvironmentFromLevelName(const QString& levelName) const;
180  Q_INVOKABLE LevelInfo* getNextLevelInfo(const QString& currentLevelName,
181  bool* wasLastLevel) const;
189  Q_INVOKABLE int compareLevels(const QString& levelNameA, const QString& levelNameB) const;
190 
191 signals:
195  void nameChanged();
199  void multiplayerChanged();
203  void environmentsChanged();
212 
213 private:
214  QString mName;
215  bool mMultiplayer = false;
216  QList<Environment*> mEnvironments;
217  QString mScreenshotFileName;
218  QString mAchievementToUnlockOnPerfection;
219 };
220 Q_DECLARE_METATYPE(LevelProgression*)
221 
222 #endif // LEVELPROGRESSION_H
int numLevels
Total number of levels that comprise this LevelProgression.
Definition: LevelProgression.h:53
Q_INVOKABLE LevelInfo * getLevelInfoByName(const QString &levelName) const
Returns child LevelInfo identified by levelName, or null if not found.
int getNumLevels() const
Returns numLevels.
Q_INVOKABLE LevelInfo * getNextLevelInfo(const QString &currentLevelName, bool *wasLastLevel) const
Returns the child LevelInfo representing the next level in the progression after the level identified...
Q_INVOKABLE int compareLevels(const QString &levelNameA, const QString &levelNameB) const
Compares the specified levels in terms of how far in the progression they are.
bool multiplayer
Whether or not the LevelProgression is for multiple players.
Definition: LevelProgression.h:44
QString screenshotFileName
Name of image asset file for the LevelProgression screenshot / thumbnail.
Definition: LevelProgression.h:58
QList< Environment * > & getEnvironments()
Returns environments as a QList.
Definition: LevelProgression.h:98
const QString & getScreenshotFileName() const
Returns screenshotFileName.
Definition: LevelProgression.h:110
Metadata for a Level.
Definition: LevelInfo.h:31
Q_INVOKABLE Environment * getEnvironmentFromLevelName(const QString &levelName) const
Returns child Environment containing a LevelInfo identified by levelName, or null if not found...
const QList< Environment * > & getEnvironments() const
Returns environments as a const QList.
Definition: LevelProgression.h:102
Grouping of related Environments together into a logical, ordered list.
Definition: LevelProgression.h:34
Q_INVOKABLE bool isSinglePlayer() const
Returns whether or not the LevelProgression is for only one player.
Definition: LevelProgression.h:131
QQmlListProperty< Environment > environments
QML mutable list of Envrionments that compose this progression.
Definition: LevelProgression.h:49
void achievementToUnlockOnPerfectionChanged()
Emitted when achievementToUnlockOnPerfection changes.
void environmentsChanged()
Emitted when environments changes.
void setName(const QString &value)
Sets name.
QString achievementToUnlockOnPerfection
Name of the achievement to unlock upon "perfecting" the progression, which is defined as earning all ...
Definition: LevelProgression.h:64
Q_INVOKABLE int getIndexOfEnvironment(const QString &environmentName) const
Returns the index of the child Environment identified by environmentName, or -1 if not found...
bool isMultiplayer() const
Returns multiplayer.
Definition: LevelProgression.h:85
Q_INVOKABLE int getIndexOfEnvironmentFromLevelName(const QString &levelName) const
Returns index of child Environment containing a LevelInfo identified by levelName, or -1 if not found.
QString name
Human-readable name of the LevelProgression.
Definition: LevelProgression.h:40
void setAchievementToUnlockOnPerfection(const QString &value)
Sets achievementToUnlockOnPerfection.
void nameChanged()
Emitted when name changes.
void setScreenshotFileName(const QString &value)
Sets screenshotFileName.
const QString & getName() const
Returns name.
Definition: LevelProgression.h:76
Q_INVOKABLE bool hasLevel(const QString &levelName) const
Returns whether or not the LevelProgression contains a LevelInfo named levelName. ...
Q_INVOKABLE Environment * getEnvironmentByName(const QString &environmentName) const
Returns child Environment identified by environmentName, or null if not found.
Q_INVOKABLE LevelInfo * getStartingLevelInfo() const
Returns child LevelInfo representing the first level in the progression.
void multiplayerChanged()
Emitted when multiplayer changes.
void screenshotFileNameChanged()
Emitted when screenshotFileName changes.
QQmlListProperty< Environment > getEnvironmentsListProperty()
Returns environments.
Grouping of related LevelInfos together into an logical, ordered list.
Definition: Environment.h:37
QObject * parent() const
void setMultiplayer(bool value)
Sets multiplayer.
const QString & getAchievementToUnlockOnPerfection() const
Returns achievementToUnlockOnPerfection.
Definition: LevelProgression.h:119