Subversion Repositories spk

Rev

Rev 224 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
36 cycrow 1
#include "../stdafx.h"
2
#include "SelectFilesystem.h"
3
 
4
namespace Creator {
5
 
6
	void SelectFilesystem::update()
7
	{
94 cycrow 8
		for ( int i = 1; i <= _pGameDir->highestGame(); i++ ) {
197 cycrow 9
			for(Utils::WString dir = _pGameDir->first(); !dir.empty(); dir = _pGameDir->next()) {
94 cycrow 10
				if ( _pGameDir->currentGame() == i ) {
11
					this->comboBox1->Items->Add(_US(_pGameDir->currentName()));
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;
197 cycrow 26
		Utils::WString gameName = _WS(this->comboBox1->SelectedItem->ToString());
27
		for ( Utils::WString dir = _pGameDir->first(); !dir.empty(); dir = _pGameDir->next() ) {
94 cycrow 28
			if ( gameName.Compare(_pGameDir->currentName()) ) {
29
				iCurrentGame = _pGameDir->currentGame();
68 cycrow 30
				break;
36 cycrow 31
			}
32
		}
33
 
197 cycrow 34
		for (Utils::WString dir = _pGameDir->first(iCurrentGame); !dir.empty(); dir = _pGameDir->next(iCurrentGame) ) {
94 cycrow 35
			this->comboBox2->Items->Add(_US(dir));
68 cycrow 36
		}
37
 
38
		this->comboBox2->SelectedIndex = (!this->comboBox2->Items->Count) ? -1 : 0;
36 cycrow 39
	}
40
 
41
	void SelectFilesystem::selectedDir()
42
	{
43
		this->comboBox3->Items->Clear();
44
 
45
		this->comboBox3->Items->Add(":: No Mod ::");
46
 
47
		String ^dir = this->comboBox2->Items[this->comboBox2->SelectedIndex]->ToString();
48
		dir += "\\mods";
49
		if ( System::IO::Directory::Exists(dir) ) {
50
			cli::array<String ^> ^dirList = System::IO::Directory::GetFiles(dir, "*.cat");
51
			for ( int i = 0; i < dirList->Length; i++ ) {
52
				this->comboBox3->Items->Add(System::IO::FileInfo(dirList[i]).Name->Replace(System::IO::FileInfo(dirList[i]).Extension, ""));
53
			}
54
		}
55
 
56
		this->comboBox3->SelectedIndex = 0;
57
	}
58
 
197 cycrow 59
	Utils::WString SelectFilesystem::gameDir()
36 cycrow 60
	{
197 cycrow 61
		for ( Utils::WString dir = _pGameDir->first(); !dir.empty(); dir = _pGameDir->next() ) {
224 cycrow 62
			if ( dir.Compare(_WS(this->comboBox2->Items[this->comboBox2->SelectedIndex]->ToString())) ) {
94 cycrow 63
				_pGameDir->setSelectedDirectory(dir);
64
				return dir;
36 cycrow 65
			}
66
		}
67
 
228 cycrow 68
		return Utils::WString::Null();
36 cycrow 69
	}
70
 
71
	String ^SelectFilesystem::gameMod()
72
	{
73
		if ( this->comboBox3->SelectedIndex == 0 ) return nullptr;
74
		return this->comboBox3->Items[this->comboBox3->SelectedIndex]->ToString();
75
	}
76
}