| Line 23... |
Line 23... |
| 23 |
void MainGui::OpenDirectoryControl()
|
23 |
void MainGui::OpenDirectoryControl()
|
| 24 |
{
|
24 |
{
|
| 25 |
DirectoryControl ^dialog = gcnew DirectoryControl(m_pPackages, m_pDirList, m_pRemovedDirList);
|
25 |
DirectoryControl ^dialog = gcnew DirectoryControl(m_pPackages, m_pDirList, m_pRemovedDirList);
|
| 26 |
if (dialog->ShowDialog(this) == System::Windows::Forms::DialogResult::OK)
|
26 |
if (dialog->ShowDialog(this) == System::Windows::Forms::DialogResult::OK)
|
| 27 |
{
|
27 |
{
|
| 28 |
Utils::CStringList *dirs = dialog->directories();
|
28 |
Utils::WStringList *dirs = dialog->directories();
|
| 29 |
Utils::CStringList *removed = dialog->removeDirectories();
|
29 |
Utils::WStringList *removed = dialog->removeDirectories();
|
| 30 |
|
30 |
|
| 31 |
// check if the current directory has been remove
|
31 |
// check if the current directory has been remove
|
| 32 |
bool isRemoved = m_pPackages->IsLoaded() && removed->contains(m_pPackages->getCurrentDirectory(), true);
|
32 |
bool isRemoved = m_pPackages->IsLoaded() && removed->contains(m_pPackages->getCurrentDirectory(), true);
|
| 33 |
|
33 |
|
| 34 |
// add all removed directories to list
|
34 |
// add all removed directories to list
|
| 35 |
m_pRemovedDirList->clear();
|
35 |
m_pRemovedDirList->clear();
|
| 36 |
for (auto itr = removed->begin(); itr != removed->end(); itr++)
|
36 |
for (auto itr = removed->begin(); itr != removed->end(); itr++)
|
| 37 |
m_pRemovedDirList->pushBack(m_pPackages->getProperDir((*itr)->str), (*itr)->data);
|
37 |
m_pRemovedDirList->pushBack(m_pPackages->getProperDir((*itr)->str.toString()), (*itr)->data);
|
| 38 |
|
38 |
|
| 39 |
bool changed = false;
|
39 |
bool changed = false;
|
| 40 |
|
40 |
|
| 41 |
Utils::String current;
|
41 |
Utils::WString current;
|
| 42 |
if (ComboDir->SelectedIndex == (ComboDir->Items->Count - 1))
|
42 |
if (ComboDir->SelectedIndex == (ComboDir->Items->Count - 1))
|
| 43 |
current = _S(ComboDir->Text);
|
43 |
current = _WS(ComboDir->Text);
|
| 44 |
else
|
44 |
else
|
| 45 |
current = m_pDirList->get(ComboDir->SelectedIndex)->str;
|
45 |
current = m_pDirList->get(ComboDir->SelectedIndex)->str;
|
| 46 |
|
46 |
|
| 47 |
// remove any directories from main list that are not removed
|
47 |
// remove any directories from main list that are not removed
|
| 48 |
for (int i = m_pDirList->size() - 1; i >= 0; --i)
|
48 |
for (int i = m_pDirList->size() - 1; i >= 0; --i)
|
| 49 |
{
|
49 |
{
|
| 50 |
Utils::String dir = m_pDirList->get(i)->str;
|
50 |
Utils::WString dir = m_pDirList->get(i)->str;
|
| 51 |
if (m_pRemovedDirList->contains(dir))
|
51 |
if (m_pRemovedDirList->contains(dir))
|
| 52 |
{
|
52 |
{
|
| 53 |
m_pDirList->removeAt(i);
|
53 |
m_pDirList->removeAt(i);
|
| 54 |
changed = true;
|
54 |
changed = true;
|
| 55 |
}
|
55 |
}
|
| 56 |
}
|
56 |
}
|
| 57 |
|
57 |
|
| 58 |
// now add any remaining directories
|
58 |
// now add any remaining directories
|
| 59 |
for (auto itr = dirs->begin(); itr != dirs->end(); itr++)
|
59 |
for (auto itr = dirs->begin(); itr != dirs->end(); itr++)
|
| 60 |
{
|
60 |
{
|
| 61 |
Utils::String dir = m_pPackages->getProperDir((*itr)->str);
|
61 |
Utils::WString dir = m_pPackages->getProperDir((*itr)->str.toString());
|
| 62 |
if (!m_pDirList->contains(dir))
|
62 |
if (!m_pDirList->contains(dir))
|
| 63 |
{
|
63 |
{
|
| 64 |
int lang = m_pPackages->getGameLanguage(dir);
|
64 |
int lang = m_pPackages->getGameLanguage(dir.toString());
|
| 65 |
if(lang > 0)
|
65 |
if(lang > 0)
|
| 66 |
m_pDirList->pushBack(dir, Utils::String::Number(lang) + "|" + (*itr)->data);
|
66 |
m_pDirList->pushBack(dir, Utils::WString::Number(lang) + L"|" + (*itr)->data);
|
| 67 |
else
|
67 |
else
|
| 68 |
m_pDirList->pushBack(dir, (*itr)->data);
|
68 |
m_pDirList->pushBack(dir, (*itr)->data);
|
| 69 |
changed = true;
|
69 |
changed = true;
|
| 70 |
}
|
70 |
}
|
| 71 |
}
|
71 |
}
|
| Line 168... |
Line 168... |
| 168 |
found = true;
|
168 |
found = true;
|
| 169 |
}
|
169 |
}
|
| 170 |
|
170 |
|
| 171 |
if ( found ) {
|
171 |
if ( found ) {
|
| 172 |
if ( !m_pPackages->IsSupressProtectedWarning() ) {
|
172 |
if ( !m_pPackages->IsSupressProtectedWarning() ) {
|
| 173 |
if ( MessageBox::Show(this, "WARNING: The game directory:\n" + _US(dir) + "\n\nIs in a protected directory (" + _US(CFileIO(dir).dir().tokens("/", 1, 2).findReplace("/", "\\")) + ")\n\nThis might cause problems with installing anything, its better to move to game elsewhere, or you may need to run the Plugin Manager with admin access rights\n\nWould you like to surpress this warning in the future?", "Protected Directory", MessageBoxButtons::YesNo, MessageBoxIcon::Warning) == Windows::Forms::DialogResult::Yes ) {
|
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("/", "\\")) + ")\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 ) {
|
| 174 |
m_pPackages->SurpressProtectedWarning();
|
174 |
m_pPackages->SurpressProtectedWarning();
|
| 175 |
}
|
175 |
}
|
| 176 |
}
|
176 |
}
|
| 177 |
}
|
177 |
}
|
| 178 |
}
|
178 |
}
|
| 179 |
}
|
179 |
}
|
| 180 |
}
|
180 |
}
|
| 181 |
|
181 |
|
| 182 |
void MainGui::UpdateDirList(const Utils::String ¤t)
|
182 |
void MainGui::UpdateDirList(const Utils::WString ¤t)
|
| 183 |
{
|
183 |
{
|
| 184 |
System::String ^checkCurrent = ComboDir->Text;
|
184 |
System::String ^checkCurrent = ComboDir->Text;
|
| 185 |
System::String ^selected = nullptr;
|
185 |
System::String ^selected = nullptr;
|
| 186 |
bool foundCurrent = false;
|
186 |
bool foundCurrent = false;
|
| 187 |
|
187 |
|
| Line 193... |
Line 193... |
| 193 |
{
|
193 |
{
|
| 194 |
if (CDirIO((*itr)->str).exists())
|
194 |
if (CDirIO((*itr)->str).exists())
|
| 195 |
{
|
195 |
{
|
| 196 |
System::String ^str;
|
196 |
System::String ^str;
|
| 197 |
if ((*itr)->data.isin("|"))
|
197 |
if ((*itr)->data.isin("|"))
|
| 198 |
str = _US((*itr)->str + " [" + (*itr)->data.tokens("|", 2) + "] (Language: " + CPackages::ConvertLanguage((*itr)->data.token("|", 1).toInt()) + ")");
|
198 |
str = _US((*itr)->str + L" [" + (*itr)->data.tokens(L"|", 2) + L"] (Language: " + CPackages::ConvertLanguage((*itr)->data.token(L"|", 1).toInt()).toWString() + L")");
|
| 199 |
else
|
199 |
else
|
| 200 |
str = _US((*itr)->str + " [" + (*itr)->data + "]");
|
200 |
str = _US((*itr)->str + L" [" + (*itr)->data + L"]");
|
| 201 |
ComboDir->Items->Add(str);
|
201 |
ComboDir->Items->Add(str);
|
| 202 |
|
202 |
|
| 203 |
if (!current.empty() && current.Compare((*itr)->str))
|
203 |
if (!current.empty() && current.Compare((*itr)->str))
|
| 204 |
selected = str;
|
204 |
selected = str;
|
| 205 |
|
205 |
|
| Line 331... |
Line 331... |
| 331 |
|
331 |
|
| 332 |
// now display
|
332 |
// now display
|
| 333 |
for ( i = 0; i < aPackages->Length; i++ )
|
333 |
for ( i = 0; i < aPackages->Length; i++ )
|
| 334 |
{
|
334 |
{
|
| 335 |
CBaseFile *p = (m_bSortingAsc) ? aPackages[i]->Package : aPackages[(aPackages->Length - 1 - i)]->Package;
|
335 |
CBaseFile *p = (m_bSortingAsc) ? aPackages[i]->Package : aPackages[(aPackages->Length - 1 - i)]->Package;
|
| 336 |
Utils::String name;
|
336 |
Utils::WString name;
|
| 337 |
if ( p->GetType() == TYPE_ARCHIVE )
|
337 |
if ( p->GetType() == TYPE_ARCHIVE )
|
| 338 |
name = CFileIO(p->filename()).filename();
|
338 |
name = CFileIO(p->filename()).filename();
|
| 339 |
else
|
339 |
else
|
| 340 |
name = p->name(m_pPackages->GetLanguage());
|
340 |
name = p->name(m_pPackages->GetLanguage()).toWString();
|
| 341 |
|
341 |
|
| 342 |
int indent = 0;
|
342 |
int indent = 0;
|
| 343 |
CBaseFile *parent = p;
|
343 |
CBaseFile *parent = p;
|
| 344 |
|
344 |
|
| 345 |
if ( p->GetParent() && p->GetParent()->GetType() == TYPE_SPK && ((CSpkFile *)p->GetParent())->IsLibrary() )
|
345 |
if ( p->GetParent() && p->GetParent()->GetType() == TYPE_SPK && ((CSpkFile *)p->GetParent())->IsLibrary() )
|
| Line 409... |
Line 409... |
| 409 |
addGroup = LISTGROUP_ARCHIVE;
|
409 |
addGroup = LISTGROUP_ARCHIVE;
|
| 410 |
|
410 |
|
| 411 |
item->Group = ListPackages->Groups[addGroup];
|
411 |
item->Group = ListPackages->Groups[addGroup];
|
| 412 |
}
|
412 |
}
|
| 413 |
|
413 |
|
| 414 |
CyString groupName = CyStringFromSystemString(item->Group->Header);
|
414 |
Utils::WString groupName = _WS(item->Group->Header);
|
| 415 |
if ( groupName.IsIn(" [") )
|
415 |
if ( groupName.contains(L" ["))
|
| 416 |
{
|
416 |
{
|
| 417 |
int enabled = groupName.GetToken(" [", 2, 2).GetToken("/", 1, 1).ToInt();
|
417 |
int enabled = groupName.token(L" [", 2).token(L"/", 1).toInt();
|
| 418 |
int total = groupName.GetToken(" [", 2, 2).GetToken("/", 2, 2).GetToken("]", 1, 1).ToInt() + 1;
|
418 |
int total = groupName.token(L" [", 2).token(L"/", 2).token(L"]", 1).toInt() + 1;
|
| 419 |
if ( p->IsEnabled() ) ++enabled;
|
419 |
if ( p->IsEnabled() ) ++enabled;
|
| 420 |
groupName = groupName.GetToken(" [", 1, 1) + " [" + CyString::Number(enabled) + "/" + CyString::Number(total) + "]";
|
420 |
groupName = groupName.token(L" [", 1) + L" [" + Utils::WString::Number(enabled) + L"/" + Utils::WString::Number(total) + L"]";
|
| 421 |
}
|
421 |
}
|
| 422 |
else
|
422 |
else
|
| 423 |
{
|
423 |
{
|
| 424 |
if ( p->IsEnabled() )
|
424 |
if ( p->IsEnabled() )
|
| 425 |
groupName = groupName + " [1/1]";
|
425 |
groupName = groupName + L" [1/1]";
|
| 426 |
else
|
426 |
else
|
| 427 |
groupName = groupName + " [0/1]";
|
427 |
groupName = groupName + L" [0/1]";
|
| 428 |
}
|
428 |
}
|
| 429 |
item->Group->Header = _US(groupName.ToString());
|
429 |
item->Group->Header = _US(groupName);
|
| 430 |
|
430 |
|
| 431 |
// get the icon
|
431 |
// get the icon
|
| 432 |
item->ImageIndex = -1;
|
432 |
item->ImageIndex = -1;
|
| 433 |
if ( p->icon() )
|
433 |
if ( p->icon() )
|
| 434 |
PluginManager::DisplayListIcon(p, ListPackages, item);
|
434 |
PluginManager::DisplayListIcon(p, ListPackages, item);
|
| Line 1720... |
Line 1720... |
| 1720 |
this->StartBackground(MGUI_BACKGROUND_CLOSEDIR, "");
|
1720 |
this->StartBackground(MGUI_BACKGROUND_CLOSEDIR, "");
|
| 1721 |
}
|
1721 |
}
|
| 1722 |
}
|
1722 |
}
|
| 1723 |
else if (ComboDir->SelectedIndex >= 0)
|
1723 |
else if (ComboDir->SelectedIndex >= 0)
|
| 1724 |
{
|
1724 |
{
|
| 1725 |
Utils::String dir = m_pDirList->get(ComboDir->SelectedIndex)->str;
|
1725 |
Utils::WString dir = m_pDirList->get(ComboDir->SelectedIndex)->str;
|
| 1726 |
if (!m_pPackages->isCurrentDir(dir))
|
1726 |
if (!m_pPackages->isCurrentDir(dir.toString()))
|
| 1727 |
{
|
1727 |
{
|
| 1728 |
this->Enabled = false;
|
1728 |
this->Enabled = false;
|
| 1729 |
ProgressBar->Show();
|
1729 |
ProgressBar->Show();
|
| 1730 |
this->CheckUnusedShared();
|
1730 |
this->CheckUnusedShared();
|
| 1731 |
this->StartBackground(MGUI_BACKGROUND_CHANGEDIR, _US(dir));
|
1731 |
this->StartBackground(MGUI_BACKGROUND_CHANGEDIR, _US(dir));
|
| Line 1781... |
Line 1781... |
| 1781 |
m_bDisplayMessage = false;
|
1781 |
m_bDisplayMessage = false;
|
| 1782 |
|
1782 |
|
| 1783 |
if ( m_iBackgroundTask == MGUI_BACKGROUND_CHANGEDIR || m_iBackgroundTask == MGUI_BACKGROUND_CLOSEDIR)
|
1783 |
if ( m_iBackgroundTask == MGUI_BACKGROUND_CHANGEDIR || m_iBackgroundTask == MGUI_BACKGROUND_CLOSEDIR)
|
| 1784 |
{
|
1784 |
{
|
| 1785 |
// switch the dir list
|
1785 |
// switch the dir list
|
| 1786 |
Utils::String selectedDir;
|
1786 |
Utils::WString selectedDir;
|
| 1787 |
if (ComboDir->SelectedIndex == ComboDir->Items->Count - 1)
|
1787 |
if (ComboDir->SelectedIndex == ComboDir->Items->Count - 1)
|
| 1788 |
selectedDir = _S(ComboDir->Text);
|
1788 |
selectedDir = _WS(ComboDir->Text);
|
| 1789 |
else if (ComboDir->SelectedIndex >= 0)
|
1789 |
else if (ComboDir->SelectedIndex >= 0)
|
| 1790 |
{
|
1790 |
{
|
| 1791 |
Utils::String dir = m_pDirList->get(ComboDir->SelectedIndex)->str;
|
1791 |
Utils::WString dir = m_pDirList->get(ComboDir->SelectedIndex)->str;
|
| 1792 |
selectedDir = dir;
|
1792 |
selectedDir = dir;
|
| 1793 |
if ( !dir.empty() )
|
1793 |
if ( !dir.empty() )
|
| 1794 |
{
|
1794 |
{
|
| 1795 |
if ( (m_iBackgroundTask == MGUI_BACKGROUND_CHANGEDIR) && (dir.countToken(" [")) )
|
1795 |
if ( (m_iBackgroundTask == MGUI_BACKGROUND_CHANGEDIR) && (dir.countToken(L" [")) )
|
| 1796 |
dir = dir.tokens(" [", 1);
|
1796 |
dir = dir.tokens(L" [", 1);
|
| 1797 |
if ( m_pDirList->findString(dir) )
|
1797 |
if ( m_pDirList->findString(dir) )
|
| 1798 |
{
|
1798 |
{
|
| 1799 |
Utils::String data = m_pDirList->findString(dir);
|
1799 |
Utils::WString data = m_pDirList->findString(dir);
|
| 1800 |
m_pDirList->remove(dir, false);
|
1800 |
m_pDirList->remove(dir, false);
|
| 1801 |
m_pDirList->pushFront(dir, data);
|
1801 |
m_pDirList->pushFront(dir, data);
|
| 1802 |
}
|
1802 |
}
|
| 1803 |
else
|
1803 |
else
|
| 1804 |
{
|
1804 |
{
|
| 1805 |
int lang = m_pPackages->getGameLanguage(dir);
|
1805 |
int lang = m_pPackages->getGameLanguage(dir.toString());
|
| 1806 |
if ( lang )
|
1806 |
if ( lang )
|
| 1807 |
m_pDirList->pushFront(dir, Utils::String::Number(lang) + "|" + m_pPackages->getGameName(dir));
|
1807 |
m_pDirList->pushFront(dir, Utils::WString::Number(lang) + L"|" + m_pPackages->getGameName(dir.toString()).toWString());
|
| 1808 |
else
|
1808 |
else
|
| 1809 |
m_pDirList->pushFront(dir, m_pPackages->getGameName(dir));
|
1809 |
m_pDirList->pushFront(dir, m_pPackages->getGameName(dir.toString()));
|
| 1810 |
}
|
1810 |
}
|
| 1811 |
}
|
1811 |
}
|
| 1812 |
}
|
1812 |
}
|
| 1813 |
|
1813 |
|
| 1814 |
this->UpdateDirList(selectedDir);
|
1814 |
this->UpdateDirList(selectedDir);
|