[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/games/magazynier
From: Niels Slot <nielsslot () gmail ! com>
Date: 2009-04-04 14:54:08
Message-ID: 1238856848.555464.25407.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 949140 by nielsslot:
Add highscores. (Still needs some work)
- 'Show highscore' item in the menu
- Add a new highscore when the player completes a level
Open issues:
- Currently it adds everything to the highscore table (Time, Level #, Level pack \
name). This might be a bit to much. (Maybe we can use the tabs in the \
score dialog?)
- The current score is _always_ 10. I haven't come up with a nice formula for \
determining the score yet. (Suggestions are welcome)
- After entering a score, if the player makes another move, the score dialog comes up \
again. Should not be difficult to fix (maybe only give the 'levelCompleted' signal \
once per LevelModel instance)
M +5 -0 levelModel.cpp
M +1 -0 levelModel.h
M +31 -0 window.cpp
M +2 -0 window.h
--- trunk/playground/games/magazynier/levelModel.cpp #949139:949140
@@ -364,4 +364,9 @@
return;
} //}}}
+int LevelModel::getMoveCount() //{{{
+{
+ return m_moveCount;
+} //}}}
+
// vim: foldmethod=marker
--- trunk/playground/games/magazynier/levelModel.h #949139:949140
@@ -52,6 +52,7 @@
int getColumnCount(void);
int getRowCount(void);
+ int getMoveCount(void);
void moveFromEmptyToEmpty(QPoint pos, QPoint delta);
void moveFromEmptyToGoal(QPoint pos, QPoint delta);
--- trunk/playground/games/magazynier/window.cpp #949139:949140
@@ -29,6 +29,7 @@
#include <KLocale>
#include <KMenu>
#include <KMenuBar>
+#include <KScoreDialog>
#include <KStandardDirs>
#include <KStandardGameAction>
#include <KStatusBar>
@@ -132,6 +133,9 @@
{
KStandardGameAction::quit(this, SLOT(close()), actionCollection());
+ KStandardGameAction::highscores(this, SLOT(showHighscore()),
+ actionCollection());
+
m_undoStack->createUndoAction(actionCollection(), "");
m_undoStack->createRedoAction(actionCollection(), "");
@@ -224,6 +228,8 @@
this, SLOT(updateLevelChangeActions(void)));
connect(newLevelModel, SIGNAL(levelCompleted(void)),
m_gameClock, SLOT(pause(void)));
+ connect(newLevelModel, SIGNAL(levelCompleted(void)),
+ this, SLOT(addHighscore(void)));
statusBar()->changeItem(
i18n(
@@ -349,5 +355,30 @@
}
} //}}}
+void MagazynierWindow::showHighscore(void) //{{{
+{
+ KScoreDialog scoreDialog(KScoreDialog::Name | KScoreDialog::Time | \
KScoreDialog::Level, this); + scoreDialog.addField(KScoreDialog::Custom1, \
i18n("Number of moves"), "moves"); + scoreDialog.addField(KScoreDialog::Custom2, \
i18n("Level pack"), "level-pack"); + scoreDialog.exec();
+} //}}}
+
+void MagazynierWindow::addHighscore(void) //{{{
+{
+ KScoreDialog::FieldInfo scoreInfo;
+ scoreInfo[KScoreDialog::Time] = m_gameClock->timeString();
+ scoreInfo[KScoreDialog::Level].setNum(m_levelPack->getCurrentLevelNumber());
+ scoreInfo[KScoreDialog::Custom1].setNum(m_levelModel->getMoveCount());
+ scoreInfo[KScoreDialog::Custom2] = m_levelPack->getName();
+ scoreInfo[KScoreDialog::Score].setNum(10); //TODO: Think of something that makes \
sense as a score +
+ KScoreDialog scoreDialog(KScoreDialog::Name | KScoreDialog::Time | \
KScoreDialog::Level, this); + scoreDialog.addField(KScoreDialog::Custom1, \
i18n("Number of moves"), "moves"); + scoreDialog.addField(KScoreDialog::Custom2, \
i18n("Level pack"), "level-pack"); +
+ scoreDialog.addScore(scoreInfo);
+ scoreDialog.exec();
+} //}}}
+
// vim: foldmethod=marker
--- trunk/playground/games/magazynier/window.h #949139:949140
@@ -71,6 +71,8 @@
void configureSettings(void);
void reloadTheme(void);
void updateTimer(void);
+ void showHighscore(void);
+ void addHighscore(void);
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic