SVN_SILENT made messages (.desktop file)
[kdegames.git] / kreversi / highscores.cpp
blob7c7cb56a2b26fe0e909a2ae0d08d29ad6ed88952
1 /*
2 * Copyright (c) 2004 Nicolas HADACEK (hadacek@kde.org)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "highscores.h"
22 #include <klocale.h>
23 #include <kconfig.h>
24 #include <QVector>
25 #include <QDateTime>
26 #include <kglobal.h>
27 #include <kconfiggroup.h>
30 namespace KExtHighscore
33 ExtManager::ExtManager()
34 : Manager(7)
36 setShowMode( NeverShow );
37 setShowStatistics(true);
38 setShowDrawGamesStatistic(true);
40 const uint RANGE[6] = { 0, 32, 40, 48, 56, 64 };
41 QVector<uint> s;
42 s.resize(6);
43 qCopy(RANGE, RANGE + 6, s.begin());
44 setScoreHistogram(s, ScoreBound);
46 // FIXME dimsuz: somehow rearrange the code to be sure that this and in mainwindow.cpp are
47 // always in sync
48 m_typeLabels << i18n("Very Easy") << i18n("Easy") << i18n("Normal");
49 m_typeLabels << i18n("Hard") << i18n("Very Hard") << i18n("Unbeatable") << i18n("Champion");
53 QString ExtManager::gameTypeLabel(uint gameType, LabelType type) const
55 switch (type) {
56 case Standard:
57 return QString::number(gameType);
58 case I18N:
59 return m_typeLabels.at(gameType);
60 case Icon:
61 // FIXME dimsuz: implement
62 break;
63 case WW:
64 break;
67 return QString();
71 // FIXME dimsuz: is this still needed?
72 /*
73 void ExtManager::convertLegacy(uint gameType)
75 // Since there is no information about the skill level
76 // in the legacy highscore list, consider they are
77 // for beginner skill ...
78 if ( gameType!=0 )
79 return;
81 KConfigGroup cg(KGlobal::config(), "High Score");
83 for (uint i = 1; i <= 10; i++) {
84 QString key = "Pos" + QString::number(i);
85 QString name = cg.readEntry(key + "Name", QString());
87 if ( name.isEmpty() )
88 name = i18n("anonymous");
90 uint score = cg.readEntry(key + "NumChips", (uint)0);
91 if ( score==0 )
92 continue;
94 QString sdate = cg.readEntry(key + "Date", QString());
95 QDateTime date = QDateTime::fromString(sdate);
96 Score s(Won);
98 s.setScore(score);
99 s.setData("name", name);
100 if ( date.isValid() )
101 s.setData("date", date);
102 submitLegacyScore(s);
108 } // Namespace