Subversion Repositories spk

Rev

Rev 103 | 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;

typedef struct SWeaponMasks {
        int     iGame;
        int iLaserMask;
        int iMissileMask;
} SWeaponMasks;

namespace Creator {

        /// <summary>
        /// Summary for CustomiseWeapons
        /// </summary>
        public ref class CustomiseWeapons : public System::Windows::Forms::UserControl
        {
        public:
                CustomiseWeapons(Windows::Forms::Form ^parent, CLinkList<SWeaponMasks> *weapons, CShipData *shipData)
                {
                        InitializeComponent();

                        m_pShipData = shipData;
                        m_pWeapons = weapons;
                        m_pParent = parent;
                        m_bUpdating = false;

                        this->SetupControls();
                }

                void AddGameEntry(String ^game) { this->ComboGameLaser->Items->Add(game); }
                void SetupControlsEnd() { this->ComboGameLaser->SelectedIndex = 0; }

        protected:
                /// <summary>
                /// Clean up any resources being used.
                /// </summary>
                void SetupControls();
                void UpdateWeaponsList();
                void SaveWeaponsList();

                ~CustomiseWeapons()
                {
                        if (components)
                        {
                                delete components;
                        }
                }
        private: System::Windows::Forms::ListView^  ListWeapons;
        protected: 
        private: System::Windows::Forms::ColumnHeader^  columnHeader1;
        private: System::Windows::Forms::ColumnHeader^  columnHeader2;
        private: System::Windows::Forms::FlowLayoutPanel^  flowLayoutPanel1;
        private: System::Windows::Forms::RadioButton^  RadioLasers;
        private: System::Windows::Forms::RadioButton^  RadioMissiles;
        private: System::Windows::Forms::CheckBox^  CheckWeaponDefault;
        private: System::Windows::Forms::Button^  ButCopyDefault;
        private: System::Windows::Forms::Panel^  panel34;
        private: System::Windows::Forms::ComboBox^  ComboGameLaser;
        private: System::Windows::Forms::Label^  label51;

        private:
                Windows::Forms::Form            ^m_pParent;
                bool                                             m_bUpdating;
                CLinkList<SWeaponMasks>         *m_pWeapons;
                CShipData                                       *m_pShipData;
                /// <summary>
                /// Required designer variable.
                /// </summary>
                System::ComponentModel::Container ^components;

#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->ListWeapons = (gcnew System::Windows::Forms::ListView());
                        this->columnHeader1 = (gcnew System::Windows::Forms::ColumnHeader());
                        this->columnHeader2 = (gcnew System::Windows::Forms::ColumnHeader());
                        this->flowLayoutPanel1 = (gcnew System::Windows::Forms::FlowLayoutPanel());
                        this->RadioLasers = (gcnew System::Windows::Forms::RadioButton());
                        this->RadioMissiles = (gcnew System::Windows::Forms::RadioButton());
                        this->CheckWeaponDefault = (gcnew System::Windows::Forms::CheckBox());
                        this->ButCopyDefault = (gcnew System::Windows::Forms::Button());
                        this->panel34 = (gcnew System::Windows::Forms::Panel());
                        this->ComboGameLaser = (gcnew System::Windows::Forms::ComboBox());
                        this->label51 = (gcnew System::Windows::Forms::Label());
                        this->flowLayoutPanel1->SuspendLayout();
                        this->panel34->SuspendLayout();
                        this->SuspendLayout();
                        // 
                        // ListWeapons
                        // 
                        this->ListWeapons->CheckBoxes = true;
                        this->ListWeapons->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^  >(2) {
                                this->columnHeader1,
                                        this->columnHeader2
                        });
                        this->ListWeapons->Dock = System::Windows::Forms::DockStyle::Fill;
                        this->ListWeapons->FullRowSelect = true;
                        this->ListWeapons->HideSelection = false;
                        this->ListWeapons->Location = System::Drawing::Point(0, 48);
                        this->ListWeapons->Name = L"ListWeapons";
                        this->ListWeapons->Size = System::Drawing::Size(552, 588);
                        this->ListWeapons->TabIndex = 5;
                        this->ListWeapons->UseCompatibleStateImageBehavior = false;
                        this->ListWeapons->View = System::Windows::Forms::View::Details;
                        this->ListWeapons->ItemCheck += gcnew System::Windows::Forms::ItemCheckEventHandler(this, &CustomiseWeapons::ListWeapons_ItemCheck);
                        this->ListWeapons->ItemChecked += gcnew System::Windows::Forms::ItemCheckedEventHandler(this, &CustomiseWeapons::ListWeapons_ItemChecked);
                        // 
                        // columnHeader1
                        // 
                        this->columnHeader1->Text = L"Group";
                        // 
                        // columnHeader2
                        // 
                        this->columnHeader2->Text = L"Weapons";
                        // 
                        // flowLayoutPanel1
                        // 
                        this->flowLayoutPanel1->Controls->Add(this->RadioLasers);
                        this->flowLayoutPanel1->Controls->Add(this->RadioMissiles);
                        this->flowLayoutPanel1->Controls->Add(this->CheckWeaponDefault);
                        this->flowLayoutPanel1->Controls->Add(this->ButCopyDefault);
                        this->flowLayoutPanel1->Dock = System::Windows::Forms::DockStyle::Top;
                        this->flowLayoutPanel1->Location = System::Drawing::Point(0, 22);
                        this->flowLayoutPanel1->Name = L"flowLayoutPanel1";
                        this->flowLayoutPanel1->Size = System::Drawing::Size(552, 26);
                        this->flowLayoutPanel1->TabIndex = 4;
                        // 
                        // RadioLasers
                        // 
                        this->RadioLasers->AutoSize = true;
                        this->RadioLasers->Checked = true;
                        this->RadioLasers->Location = System::Drawing::Point(3, 3);
                        this->RadioLasers->Name = L"RadioLasers";
                        this->RadioLasers->Size = System::Drawing::Size(116, 17);
                        this->RadioLasers->TabIndex = 0;
                        this->RadioLasers->TabStop = true;
                        this->RadioLasers->Text = L"Laser Compatability";
                        this->RadioLasers->UseVisualStyleBackColor = true;
                        this->RadioLasers->CheckedChanged += gcnew System::EventHandler(this, &CustomiseWeapons::RadioLasers_CheckedChanged);
                        // 
                        // RadioMissiles
                        // 
                        this->RadioMissiles->AutoSize = true;
                        this->RadioMissiles->Location = System::Drawing::Point(125, 3);
                        this->RadioMissiles->Name = L"RadioMissiles";
                        this->RadioMissiles->Size = System::Drawing::Size(121, 17);
                        this->RadioMissiles->TabIndex = 1;
                        this->RadioMissiles->Text = L"Missile Compatability";
                        this->RadioMissiles->UseVisualStyleBackColor = true;
                        this->RadioMissiles->CheckedChanged += gcnew System::EventHandler(this, &CustomiseWeapons::RadioMissiles_CheckedChanged);
                        // 
                        // CheckWeaponDefault
                        // 
                        this->CheckWeaponDefault->AutoSize = true;
                        this->CheckWeaponDefault->Location = System::Drawing::Point(252, 3);
                        this->CheckWeaponDefault->Name = L"CheckWeaponDefault";
                        this->CheckWeaponDefault->Size = System::Drawing::Size(82, 17);
                        this->CheckWeaponDefault->TabIndex = 2;
                        this->CheckWeaponDefault->Text = L"Use Default";
                        this->CheckWeaponDefault->UseVisualStyleBackColor = true;
                        this->CheckWeaponDefault->CheckedChanged += gcnew System::EventHandler(this, &CustomiseWeapons::CheckWeaponDefault_CheckedChanged);
                        // 
                        // ButCopyDefault
                        // 
                        this->ButCopyDefault->AutoSize = true;
                        this->ButCopyDefault->Location = System::Drawing::Point(340, 3);
                        this->ButCopyDefault->Name = L"ButCopyDefault";
                        this->ButCopyDefault->Size = System::Drawing::Size(83, 23);
                        this->ButCopyDefault->TabIndex = 2;
                        this->ButCopyDefault->Text = L"Copy Defaults";
                        this->ButCopyDefault->UseVisualStyleBackColor = true;
                        this->ButCopyDefault->Click += gcnew System::EventHandler(this, &CustomiseWeapons::ButCopyDefault_Click);
                        // 
                        // panel34
                        // 
                        this->panel34->Controls->Add(this->ComboGameLaser);
                        this->panel34->Controls->Add(this->label51);
                        this->panel34->Dock = System::Windows::Forms::DockStyle::Top;
                        this->panel34->Location = System::Drawing::Point(0, 0);
                        this->panel34->Name = L"panel34";
                        this->panel34->Size = System::Drawing::Size(552, 22);
                        this->panel34->TabIndex = 3;
                        // 
                        // ComboGameLaser
                        // 
                        this->ComboGameLaser->Dock = System::Windows::Forms::DockStyle::Fill;
                        this->ComboGameLaser->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
                        this->ComboGameLaser->FormattingEnabled = true;
                        this->ComboGameLaser->Location = System::Drawing::Point(188, 0);
                        this->ComboGameLaser->Name = L"ComboGameLaser";
                        this->ComboGameLaser->Size = System::Drawing::Size(364, 21);
                        this->ComboGameLaser->TabIndex = 0;
                        this->ComboGameLaser->SelectedIndexChanged += gcnew System::EventHandler(this, &CustomiseWeapons::ComboGameLaser_SelectedIndexChanged);
                        // 
                        // label51
                        // 
                        this->label51->Dock = System::Windows::Forms::DockStyle::Left;
                        this->label51->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->label51->Location = System::Drawing::Point(0, 0);
                        this->label51->Name = L"label51";
                        this->label51->Size = System::Drawing::Size(188, 22);
                        this->label51->TabIndex = 1;
                        this->label51->Text = L"X-Universe Game:";
                        this->label51->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
                        // 
                        // CustomiseWeapons
                        // 
                        this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
                        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
                        this->Controls->Add(this->ListWeapons);
                        this->Controls->Add(this->flowLayoutPanel1);
                        this->Controls->Add(this->panel34);
                        this->Name = L"CustomiseWeapons";
                        this->Size = System::Drawing::Size(552, 636);
                        this->flowLayoutPanel1->ResumeLayout(false);
                        this->flowLayoutPanel1->PerformLayout();
                        this->panel34->ResumeLayout(false);
                        this->ResumeLayout(false);

                }
