File indexing completed on 2024-05-19 07:51:09

0001 /*
0002     SPDX-FileCopyrightText: 2009 Mathias Kraus <k.hias@gmx.de>
0003     SPDX-FileCopyrightText: 2007 Mauricio Piacentini <mauricio@tabuleiro.com>
0004     SPDX-FileCopyrightText: 2007 Matt Williams <matt@milliams.com>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef ARENASETTINGS_H
0010 #define ARENASETTINGS_H
0011 
0012 #include <QString>
0013 
0014 class ArenaSettingsPrivate;
0015 
0016 /**
0017  * \class ArenaSettings arenasettings.h <ArenaSettings>
0018  * 
0019  * @short Class for loading arena files
0020  *
0021  * Essentially just a wrapper around a .desktop arena file. Load a file with
0022  * load() and then access its properties.
0023  *
0024  * For more advanced feaures like dynamic arenas or custom game rules, it
0025  * will likely be necessary to derive from this class
0026  *
0027  * @author Mauricio Piacentini
0028  **/
0029 class ArenaSettings
0030 {
0031     public:
0032         explicit ArenaSettings(const QString &arenaGroup = QStringLiteral("Arena"));
0033         virtual ~ArenaSettings();
0034 
0035         /**
0036          * Load the default arena file. Called "granatier.desktop"
0037          * @return true if the arena files and properties could be loaded
0038          */
0039         virtual bool loadDefault();
0040         /**
0041          * Load a specific arena file.
0042          * Note that although arena could be successfully loaded,
0043          * no check on the validity of arena's XML file contents is done.
0044          * Application writers will need to perform this check manually
0045          * @param file the name of the arena file relative to the share/apps/appname
0046          * directory. e.g. "arena/granatier.desktop"
0047          * @return true if the arena files and properties could be loaded
0048          */
0049         virtual bool load(const QString &file);
0050         /// @return the full path of the .desktop file
0051         QString path() const;
0052         /// @return just the "*.desktop" part
0053         QString fileName() const;
0054         /// @return the full path of the svg file which is specified in "FileName" key
0055         virtual QString graphics() const;
0056         /// @return a property directly from the .desktop file
0057         QString property(const QString &key) const;
0058         /**
0059          * Possible keys:
0060          * - Name
0061          * - Author
0062          * - Description
0063          * - AuthorEmail
0064          * @param key the key of the wanted property
0065          * @return the data related to 'key'
0066          */
0067         virtual QString arenaProperty(const QString &key) const;
0068 
0069     private:
0070         friend class ArenaSettingsPrivate;
0071         ArenaSettingsPrivate *const d;
0072 };
0073 
0074 #endif