namespace ns1
{
    using ns0;
    using ns2;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    internal class frmNewQuest : Form
    {
        private Button button1;
        private Button button2;
        private frmMain frmMain_0;
        private IContainer icontainer_0 = null;
        private Label label1;
        private Label label2;
        private Label label3;
        private Label label4;
        private Label lblMax;
        private TextBox txtDesc;
        private TextBox txtQID;
        private TextBox txtTitle;

        public frmNewQuest(frmMain main)
        {
            this.frmMain_0 = main;
            this.InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ushort num = 0;
            ushort num2 = 0;
            ushort num3 = 0;
            try
            {
                num = Convert.ToUInt16(this.txtQID.Text);
                num2 = Convert.ToUInt16(this.txtDesc.Text);
                num3 = Convert.ToUInt16(this.txtTitle.Text);
                using (List<Class3>.Enumerator enumerator = this.frmMain_0.class2_0.list_0.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Class3 current = enumerator.Current;
                        if (current.ID == num)
                        {
                            goto Label_0075;
                        }
                    }
                    goto Label_0090;
                Label_0075:
                    MessageBox.Show("QuestID already in use!");
                    return;
                }
            Label_0090:
                this.method_0(num, num3, num2);
            }
            catch
            {
                MessageBox.Show("Error parsing numbers");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (this.frmMain_0.frmResEditor_0 == null)
            {
                this.frmMain_0.frmResEditor_0 = new frmResEditor(this.frmMain_0);
            }
            this.frmMain_0.Show();
        }

        private void frmNewQuest_Load(object sender, EventArgs e)
        {
            if (this.frmMain_0.class3_0 == null)
            {
                base.Close();
            }
            ushort num = 0;
            num = 0xffff;
            this.lblMax.Text = "Values allowed: " + num.ToString() + " - " + num.ToString();
        }

        private void InitializeComponent()
        {
            this.label1 = new Label();
            this.txtTitle = new TextBox();
            this.label2 = new Label();
            this.label3 = new Label();
            this.txtDesc = new TextBox();
            this.label4 = new Label();
            this.txtQID = new TextBox();
            this.button1 = new Button();
            this.button2 = new Button();
            this.lblMax = new Label();
            base.SuspendLayout();
            this.label1.AutoSize = true;
            this.label1.Location = new Point(12, 9);
            this.label1.Name = "label1";
            this.label1.Size = new Size(30, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "Title:";
            this.txtTitle.Location = new Point(0x30, 6);
            this.txtTitle.Name = "txtTitle";
            this.txtTitle.Size = new Size(0x4e, 20);
            this.txtTitle.TabIndex = 1;
            this.label2.AutoSize = true;
            this.label2.Location = new Point(0x92, 10);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0xf5, 13);
            this.label2.TabIndex = 2;
            this.label2.Text = "Enter a NUMBER - Create new text with ResEditor";
            this.label3.AutoSize = true;
            this.label3.Location = new Point(12, 0x27);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x23, 13);
            this.label3.TabIndex = 3;
            this.label3.Text = "Desc:";
            this.txtDesc.Location = new Point(0x30, 0x24);
            this.txtDesc.Name = "txtDesc";
            this.txtDesc.Size = new Size(0x4e, 20);
            this.txtDesc.TabIndex = 4;
            this.label4.AutoSize = true;
            this.label4.Location = new Point(14, 0x5d);
            this.label4.Name = "label4";
            this.label4.Size = new Size(0x2e, 13);
            this.label4.TabIndex = 5;
            this.label4.Text = "QuestID";
            this.txtQID.Location = new Point(0x43, 90);
            this.txtQID.Name = "txtQID";
            this.txtQID.Size = new Size(0x3b, 20);
            this.txtQID.TabIndex = 6;
            this.button1.Location = new Point(0x95, 0x24);
            this.button1.Name = "button1";
            this.button1.Size = new Size(0x5f, 0x2e);
            this.button1.TabIndex = 7;
            this.button1.Text = "Create";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new EventHandler(this.button1_Click);
            this.button2.Location = new Point(0x108, 0x24);
            this.button2.Name = "button2";
            this.button2.Size = new Size(0x60, 0x2d);
            this.button2.TabIndex = 8;
            this.button2.Text = "ResEditor";
            this.button2.UseVisualStyleBackColor = true;
            this.button2.Click += new EventHandler(this.button2_Click);
            this.lblMax.AutoSize = true;
            this.lblMax.Location = new Point(0xbc, 0x5f);
            this.lblMax.Name = "lblMax";
            this.lblMax.Size = new Size(0x23, 13);
            this.lblMax.TabIndex = 9;
            this.lblMax.Text = "label5";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x188, 0x7b);
            base.Controls.Add(this.lblMax);
            base.Controls.Add(this.button2);
            base.Controls.Add(this.button1);
            base.Controls.Add(this.txtQID);
            base.Controls.Add(this.label4);
            base.Controls.Add(this.txtDesc);
            base.Controls.Add(this.label3);
            base.Controls.Add(this.label2);
            base.Controls.Add(this.txtTitle);
            base.Controls.Add(this.label1);
            base.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            base.Name = "frmNewQuest";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "New Quest";
            base.Load += new EventHandler(this.frmNewQuest_Load);
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void method_0(ushort ushort_0, ushort ushort_1, ushort ushort_2)
        {
            Class3 item = new Class3 {
                ActionScript = this.ViewingQuest.ActionScript,
                Description = ushort_2,
                FinishScript = this.ViewingQuest.FinishScript,
                ItemData = new byte[this.ViewingQuest.ItemData.Length]
            };
            this.ViewingQuest.ItemData.CopyTo(item.ItemData, 0);
            item.ID = ushort_0;
            item.MaxLevel = this.ViewingQuest.MaxLevel;
            item.MinLevel = this.ViewingQuest.MinLevel;
            item.MultiQuest = this.ViewingQuest.MultiQuest;
            item.NeedClass = this.ViewingQuest.NeedClass;
            item.NeedLevel = this.ViewingQuest.NeedLevel;
            item.Predesessor = 0;
            item.RewardData = new byte[this.ViewingQuest.RewardData.Length];
            this.ViewingQuest.RewardData.CopyTo(item.RewardData, 0);
            item.StartingNPC = this.ViewingQuest.StartingNPC;
            item.StartScript = this.ViewingQuest.StartScript;
            item.Title = ushort_1;
            foreach (KeyValuePair<byte, byte[]> pair in this.ViewingQuest.dictionary_0)
            {
                byte[] array = new byte[pair.Value.Length];
                pair.Value.CopyTo(array, 0);
                item.dictionary_0.Add(pair.Key, array);
            }
            this.frmMain_0.class2_0.list_0.Add(item);
            this.frmMain_0.method_6("");
            base.Close();
            this.frmMain_0.method_0("Duplicated Quest!");
        }

        public void Dispose(bool disposing)
        {
            if (disposing && (this.icontainer_0 != null))
            {
                this.icontainer_0.Dispose();
            }
            base.Dispose(disposing);
        }

        public Class3 ViewingQuest
        {
            get
            {
                return this.frmMain_0.class3_0;
            }
        }
    }
}