#pragma endregion
        private: System::Void ListWeapons_ItemChecked(System::Object^  sender, System::Windows::Forms::ItemCheckedEventArgs^  e) {
                                 this->SaveWeaponsList();
                         }
private: System::Void RadioLasers_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
                         this->UpdateWeaponsList();
                 }
private: System::Void RadioMissiles_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
                         this->UpdateWeaponsList();
                 }
private: System::Void ComboGameLaser_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
                         this->UpdateWeaponsList();
                 }
private: System::Void CheckWeaponDefault_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
                         if ( this->CheckWeaponDefault->Checked ) {
                                 this->ListWeapons->BackColor = Color::Gainsboro;
                         }
                         else {
                                 this->ListWeapons->BackColor = Color::White;
                         }
                         this->ButCopyDefault->Visible = !this->CheckWeaponDefault->Checked;
                         if ( m_bUpdating ) return;
                         int value = (this->CheckWeaponDefault->Checked) ? -1 : 0;

                        for ( SWeaponMasks *m = m_pWeapons->First(); m; m = m_pWeapons->Next() )
                        {
                                if ( m->iGame == this->ComboGameLaser->SelectedIndex )
                                {
                                        if ( this->RadioMissiles->Checked )
                                                m->iMissileMask = value;
                                        else
                                                m->iLaserMask = value;
                                        break;
                                }
                        }
                        this->UpdateWeaponsList();
                 }
private: System::Void ButCopyDefault_Click(System::Object^  sender, System::EventArgs^  e) {
                        for ( SWeaponMasks *m = m_pWeapons->First(); m; m = m_pWeapons->Next() )
                        {
                                if ( m->iGame == this->ComboGameLaser->SelectedIndex )
                                {
                                        if ( this->RadioMissiles->Checked )
                                                m->iMissileMask = m_pShipData->iMissileMask;
                                        else
                                                m->iLaserMask = m_pShipData->iLaserMask;
                                        break;
                                }
                        }
                        this->UpdateWeaponsList();
                 }
private: System::Void ListWeapons_ItemCheck(System::Object^  sender, System::Windows::Forms::ItemCheckEventArgs^  e) {
                         if ( this->CheckWeaponDefault->Checked && !m_bUpdating ) {
                                 e->NewValue = e->CurrentValue;
                         }
                 }
};
}