• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

libkdegames

  • sources
  • kde-4.14
  • kdegames
  • libkdegames
kgdifficulty.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright 2007 Nicolas Roffet <nicolas-kde@roffet.com> *
3  * Copyright 2007 Pino Toscano <toscano.pino@tiscali.it> *
4  * Copyright 2011-2012 Stefan Majewsky <majewsky@gmx.net> *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU Library General Public License *
8  * version 2 as published by the Free Software Foundation *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU Library General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU Library General Public *
16  * License along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef KGDIFFICULTY_H
22 #define KGDIFFICULTY_H
23 
24 #include <QtCore/QMetaType>
25 #include <QtCore/QObject>
26 
27 #include <libkdegames_export.h>
28 
33 class KDEGAMES_EXPORT KgDifficultyLevel : public QObject
34 {
35  Q_OBJECT
36  Q_DISABLE_COPY(KgDifficultyLevel)
37  Q_PROPERTY(bool default READ isDefault)
38  Q_PROPERTY(int hardness READ hardness)
39  Q_PROPERTY(QByteArray key READ key)
40  Q_PROPERTY(QString title READ title)
41  Q_ENUMS(StandardLevel)
42  Q_PROPERTY(StandardLevel standardLevel READ standardLevel)
43  public:
44  enum StandardLevel
45  {
46  Custom = -1,
47  RidiculouslyEasy = 10,
48  VeryEasy = 20,
49  Easy = 30,
50  Medium = 40,
51  Hard = 50,
52  VeryHard = 60,
53  ExtremelyHard = 70,
54  Impossible = 80
55  };
56 
58  KgDifficultyLevel(int hardness, const QByteArray& key, const QString& title, bool isDefault = false);
59  explicit KgDifficultyLevel(StandardLevel level, bool isDefault = false);
60  virtual ~KgDifficultyLevel();
61 
64  bool isDefault() const;
69  int hardness() const;
71  QByteArray key() const;
73  QString title() const;
76  StandardLevel standardLevel() const;
77  private:
78  class Private;
79  Private* const d;
80 };
81 
96 class KDEGAMES_EXPORT KgDifficulty : public QObject
97 {
98  Q_OBJECT
99  Q_DISABLE_COPY(KgDifficulty)
100  //Use currentLevel in game logic and selectedLevel in level selection UI.
101  Q_PROPERTY(const KgDifficultyLevel* currentLevel READ currentLevel WRITE select NOTIFY currentLevelChanged)
102  Q_PROPERTY(const KgDifficultyLevel* selectedLevel READ currentLevel WRITE select NOTIFY selectedLevelChanged)
103  Q_PROPERTY(bool editable READ isEditable WRITE setEditable NOTIFY editableChanged)
104  Q_PROPERTY(bool gameRunning READ isGameRunning WRITE setGameRunning NOTIFY gameRunningChanged)
105  public:
106  explicit KgDifficulty(QObject* parent = 0);
108  virtual ~KgDifficulty();
109 
112  void addLevel(KgDifficultyLevel* level);
114  void addStandardLevel(KgDifficultyLevel::StandardLevel level, bool isDefault = false);
124  void addStandardLevelRange(KgDifficultyLevel::StandardLevel from, KgDifficultyLevel::StandardLevel to);
127  void addStandardLevelRange(KgDifficultyLevel::StandardLevel from, KgDifficultyLevel::StandardLevel to, KgDifficultyLevel::StandardLevel defaultLevel);
128 
130  QList<const KgDifficultyLevel*> levels() const;
138  const KgDifficultyLevel* currentLevel() const;
139 
141  bool isEditable() const;
143  bool isGameRunning() const;
146  void setEditable(bool editable);
151  void setGameRunning(bool running);
152  Q_SIGNALS:
154  void editableChanged(bool editable);
156  void gameRunningChanged(bool gameRunning);
158  void currentLevelChanged(const KgDifficultyLevel* level);
162  void selectedLevelChanged(const KgDifficultyLevel* level);
163  public Q_SLOTS:
169  void select(const KgDifficultyLevel* level);
170  private:
171  class Private;
172  Private* const d;
173 };
174 
175 Q_DECLARE_METATYPE(const KgDifficultyLevel*)
176 
177 //TODO: Where to put documentation for this namespace?
178 namespace Kg
179 {
181  KDEGAMES_EXPORT KgDifficulty* difficulty();
183  KDEGAMES_EXPORT KgDifficultyLevel::StandardLevel difficultyLevel();
184 }
185 
186 class KXmlGuiWindow;
187 
188 //TODO KDE5: move this into a separate QtWidgets support library
189 namespace KgDifficultyGUI
190 {
195  KDEGAMES_EXPORT void init(KXmlGuiWindow* window, KgDifficulty* difficulty = 0);
196 }
197 
198 #endif // KGDIFFICULTY_H
QByteArray
libkdegames_export.h
KgDifficultyLevel::StandardLevel
StandardLevel
Definition: kgdifficulty.h:44
Kg::difficulty
KDEGAMES_EXPORT KgDifficulty * difficulty()
Definition: kgdifficulty.cpp:329
KDEGAMES_EXPORT
#define KDEGAMES_EXPORT
Definition: libkdegames_export.h:32
QObject
Kg::difficultyLevel
KDEGAMES_EXPORT KgDifficultyLevel::StandardLevel difficultyLevel()
A shortcut for Kg::difficulty()->currentLevel()->standardLevel().
Definition: kgdifficulty.cpp:334
QString
QList
KgDifficultyGUI::init
KDEGAMES_EXPORT void init(KXmlGuiWindow *window, KgDifficulty *difficulty=0)
Install standard GUI components for the manipulation of the given KgDifficulty instance in the given ...
Definition: kgdifficulty.cpp:374
KgDifficultyLevel
Definition: kgdifficulty.h:33
KgDifficulty
KgDifficulty manages difficulty levels of a game in a standard way.
Definition: kgdifficulty.h:96
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:42 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkdegames

Skip menu "libkdegames"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal