libkdegames
#include <KgDifficulty>
Public Slots | |
void | select (const KgDifficultyLevel *level) |
Signals | |
void | currentLevelChanged (const KgDifficultyLevel *level) |
void | editableChanged (bool editable) |
void | gameRunningChanged (bool gameRunning) |
void | selectedLevelChanged (const KgDifficultyLevel *level) |
Public Member Functions | |
KgDifficulty (QObject *parent=0) | |
virtual | ~KgDifficulty () |
void | addLevel (KgDifficultyLevel *level) |
void | addStandardLevel (KgDifficultyLevel::StandardLevel level, bool isDefault=false) |
void | addStandardLevelRange (KgDifficultyLevel::StandardLevel from, KgDifficultyLevel::StandardLevel to) |
void | addStandardLevelRange (KgDifficultyLevel::StandardLevel from, KgDifficultyLevel::StandardLevel to, KgDifficultyLevel::StandardLevel defaultLevel) |
const KgDifficultyLevel * | currentLevel () const |
bool | isEditable () const |
bool | isGameRunning () const |
QList< const KgDifficultyLevel * > | levels () const |
void | setEditable (bool editable) |
void | setGameRunning (bool running) |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QObject (QObject *parent, const char *name) | |
virtual | ~QObject () |
bool | blockSignals (bool block) |
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const |
const QObjectList & | children () const |
const char * | className () const |
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const QObject *receiver, const char *method) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QByteArray > | dynamicPropertyNames () const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name) const |
QList< T > | findChildren (const QRegExp ®Exp) const |
QList< T > | findChildren (const QString &name) const |
bool | inherits (const char *className) const |
void | insertChild (QObject *object) |
void | installEventFilter (QObject *filterObj) |
bool | isA (const char *className) const |
bool | isWidgetType () const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
const char * | name () const |
const char * | name (const char *defaultName) const |
QString | objectName () const |
QObject * | parent () const |
QVariant | property (const char *name) const |
void | removeChild (QObject *object) |
void | removeEventFilter (QObject *obj) |
void | setName (const char *name) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval) |
QThread * | thread () const |
Properties | |
const KgDifficultyLevel | currentLevel |
bool | editable |
bool | gameRunning |
const KgDifficultyLevel | selectedLevel |
Properties inherited from QObject | |
objectName | |
Additional Inherited Members | |
Static Public Member Functions inherited from QObject | |
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Protected Member Functions inherited from QObject | |
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method) |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const char *signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const char *signal) |
int | receivers (const char *signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Static Protected Member Functions inherited from QObject | |
QByteArray | normalizeSignalSlot (const char *signalSlot) |
Detailed Description
KgDifficulty manages difficulty levels of a game in a standard way.
The difficulty can be a type of game (like in KMines: small or big field) or the AI skills (like in Bovo: how deep should the computer search to find the best move) or a combination of both of them. On the user point of view, it's not really different: either is the game easy or hard to play.
KgDifficulty contains a list of KgDifficultyLevel instances. One of these levels is selected; this selection will be recorded when the application is closed. A set of standard difficulty levels is provided by KgDifficultyLevel, but custom levels can be defined at the same time.
Definition at line 96 of file kgdifficulty.h.
Constructor & Destructor Documentation
|
explicit |
Definition at line 153 of file kgdifficulty.cpp.
|
virtual |
Destroys this instance and all DifficultyLevel instances in it.
Definition at line 160 of file kgdifficulty.cpp.
Member Function Documentation
void KgDifficulty::addLevel | ( | KgDifficultyLevel * | level | ) |
Adds a difficulty level to this instance.
This will not affect the currentLevel() if there is one.
Definition at line 178 of file kgdifficulty.cpp.
void KgDifficulty::addStandardLevel | ( | KgDifficultyLevel::StandardLevel | level, |
bool | isDefault = false |
||
) |
A shortcut for addLevel(new KgDifficultyLevel(level)).
Definition at line 200 of file kgdifficulty.cpp.
void KgDifficulty::addStandardLevelRange | ( | KgDifficultyLevel::StandardLevel | from, |
KgDifficultyLevel::StandardLevel | to | ||
) |
This convenience method adds a range of standard levels to this instance (including the boundaries).
For example:
This adds the levels "Easy", "Medium", "Hard" and "Very hard".
Definition at line 205 of file kgdifficulty.cpp.
void KgDifficulty::addStandardLevelRange | ( | KgDifficultyLevel::StandardLevel | from, |
KgDifficultyLevel::StandardLevel | to, | ||
KgDifficultyLevel::StandardLevel | defaultLevel | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This overload allows to specify a defaultLevel.
Definition at line 211 of file kgdifficulty.cpp.
const KgDifficultyLevel* KgDifficulty::currentLevel | ( | ) | const |
- Returns
- the current difficulty level
After the KgDifficulty object has been created, the current difficulty level will not be determined until this method is called for the first time. This allows the application developer to set up the difficulty levels before KgDifficulty retrieves the last selected level from the configuration file.
|
signal |
Emitted when a new difficulty level has been selected.
|
signal |
Emitted when the editability changes.
- See also
- setEditable
|
signal |
Emitted when a running game has been marked or unmarked.
- See also
- setGameRunning
bool KgDifficulty::isEditable | ( | ) | const |
- Returns
- whether the difficulty level selection may be edited
Definition at line 270 of file kgdifficulty.cpp.
bool KgDifficulty::isGameRunning | ( | ) | const |
- Returns
- whether a running game has been marked
- See also
- setGameRunning
Definition at line 285 of file kgdifficulty.cpp.
QList< const KgDifficultyLevel * > KgDifficulty::levels | ( | ) | const |
- Returns
- a list of all difficulty levels, sorted by hardness
Definition at line 236 of file kgdifficulty.cpp.
|
slot |
Select a new difficulty level.
The given level must already have been added to this instance.
- Note
- This does nothing if isEditable() is false. If a game is running (according to setGameRunning()), the user will be asked for confirmation before the new difficulty level is selected.
Definition at line 300 of file kgdifficulty.cpp.
|
signal |
Emitted after every call to select(), even when the user has rejected the change.
This is useful to reset a difficulty level selection UI after a rejected change.
void KgDifficulty::setEditable | ( | bool | editable | ) |
Set whether the difficulty level selection may be edited.
The default value is true.
Definition at line 275 of file kgdifficulty.cpp.
void KgDifficulty::setGameRunning | ( | bool | running | ) |
KgDifficulty has optional protection against changing the difficulty level while a game is running.
If setGameRunning(true) has been called, and select() is called to select a new difficulty level, the user will be asked for confirmation.
Definition at line 290 of file kgdifficulty.cpp.
Property Documentation
|
readwrite |
Definition at line 101 of file kgdifficulty.h.
|
readwrite |
Definition at line 103 of file kgdifficulty.h.
|
readwrite |
Definition at line 104 of file kgdifficulty.h.
|
readwrite |
Definition at line 102 of file kgdifficulty.h.
The documentation for this class was generated from the following files:
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.