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