1 |
cycrow |
1 |
#include "../StdAfx.h"
|
|
|
2 |
#include "MainGui.h"
|
|
|
3 |
#include "ModSelector.h"
|
|
|
4 |
#include "PackageBrowser.h"
|
|
|
5 |
#include "InstallPackageDialog.h"
|
|
|
6 |
#include "CompareList.h"
|
|
|
7 |
#include "EditGlobals.h"
|
|
|
8 |
#include "DownloadPackageList.h"
|
|
|
9 |
#include "FileLog.h"
|
|
|
10 |
#include "MessageBoxDetails.h"
|
|
|
11 |
#include <shellapi.h>
|
|
|
12 |
|
|
|
13 |
using System::Configuration::ApplicationSettingsBase;
|
|
|
14 |
|
|
|
15 |
#undef GetEnvironmentVariable
|
|
|
16 |
|
|
|
17 |
enum {LISTGROUP_INSTALLED, LISTGROUP_SHIP, LISTGROUP_FAKE, LISTGROUP_LIBRARY, LISTGROUP_MOD, LISTGROUP_ARCHIVE};
|
|
|
18 |
|
|
|
19 |
namespace PluginManager {
|
|
|
20 |
|
|
|
21 |
void MainGui::CheckProtectedDir()
|
|
|
22 |
{
|
|
|
23 |
CyString dir;
|
|
|
24 |
if ( m_pDirList->Head() ) {
|
|
|
25 |
m_bDirLocked = false;
|
|
|
26 |
dir = m_pDirList->Head()->str;
|
|
|
27 |
|
|
|
28 |
// write a file in the directory
|
|
|
29 |
String ^sDir = SystemStringFromCyString(dir.findreplace("/", "\\"));
|
|
|
30 |
bool written = true;
|
|
|
31 |
StreamWriter ^sw = nullptr;
|
|
|
32 |
try {
|
|
|
33 |
sw = System::IO::File::CreateText(sDir + "\\checklock.xpmtest");
|
|
|
34 |
sw->WriteLine("can write");
|
|
|
35 |
}
|
|
|
36 |
catch (System::Exception ^) {
|
|
|
37 |
written = false;
|
|
|
38 |
}
|
|
|
39 |
finally {
|
|
|
40 |
if ( sw )
|
|
|
41 |
delete (IDisposable ^)sw;
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
// check its there
|
|
|
45 |
if ( written ) {
|
|
|
46 |
written = false;
|
|
|
47 |
cli::array<String ^> ^dirList = IO::Directory::GetFiles(sDir, "*.xpmtest");
|
|
|
48 |
if ( dirList && dirList->Length ) {
|
|
|
49 |
for ( int i = 0; i < dirList->Length; i++ ) {
|
|
|
50 |
if ( IO::FileInfo(dirList[i]).Name == "checklock.xpmtest" ) {
|
|
|
51 |
written = true;
|
|
|
52 |
break;
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
}
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
// remove it
|
|
|
59 |
if ( !IO::File::Exists(sDir + "\\checklock.xpmtest") )
|
|
|
60 |
written = false;
|
|
|
61 |
else {
|
|
|
62 |
try {
|
|
|
63 |
IO::File::Delete(sDir + "\\checklock.xpmtest");
|
|
|
64 |
if ( IO::File::Exists(sDir + "\\checklock.xpmtest") )
|
|
|
65 |
written = false;
|
|
|
66 |
}
|
|
|
67 |
catch (System::Exception ^) {
|
|
|
68 |
written = false;
|
|
|
69 |
}
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
if ( !written ) {
|
|
|
73 |
MessageBox::Show(this, "ERROR: The game directory:\n" + SystemStringFromCyString(dir) + "\n\nIs locked and unable to add/remove any plugins", "Directory Locked", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
|
|
74 |
m_bDirLocked = true;
|
|
|
75 |
}
|
|
|
76 |
else {
|
|
|
77 |
dir = dir.findreplace("/", "\\");
|
|
|
78 |
bool found = false;
|
|
|
79 |
|
|
|
80 |
String ^folder = Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles);
|
|
|
81 |
if ( dir.IsIn(CyStringFromSystemString(folder)) )
|
|
|
82 |
found = true;
|
|
|
83 |
else {
|
|
|
84 |
folder = Environment::GetEnvironmentVariable("ProgramFiles(x86)");
|
|
|
85 |
if ( dir.IsIn(CyStringFromSystemString(folder)) )
|
|
|
86 |
found = true;
|
|
|
87 |
}
|
|
|
88 |
if ( !found ) {
|
|
|
89 |
folder = Environment::GetEnvironmentVariable("ProgramFiles");
|
|
|
90 |
if ( dir.IsIn(CyStringFromSystemString(folder)) )
|
|
|
91 |
found = true;
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
if ( found ) {
|
|
|
95 |
if ( !m_pPackages->IsSupressProtectedWarning() ) {
|
|
|
96 |
if ( MessageBox::Show(this, "WARNING: The game directory:\n" + SystemStringFromCyString(dir) + "\n\nIs in a protected directory (" + SystemStringFromCyString(CFileIO(dir).GetDir().GetToken("/", 1, 2).findreplace("/", "\\")) + ")\n\nThis might cause problems with installing anything, its better to move to game elsewhere, or you may need to run the Plugin Manager with admin access rights\n\nWould you like to surpress this warning in the future?", "Protected Directory", MessageBoxButtons::YesNo, MessageBoxIcon::Warning) == Windows::Forms::DialogResult::Yes ) {
|
|
|
97 |
m_pPackages->SurpressProtectedWarning();
|
|
|
98 |
}
|
|
|
99 |
}
|
|
|
100 |
}
|
|
|
101 |
}
|
|
|
102 |
}
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
void MainGui::GetGameDirs(CyString &dir, bool askDir, bool askDirAddon)
|
|
|
106 |
{
|
|
|
107 |
if ( CDirIO(dir).Exists() )
|
|
|
108 |
{
|
|
|
109 |
CyString gameName = m_pPackages->GetGameName(dir);
|
|
|
110 |
if ( !gameName.Empty() )
|
|
|
111 |
{
|
|
|
112 |
if ( !m_pDirList->FindString(dir) && !m_pRemovedDirList->FindString(dir) ) {
|
|
|
113 |
int lang = m_pPackages->GetGameLanguage(dir);
|
|
|
114 |
if ( !askDir || MessageBox::Show(this, "New Game Directory Found:\n" + SystemStringFromCyString(dir) + " [" + SystemStringFromCyString(gameName) + "]\n\nDo you wish to add this?", "Add New Game", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == Windows::Forms::DialogResult::Yes ) {
|
|
|
115 |
if ( lang )
|
|
|
116 |
m_pDirList->PushFront(dir, CyString::Number(lang) + "|" + gameName);
|
|
|
117 |
else
|
|
|
118 |
m_pDirList->PushFront(dir, gameName);
|
|
|
119 |
}
|
|
|
120 |
else {
|
|
|
121 |
m_pRemovedDirList->PushBack(dir);
|
|
|
122 |
}
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
// check for any addons
|
|
|
126 |
CyStringList addons;
|
|
|
127 |
if ( m_pPackages->GetGameAddons(addons, dir) ) {
|
|
|
128 |
for ( SStringList *str = addons.Head(); str; str = str->next ) {
|
|
|
129 |
CyString exe = CDirIO(dir).File(str->str);
|
|
|
130 |
dir = CDirIO(dir).Dir(str->data);
|
|
|
131 |
if ( CDirIO(dir).Exists() && !m_pDirList->FindString(dir) && !m_pRemovedDirList->FindString(dir) ) {
|
|
|
132 |
gameName = m_pPackages->GetGameName(exe);
|
|
|
133 |
if ( !gameName.Empty() ) {
|
|
|
134 |
int lang = m_pPackages->GetGameLanguage(dir);
|
|
|
135 |
if ( !askDirAddon || MessageBox::Show(this, "New Game Directory Found:\n" + SystemStringFromCyString(dir) + " [" + SystemStringFromCyString(gameName) + "]\n\nDo you wish to add this?", "Add New Game", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == Windows::Forms::DialogResult::Yes ) {
|
|
|
136 |
if ( lang )
|
|
|
137 |
m_pDirList->PushFront(dir, CyString::Number(lang) + "|" + gameName);
|
|
|
138 |
else
|
|
|
139 |
m_pDirList->PushFront(dir, gameName);
|
|
|
140 |
}
|
|
|
141 |
else {
|
|
|
142 |
m_pRemovedDirList->PushBack(dir);
|
|
|
143 |
}
|
|
|
144 |
}
|
|
|
145 |
}
|
|
|
146 |
}
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
}
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
void MainGui::UpdateDirList()
|
|
|
153 |
{
|
|
|
154 |
ComboDir->Items->Clear();
|
|
|
155 |
|
|
|
156 |
if ( !m_pDirList || !m_pDirList->Head() )
|
|
|
157 |
return;
|
|
|
158 |
|
|
|
159 |
for ( SStringList *node = m_pDirList->Head(); node; node = node->next )
|
|
|
160 |
{
|
|
|
161 |
System::String ^str;
|
|
|
162 |
if ( node->data.IsIn("|") )
|
|
|
163 |
str = SystemStringFromCyString(node->str + " [" + node->data.GetToken("|", 2) + "] (Language: " + CPackages::ConvertLanguage(node->data.GetToken("|", 1, 1).ToInt()) + ")");
|
|
|
164 |
else
|
|
|
165 |
str = SystemStringFromCyString(node->str + " [" + node->data + "]");
|
|
|
166 |
ComboDir->Items->Add(str);
|
|
|
167 |
|
|
|
168 |
// first item
|
|
|
169 |
if ( node == m_pDirList->Head() )
|
|
|
170 |
ComboDir->Text = str;
|
|
|
171 |
}
|
|
|
172 |
|
|
|
173 |
this->UpdateRunButton();
|
|
|
174 |
}
|
|
|
175 |
|
|
|
176 |
void MainGui::UpdateRunButton()
|
|
|
177 |
{
|
|
|
178 |
ButRun->Text = "Run: " + SystemStringFromCyString(m_pPackages->GetGameName());
|
|
|
179 |
|
|
|
180 |
CyString exe = m_pPackages->GetGameExe()->GetGameRunExe(m_pPackages->GetCurrentDirectory());
|
|
|
181 |
if ( CFileIO(exe).Exists() )
|
|
|
182 |
{
|
|
|
183 |
exe = exe.FindReplace("/", "\\");
|
|
|
184 |
wchar_t wText[200];
|
|
|
185 |
::MultiByteToWideChar(CP_ACP, NULL, (char *)exe.c_str(), -1, wText, exe.Length() + 1);
|
|
|
186 |
|
|
|
187 |
System::Drawing::Icon ^myIcon;
|
|
|
188 |
SHFILEINFO *shinfo = new SHFILEINFO();
|
|
|
189 |
|
|
|
190 |
if ( FAILED(SHGetFileInfo(wText, 0, shinfo, sizeof(shinfo), SHGFI_ICON | SHGFI_LARGEICON)) )
|
|
|
191 |
{
|
|
|
192 |
if ( FAILED(SHGetFileInfo(wText, 0, shinfo, sizeof(shinfo), SHGFI_ICON | SHGFI_SMALLICON)) )
|
|
|
193 |
{
|
|
|
194 |
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MainGui::typeid));
|
|
|
195 |
this->ButRun->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"ButRun.Image")));
|
|
|
196 |
}
|
|
|
197 |
else
|
|
|
198 |
{
|
|
|
199 |
myIcon = System::Drawing::Icon::FromHandle(IntPtr(shinfo->hIcon));
|
|
|
200 |
ButRun->Image = myIcon->ToBitmap();
|
|
|
201 |
}
|
|
|
202 |
}
|
|
|
203 |
else
|
|
|
204 |
{
|
|
|
205 |
myIcon = System::Drawing::Icon::FromHandle(IntPtr(shinfo->hIcon));
|
|
|
206 |
ButRun->Image = myIcon->ToBitmap();
|
|
|
207 |
}
|
|
|
208 |
|
|
|
209 |
delete shinfo;
|
|
|
210 |
}
|
|
|
211 |
}
|
|
|
212 |
|
|
|
213 |
void MainGui::_DisplayPackages(CBaseFile *currentParent, ListViewGroup ^useGroup)
|
|
|
214 |
{
|
|
|
215 |
CLinkList<CBaseFile> packageList;
|
|
|
216 |
|
|
|
217 |
for ( CBaseFile *p = m_pPackages->FirstPackage(); p; p = m_pPackages->NextPackage() )
|
|
|
218 |
{
|
|
|
219 |
if ( p->IsMod() )
|
|
|
220 |
continue;
|
|
|
221 |
if ( p->GetAuthor().Compare("PluginManager") )
|
|
|
222 |
continue;
|
|
|
223 |
// if thier parent is a library dont add unless top level
|
|
|
224 |
if ( currentParent && p->GetParent() && p->GetParent()->GetType() == TYPE_SPK && ((CSpkFile *)p->GetParent())->IsLibrary() )
|
|
|
225 |
continue;
|
|
|
226 |
else if ( p->GetParent() == currentParent )
|
|
|
227 |
packageList.push_back(p);
|
|
|
228 |
// add any mod addons as the top level
|
|
|
229 |
else if ( p->GetParent() && p->GetParent()->IsMod() && !currentParent && p->GetParent() == m_pPackages->GetEnabledMod() )
|
|
|
230 |
packageList.push_back(p);
|
|
|
231 |
// if thier parent is a library add at top level
|
|
|
232 |
else if ( !currentParent && p->GetParent() && p->GetParent()->GetType() == TYPE_SPK && ((CSpkFile *)p->GetParent())->IsLibrary() )
|
|
|
233 |
packageList.push_back(p);
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
array<SortPackage ^> ^aPackages = gcnew array<SortPackage ^>(packageList.size());
|
|
|
237 |
array<System::String ^> ^aNames = gcnew array<System::String ^>(packageList.size());
|
|
|
238 |
|
|
|
239 |
int i = 0;
|
|
|
240 |
for ( CBaseFile *p = packageList.First(); p; p = packageList.Next(), i++ )
|
|
|
241 |
{
|
|
|
242 |
aPackages[i] = gcnew SortPackage(p);
|
|
|
243 |
if ( m_iSortingColumn == SORT_AUTHOR ) // sort by author
|
|
|
244 |
aNames[i] = SystemStringFromCyString(p->GetAuthor())->ToLower();
|
|
|
245 |
else if ( m_iSortingColumn == SORT_VERSION ) // sort by author
|
|
|
246 |
aNames[i] = SystemStringFromCyString(p->GetVersion())->ToLower();
|
|
|
247 |
else if ( m_iSortingColumn == SORT_CREATED ) // sort by author
|
|
|
248 |
{
|
|
|
249 |
CyString date = p->GetCreationDate().GetToken("/", 3, 3) + p->GetCreationDate().GetToken("/", 2, 2) + p->GetCreationDate().GetToken("/", 1, 1);
|
|
|
250 |
aNames[i] = SystemStringFromCyString(date);
|
|
|
251 |
}
|
|
|
252 |
else if ( m_iSortingColumn == SORT_ENABLE ) // sort by author
|
|
|
253 |
{
|
|
|
254 |
if ( p->IsEnabled() )
|
|
|
255 |
aNames[i] = SystemStringFromCyString(CyString::Number(1));
|
|
|
256 |
else
|
|
|
257 |
aNames[i] = SystemStringFromCyString(CyString::Number(0));
|
|
|
258 |
}
|
|
|
259 |
else if ( m_iSortingColumn == SORT_SIGNED ) // sort by author
|
|
|
260 |
{
|
|
|
261 |
if ( p->IsEnabled() )
|
|
|
262 |
aNames[i] = SystemStringFromCyString(CyString::Number(1));
|
|
|
263 |
else
|
|
|
264 |
aNames[i] = SystemStringFromCyString(CyString::Number(0));
|
|
|
265 |
}
|
|
|
266 |
else if ( m_iSortingColumn == SORT_TYPE ) // sort by type
|
|
|
267 |
{
|
|
|
268 |
if ( p->GetType() == TYPE_XSP )
|
|
|
269 |
aNames[i] = "Ship";
|
|
|
270 |
else if ( p->GetType() == TYPE_ARCHIVE )
|
|
|
271 |
aNames[i] = "- Archive -";
|
|
|
272 |
else if ( p->GetType() == TYPE_SPK )
|
|
|
273 |
aNames[i] = SystemStringFromCyString(((CSpkFile *)p)->GetScriptTypeString(m_pPackages->GetLanguage()));
|
|
|
274 |
else
|
|
|
275 |
aNames[i] = "";
|
|
|
276 |
}
|
|
|
277 |
else
|
|
|
278 |
aNames[i] = SystemStringFromCyString(p->GetLanguageName(m_pPackages->GetLanguage()))->ToLower();
|
|
|
279 |
}
|
|
|
280 |
|
|
|
281 |
Array::Sort(aNames, aPackages);
|
|
|
282 |
|
|
|
283 |
// now display
|
|
|
284 |
for ( i = 0; i < aPackages->Length; i++ )
|
|
|
285 |
{
|
|
|
286 |
CBaseFile *p = (m_bSortingAsc) ? aPackages[i]->Package : aPackages[(aPackages->Length - 1 - i)]->Package;
|
|
|
287 |
CyString name;
|
|
|
288 |
if ( p->GetType() == TYPE_ARCHIVE )
|
|
|
289 |
name = CFileIO(p->GetFilename()).GetFilename();
|
|
|
290 |
else
|
|
|
291 |
name = p->GetLanguageName(m_pPackages->GetLanguage());
|
|
|
292 |
|
|
|
293 |
int indent = 0;
|
|
|
294 |
CBaseFile *parent = p;
|
|
|
295 |
|
|
|
296 |
if ( p->GetParent() && p->GetParent()->GetType() == TYPE_SPK && ((CSpkFile *)p->GetParent())->IsLibrary() )
|
|
|
297 |
indent = 0;
|
|
|
298 |
else
|
|
|
299 |
{
|
|
|
300 |
while ( parent->GetParent() )
|
|
|
301 |
{
|
|
|
302 |
parent = parent->GetParent();
|
|
|
303 |
++indent;
|
|
|
304 |
}
|
|
|
305 |
|
|
|
306 |
if ( p->GetParent() && p->GetParent() == m_pPackages->GetEnabledMod() )
|
|
|
307 |
--indent;
|
|
|
308 |
}
|
|
|
309 |
|
|
|
310 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(name));
|
|
|
311 |
item->IndentCount = (indent * 2);
|
|
|
312 |
item->SubItems->Add(SystemStringFromCyString(p->GetAuthor()));
|
|
|
313 |
item->SubItems->Add(SystemStringFromCyString(p->GetVersion()));
|
|
|
314 |
item->SubItems->Add(SystemStringFromCyString(p->GetCreationDate()));
|
|
|
315 |
if ( p->GetType() == TYPE_XSP )
|
|
|
316 |
item->SubItems->Add("Ship");
|
|
|
317 |
else if ( p->GetType() == TYPE_ARCHIVE )
|
|
|
318 |
item->SubItems->Add("- Archive -");
|
|
|
319 |
else if ( p->GetType() == TYPE_SPK )
|
|
|
320 |
{
|
|
|
321 |
CSpkFile *spk = (CSpkFile *)p;
|
|
|
322 |
item->SubItems->Add(SystemStringFromCyString(spk->GetScriptTypeString(m_pPackages->GetLanguage())));
|
|
|
323 |
}
|
|
|
324 |
else
|
|
|
325 |
item->SubItems->Add("");
|
|
|
326 |
|
|
|
327 |
if ( p->IsEnabled() )
|
|
|
328 |
item->SubItems->Add("Yes");
|
|
|
329 |
else
|
|
|
330 |
item->SubItems->Add("No");
|
|
|
331 |
if ( p->IsSigned() )
|
|
|
332 |
item->SubItems->Add("Yes");
|
|
|
333 |
else
|
|
|
334 |
item->SubItems->Add("No");
|
|
|
335 |
item->Tag = SystemStringFromCyString(CyString::Number(p->GetNum()));
|
|
|
336 |
|
|
|
337 |
ListPackages->Items->Add(item);
|
|
|
338 |
|
|
|
339 |
if ( useGroup )
|
|
|
340 |
item->Group = useGroup;
|
|
|
341 |
else
|
|
|
342 |
{
|
|
|
343 |
int addGroup = LISTGROUP_INSTALLED;
|
|
|
344 |
if ( p->GetParent() && p->GetParent() == m_pPackages->GetEnabledMod() )
|
|
|
345 |
addGroup = LISTGROUP_MOD;
|
|
|
346 |
else if ( p->GetType() == TYPE_SPK && ((CSpkFile *)p)->IsLibrary() )
|
|
|
347 |
addGroup = LISTGROUP_LIBRARY;
|
|
|
348 |
else if ( p->GetType() == TYPE_SPK && ((CSpkFile *)p)->IsFakePatch() )
|
|
|
349 |
addGroup = LISTGROUP_FAKE;
|
|
|
350 |
else if ( p->GetType() == TYPE_XSP )
|
|
|
351 |
addGroup = LISTGROUP_SHIP;
|
|
|
352 |
else if ( p->GetType() == TYPE_ARCHIVE )
|
|
|
353 |
addGroup = LISTGROUP_ARCHIVE;
|
|
|
354 |
|
|
|
355 |
item->Group = ListPackages->Groups[addGroup];
|
|
|
356 |
}
|
|
|
357 |
|
|
|
358 |
CyString groupName = CyStringFromSystemString(item->Group->Header);
|
|
|
359 |
if ( groupName.IsIn(" [") )
|
|
|
360 |
{
|
|
|
361 |
int enabled = groupName.GetToken(" [", 2, 2).GetToken("/", 1, 1).ToInt();
|
|
|
362 |
int total = groupName.GetToken(" [", 2, 2).GetToken("/", 2, 2).GetToken("]", 1, 1).ToInt() + 1;
|
|
|
363 |
if ( p->IsEnabled() ) ++enabled;
|
|
|
364 |
groupName = groupName.GetToken(" [", 1, 1) + " [" + CyString::Number(enabled) + "/" + CyString::Number(total) + "]";
|
|
|
365 |
}
|
|
|
366 |
else
|
|
|
367 |
{
|
|
|
368 |
if ( p->IsEnabled() )
|
|
|
369 |
groupName = groupName + " [1/1]";
|
|
|
370 |
else
|
|
|
371 |
groupName = groupName + " [0/1]";
|
|
|
372 |
}
|
|
|
373 |
item->Group->Header = SystemStringFromCyString(groupName);
|
|
|
374 |
|
|
|
375 |
// get the icon
|
|
|
376 |
item->ImageIndex = -1;
|
|
|
377 |
if ( p->GetIcon() )
|
|
|
378 |
PluginManager::DisplayListIcon(p, ListPackages, item);
|
|
|
379 |
|
|
|
380 |
if ( item->ImageIndex == -1 )
|
|
|
381 |
{
|
|
|
382 |
if ( p->GetType() == TYPE_XSP )
|
|
|
383 |
item->ImageKey = "ship";
|
|
|
384 |
else if ( p->GetType() == TYPE_ARCHIVE )
|
|
|
385 |
item->ImageKey = "archive";
|
|
|
386 |
else if ( p->GetType() == TYPE_SPK && ((CSpkFile *)p)->IsLibrary() )
|
|
|
387 |
item->ImageKey = "library";
|
|
|
388 |
else if ( p->IsFakePatch() )
|
|
|
389 |
item->ImageKey = "fake";
|
|
|
390 |
else
|
|
|
391 |
item->ImageKey = "package";
|
|
|
392 |
}
|
|
|
393 |
|
|
|
394 |
// check for any children
|
|
|
395 |
this->_DisplayPackages(p, item->Group);
|
|
|
396 |
}
|
|
|
397 |
}
|
|
|
398 |
|
|
|
399 |
void MainGui::UpdatePackages()
|
|
|
400 |
{
|
|
|
401 |
ListPackages->Items->Clear();
|
|
|
402 |
ListPackages->Groups->Clear();
|
|
|
403 |
ListPackages->SmallImageList = gcnew ImageList();
|
|
|
404 |
ListPackages->LargeImageList = gcnew ImageList();
|
|
|
405 |
ListPackages->LargeImageList->ImageSize = System::Drawing::Size(32, 32);
|
|
|
406 |
ListPackages->LargeImageList->ColorDepth = Windows::Forms::ColorDepth::Depth32Bit;
|
|
|
407 |
ListPackages->SmallImageList->ImageSize = System::Drawing::Size(16, 16);
|
|
|
408 |
ListPackages->SmallImageList->ColorDepth = Windows::Forms::ColorDepth::Depth32Bit;
|
|
|
409 |
|
|
|
410 |
int index = this->imageList1->Images->IndexOfKey("package.png");
|
|
|
411 |
if ( index != -1 )
|
|
|
412 |
{
|
|
|
413 |
ListPackages->SmallImageList->Images->Add("package", this->imageList1->Images[index]);
|
|
|
414 |
ListPackages->LargeImageList->Images->Add("package", this->imageList1->Images[index]);
|
|
|
415 |
}
|
|
|
416 |
index = this->imageList1->Images->IndexOfKey("ship.png");
|
|
|
417 |
if ( index != -1 )
|
|
|
418 |
{
|
|
|
419 |
ListPackages->SmallImageList->Images->Add("ship", this->imageList1->Images[index]);
|
|
|
420 |
ListPackages->LargeImageList->Images->Add("ship", this->imageList1->Images[index]);
|
|
|
421 |
}
|
|
|
422 |
index = this->imageList1->Images->IndexOfKey("fake.png");
|
|
|
423 |
if ( index != -1 )
|
|
|
424 |
{
|
|
|
425 |
ListPackages->SmallImageList->Images->Add("fake", this->imageList1->Images[index]);
|
|
|
426 |
ListPackages->LargeImageList->Images->Add("fake", this->imageList1->Images[index]);
|
|
|
427 |
}
|
|
|
428 |
index = this->imageList1->Images->IndexOfKey("library.png");
|
|
|
429 |
if ( index != -1 )
|
|
|
430 |
{
|
|
|
431 |
ListPackages->SmallImageList->Images->Add("library", this->imageList1->Images[index]);
|
|
|
432 |
ListPackages->LargeImageList->Images->Add("library", this->imageList1->Images[index]);
|
|
|
433 |
}
|
|
|
434 |
|
|
|
435 |
index = this->imageList1->Images->IndexOfKey("archive.png");
|
|
|
436 |
if ( index != -1 )
|
|
|
437 |
{
|
|
|
438 |
ListPackages->SmallImageList->Images->Add("archive", this->imageList1->Images[index]);
|
|
|
439 |
ListPackages->LargeImageList->Images->Add("archive", this->imageList1->Images[index]);
|
|
|
440 |
}
|
|
|
441 |
|
|
|
442 |
ListViewGroup ^group = gcnew ListViewGroup("Installed Scripts", HorizontalAlignment::Left);
|
|
|
443 |
ListPackages->Groups->Add(group);
|
|
|
444 |
ListViewGroup ^shipGroup = gcnew ListViewGroup("Installed Ships", HorizontalAlignment::Left);
|
|
|
445 |
ListPackages->Groups->Add(shipGroup);
|
|
|
446 |
ListViewGroup ^fakeGroup = gcnew ListViewGroup("Fake Patches", HorizontalAlignment::Left);
|
|
|
447 |
ListPackages->Groups->Add(fakeGroup);
|
|
|
448 |
ListViewGroup ^libGroup = gcnew ListViewGroup("Script Libraries", HorizontalAlignment::Left);
|
|
|
449 |
ListPackages->Groups->Add(libGroup);
|
|
|
450 |
ListViewGroup ^modGroup = gcnew ListViewGroup("Current Mod Addons", HorizontalAlignment::Left);
|
|
|
451 |
ListPackages->Groups->Add(modGroup);
|
|
|
452 |
ListViewGroup ^arcGroup = gcnew ListViewGroup("Installed Archives", HorizontalAlignment::Left);
|
|
|
453 |
ListPackages->Groups->Add(arcGroup);
|
|
|
454 |
|
|
|
455 |
// sort the items
|
|
|
456 |
if ( m_pPackages )
|
|
|
457 |
{
|
|
|
458 |
m_pPackages->AssignPackageNumbers();
|
|
|
459 |
this->_DisplayPackages(NULL, nullptr);
|
|
|
460 |
}
|
|
|
461 |
|
|
|
462 |
PackageListSelected(ListPackages, gcnew System::EventArgs());
|
|
|
463 |
ListPackages->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
464 |
|
|
|
465 |
// update the status bar
|
|
|
466 |
LabelStatus->Text = "Plugins Available: " + (m_pPackages->CountPackages(TYPE_BASE, false) - m_pPackages->CountBuiltInPackages(false))+ " (" + (m_pPackages->CountPackages(TYPE_BASE, true) - m_pPackages->CountBuiltInPackages(true)) + " Enabled)";
|
|
|
467 |
}
|
|
|
468 |
|
|
|
469 |
void MainGui::StartCheckTimer()
|
|
|
470 |
{
|
|
|
471 |
System::Windows::Forms::Timer ^timer = gcnew System::Windows::Forms::Timer();
|
|
|
472 |
timer->Interval = 5000;
|
|
|
473 |
timer->Tick += gcnew System::EventHandler(this, &MainGui::TimerEvent_CheckFile);
|
|
|
474 |
timer->Start();
|
|
|
475 |
}
|
|
|
476 |
|
|
|
477 |
|
|
|
478 |
//
|
|
|
479 |
// Update Controls
|
|
|
480 |
// Updates any additional controls, ie adding columns to package list
|
|
|
481 |
//
|
|
|
482 |
void MainGui::UpdateControls()
|
|
|
483 |
{
|
|
|
484 |
// Package List Columns
|
|
|
485 |
int csize = ListPackages->Width - 200 - 5;
|
|
|
486 |
int psize = ((csize * 7) / 10);
|
|
|
487 |
int asize = ((csize * 3) / 10);
|
|
|
488 |
if ( psize < 60 ) psize = 60;
|
|
|
489 |
if ( asize < 60 ) asize = 60;
|
|
|
490 |
ListPackages->Columns->Clear();
|
|
|
491 |
ListPackages->Columns->Add("Package", psize, HorizontalAlignment::Left);
|
|
|
492 |
ListPackages->Columns->Add("Author", asize, HorizontalAlignment::Left);
|
|
|
493 |
ListPackages->Columns->Add("Version", 60, HorizontalAlignment::Right);
|
|
|
494 |
ListPackages->Columns->Add("Updated", 80, HorizontalAlignment::Left);
|
|
|
495 |
ListPackages->Columns->Add("Type", 100, HorizontalAlignment::Left);
|
|
|
496 |
ListPackages->Columns->Add("Enabled", 60, HorizontalAlignment::Right);
|
|
|
497 |
ListPackages->Columns->Add("Signed", 60, HorizontalAlignment::Right);
|
|
|
498 |
ListPackages->FullRowSelect = true;
|
|
|
499 |
ListPackages->Focus();
|
|
|
500 |
|
|
|
501 |
if ( m_pPackages->IsVanilla() )
|
|
|
502 |
m_pMenuBar->Vanilla();
|
|
|
503 |
else
|
|
|
504 |
m_pMenuBar->Modified();
|
|
|
505 |
}
|
|
|
506 |
|
|
|
507 |
//
|
|
|
508 |
// Install a package
|
|
|
509 |
// Called from either install button, or from command line
|
|
|
510 |
//
|
|
|
511 |
bool MainGui::InstallPackage(System::String ^file, bool straightAway, bool builtin, bool background)
|
|
|
512 |
{
|
|
|
513 |
bool errored = false;
|
|
|
514 |
|
|
|
515 |
if ( file->Length )
|
|
|
516 |
{
|
|
|
517 |
int error;
|
|
|
518 |
CBaseFile *package = m_pPackages->OpenPackage(CyStringFromSystemString(file), &error, 0, SPKREAD_NODATA, READFLAG_NOUNCOMPRESS);
|
|
|
519 |
if ( error == INSTALLERR_NOMULTI )
|
|
|
520 |
{
|
|
|
521 |
CLinkList<CBaseFile> erroredList;
|
|
|
522 |
m_pPackages->PrepareMultiPackage(CyStringFromSystemString(file), &erroredList, &error, 0);
|
|
|
523 |
if ( erroredList.size() )
|
|
|
524 |
{
|
|
|
525 |
System::String ^modified;
|
|
|
526 |
for ( CBaseFile *p = erroredList.First(); p; p = erroredList.Next() )
|
|
|
527 |
{
|
|
|
528 |
p->SetOverrideFiles(builtin);
|
|
|
529 |
if ( m_pPackages->PrepareInstallPackage(p, false, false, IC_MODIFIED) != INSTALLCHECK_OK )
|
|
|
530 |
{
|
|
|
531 |
modified += SystemStringFromCyString(p->GetFullPackageName(m_pPackages->GetLanguage()));
|
|
|
532 |
modified += "\n";
|
|
|
533 |
errored = true;
|
|
|
534 |
}
|
|
|
535 |
}
|
|
|
536 |
|
|
|
537 |
if ( errored )
|
|
|
538 |
this->DisplayMessageBox(false, "Installing", "Currently in Vanilla Mode, Package is not an Vanilla Package\n\n" + modified + "\nSwitch to modified mode if you wish to install this package", MessageBoxButtons::OK, MessageBoxIcon::Question);
|
|
|
539 |
}
|
|
|
540 |
}
|
|
|
541 |
else if ( !package )
|
|
|
542 |
{
|
|
|
543 |
System::String ^errorStr;
|
|
|
544 |
switch ( error )
|
|
|
545 |
{
|
|
|
546 |
case INSTALLERR_OLD:
|
|
|
547 |
errorStr = "File is in old format no longer supported";
|
|
|
548 |
break;
|
|
|
549 |
case INSTALLERR_NOEXIST:
|
|
|
550 |
errorStr = "file doesn't exist";
|
|
|
551 |
break;
|
|
|
552 |
case INSTALLERR_INVALID:
|
|
|
553 |
errorStr = "Invalid package file";
|
|
|
554 |
break;
|
|
|
555 |
case INSTALLERR_NOSHIP:
|
|
|
556 |
errorStr = "Ship Packages are currently not supported";
|
|
|
557 |
break;
|
|
|
558 |
case INSTALLERR_VERSION:
|
|
|
559 |
errorStr = "Package file was created in a newer version, unable to open";
|
|
|
560 |
break;
|
|
|
561 |
|
|
|
562 |
default:
|
|
|
563 |
errorStr = "Unknown Error";
|
|
|
564 |
}
|
|
|
565 |
|
|
|
566 |
if ( !builtin )
|
|
|
567 |
this->DisplayMessageBox(false, "Open Package Error", "Error Opening: " + file + "\n" + errorStr, MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
568 |
errored = true;
|
|
|
569 |
}
|
|
|
570 |
else
|
|
|
571 |
{
|
|
|
572 |
if ( builtin )
|
|
|
573 |
{
|
|
|
574 |
package->SetOverrideFiles(builtin);
|
|
|
575 |
if ( m_pPackages->PrepareInstallPackage(package, false, false, IC_WRONGGAME|IC_WRONGVERSION|IC_OLDVERSION) != INSTALLCHECK_OK )
|
|
|
576 |
errored = true;
|
|
|
577 |
}
|
|
|
578 |
else
|
|
|
579 |
{
|
|
|
580 |
int errorNum = m_pPackages->PrepareInstallPackage(package, false, false, IC_ALL);
|
|
|
581 |
if ( errorNum != INSTALLCHECK_OK )
|
|
|
582 |
{
|
|
|
583 |
if ( errorNum == INSTALLCHECK_NOSHIP )
|
|
|
584 |
{
|
|
|
585 |
this->DisplayMessageBox(false, "No Ships", "Ships are not supported for " + SystemStringFromCyString(m_pPackages->GetGameName()), MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
586 |
errored = true;
|
|
|
587 |
}
|
|
|
588 |
else if ( m_pPackages->PrepareInstallPackage(package, false, false, IC_MODIFIED) != INSTALLCHECK_OK )
|
|
|
589 |
{
|
|
|
590 |
this->DisplayMessageBox(false, "Installing", "Currently in Vanilla Mode, Package is not an Vanilla Package\n" + SystemStringFromCyString(package->GetLanguageName(m_pPackages->GetLanguage())) + "\n\nSwitch to modified mode if you wish to install this package", MessageBoxButtons::OK, MessageBoxIcon::Question);
|
|
|
591 |
errored = true;
|
|
|
592 |
}
|
|
|
593 |
}
|
|
|
594 |
|
|
|
595 |
// check for compatabilities
|
|
|
596 |
CLinkList<CBaseFile> packages;
|
|
|
597 |
int compat = m_pPackages->CheckCompatabilityAgainstPackages(package, NULL, &packages);
|
|
|
598 |
if ( compat )
|
|
|
599 |
{
|
|
|
600 |
String ^message = "\nConflicts with:\n";
|
|
|
601 |
for ( CBaseFile *p = packages.First(); p; p = packages.Next() )
|
|
|
602 |
message += SystemStringFromCyString(p->GetFullPackageName(m_pPackages->GetLanguage())) + "\n";
|
|
|
603 |
|
|
|
604 |
if ( MessageBox::Show(this, SystemStringFromCyString(package->GetFullPackageName(m_pPackages->GetLanguage())) + ":\nIncompatabilities found with installed fake patches\n" + message + "\n\nDo you still wish to install?", "Packages Incompatable", MessageBoxButtons::YesNo, MessageBoxIcon::Warning) != Windows::Forms::DialogResult::Yes )
|
|
|
605 |
{
|
|
|
606 |
m_pPackages->RemovePreparedInstall(package);
|
|
|
607 |
errored = true;
|
|
|
608 |
}
|
|
|
609 |
}
|
|
|
610 |
}
|
|
|
611 |
|
|
|
612 |
// not installing
|
|
|
613 |
if ( errored )
|
|
|
614 |
{
|
|
|
615 |
delete package;
|
|
|
616 |
package = NULL;
|
|
|
617 |
}
|
|
|
618 |
}
|
|
|
619 |
}
|
|
|
620 |
|
|
|
621 |
if ( errored )
|
|
|
622 |
{
|
|
|
623 |
this->Enabled= true;
|
|
|
624 |
this->ProgressBar->Hide();
|
|
|
625 |
return false;
|
|
|
626 |
}
|
|
|
627 |
|
|
|
628 |
// start installing
|
|
|
629 |
if ( straightAway )
|
|
|
630 |
return this->StartInstalling(builtin, background);
|
|
|
631 |
|
|
|
632 |
return true;
|
|
|
633 |
}
|
|
|
634 |
|
|
|
635 |
void MainGui::DoUninstall()
|
|
|
636 |
{
|
|
|
637 |
m_pPi = gcnew PackageInstalled("Uninstall Packages");
|
|
|
638 |
|
|
|
639 |
CLinkList<CBaseFile> packageList;
|
|
|
640 |
CLinkList<CBaseFile> disableList;
|
|
|
641 |
|
|
|
642 |
if ( m_pPackages->UninstallPreparedPackages(m_pFileErrors, 0, &packageList, &disableList) )
|
|
|
643 |
{
|
|
|
644 |
CyString sDisplay;
|
|
|
645 |
CyString sAfterText;
|
|
|
646 |
for ( CBaseFile *p = packageList.First(); p; p = packageList.Next() )
|
|
|
647 |
{
|
|
|
648 |
sAfterText = m_pPackages->GetUninstallAfterText(p);
|
|
|
649 |
m_pPi->AddPackageWithGroup(SystemStringFromCyString(p->GetLanguageName(m_pPackages->GetLanguage())), SystemStringFromCyString(p->GetAuthor()), SystemStringFromCyString(p->GetVersion()), (sAfterText.Empty() ? "Uninstalled" : SystemStringFromCyString(sAfterText)), "Uninstalled");
|
|
|
650 |
sDisplay = p->GetFullPackageName(m_pPackages->GetLanguage());
|
|
|
651 |
delete p;
|
|
|
652 |
}
|
|
|
653 |
for ( CBaseFile *p = disableList.First(); p; p = disableList.Next() )
|
|
|
654 |
m_pPi->AddPackageWithGroup(SystemStringFromCyString(p->GetLanguageName(m_pPackages->GetLanguage())), SystemStringFromCyString(p->GetAuthor()), SystemStringFromCyString(p->GetVersion()), "Disabled", "Dependants Disabled");
|
|
|
655 |
packageList.clear();
|
|
|
656 |
|
|
|
657 |
if ( m_pPi->PackageCount() == 1 )
|
|
|
658 |
{
|
|
|
659 |
if ( sAfterText.Empty() )
|
|
|
660 |
this->DisplayMessageBox(true, "Uninstalled", "Package Uninstalled\n" + SystemStringFromCyString(sDisplay), MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
661 |
else
|
|
|
662 |
this->DisplayMessageBox(true, "Uninstalled", "Package Uninstalled\n" + SystemStringFromCyString(sDisplay) + "\n\n" + SystemStringFromCyString(sAfterText), MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
663 |
}
|
|
|
664 |
else
|
|
|
665 |
m_bDisplayDialog = true;
|
|
|
666 |
}
|
|
|
667 |
else
|
|
|
668 |
this->DisplayMessageBox(true, "Uninstall Error", "Error Uninstalling", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
669 |
}
|
|
|
670 |
|
|
|
671 |
void MainGui::DoDisable()
|
|
|
672 |
{
|
|
|
673 |
CLinkList<CBaseFile> packageList;
|
|
|
674 |
|
|
|
675 |
System::String ^display;
|
|
|
676 |
m_pPi = gcnew PackageInstalled("Enabled/Disabled Packages");
|
|
|
677 |
|
|
|
678 |
if ( m_pPackages->GetNumPackagesInDisabledQueue() )
|
|
|
679 |
{
|
|
|
680 |
if ( m_pPackages->DisablePreparedPackages(0, 0, &packageList) )
|
|
|
681 |
{
|
|
|
682 |
for ( CBaseFile *p = packageList.First(); p; p = packageList.Next() )
|
|
|
683 |
{
|
|
|
684 |
m_pPi->AddPackageWithGroup(SystemStringFromCyString(p->GetLanguageName(m_pPackages->GetLanguage())), SystemStringFromCyString(p->GetAuthor()), SystemStringFromCyString(p->GetVersion()), "Disabled", "Disabled Packages");
|
|
|
685 |
display = "Package Disabled\n\n" + SystemStringFromCyString(p->GetFullPackageName(m_pPackages->GetLanguage()));
|
|
|
686 |
}
|
|
|
687 |
}
|
|
|
688 |
else
|
|
|
689 |
this->DisplayMessageBox(true, "Disable Error", "Error Disabling packages", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
690 |
}
|
|
|
691 |
|
|
|
692 |
packageList.clear();
|
|
|
693 |
if ( m_pPackages->GetNumPackagesInEnabledQueue() )
|
|
|
694 |
{
|
|
|
695 |
if ( m_pPackages->EnablePreparedPackages(0, 0, &packageList) )
|
|
|
696 |
{
|
|
|
697 |
for ( CBaseFile *p = packageList.First(); p; p = packageList.Next() )
|
|
|
698 |
{
|
|
|
699 |
m_pPi->AddPackageWithGroup(SystemStringFromCyString(p->GetLanguageName(m_pPackages->GetLanguage())), SystemStringFromCyString(p->GetAuthor()), SystemStringFromCyString(p->GetVersion()), "Enabled", "Enable Packages");
|
|
|
700 |
display = "Package Enabled\n\n" + SystemStringFromCyString(p->GetFullPackageName(m_pPackages->GetLanguage()));
|
|
|
701 |
}
|
|
|
702 |
}
|
|
|
703 |
else
|
|
|
704 |
this->DisplayMessageBox(true, "Enable Error", "Error Enabling packages", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
705 |
}
|
|
|
706 |
|
|
|
707 |
if ( m_pPi->PackageCount() == 1 )
|
|
|
708 |
this->DisplayMessageBox(true, "Packages Enabled/Disabled", display, MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
709 |
else
|
|
|
710 |
{
|
|
|
711 |
m_bDisplayDialog = true;
|
|
|
712 |
}
|
|
|
713 |
}
|
|
|
714 |
|
|
|
715 |
void MainGui::DoInstall(bool builtin, bool frombackground)
|
|
|
716 |
{
|
|
|
717 |
CLinkList<CBaseFile> erroredPackages;
|
|
|
718 |
CLinkList<CBaseFile> installedPackages;
|
|
|
719 |
if ( m_pPackages->InstallPreparedPackages(m_pFileErrors, 0, &erroredPackages, &installedPackages) )
|
|
|
720 |
{
|
|
|
721 |
if ( !builtin )
|
|
|
722 |
{
|
|
|
723 |
if ( installedPackages.size() == 1 && erroredPackages.size() == 0 )
|
|
|
724 |
{
|
|
|
725 |
CBaseFile *p = installedPackages.Front()->Data();
|
|
|
726 |
CyString packageName = p->GetFullPackageName(m_pPackages->GetLanguage());
|
|
|
727 |
CyString afterText = m_pPackages->GetInstallAfterText(p);
|
|
|
728 |
if ( afterText.Empty() )
|
|
|
729 |
this->DisplayMessageBox(frombackground, "Installed", "Package: " + SystemStringFromCyString(packageName) + " installed!\n\n", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
730 |
else
|
|
|
731 |
{
|
|
|
732 |
afterText.StripHTML();
|
|
|
733 |
this->DisplayMessageBox(frombackground, "Installed", "Package: " + SystemStringFromCyString(packageName) + " installed!\n\n" + SystemStringFromCyString(afterText), MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
734 |
}
|
|
|
735 |
}
|
|
|
736 |
else
|
|
|
737 |
{
|
|
|
738 |
m_pPi = gcnew PackageInstalled("Packages Installed");
|
|
|
739 |
|
|
|
740 |
CyStringList packages;
|
|
|
741 |
for ( CListNode<CBaseFile> *node = installedPackages.Front(); node; node = node->next() )
|
|
|
742 |
{
|
|
|
743 |
CBaseFile *p = node->Data();
|
|
|
744 |
CyString packageName = p->GetFullPackageName(m_pPackages->GetLanguage());
|
|
|
745 |
CyString afterText = m_pPackages->GetInstallAfterText(p);
|
|
|
746 |
|
|
|
747 |
if ( afterText.Empty() )
|
|
|
748 |
afterText = "Installed";
|
|
|
749 |
m_pPi->AddPackage(SystemStringFromCyString(packageName), SystemStringFromCyString(p->GetAuthor()), SystemStringFromCyString(p->GetVersion()), SystemStringFromCyString(afterText));
|
|
|
750 |
}
|
|
|
751 |
for ( CListNode<CBaseFile> *node = erroredPackages.Front(); node; node = node->next() )
|
|
|
752 |
{
|
|
|
753 |
CBaseFile *p = node->Data();
|
|
|
754 |
CyString packageName = p->GetFullPackageName(m_pPackages->GetLanguage());
|
|
|
755 |
m_pPi->AddPackage(SystemStringFromCyString(packageName), SystemStringFromCyString(p->GetAuthor()), SystemStringFromCyString(p->GetVersion()), SystemStringFromCyString("Failed to Install"));
|
|
|
756 |
}
|
|
|
757 |
|
|
|
758 |
m_bDisplayDialog = true;
|
|
|
759 |
}
|
|
|
760 |
}
|
|
|
761 |
}
|
|
|
762 |
// no packages were installed
|
|
|
763 |
else
|
|
|
764 |
{
|
|
|
765 |
if ( !builtin )
|
|
|
766 |
{
|
|
|
767 |
if ( erroredPackages.size() == 1 )
|
|
|
768 |
{
|
|
|
769 |
CBaseFile *p = erroredPackages.Front()->Data();
|
|
|
770 |
CyString packageName = p->GetFullPackageName(m_pPackages->GetLanguage());
|
|
|
771 |
this->DisplayMessageBox(frombackground, "Error Installing", "Package: " + SystemStringFromCyString(packageName) + " failed to install!\nError: " + SystemStringFromCyString(CBaseFile::ErrorString(p->GetLastError(), p->GetLastErrorString())) + "\n", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
|
|
772 |
}
|
|
|
773 |
else
|
|
|
774 |
{
|
|
|
775 |
m_pPi = gcnew PackageInstalled("Packages Failed To Install");
|
|
|
776 |
|
|
|
777 |
CyStringList packages;
|
|
|
778 |
for ( CListNode<CBaseFile> *node = erroredPackages.Front(); node; node = node->next() )
|
|
|
779 |
{
|
|
|
780 |
CBaseFile *p = node->Data();
|
|
|
781 |
CyString packageName = p->GetFullPackageName(m_pPackages->GetLanguage());
|
|
|
782 |
m_pPi->AddPackage(SystemStringFromCyString(packageName), SystemStringFromCyString(p->GetAuthor()), SystemStringFromCyString(p->GetVersion()), "Failed: " + SystemStringFromCyString(CBaseFile::ErrorString(p->GetLastError(), p->GetLastErrorString())));
|
|
|
783 |
}
|
|
|
784 |
|
|
|
785 |
m_bDisplayDialog = true;
|
|
|
786 |
}
|
|
|
787 |
}
|
|
|
788 |
}
|
|
|
789 |
|
|
|
790 |
if ( !frombackground )
|
|
|
791 |
this->Background_Finished();
|
|
|
792 |
}
|
|
|
793 |
|
|
|
794 |
void MainGui::ClearSelectedItems()
|
|
|
795 |
{
|
|
|
796 |
for ( int i = 0; i < this->ListPackages->Items->Count; i++ )
|
|
|
797 |
this->ListPackages->Items[i]->Selected = false;
|
|
|
798 |
PackageListSelected(ListPackages, gcnew System::EventArgs());
|
|
|
799 |
}
|
|
|
800 |
|
|
|
801 |
bool MainGui::StartInstalling(bool builtin, bool background, bool archive)
|
|
|
802 |
{
|
|
|
803 |
// no packages to install
|
|
|
804 |
if ( !m_pPackages->GetNumPackagesInQueue() )
|
|
|
805 |
return false;
|
|
|
806 |
|
|
|
807 |
// clear selected
|
|
|
808 |
this->ClearSelectedItems();
|
|
|
809 |
|
|
|
810 |
// lets install them now
|
|
|
811 |
CLinkList<CBaseFile> lCheckPackages;
|
|
|
812 |
if ( m_pPackages->CheckPreparedInstallRequired(&lCheckPackages) )
|
|
|
813 |
{
|
|
|
814 |
for ( CListNode<CBaseFile> *pNode = lCheckPackages.Front(); pNode; pNode = pNode->next() )
|
|
|
815 |
{
|
|
|
816 |
CBaseFile *package = pNode->Data();
|
|
|
817 |
CSpkFile *spk = (CSpkFile *)package;
|
|
|
818 |
|
|
|
819 |
CyStringList missingList;
|
|
|
820 |
if ( m_pPackages->GetMissingDependacies(package, &missingList) )
|
|
|
821 |
{
|
|
|
822 |
CyString requires;
|
|
|
823 |
for ( SStringList *strNode = missingList.Head(); strNode; strNode = strNode->next )
|
|
|
824 |
{
|
|
|
825 |
if ( strNode->str.IsIn("|") )
|
|
|
826 |
requires += strNode->str.GetToken("|", 1, 1) + " V" + strNode->str.GetToken("|", 2, 2) + " by " + strNode->data;
|
|
|
827 |
else
|
|
|
828 |
requires += strNode->str + " by " + strNode->data;
|
|
|
829 |
requires += "\n";
|
|
|
830 |
}
|
|
|
831 |
this->DisplayMessageBox(false, "Installing", "Missing Package for " + SystemStringFromCyString(package->GetLanguageName(m_pPackages->GetLanguage())) + "\nRequires:\n" + SystemStringFromCyString(requires), MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
|
|
|
832 |
}
|
|
|
833 |
}
|
|
|
834 |
}
|
|
|
835 |
|
|
|
836 |
// no packages to install
|
|
|
837 |
if ( !m_pPackages->GetNumPackagesInQueue() )
|
|
|
838 |
{
|
|
|
839 |
this->Enabled = true;
|
|
|
840 |
this->ProgressBar->Hide();
|
|
|
841 |
return false;
|
|
|
842 |
}
|
|
|
843 |
|
|
|
844 |
ProgressBar->Show();
|
|
|
845 |
this->Enabled = false;
|
|
|
846 |
|
|
|
847 |
if ( builtin )
|
|
|
848 |
{
|
|
|
849 |
if ( background )
|
|
|
850 |
this->StartBackground(MGUI_BACKGROUND_INSTALLBUILTIN);
|
|
|
851 |
else
|
|
|
852 |
this->DoInstall(builtin, false);
|
|
|
853 |
}
|
|
|
854 |
else if ( archive )
|
|
|
855 |
{
|
|
|
856 |
if ( background )
|
|
|
857 |
this->StartBackground(MGUI_BACKGROUND_INSTALL);
|
|
|
858 |
else
|
|
|
859 |
this->DoInstall(false, false);
|
|
|
860 |
}
|
|
|
861 |
else
|
|
|
862 |
{
|
|
|
863 |
InstallPackageDialog ^installDialog = gcnew InstallPackageDialog(m_pPackages);
|
|
|
864 |
if ( installDialog->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
865 |
{
|
|
|
866 |
// no packages to install
|
|
|
867 |
if ( !m_pPackages->GetNumPackagesInQueue() )
|
|
|
868 |
{
|
|
|
869 |
this->Enabled = true;
|
|
|
870 |
this->ProgressBar->Hide();
|
|
|
871 |
return false;
|
|
|
872 |
}
|
|
|
873 |
if ( background )
|
|
|
874 |
this->StartBackground(MGUI_BACKGROUND_INSTALL);
|
|
|
875 |
else
|
|
|
876 |
this->DoInstall(false, false);
|
|
|
877 |
}
|
|
|
878 |
else
|
|
|
879 |
{
|
|
|
880 |
m_pPackages->RemovePreparedInstall(NULL);
|
|
|
881 |
this->Enabled = true;
|
|
|
882 |
this->ProgressBar->Hide();
|
|
|
883 |
return false;
|
|
|
884 |
}
|
|
|
885 |
}
|
|
|
886 |
return true;
|
|
|
887 |
}
|
|
|
888 |
|
|
|
889 |
bool MainGui::StartBackground(int type, System::String ^info)
|
|
|
890 |
{
|
|
|
891 |
if ( backgroundWorker1->IsBusy )
|
|
|
892 |
return false;
|
|
|
893 |
if ( m_bRunningBackground )
|
|
|
894 |
return false;
|
|
|
895 |
|
|
|
896 |
m_sBackgroundInfo = info;
|
|
|
897 |
return this->StartBackground(type);
|
|
|
898 |
}
|
|
|
899 |
|
|
|
900 |
bool MainGui::StartBackground(int type)
|
|
|
901 |
{
|
|
|
902 |
if ( backgroundWorker1->IsBusy )
|
|
|
903 |
return false;
|
|
|
904 |
if ( m_bRunningBackground )
|
|
|
905 |
return false;
|
|
|
906 |
|
|
|
907 |
m_iBackgroundTask = type;
|
|
|
908 |
|
|
|
909 |
backgroundWorker1->RunWorkerAsync();
|
|
|
910 |
m_bRunningBackground = true;
|
|
|
911 |
return true;
|
|
|
912 |
}
|
|
|
913 |
|
|
|
914 |
void MainGui::ChangeDirectory(CyString dir)
|
|
|
915 |
{
|
|
|
916 |
if ( m_pPackages->IsCurrentDir(dir) )
|
|
|
917 |
return;
|
|
|
918 |
|
|
|
919 |
if ( m_pPackages->IsLoaded() )
|
|
|
920 |
{
|
|
|
921 |
if ( m_pPackages->CloseDir(0, 0, true) )
|
|
|
922 |
{
|
|
|
923 |
// write the modname
|
|
|
924 |
if ( !m_pPackages->GetModKey().Empty() )
|
|
|
925 |
PluginManager::WriteRegistryValue(m_pPackages->GetModKey(), m_pPackages->GetSelectedModName());
|
|
|
926 |
m_pPackages->Reset();
|
|
|
927 |
}
|
|
|
928 |
else
|
|
|
929 |
{
|
|
|
930 |
this->DisplayMessageBox(true, "Error", "unable to close directory", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
|
|
931 |
return;
|
|
|
932 |
}
|
|
|
933 |
}
|
|
|
934 |
|
|
|
935 |
m_pPackages->Reset();
|
|
|
936 |
|
|
|
937 |
if ( m_pPackages->Read(dir, 0) )
|
|
|
938 |
{
|
|
|
939 |
if ( m_iSaveGameManager == 1 )
|
|
|
940 |
m_pPackages->RestoreSaves();
|
|
|
941 |
m_pPackages->UpdatePackages();
|
|
|
942 |
m_pPackages->ReadGameLanguage(true);
|
|
|
943 |
this->UpdateRunButton();
|
|
|
944 |
System::String ^mod = PluginManager::ReadRegistryValue(m_pPackages->GetModKey());
|
|
|
945 |
m_pPackages->SetMod(CyStringFromSystemString(mod));
|
|
|
946 |
}
|
|
|
947 |
else
|
|
|
948 |
{
|
|
|
949 |
this->DisplayMessageBox(true, "Error", "unable to open new directory", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
|
|
950 |
this->Close();
|
|
|
951 |
}
|
|
|
952 |
}
|
|
|
953 |
|
|
|
954 |
CBaseFile *MainGui::FindPackageFromList(ListViewItem ^item)
|
|
|
955 |
{
|
|
|
956 |
if ( !item )
|
|
|
957 |
return NULL;
|
|
|
958 |
|
|
|
959 |
System::String ^sNum = System::Convert::ToString(item->Tag);
|
|
|
960 |
int iNum = CyStringFromSystemString(sNum).ToInt();
|
|
|
961 |
|
|
|
962 |
CBaseFile *p = m_pPackages->GetPackageAt(iNum);
|
|
|
963 |
return p;
|
|
|
964 |
}
|
|
|
965 |
|
|
|
966 |
void MainGui::FindPackagesOnline()
|
|
|
967 |
{
|
|
|
968 |
CyStringList servers;
|
|
|
969 |
m_pPackages->FindAllServers(&servers);
|
|
|
970 |
if ( servers.Empty() )
|
|
|
971 |
{
|
|
|
972 |
MessageBox::Show(this, "Found now web address to check for packages", "No Web Address", MessageBoxButtons::OK, MessageBoxIcon::Warning);
|
|
|
973 |
return;
|
|
|
974 |
}
|
|
|
975 |
|
|
|
976 |
DownloadPackageList ^dpl = gcnew DownloadPackageList(m_pPackages, &servers);
|
|
|
977 |
dpl->ShowDialog(this);
|
|
|
978 |
|
|
|
979 |
if ( m_pPackages->AnyAvailablePackages() )
|
|
|
980 |
MessageBox::Show(this, "Package update completed\n" + m_pPackages->GetAvailablePackageList()->size() + " packages have been added to the package browser", "Found Packages", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
981 |
else
|
|
|
982 |
MessageBox::Show(this, "Unable to find any packages\n", "No Packages Found", MessageBoxButtons::OK, MessageBoxIcon::Warning);
|
|
|
983 |
}
|
|
|
984 |
|
|
|
985 |
//
|
|
|
986 |
// Event Handlers
|
|
|
987 |
//
|
|
|
988 |
void MainGui::SetupEventHandlers()
|
|
|
989 |
{
|
|
|
990 |
// setup Event Handlers
|
|
|
991 |
ButClose->Click += gcnew EventHandler(this, &PluginManager::MainGui::ClosedEvent);
|
|
|
992 |
ButInstall->Click += gcnew EventHandler(this, &PluginManager::MainGui::InstallEvent);
|
|
|
993 |
ButUninstall->Click += gcnew EventHandler(this, &PluginManager::MainGui::UninstallEvent);
|
|
|
994 |
ButDisable->Click += gcnew EventHandler(this, &PluginManager::MainGui::DisableEvent);
|
|
|
995 |
ListPackages->SelectedIndexChanged += gcnew EventHandler(this, &PluginManager::MainGui::PackageListSelected);
|
|
|
996 |
ListPackages->ColumnClick += gcnew ColumnClickEventHandler(this, &PluginManager::MainGui::PackageListSort);
|
|
|
997 |
ComboDir->SelectedIndexChanged += gcnew EventHandler(this, &PluginManager::MainGui::ChangeDirectoryEvent);
|
|
|
998 |
|
|
|
999 |
|
|
|
1000 |
// background worker
|
|
|
1001 |
backgroundWorker1->DoWork += gcnew DoWorkEventHandler( this, &MainGui::Background_DoWork );
|
|
|
1002 |
backgroundWorker1->RunWorkerCompleted += gcnew RunWorkerCompletedEventHandler( this, &MainGui::Background_Finished );
|
|
|
1003 |
backgroundWorker1->ProgressChanged += gcnew ProgressChangedEventHandler( this, &MainGui::Background_Progress );
|
|
|
1004 |
|
|
|
1005 |
// auto update
|
|
|
1006 |
backgroundUpdater->DoWork += gcnew DoWorkEventHandler( this, &MainGui::Updater_DoWork );
|
|
|
1007 |
backgroundUpdater->RunWorkerCompleted += gcnew RunWorkerCompletedEventHandler( this, &MainGui::Updater_Finished );
|
|
|
1008 |
}
|
|
|
1009 |
|
|
|
1010 |
void MainGui::PackageListSort(System::Object ^Sender, ColumnClickEventArgs ^E)
|
|
|
1011 |
{
|
|
|
1012 |
if ( E->Column != m_iSortingColumn )
|
|
|
1013 |
{
|
|
|
1014 |
m_iSortingColumn = E->Column;
|
|
|
1015 |
m_bSortingAsc = true;
|
|
|
1016 |
}
|
|
|
1017 |
else
|
|
|
1018 |
m_bSortingAsc = !m_bSortingAsc;
|
|
|
1019 |
this->UpdatePackages();
|
|
|
1020 |
}
|
|
|
1021 |
|
|
|
1022 |
void MainGui::PackageListSelected(System::Object ^Sender, System::EventArgs ^E)
|
|
|
1023 |
{
|
|
|
1024 |
// is there any selected items
|
|
|
1025 |
this->PictureDisplay->Image = nullptr;
|
|
|
1026 |
this->PanelDisplay->Hide();
|
|
|
1027 |
TextDesc->Text = "";
|
|
|
1028 |
bool buttonEnabled = false;
|
|
|
1029 |
if ( ListPackages->SelectedItems->Count )
|
|
|
1030 |
{
|
|
|
1031 |
buttonEnabled = true;
|
|
|
1032 |
|
|
|
1033 |
ListView::SelectedListViewItemCollection^ selected = this->ListPackages->SelectedItems;
|
|
|
1034 |
System::Collections::IEnumerator^ myEnum = selected->GetEnumerator();
|
|
|
1035 |
while ( myEnum->MoveNext() )
|
|
|
1036 |
{
|
|
|
1037 |
CBaseFile *p = this->FindPackageFromList(safe_cast<ListViewItem ^>(myEnum->Current));
|
|
|
1038 |
if ( p )
|
|
|
1039 |
{
|
|
|
1040 |
if ( p->IsEnabled() )
|
|
|
1041 |
ButDisable->Text = "Disable";
|
|
|
1042 |
else
|
|
|
1043 |
ButDisable->Text = "Enable";
|
|
|
1044 |
if ( !p->GetDescription().Empty() )
|
|
|
1045 |
TextDesc->Text = SystemStringFromCyString(p->GetDescription().FindReplace("<br>", "\n").StripHTML());
|
|
|
1046 |
|
|
|
1047 |
this->PictureDisplay->Show();
|
|
|
1048 |
bool addedIcon = false;
|
|
|
1049 |
C_File *picFile = p->GetFirstFile(FILETYPE_ADVERT);
|
|
|
1050 |
if ( picFile )
|
|
|
1051 |
{
|
|
|
1052 |
System::String ^pic = SystemStringFromCyString(picFile->GetFilePointer());
|
|
|
1053 |
if ( System::IO::File::Exists(pic) )
|
|
|
1054 |
{
|
|
|
1055 |
Bitmap ^myBitmap = gcnew Bitmap(pic);
|
|
|
1056 |
if ( myBitmap )
|
|
|
1057 |
{
|
|
|
1058 |
this->PictureDisplay->Image = dynamic_cast<Image ^>(myBitmap);
|
|
|
1059 |
addedIcon = true;
|
|
|
1060 |
}
|
|
|
1061 |
}
|
|
|
1062 |
}
|
|
|
1063 |
|
|
|
1064 |
if ( !addedIcon )
|
|
|
1065 |
{
|
|
|
1066 |
|
|
|
1067 |
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MainGui::typeid));
|
|
|
1068 |
this->PictureDisplay->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"PictureDisplay.Image")));
|
|
|
1069 |
}
|
|
|
1070 |
|
|
|
1071 |
if ( p->GetType() != TYPE_ARCHIVE )
|
|
|
1072 |
this->PanelDisplay->Show();
|
|
|
1073 |
}
|
|
|
1074 |
}
|
|
|
1075 |
}
|
|
|
1076 |
|
|
|
1077 |
// enable/disable the buttons connected to the package list
|
|
|
1078 |
ButUninstall->Enabled = buttonEnabled;
|
|
|
1079 |
ButDisable->Enabled = buttonEnabled;
|
|
|
1080 |
}
|
|
|
1081 |
|
|
|
1082 |
void MainGui::AddDirectoryEvent(System::Object ^Sender, System::EventArgs ^E)
|
|
|
1083 |
{
|
|
|
1084 |
OpenFileDialog ^ofd = gcnew OpenFileDialog();
|
|
|
1085 |
ofd->Filter = "X-Universe Executable|";
|
|
|
1086 |
String ^games = "";
|
|
|
1087 |
for ( int i = 0; i < m_pPackages->GetGameExe()->GetNumGames(); i++ )
|
|
|
1088 |
{
|
|
|
1089 |
SGameExe *exe = m_pPackages->GetGameExe()->GetGame(i);
|
|
|
1090 |
if ( i ) ofd->Filter += ";";
|
|
|
1091 |
ofd->Filter += SystemStringFromCyString(exe->sExe);
|
|
|
1092 |
games += "|" + SystemStringFromCyString(exe->sName) + "|" + SystemStringFromCyString(exe->sExe);
|
|
|
1093 |
}
|
|
|
1094 |
ofd->Filter += games;
|
|
|
1095 |
ofd->FilterIndex = 1;
|
|
|
1096 |
ofd->RestoreDirectory = true;
|
|
|
1097 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1098 |
{
|
|
|
1099 |
CyString dir = CyStringFromSystemString(IO::FileInfo(ofd->FileName).DirectoryName);
|
|
|
1100 |
// check its a valid directory
|
|
|
1101 |
if ( !dir.Empty() )
|
|
|
1102 |
{
|
|
|
1103 |
CyString gameName = m_pPackages->GetGameName(dir);
|
|
|
1104 |
if ( gameName.Empty() )
|
|
|
1105 |
this->DisplayMessageBox(false, "Add Directory Error", "No X-Universe game found in folder:\n" + SystemStringFromCyString(dir), MessageBoxButtons::OK, MessageBoxIcon::Error);
|
|
|
1106 |
else
|
|
|
1107 |
{
|
|
|
1108 |
// lets check if theres an old folder
|
|
|
1109 |
if ( m_pPackages->IsOldDir(dir) )
|
|
|
1110 |
{
|
|
|
1111 |
if ( this->DisplayMessageBox(false, "Update Game Directory", "Game directory: " + SystemStringFromCyString(dir) + "\nIs currently being controled by the old plugin manager\nIf you continue, you will be unable to use the old version again\nDo you wish to continue?", MessageBoxButtons::YesNo, MessageBoxIcon::Question) != System::Windows::Forms::DialogResult::Yes )
|
|
|
1112 |
return;
|
|
|
1113 |
}
|
|
|
1114 |
m_iBackgroundTask = MGUI_BACKGROUND_ADDDIR;
|
|
|
1115 |
this->Enabled = false;
|
|
|
1116 |
CyString properDir = m_pPackages->GetProperDir(dir);
|
|
|
1117 |
ComboDir->Items->Add(SystemStringFromCyString(properDir));
|
|
|
1118 |
ComboDir->Text = SystemStringFromCyString(properDir);
|
|
|
1119 |
|
|
|
1120 |
m_pRemovedDirList->Remove(properDir, true);
|
|
|
1121 |
GetGameDirs(dir, false, true);
|
|
|
1122 |
/*int lang = m_pPackages->GetGameLanguage(dir);
|
|
|
1123 |
if ( lang )
|
|
|
1124 |
m_pDirList->PushFront(properDir, CyString::Number(lang) + "|" + gameName);
|
|
|
1125 |
else
|
|
|
1126 |
m_pDirList->PushFront(properDir, gameName);*/
|
|
|
1127 |
this->StartBackground(MGUI_BACKGROUND_ADDDIR, SystemStringFromCyString(properDir));
|
|
|
1128 |
}
|
|
|
1129 |
}
|
|
|
1130 |
}
|
|
|
1131 |
}
|
|
|
1132 |
|
|
|
1133 |
bool MainGui::EnablePackage(CBaseFile *p)
|
|
|
1134 |
{
|
|
|
1135 |
if ( !m_pPackages->PrepareEnablePackage(p) )
|
|
|
1136 |
{
|
|
|
1137 |
if ( m_pPackages->GetError() == PKERR_NOPARENT )
|
|
|
1138 |
this->DisplayMessageBox(false, "Enable Error", "Error enabling package\n" + SystemStringFromCyString(p->GetFullPackageName(m_pPackages->GetLanguage())) + "\n\nParent mod is not enabled", MessageBoxButtons::OK, MessageBoxIcon::Warning);
|
|
|
1139 |
else if ( m_pPackages->GetError() == PKERR_MODIFIED )
|
|
|
1140 |
this->DisplayMessageBox(false, "Enable Error", "Error enabling package\n" + SystemStringFromCyString(p->GetFullPackageName(m_pPackages->GetLanguage())) + "\n\nPackage is modified and game is currently set to vanilla\nSwitch to modified mode to enable", MessageBoxButtons::OK, MessageBoxIcon::Warning);
|
|
|
1141 |
else if ( m_pPackages->GetError() == PKERR_MISSINGDEP )
|
|
|
1142 |
{
|
|
|
1143 |
CyStringList depList;
|
|
|
1144 |
m_pPackages->GetMissingDependacies(p, &depList, true);
|
|
|
1145 |
CyString sDep;
|
|
|
1146 |
for ( SStringList *strNode = depList.Head(); strNode; strNode = strNode->next )
|
|
|
1147 |
{
|
|
|
1148 |
if ( strNode->str.IsIn("|") )
|
|
|
1149 |
sDep = strNode->str.GetToken("|", 1, 1) + " V" + strNode->str.GetToken("|", 2, 2) + " by " + strNode->data + "\n";
|
|
|
1150 |
else
|
|
|
1151 |
sDep = strNode->str + " by " + strNode->data + "\n";
|
|
|
1152 |
}
|
|
|
1153 |
this->DisplayMessageBox(false, "Enable Error", "Error enabling package\n" + SystemStringFromCyString(p->GetFullPackageName(m_pPackages->GetLanguage())) + "\n\nMissing Enabled Dependacies:\n" + SystemStringFromCyString(sDep), MessageBoxButtons::OK, MessageBoxIcon::Warning);
|
|
|
1154 |
}
|
|
|
1155 |
else
|
|
|
1156 |
this->DisplayMessageBox(false, "Enable Error", "Error enabling package\n" + SystemStringFromCyString(p->GetFullPackageName(m_pPackages->GetLanguage())) + "\n\nUnknown Error", MessageBoxButtons::OK, MessageBoxIcon::Warning);
|
|
|
1157 |
return false;
|
|
|
1158 |
}
|
|
|
1159 |
return true;
|
|
|
1160 |
}
|
|
|
1161 |
|
|
|
1162 |
void MainGui::DisableList(ArrayList ^List)
|
|
|
1163 |
{
|
|
|
1164 |
bool skipShips = false;
|
|
|
1165 |
int count = 0;
|
|
|
1166 |
|
|
|
1167 |
for ( int i = 0; i < List->Count; i++ )
|
|
|
1168 |
{
|
|
|
1169 |
CBaseFile *p = this->FindPackageFromList(cli::safe_cast<ListViewItem ^>(List[i]));
|
|
|
1170 |
if ( p )
|
|
|
1171 |
{
|
|
|
1172 |
if ( p->IsEnabled() )
|
|
|
1173 |
{
|
|
|
1174 |
if ( p->GetType() == TYPE_SPK && ((CSpkFile *)p)->IsLibrary() )
|
|
|
1175 |
{
|
|
|
1176 |
if ( this->DisplayMessageBox(false, "Disable Library", "Package: " + SystemStringFromCyString(p->GetFullPackageName(m_pPackages->GetLanguage())) + "\nThis is a library package and might be required for other installed packages\nDo you still wish to disable it?", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::No )
|
|
|
1177 |
continue;
|
|
|
1178 |
}
|
|
|
1179 |
if ( p->GetType() == TYPE_XSP )
|
|
|
1180 |
{
|
|
|
1181 |
if ( !this->DisplayTip(TIPSECTION_YESNO, TIP_SHIPDISABLE) )
|
|
|
1182 |
skipShips = true;
|
|
|
1183 |
|
|
|
1184 |
if ( skipShips )
|
|
|
1185 |
continue;
|
|
|
1186 |
}
|
|
|
1187 |
|
|
|
1188 |
m_pPackages->PrepareDisablePackage(p);
|
|
|
1189 |
++count;
|
|
|
1190 |
}
|
|
|
1191 |
else
|
|
|
1192 |
{
|
|
|
1193 |
this->EnablePackage(p);
|
|
|
1194 |
++count;
|
|
|
1195 |
}
|
|
|
1196 |
}
|
|
|
1197 |
}
|
|
|
1198 |
|
|
|
1199 |
if ( count )
|
|
|
1200 |
{
|
|
|
1201 |
this->Enabled = false;
|
|
|
1202 |
this->StartBackground(MGUI_BACKGROUND_DISABLE);
|
|
|
1203 |
}
|
|
|
1204 |
}
|
|
|
1205 |
|
|
|
1206 |
void MainGui::DisableEvent(System::Object ^Sender, System::EventArgs ^E)
|
|
|
1207 |
{
|
|
|
1208 |
if ( !ListPackages->SelectedItems->Count )
|
|
|
1209 |
return;
|
|
|
1210 |
|
|
|
1211 |
bool skipShips = false;
|
|
|
1212 |
|
|
|
1213 |
ListView::SelectedListViewItemCollection^ selected = this->ListPackages->SelectedItems;
|
|
|
1214 |
System::Collections::IEnumerator^ myEnum = selected->GetEnumerator();
|
|
|
1215 |
int count = 0;
|
|
|
1216 |
ArrayList ^List = gcnew ArrayList();
|
|
|
1217 |
|
|
|
1218 |
while ( myEnum->MoveNext() )
|
|
|
1219 |
List->Add(safe_cast<ListViewItem ^>(myEnum->Current));
|
|
|
1220 |
|
|
|
1221 |
if ( List->Count )
|
|
|
1222 |
this->DisableList(List);
|
|
|
1223 |
}
|
|
|
1224 |
|
|
|
1225 |
void MainGui::PackageBrowserEvent(System::Object ^Sender, System::EventArgs ^E)
|
|
|
1226 |
{
|
|
|
1227 |
this->Enabled = false;
|
|
|
1228 |
PackageBrowser ^mod = gcnew PackageBrowser(m_pPackages, this->imageList1);
|
|
|
1229 |
if ( !mod->AnyPackages() )
|
|
|
1230 |
{
|
|
|
1231 |
System::String ^game;
|
|
|
1232 |
if ( m_pDirList && m_pDirList->Count() && m_pDirList->Head() )
|
|
|
1233 |
{
|
|
|
1234 |
CyString sGame = m_pDirList->Head()->data;
|
|
|
1235 |
if ( sGame.IsIn("|") )
|
|
|
1236 |
sGame = sGame.GetToken("|", 2);
|
|
|
1237 |
game = SystemStringFromCyString(sGame);
|
|
|
1238 |
}
|
|
|
1239 |
this->DisplayMessageBox(false, "No Available Packages", "No available packages found for " + game, MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
|
|
|
1240 |
|
|
|
1241 |
this->Enabled = true;
|
|
|
1242 |
return;
|
|
|
1243 |
}
|
|
|
1244 |
|
|
|
1245 |
if ( m_bDirLocked ) {
|
|
|
1246 |
this->DisplayLocked(false);
|
|
|
1247 |
this->Enabled = true;
|
|
|
1248 |
return;
|
|
|
1249 |
}
|
|
|
1250 |
|
|
|
1251 |
mod->SetExperimental(m_bExperimental);
|
|
|
1252 |
mod->SetCheat(m_bCheat);
|
|
|
1253 |
mod->SetShips(m_bShips);
|
|
|
1254 |
if ( m_pPackages->IsVanilla() )
|
|
|
1255 |
mod->SetSigned(true);
|
|
|
1256 |
else
|
|
|
1257 |
mod->SetSigned(m_bSigned);
|
|
|
1258 |
mod->SetDownload(m_bDownloadable);
|
|
|
1259 |
mod->UpdatePackages();
|
|
|
1260 |
System::Windows::Forms::DialogResult result = mod->ShowDialog(this);
|
|
|
1261 |
|
|
|
1262 |
m_bDownloadable = mod->IsDownload();
|
|
|
1263 |
m_bCheat = mod->IsCheat();
|
|
|
1264 |
m_bExperimental = mod->IsExperimental();
|
|
|
1265 |
m_bShips = mod->IsShips();
|
|
|
1266 |
m_bSigned = mod->IsSigned();
|
|
|
1267 |
|
|
|
1268 |
bool doenable = true;
|
|
|
1269 |
CBaseFile *p = mod->SelectedMod();
|
|
|
1270 |
if ( result == System::Windows::Forms::DialogResult::OK )
|
|
|
1271 |
{
|
|
|
1272 |
if ( p )
|
|
|
1273 |
{
|
|
|
1274 |
if ( this->InstallPackage(SystemStringFromCyString(p->GetFilename()), true, false, true) )
|
|
|
1275 |
doenable = false;
|
|
|
1276 |
}
|
|
|
1277 |
}
|
|
|
1278 |
else if ( result == System::Windows::Forms::DialogResult::Yes )
|
|
|
1279 |
this->StartInstalling(false, true);
|
|
|
1280 |
|
|
|
1281 |
this->Enabled = doenable;
|
|
|
1282 |
}
|
|
|
1283 |
|
|
|
1284 |
void MainGui::CloseEvent(System::Object ^Sender, FormClosingEventArgs ^E)
|
|
|
1285 |
{
|
|
|
1286 |
int h = this->Size.Height;
|
|
|
1287 |
int w = this->Size.Width;
|
|
|
1288 |
}
|
|
|
1289 |
|
|
|
1290 |
void MainGui::DisplayLocked(bool inthread)
|
|
|
1291 |
{
|
|
|
1292 |
this->DisplayMessageBox(inthread, "Directory Locked", "The current directory is locked and unable to make any changes\nYou may need to adjust the directory permissions", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
|
|
1293 |
}
|
|
|
1294 |
|
|
|
1295 |
void MainGui::ModSelectorEvent(System::Object ^Sender, System::EventArgs ^E)
|
|
|
1296 |
{
|
|
|
1297 |
if ( m_pPackages->IsVanilla() )
|
|
|
1298 |
{
|
|
|
1299 |
this->DisplayMessageBox(false, "Mod Selector", "Currently in Vanilla Mode, You can only enable mods when in Modified Mode\n\nSwitch to modified mode if you wish to install mods", MessageBoxButtons::OK, MessageBoxIcon::Question);
|
|
|
1300 |
return;
|
|
|
1301 |
}
|
|
|
1302 |
this->Enabled = false;
|
|
|
1303 |
ModSelector ^mod = gcnew ModSelector(m_pPackages, this->imageList1);
|
|
|
1304 |
|
|
|
1305 |
if ( !mod->AnyPackages() )
|
|
|
1306 |
{
|
|
|
1307 |
this->DisplayMessageBox(false, "Mod Selector", "No available mods have been found", MessageBoxButtons::OK, MessageBoxIcon::Warning);
|
|
|
1308 |
this->Enabled = true;
|
|
|
1309 |
return;
|
|
|
1310 |
}
|
|
|
1311 |
|
|
|
1312 |
if ( m_bDirLocked ) {
|
|
|
1313 |
this->DisplayLocked(false);
|
|
|
1314 |
this->Enabled = true;
|
|
|
1315 |
return;
|
|
|
1316 |
}
|
|
|
1317 |
|
|
|
1318 |
if ( !m_bModSelectorDetails )
|
|
|
1319 |
{
|
|
|
1320 |
mod->HideDetails();
|
|
|
1321 |
mod->Update();
|
|
|
1322 |
}
|
|
|
1323 |
|
|
|
1324 |
System::Windows::Forms::DialogResult result = mod->ShowDialog(this);
|
|
|
1325 |
m_bModSelectorDetails = mod->ShowingDetails();
|
|
|
1326 |
|
|
|
1327 |
// install the selected mod
|
|
|
1328 |
bool reEnable = true;
|
|
|
1329 |
|
|
|
1330 |
CBaseFile *p = mod->SelectedMod();
|
|
|
1331 |
if ( result == System::Windows::Forms::DialogResult::OK )
|
|
|
1332 |
{
|
|
|
1333 |
if ( p )
|
|
|
1334 |
{
|
|
|
1335 |
// from file
|
|
|
1336 |
if ( p->GetNum() < 0 )
|
|
|
1337 |
{
|
|
|
1338 |
if ( m_pPackages->GetEnabledMod() )
|
|
|
1339 |
m_pPackages->DisablePackage(m_pPackages->GetEnabledMod(), 0, 0);
|
|
|
1340 |
if ( this->InstallPackage(SystemStringFromCyString(p->GetFilename()), true, false, true) )
|
|
|
1341 |
reEnable = false;
|
|
|
1342 |
}
|
|
|
1343 |
// otherwise just enable it
|
|
|
1344 |
else
|
|
|
1345 |
{
|
|
|
1346 |
if ( this->EnablePackage(p) )
|
|
|
1347 |
{
|
|
|
1348 |
this->StartBackground(MGUI_BACKGROUND_DISABLE);
|
|
|
1349 |
reEnable = false;
|
|
|
1350 |
}
|
|
|
1351 |
}
|
|
|
1352 |
}
|
|
|
1353 |
}
|
|
|
1354 |
|
|
|
1355 |
// install downloaded mods
|
|
|
1356 |
else if ( result == Windows::Forms::DialogResult::Yes )
|
|
|
1357 |
this->StartInstalling(false, true);
|
|
|
1358 |
|
|
|
1359 |
// remove the current mod
|
|
|
1360 |
else if ( result == System::Windows::Forms::DialogResult::Abort )
|
|
|
1361 |
{
|
|
|
1362 |
if ( m_pPackages->GetEnabledMod() )
|
|
|
1363 |
{
|
|
|
1364 |
CBaseFile *mod = m_pPackages->GetEnabledMod();
|
|
|
1365 |
CyString message = mod->GetFullPackageName(m_pPackages->GetLanguage());
|
|
|
1366 |
m_pPackages->DisablePackage(m_pPackages->GetEnabledMod(), 0, 0);
|
|
|
1367 |
this->DisplayMessageBox(false, "Mod Disabed", SystemStringFromCyString(message) + " has been disabled\nYour game is no longer using any mods\n", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
|
|
|
1368 |
}
|
|
|
1369 |
}
|
|
|
1370 |
|
|
|
1371 |
// uninstall the selected mod
|
|
|
1372 |
else if ( result == System::Windows::Forms::DialogResult::Retry )
|
|
|
1373 |
{
|
|
|
1374 |
if ( p && p->GetNum() >= 0 )
|
|
|
1375 |
{
|
|
|
1376 |
m_pPackages->PrepareUninstallPackage(p);
|
|
|
1377 |
if ( m_pPackages->GetNumPackagesInQueue() )
|
|
|
1378 |
{
|
|
|
1379 |
reEnable = false;
|
|
|
1380 |
this->StartBackground(MGUI_BACKGROUND_UNINSTALL);
|
|
|
1381 |
}
|
|
|
1382 |
}
|
|
|
1383 |
}
|
|
|
1384 |
|
|
|
1385 |
if ( reEnable )
|
|
|
1386 |
this->Enabled = true;
|
|
|
1387 |
|
|
|
1388 |
mod->RemovePackages();
|
|
|
1389 |
}
|
|
|
1390 |
|
|
|
1391 |
void MainGui::UninstallList(ArrayList ^List)
|
|
|
1392 |
{
|
|
|
1393 |
bool skipShips = false;
|
|
|
1394 |
|
|
|
1395 |
for ( int i = 0; i < List->Count; i++ )
|
|
|
1396 |
{
|
|
|
1397 |
CBaseFile *p = this->FindPackageFromList(safe_cast<ListViewItem ^>(List[i]));
|
|
|
1398 |
if ( p )
|
|
|
1399 |
{
|
|
|
1400 |
if ( p->GetType() == TYPE_XSP )
|
|
|
1401 |
{
|
|
|
1402 |
if ( !this->DisplayTip(TIPSECTION_YESNO, TIP_SHIPUNINSTALL) )
|
|
|
1403 |
skipShips = true;
|
|
|
1404 |
|
|
|
1405 |
if ( skipShips )
|
|
|
1406 |
continue;
|
|
|
1407 |
}
|
|
|
1408 |
|
|
|
1409 |
m_pPackages->PrepareUninstallPackage(p);
|
|
|
1410 |
}
|
|
|
1411 |
}
|
|
|
1412 |
|
|
|
1413 |
if ( m_pPackages->GetNumPackagesInQueue() )
|
|
|
1414 |
{
|
|
|
1415 |
this->Enabled = false;
|
|
|
1416 |
this->StartBackground(MGUI_BACKGROUND_UNINSTALL);
|
|
|
1417 |
}
|
|
|
1418 |
}
|
|
|
1419 |
void MainGui::UninstallEvent(System::Object ^Sender, System::EventArgs ^E)
|
|
|
1420 |
{
|
|
|
1421 |
if ( !ListPackages->SelectedItems->Count )
|
|
|
1422 |
return;
|
|
|
1423 |
|
|
|
1424 |
ArrayList ^List = gcnew ArrayList();
|
|
|
1425 |
|
|
|
1426 |
ListView::SelectedListViewItemCollection^ selected = this->ListPackages->SelectedItems;
|
|
|
1427 |
System::Collections::IEnumerator^ myEnum = selected->GetEnumerator();
|
|
|
1428 |
|
|
|
1429 |
while ( myEnum->MoveNext() )
|
|
|
1430 |
List->Add(safe_cast<ListViewItem ^>(myEnum->Current));
|
|
|
1431 |
|
|
|
1432 |
this->UninstallList(List);
|
|
|
1433 |
}
|
|
|
1434 |
|
|
|
1435 |
void MainGui::ModifiedEvent(System::Object ^Sender, System::EventArgs ^E)
|
|
|
1436 |
{
|
|
|
1437 |
if ( m_bDirLocked ) {
|
|
|
1438 |
this->DisplayLocked(false);
|
|
|
1439 |
return;
|
|
|
1440 |
}
|
|
|
1441 |
if ( m_pPackages->IsVanilla() )
|
|
|
1442 |
{
|
|
|
1443 |
this->Enabled = false;
|
|
|
1444 |
if ( this->DisplayMessageBox(false, "Modified Mode", "Enabling modified mode will allow you to use any modified content\nThis will however mark any games you save as modified and you will be unable to participate in Uplink\nAny current save games wil also be backed up and kept seperate from your modified save games\n\nDo you wish to enable modified mode?", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
|
|
|
1445 |
{
|
|
|
1446 |
if ( m_iSaveGameManager == 1 )
|
|
|
1447 |
{
|
|
|
1448 |
m_pPackages->BackupSaves(true);
|
|
|
1449 |
m_pPackages->RestoreSaves(false);
|
|
|
1450 |
}
|
|
|
1451 |
m_pPackages->SetVanilla(false);
|
|
|
1452 |
m_pMenuBar->Modified();
|
|
|
1453 |
m_pPackages->PrepareEnableLibrarys();
|
|
|
1454 |
m_pPackages->PrepareEnableFromVanilla();
|
|
|
1455 |
this->StartBackground(MGUI_BACKGROUND_DISABLE);
|
|
|
1456 |
}
|
|
|
1457 |
else
|
|
|
1458 |
this->Enabled = true;
|
|
|
1459 |
}
|
|
|
1460 |
}
|
|
|
1461 |
|
|
|
1462 |
void MainGui::VanillaEvent(System::Object ^Sender, System::EventArgs ^E)
|
|
|
1463 |
{
|
|
|
1464 |
if ( m_bDirLocked ) {
|
|
|
1465 |
this->DisplayLocked(false);
|
|
|
1466 |
return;
|
|
|
1467 |
}
|
|
|
1468 |
if ( !m_pPackages->IsVanilla() )
|
|
|
1469 |
{
|
|
|
1470 |
this->Enabled = false;
|
|
|
1471 |
if ( this->DisplayMessageBox(false, "Vanilla Mode", "Switching back to vanilla mode you will no longer be able to use any modifying packages, these will be disabled\nYour current save games will be backed up as modified saves, and any vanilla save games will be restored\n\nDo you wish to go back to Vanilla?", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
|
|
|
1472 |
{
|
|
|
1473 |
if ( m_iSaveGameManager == 1 )
|
|
|
1474 |
{
|
|
|
1475 |
m_pPackages->RestoreSaves(true);
|
|
|
1476 |
m_pPackages->BackupSaves(false);
|
|
|
1477 |
}
|
|
|
1478 |
m_pPackages->SetVanilla(true);
|
|
|
1479 |
m_pMenuBar->Vanilla();
|
|
|
1480 |
m_pPackages->PrepareDisableForVanilla();
|
|
|
1481 |
this->StartBackground(MGUI_BACKGROUND_DISABLE);
|
|
|
1482 |
}
|
|
|
1483 |
else
|
|
|
1484 |
this->Enabled = true;
|
|
|
1485 |
}
|
|
|
1486 |
}
|
|
|
1487 |
|
|
|
1488 |
void MainGui::InstallEvent(System::Object ^Sender, System::EventArgs ^E)
|
|
|
1489 |
{
|
|
|
1490 |
if ( m_bDirLocked ) {
|
|
|
1491 |
this->DisplayLocked(false);
|
|
|
1492 |
return;
|
|
|
1493 |
}
|
|
|
1494 |
|
|
|
1495 |
OpenFileDialog ^ofd = gcnew OpenFileDialog();
|
|
|
1496 |
ofd->Filter = "All (*.spk, *.xsp)|*.spk;*.xsp|Package Files (*.spk)|*.spk|Ship Files (*.xsp)|*.xsp";
|
|
|
1497 |
ofd->FilterIndex = 1;
|
|
|
1498 |
ofd->RestoreDirectory = true;
|
|
|
1499 |
ofd->Multiselect = true;
|
|
|
1500 |
|
|
|
1501 |
this->Enabled = false;
|
|
|
1502 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1503 |
{
|
|
|
1504 |
bool anytoinstall = false;
|
|
|
1505 |
array<System::String ^> ^fileArray = ofd->FileNames;
|
|
|
1506 |
for ( int i = 0; i < fileArray->Length; i++ )
|
|
|
1507 |
{
|
|
|
1508 |
System::String ^file = fileArray[i];
|
|
|
1509 |
if ( this->InstallPackage(file, false, false, true) )
|
|
|
1510 |
anytoinstall = true;
|
|
|
1511 |
}
|
|
|
1512 |
|
|
|
1513 |
if ( anytoinstall )
|
|
|
1514 |
this->StartInstalling(false, true);
|
|
|
1515 |
}
|
|
|
1516 |
else
|
|
|
1517 |
{
|
|
|
1518 |
ProgressBar->Hide();
|
|
|
1519 |
this->Enabled = true;
|
|
|
1520 |
}
|
|
|
1521 |
}
|
|
|
1522 |
|
|
|
1523 |
void MainGui::CheckUnusedShared()
|
|
|
1524 |
{
|
|
|
1525 |
if ( m_pPackages->AnyUnusedShared() )
|
|
|
1526 |
{
|
|
|
1527 |
if ( this->DisplayMessageBox(false, "Remove Shared Files", "You have some unused shared files, would you like to remove these?", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes)
|
|
|
1528 |
m_pPackages->RemoveUnusedSharedFiles();
|
|
|
1529 |
}
|
|
|
1530 |
}
|
|
|
1531 |
|
|
|
1532 |
void MainGui::ChangeDirectoryEvent(System::Object ^Sender, System::EventArgs ^E)
|
|
|
1533 |
{
|
|
|
1534 |
if ( m_iBackgroundTask == MGUI_BACKGROUND_ADDDIR )
|
|
|
1535 |
return;
|
|
|
1536 |
|
|
|
1537 |
CyString dir = CyStringFromSystemString(ComboDir->Text);
|
|
|
1538 |
if ( dir.NumToken(" [") )
|
|
|
1539 |
dir = dir.GetToken(" [", 1, dir.NumToken(" [") - 1);
|
|
|
1540 |
|
|
|
1541 |
if ( !m_pPackages->IsCurrentDir(dir) )
|
|
|
1542 |
{
|
|
|
1543 |
this->Enabled = false;
|
|
|
1544 |
this->CheckUnusedShared();
|
|
|
1545 |
this->StartBackground(MGUI_BACKGROUND_CHANGEDIR, SystemStringFromCyString(dir));
|
|
|
1546 |
}
|
|
|
1547 |
}
|
|
|
1548 |
|
|
|
1549 |
void MainGui::Background_DoWork(System::Object ^Sender, DoWorkEventArgs ^E)
|
|
|
1550 |
{
|
|
|
1551 |
m_bDisplayMessage = false;
|
|
|
1552 |
m_bDisplayDialog = false;
|
|
|
1553 |
|
|
|
1554 |
switch ( m_iBackgroundTask )
|
|
|
1555 |
{
|
|
|
1556 |
case MGUI_BACKGROUND_INSTALL:
|
|
|
1557 |
this->DoInstall(false, true);
|
|
|
1558 |
break;
|
|
|
1559 |
case MGUI_BACKGROUND_INSTALLBUILTIN:
|
|
|
1560 |
this->DoInstall(true, true);
|
|
|
1561 |
break;
|
|
|
1562 |
case MGUI_BACKGROUND_UNINSTALL:
|
|
|
1563 |
this->DoUninstall();
|
|
|
1564 |
break;
|
|
|
1565 |
case MGUI_BACKGROUND_DISABLE:
|
|
|
1566 |
this->DoDisable();
|
|
|
1567 |
break;
|
|
|
1568 |
case MGUI_BACKGROUND_CHANGEDIR:
|
|
|
1569 |
case MGUI_BACKGROUND_ADDDIR:
|
|
|
1570 |
this->ChangeDirectory(CyStringFromSystemString(m_sBackgroundInfo));
|
|
|
1571 |
break;
|
|
|
1572 |
case MGUI_BACKGROUND_REMOVEDIR:
|
|
|
1573 |
this->RemoveCurrentDirectory();
|
|
|
1574 |
}
|
|
|
1575 |
}
|
|
|
1576 |
|
|
|
1577 |
void MainGui::Background_Finished()
|
|
|
1578 |
{
|
|
|
1579 |
ProgressBar->Hide();
|
|
|
1580 |
|
|
|
1581 |
if ( m_bDisplayMessage )
|
|
|
1582 |
MessageBox::Show(this, m_sMessageText, m_sMessageTitle, m_messageButtons, m_messageIcon);
|
|
|
1583 |
|
|
|
1584 |
if ( m_bDisplayDialog )
|
|
|
1585 |
{
|
|
|
1586 |
if ( m_pPi->PackageCount() )
|
|
|
1587 |
{
|
|
|
1588 |
m_pPi->AdjustColumns();
|
|
|
1589 |
m_pPi->ShowDialog(this);
|
|
|
1590 |
}
|
|
|
1591 |
}
|
|
|
1592 |
|
|
|
1593 |
m_bDisplayDialog = false;
|
|
|
1594 |
m_bDisplayMessage = false;
|
|
|
1595 |
|
|
|
1596 |
if ( m_iBackgroundTask == MGUI_BACKGROUND_CHANGEDIR || m_iBackgroundTask == MGUI_BACKGROUND_ADDDIR )
|
|
|
1597 |
{
|
|
|
1598 |
// switch the dir list
|
|
|
1599 |
if ( ComboDir->Text )
|
|
|
1600 |
{
|
|
|
1601 |
CyString dir = CyStringFromSystemString(ComboDir->Text);
|
|
|
1602 |
if ( !dir.Empty() )
|
|
|
1603 |
{
|
|
|
1604 |
if ( (m_iBackgroundTask == MGUI_BACKGROUND_CHANGEDIR) && (dir.NumToken(" [")) )
|
|
|
1605 |
dir = dir.GetToken(" [", 1, dir.NumToken(" [") - 1);
|
|
|
1606 |
if ( m_pDirList->FindString(dir) )
|
|
|
1607 |
{
|
|
|
1608 |
CyString data = m_pDirList->FindString(dir)->data;
|
|
|
1609 |
m_pDirList->Remove(dir, false);
|
|
|
1610 |
m_pDirList->PushFront(dir, data);
|
|
|
1611 |
}
|
|
|
1612 |
else
|
|
|
1613 |
{
|
|
|
1614 |
int lang = m_pPackages->GetGameLanguage(dir);
|
|
|
1615 |
if ( lang )
|
|
|
1616 |
m_pDirList->PushFront(dir, CyString::Number(lang) + "|" + m_pPackages->GetGameName(dir));
|
|
|
1617 |
else
|
|
|
1618 |
m_pDirList->PushFront(dir, m_pPackages->GetGameName(dir));
|
|
|
1619 |
}
|
|
|
1620 |
|
|
|
1621 |
this->UpdateDirList();
|
|
|
1622 |
}
|
|
|
1623 |
}
|
|
|
1624 |
}
|
|
|
1625 |
|
|
|
1626 |
// display any files that failed
|
|
|
1627 |
if ( m_iBackgroundTask == MGUI_BACKGROUND_INSTALL )
|
|
|
1628 |
{
|
|
|
1629 |
String ^files = "";
|
|
|
1630 |
for ( SStringList *str = m_pFileErrors->Head(); str; str = str->next )
|
|
|
1631 |
{
|
|
|
1632 |
if ( str->data.ToInt() == SPKINSTALL_WRITEFILE_FAIL )
|
|
|
1633 |
{
|
|
|
1634 |
files += "\n";
|
|
|
1635 |
files += SystemStringFromCyString(str->str);
|
|
|
1636 |
}
|
|
|
1637 |
}
|
|
|
1638 |
|
|
|
1639 |
if ( files->Length )
|
|
|
1640 |
MessageBox::Show(this, "These files failed to install\n" + files, "Failed Files", MessageBoxButtons::OK, MessageBoxIcon::Warning);
|
|
|
1641 |
}
|
|
|
1642 |
|
|
|
1643 |
switch ( m_iBackgroundTask )
|
|
|
1644 |
{
|
|
|
1645 |
case MGUI_BACKGROUND_CHANGEDIR:
|
|
|
1646 |
case MGUI_BACKGROUND_ADDDIR:
|
|
|
1647 |
this->UpdateControls();
|
|
|
1648 |
this->UpdatePackages();
|
|
|
1649 |
this->CheckProtectedDir();
|
|
|
1650 |
m_bRunningBackground = false;
|
|
|
1651 |
if ( this->UpdateBuiltInPackages() )
|
|
|
1652 |
return;
|
|
|
1653 |
break;
|
|
|
1654 |
|
|
|
1655 |
case MGUI_BACKGROUND_INSTALL:
|
|
|
1656 |
case MGUI_BACKGROUND_INSTALLBUILTIN:
|
|
|
1657 |
case MGUI_BACKGROUND_UNINSTALL:
|
|
|
1658 |
case MGUI_BACKGROUND_DISABLE:
|
|
|
1659 |
this->UpdatePackages();
|
|
|
1660 |
break;
|
|
|
1661 |
case MGUI_BACKGROUND_REMOVEDIR:
|
|
|
1662 |
ComboDir->Items->RemoveAt(0);
|
|
|
1663 |
this->DisplayMessageBox(false, "Remove Directory", "Directory has been removed\n" + SystemStringFromCyString(m_pRemovedDirList->Tail()->str), MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
1664 |
break;
|
|
|
1665 |
}
|
|
|
1666 |
|
|
|
1667 |
if ( m_iBackgroundTask == MGUI_BACKGROUND_ADDDIR )
|
|
|
1668 |
this->DisplayMessageBox(false, "Add Game Folder", "Folder \"" + m_sBackgroundInfo + "\" added\nGame: " + SystemStringFromCyString(m_pPackages->GetGameName(CyStringFromSystemString(m_sBackgroundInfo))), MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
1669 |
|
|
|
1670 |
else if ( m_iBackgroundTask == MGUI_BACKGROUND_REMOVEDIR )
|
|
|
1671 |
{
|
|
|
1672 |
// no more directories left
|
|
|
1673 |
if ( m_pDirList->Empty() )
|
|
|
1674 |
{
|
|
|
1675 |
m_bRunningBackground = false;
|
|
|
1676 |
this->Close();
|
|
|
1677 |
}
|
|
|
1678 |
// otherwise, open the next directory
|
|
|
1679 |
else
|
|
|
1680 |
{
|
|
|
1681 |
m_bRunningBackground = false;
|
|
|
1682 |
ComboDir->SelectedItem = ComboDir->Items[0];
|
|
|
1683 |
// this->StartBackground(MGUI_BACKGROUND_CHANGEDIR, SystemStringFromCyString(m_pDirList->Head()->str));
|
|
|
1684 |
return;
|
|
|
1685 |
}
|
|
|
1686 |
}
|
|
|
1687 |
|
|
|
1688 |
m_iBackgroundTask = MGUI_BACKGROUND_NONE;
|
|
|
1689 |
|
|
|
1690 |
this->Enabled = true;
|
|
|
1691 |
|
|
|
1692 |
m_bRunningBackground = false;
|
|
|
1693 |
}
|
|
|
1694 |
|
|
|
1695 |
void MainGui::Background_Progress(System::Object ^Sender, ProgressChangedEventArgs ^E)
|
|
|
1696 |
{
|
|
|
1697 |
this->ProgressBar->Value = E->ProgressPercentage;
|
|
|
1698 |
}
|
|
|
1699 |
|
|
|
1700 |
bool MainGui::UpdateBuiltInPackages()
|
|
|
1701 |
{
|
|
|
1702 |
// find all built-in packages
|
|
|
1703 |
if ( System::IO::Directory::Exists(".\\Required") )
|
|
|
1704 |
{
|
|
|
1705 |
bool installing = false;
|
|
|
1706 |
array <System::String ^> ^Files = System::IO::Directory::GetFiles(".\\Required", "*.spk");
|
|
|
1707 |
|
|
|
1708 |
for ( int i = 0; i < Files->Length; i++ )
|
|
|
1709 |
{
|
|
|
1710 |
CyString file = CyStringFromSystemString(Files[i]);
|
|
|
1711 |
int error;
|
|
|
1712 |
CBaseFile *p = m_pPackages->OpenPackage(file, &error, 0, SPKREAD_NODATA);
|
|
|
1713 |
if ( !p )
|
|
|
1714 |
continue;
|
|
|
1715 |
|
|
|
1716 |
if ( !((CSpkFile *)p)->IsLibrary() )
|
|
|
1717 |
continue;
|
|
|
1718 |
|
|
|
1719 |
if ( !p->CheckGameCompatability(m_pPackages->GetGame()) )
|
|
|
1720 |
continue;
|
|
|
1721 |
|
|
|
1722 |
// if its installed, check if we have a newer version
|
|
|
1723 |
CBaseFile *check = m_pPackages->FindSpkPackage(p->GetName(), p->GetAuthor());
|
|
|
1724 |
if ( check )
|
|
|
1725 |
{
|
|
|
1726 |
if ( check->GetVersion().CompareVersion(p->GetVersion()) != COMPARE_OLDER )
|
|
|
1727 |
{
|
|
|
1728 |
this->InstallPackage(Files[i], false, true, true);
|
|
|
1729 |
installing = true;
|
|
|
1730 |
}
|
|
|
1731 |
}
|
|
|
1732 |
else
|
|
|
1733 |
{
|
|
|
1734 |
this->InstallPackage(Files[i], false, true, true);
|
|
|
1735 |
installing = true;
|
|
|
1736 |
}
|
|
|
1737 |
|
|
|
1738 |
delete p;
|
|
|
1739 |
}
|
|
|
1740 |
|
|
|
1741 |
if ( installing )
|
|
|
1742 |
this->StartInstalling(true, true);
|
|
|
1743 |
return installing;
|
|
|
1744 |
}
|
|
|
1745 |
|
|
|
1746 |
return false;
|
|
|
1747 |
}
|
|
|
1748 |
|
|
|
1749 |
////
|
|
|
1750 |
// Auto Update
|
|
|
1751 |
////
|
|
|
1752 |
void MainGui::AutoUpdate()
|
|
|
1753 |
{
|
|
|
1754 |
if ( !m_bAutoUpdate || !System::IO::File::Exists( ".\\AutoUpdater.exe") )
|
|
|
1755 |
return;
|
|
|
1756 |
|
|
|
1757 |
// load the dir list
|
|
|
1758 |
if ( !m_pUpdateList )
|
|
|
1759 |
{
|
|
|
1760 |
m_pUpdateList = new CyStringList;
|
|
|
1761 |
|
|
|
1762 |
// TODO: read addresses from data
|
|
|
1763 |
|
|
|
1764 |
// hardcoded address
|
|
|
1765 |
m_pUpdateList->PushBack("http://cycrow.thexuniverse.us/pmupdate.dat", "", true);
|
|
|
1766 |
if ( (int)PMLBETA )
|
|
|
1767 |
m_pUpdateList->PushBack("http://cycrow.thexuniverse.us/Beta/pmupdatebeta.dat", "", true);
|
|
|
1768 |
}
|
|
|
1769 |
|
|
|
1770 |
backgroundUpdater->RunWorkerAsync();
|
|
|
1771 |
}
|
|
|
1772 |
|
|
|
1773 |
void MainGui::Updater_Finished(System::Object ^Sender, RunWorkerCompletedEventArgs ^E)
|
|
|
1774 |
{
|
|
|
1775 |
if ( !m_pUpdateList )
|
|
|
1776 |
return;
|
|
|
1777 |
if ( !m_pUpdateList->Head() )
|
|
|
1778 |
{
|
|
|
1779 |
delete m_pUpdateList;
|
|
|
1780 |
m_pUpdateList = NULL;
|
|
|
1781 |
return;
|
|
|
1782 |
}
|
|
|
1783 |
|
|
|
1784 |
this->Enabled = false;
|
|
|
1785 |
|
|
|
1786 |
CyString server = m_pUpdateList->Head()->str;
|
|
|
1787 |
CyString data = m_pUpdateList->Head()->data;
|
|
|
1788 |
|
|
|
1789 |
m_pUpdateList->PopFront();
|
|
|
1790 |
|
|
|
1791 |
// lets check if we have an update
|
|
|
1792 |
if ( data.GetToken(" ", 1, 1) != "!ERROR!" )
|
|
|
1793 |
{
|
|
|
1794 |
CyString download;
|
|
|
1795 |
CyString message;
|
|
|
1796 |
int max;
|
|
|
1797 |
CyString *strs = data.SplitToken("\n", &max);
|
|
|
1798 |
if ( strs )
|
|
|
1799 |
{
|
|
|
1800 |
for ( int i = 0; i < max; i++ )
|
|
|
1801 |
{
|
|
|
1802 |
CyString cmd = strs[i].GetToken(":", 1, 1);
|
|
|
1803 |
CyString rest = strs[i].GetToken(":", 2);
|
|
|
1804 |
rest.RemoveFirstSpace();
|
|
|
1805 |
if ( cmd.Compare("SPKVERSION") )
|
|
|
1806 |
{
|
|
|
1807 |
float v = rest.GetToken(" ", 1, 1).ToFloat();
|
|
|
1808 |
if ( v > GetLibraryVersion() )
|
|
|
1809 |
{
|
|
|
1810 |
message += "New version of the SPK Libraries available\nCurrent = ";
|
|
|
1811 |
message += CyString::CreateFromFloat(GetLibraryVersion(), 2);
|
|
|
1812 |
message += "\nNew Version = ";
|
|
|
1813 |
message += CyString::CreateFromFloat(v, 2);
|
|
|
1814 |
message += "\n\n";
|
|
|
1815 |
|
|
|
1816 |
CyString filename = rest.GetToken(" ", 2);
|
|
|
1817 |
if ( download.Empty() )
|
|
|
1818 |
download = filename;
|
|
|
1819 |
else
|
|
|
1820 |
{
|
|
|
1821 |
download += "|";
|
|
|
1822 |
download += filename;
|
|
|
1823 |
}
|
|
|
1824 |
}
|
|
|
1825 |
}
|
|
|
1826 |
else if ( cmd.Compare("PMLVERSION") )
|
|
|
1827 |
{
|
|
|
1828 |
float v = rest.GetToken(" ", 1, 1).ToFloat();
|
|
|
1829 |
int beta = rest.GetToken(" ", 2, 2).ToInt();
|
|
|
1830 |
|
|
|
1831 |
bool newVersion = false;
|
|
|
1832 |
// new version
|
|
|
1833 |
if ( v > (float)PMLVERSION )
|
|
|
1834 |
newVersion = true;
|
|
|
1835 |
// same version, check beta/rc
|
|
|
1836 |
if ( v == (float)PMLVERSION )
|
|
|
1837 |
{
|
|
|
1838 |
// newer beta version
|
|
|
1839 |
if ( beta > (int)PMLBETA && (int)PMLBETA > 0 )
|
|
|
1840 |
newVersion = true;
|
|
|
1841 |
// current is beta, new is an RC
|
|
|
1842 |
else if ( (int)PMLBETA > 0 && beta < 0 )
|
|
|
1843 |
newVersion = true;
|
|
|
1844 |
// current is rc, new is an rc
|
|
|
1845 |
else if ( (int)PMLBETA < 0 && beta < 0 && beta < (int)PMLBETA )
|
|
|
1846 |
newVersion = true;
|
|
|
1847 |
// current is beta or rc, new is not, so its newer
|
|
|
1848 |
else if ( (int)PMLBETA != 0 && beta == 0 )
|
|
|
1849 |
newVersion = true;
|
|
|
1850 |
}
|
|
|
1851 |
|
|
|
1852 |
if ( newVersion )
|
|
|
1853 |
{
|
|
|
1854 |
message += "New version of the ";
|
|
|
1855 |
message += CyStringFromSystemString(GetProgramName(m_bAdvanced));
|
|
|
1856 |
message += " available\nCurrent = ";
|
|
|
1857 |
message += CyStringFromSystemString(PluginManager::GetVersionString());
|
|
|
1858 |
message += "\nNew Version = ";
|
|
|
1859 |
message += CyStringFromSystemString(PluginManager::GetVersionString(v, beta));
|
|
|
1860 |
message += "\n\n";
|
|
|
1861 |
if ( download.Empty() )
|
|
|
1862 |
download = rest.GetToken(" ", 3);
|
|
|
1863 |
else
|
|
|
1864 |
{
|
|
|
1865 |
download += "|";
|
|
|
1866 |
download += rest.GetToken(" ", 3);
|
|
|
1867 |
}
|
|
|
1868 |
}
|
|
|
1869 |
}
|
|
|
1870 |
}
|
|
|
1871 |
}
|
|
|
1872 |
|
|
|
1873 |
CLEANSPLIT(strs, max)
|
|
|
1874 |
|
|
|
1875 |
if ( !download.Empty() && !message.Empty() )
|
|
|
1876 |
{
|
|
|
1877 |
if ( this->DisplayMessageBox(false, "Updater", SystemStringFromCyString(message) + "Do You wish to download and install it?", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
|
|
|
1878 |
{
|
|
|
1879 |
// absolute address
|
|
|
1880 |
CyString downloadFile;
|
|
|
1881 |
|
|
|
1882 |
int max;
|
|
|
1883 |
CyString *strs = download.SplitToken("|", &max);
|
|
|
1884 |
for ( int i = 0; i < max; i++ )
|
|
|
1885 |
{
|
|
|
1886 |
CyString d = strs[i];
|
|
|
1887 |
// relative address
|
|
|
1888 |
if ( !d.Left(7).Compare("http://") && !d.Left(4).Compare("www.") )
|
|
|
1889 |
d = server.DelToken("/", server.NumToken("/")) + "/" + d;
|
|
|
1890 |
|
|
|
1891 |
if ( downloadFile.Empty() )
|
|
|
1892 |
downloadFile = d;
|
|
|
1893 |
else
|
|
|
1894 |
{
|
|
|
1895 |
downloadFile += "|";
|
|
|
1896 |
downloadFile += d;
|
|
|
1897 |
}
|
|
|
1898 |
}
|
|
|
1899 |
|
|
|
1900 |
CLEANSPLIT(strs, max);
|
|
|
1901 |
|
|
|
1902 |
if ( !downloadFile.Empty() )
|
|
|
1903 |
{
|
|
|
1904 |
m_sDownload = SystemStringFromCyString(downloadFile);
|
|
|
1905 |
this->Close();
|
|
|
1906 |
return;
|
|
|
1907 |
}
|
|
|
1908 |
}
|
|
|
1909 |
}
|
|
|
1910 |
}
|
|
|
1911 |
|
|
|
1912 |
// otherwise, lets continue with the next server
|
|
|
1913 |
if ( m_pUpdateList->Head() )
|
|
|
1914 |
backgroundUpdater->RunWorkerAsync();
|
|
|
1915 |
else
|
|
|
1916 |
{
|
|
|
1917 |
delete m_pUpdateList;
|
|
|
1918 |
m_pUpdateList = NULL;
|
|
|
1919 |
}
|
|
|
1920 |
|
|
|
1921 |
this->Enabled = true;
|
|
|
1922 |
}
|
|
|
1923 |
|
|
|
1924 |
void MainGui::TimerEvent_CheckFile(System::Object ^Sender, System::EventArgs ^E)
|
|
|
1925 |
{
|
|
|
1926 |
if ( m_bRunningBackground )
|
|
|
1927 |
return;
|
|
|
1928 |
|
|
|
1929 |
System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
|
|
|
1930 |
|
|
|
1931 |
bool anytoinstall = false;
|
|
|
1932 |
|
|
|
1933 |
if ( System::IO::File::Exists(mydoc + "\\Egosoft\\pluginmanager_load.dat") )
|
|
|
1934 |
{
|
|
|
1935 |
System::String ^lines = System::IO::File::ReadAllText(mydoc + "\\Egosoft\\pluginmanager_load.dat");
|
|
|
1936 |
System::IO::File::Delete(mydoc + "\\Egosoft\\pluginmanager_load.dat");
|
|
|
1937 |
if ( lines )
|
|
|
1938 |
{
|
|
|
1939 |
CyString strLines = CyStringFromSystemString(lines);
|
|
|
1940 |
int num;
|
|
|
1941 |
CyString *aLines = strLines.SplitToken("\n", &num);
|
|
|
1942 |
if ( num && aLines )
|
|
|
1943 |
{
|
|
|
1944 |
for ( int i = 0; i < num; i++ )
|
|
|
1945 |
{
|
|
|
1946 |
CyString l = aLines[i];
|
|
|
1947 |
l = l.Remove("\r");
|
|
|
1948 |
CyString first = l.GetToken(":", 1, 1);
|
|
|
1949 |
CyString rest = l.GetToken(":", 2);
|
|
|
1950 |
rest.RemoveFirstSpace();
|
|
|
1951 |
|
|
|
1952 |
if ( first.Compare("File") )
|
|
|
1953 |
{
|
|
|
1954 |
if ( m_bDirLocked ) {
|
|
|
1955 |
this->DisplayLocked(false);
|
|
|
1956 |
return;
|
|
|
1957 |
}
|
|
|
1958 |
if ( this->InstallPackage(SystemStringFromCyString(rest), false, false, true) )
|
|
|
1959 |
anytoinstall = true;
|
|
|
1960 |
}
|
|
|
1961 |
}
|
|
|
1962 |
|
|
|
1963 |
CLEANSPLIT(aLines, num);
|
|
|
1964 |
}
|
|
|
1965 |
}
|
|
|
1966 |
}
|
|
|
1967 |
|
|
|
1968 |
if ( anytoinstall )
|
|
|
1969 |
this->StartInstalling(false, true);
|
|
|
1970 |
}
|
|
|
1971 |
|
|
|
1972 |
void MainGui::Updater_DoWork(System::Object ^Sender, DoWorkEventArgs ^E)
|
|
|
1973 |
{
|
|
|
1974 |
if ( !m_pUpdateList )
|
|
|
1975 |
return;
|
|
|
1976 |
if ( !m_pUpdateList->Head() )
|
|
|
1977 |
{
|
|
|
1978 |
delete m_pUpdateList;
|
|
|
1979 |
m_pUpdateList = NULL;
|
|
|
1980 |
return;
|
|
|
1981 |
}
|
|
|
1982 |
|
|
|
1983 |
try
|
|
|
1984 |
{
|
|
|
1985 |
System::Net::WebClient ^Client = gcnew System::Net::WebClient();
|
|
|
1986 |
|
|
|
1987 |
System::IO::Stream ^strm = Client->OpenRead(SystemStringFromCyString(m_pUpdateList->Head()->str));
|
|
|
1988 |
System::IO::StreamReader ^sr = gcnew System::IO::StreamReader(strm);
|
|
|
1989 |
System::String ^read = sr->ReadToEnd();
|
|
|
1990 |
strm->Close();
|
|
|
1991 |
sr->Close();
|
|
|
1992 |
|
|
|
1993 |
m_pUpdateList->Head()->data = CyStringFromSystemString(read);
|
|
|
1994 |
}
|
|
|
1995 |
catch (System::Net::WebException ^ex)
|
|
|
1996 |
{
|
|
|
1997 |
m_pUpdateList->Head()->data = CyStringFromSystemString("!ERROR! " + ex->ToString());
|
|
|
1998 |
if ( ex->Status == System::Net::WebExceptionStatus::ConnectFailure )
|
|
|
1999 |
{
|
|
|
2000 |
m_pUpdateList->Head()->data = CyStringFromSystemString("!ERROR! " + ex->ToString());
|
|
|
2001 |
|
|
|
2002 |
}
|
|
|
2003 |
}
|
|
|
2004 |
}
|
|
|
2005 |
|
|
|
2006 |
void MainGui::RemoveDirectory()
|
|
|
2007 |
{
|
|
|
2008 |
if ( !m_pPackages->IsLoaded() )
|
|
|
2009 |
return;
|
|
|
2010 |
|
|
|
2011 |
System::String ^remDir = SystemStringFromCyString(m_pPackages->GetCurrentDirectory());
|
|
|
2012 |
this->Enabled = false;
|
|
|
2013 |
if ( this->DisplayMessageBox(false, "Remove Directory", "Are you sure you want to remove this directory:\n" + remDir + "\n\nThis will remove all installed packages and clear any settings", MessageBoxButtons::YesNo, MessageBoxIcon::Question) != System::Windows::Forms::DialogResult::Yes)
|
|
|
2014 |
{
|
|
|
2015 |
this->Enabled = true;
|
|
|
2016 |
return;
|
|
|
2017 |
}
|
|
|
2018 |
|
|
|
2019 |
this->StartBackground(MGUI_BACKGROUND_REMOVEDIR, remDir);
|
|
|
2020 |
}
|
|
|
2021 |
|
|
|
2022 |
bool MainGui::RemoveCurrentDirectory()
|
|
|
2023 |
{
|
|
|
2024 |
if ( !m_pPackages->RemoveCurrentDirectory() )
|
|
|
2025 |
return false;
|
|
|
2026 |
|
|
|
2027 |
// remove directory from list
|
|
|
2028 |
m_pRemovedDirList->PushBack(m_pDirList->Head()->str, "", true);
|
|
|
2029 |
m_pDirList->PopFront();
|
|
|
2030 |
|
|
|
2031 |
return true;
|
|
|
2032 |
}
|
|
|
2033 |
|
|
|
2034 |
void MainGui::LaunchGame()
|
|
|
2035 |
{
|
|
|
2036 |
if ( !System::IO::File::Exists(".\\GameLauncher.exe") )
|
|
|
2037 |
return;
|
|
|
2038 |
|
|
|
2039 |
m_sRun = SystemStringFromCyString(m_pPackages->GetGameRunExe());
|
|
|
2040 |
this->Close();
|
|
|
2041 |
}
|
|
|
2042 |
|
|
|
2043 |
bool MainGui::DisplayTip(int tipsection, int tip)
|
|
|
2044 |
{
|
|
|
2045 |
if ( tipsection < 0 || tipsection >= MAXTIPS )
|
|
|
2046 |
return false;
|
|
|
2047 |
|
|
|
2048 |
STips ^tips = (STips ^)m_lTips[tipsection];
|
|
|
2049 |
if ( !(tips->iTips & tip) )
|
|
|
2050 |
{
|
|
|
2051 |
System::String ^sTip = cli::safe_cast<System::String ^>(tips->sTips[(tip >> 1)]);
|
|
|
2052 |
|
|
|
2053 |
tips->iTips |= tip;
|
|
|
2054 |
|
|
|
2055 |
if ( this->DisplayMessageBox(false, "Plugin Manager Tip", sTip, MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
|
|
|
2056 |
return true;
|
|
|
2057 |
else
|
|
|
2058 |
return false;
|
|
|
2059 |
}
|
|
|
2060 |
|
|
|
2061 |
return true;
|
|
|
2062 |
}
|
|
|
2063 |
|
|
|
2064 |
void MainGui::SetTipStrings(int section)
|
|
|
2065 |
{
|
|
|
2066 |
STips ^t = (STips ^)m_lTips[section];
|
|
|
2067 |
t->sTips = gcnew ArrayList();
|
|
|
2068 |
|
|
|
2069 |
switch ( section )
|
|
|
2070 |
{
|
|
|
2071 |
case TIPSECTION_YESNO:
|
|
|
2072 |
t->sTips->Add("You are about to uninstall a ship, you need to make sure that there are no ships in the sector you was in when you saved, otherwise it could prevent the save from loading\n\nContinue Uninstalling Ship?");
|
|
|
2073 |
t->sTips->Add("You are about to disable a ship, you need to make sure that there are no ships in the sector you was in when you saved, otherwise it could prevent the save from loading\n\nContinue Disabling Ship?");
|
|
|
2074 |
break;
|
|
|
2075 |
}
|
|
|
2076 |
}
|
|
|
2077 |
|
|
|
2078 |
System::Windows::Forms::DialogResult MainGui::DisplayMessageBox(bool inthread, System::String ^title, System::String ^text, MessageBoxButtons buttons, MessageBoxIcon icon)
|
|
|
2079 |
{
|
|
|
2080 |
if ( !inthread )
|
|
|
2081 |
return MessageBox::Show(this, text, title, buttons, icon);
|
|
|
2082 |
else
|
|
|
2083 |
{
|
|
|
2084 |
m_bDisplayMessage = true;
|
|
|
2085 |
m_sMessageText = text;
|
|
|
2086 |
m_sMessageTitle = title;
|
|
|
2087 |
m_messageIcon = icon;
|
|
|
2088 |
m_messageButtons = buttons;
|
|
|
2089 |
|
|
|
2090 |
return System::Windows::Forms::DialogResult::Abort;
|
|
|
2091 |
}
|
|
|
2092 |
}
|
|
|
2093 |
|
|
|
2094 |
ListViewItem ^MainGui::FindSelectedItem()
|
|
|
2095 |
{
|
|
|
2096 |
Point ^mousePoint = this->ListPackages->PointToClient(this->contextMenuStrip1->MousePosition);
|
|
|
2097 |
return this->ListPackages->GetItemAt(mousePoint->X, mousePoint->Y);
|
|
|
2098 |
}
|
|
|
2099 |
|
|
|
2100 |
CBaseFile *MainGui::GetFileFromItem(ListViewItem ^item)
|
|
|
2101 |
{
|
|
|
2102 |
int num = System::Convert::ToInt32(item->Tag);
|
|
|
2103 |
return m_pPackages->GetPackageAt(num);
|
|
|
2104 |
}
|
|
|
2105 |
|
|
|
2106 |
System::Void MainGui::OpenContextMenu(System::Object ^Sender, CancelEventArgs ^E)
|
|
|
2107 |
{
|
|
|
2108 |
m_pListItem = nullptr;
|
|
|
2109 |
E->Cancel = true;
|
|
|
2110 |
bool showSep = false;
|
|
|
2111 |
bool showSep2 = false;
|
|
|
2112 |
|
|
|
2113 |
ListViewItem ^item = this->FindSelectedItem();
|
|
|
2114 |
CBaseFile *p = NULL;
|
|
|
2115 |
if ( item )
|
|
|
2116 |
p = this->GetFileFromItem(item);
|
|
|
2117 |
|
|
|
2118 |
this->emailAuthorToolStripMenuItem->Visible = false;
|
|
|
2119 |
this->visitForumPageToolStripMenuItem->Visible = false;
|
|
|
2120 |
this->visitWebSiteToolStripMenuItem->Visible = false;
|
|
|
2121 |
this->ContextDisable->Visible = false;
|
|
|
2122 |
this->ContextEnable->Visible = false;
|
|
|
2123 |
this->ContextName->Image = nullptr;
|
|
|
2124 |
this->UninstallSelectedContext->Visible = false;
|
|
|
2125 |
this->viewReadmeToolStripMenuItem->Visible = false;
|
|
|
2126 |
this->extrasToolStripMenuItem->Visible = false;
|
|
|
2127 |
this->checkForUpdatesToolStripMenuItem->Visible = false;
|
|
|
2128 |
|
|
|
2129 |
if ( p || this->ListPackages->SelectedItems->Count )
|
|
|
2130 |
{
|
|
|
2131 |
|
|
|
2132 |
if ( item && p )
|
|
|
2133 |
{
|
|
|
2134 |
m_pListItem = item;
|
|
|
2135 |
this->ContextName->Text = item->Text;
|
|
|
2136 |
if ( item->ImageIndex != -1 )
|
|
|
2137 |
this->ContextName->Image = this->ListPackages->LargeImageList->Images[item->ImageIndex];
|
|
|
2138 |
else if ( item->ImageKey )
|
|
|
2139 |
{
|
|
|
2140 |
int key = this->ListPackages->LargeImageList->Images->IndexOfKey(item->ImageKey);
|
|
|
2141 |
if ( key != -1 )
|
|
|
2142 |
this->ContextName->Image = this->ListPackages->LargeImageList->Images[key];
|
|
|
2143 |
}
|
|
|
2144 |
else if ( p->GetIcon() )
|
|
|
2145 |
PluginManager::DisplayContextIcon(p, this->ContextName, nullptr);
|
|
|
2146 |
|
|
|
2147 |
this->uninstallToolStripMenuItem->Text = "Uninstall: " + item->Text;
|
|
|
2148 |
|
|
|
2149 |
this->viewReadmeToolStripMenuItem->DropDownItems->Clear();
|
|
|
2150 |
if ( p->CountFiles(FILETYPE_README) )
|
|
|
2151 |
{
|
|
|
2152 |
for ( C_File *f = p->GetFirstFile(FILETYPE_README); f; f = p->GetNextFile(f) )
|
|
|
2153 |
{
|
|
|
2154 |
if ( f->GetBaseName().GetToken(".", 1, 1).IsNumber() )
|
|
|
2155 |
{
|
|
|
2156 |
if ( f->GetBaseName().GetToken(".", 1, 1).ToInt() != m_pPackages->GetLanguage() )
|
|
|
2157 |
continue;
|
|
|
2158 |
}
|
|
|
2159 |
if ( f->GetBaseName().IsIn("-L") )
|
|
|
2160 |
{
|
|
|
2161 |
int pos = f->GetBaseName().FindPos("-L");
|
|
|
2162 |
int l = f->GetBaseName().Mid(pos + 2, 3).ToInt();
|
|
|
2163 |
if ( l != m_pPackages->GetLanguage() )
|
|
|
2164 |
continue;
|
|
|
2165 |
}
|
|
|
2166 |
|
|
|
2167 |
Windows::Forms::ToolStripMenuItem ^item = gcnew Windows::Forms::ToolStripMenuItem();
|
|
|
2168 |
item->Text = SystemStringFromCyString(f->GetFilename());
|
|
|
2169 |
item->Image = this->viewReadmeToolStripMenuItem->Image;
|
|
|
2170 |
item->ImageScaling = ToolStripItemImageScaling::None;
|
|
|
2171 |
item->Click += gcnew System::EventHandler(this, &MainGui::RunItem);
|
|
|
2172 |
item->Tag = SystemStringFromCyString(f->GetFilePointer());
|
|
|
2173 |
this->viewReadmeToolStripMenuItem->DropDownItems->Add(item);
|
|
|
2174 |
}
|
|
|
2175 |
|
|
|
2176 |
if ( this->viewReadmeToolStripMenuItem->DropDownItems->Count )
|
|
|
2177 |
{
|
|
|
2178 |
this->viewReadmeToolStripMenuItem->Visible = true;
|
|
|
2179 |
showSep = true;
|
|
|
2180 |
}
|
|
|
2181 |
}
|
|
|
2182 |
|
|
|
2183 |
this->extrasToolStripMenuItem->DropDownItems->Clear();
|
|
|
2184 |
if ( p->CountFiles(FILETYPE_EXTRA) )
|
|
|
2185 |
{
|
|
|
2186 |
showSep = true;
|
|
|
2187 |
for ( C_File *f = p->GetFirstFile(FILETYPE_EXTRA); f; f = p->GetNextFile(f) )
|
|
|
2188 |
{
|
|
|
2189 |
if ( !f->GetDir().Left(6).Compare("extras") )
|
|
|
2190 |
continue;
|
|
|
2191 |
|
|
|
2192 |
Windows::Forms::ToolStripMenuItem ^item = gcnew Windows::Forms::ToolStripMenuItem();
|
|
|
2193 |
item->Text = SystemStringFromCyString(f->GetFilename());
|
|
|
2194 |
if ( this->imageList2->Images->IndexOfKey(SystemStringFromCyString(f->GetFileExt().ToLower())) > -1 )
|
|
|
2195 |
item->Image = this->imageList2->Images[this->imageList2->Images->IndexOfKey(SystemStringFromCyString(f->GetFileExt().ToLower()))];
|
|
|
2196 |
else
|
|
|
2197 |
{
|
|
|
2198 |
CyString exe = f->GetFilePointer();
|
|
|
2199 |
exe = exe.FindReplace("/", "\\");
|
|
|
2200 |
wchar_t wText[200];
|
|
|
2201 |
::MultiByteToWideChar(CP_ACP, NULL, (char *)exe.c_str(), -1, wText, exe.Length() + 1);
|
|
|
2202 |
|
|
|
2203 |
System::Drawing::Icon ^myIcon;
|
|
|
2204 |
SHFILEINFO *shinfo = new SHFILEINFO();
|
|
|
2205 |
|
|
|
2206 |
if ( FAILED(SHGetFileInfo(wText, 0, shinfo, sizeof(shinfo), SHGFI_ICON | SHGFI_LARGEICON)) )
|
|
|
2207 |
{
|
|
|
2208 |
if ( FAILED(SHGetFileInfo(wText, 0, shinfo, sizeof(shinfo), SHGFI_ICON | SHGFI_SMALLICON)) )
|
|
|
2209 |
item->Image = this->imageList2->Images[0];
|
|
|
2210 |
else
|
|
|
2211 |
{
|
|
|
2212 |
myIcon = System::Drawing::Icon::FromHandle(IntPtr(shinfo->hIcon));
|
|
|
2213 |
item->Image = myIcon->ToBitmap();
|
|
|
2214 |
}
|
|
|
2215 |
}
|
|
|
2216 |
else
|
|
|
2217 |
{
|
|
|
2218 |
myIcon = System::Drawing::Icon::FromHandle(IntPtr(shinfo->hIcon));
|
|
|
2219 |
item->Image = myIcon->ToBitmap();
|
|
|
2220 |
}
|
|
|
2221 |
|
|
|
2222 |
delete shinfo;
|
|
|
2223 |
}
|
|
|
2224 |
item->ImageScaling = ToolStripItemImageScaling::None;
|
|
|
2225 |
item->Click += gcnew System::EventHandler(this, &MainGui::RunItem);
|
|
|
2226 |
item->Tag = SystemStringFromCyString(f->GetFilePointer());
|
|
|
2227 |
this->extrasToolStripMenuItem->DropDownItems->Add(item);
|
|
|
2228 |
}
|
|
|
2229 |
}
|
|
|
2230 |
|
|
|
2231 |
if ( this->extrasToolStripMenuItem->DropDownItems->Count )
|
|
|
2232 |
this->extrasToolStripMenuItem->Visible = true;
|
|
|
2233 |
|
|
|
2234 |
// email/website/forum
|
|
|
2235 |
if ( !p->GetForumLink().Empty() )
|
|
|
2236 |
{
|
|
|
2237 |
CyString web = p->GetForumLink();
|
|
|
2238 |
if ( web.IsNumber() )
|
|
|
2239 |
web = CyString("http://forum.egosoft.com/viewtopic.php?t=") + web;
|
|
|
2240 |
|
|
|
2241 |
this->visitForumPageToolStripMenuItem->Visible = true;
|
|
|
2242 |
if ( !web.IsIn("http://") )
|
|
|
2243 |
this->visitForumPageToolStripMenuItem->Tag = "http://" + SystemStringFromCyString(web);
|
|
|
2244 |
else
|
|
|
2245 |
this->visitForumPageToolStripMenuItem->Tag = SystemStringFromCyString(web);
|
|
|
2246 |
showSep2 = true;
|
|
|
2247 |
}
|
|
|
2248 |
if ( !p->GetEmail().Empty() )
|
|
|
2249 |
{
|
|
|
2250 |
this->emailAuthorToolStripMenuItem->Visible = true;
|
|
|
2251 |
this->emailAuthorToolStripMenuItem->Tag = "mailto://" + SystemStringFromCyString(p->GetEmail()) + "?subject=Re: " + SystemStringFromCyString(p->GetName().FindReplace(" ", "%20"));
|
|
|
2252 |
showSep2 = true;
|
|
|
2253 |
}
|
|
|
2254 |
if ( !p->GetWebSite().Empty() )
|
|
|
2255 |
{
|
|
|
2256 |
this->visitWebSiteToolStripMenuItem->Visible = true;
|
|
|
2257 |
if ( !p->GetWebSite().IsIn("http://") )
|
|
|
2258 |
this->visitWebSiteToolStripMenuItem->Tag = "http://" + SystemStringFromCyString(p->GetWebSite());
|
|
|
2259 |
else
|
|
|
2260 |
this->visitWebSiteToolStripMenuItem->Tag = SystemStringFromCyString(p->GetWebSite());
|
|
|
2261 |
showSep2 = true;
|
|
|
2262 |
}
|
|
|
2263 |
|
|
|
2264 |
if ( !p->GetWebAddress().Empty() )
|
|
|
2265 |
this->checkForUpdatesToolStripMenuItem->Visible = true;
|
|
|
2266 |
}
|
|
|
2267 |
else
|
|
|
2268 |
m_pListItem = nullptr;
|
|
|
2269 |
|
|
|
2270 |
if ( this->ListPackages->SelectedItems->Count > 1 || !p )
|
|
|
2271 |
{
|
|
|
2272 |
this->UninstallSelectedContext->Visible = true;
|
|
|
2273 |
this->UninstallSelectedContext->Text = "Uninstall Selected (" + System::Convert::ToString(this->ListPackages->SelectedItems->Count) + " packages)";
|
|
|
2274 |
}
|
|
|
2275 |
|
|
|
2276 |
if ( p )
|
|
|
2277 |
{
|
|
|
2278 |
if ( p->IsEnabled() )
|
|
|
2279 |
this->ContextDisable->Visible = true;
|
|
|
2280 |
else
|
|
|
2281 |
this->ContextEnable->Visible = true;
|
|
|
2282 |
}
|
|
|
2283 |
|
|
|
2284 |
this->ContextSeperator->Visible = showSep;
|
|
|
2285 |
this->ContextSeperator2->Visible = showSep2;
|
|
|
2286 |
E->Cancel = false;
|
|
|
2287 |
}
|
|
|
2288 |
}
|
|
|
2289 |
|
|
|
2290 |
System::Void MainGui::ListPackages_DragOver(System::Object^ sender, System::Windows::Forms::DragEventArgs^ e)
|
|
|
2291 |
{
|
|
|
2292 |
e->Effect = DragDropEffects::None;
|
|
|
2293 |
|
|
|
2294 |
if (e->Data->GetDataPresent(DataFormats::FileDrop))
|
|
|
2295 |
{
|
|
|
2296 |
cli::array<String ^> ^a = (cli::array<String ^> ^)e->Data->GetData(DataFormats::FileDrop, false);
|
|
|
2297 |
int i;
|
|
|
2298 |
for(i = 0; i < a->Length; i++)
|
|
|
2299 |
{
|
|
|
2300 |
String ^s = a[i];
|
|
|
2301 |
String ^ext = IO::FileInfo(s).Extension;
|
|
|
2302 |
if ( String::Compare(IO::FileInfo(s).Extension, ".xsp", true) == 0 || String::Compare(IO::FileInfo(s).Extension, ".spk", true) == 0 )
|
|
|
2303 |
{
|
|
|
2304 |
e->Effect = DragDropEffects::Copy;
|
|
|
2305 |
break;
|
|
|
2306 |
}
|
|
|
2307 |
}
|
|
|
2308 |
}
|
|
|
2309 |
}
|
|
|
2310 |
|
|
|
2311 |
System::Void MainGui::ListPackages_DragDrop(System::Object^ sender, System::Windows::Forms::DragEventArgs^ e)
|
|
|
2312 |
{
|
|
|
2313 |
if (e->Data->GetDataPresent(DataFormats::FileDrop))
|
|
|
2314 |
{
|
|
|
2315 |
cli::array<String ^> ^a = (cli::array<String ^> ^)e->Data->GetData(DataFormats::FileDrop, false);
|
|
|
2316 |
int i;
|
|
|
2317 |
for(i = 0; i < a->Length; i++)
|
|
|
2318 |
{
|
|
|
2319 |
String ^s = a[i];
|
|
|
2320 |
String ^ext = IO::FileInfo(s).Extension;
|
|
|
2321 |
if ( String::Compare(IO::FileInfo(s).Extension, ".xsp", true) == 0 || String::Compare(IO::FileInfo(s).Extension, ".spk", true) == 0 )
|
|
|
2322 |
{
|
|
|
2323 |
if ( m_bDirLocked ) {
|
|
|
2324 |
this->DisplayLocked(false);
|
|
|
2325 |
return;
|
|
|
2326 |
}
|
|
|
2327 |
this->InstallPackage(s, false, false, true);
|
|
|
2328 |
}
|
|
|
2329 |
}
|
|
|
2330 |
|
|
|
2331 |
this->StartInstalling(false, true);
|
|
|
2332 |
}
|
|
|
2333 |
}
|
|
|
2334 |
|
|
|
2335 |
bool MainGui::CheckAccessRights(String ^dir)
|
|
|
2336 |
{
|
|
|
2337 |
/*
|
|
|
2338 |
// check if already exists
|
|
|
2339 |
String ^file = dir + "\\accessrightscheck.dat";
|
|
|
2340 |
String ^writeStr = "testing file access";
|
|
|
2341 |
if ( IO::File::Exists(file) )
|
|
|
2342 |
{
|
|
|
2343 |
// remove it
|
|
|
2344 |
IO::File::Delete(file);
|
|
|
2345 |
// still exists, cant delete it
|
|
|
2346 |
if ( IO::File::Exists(file) )
|
|
|
2347 |
return false;
|
|
|
2348 |
}
|
|
|
2349 |
|
|
|
2350 |
IO::DirectoryInfo ^dInfo = gcnew IO::DirectoryInfo(dir);
|
|
|
2351 |
Security::AccessControl::DirectorySecurity ^dSecurity = dInfo->GetAccessControl();
|
|
|
2352 |
dSecurity->
|
|
|
2353 |
|
|
|
2354 |
|
|
|
2355 |
System::IO::FileStream ^writeStream = nullptr;
|
|
|
2356 |
IO::BinaryWriter ^writer = nullptr;
|
|
|
2357 |
try {
|
|
|
2358 |
writeStream = gcnew System::IO::FileStream(file, System::IO::FileMode::Create);
|
|
|
2359 |
writer = gcnew IO::BinaryWriter(writeStream);
|
|
|
2360 |
}
|
|
|
2361 |
catch (System::IO::IOException ^e)
|
|
|
2362 |
{
|
|
|
2363 |
MessageBox::Show("Error: " + e->ToString(), "Error", MessageBoxButtons::OK, MessageBoxIcon::Warning);
|
|
|
2364 |
}
|
|
|
2365 |
catch (System::Exception ^e)
|
|
|
2366 |
{
|
|
|
2367 |
MessageBox::Show("Error: " + e->ToString(), "Error", MessageBoxButtons::OK, MessageBoxIcon::Warning);
|
|
|
2368 |
}
|
|
|
2369 |
finally
|
|
|
2370 |
{
|
|
|
2371 |
writer->Write(writeStr);
|
|
|
2372 |
writer->Close();
|
|
|
2373 |
writeStream->Close();
|
|
|
2374 |
}
|
|
|
2375 |
|
|
|
2376 |
// check if its written
|
|
|
2377 |
if ( !IO::File::Exists(file) )
|
|
|
2378 |
return false;
|
|
|
2379 |
|
|
|
2380 |
// remove the file again
|
|
|
2381 |
IO::File::Delete(file);
|
|
|
2382 |
if ( IO::File::Exists(file) )
|
|
|
2383 |
return false;
|
|
|
2384 |
*/
|
|
|
2385 |
return true;
|
|
|
2386 |
}
|
|
|
2387 |
|
|
|
2388 |
System::Void MainGui::RunItem(System::Object ^sender, System::EventArgs ^e)
|
|
|
2389 |
{
|
|
|
2390 |
Windows::Forms::ToolStripMenuItem ^item = cli::safe_cast<ToolStripMenuItem ^>(sender);
|
|
|
2391 |
String ^file = Convert::ToString(item->Tag);
|
|
|
2392 |
|
|
|
2393 |
if ( IO::File::Exists(file) )
|
|
|
2394 |
{
|
|
|
2395 |
System::Diagnostics::Process::Start(file);
|
|
|
2396 |
}
|
|
|
2397 |
}
|
|
|
2398 |
|
|
|
2399 |
void MainGui::RunFromToolItem(ToolStripMenuItem ^item)
|
|
|
2400 |
{
|
|
|
2401 |
if ( !item ) return;
|
|
|
2402 |
if ( !item->Tag ) return;
|
|
|
2403 |
|
|
|
2404 |
String ^file = Convert::ToString(item->Tag);
|
|
|
2405 |
System::Diagnostics::Process::Start(file);
|
|
|
2406 |
}
|
|
|
2407 |
|
|
|
2408 |
void MainGui::FakePatchControlDialog()
|
|
|
2409 |
{
|
|
|
2410 |
FakePatchControl ^fpc = gcnew FakePatchControl(m_pPackages);
|
|
|
2411 |
if ( fpc->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
2412 |
{
|
|
|
2413 |
m_pPackages->ApplyFakePatchOrder(fpc->GetPatchOrder());
|
|
|
2414 |
m_pPackages->ShuffleFakePatches(0);
|
|
|
2415 |
}
|
|
|
2416 |
}
|
|
|
2417 |
|
|
|
2418 |
void MainGui::CheckFakePatchCompatability()
|
|
|
2419 |
{
|
|
|
2420 |
CyStringList errorList;
|
|
|
2421 |
int count = 0;
|
|
|
2422 |
int packageCount = 0;
|
|
|
2423 |
for ( CBaseFile *p = m_pPackages->GetFirstPackage(); p; p = m_pPackages->GetNextPackage(p) )
|
|
|
2424 |
{
|
|
|
2425 |
if ( !p->IsEnabled() ) continue;
|
|
|
2426 |
if ( !p->AnyFileType(FILETYPE_MOD) ) continue;
|
|
|
2427 |
|
|
|
2428 |
CyString packageName = p->GetFullPackageName(m_pPackages->GetLanguage());
|
|
|
2429 |
|
|
|
2430 |
// compare this file against all other packages
|
|
|
2431 |
for ( CBaseFile *comparePackage = m_pPackages->GetNextPackage(p); comparePackage; comparePackage = m_pPackages->GetNextPackage(comparePackage) )
|
|
|
2432 |
{
|
|
|
2433 |
if ( comparePackage == p ) continue; // dont include the same package
|
|
|
2434 |
if ( !comparePackage->IsEnabled() ) continue;
|
|
|
2435 |
if ( !comparePackage->AnyFileType(FILETYPE_MOD) ) continue;
|
|
|
2436 |
|
|
|
2437 |
CyStringList list;
|
|
|
2438 |
if ( m_pPackages->CheckCompatabilityBetweenMods(p, comparePackage, &list) )
|
|
|
2439 |
{
|
|
|
2440 |
CyString package2Name = comparePackage->GetFullPackageName(m_pPackages->GetLanguage());
|
|
|
2441 |
for ( SStringList *str = list.Head(); str; str = str->next )
|
|
|
2442 |
{
|
|
|
2443 |
errorList.PushBack(str->str + " (" + packageName + ")", str->data + " (" + package2Name + ")");
|
|
|
2444 |
++count;
|
|
|
2445 |
}
|
|
|
2446 |
++packageCount;
|
|
|
2447 |
}
|
|
|
2448 |
}
|
|
|
2449 |
}
|
|
|
2450 |
|
|
|
2451 |
if ( count )
|
|
|
2452 |
{
|
|
|
2453 |
if ( MessageBox::Show(this, "Found incompatability between fake patches\n" + count + " errors found\n\nDo you wish to view the errors?", "Fake Patch Compatability", MessageBoxButtons::YesNo, MessageBoxIcon::Information) == Windows::Forms::DialogResult::Yes )
|
|
|
2454 |
{
|
|
|
2455 |
CompareList ^cl = gcnew CompareList("Fake Patch Incompatabilities");
|
|
|
2456 |
cl->AddStringList(errorList);
|
|
|
2457 |
cl->ShowDialog(this);
|
|
|
2458 |
}
|
|
|
2459 |
}
|
|
|
2460 |
else
|
|
|
2461 |
MessageBox::Show(this, "No incompatabilities found between fake patches", "Fake Patch Compatability", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
2462 |
}
|
|
|
2463 |
|
|
|
2464 |
void MainGui::EditGlobalsDialog()
|
|
|
2465 |
{
|
|
|
2466 |
if ( m_pPackages->IsVanilla() ) {
|
|
|
2467 |
this->DisplayMessageBox(false, "Edit Globals", "Currently in Vanilla Mode, Cant change globals without being modified\n\nSwitch to modified mode if you wish to edit globals", MessageBoxButtons::OK, MessageBoxIcon::Question);
|
|
|
2468 |
return;
|
|
|
2469 |
}
|
|
|
2470 |
if ( m_bDirLocked ) {
|
|
|
2471 |
this->DisplayLocked(false);
|
|
|
2472 |
return;
|
|
|
2473 |
}
|
|
|
2474 |
|
|
|
2475 |
//load globals
|
|
|
2476 |
CyStringList globals;
|
|
|
2477 |
m_pPackages->ReadGlobals(globals);
|
|
|
2478 |
|
|
|
2479 |
EditGlobals ^edit = gcnew EditGlobals(&globals);
|
|
|
2480 |
|
|
|
2481 |
// make our saved changes
|
|
|
2482 |
for ( SStringList *str = m_pPackages->GetGlobals()->Head(); str; str = str->next )
|
|
|
2483 |
edit->SetEditedItem(SystemStringFromCyString(str->str), SystemStringFromCyString(str->data));
|
|
|
2484 |
|
|
|
2485 |
if ( edit->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
2486 |
{
|
|
|
2487 |
// compare whats different and save
|
|
|
2488 |
m_pPackages->GetGlobals()->Clear();
|
|
|
2489 |
for ( SStringList *str = edit->GetSavedSettings()->Head(); str; str = str->next )
|
|
|
2490 |
m_pPackages->GetGlobals()->PushBack(str->str, str->data);
|
|
|
2491 |
}
|
|
|
2492 |
}
|
|
|
2493 |
|
|
|
2494 |
void MainGui::ViewFileLog()
|
|
|
2495 |
{
|
|
|
2496 |
if ( m_pFileErrors->Empty() )
|
|
|
2497 |
MessageBox::Show(this, "No messages to view in file log", "Empty File Log", MessageBoxButtons::OK, MessageBoxIcon::Warning);
|
|
|
2498 |
else
|
|
|
2499 |
{
|
|
|
2500 |
FileLog ^log = gcnew FileLog;
|
|
|
2501 |
for ( SStringList *str = m_pFileErrors->Head(); str; str = str->next )
|
|
|
2502 |
{
|
|
|
2503 |
bool add = true;
|
|
|
2504 |
String ^status = "Unknown Error";
|
|
|
2505 |
switch(str->data.GetToken(" ", 1, 1).ToInt())
|
|
|
2506 |
{
|
|
|
2507 |
case SPKINSTALL_CREATEDIRECTORY:
|
|
|
2508 |
status = "Created Directory";
|
|
|
2509 |
break;
|
|
|
2510 |
case SPKINSTALL_CREATEDIRECTORY_FAIL:
|
|
|
2511 |
status = "Failed to create Directory";
|
|
|
2512 |
break;
|
|
|
2513 |
case SPKINSTALL_WRITEFILE:
|
|
|
2514 |
status = "File Written";
|
|
|
2515 |
break;
|
|
|
2516 |
case SPKINSTALL_WRITEFILE_FAIL:
|
|
|
2517 |
status = "Failed to Write File";
|
|
|
2518 |
break;
|
|
|
2519 |
case SPKINSTALL_DELETEFILE:
|
|
|
2520 |
status = "Deleted File";
|
|
|
2521 |
break;
|
|
|
2522 |
case SPKINSTALL_DELETEFILE_FAIL:
|
|
|
2523 |
status = "Failed to Delete File";
|
|
|
2524 |
break;
|
|
|
2525 |
case SPKINSTALL_SKIPFILE:
|
|
|
2526 |
status = "File Skipped";
|
|
|
2527 |
break;
|
|
|
2528 |
case SPKINSTALL_REMOVEDIR:
|
|
|
2529 |
status = "Removed Directory";
|
|
|
2530 |
break;
|
|
|
2531 |
case SPKINSTALL_ENABLEFILE:
|
|
|
2532 |
status = "Enabled File";
|
|
|
2533 |
break;
|
|
|
2534 |
case SPKINSTALL_DISABLEFILE:
|
|
|
2535 |
status = "Disabled File";
|
|
|
2536 |
break;
|
|
|
2537 |
case SPKINSTALL_ENABLEFILE_FAIL:
|
|
|
2538 |
status = "Failed to Enable File";
|
|
|
2539 |
break;
|
|
|
2540 |
case SPKINSTALL_DISABLEFILE_FAIL:
|
|
|
2541 |
status = "Failed to Disable File";
|
|
|
2542 |
break;
|
|
|
2543 |
case SPKINSTALL_UNINSTALL_MOVE:
|
|
|
2544 |
status = "Moved Uninstall File";
|
|
|
2545 |
break;
|
|
|
2546 |
case SPKINSTALL_UNINSTALL_COPY:
|
|
|
2547 |
status = "Copied Uninstall File";
|
|
|
2548 |
break;
|
|
|
2549 |
case SPKINSTALL_UNINSTALL_MOVE_FAIL:
|
|
|
2550 |
status = "Failed to move uninstall file";
|
|
|
2551 |
break;
|
|
|
2552 |
case SPKINSTALL_UNINSTALL_COPY_FAIL:
|
|
|
2553 |
status = "Failed to copy uninstall file";
|
|
|
2554 |
break;
|
|
|
2555 |
case SPKINSTALL_UNINSTALL_REMOVE:
|
|
|
2556 |
status = "Removed uninstall file";
|
|
|
2557 |
break;
|
|
|
2558 |
case SPKINSTALL_UNINSTALL_REMOVE_FAIL:
|
|
|
2559 |
status = "Failed to remove uninstall file";
|
|
|
2560 |
break;
|
|
|
2561 |
case SPKINSTALL_ORIGINAL_BACKUP:
|
|
|
2562 |
status = "Backed up Original";
|
|
|
2563 |
break;
|
|
|
2564 |
case SPKINSTALL_ORIGINAL_RESTORE:
|
|
|
2565 |
status = "Restored Original";
|
|
|
2566 |
break;
|
|
|
2567 |
case SPKINSTALL_ORIGINAL_BACKUP_FAIL:
|
|
|
2568 |
status = "Failed to Backup Original";
|
|
|
2569 |
break;
|
|
|
2570 |
case SPKINSTALL_ORIGINAL_RESTORE_FAIL:
|
|
|
2571 |
status = "Failed to restore Original";
|
|
|
2572 |
break;
|
|
|
2573 |
case SPKINSTALL_FAKEPATCH:
|
|
|
2574 |
status = "Adjusting Fakepatch";
|
|
|
2575 |
break;
|
|
|
2576 |
case SPKINSTALL_FAKEPATCH_FAIL:
|
|
|
2577 |
status = "Failed to adjust Fakepatch";
|
|
|
2578 |
break;
|
|
|
2579 |
case SPKINSTALL_AUTOTEXT:
|
|
|
2580 |
status = "Adjusting Text File";
|
|
|
2581 |
break;
|
|
|
2582 |
case SPKINSTALL_AUTOTEXT_FAIL:
|
|
|
2583 |
status = "Failed to adjust Text File";
|
|
|
2584 |
break;
|
|
|
2585 |
case SPKINSTALL_MISSINGFILE:
|
|
|
2586 |
status = "Missing File";
|
|
|
2587 |
break;
|
|
|
2588 |
case SPKINSTALL_SHARED:
|
|
|
2589 |
status = "Shared File";
|
|
|
2590 |
break;
|
|
|
2591 |
case SPKINSTALL_SHARED_FAIL:
|
|
|
2592 |
status = "Shared File Failed";
|
|
|
2593 |
break;
|
|
|
2594 |
case SPKINSTALL_ORPHANED:
|
|
|
2595 |
status = "File Orphaned";
|
|
|
2596 |
break;
|
|
|
2597 |
case SPKINSTALL_ORPHANED_FAIL:
|
|
|
2598 |
status = "Failed to Orphan file";
|
|
|
2599 |
break;
|
|
|
2600 |
case SPKINSTALL_UNCOMPRESS_FAIL:
|
|
|
2601 |
status = "Failed to Uncompress";
|
|
|
2602 |
break;
|
|
|
2603 |
}
|
|
|
2604 |
|
|
|
2605 |
if ( add )
|
|
|
2606 |
{
|
|
|
2607 |
if ( str->data.NumToken(" ") > 1 )
|
|
|
2608 |
log->AddItem(SystemStringFromCyString(str->str.findreplace("~", " => ")), status, SystemStringFromCyString(SPK::ConvertTimeString((long)str->data.GetToken(" ", 2, 2).ToLong())));
|
|
|
2609 |
else
|
|
|
2610 |
log->AddItem(SystemStringFromCyString(str->str.findreplace("~", " => ")), status, nullptr);
|
|
|
2611 |
}
|
|
|
2612 |
}
|
|
|
2613 |
if ( log->ShowDialog(this) == Windows::Forms::DialogResult::Cancel )
|
|
|
2614 |
{
|
|
|
2615 |
if ( MessageBox::Show(this, "Are you sure you want to clear the file log?", "Clear File Log", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == Windows::Forms::DialogResult::Yes )
|
|
|
2616 |
{
|
|
|
2617 |
m_pFileErrors->Clear();
|
|
|
2618 |
MessageBox::Show(this, "The file log has been cleared", "File Log Cleared", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
2619 |
}
|
|
|
2620 |
}
|
|
|
2621 |
|
|
|
2622 |
}
|
|
|
2623 |
}
|
|
|
2624 |
|
|
|
2625 |
void MainGui::VerifyInstalledFiles()
|
|
|
2626 |
{
|
|
|
2627 |
CyStringList missing;
|
|
|
2628 |
int amount = m_pPackages->VerifyInstalledFiles(&missing);
|
|
|
2629 |
if ( !amount )
|
|
|
2630 |
MessageBox::Show(this, "All files are currently installed", "Verifying Installed Files", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
2631 |
else
|
|
|
2632 |
{
|
|
|
2633 |
String ^text;
|
|
|
2634 |
for ( SStringList *str = missing.Head(); str; str = str->next )
|
|
|
2635 |
{
|
|
|
2636 |
text += SystemStringFromCyString(str->str);
|
|
|
2637 |
text += "\n\t";
|
|
|
2638 |
CyString data = str->data.findreplace("\n", "\t\n");
|
|
|
2639 |
text += SystemStringFromCyString(data);
|
|
|
2640 |
text += "\n\n";
|
|
|
2641 |
}
|
|
|
2642 |
MessageBoxDetails::Show(this, "Verifing Installed Files", "Missing files detected\nAmount = " + amount, text, false, 600);
|
|
|
2643 |
}
|
|
|
2644 |
}
|
|
|
2645 |
|
|
|
2646 |
void MainGui::ExportPackageList()
|
|
|
2647 |
{
|
|
|
2648 |
bool enabled = false;
|
|
|
2649 |
if ( MessageBox::Show(this, "Do you only want to export enabled packages?", "Only Enabled", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == Windows::Forms::DialogResult::Yes )
|
|
|
2650 |
enabled =true;
|
|
|
2651 |
SaveFileDialog ^ofd = gcnew SaveFileDialog();
|
|
|
2652 |
ofd->Filter = "Log Files (*.log)|*.log";
|
|
|
2653 |
ofd->FilterIndex = 1;
|
|
|
2654 |
ofd->RestoreDirectory = true;
|
|
|
2655 |
ofd->AddExtension = true;
|
|
|
2656 |
ofd->Title = "Select the file to save the package list to";
|
|
|
2657 |
if ( ofd->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
2658 |
{
|
|
|
2659 |
if ( IO::File::Exists(ofd->FileName) )
|
|
|
2660 |
IO::File::Delete(ofd->FileName);
|
|
|
2661 |
|
|
|
2662 |
StreamWriter ^sw = File::CreateText(ofd->FileName);
|
|
|
2663 |
try
|
|
|
2664 |
{
|
|
|
2665 |
for ( CBaseFile *package = m_pPackages->FirstPackage(); package; package = m_pPackages->NextPackage() )
|
|
|
2666 |
{
|
|
|
2667 |
if ( enabled && !package->IsEnabled() ) continue;
|
|
|
2668 |
CyString line = package->GetName() + " :: " + package->GetAuthor() + " :: " + package->GetVersion() + " :: " + package->GetCreationDate() + " :: ";
|
|
|
2669 |
|
|
|
2670 |
if ( package->GetType() == TYPE_XSP )
|
|
|
2671 |
line += "Ship :: ";
|
|
|
2672 |
else if ( package->GetType() == TYPE_ARCHIVE )
|
|
|
2673 |
line += "- Archive - :: ";
|
|
|
2674 |
else if ( package->GetType() == TYPE_SPK )
|
|
|
2675 |
{
|
|
|
2676 |
CyString type = ((CSpkFile *)package)->GetScriptTypeString(m_pPackages->GetLanguage());
|
|
|
2677 |
if ( !type.Empty() )
|
|
|
2678 |
line += type + " :: ";
|
|
|
2679 |
}
|
|
|
2680 |
|
|
|
2681 |
line += ((package->IsEnabled()) ? CyString("Yes") : CyString("No")) + " :: " + ((package->IsSigned()) ? "Yes" : "No");
|
|
|
2682 |
sw->WriteLine(SystemStringFromCyString(line));
|
|
|
2683 |
}
|
|
|
2684 |
}
|
|
|
2685 |
finally
|
|
|
2686 |
{
|
|
|
2687 |
if ( sw )
|
|
|
2688 |
delete (IDisposable ^)sw;
|
|
|
2689 |
}
|
|
|
2690 |
|
|
|
2691 |
if ( IO::File::Exists(ofd->FileName) )
|
|
|
2692 |
{
|
|
|
2693 |
if ( enabled )
|
|
|
2694 |
MessageBox::Show(this, "Enabled Packages have been saved to:\n" + ofd->FileName, "Package List Saved", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
2695 |
else
|
|
|
2696 |
MessageBox::Show(this, "Complete Package List has been saved to:\n" + ofd->FileName, "Package List Saved", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
2697 |
}
|
|
|
2698 |
else
|
|
|
2699 |
MessageBox::Show(this, "There was an error writing file:\n" + ofd->FileName, "File Write Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
|
|
2700 |
}
|
|
|
2701 |
}
|
|
|
2702 |
}
|
|
|
2703 |
|