Rev 224 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#include "../stdafx.h"
#include "SelectFilesystem.h"
namespace Creator {
void SelectFilesystem::update()
{
for ( int i = 1; i <= _pGameDir->highestGame(); i++ ) {
for(Utils::WString dir = _pGameDir->first(); !dir.empty(); dir = _pGameDir->next()) {
if ( _pGameDir->currentGame() == i ) {
this->comboBox1->Items->Add(_US(_pGameDir->currentName()));
break;
}
}
}
this->comboBox1->SelectedIndex = this->comboBox1->Items->Count - 1;
}
void SelectFilesystem::selectedGame()
{
this->comboBox2->Items->Clear();
// find the game to match the currently selected one
int iCurrentGame = this->comboBox1->SelectedIndex + 1;
Utils::WString gameName = _WS(this->comboBox1->SelectedItem->ToString());
for ( Utils::WString dir = _pGameDir->first(); !dir.empty(); dir = _pGameDir->next() ) {
if ( gameName.Compare(_pGameDir->currentName()) ) {
iCurrentGame = _pGameDir->currentGame();
break;
}
}
for (Utils::WString dir = _pGameDir->first(iCurrentGame); !dir.empty(); dir = _pGameDir->next(iCurrentGame) ) {
this->comboBox2->Items->Add(_US(dir));
}
this->comboBox2->SelectedIndex = (!this->comboBox2->Items->Count) ? -1 : 0;
}
void SelectFilesystem::selectedDir()
{
this->comboBox3->Items->Clear();
this->comboBox3->Items->Add(":: No Mod ::");
String ^dir = this->comboBox2->Items[this->comboBox2->SelectedIndex]->ToString();
dir += "\\mods";
if ( System::IO::Directory::Exists(dir) ) {
cli::array<String ^> ^dirList = System::IO::Directory::GetFiles(dir, "*.cat");
for ( int i = 0; i < dirList->Length; i++ ) {
this->comboBox3->Items->Add(System::IO::FileInfo(dirList[i]).Name->Replace(System::IO::FileInfo(dirList[i]).Extension, ""));
}
}
this->comboBox3->SelectedIndex = 0;
}
Utils::WString SelectFilesystem::gameDir()
{
for ( Utils::WString dir = _pGameDir->first(); !dir.empty(); dir = _pGameDir->next() ) {
if ( dir.Compare(_WS(this->comboBox2->Items[this->comboBox2->SelectedIndex]->ToString())) ) {
_pGameDir->setSelectedDirectory(dir);
return dir;
}
}
return Utils::WString::Null();
}
String ^SelectFilesystem::gameMod()
{
if ( this->comboBox3->SelectedIndex == 0 ) return nullptr;
return this->comboBox3->Items[this->comboBox3->SelectedIndex]->ToString();
}
}