| 1 | cycrow | 1 | #include "../StdAfx.h"
 | 
        
           |  |  | 2 | #include "CustomiseShip.h"
 | 
        
           |  |  | 3 |   | 
        
           |  |  | 4 | #include "Form1.h"
 | 
        
           |  |  | 5 |   | 
        
           |  |  | 6 | namespace Creator {
 | 
        
           | 94 | cycrow | 7 | 	CustomiseShip::CustomiseShip(CXspFile *shipFile, Windows::Forms::Form ^mainForm, CPackages *p, ImageList ^imagesSmall, ImageList ^imagesLarge, CGameDirectories *gameDir)
 | 
        
           | 1 | cycrow | 8 | 	{
 | 
        
           | 94 | cycrow | 9 | 		InitializeComponent();
 | 
        
           | 1 | cycrow | 10 |   | 
        
           | 94 | cycrow | 11 | 		m_bUpdateing = false;
 | 
        
           |  |  | 12 | 		m_pPackages = p;
 | 
        
           |  |  | 13 | 		m_pMainForm = mainForm;
 | 
        
           |  |  | 14 | 		m_pShipFile = shipFile;
 | 
        
           |  |  | 15 | 		m_pShipData = new CShipData(m_pShipFile->GetShipData());
 | 
        
           |  |  | 16 | 		m_pWeapons = new CLinkList<SWeaponMasks>;
 | 
        
           | 170 | cycrow | 17 | 		m_pShipFile->readSceneModels(*_pModels);
 | 
        
           | 94 | cycrow | 18 |   | 
        
           | 191 | cycrow | 19 | 		this->Text = "Customise Ship: " + _US(m_pShipData->sID);
 | 
        
           | 94 | cycrow | 20 |   | 
        
           |  |  | 21 | 		m_pCustomiseInfo = gcnew CustomiseInfo(this, m_pShipData);
 | 
        
           |  |  | 22 | 		this->tabPage1->Controls->Add(m_pCustomiseInfo);
 | 
        
           |  |  | 23 | 		m_pCustomisePerformance = gcnew CustomisePerformance(m_pShipData);
 | 
        
           |  |  | 24 | 		this->tabPage2->Controls->Add(m_pCustomisePerformance);
 | 
        
           |  |  | 25 | 		m_pCustomiseWeapons1 = gcnew CustomiseWeapons1(this, m_pShipData);
 | 
        
           |  |  | 26 | 		this->tabPage3->Controls->Add(m_pCustomiseWeapons1);
 | 
        
           |  |  | 27 | 		m_pCustomiseModel = gcnew CustomiseModel(m_pShipData);
 | 
        
           |  |  | 28 | 		this->tabPage4->Controls->Add(m_pCustomiseModel);
 | 
        
           |  |  | 29 | 		m_pCustomiseWeapons = gcnew CustomiseWeapons(this, m_pWeapons, m_pShipData);
 | 
        
           |  |  | 30 | 		this->tabPage5->Controls->Add(m_pCustomiseWeapons);
 | 
        
           | 170 | cycrow | 31 | 		m_pCustomiseGuns = gcnew CustomiseGuns(this, imagesSmall, imagesLarge, m_pShipData, _pModels);
 | 
        
           | 94 | cycrow | 32 | 		this->tabPage7->Controls->Add(m_pCustomiseGuns);
 | 
        
           | 170 | cycrow | 33 | 		m_pCustomiseTurret = gcnew CustomiseTurret(this, imagesSmall, imagesLarge, _pModels, m_pShipData, m_pShipFile);
 | 
        
           | 94 | cycrow | 34 | 		this->tabPage6->Controls->Add(m_pCustomiseTurret);
 | 
        
           |  |  | 35 |   | 
        
           |  |  | 36 | 		_pGameDir = gameDir;
 | 
        
           |  |  | 37 |   | 
        
           |  |  | 38 | 		this->SetupControls();
 | 
        
           | 1 | cycrow | 39 | 	}
 | 
        
           |  |  | 40 |   | 
        
           | 103 | cycrow | 41 | 	void CustomiseShip::SwitchGame()
 | 
        
           |  |  | 42 | 	{
 | 
        
           |  |  | 43 | 		bool m_bUpdateding = true;
 | 
        
           |  |  | 44 |   | 
        
           |  |  | 45 | 		Utils::String dir = _S(this->ComboGame->Items[this->ComboGame->SelectedIndex]->ToString());
 | 
        
           |  |  | 46 | 		dir = dir.token("[", -1).token("]", 1);
 | 
        
           |  |  | 47 |   | 
        
           |  |  | 48 | 		_pGameDir->setSelectedDirectory(dir);
 | 
        
           |  |  | 49 |   | 
        
           |  |  | 50 | 		((Form1 ^)m_pMainForm)->LoadText(_pGameDir->selectedVFS());
 | 
        
           |  |  | 51 |   | 
        
           |  |  | 52 | 		// the ship info
 | 
        
           |  |  | 53 | 		m_pCustomiseInfo->UpdateInfo();
 | 
        
           |  |  | 54 | 		// the shield entries
 | 
        
           |  |  | 55 | 		m_pCustomiseWeapons1->UpdateShields();
 | 
        
           |  |  | 56 | 		// the cockpit entries
 | 
        
           |  |  | 57 | 		m_pCustomiseTurret->UpdateCockpits();
 | 
        
           |  |  | 58 |   | 
        
           |  |  | 59 | 		// notority preset
 | 
        
           |  |  | 60 | 		this->UpdateDisplay();
 | 
        
           |  |  | 61 |   | 
        
           |  |  | 62 | 		bool m_bUpdateing = false;
 | 
        
           |  |  | 63 | 	}
 | 
        
           |  |  | 64 |   | 
        
           |  |  | 65 | 	void CustomiseShip::LoadText(CVirtualFileSystem *vfs)
 | 
        
           |  |  | 66 | 	{
 | 
        
           |  |  | 67 | 		((Form1 ^)m_pMainForm)->LoadText(vfs);
 | 
        
           |  |  | 68 | 	}
 | 
        
           |  |  | 69 |   | 
        
           | 94 | cycrow | 70 | 	void CustomiseShip::SetupControls()
 | 
        
           | 1 | cycrow | 71 | 	{
 | 
        
           | 94 | cycrow | 72 | 		this->ComboGame->Enabled = true;
 | 
        
           |  |  | 73 | 		this->ComboGame->Items->Clear();
 | 
        
           | 1 | cycrow | 74 |   | 
        
           | 94 | cycrow | 75 | 		int selectedGame = 0;
 | 
        
           |  |  | 76 | 		int highestGame = 0;
 | 
        
           |  |  | 77 | 		for ( Utils::String dir = _pGameDir->first(); !dir.empty(); dir = _pGameDir->next() ) {
 | 
        
           |  |  | 78 | 			if ( _pGameDir->currentGame() > highestGame ) {
 | 
        
           |  |  | 79 | 				selectedGame = this->ComboGame->Items->Count;
 | 
        
           |  |  | 80 | 				highestGame = _pGameDir->currentGame();
 | 
        
           |  |  | 81 | 			}
 | 
        
           |  |  | 82 | 			this->ComboGame->Items->Add(_US(_pGameDir->currentName() + " [" + dir + "]"));
 | 
        
           |  |  | 83 | 		}
 | 
        
           |  |  | 84 |   | 
        
           | 103 | cycrow | 85 | 		//((Form1 ^)m_pMainForm)->LoadText(NULL);
 | 
        
           | 94 | cycrow | 86 |   | 
        
           |  |  | 87 | 		for ( int i = 1; i < m_pPackages->GetGameExe()->GetNumGames(); i++ )
 | 
        
           |  |  | 88 | 		{
 | 
        
           |  |  | 89 | 			SGameExe *gameExe = m_pPackages->GetGameExe()->GetGame(i);
 | 
        
           |  |  | 90 | 			if ( gameExe )
 | 
        
           |  |  | 91 | 			{
 | 
        
           | 191 | cycrow | 92 | 				//this->ComboGame->Items->Add(_US(gameExe->sName));
 | 
        
           |  |  | 93 | 				m_pCustomiseTurret->AddGameEntry(_US(gameExe->sName));
 | 
        
           |  |  | 94 | 				m_pCustomiseWeapons->AddGameEntry(_US(gameExe->sName));
 | 
        
           | 94 | cycrow | 95 | 			}
 | 
        
           |  |  | 96 | 			SWeaponMasks *m = m_pWeapons->push_back(new SWeaponMasks);
 | 
        
           |  |  | 97 | 			m->iGame = i;
 | 
        
           |  |  | 98 | 			m->iLaserMask = m_pShipFile->GetLaserMask(i, true);
 | 
        
           |  |  | 99 | 			m->iMissileMask = m_pShipFile->GetMissileMask(i, true);	
 | 
        
           |  |  | 100 | 		}
 | 
        
           |  |  | 101 |   | 
        
           |  |  | 102 | 		// find heighest game we have added
 | 
        
           |  |  | 103 | 		if ( !this->ComboGame->Items->Count ) {
 | 
        
           |  |  | 104 | 			this->ComboGame->Items->Add(":: None Found ::");	
 | 
        
           |  |  | 105 | 			this->ComboGame->Enabled = false;
 | 
        
           |  |  | 106 | 		}
 | 
        
           |  |  | 107 | 		this->ComboGame->SelectedIndex = selectedGame;
 | 
        
           |  |  | 108 |   | 
        
           |  |  | 109 | 		m_pCustomiseWeapons->SetupControlsEnd();
 | 
        
           |  |  | 110 | 		m_pCustomiseTurret->SetupControlsEnd();
 | 
        
           | 1 | cycrow | 111 | 	}
 | 
        
           |  |  | 112 |   | 
        
           |  |  | 113 |   | 
        
           | 94 | cycrow | 114 |   | 
        
           |  |  | 115 | 	CGameDirectories *CustomiseShip::gameDirectories()
 | 
        
           | 1 | cycrow | 116 | 	{
 | 
        
           | 94 | cycrow | 117 | 		return _pGameDir;
 | 
        
           | 1 | cycrow | 118 | 	}
 | 
        
           |  |  | 119 | }
 |