Rev 46 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#include "../StdAfx.h"
#include "InstallPackageDialog.h"
#undef GetTempPath
#undef GetCurrentDirectory
namespace PluginManager {
void InstallPackageDialog::UpdatePackages()
{
ListPackages->Items->Clear();
ListPackages->Groups->Clear();
ListPackages->SmallImageList = gcnew ImageList();
ListPackages->LargeImageList = ListPackages->SmallImageList;
int count = 0;
for ( CListNode<CBaseFile> *node = m_pPackages->GetInstallPackageList()->Front(); node; node = node->next() )
{
CBaseFile *p = node->Data();
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(p->GetLanguageName(m_pPackages->GetLanguage())));
item->SubItems->Add(SystemStringFromCyString(p->GetAuthor()));
item->SubItems->Add(SystemStringFromCyString(p->GetVersion()));
switch ( p->GetLoadError() )
{
case INSTALLCHECK_OLDVERSION:
item->SubItems->Add("Newer version installed");
break;
case INSTALLCHECK_WRONGGAME:
item->SubItems->Add("For Wrong Game");
break;
case INSTALLCHECK_WRONGVERSION:
item->SubItems->Add("For Wrong Game Version");
break;
}
ListPackages->Items->Add(item);
item->Tag = SystemStringFromCyString(CyString::Number(count));
++count;
if ( p->GetIcon() )
{
//extract icon
C_File *f = p->GetIcon();
f->SetFullDir(CyStringFromSystemString(System::IO::Path::GetTempPath()));
if ( f->UncompressData() )
f->WriteFilePointer();
PluginManager::DisplayListIcon(p, ListPackages, item);
}
C_File *gf = p->GetFirstFile(FILETYPE_ADVERT);
if ( gf )
{
gf->SetFullDir(CyStringFromSystemString(System::IO::Path::GetTempPath()));
if ( gf->UncompressData() )
gf->WriteFilePointer();
}
if ( count == 1 )
item->Selected = true;
item->Checked = (p->GetLoadError()) ? false : true;
// select one with an error if there is any
if ( p->GetLoadError() )
item->Selected = true;
}
if ( ListPackages->Items->Count == 1 )
{
this->GroupList->Hide();
this->Height = 250;
this->DisplayPackage(m_pPackages->GetInstallPackageList()->Get(0));
}
}
void InstallPackageDialog::DisplayPackage(CBaseFile *p)
{
TextInstall->Hide();
this->PanelRating->Hide();
PicEase1->Hide();
PicEase2->Hide();
PicEase3->Hide();
PicEase4->Hide();
PicEase5->Hide();
PicChange1->Hide();
PicChange2->Hide();
PicChange3->Hide();
PicChange4->Hide();
PicChange5->Hide();
PicRec1->Hide();
PicRec2->Hide();
PicRec3->Hide();
PicRec4->Hide();
PicRec5->Hide();
this->LabError->Text = "";
if ( p )
{
this->GroupPackage->Text = SystemStringFromCyString(p->GetFullPackageName(m_pPackages->GetLanguage(), false));
this->TextDesc->Text = SystemStringFromCyString(p->GetDescription().FindReplace("<br>", "\n").StripHTML());
// update graphic
bool addedIcon = false;
C_File *picFile = p->GetFirstFile(FILETYPE_ADVERT);
if ( picFile )
{
System::String ^pic = SystemStringFromCyString(picFile->GetFilePointer());
if ( System::IO::File::Exists(pic) )
{
Bitmap ^myBitmap = gcnew Bitmap(pic);
if ( myBitmap )
{
this->PictureDisplay->Image = dynamic_cast<Image ^>(myBitmap);
addedIcon = true;
}
}
}
if ( !addedIcon )
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(InstallPackageDialog::typeid));
System::Drawing::Icon ^icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
this->PictureDisplay->Image = icon->ToBitmap();
}
if ( !p->GetInstallBeforeText(m_pPackages->GetLanguage()).Empty() )
{
this->TextInstall->Text = SystemStringFromCyString(p->GetInstallBeforeText(m_pPackages->GetLanguage()).StripHTML());
this->TextInstall->Show();
}
this->LabDate->Text = SystemStringFromCyString(p->GetCreationDate());
this->LabVersion->Text = SystemStringFromCyString(p->GetVersion());
if ( p->GetType() == TYPE_SPK )
{
this->LabType->Text = SystemStringFromCyString(((CSpkFile *)p)->GetScriptTypeString(m_pPackages->GetLanguage()));
switch ( p->GetPluginType() )
{
case PLUGIN_NORMAL:
this->LabPluginType->Text = "Normal";
break;
case PLUGIN_STABLE:
this->LabPluginType->Text = "Stable";
break;
case PLUGIN_EXPERIMENTAL:
this->LabPluginType->Text = "Experimental";
break;
case PLUGIN_CHEAT:
this->LabPluginType->Text = "Cheat";
break;
case PLUGIN_MOD:
this->LabPluginType->Text = "Mod";
break;
}
}
else if ( p->GetType() == TYPE_XSP )
{
this->LabType->Text = "Ship";
this->LabPluginType->Text = "Ship";
}
else
{
this->LabType->Text = "Other";
this->LabPluginType->Text = "Other";
}
if ( p->AnyGameCompatability() )
this->LabGames->Text = SystemStringFromCyString(m_pPackages->GetGameTypesString(p, true));
else
this->LabGames->Text = "All Games";
if ( p->GetGameChanging() >= 1 || p->GetRecommended() >= 1 || p->GetEaseOfUse() >= 1 )
{
this->PanelRating->Show();
// ease of use rating
if ( p->GetEaseOfUse() >= 1 )
PicEase1->Show();
if ( p->GetEaseOfUse() >= 2 )
PicEase2->Show();
if ( p->GetEaseOfUse() >= 3 )
PicEase3->Show();
if ( p->GetEaseOfUse() >= 4 )
PicEase4->Show();
if ( p->GetEaseOfUse() >= 5 )
PicEase5->Show();
// game changing rating
if ( p->GetGameChanging() >= 1 )
PicChange1->Show();
if ( p->GetGameChanging() >= 2 )
PicChange2->Show();
if ( p->GetGameChanging() >= 3 )
PicChange3->Show();
if ( p->GetGameChanging() >= 4 )
PicChange4->Show();
if ( p->GetGameChanging() >= 5 )
PicChange5->Show();
// Recommanded rating
if ( p->GetRecommended() >= 1 )
PicRec1->Show();
if ( p->GetRecommended() >= 2 )
PicRec2->Show();
if ( p->GetRecommended() >= 3 )
PicRec3->Show();
if ( p->GetRecommended() >= 4 )
PicRec4->Show();
if ( p->GetRecommended() >= 5 )
PicRec5->Show();
}
switch ( p->GetLoadError() )
{
case INSTALLCHECK_OLDVERSION:
{
CBaseFile *oldPackage = m_pPackages->FindPackage(p);
if ( oldPackage )
this->LabError->Text = "Newer version already installed: V" + SystemStringFromCyString(oldPackage->GetVersion()) + " - " + SystemStringFromCyString(oldPackage->GetCreationDate());
else
this->LabError->Text = "Newer version already installed";
}
break;
case INSTALLCHECK_WRONGGAME:
this->LabError->Text = "For Wrong Game, Requires: " + SystemStringFromCyString(m_pPackages->GetGameTypesString(p, false));
break;
case INSTALLCHECK_WRONGVERSION:
this->LabError->Text = "For Wrong Game Version, Requires: " + SystemStringFromCyString(m_pPackages->GetGameVersionString(p));
break;
}
}
else
{
this->LabType->Text = "";
this->GroupPackage->Text = "";
this->TextDesc->Text = "";
this->PictureDisplay->Image = nullptr;
}
}
void InstallPackageDialog::DoClose()
{
// remove any packages that are not selected
// if only 1 package, we cant select the check box, so always checked
if ( ListPackages->Items->Count > 1 )
{
CLinkList<CBaseFile> removePackages;
for ( int i = ListPackages->Items->Count - 1; i >= 0; i-- )
{
ListViewItem ^item = ListPackages->Items[i];
if ( !item->Checked )
{
int num = Convert::ToInt32(item->Tag);
removePackages.push_back(m_pPackages->GetInstallPackageList()->Get(num));
}
}
for ( CBaseFile *p = removePackages.First(); p; p = removePackages.Next() )
m_pPackages->RemovePreparedInstall(p);
removePackages.MemoryClear();
}
m_pPackages->CheckPreparedInstallRequired(NULL);
this->Close();
}
}