Rev 197 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#pragma onceusing namespace System;using namespace System::ComponentModel;using namespace System::Collections;using namespace System::Windows::Forms;using namespace System::Data;using namespace System::Drawing;namespace Creator {/// <summary>/// Summary for ModDiff////// 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 ModDiff : public System::Windows::Forms::Form{public:ModDiff(CGameDirectories *gameDir, CPackages *p){InitializeComponent();for ( Utils::WString dir = gameDir->first(); !dir.empty(); dir = gameDir->next() )this->comboBox1->Items->Add(_US(dir + L" (" + gameDir->currentName() + L")"));m_pPackages = p;this->panel3->Enabled = false;this->panel5->Enabled = false;this->pictureBox2->Image = nullptr;this->pictureBox3->Image = nullptr;this->splitContainer1->Visible = false;this->toolTip1->SetToolTip(this->comboBox2, "All mod/patchs that are after this one will not be included when generating a diff");}void SetImage(Windows::Forms::PictureBox ^pic){System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(ModDiff::typeid));pic->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"pictureBox1.Image")));}protected:/// <summary>/// Clean up any resources being used./// </summary>~ModDiff(){if (components){delete components;}}private: System::Windows::Forms::PictureBox^ pictureBox1;protected:private: System::Windows::Forms::Panel^ panel1;private: System::Windows::Forms::ComboBox^ comboBox1;private: System::Windows::Forms::Label^ label1;private: System::Windows::Forms::Panel^ panel2;private: System::Windows::Forms::Panel^ panel3;private: System::Windows::Forms::Panel^ panel4;private: System::Windows::Forms::ComboBox^ comboBox2;private: System::Windows::Forms::Label^ label2;private: System::Windows::Forms::PictureBox^ pictureBox2;private:CPackages *m_pPackages;private: System::Windows::Forms::Panel^ panel5;private: System::Windows::Forms::Panel^ panel6;private: System::Windows::Forms::Label^ label3;private: System::Windows::Forms::PictureBox^ pictureBox3;private: System::Windows::Forms::TextBox^ textBox1;private: System::Windows::Forms::Button^ button1;private: System::Windows::Forms::Panel^ panel7;private: System::Windows::Forms::SplitContainer^ splitContainer1;private: System::Windows::Forms::Button^ button2;private: System::Windows::Forms::Button^ button3;private: System::Windows::Forms::ToolTip^ toolTip1;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->components = (gcnew System::ComponentModel::Container());System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(ModDiff::typeid));this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());this->panel1 = (gcnew System::Windows::Forms::Panel());this->panel2 = (gcnew System::Windows::Forms::Panel());this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());this->label1 = (gcnew System::Windows::Forms::Label());this->panel3 = (gcnew System::Windows::Forms::Panel());this->panel4 = (gcnew System::Windows::Forms::Panel());this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());this->label2 = (gcnew System::Windows::Forms::Label());this->pictureBox2 = (gcnew System::Windows::Forms::PictureBox());this->panel5 = (gcnew System::Windows::Forms::Panel());this->panel6 = (gcnew System::Windows::Forms::Panel());this->textBox1 = (gcnew System::Windows::Forms::TextBox());this->button1 = (gcnew System::Windows::Forms::Button());this->label3 = (gcnew System::Windows::Forms::Label());this->pictureBox3 = (gcnew System::Windows::Forms::PictureBox());this->panel7 = (gcnew System::Windows::Forms::Panel());this->splitContainer1 = (gcnew System::Windows::Forms::SplitContainer());this->button2 = (gcnew System::Windows::Forms::Button());this->button3 = (gcnew System::Windows::Forms::Button());this->toolTip1 = (gcnew System::Windows::Forms::ToolTip(this->components));(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->BeginInit();this->panel1->SuspendLayout();this->panel2->SuspendLayout();this->panel3->SuspendLayout();this->panel4->SuspendLayout();(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox2))->BeginInit();this->panel5->SuspendLayout();this->panel6->SuspendLayout();(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox3))->BeginInit();this->panel7->SuspendLayout();this->splitContainer1->Panel1->SuspendLayout();this->splitContainer1->Panel2->SuspendLayout();this->splitContainer1->SuspendLayout();this->SuspendLayout();//// pictureBox1//this->pictureBox1->Dock = System::Windows::Forms::DockStyle::Left;this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"pictureBox1.Image")));this->pictureBox1->Location = System::Drawing::Point(3, 3);this->pictureBox1->Name = L"pictureBox1";this->pictureBox1->Size = System::Drawing::Size(33, 30);this->pictureBox1->TabIndex = 0;this->pictureBox1->TabStop = false;//// panel1//this->panel1->Controls->Add(this->panel2);this->panel1->Controls->Add(this->label1);this->panel1->Controls->Add(this->pictureBox1);this->panel1->Dock = System::Windows::Forms::DockStyle::Top;this->panel1->Location = System::Drawing::Point(5, 5);this->panel1->Name = L"panel1";this->panel1->Padding = System::Windows::Forms::Padding(3);this->panel1->Size = System::Drawing::Size(573, 36);this->panel1->TabIndex = 1;//// panel2//this->panel2->Controls->Add(this->comboBox1);this->panel2->Dock = System::Windows::Forms::DockStyle::Fill;this->panel2->Location = System::Drawing::Point(201, 3);this->panel2->Name = L"panel2";this->panel2->Padding = System::Windows::Forms::Padding(0, 5, 0, 0);this->panel2->Size = System::Drawing::Size(369, 30);this->panel2->TabIndex = 3;//// comboBox1//this->comboBox1->Dock = System::Windows::Forms::DockStyle::Fill;this->comboBox1->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;this->comboBox1->FormattingEnabled = true;this->comboBox1->Location = System::Drawing::Point(0, 5);this->comboBox1->Name = L"comboBox1";this->comboBox1->Size = System::Drawing::Size(369, 21);this->comboBox1->TabIndex = 2;this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &ModDiff::comboBox1_SelectedIndexChanged);//// label1//this->label1->Dock = System::Windows::Forms::DockStyle::Left;this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,static_cast<System::Byte>(0)));this->label1->Location = System::Drawing::Point(36, 3);this->label1->Name = L"label1";this->label1->Size = System::Drawing::Size(165, 30);this->label1->TabIndex = 1;this->label1->Text = L"Game Directory";this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;//// panel3//this->panel3->Controls->Add(this->panel4);this->panel3->Controls->Add(this->label2);this->panel3->Controls->Add(this->pictureBox2);this->panel3->Dock = System::Windows::Forms::DockStyle::Top;this->panel3->Location = System::Drawing::Point(5, 41);this->panel3->Name = L"panel3";this->panel3->Padding = System::Windows::Forms::Padding(3);this->panel3->Size = System::Drawing::Size(573, 36);this->panel3->TabIndex = 2;//// panel4//this->panel4->Controls->Add(this->comboBox2);this->panel4->Dock = System::Windows::Forms::DockStyle::Fill;this->panel4->Location = System::Drawing::Point(201, 3);this->panel4->Name = L"panel4";this->panel4->Padding = System::Windows::Forms::Padding(0, 5, 0, 0);this->panel4->Size = System::Drawing::Size(369, 30);this->panel4->TabIndex = 3;//// comboBox2//this->comboBox2->Dock = System::Windows::Forms::DockStyle::Fill;this->comboBox2->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;this->comboBox2->FormattingEnabled = true;this->comboBox2->Location = System::Drawing::Point(0, 5);this->comboBox2->Name = L"comboBox2";this->comboBox2->Size = System::Drawing::Size(369, 21);this->comboBox2->TabIndex = 2;this->comboBox2->SelectedIndexChanged += gcnew System::EventHandler(this, &ModDiff::comboBox2_SelectedIndexChanged);//// label2//this->label2->Dock = System::Windows::Forms::DockStyle::Left;this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,static_cast<System::Byte>(0)));this->label2->Location = System::Drawing::Point(36, 3);this->label2->Name = L"label2";this->label2->Size = System::Drawing::Size(165, 30);this->label2->TabIndex = 1;this->label2->Text = L"Fake Patch Start";this->label2->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;//// pictureBox2//this->pictureBox2->Dock = System::Windows::Forms::DockStyle::Left;this->pictureBox2->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"pictureBox2.Image")));this->pictureBox2->Location = System::Drawing::Point(3, 3);this->pictureBox2->Name = L"pictureBox2";this->pictureBox2->Size = System::Drawing::Size(33, 30);this->pictureBox2->TabIndex = 0;this->pictureBox2->TabStop = false;//// panel5//this->panel5->Controls->Add(this->panel6);this->panel5->Controls->Add(this->label3);this->panel5->Controls->Add(this->pictureBox3);this->panel5->Dock = System::Windows::Forms::DockStyle::Top;this->panel5->Location = System::Drawing::Point(5, 77);this->panel5->Name = L"panel5";this->panel5->Padding = System::Windows::Forms::Padding(3);this->panel5->Size = System::Drawing::Size(573, 36);this->panel5->TabIndex = 3;//// panel6//this->panel6->Controls->Add(this->textBox1);this->panel6->Controls->Add(this->button1);this->panel6->Dock = System::Windows::Forms::DockStyle::Fill;this->panel6->Location = System::Drawing::Point(201, 3);this->panel6->Name = L"panel6";this->panel6->Padding = System::Windows::Forms::Padding(0, 5, 0, 0);this->panel6->Size = System::Drawing::Size(369, 30);this->panel6->TabIndex = 3;//// textBox1//this->textBox1->Dock = System::Windows::Forms::DockStyle::Fill;this->textBox1->Location = System::Drawing::Point(0, 5);this->textBox1->Name = L"textBox1";this->textBox1->ReadOnly = true;this->textBox1->Size = System::Drawing::Size(343, 20);this->textBox1->TabIndex = 0;//// button1//this->button1->Dock = System::Windows::Forms::DockStyle::Right;this->button1->ForeColor = System::Drawing::Color::ForestGreen;this->button1->Location = System::Drawing::Point(343, 5);this->button1->Name = L"button1";this->button1->Size = System::Drawing::Size(26, 25);this->button1->TabIndex = 1;this->button1->Text = L"...";this->button1->UseVisualStyleBackColor = true;this->button1->Click += gcnew System::EventHandler(this, &ModDiff::button1_Click);//// label3//this->label3->Dock = System::Windows::Forms::DockStyle::Left;this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,static_cast<System::Byte>(0)));this->label3->Location = System::Drawing::Point(36, 3);this->label3->Name = L"label3";this->label3->Size = System::Drawing::Size(165, 30);this->label3->TabIndex = 1;this->label3->Text = L"Mod";this->label3->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;//// pictureBox3//this->pictureBox3->Dock = System::Windows::Forms::DockStyle::Left;this->pictureBox3->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"pictureBox3.Image")));this->pictureBox3->Location = System::Drawing::Point(3, 3);this->pictureBox3->Name = L"pictureBox3";this->pictureBox3->Size = System::Drawing::Size(33, 30);this->pictureBox3->TabIndex = 0;this->pictureBox3->TabStop = false;//// panel7//this->panel7->Controls->Add(this->splitContainer1);this->panel7->Dock = System::Windows::Forms::DockStyle::Fill;this->panel7->Location = System::Drawing::Point(5, 113);this->panel7->Name = L"panel7";this->panel7->Padding = System::Windows::Forms::Padding(100, 10, 100, 10);this->panel7->Size = System::Drawing::Size(573, 49);this->panel7->TabIndex = 4;//// splitContainer1//this->splitContainer1->Dock = System::Windows::Forms::DockStyle::Fill;this->splitContainer1->IsSplitterFixed = true;this->splitContainer1->Location = System::Drawing::Point(100, 10);this->splitContainer1->Name = L"splitContainer1";//// splitContainer1.Panel1//this->splitContainer1->Panel1->Controls->Add(this->button2);//// splitContainer1.Panel2//this->splitContainer1->Panel2->Controls->Add(this->button3);this->splitContainer1->Size = System::Drawing::Size(373, 29);this->splitContainer1->SplitterDistance = 192;this->splitContainer1->TabIndex = 5;//// button2//this->button2->Dock = System::Windows::Forms::DockStyle::Fill;this->button2->Location = System::Drawing::Point(0, 0);this->button2->Name = L"button2";this->button2->Size = System::Drawing::Size(192, 29);this->button2->TabIndex = 0;this->button2->Text = L"Create Diff";this->button2->UseVisualStyleBackColor = true;this->button2->Click += gcnew System::EventHandler(this, &ModDiff::button2_Click);//// button3//this->button3->Dock = System::Windows::Forms::DockStyle::Fill;this->button3->Location = System::Drawing::Point(0, 0);this->button3->Name = L"button3";this->button3->Size = System::Drawing::Size(177, 29);this->button3->TabIndex = 1;this->button3->Text = L"Apply Diff";this->button3->UseVisualStyleBackColor = true;this->button3->Click += gcnew System::EventHandler(this, &ModDiff::button3_Click);//// toolTip1//this->toolTip1->IsBalloon = true;this->toolTip1->ToolTipIcon = System::Windows::Forms::ToolTipIcon::Info;this->toolTip1->ToolTipTitle = L"Help";//// ModDiff//this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;this->ClientSize = System::Drawing::Size(583, 167);this->Controls->Add(this->panel7);this->Controls->Add(this->panel5);this->Controls->Add(this->panel3);this->Controls->Add(this->panel1);this->Name = L"ModDiff";this->Padding = System::Windows::Forms::Padding(5);this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;this->Text = L"Mod Diff";this->TopMost = true;this->Load += gcnew System::EventHandler(this, &ModDiff::ModDiff_Load);(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->EndInit();this->panel1->ResumeLayout(false);this->panel2->ResumeLayout(false);this->panel3->ResumeLayout(false);this->panel4->ResumeLayout(false);(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox2))->EndInit();this->panel5->ResumeLayout(false);this->panel6->ResumeLayout(false);this->panel6->PerformLayout();(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox3))->EndInit();this->panel7->ResumeLayout(false);this->splitContainer1->Panel1->ResumeLayout(false);this->splitContainer1->Panel2->ResumeLayout(false);this->splitContainer1->ResumeLayout(false);this->ResumeLayout(false);}#pragma endregionprivate: System::Void ModDiff_Load(System::Object^ sender, System::EventArgs^ e) {}private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {int fake = m_pPackages->findNextFakePatch(0, _WS(this->comboBox1->Text).token(L" (", 1));this->comboBox2->Items->Add("- None -");for ( int i = 1; i < fake; i++ )this->comboBox2->Items->Add(_US(Utils::WString::PadNumber(i, 2)) + ".cat");this->pictureBox1->Image = nullptr;SetImage(this->pictureBox2);this->comboBox1->Enabled = false;this->panel3->Enabled = true;}private: System::Void comboBox2_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {this->pictureBox2->Image = nullptr;this->panel5->Enabled = true;SetImage(this->pictureBox3);}private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {OpenFileDialog ^ofd = gcnew OpenFileDialog();ofd->Filter = "X-Mod Files (*.cat)|*.cat";ofd->FilterIndex = 1;ofd->RestoreDirectory = true;ofd->Title = "Select the mod file to use";if ( ofd->ShowDialog(this) == Windows::Forms::DialogResult::OK ){this->textBox1->Text = ofd->FileName;this->pictureBox3->Image = nullptr;this->splitContainer1->Visible = true;}}private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {SaveFileDialog ^ofd = gcnew SaveFileDialog();ofd->Filter = "Diff Files (*.diff)|*.diff";ofd->FilterIndex = 1;ofd->RestoreDirectory = true;ofd->AddExtension = true;ofd->Title = "Select the diff file to save changes to";if ( ofd->ShowDialog(this) == Windows::Forms::DialogResult::OK ){CModDiff Diff(_WS(this->comboBox1->Text).token(L" (", 1), L"addon", this->comboBox2->SelectedIndex);if ( !Diff.CreateDiff(_WS(this->textBox1->Text)) ){MessageBox::Show(this, "Unable to create diff from mod:\n" + this->textBox1->Text, "Create Diff", MessageBoxButtons::OK, MessageBoxIcon::Error);Close();}if ( !Diff.WriteDiff(_WS(ofd->FileName)) ){MessageBox::Show(this, "Unable to write diff file:\n" + ofd->FileName, "Create Diff", MessageBoxButtons::OK, MessageBoxIcon::Error);Close();}MessageBox::Show(this, "Diff file: " + ofd->FileName + " has been generated", "Create Diff", MessageBoxButtons::OK, MessageBoxIcon::Information);Close();}}private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {OpenFileDialog ^ofd = gcnew OpenFileDialog();ofd->Filter = "Diff Files (*.diff)|*.diff";ofd->FilterIndex = 1;ofd->RestoreDirectory = true;ofd->Title = "Select the diff file to apply to the mod";if ( ofd->ShowDialog(this) == Windows::Forms::DialogResult::OK ){CModDiff Diff(_WS(this->comboBox1->Text).token(L" (", 1), L"addon", this->comboBox2->SelectedIndex);Diff.ApplyDiff(_WS(this->textBox1->Text));if ( !Diff.ReadDiff(_WS(ofd->FileName)) ){MessageBox::Show(this, "Unable to read diff file:\n" + ofd->FileName, "Apply Diff", MessageBoxButtons::OK, MessageBoxIcon::Error);Close();}if ( !Diff.ApplyDiff(_WS(this->textBox1->Text)) ){MessageBox::Show(this, "Unable to apply diff to mod:\n" + this->textBox1->Text, "Apply Diff", MessageBoxButtons::OK, MessageBoxIcon::Error);Close();}MessageBox::Show(this, "Diff file: " + ofd->FileName + " has been applied to " + this->textBox1->Text, "Apply Diff", MessageBoxButtons::OK, MessageBoxIcon::Information);Close();}}};}