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