• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdegames
 

libtdegames

  • libtdegames
  • highscore
kexthighscore_item.h
1/*
2 This file is part of the TDE games library
3 Copyright (C) 2001-2003 Nicolas Hadacek (hadacek@kde.org)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
8
9 This library 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 GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KEXTHIGHSCORE_ITEM_H
21#define KEXTHIGHSCORE_ITEM_H
22
23#include <tqvariant.h>
24#include <tqnamespace.h>
25#include <tqmap.h>
26#include <tqvaluevector.h>
27#include <tdemacros.h>
28class TQWidget;
29
30
31namespace KExtHighscore
32{
33
34//-----------------------------------------------------------------------------
40class TDE_EXPORT Item
41{
42 public:
55 enum Format { NoFormat, OneDecimal, Percentage, MinuteTime,
56 DateTime };
57
72 enum Special { NoSpecial, ZeroNotDefined, NegativeNotDefined,
73 DefaultNotDefined, Anonymous };
74
84 Item(const TQVariant &def = TQVariant::Invalid,
85 const TQString &label = TQString(), int alignment = TQt::AlignRight);
86
87 virtual ~Item();
88
93 void setPrettyFormat(Format format);
94
99 void setPrettySpecial(Special special);
100
104 bool isVisible() const { return !_label.isEmpty(); }
105
109 void setLabel(const TQString &label) { _label = label; }
110
114 TQString label() const { return _label; }
115
119 int alignment() const { return _alignment; }
120
124 void setDefaultValue(const TQVariant &value) { _default = value; }
125
129 const TQVariant &defaultValue() const { return _default; }
130
138 virtual TQVariant read(uint i, const TQVariant &value) const;
139
147 virtual TQString pretty(uint i, const TQVariant &value) const;
148
149 private:
150 TQVariant _default;
151 TQString _label;
152 int _alignment;
153 Format _format;
154 Special _special;
155
156 class ItemPrivate;
157 ItemPrivate *d;
158
159 static TQString timeFormat(uint);
160};
161
162//-----------------------------------------------------------------------------
169enum ScoreType { Won = 0, Lost = -1, Draw = -2 };
170
175class TDE_EXPORT Score
176{
177 public:
178 Score(ScoreType type = Won);
179
180 ~Score();
181
185 ScoreType type() const { return _type; }
186
190 void setType(ScoreType type) { _type = type; }
191
195 const TQVariant &data(const TQString &name) const;
196
202 void setData(const TQString &name, const TQVariant &value);
203
209 uint score() const { return data("score").toUInt(); }
210
216 void setScore(uint score) { setData("score", score); }
217
222 bool isTheWorst() const;
223
229 bool operator <(const Score &score);
230
231 private:
232 ScoreType _type;
233 TQStringVariantMap _data;
234
235 class ScorePrivate;
236 ScorePrivate *d;
237
238 friend class MultiplayerScores;
239
240 friend TQDataStream &operator <<(TQDataStream &stream, const Score &score);
241 friend TQDataStream &operator >>(TQDataStream &stream, Score &score);
242};
243
244TDE_EXPORT TQDataStream &operator <<(TQDataStream &stream, const Score &score);
245TDE_EXPORT TQDataStream &operator >>(TQDataStream &stream, Score &score);
246
267class TDE_EXPORT MultiplayerScores
268{
269 public:
270 MultiplayerScores();
271
272 ~MultiplayerScores();
273
277 void setPlayerCount(uint nb);
278
282 void setName(uint player, const TQString &name);
283
287 void addScore(uint player, const Score &score);
288
292 void clear();
293
297 void show(TQWidget *parent);
298
299 private:
300 TQValueVector<uint> _nbGames;
301 TQValueVector<Score> _scores;
302
303 class MultiplayerScoresPrivate;
304 MultiplayerScoresPrivate *d;
305
306 friend TQDataStream &operator <<(TQDataStream &stream,
307 const MultiplayerScores &score);
308 friend TQDataStream &operator >>(TQDataStream &stream,
309 MultiplayerScores &score);
310};
311
312TDE_EXPORT TQDataStream &operator <<(TQDataStream &stream, const MultiplayerScores &score);
313TDE_EXPORT TQDataStream &operator >>(TQDataStream &stream, MultiplayerScores &score);
314
315} // namespace
316
317#endif
KExtHighscore::Item
This class defines how to convert and how to display a highscore element (such as the score,...
Definition: kexthighscore_item.h:41
KExtHighscore::Item::alignment
int alignment() const
Definition: kexthighscore_item.h:119
KExtHighscore::Item::Format
Format
Possible display format.
Definition: kexthighscore_item.h:55
KExtHighscore::Item::Special
Special
Possible special value for display format.
Definition: kexthighscore_item.h:72
KExtHighscore::Item::setDefaultValue
void setDefaultValue(const TQVariant &value)
Set default value.
Definition: kexthighscore_item.h:124
KExtHighscore::Item::defaultValue
const TQVariant & defaultValue() const
Definition: kexthighscore_item.h:129
KExtHighscore::Item::isVisible
bool isVisible() const
Definition: kexthighscore_item.h:104
KExtHighscore::Item::label
TQString label() const
Definition: kexthighscore_item.h:114
KExtHighscore::Item::setLabel
void setLabel(const TQString &label)
Set the label.
Definition: kexthighscore_item.h:109
KExtHighscore::MultiplayerScores
This class is used to store and show scores for multiplayer games.
Definition: kexthighscore_item.h:268
KExtHighscore::Score
This class contains data for a score.
Definition: kexthighscore_item.h:176
KExtHighscore::Score::type
ScoreType type() const
Definition: kexthighscore_item.h:185
KExtHighscore::Score::setType
void setType(ScoreType type)
Set the game type.
Definition: kexthighscore_item.h:190
KExtHighscore::Score::setScore
void setScore(uint score)
Set the score value.
Definition: kexthighscore_item.h:216
KExtHighscore::Score::score
uint score() const
Definition: kexthighscore_item.h:209

libtdegames

Skip menu "libtdegames"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libtdegames

Skip menu "libtdegames"
  • libtdegames
Generated for libtdegames by doxygen 1.9.4
This website is maintained by Timothy Pearson.