/*
 * Config.h
 *
 *  Created on: 2009-07-11
 *      Author: wasyl
 */

#ifndef CONFIG_H_
#define CONFIG_H_

#include <cstdio>
#include <vector>

struct LevelInfo
{
	bool unlocked, complete, complete100, timeattack;
	double bestTime;

	LevelInfo(int i);
	void load(FILE *f);
	void save(FILE *f);
};

class Config
{
private:
	static Config *instance;
	Config(){};

	std::vector<LevelInfo> level;
	int deaths;

public:

	void initialize(int numLevels);

	static Config &get()
	{
		if (!instance)
			instance = new Config();
		return *instance;
	}

	void save();

	int numLevels() { return level.size(); }
	LevelInfo levelinfo(int no) { return level[no]; }
	void levelComplete(int no, bool perfect, double time);
	int unlockPoints();
	int completions();
	double timeAttackTime(int no);

	int deathsSoFar() { return deaths; };
	void addDeath() { deaths++; };
};

#endif /* CONFIG_H_ */
