Subversion Repositories spk

Rev

Go to most recent revision | 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 <= m_iHighestGame; i++ ) {
                        for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() ) {
                                int game = gd->sGame.GetToken(" ", 1, 1).ToInt();
                                if ( i == game ) {
                                        this->comboBox1->Items->Add(SystemStringFromCyString(gd->sGame.GetToken(" ", 2)));
                                        break;
                                }
                        }
                }

                this->comboBox1->SelectedIndex = this->comboBox1->Items->Count - 1;
        }

        void SelectFilesystem::selectedGame()
        {
                this->comboBox2->Items->Clear();

                for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() ) {
                        int game = gd->sGame.GetToken(" ", 1, 1).ToInt();
                        if ( game == this->comboBox1->SelectedIndex + 1 ) {
                                this->comboBox2->Items->Add(SystemStringFromCyString(gd->sDir));
                        }
                }

                this->comboBox2->SelectedIndex = 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;
        }

        SGameDir *SelectFilesystem::gameDir()
        {
                for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() ) {
                        if ( gd->sDir.Compare(CyStringFromSystemString(this->comboBox2->Items[this->comboBox2->SelectedIndex]->ToString())) ) {
                                return gd;
                        }
                }

                return NULL;
        }

        String ^SelectFilesystem::gameMod()
        {
                if ( this->comboBox3->SelectedIndex == 0 ) return nullptr;
                return this->comboBox3->Items[this->comboBox3->SelectedIndex]->ToString();
        }
}