Subversion Repositories spk

Rev

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

Rev Author Line No. Line
1 cycrow 1
#pragma once
2
 
3
using namespace System;
4
using namespace System::ComponentModel;
5
using namespace System::Collections;
6
using namespace System::Windows::Forms;
7
using namespace System::Data;
8
using namespace System::Drawing;
9
 
10
#include "CustomiseTurret.h"
11
#include "CustomiseGuns.h"
12
#include "CustomiseWeapons.h"
13
#include "CustomiseWeapons1.h"
14
#include "CustomiseModel.h"
15
#include "CustomisePerformance.h"
16
#include "CustomiseInfo.h"
17
 
18
namespace Creator {
19
 
20
	/// <summary>
21
	/// Summary for CustomiseShip
22
	///
23
	/// WARNING: If you change the name of this class, you will need to change the
24
	///          'Resource File Name' property for the managed resource compiler tool
25
	///          associated with all .resx files this class depends on.  Otherwise
26
	///          the designers will not be able to interact properly with localized
27
	///          resources associated with this form.
28
	/// </summary>
29
	public ref class CustomiseShip : public System::Windows::Forms::Form
30
	{
31
	public:
32
		CustomiseShip(CXspFile *shipFile, Windows::Forms::Form ^mainForm, CPackages *p, ImageList ^imagesSmall, ImageList ^imagesLarge, int highestGame)
33
		{
34
			InitializeComponent();
35
 
36
			m_bUpdateing = false;
37
			m_pPackages = p;
38
			m_pMainForm = mainForm;
39
			m_pShipFile = shipFile;
40
			m_pShipData = new CShipData(m_pShipFile->GetShipData());
41
			m_pWeapons = new CLinkList<SWeaponMasks>;
42
			m_pModels = m_pShipFile->ReadSceneModels();
43
 
44
			this->Text = "Customise Ship: " + SystemStringFromCyString(m_pShipData->sID);
45
 
46
			m_pCustomiseInfo = gcnew CustomiseInfo(this, m_pShipData);
47
			this->tabPage1->Controls->Add(m_pCustomiseInfo);
48
			m_pCustomisePerformance = gcnew CustomisePerformance(m_pShipData);
49
			this->tabPage2->Controls->Add(m_pCustomisePerformance);
50
			m_pCustomiseWeapons1 = gcnew CustomiseWeapons1(this, m_pShipData);
51
			this->tabPage3->Controls->Add(m_pCustomiseWeapons1);
52
			m_pCustomiseModel = gcnew CustomiseModel(m_pShipData);
53
			this->tabPage4->Controls->Add(m_pCustomiseModel);
54
			m_pCustomiseWeapons = gcnew CustomiseWeapons(this, m_pWeapons, m_pShipData);
55
			this->tabPage5->Controls->Add(m_pCustomiseWeapons);
56
			m_pCustomiseGuns = gcnew CustomiseGuns(this, imagesSmall, imagesLarge, m_pShipData, m_pModels);
57
			this->tabPage7->Controls->Add(m_pCustomiseGuns);
58
			m_pCustomiseTurret = gcnew CustomiseTurret(this, imagesSmall, imagesLarge, m_pModels, m_pShipData, m_pShipFile);
59
			this->tabPage6->Controls->Add(m_pCustomiseTurret);
60
 
61
			m_iHighestGame = highestGame;
62
 
63
			this->SetupControls();
64
		}
65
 
66
		String ^FindText(int game, int page, int id);
67
		CyStringList *GetLasers(int game);
68
		CyStringList *GetShields();
69
		CyStringList *GetMissiles(int game);
70
		CyStringList *GetCockpits();
71
 
72
		String ^GetPosition(int pos)
73
		{
74
			switch ( pos )
75
			{
76
				case 0:
77
					return "Cockpit";	
78
				case 1: 
79
					return "Front";
80
				case 2:
81
					return "Rear";
82
				case 3:
83
					return "Left";
84
				case 4:
85
					return "Right";
86
				case 5:
87
					return "Top";
88
				case 6:
89
					return "Bottom";
90
			}
91
			return "";
92
		}
93
 
94
		void UpdateGunTurrets() { m_pCustomiseGuns->UpdateGunTurrets(); }
95
 
96
		void SetupControls()
97
		{
98
			this->ComboGame->Items->Clear();
99
			for ( int i = 1; i < m_pPackages->GetGameExe()->GetNumGames(); i++ )
100
			{
101
				SGameExe *gameExe = m_pPackages->GetGameExe()->GetGame(i);
102
				if ( gameExe )
103
				{
104
					this->ComboGame->Items->Add(SystemStringFromCyString(gameExe->sName));
105
					m_pCustomiseTurret->AddGameEntry(SystemStringFromCyString(gameExe->sName));
106
					m_pCustomiseWeapons->AddGameEntry(SystemStringFromCyString(gameExe->sName));
107
				}
108
				SWeaponMasks *m = m_pWeapons->push_back(new SWeaponMasks);
109
				m->iGame = i;
110
				m->iLaserMask = m_pShipFile->GetLaserMask(i, true);
111
				m->iMissileMask = m_pShipFile->GetMissileMask(i, true);	
112
			}
113
 
114
			// find heighest game we have added
115
			if ( m_iHighestGame > 0 ) 
116
				this->ComboGame->SelectedIndex = m_iHighestGame - 1;
117
			else
118
				this->ComboGame->SelectedIndex = this->ComboGame->Items->Count - 1;
119
 
120
			m_pCustomiseWeapons->SetupControlsEnd();
121
			m_pCustomiseTurret->SetupControlsEnd();
122
		}
123
 
124
		String ^AddText(String ^text, String ^def)
125
		{
126
			if ( !text || !text->Length )
127
				return def;
128
			return text;
129
		}
130
 
131
 
132
		void SwitchGame()
133
		{
134
			bool m_bUpdateding = true;
135
			int game = this->ComboGame->SelectedIndex + 1;
136
 
137
			// the ship info
138
			m_pCustomiseInfo->UpdateInfo();
139
			// the shield entries
140
			m_pCustomiseWeapons1->UpdateShields();
141
			// the cockpit entries
142
			m_pCustomiseTurret->UpdateCockpits();
143
 
144
			// notority preset
145
			this->UpdateDisplay();
146
 
147
			bool m_bUpdateing = false;
148
		}
149
 
150
		void UpdateDisplay()
151
		{
152
			m_pCustomiseInfo->UpdateDisplay();
153
			m_pCustomisePerformance->UpdateDisplay();
154
			m_pCustomiseWeapons1->UpdateDisplay();
155
			m_pCustomiseModel->UpdateDisplay();
156
			m_pCustomiseTurret->UpdateDisplay();
157
		}
158
 
159
	protected:
160
		~CustomiseShip()
161
		{
162
			if (components)
163
			{
164
				delete components;
165
			}
166
			delete m_pShipData;
167
			if ( m_pWeapons )
168
				m_pWeapons->MemoryClear();
169
			delete m_pWeapons;
170
			if ( m_pModels )
171
				delete m_pModels;
172
		}
173
 
174
		CustomiseInfo			^m_pCustomiseInfo;
175
		CustomisePerformance	^m_pCustomisePerformance;
176
		CustomiseWeapons1		^m_pCustomiseWeapons1;
177
		CustomiseModel			^m_pCustomiseModel;
178
		CustomiseWeapons		^m_pCustomiseWeapons;
179
		CustomiseGuns			^m_pCustomiseGuns;
180
		CustomiseTurret			^m_pCustomiseTurret;
181
		CLinkList<SWeaponMasks> *m_pWeapons;
182
		CPackages				*m_pPackages;
183
		bool					 m_bUpdateing;
184
		Windows::Forms::Form	^m_pMainForm;
185
		CXspFile				*m_pShipFile;
186
		CShipData				*m_pShipData;
187
		CyStringList			*m_pModels;
188
		int						 m_iHighestGame;
189
 
190
		/// <summary>
191
		/// Clean up any resources being used.
192
		/// </summary>
193
		private: System::Windows::Forms::Panel^  panel1;
194
		private: System::Windows::Forms::Label^  label1;
195
		private: System::Windows::Forms::ComboBox^  ComboGame;
196
		private: System::Windows::Forms::Panel^  panel2;
197
		private: System::Windows::Forms::Button^  button2;
198
		private: System::Windows::Forms::Button^  ButSave;
199
private: System::Windows::Forms::ListView^  listView2;
200
private: System::Windows::Forms::ListView^  listView1;
201
private: System::Windows::Forms::CheckBox^  CheckWeaponDefaultCockpit;
202
private: System::Windows::Forms::TabPage^  tabPage7;
203
private: System::Windows::Forms::TabPage^  tabPage6;
204
private: System::Windows::Forms::TabPage^  tabPage5;
205
private: System::Windows::Forms::TabPage^  tabPage4;
206
private: System::Windows::Forms::TabPage^  tabPage3;
207
private: System::Windows::Forms::TabPage^  tabPage2;
208
private: System::Windows::Forms::TabControl^  tabControl1;
209
 
210
private: System::Windows::Forms::TabPage^  tabPage1;
211
 
212
private: System::ComponentModel::IContainer^  components;
213
		 /// <summary>
214
		/// Required designer variable.
215
		/// </summary>
216
 
217
#pragma region Windows Form Designer generated code
218
		/// <summary>
219
		/// Required method for Designer support - do not modify
220
		/// the contents of this method with the code editor.
221
		/// </summary>
222
		void InitializeComponent(void)
223
		{
224
			this->panel1 = (gcnew System::Windows::Forms::Panel());
225
			this->ComboGame = (gcnew System::Windows::Forms::ComboBox());
226
			this->label1 = (gcnew System::Windows::Forms::Label());
227
			this->panel2 = (gcnew System::Windows::Forms::Panel());
228
			this->button2 = (gcnew System::Windows::Forms::Button());
229
			this->ButSave = (gcnew System::Windows::Forms::Button());
230
			this->tabPage7 = (gcnew System::Windows::Forms::TabPage());
231
			this->tabPage6 = (gcnew System::Windows::Forms::TabPage());
232
			this->tabPage5 = (gcnew System::Windows::Forms::TabPage());
233
			this->tabPage4 = (gcnew System::Windows::Forms::TabPage());
234
			this->tabPage3 = (gcnew System::Windows::Forms::TabPage());
235
			this->tabPage2 = (gcnew System::Windows::Forms::TabPage());
236
			this->tabControl1 = (gcnew System::Windows::Forms::TabControl());
237
			this->tabPage1 = (gcnew System::Windows::Forms::TabPage());
238
			this->panel1->SuspendLayout();
239
			this->panel2->SuspendLayout();
240
			this->tabControl1->SuspendLayout();
241
			this->SuspendLayout();
242
			// 
243
			// panel1
244
			// 
245
			this->panel1->Controls->Add(this->ComboGame);
246
			this->panel1->Controls->Add(this->label1);
247
			this->panel1->Dock = System::Windows::Forms::DockStyle::Top;
248
			this->panel1->Location = System::Drawing::Point(10, 10);
249
			this->panel1->Name = L"panel1";
250
			this->panel1->Padding = System::Windows::Forms::Padding(5);
251
			this->panel1->Size = System::Drawing::Size(548, 32);
252
			this->panel1->TabIndex = 0;
253
			// 
254
			// ComboGame
255
			// 
256
			this->ComboGame->Dock = System::Windows::Forms::DockStyle::Fill;
257
			this->ComboGame->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
258
			this->ComboGame->FormattingEnabled = true;
259
			this->ComboGame->Location = System::Drawing::Point(155, 5);
260
			this->ComboGame->Name = L"ComboGame";
261
			this->ComboGame->Size = System::Drawing::Size(388, 21);
262
			this->ComboGame->TabIndex = 1;
263
			this->ComboGame->SelectedIndexChanged += gcnew System::EventHandler(this, &CustomiseShip::ComboGame_SelectedIndexChanged);
264
			// 
265
			// label1
266
			// 
267
			this->label1->Dock = System::Windows::Forms::DockStyle::Left;
268
			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
269
				static_cast<System::Byte>(0)));
270
			this->label1->Location = System::Drawing::Point(5, 5);
271
			this->label1->Name = L"label1";
272
			this->label1->Size = System::Drawing::Size(150, 22);
273
			this->label1->TabIndex = 0;
274
			this->label1->Text = L"Primary Game";
275
			this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
276
			// 
277
			// panel2
278
			// 
279
			this->panel2->Controls->Add(this->button2);
280
			this->panel2->Controls->Add(this->ButSave);
281
			this->panel2->Dock = System::Windows::Forms::DockStyle::Bottom;
282
			this->panel2->Location = System::Drawing::Point(10, 553);
283
			this->panel2->Name = L"panel2";
284
			this->panel2->Padding = System::Windows::Forms::Padding(8);
285
			this->panel2->Size = System::Drawing::Size(548, 46);
286
			this->panel2->TabIndex = 1;
287
			// 
288
			// button2
289
			// 
290
			this->button2->DialogResult = System::Windows::Forms::DialogResult::Cancel;
291
			this->button2->Dock = System::Windows::Forms::DockStyle::Right;
292
			this->button2->Location = System::Drawing::Point(331, 8);
293
			this->button2->Name = L"button2";
294
			this->button2->Size = System::Drawing::Size(99, 30);
295
			this->button2->TabIndex = 1;
296
			this->button2->Text = L"Cancel";
297
			this->button2->UseVisualStyleBackColor = true;
298
			// 
299
			// ButSave
300
			// 
301
			this->ButSave->DialogResult = System::Windows::Forms::DialogResult::OK;
302
			this->ButSave->Dock = System::Windows::Forms::DockStyle::Right;
303
			this->ButSave->Location = System::Drawing::Point(430, 8);
304
			this->ButSave->Name = L"ButSave";
305
			this->ButSave->Size = System::Drawing::Size(110, 30);
306
			this->ButSave->TabIndex = 0;
307
			this->ButSave->Text = L"Save";
308
			this->ButSave->UseVisualStyleBackColor = true;
309
			this->ButSave->Click += gcnew System::EventHandler(this, &CustomiseShip::ButSave_Click);
310
			// 
311
			// tabPage7
312
			// 
313
			this->tabPage7->Location = System::Drawing::Point(4, 22);
314
			this->tabPage7->Name = L"tabPage7";
315
			this->tabPage7->Padding = System::Windows::Forms::Padding(10);
316
			this->tabPage7->Size = System::Drawing::Size(540, 485);
317
			this->tabPage7->TabIndex = 6;
318
			this->tabPage7->Text = L"Guns";
319
			this->tabPage7->UseVisualStyleBackColor = true;
320
			// 
321
			// tabPage6
322
			// 
323
			this->tabPage6->Location = System::Drawing::Point(4, 22);
324
			this->tabPage6->Margin = System::Windows::Forms::Padding(10);
325
			this->tabPage6->Name = L"tabPage6";
326
			this->tabPage6->Padding = System::Windows::Forms::Padding(3);
327
			this->tabPage6->Size = System::Drawing::Size(540, 485);
328
			this->tabPage6->TabIndex = 5;
329
			this->tabPage6->Text = L"Turrets";
330
			this->tabPage6->UseVisualStyleBackColor = true;
331
			// 
332
			// tabPage5
333
			// 
334
			this->tabPage5->Location = System::Drawing::Point(4, 22);
335
			this->tabPage5->Name = L"tabPage5";
336
			this->tabPage5->Padding = System::Windows::Forms::Padding(10);
337
			this->tabPage5->Size = System::Drawing::Size(540, 485);
338
			this->tabPage5->TabIndex = 4;
339
			this->tabPage5->Text = L"Lasers/Missiles";
340
			this->tabPage5->UseVisualStyleBackColor = true;
341
			// 
342
			// tabPage4
343
			// 
344
			this->tabPage4->Location = System::Drawing::Point(4, 22);
345
			this->tabPage4->Name = L"tabPage4";
346
			this->tabPage4->Padding = System::Windows::Forms::Padding(3);
347
			this->tabPage4->Size = System::Drawing::Size(540, 485);
348
			this->tabPage4->TabIndex = 3;
349
			this->tabPage4->Text = L"Model";
350
			this->tabPage4->UseVisualStyleBackColor = true;
351
			// 
352
			// tabPage3
353
			// 
354
			this->tabPage3->Location = System::Drawing::Point(4, 22);
355
			this->tabPage3->Name = L"tabPage3";
356
			this->tabPage3->Padding = System::Windows::Forms::Padding(3);
357
			this->tabPage3->Size = System::Drawing::Size(540, 485);
358
			this->tabPage3->TabIndex = 2;
359
			this->tabPage3->Text = L"Weapons";
360
			this->tabPage3->UseVisualStyleBackColor = true;
361
			// 
362
			// tabPage2
363
			// 
364
			this->tabPage2->Location = System::Drawing::Point(4, 22);
365
			this->tabPage2->Name = L"tabPage2";
366
			this->tabPage2->Padding = System::Windows::Forms::Padding(3);
367
			this->tabPage2->Size = System::Drawing::Size(540, 485);
368
			this->tabPage2->TabIndex = 1;
369
			this->tabPage2->Text = L"Performance";
370
			this->tabPage2->UseVisualStyleBackColor = true;
371
			// 
372
			// tabControl1
373
			// 
374
			this->tabControl1->Controls->Add(this->tabPage1);
375
			this->tabControl1->Controls->Add(this->tabPage2);
376
			this->tabControl1->Controls->Add(this->tabPage3);
377
			this->tabControl1->Controls->Add(this->tabPage4);
378
			this->tabControl1->Controls->Add(this->tabPage5);
379
			this->tabControl1->Controls->Add(this->tabPage6);
380
			this->tabControl1->Controls->Add(this->tabPage7);
381
			this->tabControl1->Dock = System::Windows::Forms::DockStyle::Fill;
382
			this->tabControl1->Location = System::Drawing::Point(10, 42);
383
			this->tabControl1->Name = L"tabControl1";
384
			this->tabControl1->SelectedIndex = 0;
385
			this->tabControl1->Size = System::Drawing::Size(548, 511);
386
			this->tabControl1->TabIndex = 2;
387
			// 
388
			// tabPage1
389
			// 
390
			this->tabPage1->Location = System::Drawing::Point(4, 22);
391
			this->tabPage1->Name = L"tabPage1";
392
			this->tabPage1->Padding = System::Windows::Forms::Padding(3);
393
			this->tabPage1->Size = System::Drawing::Size(540, 485);
394
			this->tabPage1->TabIndex = 0;
395
			this->tabPage1->Text = L"Ship Info";
396
			this->tabPage1->UseVisualStyleBackColor = true;
397
			// 
398
			// CustomiseShip
399
			// 
400
			this->AcceptButton = this->ButSave;
401
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
402
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
403
			this->CancelButton = this->button2;
404
			this->ClientSize = System::Drawing::Size(568, 609);
405
			this->Controls->Add(this->tabControl1);
406
			this->Controls->Add(this->panel2);
407
			this->Controls->Add(this->panel1);
408
			this->Name = L"CustomiseShip";
409
			this->Padding = System::Windows::Forms::Padding(10);
410
			this->ShowInTaskbar = false;
411
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
412
			this->Text = L"Customise Ship";
413
			this->panel1->ResumeLayout(false);
414
			this->panel2->ResumeLayout(false);
415
			this->tabControl1->ResumeLayout(false);
416
			this->ResumeLayout(false);
417
 
418
		}
419
#pragma endregion
420
	private: System::Void ComboGame_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
421
				 this->SwitchGame();
422
			 }
423
private: System::Void ButSave_Click(System::Object^  sender, System::EventArgs^  e) {
424
			 m_pShipFile->SetCreatedShipData(m_pShipData);
425
			 for ( SWeaponMasks *m = m_pWeapons->First(); m; m = m_pWeapons->Next() )
426
			 {
427
				 if ( m->iLaserMask > -1 )
428
					 m_pShipFile->SetLaserMask(m->iGame, m->iLaserMask);
429
				 if ( m->iMissileMask > -1 )
430
					 m_pShipFile->SetMissileMask(m->iGame, m->iMissileMask);
431
			 }
432
		 }
433
};
434
}