Subversion Repositories spk

Rev

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

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