Click here to Skip to main content
15,886,199 members
Articles / Desktop Programming / MFC

Adding high score capability to MS Solitaire

Rate me:
Please Sign up or sign in to vote.
4.70/5 (16 votes)
25 Jul 2007CPOL14 min read 44K   713   18  
An application that manages MS Solitaire high scores by reading and writing Solitaire memory
#ifndef _HIGHSCOREMANAGAR_H
#define _HIGHSCOREMANAGAR_H

#pragma once

// Includes
#include <vector>
#include "events.h"
#include "tsingleton.h"
#include "highscoreentry.h"

// Event and Vector definitions
typedef Event<void, long>  HighscoreEvent;
typedef vector<CHighscoreEntry>  HighscoreVector;
typedef HighscoreVector::iterator HighscoreVectorIterator;
typedef HighscoreVector::reverse_iterator HighscoreVectorRevereseIterator;

using namespace std;

///////////////////////////////////////////////////////////////////////////////////
// Class CHighscoreManager
// is a class that manages highscores. Creates, deletes and inform others
// through events of creation and deletion.
//
// Author: Asa Meltzer
// Date: 07/2007
class CHighscoreManager
{
public:
// Globals
	const static int MAX_SCORES = 10;
// Construction
	CHighscoreManager();
	virtual ~CHighscoreManager();
// Operations
	void CreateHighscore(const CString& strName, long lScore, long lTime = -1, bool bRaisEvent = true);
	void DeleteHighscore(const CString& strName, long lScore);
	void DeleteHighscore(UINT nIndex);
	void DeleteAll(bool bRaiseEvent = true);
// Access
	const HighscoreVector& GetHighscoreArray() const;
// events
	HighscoreEvent OnHighscoreCreatedEvent;
	HighscoreEvent OnNotHighscoreEvent;
	HighscoreEvent OnHighscoreDeletedEvent;
private:
// variables
	HighscoreVector m_vecHighscores;
};

typedef TSingleton<CHighscoreManager> STHighscoreManager;

// Inline Access
// this will copy the vector
inline const HighscoreVector& CHighscoreManager::GetHighscoreArray() const
{
	return m_vecHighscores;
}

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Israel Israel
Software designer and programmer.
Programming languages:
MFC, C++, Java , C#, VB and sometimes C and assembly.

Comments and Discussions