Subversion Repositories spk

Rev

Rev 48 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed


#include "CorePackage.h"

#include <File.h>
#include "InstallText.h"

namespace SPK {
namespace Package {

CCorePackage::CCorePackage(void) : _bChanged(false), _pIconFile(NULL), _pInstallText(NULL), _pUninstallText(NULL)
{
        _setDefaults();
}

CCorePackage::~CCorePackage(void)
{
        delete _pIconFile;
        delete _pInstallText;
        delete _pUninstallText;
}

void CCorePackage::setIcon(C_File *file, const Utils::String ext)
{
        delete _pIconFile; 
        _sIconExt = ext; 
        _pIconFile = file; 
        _changed();
}

void CCorePackage::_setDefaults()
{
        _iRecommended = -1;
        _iGameChanging = -1;
        _iEaseOfUse = -1;

        delete _pIconFile;
        _pIconFile = NULL;

        delete _pInstallText;
        delete _pUninstallText;

        _pInstallText = new CInstallText;
        _pUninstallText = new CInstallText;
}

void CCorePackage::_setRatings(int iEase, int iChanging, int iRec)
{
        _iRecommended = iRec;
        _iGameChanging = iChanging;
        _iEaseOfUse = iEase;
}

void CCorePackage::_merge(CCorePackage *pPackage)
{
        _iRecommended   = pPackage->recommended();
        _iGameChanging  = pPackage->gameChanging();
        _iEaseOfUse             = pPackage->easeOfUse();

        _pInstallText->merge(pPackage->installText());
        _pUninstallText->merge(pPackage->uninstallText());
}

///////////////////////////////////////////////////////////////////////////////////////////////
//      Install/Uninstall Texts
///////

Utils::String CCorePackage::_installText(int iLang, bool bBefore, bool bIncludeDefault, const CInstallText *pText) const
{
        return (bBefore) ? pText->getBefore(iLang, bIncludeDefault) : pText->getAfter(iLang, bIncludeDefault);
}

Utils::String CCorePackage::installText(int iLang, bool bBefore, bool bIncludeDefault) const
{
        return _installText(iLang, bBefore, bIncludeDefault, _pInstallText);
}

Utils::String CCorePackage::uninstallText(int iLang, bool bBefore, bool bIncludeDefault) const
{
        return _installText(iLang, bBefore, bIncludeDefault, _pUninstallText);
}

void CCorePackage::addInstallText(int iLang, bool bBefore, const Utils::String &sText) 
{
        _addInstallText(iLang, bBefore, sText, _pInstallText);
}

void CCorePackage::addUninstallText(int iLang, bool bBefore, const Utils::String &sText)
{
        _addInstallText(iLang, bBefore, sText, _pUninstallText);
}

void CCorePackage::removeInstallText(int iLang, bool bInstall)
{
        if ( bInstall ) _pInstallText->remove(iLang);
        else                    _pUninstallText->remove(iLang);
}


void CCorePackage::_addInstallText(int iLang, bool bBefore, const Utils::String &sText, CInstallText *pText)
{
        if ( bBefore ) pText->addBefore(iLang, sText);
        else pText->addAfter(iLang, sText);
}



}}//NAMESPACE