libkdegames/libkdegamesprivate
kgamedifficulty.cpp
Go to the documentation of this file.
5 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
7 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.
9 You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
37 void init(KXmlGuiWindow* window, const QObject* recvr, const char* slotStandard, const char* slotCustom);
104 void KGameDifficultyPrivate::init(KXmlGuiWindow* window, const QObject* recvr, const char* slotStandard, const char* slotCustom = 0)
112 QObject::connect(this, SIGNAL(standardLevelChanged(KGameDifficulty::standardLevel)), recvr, slotStandard);
116 m_menu = new KSelectAction(KIcon( QLatin1String( "games-difficult") ), i18nc("Game difficulty level", "Difficulty" ), window);
140 mayChange = ( KMessageBox::warningContinueCancel(0, i18n("Changing the difficulty level will end the current game!"), QString(), KGuiItem(i18n("Change the difficulty level"))) == KMessageBox::Continue );
151 QPair<QByteArray, QString> KGameDifficultyPrivate::standardLevelString(KGameDifficulty::standardLevel level)
153 //The first entry in the pair is to be used as a key so don't change it. It doesn't have to match the string to be translated
156 return qMakePair(QByteArray("Ridiculously Easy"), i18nc("Game difficulty level 1 out of 8", "Ridiculously Easy"));
158 return qMakePair(QByteArray("Very Easy"), i18nc("Game difficulty level 2 out of 8", "Very Easy"));
166 return qMakePair(QByteArray("Very Hard"), i18nc("Game difficulty level 6 out of 8", "Very Hard"));
168 return qMakePair(QByteArray("Extremely Hard"), i18nc("Game difficulty level 7 out of 8", "Extremely Hard"));
170 return qMakePair(QByteArray("Impossible"), i18nc("Game difficulty level 8 out of 8", "Impossible"));
189 m_comboBox->addItem(KIcon( QLatin1String( "games-difficult" )), standardLevelString(level).second);
205 QString s = i18nc("Name of the game difficulty level that is customized by the user by setting up different game parameters", "Custom");
223 if ((m_standardLevels.contains(KGameDifficulty::Configurable)) && (newSelection>m_menu->actions().count()-3))
228 KGameDifficulty::setLevelCustom((m_customLevels.uniqueKeys()).value(newSelection - countWithoutConfigurable));
292 void KGameDifficulty::init(KXmlGuiWindow* window, const QObject* recvr, const char* slotStandard, const char* slotCustom)
304 self()->d->m_comboBox->setWhatsThis(i18n("Select the <b>difficulty</b> of the game.<br />If you change the difficulty level while a game is running, you will have to cancel it and start a new one."));
306 self()->d->m_comboBox->setWhatsThis(i18n("Select the <b>difficulty</b> of the game.<br />You can change the difficulty level during a running game."));
353 // TODO: Doing this never disable the combobox in the toolbar (just in the menu). It seems to be a bug in the class KSelectAction of kdelibs/kdeui/actions. To check and solve...
413 levelStrings.insert(self()->d->standardLevelString(RidiculouslyEasy).first, self()->d->standardLevelString(RidiculouslyEasy).second);
414 levelStrings.insert(self()->d->standardLevelString(VeryEasy).first, self()->d->standardLevelString(VeryEasy).second);
415 levelStrings.insert(self()->d->standardLevelString(Easy).first, self()->d->standardLevelString(Easy).second);
416 levelStrings.insert(self()->d->standardLevelString(Medium).first, self()->d->standardLevelString(Medium).second);
417 levelStrings.insert(self()->d->standardLevelString(Hard).first, self()->d->standardLevelString(Hard).second);
418 levelStrings.insert(self()->d->standardLevelString(VeryHard).first, self()->d->standardLevelString(VeryHard).second);
419 levelStrings.insert(self()->d->standardLevelString(ExtremelyHard).first, self()->d->standardLevelString(ExtremelyHard).second);
420 levelStrings.insert(self()->d->standardLevelString(Impossible).first, self()->d->standardLevelString(Impossible).second);
static void addCustomLevel(int key, const QString &appellation)
Add a custom difficulty level.
Definition: kgamedifficulty.cpp:331
void setSeparator(bool b)
static QPair< QByteArray, QString > localizedLevelString()
Definition: kgamedifficulty.cpp:399
static int levelCustom()
Get the current custom difficulty level.
Definition: kgamedifficulty.cpp:375
static QMap< QByteArray, QString > localizedLevelStrings()
Definition: kgamedifficulty.cpp:407
KGameDifficuty manages the game difficulty levels in a standard way.
Definition: kgamedifficulty.h:78
static void removeStandardLevel(standardLevel level)
Remove a standard difficulty level.
Definition: kgamedifficulty.cpp:322
static standardLevel level()
Get the current standard difficulty level.
Definition: kgamedifficulty.cpp:383
static void setLevelCustom(int key)
Set the new current difficulty level as a custom one.
Definition: kgamedifficulty.cpp:367
static void setLevel(standardLevel level)
Set the new current difficulty level as a standard one.
Definition: kgamedifficulty.cpp:359
static void removeCustomLevel(int key)
Remove a custom difficulty level.
Definition: kgamedifficulty.cpp:340
static void setRunning(bool running)
Set the game state: Running or not.
Definition: kgamedifficulty.cpp:442
iterator insert(const Key &key, const T &value)
static void setRestartOnChange(onChange restart)
Set if a new game has to be started by change.
Definition: kgamedifficulty.cpp:298
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
static void addStandardLevel(standardLevel level)
Add a standard difficulty level.
Definition: kgamedifficulty.cpp:311
The current game has to be canceled and a new game will be started on change.
Definition: kgamedifficulty.h:87
static void init(KXmlGuiWindow *window, const QObject *recvr, const char *slotStandard, const char *slotCustom=0)
Initialize the difficulty class.
Definition: kgamedifficulty.cpp:292
static QMap< int, QByteArray > levelWeights()
Definition: kgamedifficulty.cpp:425
static void setEnabled(bool enabled)
Set if the difficulty level may be changed.
Definition: kgamedifficulty.cpp:349
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:50 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:50 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.