Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   Namespace Members   Compound Members  

PLMScore Class Reference

A score table manager. More...

#include <PLMScore.hpp>

List of all members.

Public Types

enum  SortOrder { GREATER_FIRST, LOWER_FIRST }

Public Methods

 PLMScore (u32 entries=0, SortOrder order=GREATER_FIRST, s32 value=0)
u32 Size () const
u32 Length () const
void SetSortOrder (SortOrder order)
void Resize (u32 size)
s32 Add (PLMScoreEntry *ent)
const PLMScoreEntryGetEntry (u32 idx) const
void Reset (s32 value=0)
bool Load (const char *filename)
bool Save (const char *filename, bool obfuscate=true)
void PrintInfo () const


Detailed Description

A score table manager.

You can choose the size and the order of the table. Simply call Add() to add a new score, it will be added at the right place if it is good enough. The table can be loaded from/saved to a file, and player names can be encrypted.


Member Enumeration Documentation

enum PLMScore::SortOrder
 

Sorting orders.

Enumeration values:
GREATER_FIRST  sort entries from greater to lower score (decreasing values)
LOWER_FIRST  sort entries from lower to greater score (increasing values)


Constructor & Destructor Documentation

PLMScore::PLMScore u32    entries = 0,
SortOrder    order = GREATER_FIRST,
s32    value = 0
 

Create a new score table of entries entries, all set to value, sorted in the given order.

The smallest size is 3 (default).


Member Function Documentation

u32 PLMScore::Size   [inline]
 

Get the size of the table (as set by the constructor and Resize()), some entries may be unused.

u32 PLMScore::Length  
 

Get the current (computed) number of non-null entries (with no name).

Same as Size() if all entries are used.

void PLMScore::SetSortOrder SortOrder    order
 

Change the sorting order (use GREATER_FIRST or LOWER_FIRST).

The table is then updated according to the new order.

void PLMScore::Resize u32    size
 

Change the size (number of entries) of the score table.

If size is bigger than current size, new empty entries are added at the end. If size is smaller, last entries are deleted. size can not be smaller than 3 (default value).

s32 PLMScore::Add PLMScoreEntry   ent
 

Check if an entry can be added to the table.

The entry is rejected if its score is not good enough, and its position depends on the current sorting order. If the entry is added, all existing entries with a lower score loose one position, and the last one is removed.

Returns:
the position (index from 0) of the entry, or -1 if rejected.

const PLMScoreEntry * PLMScore::GetEntry u32    idx const [inline]
 

Get the entry at index idx (should be in [0..Size()[).

Never modify the content (value) returned. Return NULL if the index is not valid (>= Size()).

void PLMScore::Reset s32    value = 0
 

Reset the score table (erase names, all scores are set to value).

bool PLMScore::Load const char *    filename
 

Load the score table from the file filename (from current directory if no path is specified).

Return false on error (bad file format).

bool PLMScore::Save const char *    filename,
bool    obfuscate = true
 

Save the score table to the file filename (in the current directory).

It is possible to modify the names in the saved table to make them unreadable if the file is open in a text editor, by setting obfuscate to true. Return false on error (can not create file or write error).

void PLMScore::PrintInfo  
 

Print the current score table to current log.


The documentation for this class was generated from the following file:
  • PLMScore.hpp

Generated by Doxygen 1.2.18 on Tue Oct 26 12:07:39 2004.