46 |
cycrow |
1 |
|
|
|
2 |
#include "CorePackage.h"
|
|
|
3 |
|
|
|
4 |
#include <File.h>
|
|
|
5 |
#include "InstallText.h"
|
|
|
6 |
|
|
|
7 |
namespace SPK {
|
|
|
8 |
namespace Package {
|
|
|
9 |
|
48 |
cycrow |
10 |
CCorePackage::CCorePackage(void) : _bChanged(false), _pInstallText(NULL), _pUninstallText(NULL)
|
46 |
cycrow |
11 |
{
|
|
|
12 |
_setDefaults();
|
|
|
13 |
}
|
|
|
14 |
|
|
|
15 |
CCorePackage::~CCorePackage(void)
|
|
|
16 |
{
|
|
|
17 |
delete _pInstallText;
|
|
|
18 |
delete _pUninstallText;
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
void CCorePackage::_setDefaults()
|
|
|
22 |
{
|
|
|
23 |
_iRecommended = -1;
|
|
|
24 |
_iGameChanging = -1;
|
|
|
25 |
_iEaseOfUse = -1;
|
|
|
26 |
|
|
|
27 |
delete _pInstallText;
|
|
|
28 |
delete _pUninstallText;
|
|
|
29 |
|
|
|
30 |
_pInstallText = new CInstallText;
|
|
|
31 |
_pUninstallText = new CInstallText;
|
48 |
cycrow |
32 |
|
|
|
33 |
_iPluginType = PLUGIN_NORMAL;
|
46 |
cycrow |
34 |
}
|
|
|
35 |
|
|
|
36 |
void CCorePackage::_setRatings(int iEase, int iChanging, int iRec)
|
|
|
37 |
{
|
|
|
38 |
_iRecommended = iRec;
|
|
|
39 |
_iGameChanging = iChanging;
|
|
|
40 |
_iEaseOfUse = iEase;
|
|
|
41 |
}
|
|
|
42 |
|
48 |
cycrow |
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("<", "<");
|
|
|
52 |
_sDescription = _sDescription.findReplace("&", "&");
|
|
|
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 |
|
46 |
cycrow |
85 |
void CCorePackage::_merge(CCorePackage *pPackage)
|
|
|
86 |
{
|
|
|
87 |
_iRecommended = pPackage->recommended();
|
|
|
88 |
_iGameChanging = pPackage->gameChanging();
|
|
|
89 |
_iEaseOfUse = pPackage->easeOfUse();
|
|
|
90 |
|
|
|
91 |
_pInstallText->merge(pPackage->installText());
|
|
|
92 |
_pUninstallText->merge(pPackage->uninstallText());
|
48 |
cycrow |
93 |
|
|
|
94 |
_iPluginType = pPackage->pluginType();
|
|
|
95 |
_sDescription = pPackage->description();
|
49 |
cycrow |
96 |
_sWebSite = pPackage->webSite();
|
|
|
97 |
_sWebAddress = pPackage->webAddress();
|
|
|
98 |
_sEmail = pPackage->email();
|
|
|
99 |
_sForumLink = pPackage->forumLink();
|
50 |
cycrow |
100 |
_sCreationDate = pPackage->creationDate();
|
|
|
101 |
_sVersion = pPackage->version();
|
46 |
cycrow |
102 |
}
|
|
|
103 |
|
|
|
104 |
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
105 |
// Install/Uninstall Texts
|
|
|
106 |
///////
|
|
|
107 |
|
|
|
108 |
Utils::String CCorePackage::installText(int iLang, bool bBefore, bool bIncludeDefault) const
|
|
|
109 |
{
|
|
|
110 |
return _installText(iLang, bBefore, bIncludeDefault, _pInstallText);
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
Utils::String CCorePackage::uninstallText(int iLang, bool bBefore, bool bIncludeDefault) const
|
|
|
114 |
{
|
|
|
115 |
return _installText(iLang, bBefore, bIncludeDefault, _pUninstallText);
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
void CCorePackage::addInstallText(int iLang, bool bBefore, const Utils::String &sText)
|
|
|
119 |
{
|
|
|
120 |
_addInstallText(iLang, bBefore, sText, _pInstallText);
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
void CCorePackage::addUninstallText(int iLang, bool bBefore, const Utils::String &sText)
|
|
|
124 |
{
|
|
|
125 |
_addInstallText(iLang, bBefore, sText, _pUninstallText);
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
void CCorePackage::removeInstallText(int iLang, bool bInstall)
|
|
|
129 |
{
|
|
|
130 |
if ( bInstall ) _pInstallText->remove(iLang);
|
|
|
131 |
else _pUninstallText->remove(iLang);
|
|
|
132 |
}
|
|
|
133 |
|
48 |
cycrow |
134 |
Utils::String CCorePackage::_installText(int iLang, bool bBefore, bool bIncludeDefault, const CInstallText *pText) const
|
|
|
135 |
{
|
|
|
136 |
return (bBefore) ? pText->getBefore(iLang, bIncludeDefault) : pText->getAfter(iLang, bIncludeDefault);
|
|
|
137 |
}
|
46 |
cycrow |
138 |
|
|
|
139 |
void CCorePackage::_addInstallText(int iLang, bool bBefore, const Utils::String &sText, CInstallText *pText)
|
|
|
140 |
{
|
|
|
141 |
if ( bBefore ) pText->addBefore(iLang, sText);
|
|
|
142 |
else pText->addAfter(iLang, sText);
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
}}//NAMESPACE
|