1 |
cycrow |
1 |
#include "../StdAfx.h"
|
|
|
2 |
#include "ModSelector.h"
|
|
|
3 |
#include "CheckUpdate.h"
|
|
|
4 |
#include "MainGui.h"
|
|
|
5 |
|
|
|
6 |
#undef GetTempPath
|
|
|
7 |
#undef GetCurrentDirectory
|
|
|
8 |
|
|
|
9 |
using namespace System::IO;
|
|
|
10 |
|
|
|
11 |
namespace PluginManager {
|
|
|
12 |
|
|
|
13 |
void ModSelector::Update()
|
|
|
14 |
{
|
|
|
15 |
// update the mod display
|
|
|
16 |
this->PictureBox->Image = nullptr;
|
|
|
17 |
if ( m_pPackages->GetEnabledMod() )
|
|
|
18 |
{
|
|
|
19 |
m_bFoundPackages = true;
|
|
|
20 |
CBaseFile *p = m_pPackages->GetEnabledMod();
|
|
|
21 |
this->TextMod->Text = SystemStringFromCyString(p->GetLanguageName(m_pPackages->GetLanguage()));
|
|
|
22 |
this->TextAuthor->Text = SystemStringFromCyString(p->GetAuthor());
|
|
|
23 |
this->TextVersion->Text = SystemStringFromCyString(p->GetVersion());
|
|
|
24 |
this->TextDesc->Text = SystemStringFromCyString(p->GetDescription().FindReplace("<br>", "\n").StripHTML());
|
|
|
25 |
this->TextCreated->Text = SystemStringFromCyString(p->GetCreationDate());
|
|
|
26 |
ButNoMod->Enabled = true;
|
|
|
27 |
|
|
|
28 |
// update graphic
|
|
|
29 |
bool addedIcon = false;
|
|
|
30 |
C_File *picFile = p->GetFirstFile(FILETYPE_ADVERT);
|
|
|
31 |
if ( picFile )
|
|
|
32 |
{
|
|
|
33 |
System::String ^pic = SystemStringFromCyString(picFile->GetFilePointer());
|
|
|
34 |
if ( System::IO::File::Exists(pic) )
|
|
|
35 |
{
|
|
|
36 |
Bitmap ^myBitmap = gcnew Bitmap(pic);
|
|
|
37 |
if ( myBitmap )
|
|
|
38 |
{
|
|
|
39 |
this->PictureBox->Image = dynamic_cast<Image ^>(myBitmap);
|
|
|
40 |
addedIcon = true;
|
|
|
41 |
}
|
|
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
if ( !addedIcon )
|
|
|
46 |
{
|
|
|
47 |
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(ModSelector::typeid));
|
|
|
48 |
System::Drawing::Icon ^icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
|
|
|
49 |
this->PictureBox->Image = icon->ToBitmap();
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
else
|
|
|
53 |
{
|
|
|
54 |
this->TextMod->Text = "N/A";
|
|
|
55 |
this->TextAuthor->Text = "";
|
|
|
56 |
this->TextVersion->Text = "";
|
|
|
57 |
this->TextCreated->Text = "";
|
|
|
58 |
this->TextDesc->Text = "";
|
|
|
59 |
this->PictureBox->Image = nullptr;
|
|
|
60 |
ButNoMod->Enabled = false;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
// now update the mods list
|
|
|
64 |
// first any installed mods
|
|
|
65 |
this->UpdatePackages();
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
void ModSelector::UpdatePackages()
|
|
|
69 |
{
|
|
|
70 |
m_pPackages->AssignPackageNumbers();
|
|
|
71 |
ListAvailable->Items->Clear();
|
|
|
72 |
ListAvailable->Groups->Clear();
|
|
|
73 |
ListAvailable->SmallImageList = gcnew ImageList();
|
|
|
74 |
ListAvailable->LargeImageList = ListAvailable->SmallImageList;
|
|
|
75 |
|
|
|
76 |
// display the installed mods
|
|
|
77 |
ListViewGroup ^group = gcnew ListViewGroup("Installed Mods", HorizontalAlignment::Left);
|
|
|
78 |
ListAvailable->Groups->Add(group);
|
|
|
79 |
|
|
|
80 |
for ( CBaseFile *p = m_pPackages->FirstPackage(); p; p = m_pPackages->NextPackage() )
|
|
|
81 |
{
|
|
|
82 |
if ( !p->IsMod() )
|
|
|
83 |
continue;
|
|
|
84 |
if ( p == m_pPackages->GetEnabledMod() )
|
|
|
85 |
continue;
|
|
|
86 |
|
|
|
87 |
m_bFoundPackages = true;
|
|
|
88 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(p->GetLanguageName(m_pPackages->GetLanguage())));
|
|
|
89 |
item->SubItems->Add(SystemStringFromCyString(p->GetAuthor()));
|
|
|
90 |
item->SubItems->Add(SystemStringFromCyString(p->GetVersion()));
|
|
|
91 |
item->SubItems->Add(SystemStringFromCyString(p->GetCreationDate()));
|
|
|
92 |
ListAvailable->Items->Add(item);
|
|
|
93 |
item->Tag = SystemStringFromCyString(CyString::Number(p->GetNum()));
|
|
|
94 |
|
|
|
95 |
item->Group = group;
|
|
|
96 |
if ( p->GetIcon() )
|
|
|
97 |
PluginManager::DisplayListIcon(p, ListAvailable, item);
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
if ( m_lAvailablePackages )
|
|
|
101 |
{
|
|
|
102 |
// display the available mods
|
|
|
103 |
ListViewGroup ^availGroup = gcnew ListViewGroup("Available Mods", HorizontalAlignment::Left);
|
|
|
104 |
ListAvailable->Groups->Add(availGroup);
|
|
|
105 |
|
|
|
106 |
for ( CBaseFile *p = m_lAvailablePackages->First(); p; p = m_lAvailablePackages->Next() )
|
|
|
107 |
{
|
|
|
108 |
if ( !p->IsMod() )
|
|
|
109 |
continue;
|
|
|
110 |
|
|
|
111 |
// check if its already installed
|
|
|
112 |
if ( m_pPackages->FindSpkPackage(p->GetName(), p->GetAuthor()) )
|
|
|
113 |
continue;
|
|
|
114 |
|
|
|
115 |
m_bFoundPackages = true;
|
|
|
116 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(p->GetLanguageName(m_pPackages->GetLanguage())));
|
|
|
117 |
item->SubItems->Add(SystemStringFromCyString(p->GetAuthor()));
|
|
|
118 |
item->SubItems->Add(SystemStringFromCyString(p->GetVersion()));
|
|
|
119 |
item->SubItems->Add(SystemStringFromCyString(p->GetCreationDate()));
|
|
|
120 |
ListAvailable->Items->Add(item);
|
|
|
121 |
item->Tag = SystemStringFromCyString(CyString::Number(p->GetNum()));
|
|
|
122 |
|
|
|
123 |
item->Group = availGroup;
|
|
|
124 |
if ( p->GetIcon() )
|
|
|
125 |
PluginManager::DisplayListIcon(p, ListAvailable, item);
|
|
|
126 |
}
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
if ( m_pPackages->AnyAvailablePackages(PACKAGETYPE_MOD) )
|
|
|
130 |
{
|
|
|
131 |
// display the available mods
|
|
|
132 |
ListViewGroup ^availGroup = gcnew ListViewGroup("Downloadable Mods", HorizontalAlignment::Left);
|
|
|
133 |
ListAvailable->Groups->Add(availGroup);
|
|
|
134 |
|
|
|
135 |
for ( SAvailablePackage *ap = m_pPackages->GetAvailablePackageList()->First(); ap; ap = m_pPackages->GetAvailablePackageList()->Next() )
|
|
|
136 |
{
|
|
|
137 |
if ( ap->iType != PACKAGETYPE_MOD ) continue; // only display mods
|
|
|
138 |
m_bFoundPackages = true;
|
|
|
139 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(ap->sName));
|
|
|
140 |
item->SubItems->Add(SystemStringFromCyString(ap->sAuthor));
|
|
|
141 |
item->SubItems->Add(SystemStringFromCyString(ap->sVersion));
|
|
|
142 |
item->SubItems->Add(SystemStringFromCyString(ap->sUpdated));
|
|
|
143 |
item->Tag = SystemStringFromCyString(ap->sFilename);
|
|
|
144 |
item->Group = availGroup;
|
|
|
145 |
ListAvailable->Items->Add(item);
|
|
|
146 |
}
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
ListAvailable->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
150 |
ModSelected(ListAvailable, gcnew System::EventArgs());
|
|
|
151 |
}
|
|
|
152 |
|
|
|
153 |
void ModSelector::UpdateControls()
|
|
|
154 |
{
|
|
|
155 |
ListAvailable->FullRowSelect = true;
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
void ModSelector::FindPackages_Directory(String ^dir)
|
|
|
159 |
{
|
|
|
160 |
if ( Directory::Exists(dir) )
|
|
|
161 |
{
|
|
|
162 |
this->FindPackages(dir);
|
|
|
163 |
|
|
|
164 |
array <System::String ^> ^Dirs = Directory::GetDirectories(dir);
|
|
|
165 |
if ( Dirs )
|
|
|
166 |
{
|
|
|
167 |
for ( int i = 0; i < Dirs->Length; i++ )
|
|
|
168 |
this->FindPackages_Directory(Dirs[i]);
|
|
|
169 |
}
|
|
|
170 |
}
|
|
|
171 |
}
|
|
|
172 |
|
|
|
173 |
void ModSelector::FindPackages(String ^dir)
|
|
|
174 |
{
|
|
|
175 |
if ( !Directory::Exists(dir) )
|
|
|
176 |
return;
|
|
|
177 |
|
|
|
178 |
array <System::String ^> ^Files = Directory::GetFiles(dir, "*.spk");
|
|
|
179 |
|
|
|
180 |
for ( int i = 0; i < Files->Length; i++ )
|
|
|
181 |
{
|
|
|
182 |
CyString file = CyStringFromSystemString(Files[i]);
|
|
|
183 |
int error = 0;
|
|
|
184 |
CBaseFile *p = m_pPackages->OpenPackage(file, &error, 0, SPKREAD_NODATA);
|
|
|
185 |
if ( !p )
|
|
|
186 |
continue;
|
|
|
187 |
if ( !p->IsMod() || m_pPackages->FindSpkPackage(p->GetName(), p->GetAuthor()) )
|
|
|
188 |
{
|
|
|
189 |
delete p;
|
|
|
190 |
continue;
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
// check its for the correct game
|
|
|
194 |
if ( !p->CheckGameCompatability(m_pPackages->GetGame()) )
|
|
|
195 |
{
|
|
|
196 |
delete p;
|
|
|
197 |
continue;
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
// check if its already on the list
|
|
|
201 |
bool found = false;
|
|
|
202 |
for ( CBaseFile *checkp = m_lAvailablePackages->First(); checkp; checkp = m_lAvailablePackages->Next() )
|
|
|
203 |
{
|
|
|
204 |
if ( p->GetName().Compare(checkp->GetName()) && p->GetAuthor().Compare(checkp->GetAuthor()) )
|
|
|
205 |
{
|
|
|
206 |
found = true;
|
|
|
207 |
break;
|
|
|
208 |
}
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
if ( found )
|
|
|
212 |
{
|
|
|
213 |
delete p;
|
|
|
214 |
continue;
|
|
|
215 |
}
|
|
|
216 |
|
|
|
217 |
if ( p->GetIcon() )
|
|
|
218 |
{
|
|
|
219 |
bool addedIcon = false;
|
|
|
220 |
p->ReadIconFileToMemory();
|
|
|
221 |
p->GetIcon()->SetFilename(m_pPackages->GetTempDirectory().FindReplace("\\", "/") + "/" + p->GetAuthor() + "_" + p->GetName() + "." + p->GetIconExt());
|
|
|
222 |
p->GetIcon()->SetFullDir(m_pPackages->GetTempDirectory());
|
|
|
223 |
if ( p->GetIcon()->UncompressData() )
|
|
|
224 |
{
|
|
|
225 |
if ( p->GetIcon()->WriteFilePointer() )
|
|
|
226 |
addedIcon = true;
|
|
|
227 |
}
|
|
|
228 |
|
|
|
229 |
if ( !addedIcon )
|
|
|
230 |
p->SetIcon(NULL, "");
|
|
|
231 |
}
|
|
|
232 |
// get an advert to display
|
|
|
233 |
if ( p->GetFirstFile(FILETYPE_ADVERT) )
|
|
|
234 |
{
|
|
|
235 |
bool done = false;
|
|
|
236 |
C_File *f = p->GetFirstFile(FILETYPE_ADVERT);
|
|
|
237 |
if ( p->ReadFileToMemory(f) )
|
|
|
238 |
{
|
|
|
239 |
f->SetFullDir(m_pPackages->GetTempDirectory());
|
|
|
240 |
if ( f->UncompressData() )
|
|
|
241 |
{
|
|
|
242 |
if ( f->WriteFilePointer() )
|
|
|
243 |
done = true;
|
|
|
244 |
}
|
|
|
245 |
}
|
|
|
246 |
|
|
|
247 |
if ( !done )
|
|
|
248 |
f->DeleteData();
|
|
|
249 |
}
|
|
|
250 |
|
|
|
251 |
m_lAvailablePackages->push_back(p);
|
|
|
252 |
}
|
|
|
253 |
}
|
|
|
254 |
|
|
|
255 |
void ModSelector::FindPackages_Current(String ^curDir)
|
|
|
256 |
{
|
|
|
257 |
this->FindPackages(curDir + "\\Addons\\Mods");
|
|
|
258 |
|
|
|
259 |
if ( Directory::Exists(curDir + "\\Addons") )
|
|
|
260 |
{
|
|
|
261 |
if ( Directory::Exists(curDir + "\\Addons\\Mods") )
|
|
|
262 |
this->FindPackages_Directory(curDir + "\\Addons\\Mods");
|
|
|
263 |
}
|
|
|
264 |
|
|
|
265 |
if ( Directory::Exists(curDir + "\\Downloads") )
|
|
|
266 |
this->FindPackages_Directory(curDir + "\\Downloads");
|
|
|
267 |
}
|
|
|
268 |
|
|
|
269 |
void ModSelector::FindPackages()
|
|
|
270 |
{
|
|
|
271 |
if ( !m_lAvailablePackages )
|
|
|
272 |
m_lAvailablePackages = new CLinkList<CBaseFile>;
|
|
|
273 |
|
|
|
274 |
FindPackages_Current(System::IO::FileInfo(System::Windows::Forms::Application::ExecutablePath).DirectoryName);
|
|
|
275 |
FindPackages_Current(Directory::GetCurrentDirectory());
|
|
|
276 |
|
|
|
277 |
// find packages from registry key
|
|
|
278 |
RegistryKey ^searchKey = Registry::CurrentUser->OpenSubKey("Software\\Egosoft\\SuperBox");
|
|
|
279 |
if ( searchKey )
|
|
|
280 |
{
|
|
|
281 |
String ^dir = System::Convert::ToString(searchKey->GetValue("Addons"));
|
|
|
282 |
if ( dir )
|
|
|
283 |
this->FindPackages_Directory(dir);
|
|
|
284 |
}
|
|
|
285 |
|
|
|
286 |
// find packages from DVD
|
|
|
287 |
cli::array<IO::DriveInfo ^> ^Drives = IO::DriveInfo::GetDrives();
|
|
|
288 |
if ( Drives )
|
|
|
289 |
{
|
|
|
290 |
for ( int i = 0; i < Drives->Length; i++ )
|
|
|
291 |
{
|
|
|
292 |
IO::DriveInfo ^info = Drives[i];
|
|
|
293 |
if ( info->DriveType != IO::DriveType::CDRom )
|
|
|
294 |
continue;
|
|
|
295 |
if ( info->IsReady )
|
|
|
296 |
this->FindPackages_Directory(info->RootDirectory + "XPluginManager");
|
|
|
297 |
}
|
|
|
298 |
}
|
|
|
299 |
|
|
|
300 |
// read all game directories extra content
|
|
|
301 |
this->FindPackages_Directory(SystemStringFromCyString(m_pPackages->GetCurrentDirectoryW().FindReplace("/","\\")) + "\\ExtraContent");
|
|
|
302 |
|
|
|
303 |
|
|
|
304 |
int num = -1;
|
|
|
305 |
for ( CBaseFile *p = m_lAvailablePackages->First(); p; p = m_lAvailablePackages->Next() )
|
|
|
306 |
{
|
|
|
307 |
p->SetNum(num);
|
|
|
308 |
--num;
|
|
|
309 |
}
|
|
|
310 |
}
|
|
|
311 |
|
|
|
312 |
void ModSelector::RemovePackages()
|
|
|
313 |
{
|
|
|
314 |
if ( m_lAvailablePackages )
|
|
|
315 |
{
|
|
|
316 |
for ( CBaseFile *p = m_lAvailablePackages->First(); p; p = m_lAvailablePackages->Next() )
|
|
|
317 |
{
|
|
|
318 |
if ( p->GetIcon() )
|
|
|
319 |
CFileIO(p->GetIcon()->GetFilePointer()).Remove();
|
|
|
320 |
delete p;
|
|
|
321 |
}
|
|
|
322 |
m_lAvailablePackages->destroy();
|
|
|
323 |
delete m_lAvailablePackages;
|
|
|
324 |
}
|
|
|
325 |
m_lAvailablePackages = NULL;
|
|
|
326 |
}
|
|
|
327 |
|
|
|
328 |
//
|
|
|
329 |
// Events
|
|
|
330 |
//
|
|
|
331 |
void ModSelector::SetupEvents()
|
|
|
332 |
{
|
|
|
333 |
ListAvailable->SelectedIndexChanged += gcnew EventHandler(this, &PluginManager::ModSelector::ModSelected);
|
|
|
334 |
ButSelect->Click += gcnew EventHandler(this, &PluginManager::ModSelector::SelectModEvent);
|
|
|
335 |
ButNoMod->Click += gcnew EventHandler(this, &PluginManager::ModSelector::NoModEvent);
|
|
|
336 |
ButUninstall->Click += gcnew EventHandler(this, &PluginManager::ModSelector::UninstallModEvent);
|
|
|
337 |
}
|
|
|
338 |
|
|
|
339 |
void ModSelector::UpdateEaseOfUse(bool disable, int value)
|
|
|
340 |
{
|
|
|
341 |
if ( disable )
|
|
|
342 |
{
|
|
|
343 |
this->PicEase1->Visible = false;
|
|
|
344 |
this->PicEase2->Visible = false;
|
|
|
345 |
this->PicEase3->Visible = false;
|
|
|
346 |
this->PicEase4->Visible = false;
|
|
|
347 |
this->PicEase5->Visible = false;
|
|
|
348 |
}
|
|
|
349 |
|
|
|
350 |
if ( value > -1 )
|
|
|
351 |
{
|
|
|
352 |
// ease of use rating
|
|
|
353 |
if ( value < 1 )
|
|
|
354 |
LabEaseNA->Show();
|
|
|
355 |
if ( value >= 1 )
|
|
|
356 |
PicEase1->Show();
|
|
|
357 |
if ( value >= 2 )
|
|
|
358 |
PicEase2->Show();
|
|
|
359 |
if ( value >= 3 )
|
|
|
360 |
PicEase3->Show();
|
|
|
361 |
if ( value >= 4 )
|
|
|
362 |
PicEase4->Show();
|
|
|
363 |
if ( value >= 5 )
|
|
|
364 |
PicEase5->Show();
|
|
|
365 |
}
|
|
|
366 |
}
|
|
|
367 |
|
|
|
368 |
void ModSelector::UpdateRecommended(bool disable, int value)
|
|
|
369 |
{
|
|
|
370 |
if ( disable )
|
|
|
371 |
{
|
|
|
372 |
this->PicRec1->Visible = false;
|
|
|
373 |
this->PicRec2->Visible = false;
|
|
|
374 |
this->PicRec3->Visible = false;
|
|
|
375 |
this->PicRec4->Visible = false;
|
|
|
376 |
this->PicRec5->Visible = false;
|
|
|
377 |
}
|
|
|
378 |
|
|
|
379 |
if ( value > -1 )
|
|
|
380 |
{
|
|
|
381 |
// Recommanded rating
|
|
|
382 |
if ( value < 1 )
|
|
|
383 |
LabelRecNA->Show();
|
|
|
384 |
if ( value >= 1 )
|
|
|
385 |
PicRec1->Show();
|
|
|
386 |
if ( value >= 2 )
|
|
|
387 |
PicRec2->Show();
|
|
|
388 |
if ( value >= 3 )
|
|
|
389 |
PicRec3->Show();
|
|
|
390 |
if ( value >= 4 )
|
|
|
391 |
PicRec4->Show();
|
|
|
392 |
if ( value >= 5 )
|
|
|
393 |
PicRec5->Show();
|
|
|
394 |
}
|
|
|
395 |
}
|
|
|
396 |
|
|
|
397 |
void ModSelector::UpdateGameChanging(bool disable, int value)
|
|
|
398 |
{
|
|
|
399 |
if ( disable )
|
|
|
400 |
{
|
|
|
401 |
this->PicChange1->Visible = false;
|
|
|
402 |
this->PicChange2->Visible = false;
|
|
|
403 |
this->PicChange3->Visible = false;
|
|
|
404 |
this->PicChange4->Visible = false;
|
|
|
405 |
this->PicChange5->Visible = false;
|
|
|
406 |
}
|
|
|
407 |
|
|
|
408 |
if ( value > -1 )
|
|
|
409 |
{
|
|
|
410 |
// game changing rating
|
|
|
411 |
if ( value < 1 )
|
|
|
412 |
LabelChangeNA->Show();
|
|
|
413 |
if ( value >= 1 )
|
|
|
414 |
PicChange1->Show();
|
|
|
415 |
if ( value >= 2 )
|
|
|
416 |
PicChange2->Show();
|
|
|
417 |
if ( value >= 3 )
|
|
|
418 |
PicChange3->Show();
|
|
|
419 |
if ( value >= 4 )
|
|
|
420 |
PicChange4->Show();
|
|
|
421 |
if ( value >= 5 )
|
|
|
422 |
PicChange5->Show();
|
|
|
423 |
}
|
|
|
424 |
}
|
|
|
425 |
|
|
|
426 |
void ModSelector::ModSelected(System::Object ^Sender, System::EventArgs ^E)
|
|
|
427 |
{
|
|
|
428 |
bool enabled = false;
|
|
|
429 |
|
|
|
430 |
m_pSelectedMod = NULL;
|
|
|
431 |
m_pSelectedPackage = NULL;
|
|
|
432 |
|
|
|
433 |
ButUninstall->Visible = false;
|
|
|
434 |
button1->Visible = false;
|
|
|
435 |
this->PictureSelected->Image = nullptr;
|
|
|
436 |
UpdateEaseOfUse(true, -1);
|
|
|
437 |
UpdateGameChanging(true, -1);
|
|
|
438 |
UpdateRecommended(true, -1);
|
|
|
439 |
this->LabEaseNA->Visible = false;
|
|
|
440 |
this->LabelChangeNA->Visible = false;
|
|
|
441 |
this->LabelRecNA->Visible = false;
|
|
|
442 |
|
|
|
443 |
bool dontEnable = false;
|
|
|
444 |
if ( ListAvailable->SelectedItems->Count )
|
|
|
445 |
{
|
|
|
446 |
ListViewItem ^item = ListAvailable->SelectedItems[0];
|
|
|
447 |
if ( item )
|
|
|
448 |
{
|
|
|
449 |
CyString sNum = CyStringFromSystemString(System::Convert::ToString(item->Tag));
|
|
|
450 |
int num = sNum.ToInt();
|
|
|
451 |
|
|
|
452 |
CBaseFile *p = NULL;
|
|
|
453 |
if ( num || sNum == "0" )
|
|
|
454 |
{
|
|
|
455 |
// its an installed mod
|
|
|
456 |
if ( num >= 0 )
|
|
|
457 |
{
|
|
|
458 |
p = m_pPackages->GetPackageAt(num);
|
|
|
459 |
ButUninstall->Visible = true;
|
|
|
460 |
}
|
|
|
461 |
//else its from a file
|
|
|
462 |
else
|
|
|
463 |
{
|
|
|
464 |
p = m_lAvailablePackages->Get(-1 - num);
|
|
|
465 |
}
|
|
|
466 |
|
|
|
467 |
if ( p )
|
|
|
468 |
{
|
|
|
469 |
enabled = true;
|
|
|
470 |
this->TextDescSelected->Text = SystemStringFromCyString(p->GetDescription().FindReplace("<br>", "\n").StripHTML());
|
|
|
471 |
m_pSelectedMod = p;
|
|
|
472 |
|
|
|
473 |
// update graphic
|
|
|
474 |
bool addedIcon = false;
|
|
|
475 |
C_File *picFile = p->GetFirstFile(FILETYPE_ADVERT);
|
|
|
476 |
if ( picFile )
|
|
|
477 |
{
|
|
|
478 |
System::String ^pic = SystemStringFromCyString(picFile->GetFilePointer());
|
|
|
479 |
if ( System::IO::File::Exists(pic) )
|
|
|
480 |
{
|
|
|
481 |
Bitmap ^myBitmap = gcnew Bitmap(pic);
|
|
|
482 |
if ( myBitmap )
|
|
|
483 |
{
|
|
|
484 |
this->PictureSelected->Image = dynamic_cast<Image ^>(myBitmap);
|
|
|
485 |
addedIcon = true;
|
|
|
486 |
}
|
|
|
487 |
}
|
|
|
488 |
}
|
|
|
489 |
|
|
|
490 |
if ( !addedIcon )
|
|
|
491 |
{
|
|
|
492 |
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(ModSelector::typeid));
|
|
|
493 |
System::Drawing::Icon ^icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
|
|
|
494 |
this->PictureSelected->Image = icon->ToBitmap();
|
|
|
495 |
}
|
|
|
496 |
|
|
|
497 |
// ratings display
|
|
|
498 |
UpdateEaseOfUse(false, p->GetEaseOfUse());
|
|
|
499 |
UpdateGameChanging(false, p->GetGameChanging());
|
|
|
500 |
UpdateRecommended(false, p->GetRecommended());
|
|
|
501 |
}
|
|
|
502 |
}
|
|
|
503 |
else // otherwise its a name (download package)
|
|
|
504 |
{
|
|
|
505 |
SAvailablePackage *p = m_pPackages->FindAvailablePackage(sNum);
|
|
|
506 |
if ( p )
|
|
|
507 |
{
|
|
|
508 |
enabled = true;
|
|
|
509 |
dontEnable = true;
|
|
|
510 |
this->button1->Visible = true;
|
|
|
511 |
this->TextDescSelected->Text = SystemStringFromCyString(p->sDesc.findreplace("<br>", "\n").StripHTML());
|
|
|
512 |
|
|
|
513 |
// ratings display
|
|
|
514 |
UpdateEaseOfUse(false, p->iEase);
|
|
|
515 |
UpdateGameChanging(false, p->iChanging);
|
|
|
516 |
UpdateRecommended(false, p->iRec);
|
|
|
517 |
|
|
|
518 |
// default display image
|
|
|
519 |
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(ModSelector::typeid));
|
|
|
520 |
System::Drawing::Icon ^icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
|
|
|
521 |
this->PictureSelected->Image = icon->ToBitmap();
|
|
|
522 |
|
|
|
523 |
m_pSelectedPackage = p;
|
|
|
524 |
}
|
|
|
525 |
}
|
|
|
526 |
}
|
|
|
527 |
}
|
|
|
528 |
|
|
|
529 |
// nothing selected
|
|
|
530 |
if ( !enabled )
|
|
|
531 |
TextDescSelected->Text = "";
|
|
|
532 |
|
|
|
533 |
ButSelect->Enabled = (dontEnable) ? false : enabled;
|
|
|
534 |
}
|
|
|
535 |
|
|
|
536 |
void ModSelector::SelectModEvent(System::Object ^Sender, System::EventArgs ^E)
|
|
|
537 |
{
|
|
|
538 |
}
|
|
|
539 |
|
|
|
540 |
void ModSelector::NoModEvent(System::Object ^Sender, System::EventArgs ^E)
|
|
|
541 |
{
|
|
|
542 |
}
|
|
|
543 |
|
|
|
544 |
void ModSelector::UninstallModEvent(System::Object ^Sender, System::EventArgs ^E)
|
|
|
545 |
{
|
|
|
546 |
}
|
|
|
547 |
|
|
|
548 |
void ModSelector::UpdateDetails()
|
|
|
549 |
{
|
|
|
550 |
if ( m_bDetails )
|
|
|
551 |
{
|
|
|
552 |
ButDetails->Text = "Hide Details <<<";
|
|
|
553 |
this->PanelDetails->Show();
|
|
|
554 |
}
|
|
|
555 |
else
|
|
|
556 |
{
|
|
|
557 |
ButDetails->Text = "Show Details >>>";
|
|
|
558 |
this->PanelDetails->Hide();
|
|
|
559 |
}
|
|
|
560 |
}
|
|
|
561 |
|
|
|
562 |
void ModSelector::DownloadPackage()
|
|
|
563 |
{
|
|
|
564 |
if ( !m_pSelectedPackage )
|
|
|
565 |
{
|
|
|
566 |
this->button1->Visible = false;
|
|
|
567 |
return;
|
|
|
568 |
}
|
|
|
569 |
|
|
|
570 |
CheckUpdate ^update = gcnew CheckUpdate(m_pPackages, m_pImageList);
|
|
|
571 |
update->SetDownloader();
|
|
|
572 |
update->OnePackage(m_pSelectedPackage);
|
|
|
573 |
if ( update->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
574 |
{
|
|
|
575 |
this->DialogResult = Windows::Forms::DialogResult::Yes;
|
|
|
576 |
for ( int i = 0; i < update->GetInstallList()->Count; i++ )
|
|
|
577 |
cli::safe_cast<MainGui ^>(this->Owner)->InstallPackage(Convert::ToString(update->GetInstallList()[i]), false, false, true);
|
|
|
578 |
this->Close();
|
|
|
579 |
}
|
|
|
580 |
}
|
|
|
581 |
|
|
|
582 |
}
|