VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Environment.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 ENVIRONMENT_H
18 #define ENVIRONMENT_H
19 
20 #include <QObject>
21 #include <QQmlListProperty>
22 #include <QString>
23 
24 class LevelInfo;
25 class LevelProgression;
26 
37 class Environment : public QObject {
38  Q_OBJECT
39 
43  Q_PROPERTY(QString name READ getName WRITE setName NOTIFY nameChanged)
52  Q_PROPERTY(QString bgmTrack READ getBGMTrack WRITE setBGMTrack NOTIFY bgmTrackChanged)
81 
82 public:
87  explicit Environment(QObject* parent = nullptr);
88 
92  const QString& getName() const { return mName; }
97  void setName(const QString& value);
101  QList<LevelInfo*>& getLevelInfos() { return mLevelInfos; }
105  const QList<LevelInfo*>& getLevelInfos() const { return mLevelInfos; }
113  const QString& getBGMTrack() const { return mBGMTrack; }
118  void setBGMTrack(const QString& value);
122  const QString& getScreenshotFileName() const { return mScreenshotFileName; }
127  void setScreenshotFileName(const QString& value);
131  const QString& getAchievementToUnlockOnPassing() const { return mAchievementToUnlockOnPassing; }
136  void setAchievementToUnlockOnPassing(const QString& value);
141  return mAchievementToUnlockOnCompletion;
142  }
147  void setAchievementToUnlockOnCompletion(const QString& value);
151  QStringList& getAchievementsToRevealOnPassing() { return mAchievementsToRevealOnPassing; }
156  return mAchievementsToRevealOnPassing;
157  }
167 
172  Q_INVOKABLE LevelInfo* getLevelInfoByName(const QString& levelName) const;
178  Q_INVOKABLE int getIndexOfLevelInfo(const QString& levelName) const;
179 
180 signals:
184  void nameChanged();
188  void levelInfosChanged();
192  void bgmTrackChanged();
209 
210 private:
211  QString mName;
212  QList<LevelInfo*> mLevelInfos;
213  QString mBGMTrack;
214  QString mScreenshotFileName;
215  QString mAchievementToUnlockOnPassing;
216  QString mAchievementToUnlockOnCompletion;
217  QStringList mAchievementsToRevealOnPassing;
218  mutable LevelProgression* mLevelProgression = nullptr;
219 };
220 Q_DECLARE_METATYPE(Environment*)
221 
222 #endif // ENVIRONMENT_H
void screenshotFileNameChanged()
Emitted when screenshotFileName changes.
QString bgmTrack
Name of sound asset file to be played in a loop as background music.
Definition: Environment.h:52
QString achievementToUnlockOnPassing
Name of the achievement to unlock upon "passing" the environment, which is defined as minimally earni...
Definition: Environment.h:63
void achievementsToRevealOnPassingChanged()
Emitted when achievementsToRevealOnPassing changes.
QQmlListProperty< LevelInfo > levelInfos
QML mutable list of levels that compose the Environment.
Definition: Environment.h:48
void setAchievementToUnlockOnCompletion(const QString &value)
Sets achievementToUnlockOnCompletion.
LevelProgression * getLevelProgression() const
Returns levelProgression.
void levelInfosChanged()
Emitted when levelInfos changes.
Metadata for a Level.
Definition: LevelInfo.h:31
LevelProgression levelProgression
LevelProgression to which this LevelInfo belongs, or nullptr if defined out of the context of a Level...
Definition: Environment.h:80
void achievementToUnlockOnPassingChanged()
Emitted when achievementToUnlockOnPassing changes.
Grouping of related Environments together into a logical, ordered list.
Definition: LevelProgression.h:34
const QString & getScreenshotFileName() const
Returns screenshotFileName.
Definition: Environment.h:122
void bgmTrackChanged()
Emitted when bgmTrack changes.
const QList< LevelInfo * > & getLevelInfos() const
Returns levelInfos as a const QList.
Definition: Environment.h:105
void setBGMTrack(const QString &value)
Sets bgmTrack.
void setScreenshotFileName(const QString &value)
Sets screenshotFileName.
void setName(const QString &value)
Sets name.
void setAchievementsToRevealOnPassing(const QStringList &value)
Sets achievementsToRevealOnPassing.
const QString & getName() const
Returns name.
Definition: Environment.h:92
const QString & getBGMTrack() const
Returns bgmTrack.
Definition: Environment.h:113
QString screenshotFileName
Name of image asset file for the Environment screenshot / thumbnail.
Definition: Environment.h:57
QString name
Human-readable name of the Environment.
Definition: Environment.h:43
const QString & getAchievementToUnlockOnPassing() const
Returns achievementToUnlockOnPassing.
Definition: Environment.h:131
QStringList & getAchievementsToRevealOnPassing()
Returns achievementsToRevealOnPassing.
Definition: Environment.h:151
QList< LevelInfo * > & getLevelInfos()
Returns levelInfos as a QList.
Definition: Environment.h:101
void setAchievementToUnlockOnPassing(const QString &value)
Sets achievementToUnlockOnPassing.
const QString & getAchievementToUnlockOnCompletion() const
Returns achievementToUnlockOnCompletion.
Definition: Environment.h:140
Q_INVOKABLE int getIndexOfLevelInfo(const QString &levelName) const
Returns the index of the child LevelInfo identified by levelName, or -1 if not found.
void achievementToUnlockOnCompletionChanged()
Emitted when achievementToUnlockOnCompletion changes.
void nameChanged()
Emitted when name changes.
Q_INVOKABLE LevelInfo * getLevelInfoByName(const QString &levelName) const
Returns the child LevelInfo identified by levelName, or nullptr if not found.
Grouping of related LevelInfos together into an logical, ordered list.
Definition: Environment.h:37
QString achievementToUnlockOnCompletion
Name of the achievement to unlock upon "completing" the environment, which is defined as minimally ea...
Definition: Environment.h:69
QObject * parent() const
QQmlListProperty< LevelInfo > getLevelInfosListProperty()
Returns levelInfos.
QStringList achievementsToRevealOnPassing
Names of the achievements to reveal upon "passing" the environment, which is defined as minimally ear...
Definition: Environment.h:75
const QStringList & getAchievementsToRevealOnPassing() const
Returns achievementsToRevealOnPassing.
Definition: Environment.h:155