File indexing completed on 2024-05-12 04:03:07

0001 /*
0002     SPDX-FileCopyrightText: 20011 Julian Helfferich <julian.helfferich@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef LEVELLOADER_H
0008 #define LEVELLOADER_H
0009 
0010 // Qt
0011 #include <QObject>
0012 
0013 class QDomDocument;
0014 class QDomElement;
0015 
0016 class LevelLoader : public QObject
0017 {
0018     Q_OBJECT
0019 public:
0020     explicit LevelLoader(QObject *parent = nullptr);
0021     ~LevelLoader() override;
0022 
0023     int level() const;
0024     void setLevel(int level);
0025     QString levelset() const;
0026     void setLevelset(const QString &levelname);
0027 
0028     void loadLevel();
0029 
0030 Q_SIGNALS:
0031     void newLine(const QString &line, int lineNumber);
0032     void newGift(const QString &giftType, int times, const QString &position);
0033 
0034 private:
0035     void loadLine(QDomElement lineNode);
0036     void loadGift(QDomElement giftNode);
0037 
0038     void loadOldStyleLevel();
0039 
0040     QDomDocument *m_levelset;
0041     bool m_oldstyle;
0042 
0043     int m_lineNumber;
0044     QString m_levelname;
0045     int m_level;
0046 };
0047 
0048 // Global list of gift types
0049 // Can be removed, when KConfig levelsets are no longer supported
0050 
0051 const QString GIFT_TYPES[] = {
0052     QStringLiteral("Gift100Points"),
0053     QStringLiteral("Gift200Points"),
0054     QStringLiteral("Gift500Points"),
0055     QStringLiteral("Gift1000Points"),
0056     QStringLiteral("GiftAddLife"),
0057 
0058     QStringLiteral("GiftLoseLife"),
0059     QStringLiteral("GiftNextLevel"),
0060     QStringLiteral("GiftSplitBall"),
0061     QStringLiteral("GiftAddBall"),
0062     QStringLiteral("GiftDecreaseSpeed"),
0063 
0064     QStringLiteral("GiftIncreaseSpeed"),
0065     QStringLiteral("GiftUnstoppableBall"),
0066     QStringLiteral("GiftBurningBall"),
0067     QStringLiteral("GiftMagicWand"),
0068     QStringLiteral("GiftMagicEye"),
0069 
0070     QStringLiteral("GiftEnlargeBar"),
0071     QStringLiteral("GiftShrinkBar"),
0072     QStringLiteral("GiftStickyBar"),
0073     QStringLiteral("GiftMoreExplosion")
0074 };
0075 
0076 // IMPORTANT: keep in sync with the above
0077 const int GIFT_TYPES_COUNT = 19;
0078 
0079 #endif // LEVELLOADER_H