| 36 | cycrow | 1 | #include "../stdafx.h"
 | 
        
           |  |  | 2 | #include "SelectFilesystem.h"
 | 
        
           |  |  | 3 |   | 
        
           |  |  | 4 | namespace Creator {
 | 
        
           |  |  | 5 |   | 
        
           |  |  | 6 | 	void SelectFilesystem::update()
 | 
        
           |  |  | 7 | 	{
 | 
        
           |  |  | 8 | 		for ( int i = 1; i <= m_iHighestGame; i++ ) {
 | 
        
           |  |  | 9 | 			for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() ) {
 | 
        
           | 68 | cycrow | 10 | 				if ( i == gd->iGame ) {
 | 
        
           |  |  | 11 | 					this->comboBox1->Items->Add(_US(gd->name));
 | 
        
           | 36 | cycrow | 12 | 					break;
 | 
        
           |  |  | 13 | 				}
 | 
        
           |  |  | 14 | 			}
 | 
        
           |  |  | 15 | 		}
 | 
        
           |  |  | 16 |   | 
        
           |  |  | 17 | 		this->comboBox1->SelectedIndex = this->comboBox1->Items->Count - 1;
 | 
        
           |  |  | 18 | 	}
 | 
        
           |  |  | 19 |   | 
        
           |  |  | 20 | 	void SelectFilesystem::selectedGame()
 | 
        
           |  |  | 21 | 	{
 | 
        
           |  |  | 22 | 		this->comboBox2->Items->Clear();
 | 
        
           |  |  | 23 |   | 
        
           | 68 | cycrow | 24 | 		// find the game to match the currently selected one
 | 
        
           |  |  | 25 | 		int iCurrentGame = this->comboBox1->SelectedIndex + 1;
 | 
        
           |  |  | 26 | 		Utils::String gameName = _S(this->comboBox1->SelectedItem->ToString());
 | 
        
           | 36 | cycrow | 27 | 		for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() ) {
 | 
        
           | 68 | cycrow | 28 | 			if ( gameName.Compare(gd->name) ) {
 | 
        
           |  |  | 29 | 				iCurrentGame = gd->iGame;
 | 
        
           |  |  | 30 | 				break;
 | 
        
           | 36 | cycrow | 31 | 			}
 | 
        
           |  |  | 32 | 		}
 | 
        
           |  |  | 33 |   | 
        
           | 68 | cycrow | 34 | 		for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() ) {
 | 
        
           |  |  | 35 | 			if ( gd->iGame == iCurrentGame ) {
 | 
        
           |  |  | 36 | 				this->comboBox2->Items->Add(_US(gd->dir));
 | 
        
           |  |  | 37 | 			}
 | 
        
           |  |  | 38 | 		}
 | 
        
           |  |  | 39 |   | 
        
           |  |  | 40 | 		this->comboBox2->SelectedIndex = (!this->comboBox2->Items->Count) ? -1 : 0;
 | 
        
           | 36 | cycrow | 41 | 	}
 | 
        
           |  |  | 42 |   | 
        
           |  |  | 43 | 	void SelectFilesystem::selectedDir()
 | 
        
           |  |  | 44 | 	{
 | 
        
           |  |  | 45 | 		this->comboBox3->Items->Clear();
 | 
        
           |  |  | 46 |   | 
        
           |  |  | 47 | 		this->comboBox3->Items->Add(":: No Mod ::");
 | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 | 		String ^dir = this->comboBox2->Items[this->comboBox2->SelectedIndex]->ToString();
 | 
        
           |  |  | 50 | 		dir += "\\mods";
 | 
        
           |  |  | 51 | 		if ( System::IO::Directory::Exists(dir) ) {
 | 
        
           |  |  | 52 | 			cli::array<String ^> ^dirList = System::IO::Directory::GetFiles(dir, "*.cat");
 | 
        
           |  |  | 53 | 			for ( int i = 0; i < dirList->Length; i++ ) {
 | 
        
           |  |  | 54 | 				this->comboBox3->Items->Add(System::IO::FileInfo(dirList[i]).Name->Replace(System::IO::FileInfo(dirList[i]).Extension, ""));
 | 
        
           |  |  | 55 | 			}
 | 
        
           |  |  | 56 | 		}
 | 
        
           |  |  | 57 |   | 
        
           |  |  | 58 | 		this->comboBox3->SelectedIndex = 0;
 | 
        
           |  |  | 59 | 	}
 | 
        
           |  |  | 60 |   | 
        
           |  |  | 61 | 	SGameDir *SelectFilesystem::gameDir()
 | 
        
           |  |  | 62 | 	{
 | 
        
           |  |  | 63 | 		for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() ) {
 | 
        
           | 68 | cycrow | 64 | 			if ( gd->dir.Compare(_S(this->comboBox2->Items[this->comboBox2->SelectedIndex]->ToString())) ) {
 | 
        
           | 36 | cycrow | 65 | 				return gd;
 | 
        
           |  |  | 66 | 			}
 | 
        
           |  |  | 67 | 		}
 | 
        
           |  |  | 68 |   | 
        
           |  |  | 69 | 		return NULL;
 | 
        
           |  |  | 70 | 	}
 | 
        
           |  |  | 71 |   | 
        
           |  |  | 72 | 	String ^SelectFilesystem::gameMod()
 | 
        
           |  |  | 73 | 	{
 | 
        
           |  |  | 74 | 		if ( this->comboBox3->SelectedIndex == 0 ) return nullptr;
 | 
        
           |  |  | 75 | 		return this->comboBox3->Items[this->comboBox3->SelectedIndex]->ToString();
 | 
        
           |  |  | 76 | 	}
 | 
        
           |  |  | 77 | }
 |