Subversion Repositories spk

Rev

Rev 46 | Rev 49 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 46 Rev 48
Line 5... Line 5...
5
#include "InstallText.h"
5
#include "InstallText.h"
6
 
6
 
7
namespace SPK {
7
namespace SPK {
8
namespace Package {
8
namespace Package {
9
 
9
 
10
CCorePackage::CCorePackage(void) : _bChanged(false), _pIconFile(NULL), _pInstallText(NULL), _pUninstallText(NULL)
10
CCorePackage::CCorePackage(void) : _bChanged(false), _pInstallText(NULL), _pUninstallText(NULL)
11
{
11
{
12
	_setDefaults();
12
	_setDefaults();
13
}
13
}
14
 
14
 
15
CCorePackage::~CCorePackage(void)
15
CCorePackage::~CCorePackage(void)
16
{
16
{
17
	delete _pIconFile;
-
 
18
	delete _pInstallText;
17
	delete _pInstallText;
19
	delete _pUninstallText;
18
	delete _pUninstallText;
20
}
-
 
21
 
-
 
22
void CCorePackage::setIcon(C_File *file, const Utils::String ext)
-
 
23
{
-
 
24
	delete _pIconFile; 
-
 
25
	_sIconExt = ext; 
-
 
26
	_pIconFile = file; 
-
 
27
	_changed();
-
 
28
}
19
}
29
 
20
 
30
void CCorePackage::_setDefaults()
21
void CCorePackage::_setDefaults()
31
{
22
{
32
	_iRecommended = -1;
23
	_iRecommended = -1;
33
	_iGameChanging = -1;
24
	_iGameChanging = -1;
34
	_iEaseOfUse = -1;
25
	_iEaseOfUse = -1;
35
 
-
 
36
	delete _pIconFile;
-
 
37
	_pIconFile = NULL;
-
 
38
 
26
 
39
	delete _pInstallText;
27
	delete _pInstallText;
40
	delete _pUninstallText;
28
	delete _pUninstallText;
41
 
29
 
42
	_pInstallText = new CInstallText;
30
	_pInstallText = new CInstallText;
43
	_pUninstallText = new CInstallText;
31
	_pUninstallText = new CInstallText;
-
 
32
 
-
 
33
	_iPluginType = PLUGIN_NORMAL;
44
}
34
}
45
 
35
 
46
void CCorePackage::_setRatings(int iEase, int iChanging, int iRec)
36
void CCorePackage::_setRatings(int iEase, int iChanging, int iRec)
47
{
37
{
48
	_iRecommended = iRec;
38
	_iRecommended = iRec;
49
	_iGameChanging = iChanging;
39
	_iGameChanging = iChanging;
50
	_iEaseOfUse = iEase;
40
	_iEaseOfUse = iEase;
51
}
41
}
52
 
42
 
-
 
43
void CCorePackage::_parseDescription(const Utils::String &sDesc)
-
 
44
{
-
 
45
	_sDescription = sDesc;
-
 
46
	//_sDescription.RemoveFirstChar('\n');
-
 
47
	//_sDescription.RemoveFirstChar('\r');
-
 
48
	_sDescription.removeFirstSpace();
-
 
49
	_sDescription = _sDescription.findReplace(""", "\"");
-
 
50
	_sDescription = _sDescription.findReplace(">", ">");
-
 
51
	_sDescription = _sDescription.findReplace("&lt;", "<");
-
 
52
	_sDescription = _sDescription.findReplace("&amp;", "&");
-
 
53
	_sDescription = _sDescription.findReplace("<newline>", "\n");
-
 
54
	_sDescription = _sDescription.findReplace("<br>", "\n");
-
 
55
 
-
 
56
	if ( _sDescription.left(6).Compare("<html>") ) {
-
 
57
		int foundFirst = -1;
-
 
58
		int pos = 0;
-
 
59
		while ( foundFirst == -1 )
-
 
60
		{
-
 
61
			pos = _sDescription.findPos(">", pos);
-
 
62
 
-
 
63
			pos++;
-
 
64
			if ( pos >= (int)_sDescription.length() )
-
 
65
				break;
-
 
66
			char c = _sDescription[pos];
-
 
67
 
-
 
68
			if ( c != '<' )
-
 
69
				foundFirst = pos;
-
 
70
		}
-
 
71
 
-
 
72
		if ( foundFirst == -1 )
-
 
73
			_sDescription = "";
-
 
74
		else
-
 
75
		{
-
 
76
			Utils::String firstStr = _sDescription.left(foundFirst).findRemove("<br />").findRemove("<br/>");
-
 
77
			Utils::String lastStr = _sDescription.right(_sDescription.length() - foundFirst);
-
 
78
 
-
 
79
			_sDescription = firstStr + lastStr;
-
 
80
		}
-
 
81
	}
-
 
82
 
-
 
83
}
-
 
84
 
53
void CCorePackage::_merge(CCorePackage *pPackage)
85
void CCorePackage::_merge(CCorePackage *pPackage)
54
{
86
{
55
	_iRecommended	= pPackage->recommended();
87
	_iRecommended	= pPackage->recommended();
56
	_iGameChanging	= pPackage->gameChanging();
88
	_iGameChanging	= pPackage->gameChanging();
57
	_iEaseOfUse		= pPackage->easeOfUse();
89
	_iEaseOfUse		= pPackage->easeOfUse();
58
 
90
 
59
	_pInstallText->merge(pPackage->installText());
91
	_pInstallText->merge(pPackage->installText());
60
	_pUninstallText->merge(pPackage->uninstallText());
92
	_pUninstallText->merge(pPackage->uninstallText());
-
 
93
 
-
 
94
	_iPluginType	= pPackage->pluginType();
-
 
95
	_sDescription	= pPackage->description();
61
}
96
}
62
 
97
 
63
///////////////////////////////////////////////////////////////////////////////////////////////
98
///////////////////////////////////////////////////////////////////////////////////////////////
64
//	Install/Uninstall Texts
99
//	Install/Uninstall Texts
65
///////
100
///////
66
 
101
 
67
Utils::String CCorePackage::_installText(int iLang, bool bBefore, bool bIncludeDefault, const CInstallText *pText) const
-
 
68
{
-
 
69
	return (bBefore) ? pText->getBefore(iLang, bIncludeDefault) : pText->getAfter(iLang, bIncludeDefault);
-
 
70
}
-
 
71
 
-
 
72
Utils::String CCorePackage::installText(int iLang, bool bBefore, bool bIncludeDefault) const
102
Utils::String CCorePackage::installText(int iLang, bool bBefore, bool bIncludeDefault) const
73
{
103
{
74
	return _installText(iLang, bBefore, bIncludeDefault, _pInstallText);
104
	return _installText(iLang, bBefore, bIncludeDefault, _pInstallText);
75
}
105
}
76
 
106
 
77
Utils::String CCorePackage::uninstallText(int iLang, bool bBefore, bool bIncludeDefault) const
107
Utils::String CCorePackage::uninstallText(int iLang, bool bBefore, bool bIncludeDefault) const
78
{
108
{
79
	return _installText(iLang, bBefore, bIncludeDefault, _pUninstallText);
109
	return _installText(iLang, bBefore, bIncludeDefault, _pUninstallText);
80
}
110
}
81
 
111
 
82
void CCorePackage::addInstallText(int iLang, bool bBefore, const Utils::String &sText) 
112
void CCorePackage::addInstallText(int iLang, bool bBefore, const Utils::String &sText) 
83
{
113
{
84
	_addInstallText(iLang, bBefore, sText, _pInstallText);
114
	_addInstallText(iLang, bBefore, sText, _pInstallText);
85
}
115
}
Line 93... Line 123...
93
{
123
{
94
	if ( bInstall ) _pInstallText->remove(iLang);
124
	if ( bInstall ) _pInstallText->remove(iLang);
95
	else			_pUninstallText->remove(iLang);
125
	else			_pUninstallText->remove(iLang);
96
}
126
}
97
 
127
 
-
 
128
Utils::String CCorePackage::_installText(int iLang, bool bBefore, bool bIncludeDefault, const CInstallText *pText) const
-
 
129
{
-
 
130
	return (bBefore) ? pText->getBefore(iLang, bIncludeDefault) : pText->getAfter(iLang, bIncludeDefault);
-
 
131
}
98
 
132
 
99
void CCorePackage::_addInstallText(int iLang, bool bBefore, const Utils::String &sText, CInstallText *pText)
133
void CCorePackage::_addInstallText(int iLang, bool bBefore, const Utils::String &sText, CInstallText *pText)
100
{
134
{
101
	if ( bBefore ) pText->addBefore(iLang, sText);
135
	if ( bBefore ) pText->addBefore(iLang, sText);
102
	else pText->addAfter(iLang, sText);
136
	else pText->addAfter(iLang, sText);