Subversion Repositories spk

Rev

Rev 208 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
46 cycrow 1
#pragma once
2
 
170 cycrow 3
#include "spkdefines.h"
4
#include "../Utils/List.h"
131 cycrow 5
#include <map>
46 cycrow 6
 
48 cycrow 7
enum {PLUGIN_NORMAL, PLUGIN_STABLE, PLUGIN_EXPERIMENTAL, PLUGIN_CHEAT, PLUGIN_MOD}; // filters for browsing packages
46 cycrow 8
 
9
namespace SPK {
10
namespace Package {
11
 
48 cycrow 12
 
46 cycrow 13
class CInstallText;
14
 
15
class SPKEXPORT CCorePackage
16
{
17
private:
203 cycrow 18
	Utils::WString _sName;
204 cycrow 19
	Utils::WString _sVersion;
203 cycrow 20
	Utils::WString _sAuthor;
206 cycrow 21
	Utils::WString _sWebSite;
22
	Utils::WString _sWebAddress;
23
	Utils::WString _sEmail;
24
	Utils::WString _sDescription;
204 cycrow 25
	Utils::WString _sCreationDate;
206 cycrow 26
	Utils::WString _sForumLink;
46 cycrow 27
 
197 cycrow 28
	Utils::WString _sFilename;
204 cycrow 29
	Utils::WString _sExportFilename;
46 cycrow 30
 
206 cycrow 31
	std::map<unsigned int, Utils::WString> *_pAutoExtract;
32
	std::map<unsigned int, Utils::WString> *_pAutoExport;
170 cycrow 33
	Utils::CList<SNames> *_lNames;
131 cycrow 34
 
46 cycrow 35
	CInstallText *_pInstallText;
36
	CInstallText *_pUninstallText;
208 cycrow 37
	Utils::WStringList _lMirrors;
46 cycrow 38
 
39
	int _iPluginType;
40
 
41
	// package stats
42
	int _iRecommended;
43
	int _iEaseOfUse;
44
	int _iGameChanging;
45
 
46
	bool _bChanged;
47
 
48
public:
49
	CCorePackage(void);
50
	virtual ~CCorePackage(void);
51
 
52
	//getters
204 cycrow 53
	const Utils::WString &name				() const { return _sName; }
54
	const Utils::WString &version	 		() const { return _sVersion; }
55
	const Utils::WString &author			() const { return _sAuthor; }
206 cycrow 56
	const Utils::WString &webSite			() const { return _sWebSite; }
57
	const Utils::WString &webAddress		() const { return _sWebAddress; }
58
	const Utils::WString &email				() const { return _sEmail; }
204 cycrow 59
	const Utils::WString &creationDate		() const { return _sCreationDate; }
206 cycrow 60
	const Utils::WString &description		() const { return _sDescription; }
61
	const Utils::WString &forumLink			() const { return _sForumLink; }
204 cycrow 62
	int					 recommended		() const { return _iRecommended; }
63
	int					 easeOfUse			() const { return _iEaseOfUse; }
64
	int					 gameChanging		() const { return _iGameChanging; }
65
	const Utils::WString &filename			() const { return _sFilename; }
66
	const Utils::WString &exportFilename	() const { return _sExportFilename; }
67
	const CInstallText  *installText		() const { return _pInstallText; }
68
	const CInstallText  *uninstallText		() const { return _pUninstallText; }
69
	int					 pluginType			() const { return _iPluginType; }
70
	bool				 hasChanged			() const { return _bChanged; }
203 cycrow 71
	const Utils::WString	&name			(int lang) const;
206 cycrow 72
	const std::map<unsigned int, Utils::WString> *autoExtraction() const { return _pAutoExtract; }
73
	const std::map<unsigned int, Utils::WString> *autoExporter() const { return _pAutoExport; }
170 cycrow 74
	const Utils::CList<SNames> *namesList() const { return _lNames; }
46 cycrow 75
 
76
	//setters
203 cycrow 77
	void setName			( const Utils::WString &str ) { _changed(); _sName = str.remove(L'|'); }
204 cycrow 78
	void setVersion			( const Utils::WString &str ) { _changed(); _sVersion = str; }
203 cycrow 79
	void setAuthor			( const Utils::WString &str ) { _changed(); _sAuthor = str.remove(L'|'); }
206 cycrow 80
	void setWebAddress		( const Utils::WString &str ) { _changed(); _sWebAddress = str; }
81
	void setWebSite			( const Utils::WString &str ) { _changed(); _sWebSite = str; }
82
	void setEmail			( const Utils::WString &str ) { _changed(); _sEmail = str; }
204 cycrow 83
	void setCreationDate	( const Utils::WString &str ) { _changed(); _sCreationDate = str; }
206 cycrow 84
	void setDescription		( const Utils::WString &str ) { _changed(); _parseDescription(str); }
197 cycrow 85
	void setFilename		( const Utils::WString &str ) { _sFilename = str; }
204 cycrow 86
	void setExportFilename	( const Utils::WString &str ) { _sExportFilename = str; }
206 cycrow 87
	void setForumLink		( const Utils::WString &str ) { _changed(); _sForumLink = str; }
46 cycrow 88
	void setRecommended		( int i )					 { _changed(); _iRecommended = i; }
89
	void setGameChanging	( int i )					 { _changed(); _iGameChanging = i; }
90
	void setEaseOfUse		( int i )					 { _changed(); _iEaseOfUse = i; }
48 cycrow 91
	void setPluginType		( int i )					 { _changed(); _iPluginType = i; }
50 cycrow 92
	void adjustChanged		( bool bChanged )			 { _bChanged = bChanged; }
208 cycrow 93
 
206 cycrow 94
	void addAutoExtract(unsigned int game, const Utils::WString &dir);
95
	void addAutoExport(unsigned int game, const Utils::WString &file);
131 cycrow 96
	void clearAutoExtract();
97
	void clearAutoExport();
98
 
204 cycrow 99
	void addName(int iLang, const Utils::WString& name);
170 cycrow 100
	void removeName(int iLang);
101
	void clearNames();
102
 
46 cycrow 103
	// install texts
206 cycrow 104
	Utils::WString installText(int iLang, bool bBefore, bool bIncludeDefault = true) const;
105
	Utils::WString uninstallText(int iLang, bool bBefore, bool bIncludeDefault = true) const;
106
	void addInstallText(int iLang, bool bBefore, const Utils::WString &sText);
107
	void addUninstallText(int iLang, bool bBefore, const Utils::WString &sText);
46 cycrow 108
	void removeInstallText(int iLang, bool bInstall);
109
 
208 cycrow 110
	// Web Mirrors
111
	bool anyWebMirrors() { return !_lMirrors.empty(); }
112
	const Utils::WStringList& webMirrors() const { return _lMirrors; }
273 cycrow 113
	size_t getMaxWebMirrors() { return _lMirrors.size(); }
208 cycrow 114
	Utils::WString getWebMirror(size_t i) { if (i >= 0 && i < _lMirrors.size()) return _lMirrors.get(i)->str; return Utils::WString::Null(); }
115
	void clearWebMirrors() { _lMirrors.clear(); }
116
	void addWebMirror(const Utils::WString& str);
117
	void removeWebMirror(const Utils::WString& str);
118
 
46 cycrow 119
protected:
120
	virtual void _changed() { _bChanged = true; }
121
	virtual void _setDefaults();
122
	void _setRatings(int iEase, int iChanging, int iRec);
206 cycrow 123
	void _parseDescription(const Utils::WString &sDesc);
46 cycrow 124
 
125
	bool _noRatings() const { return (_iRecommended == -1 && _iEaseOfUse == -1 && _iGameChanging == -1) ? true : false; }
126
	void _merge(CCorePackage *pPackage);
127
 
206 cycrow 128
	Utils::WString _installText(int iLang, bool bBefore, bool bIncludeDefault, const CInstallText *pText) const;
129
	void _addInstallText(int iLang, bool bBefore, const Utils::WString &sText, CInstallText *pText);
46 cycrow 130
};
131
 
132
 
133
}}//NAMESPACE