Subversion Repositories spk

Rev

Rev 116 | Rev 170 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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