Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
#include "CustomiseTurret.h"
#include "CustomiseGuns.h"
#include "CustomiseWeapons.h"
#include "CustomiseWeapons1.h"
#include "CustomiseModel.h"
#include "CustomisePerformance.h"
#include "CustomiseInfo.h"
namespace Creator {
/// <summary>
/// Summary for CustomiseShip
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class CustomiseShip : public System::Windows::Forms::Form
{
public:
CustomiseShip(CXspFile *shipFile, Windows::Forms::Form ^mainForm, CPackages *p, ImageList ^imagesSmall, ImageList ^imagesLarge, int highestGame)
{
InitializeComponent();
m_bUpdateing = false;
m_pPackages = p;
m_pMainForm = mainForm;
m_pShipFile = shipFile;
m_pShipData = new CShipData(m_pShipFile->GetShipData());
m_pWeapons = new CLinkList<SWeaponMasks>;
m_pModels = m_pShipFile->ReadSceneModels();
this->Text = "Customise Ship: " + SystemStringFromCyString(m_pShipData->sID);
m_pCustomiseInfo = gcnew CustomiseInfo(this, m_pShipData);
this->tabPage1->Controls->Add(m_pCustomiseInfo);
m_pCustomisePerformance = gcnew CustomisePerformance(m_pShipData);
this->tabPage2->Controls->Add(m_pCustomisePerformance);
m_pCustomiseWeapons1 = gcnew CustomiseWeapons1(this, m_pShipData);
this->tabPage3->Controls->Add(m_pCustomiseWeapons1);
m_pCustomiseModel = gcnew CustomiseModel(m_pShipData);
this->tabPage4->Controls->Add(m_pCustomiseModel);
m_pCustomiseWeapons = gcnew CustomiseWeapons(this, m_pWeapons, m_pShipData);
this->tabPage5->Controls->Add(m_pCustomiseWeapons);
m_pCustomiseGuns = gcnew CustomiseGuns(this, imagesSmall, imagesLarge, m_pShipData, m_pModels);
this->tabPage7->Controls->Add(m_pCustomiseGuns);
m_pCustomiseTurret = gcnew CustomiseTurret(this, imagesSmall, imagesLarge, m_pModels, m_pShipData, m_pShipFile);
this->tabPage6->Controls->Add(m_pCustomiseTurret);
m_iHighestGame = highestGame;
this->SetupControls();
}
String ^FindText(int game, int page, int id);
CyStringList *GetLasers(int game);
CyStringList *GetShields();
CyStringList *GetMissiles(int game);
CyStringList *GetCockpits();
String ^GetPosition(int pos)
{
switch ( pos )
{
case 0:
return "Cockpit";
case 1:
return "Front";
case 2:
return "Rear";
case 3:
return "Left";
case 4:
return "Right";
case 5:
return "Top";
case 6:
return "Bottom";
}
return "";
}
void UpdateGunTurrets() { m_pCustomiseGuns->UpdateGunTurrets(); }
void SetupControls()
{
this->ComboGame->Items->Clear();
for ( int i = 1; i < m_pPackages->GetGameExe()->GetNumGames(); i++ )
{
SGameExe *gameExe = m_pPackages->GetGameExe()->GetGame(i);
if ( gameExe )
{
this->ComboGame->Items->Add(SystemStringFromCyString(gameExe->sName));
m_pCustomiseTurret->AddGameEntry(SystemStringFromCyString(gameExe->sName));
m_pCustomiseWeapons->AddGameEntry(SystemStringFromCyString(gameExe->sName));
}
SWeaponMasks *m = m_pWeapons->push_back(new SWeaponMasks);
m->iGame = i;
m->iLaserMask = m_pShipFile->GetLaserMask(i, true);
m->iMissileMask = m_pShipFile->GetMissileMask(i, true);
}
// find heighest game we have added
if ( m_iHighestGame > 0 )
this->ComboGame->SelectedIndex = m_iHighestGame - 1;
else
this->ComboGame->SelectedIndex = this->ComboGame->Items->Count - 1;
m_pCustomiseWeapons->SetupControlsEnd();
m_pCustomiseTurret->SetupControlsEnd();
}
String ^AddText(String ^text, String ^def)
{
if ( !text || !text->Length )
return def;
return text;
}
void SwitchGame()
{
bool m_bUpdateding = true;
int game = this->ComboGame->SelectedIndex + 1;
// the ship info
m_pCustomiseInfo->UpdateInfo();
// the shield entries
m_pCustomiseWeapons1->UpdateShields();
// the cockpit entries
m_pCustomiseTurret->UpdateCockpits();
// notority preset
this->UpdateDisplay();
bool m_bUpdateing = false;
}
void UpdateDisplay()
{
m_pCustomiseInfo->UpdateDisplay();
m_pCustomisePerformance->UpdateDisplay();
m_pCustomiseWeapons1->UpdateDisplay();
m_pCustomiseModel->UpdateDisplay();
m_pCustomiseTurret->UpdateDisplay();
}
protected:
~CustomiseShip()
{
if (components)
{
delete components;
}
delete m_pShipData;
if ( m_pWeapons )
m_pWeapons->MemoryClear();
delete m_pWeapons;
if ( m_pModels )
delete m_pModels;
}
CustomiseInfo ^m_pCustomiseInfo;
CustomisePerformance ^m_pCustomisePerformance;
CustomiseWeapons1 ^m_pCustomiseWeapons1;
CustomiseModel ^m_pCustomiseModel;
CustomiseWeapons ^m_pCustomiseWeapons;
CustomiseGuns ^m_pCustomiseGuns;
CustomiseTurret ^m_pCustomiseTurret;
CLinkList<SWeaponMasks> *m_pWeapons;
CPackages *m_pPackages;
bool m_bUpdateing;
Windows::Forms::Form ^m_pMainForm;
CXspFile *m_pShipFile;
CShipData *m_pShipData;
CyStringList *m_pModels;
int m_iHighestGame;
/// <summary>
/// Clean up any resources being used.
/// </summary>
private: System::Windows::Forms::Panel^ panel1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::ComboBox^ ComboGame;
private: System::Windows::Forms::Panel^ panel2;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ ButSave;
private: System::Windows::Forms::ListView^ listView2;
private: System::Windows::Forms::ListView^ listView1;
private: System::Windows::Forms::CheckBox^ CheckWeaponDefaultCockpit;
private: System::Windows::Forms::TabPage^ tabPage7;
private: System::Windows::Forms::TabPage^ tabPage6;
private: System::Windows::Forms::TabPage^ tabPage5;
private: System::Windows::Forms::TabPage^ tabPage4;
private: System::Windows::Forms::TabPage^ tabPage3;
private: System::Windows::Forms::TabPage^ tabPage2;
private: System::Windows::Forms::TabControl^ tabControl1;
private: System::Windows::Forms::TabPage^ tabPage1;
private: System::ComponentModel::IContainer^ components;
/// <summary>
/// Required designer variable.
/// </summary>
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->panel1 = (gcnew System::Windows::Forms::Panel());
this->ComboGame = (gcnew System::Windows::Forms::ComboBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->panel2 = (gcnew System::Windows::Forms::Panel());
this->button2 = (gcnew System::Windows::Forms::Button());
this->ButSave = (gcnew System::Windows::Forms::Button());
this->tabPage7 = (gcnew System::Windows::Forms::TabPage());
this->tabPage6 = (gcnew System::Windows::Forms::TabPage());
this->tabPage5 = (gcnew System::Windows::Forms::TabPage());
this->tabPage4 = (gcnew System::Windows::Forms::TabPage());
this->tabPage3 = (gcnew System::Windows::Forms::TabPage());
this->tabPage2 = (gcnew System::Windows::Forms::TabPage());
this->tabControl1 = (gcnew System::Windows::Forms::TabControl());
this->tabPage1 = (gcnew System::Windows::Forms::TabPage());
this->panel1->SuspendLayout();
this->panel2->SuspendLayout();
this->tabControl1->SuspendLayout();
this->SuspendLayout();
//
// panel1
//
this->panel1->Controls->Add(this->ComboGame);
this->panel1->Controls->Add(this->label1);
this->panel1->Dock = System::Windows::Forms::DockStyle::Top;
this->panel1->Location = System::Drawing::Point(10, 10);
this->panel1->Name = L"panel1";
this->panel1->Padding = System::Windows::Forms::Padding(5);
this->panel1->Size = System::Drawing::Size(548, 32);
this->panel1->TabIndex = 0;
//
// ComboGame
//
this->ComboGame->Dock = System::Windows::Forms::DockStyle::Fill;
this->ComboGame->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
this->ComboGame->FormattingEnabled = true;
this->ComboGame->Location = System::Drawing::Point(155, 5);
this->ComboGame->Name = L"ComboGame";
this->ComboGame->Size = System::Drawing::Size(388, 21);
this->ComboGame->TabIndex = 1;
this->ComboGame->SelectedIndexChanged += gcnew System::EventHandler(this, &CustomiseShip::ComboGame_SelectedIndexChanged);
//
// label1
//
this->label1->Dock = System::Windows::Forms::DockStyle::Left;
this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(5, 5);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(150, 22);
this->label1->TabIndex = 0;
this->label1->Text = L"Primary Game";
this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
//
// panel2
//
this->panel2->Controls->Add(this->button2);
this->panel2->Controls->Add(this->ButSave);
this->panel2->Dock = System::Windows::Forms::DockStyle::Bottom;
this->panel2->Location = System::Drawing::Point(10, 553);
this->panel2->Name = L"panel2";
this->panel2->Padding = System::Windows::Forms::Padding(8);
this->panel2->Size = System::Drawing::Size(548, 46);
this->panel2->TabIndex = 1;
//
// button2
//
this->button2->DialogResult = System::Windows::Forms::DialogResult::Cancel;
this->button2->Dock = System::Windows::Forms::DockStyle::Right;
this->button2->Location = System::Drawing::Point(331, 8);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(99, 30);
this->button2->TabIndex = 1;
this->button2->Text = L"Cancel";
this->button2->UseVisualStyleBackColor = true;
//
// ButSave
//
this->ButSave->DialogResult = System::Windows::Forms::DialogResult::OK;
this->ButSave->Dock = System::Windows::Forms::DockStyle::Right;
this->ButSave->Location = System::Drawing::Point(430, 8);
this->ButSave->Name = L"ButSave";
this->ButSave->Size = System::Drawing::Size(110, 30);
this->ButSave->TabIndex = 0;
this->ButSave->Text = L"Save";
this->ButSave->UseVisualStyleBackColor = true;
this->ButSave->Click += gcnew System::EventHandler(this, &CustomiseShip::ButSave_Click);
//
// tabPage7
//
this->tabPage7->Location = System::Drawing::Point(4, 22);
this->tabPage7->Name = L"tabPage7";
this->tabPage7->Padding = System::Windows::Forms::Padding(10);
this->tabPage7->Size = System::Drawing::Size(540, 485);
this->tabPage7->TabIndex = 6;
this->tabPage7->Text = L"Guns";
this->tabPage7->UseVisualStyleBackColor = true;
//
// tabPage6
//
this->tabPage6->Location = System::Drawing::Point(4, 22);
this->tabPage6->Margin = System::Windows::Forms::Padding(10);
this->tabPage6->Name = L"tabPage6";
this->tabPage6->Padding = System::Windows::Forms::Padding(3);
this->tabPage6->Size = System::Drawing::Size(540, 485);
this->tabPage6->TabIndex = 5;
this->tabPage6->Text = L"Turrets";
this->tabPage6->UseVisualStyleBackColor = true;
//
// tabPage5
//
this->tabPage5->Location = System::Drawing::Point(4, 22);
this->tabPage5->Name = L"tabPage5";
this->tabPage5->Padding = System::Windows::Forms::Padding(10);
this->tabPage5->Size = System::Drawing::Size(540, 485);
this->tabPage5->TabIndex = 4;
this->tabPage5->Text = L"Lasers/Missiles";
this->tabPage5->UseVisualStyleBackColor = true;
//
// tabPage4
//
this->tabPage4->Location = System::Drawing::Point(4, 22);
this->tabPage4->Name = L"tabPage4";
this->tabPage4->Padding = System::Windows::Forms::Padding(3);
this->tabPage4->Size = System::Drawing::Size(540, 485);
this->tabPage4->TabIndex = 3;
this->tabPage4->Text = L"Model";
this->tabPage4->UseVisualStyleBackColor = true;
//
// tabPage3
//
this->tabPage3->Location = System::Drawing::Point(4, 22);
this->tabPage3->Name = L"tabPage3";
this->tabPage3->Padding = System::Windows::Forms::Padding(3);
this->tabPage3->Size = System::Drawing::Size(540, 485);
this->tabPage3->TabIndex = 2;
this->tabPage3->Text = L"Weapons";
this->tabPage3->UseVisualStyleBackColor = true;
//
// tabPage2
//
this->tabPage2->Location = System::Drawing::Point(4, 22);
this->tabPage2->Name = L"tabPage2";
this->tabPage2->Padding = System::Windows::Forms::Padding(3);
this->tabPage2->Size = System::Drawing::Size(540, 485);
this->tabPage2->TabIndex = 1;
this->tabPage2->Text = L"Performance";
this->tabPage2->UseVisualStyleBackColor = true;
//
// tabControl1
//
this->tabControl1->Controls->Add(this->tabPage1);
this->tabControl1->Controls->Add(this->tabPage2);
this->tabControl1->Controls->Add(this->tabPage3);
this->tabControl1->Controls->Add(this->tabPage4);
this->tabControl1->Controls->Add(this->tabPage5);
this->tabControl1->Controls->Add(this->tabPage6);
this->tabControl1->Controls->Add(this->tabPage7);
this->tabControl1->Dock = System::Windows::Forms::DockStyle::Fill;
this->tabControl1->Location = System::Drawing::Point(10, 42);
this->tabControl1->Name = L"tabControl1";
this->tabControl1->SelectedIndex = 0;
this->tabControl1->Size = System::Drawing::Size(548, 511);
this->tabControl1->TabIndex = 2;
//
// tabPage1
//
this->tabPage1->Location = System::Drawing::Point(4, 22);
this->tabPage1->Name = L"tabPage1";
this->tabPage1->Padding = System::Windows::Forms::Padding(3);
this->tabPage1->Size = System::Drawing::Size(540, 485);
this->tabPage1->TabIndex = 0;
this->tabPage1->Text = L"Ship Info";
this->tabPage1->UseVisualStyleBackColor = true;
//
// CustomiseShip
//
this->AcceptButton = this->ButSave;
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->CancelButton = this->button2;
this->ClientSize = System::Drawing::Size(568, 609);
this->Controls->Add(this->tabControl1);
this->Controls->Add(this->panel2);
this->Controls->Add(this->panel1);
this->Name = L"CustomiseShip";
this->Padding = System::Windows::Forms::Padding(10);
this->ShowInTaskbar = false;
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"Customise Ship";
this->panel1->ResumeLayout(false);
this->panel2->ResumeLayout(false);
this->tabControl1->ResumeLayout(false);
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void ComboGame_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
this->SwitchGame();
}
private: System::Void ButSave_Click(System::Object^ sender, System::EventArgs^ e) {
m_pShipFile->SetCreatedShipData(m_pShipData);
for ( SWeaponMasks *m = m_pWeapons->First(); m; m = m_pWeapons->Next() )
{
if ( m->iLaserMask > -1 )
m_pShipFile->SetLaserMask(m->iGame, m->iLaserMask);
if ( m->iMissileMask > -1 )
m_pShipFile->SetMissileMask(m->iGame, m->iMissileMask);
}
}
};
}