1 /*
2 SPDX-FileCopyrightText: 2004 Nicolas HADACEK <hadacek@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #include "highscores.h"
8
9 #include <QDateTime>
10 #include <QVector>
11
12 #include <KLocalizedString>
13 #include <KConfigGroup>
14 #include <KConfig>
15 #include <KgDifficulty>
16
17 namespace KExtHighscore
18 {
19
ExtManager()20 ExtManager::ExtManager()
21 : Manager(7)
22 {
23 setShowMode(NeverShow);
24 setShowStatistics(true);
25 setShowDrawGamesStatistic(true);
26
27 const uint RANGE[6] = { 0, 32, 40, 48, 56, 64 };
28 QVector<uint> s;
29 s.resize(6);
30 std::copy(RANGE, RANGE+6, s.begin());
31 setScoreHistogram(s, ScoreBound);
32
33 QList< const KgDifficultyLevel * > diffList = Kg::difficulty()->levels();
34
35 for (int i = 0; i < diffList.size(); i++)
36 m_typeLabels << diffList.at(i)->title();
37 }
38
39
gameTypeLabel(uint gameType,LabelType type) const40 QString ExtManager::gameTypeLabel(uint gameType, LabelType type) const
41 {
42 switch (type) {
43 case Standard:
44 return QString::number(gameType);
45 case I18N:
46 return m_typeLabels.at(gameType);
47 case Icon:
48 // FIXME dimsuz: implement
49 break;
50 case WW:
51 break;
52 }
53
54 return QString();
55 }
56
57
58 // FIXME dimsuz: is this still needed?
59 /*
60 void ExtManager::convertLegacy(uint gameType)
61 {
62 // Since there is no information about the skill level
63 // in the legacy highscore list, consider they are
64 // for beginner skill ...
65 if ( gameType!=0 )
66 return;
67
68 KConfigGroup cg(KSharedConfig::openConfig(), "High Score");
69
70 for (uint i = 1; i <= 10; i++) {
71 QString key = "Pos" + QString::number(i);
72 QString name = cg.readEntry(key + "Name", QString());
73
74 if ( name.isEmpty() )
75 name = i18n("anonymous");
76
77 uint score = cg.readEntry(key + "NumChips", (uint)0);
78 if ( score==0 )
79 continue;
80
81 QString sdate = cg.readEntry(key + "Date", QString());
82 QDateTime date = QDateTime::fromString(sdate);
83 Score s(Won);
84
85 s.setScore(score);
86 s.setData("name", name);
87 if ( date.isValid() )
88 s.setData("date", date);
89 submitLegacyScore(s);
90 }
91 }
92 */
93
94
95 } // Namespace KExtHighscore
96