protected override void OnFormClosing(FormClosingEventArgs e)
        {
            if (MobsChoiceOpen != null)
                MobsChoiceOpen.Close();

            MobsChoiceOpen = null;

            base.OnFormClosing(e);
        }
        private void SaveNewbutton_Click(object sender, EventArgs e)
        {
            if (!ValidNPCTemplateData())
                return;

            if (MessageBox.Show("Save this new npctemplate?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {

                try
                {
                    // user clicked yes
                    MySqlDataAdapter NewNPCTemplateVerifdataAdapter = new MySqlDataAdapter();
                    string selectCommand = "select * from npctemplate  where templateid = '" + TemplateIDtextBox.Text.ToString() + "'";
                    // Create a new data adapter based on the specified query.
                    NewNPCTemplateVerifdataAdapter = new MySqlDataAdapter(selectCommand, Util.Connection);
                    // Create a command builder to generate SQL update, insert, and
                    // delete commands based on selectCommand. These are used to
                    // update the database.
                    MySqlCommandBuilder commandBuilderNPCTemplateIDData = new MySqlCommandBuilder(NewNPCTemplateVerifdataAdapter);
                    DataTable NPCTemplateIDData = new DataTable();
                    NPCTemplateIDData.Clear();
                    // Populate a new data table.
                    NPCTemplateIDData.Locale = System.Globalization.CultureInfo.InvariantCulture;
                    NewNPCTemplateVerifdataAdapter.Fill(NPCTemplateIDData);
                    if (NPCTemplateIDData.Rows.Count > 0)
                    {
                        this.TemplateIDtextBox.Text = Util.Find_Free_NPCTemplateID().ToString();
                        MessageBox.Show("The npctemplate was not updated because the template is not anymore free. You need to save your spell again.");
                    }
                    else
                    {

                        long i = 1;
                        foreach (byte b in Guid.NewGuid().ToByteArray())
                        {
                            i *= ((int)b + 1);
                        }
                        i -= DateTime.Now.Ticks;
                        string str = "Dol_Server_Editor_" + i.ToString();

                        DataRow datarow = this.NPCTemplateDatatable.NewRow();

                        datarow["NPCTemplate_ID"] = str;
                        datarow["TemplateID"] = TemplateIDtextBox.Text;
                        datarow["Name"] = NametextBox.Text;
                        datarow["FRName"] = FRNametextBox.Text;
                        datarow["GuildName"] = GuildNametextBox.Text;
                        datarow["Model"] = ModeltextBox.Text;

                        string size = "";

                        if (LowSizenumericUpDown.Value == HightSizenumericUpDown.Value)
                            size = LowSizenumericUpDown.Value.ToString();
                        else
                        {
                            size = LowSizenumericUpDown.Value.ToString() + "-" + HightSizenumericUpDown.Value.ToString();
                        }

                        datarow["Size"] = size;
                        datarow["MaxSpeed"] = MaxSpeedtextBox.Text;
                        datarow["EquipmentTemplateID"] = EquipmentTemplateIDtextBox.Text;

                        uint flagsToSet = 0;
                        if (GhostcheckBox.Checked == true)
                            flagsToSet ^= 0x01;
                        if (StealthcheckBox.Checked == true)
                            flagsToSet ^= 0x02;
                        if (DontShowNamecheckBox.Checked == true)
                            flagsToSet ^= 0x04;
                        if (CantTargetcheckBox.Checked == true)
                            flagsToSet ^= 0x08;
                        if (PeacecheckBox.Checked == true)
                            flagsToSet ^= 0x10;
                        if (FlyingcheckBox.Checked == true)
                            flagsToSet ^= 0x20;
                        if (TorchcheckBox.Checked == true)
                            flagsToSet ^= 0x40;
                        if (StatuecheckBox.Checked == true)
                            flagsToSet ^= 0x80;
                        if (SwimmingcheckBox.Checked == true)
                            flagsToSet ^= 0x100;

                        datarow["Flags"] = flagsToSet;
                        datarow["MeleeDamageType"] = Util.Find_DamageType_Value(MeleeDamageTypecomboBox.Text);
                        datarow["ParryChance"] = ParryChanceNumericUpDown.Value;
                        datarow["EvadeChance"] = EvadeChanceNumericUpDown.Value;
                        datarow["BlockChance"] = BlockChanceNumericUpDown.Value;
                        datarow["LeftHandSwingChance"] = LeftHandSwingChanceNumericUpDown.Value;
                        datarow["Spells"] = SpellsrichTextBox.Text;
                        datarow["Styles"] = StylesrichTextBox.Text;
                        datarow["Strength"] = StrengthtextBox.Text;
                        datarow["Constitution"] = ConstitutiontextBox.Text;
                        datarow["Dexterity"] = DexteritytextBox.Text;
                        datarow["Quickness"] = QuicknesstextBox.Text;
                        datarow["Intelligence"] = IntelligencetextBox.Text;
                        datarow["Piety"] = PietytextBox.Text;
                        datarow["Charisma"] = CharismatextBox.Text;
                        datarow["Empathy"] = EmpathytextBox.Text;
                        datarow["Abilities"] = AbilitiesrichTextBox.Text;
                        datarow["AggroLevel"] = AggroLevelUpDown.Text;
                        datarow["AggroRange"] = AggroRangetextBox.Text;
                        datarow["ClassType"] = ClassTypecomboBox.Text;

                        string level = "";

                        if (LowLevelnumericUpDown.Value == HightLevelnumericUpDown.Value)
                            level = LowLevelnumericUpDown.Value.ToString();
                        else
                        {
                            level = LowLevelnumericUpDown.Value.ToString() + "-" + HightLevelnumericUpDown.Value.ToString();
                        }

                        datarow["Level"] = level;
                        datarow["Race"] = RacecomboBox.SelectedValue != null && RacecomboBox.SelectedText != "None" ? RacecomboBox.SelectedValue : "0";
                        datarow["BodyType"] = Util.Find_BodyType_Value(BodyTypecomboBox.Text);
                        datarow["MaxDistance"] = MaxDistancetextBox.Text;
                        datarow["TetherRange"] = TetherRangetextBox.Text;
                        datarow["PackageID"] = PackageIDtextBox.Text;
                        datarow["VisibleWeaponSlots"] = VisibleWeaponSlotstextBox.Text;
                        datarow["ReplaceMobValues"] = ReplaceMobValuescomboBox.Text;
                        datarow["ItemsListTemplateID"] = ItemsListTemplateIDtextBox.Text;

                        if (DolEditor.Properties.Settings.Default.OriginsSettings)
                            datarow["IsCharmable"] = IsCharmablecomboBox.Text;

                        datarow["TranslationId"] = TranslationIDtextBox.Text;
                        datarow["Suffix"] = SuffixtextBox.Text;
                        datarow["ExamineArticle"] = ExamineArticletextBox.Text;
                        datarow["MessageArticle"] = MessageArticletextBox.Text;
                        datarow["Gender"] = Util.Find_Gender_Value(GendercomboBox.Text);

                        this.NPCTemplateDatatable.Rows.Add(datarow);

                        if (MobsChoiceOpen != null)
                        {
                            MobsChoiceOpen.Close();
                            MobsChoiceOpen = null;
                        }

                        this.Validate();
                        this.NPCTemplatebindingSource.EndEdit();

                        try
                        {
                            NPCTemplatedataAdapter.Update(this.NPCTemplateDatatable);
                        }
                        catch (Exception s)
                        {
                            MessageBox.Show(s.Message);
                        }

                        this.ControlEditor.Hide();
                        this.NPCTemplatedataGridView.Show();
                        this.ControlMenu.Visible = true;
                        this.AddNPCTemplateButton.Visible = true;
                        this.NPCTemplateListingButton.Visible = false;
                        this.SaveNewbutton.Hide();
                        this.flags = 0X00;
                        loaded = false;
                    }

                }
                catch (MySqlException s)
                {
                    MessageBox.Show(s.Message);
                }
            }
        }
        private void SaveLoadedNPCTemplate_Click(object sender, EventArgs e)
        {
            if (!ValidNPCTemplateData())
                return;

            if (MessageBox.Show("Save your modifications?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {

                this.NPCTemplatedataGridView.ReadOnly = false;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["TemplateId"].Value = TemplateIDtextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Name"].Value = NametextBox.Text;

                if (DolEditor.Properties.Settings.Default.OriginsSettings)
                    this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["FRName"].Value = FRNametextBox.Text;

                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["GuildName"].Value = GuildNametextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Model"].Value = ModeltextBox.Text;

                string size = "";

                if (LowSizenumericUpDown.Value == HightSizenumericUpDown.Value)
                    size = LowSizenumericUpDown.Value.ToString();
                else
                {
                    size = LowSizenumericUpDown.Value.ToString() + "-" + HightSizenumericUpDown.Value.ToString();
                }
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Size"].Value = size;

                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["MaxSpeed"].Value = MaxSpeedtextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["EquipmentTemplateID"].Value = EquipmentTemplateIDtextBox.Text;

                uint flagsToSet = 0;

                if (GhostcheckBox.Checked == true)
                    flagsToSet ^= 0x01;
                if (StealthcheckBox.Checked == true)
                    flagsToSet ^= 0x02;
                if (DontShowNamecheckBox.Checked == true)
                    flagsToSet ^= 0x04;
                if (CantTargetcheckBox.Checked == true)
                    flagsToSet ^= 0x08;
                if (PeacecheckBox.Checked == true)
                    flagsToSet ^= 0x10;
                if (FlyingcheckBox.Checked == true)
                    flagsToSet ^= 0x20;
                if (TorchcheckBox.Checked == true)
                    flagsToSet ^= 0x40;
                if (StatuecheckBox.Checked == true)
                    flagsToSet ^= 0x80;
                if (SwimmingcheckBox.Checked == true)
                    flagsToSet ^= 0x100;

                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Flags"].Value = flagsToSet;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["MeleeDamageType"].Value = Util.Find_DamageType_Value(MeleeDamageTypecomboBox.Text);
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["ParryChance"].Value = ParryChanceNumericUpDown.Value;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["EvadeChance"].Value = EvadeChanceNumericUpDown.Value;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["BlockChance"].Value = BlockChanceNumericUpDown.Value;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["LeftHandSwingChance"].Value = LeftHandSwingChanceNumericUpDown.Value;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Spells"].Value = SpellsrichTextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Styles"].Value = StylesrichTextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Strength"].Value = StrengthtextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Constitution"].Value = ConstitutiontextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Dexterity"].Value = DexteritytextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Quickness"].Value = QuicknesstextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Intelligence"].Value = IntelligencetextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Piety"].Value = PietytextBox.Text;

                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Charisma"].Value = CharismatextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Empathy"].Value = EmpathytextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Abilities"].Value = AbilitiesrichTextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["AggroLevel"].Value = AggroLevelUpDown.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["AggroRange"].Value = AggroRangetextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["ClassType"].Value = ClassTypecomboBox.Text;

                string level = "";

                if (LowLevelnumericUpDown.Value == HightLevelnumericUpDown.Value)
                    level = LowLevelnumericUpDown.Value.ToString();
                else
                {
                    level = LowLevelnumericUpDown.Value.ToString() + "-" + HightLevelnumericUpDown.Value.ToString();
                }

                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Level"].Value = level;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Race"].Value = RacecomboBox.SelectedValue != null && RacecomboBox.SelectedText != "None" ? RacecomboBox.SelectedValue : "0";
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["BodyType"].Value = Util.Find_BodyType_Value(BodyTypecomboBox.Text);
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["MaxDistance"].Value = MaxDistancetextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["TetherRange"].Value = TetherRangetextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["PackageID"].Value = PackageIDtextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["VisibleWeaponSlots"].Value = VisibleWeaponSlotstextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["ReplaceMobValues"].Value = ReplaceMobValuescomboBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["ItemsListTemplateID"].Value = ItemsListTemplateIDtextBox.Text;

                if (DolEditor.Properties.Settings.Default.OriginsSettings)
                    this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["IsCharmable"].Value = IsCharmablecomboBox.Text;

                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["TranslationId"].Value = TranslationIDtextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Suffix"].Value = SuffixtextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["ExamineArticle"].Value = ExamineArticletextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["MessageArticle"].Value = MessageArticletextBox.Text;
                this.NPCTemplatedataGridView.Rows[NPCTemplatedataGridView.CurrentCell.RowIndex].Cells["Gender"].Value = Util.Find_Gender_Value(GendercomboBox.Text);

                if (MobsChoiceOpen != null)
                {
                    MobsChoiceOpen.Close();
                    MobsChoiceOpen = null;
                }

                this.Validate();
                this.NPCTemplatebindingSource.EndEdit();

                try
                {
                    NPCTemplatedataAdapter.Update(this.NPCTemplateDatatable);
                }
                catch (MySqlException s)
                {
                    MessageBox.Show(s.Message);
                }

                this.NPCTemplatedataGridView.ReadOnly = true;
                this.Savebutton.Hide();
                this.SaveNewbutton.Hide();
                this.NPCTemplateListingButton.Visible = false;
                this.AddNPCTemplateButton.Visible = true;
                this.ControlMenu.Visible = true;
                this.NPCTemplatedataGridView.Show();
                this.flags = 0X00;
                loaded = false;
            }
        }
        private void NPCTemplateListing_Click(object sender, EventArgs e)
        {
            if (MobsChoiceOpen != null)
            {
                MobsChoiceOpen.Close();
                MobsChoiceOpen = null;
            }

            this.flags = 0X00;
            this.Savebutton.Hide();
            this.SaveNewbutton.Hide();
            this.NPCTemplateListingButton.Visible = false;
            this.AddNPCTemplateButton.Visible = true;
            this.ControlMenu.Visible = true;
            this.ControlEditor.Hide();
            this.NPCTemplatedataGridView.Show();
            loaded = false;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (ModeltextBox.Text == null)
                ModeltextBox.Text = "";

            if (MobsChoiceOpen != null)
            {
                MobsChoiceOpen.StartPosition = FormStartPosition.CenterScreen;
                MobsChoiceOpen.TopMost = true;
                MobsChoiceOpen.Show();
            }
            else
            {

                MobsModelChoice fm = new MobsModelChoice(this, ModeltextBox);
                MobsChoiceOpen = fm;
                fm.TopMost = true;
                fm.Show();
            }
        }
Exemplo n.º 6
0
        private void SaveNewbutton_Click(object sender, EventArgs e)
        {
            if (!ValidMobData())
                return;

            if (MessageBox.Show("Save this new mob?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {

                try
                {

                        long i = 1;
                        foreach (byte b in Guid.NewGuid().ToByteArray())
                        {
                            i *= ((int)b + 1);
                        }
                        i -= DateTime.Now.Ticks;
                        string str = "Dol_Server_Editor_" + i.ToString();

                        DataRow datarow = this.MobDatatable.NewRow();

                        datarow["Mob_ID"] = str;
                        datarow["ClassType"] = ClassTypecomboBox.Text;
                        datarow["Name"] = NametextBox.Text;

                        if (DolEditor.Properties.Settings.Default.OriginsSettings)
                            datarow["FRName"] = FRNametextBox.Text;

                        datarow["Guild"] = GuildtextBox.Text;
                        datarow["X"] = XtextBox.Text;
                        datarow["Y"] = YtextBox.Text;
                        datarow["Z"] = ZtextBox.Text;
                        datarow["Speed"] = SpeedtextBox.Text;
                        datarow["Heading"] = HeadingtextBox.Text;
                        datarow["Region"] = RegiontextBox.Text;
                        datarow["Model"] = ModeltextBox.Text;
                        datarow["Size"] = SizenumericUpDown.Value;
                        datarow["Level"] =  LevelnumericUpDown.Value;
                        datarow["Realm"] = Util.Find_Realm_Value(RealmcomboBox.Text);
                        datarow["EquipmentTemplateID"] = EquipmentTemplateIDtextBox.Text;
                        datarow["ItemsListTemplateID"] = ItemsListTemplateIDtextBox.Text;

                        uint flagsToSet = 0;
                        if (GhostcheckBox.Checked == true)
                            flagsToSet ^= 0x01;
                        if (StealthcheckBox.Checked == true)
                            flagsToSet ^= 0x02;
                        if (DontShowNamecheckBox.Checked == true)
                            flagsToSet ^= 0x04;
                        if (CantTargetcheckBox.Checked == true)
                            flagsToSet ^= 0x08;
                        if (PeacecheckBox.Checked == true)
                            flagsToSet ^= 0x10;
                        if (FlyingcheckBox.Checked == true)
                            flagsToSet ^= 0x20;
                        if (TorchcheckBox.Checked == true)
                            flagsToSet ^= 0x40;
                        if (StatuecheckBox.Checked == true)
                            flagsToSet ^= 0x80;
                        if (SwimmingcheckBox.Checked == true)
                            flagsToSet ^= 0x100;

                        datarow["Flags"] = flagsToSet;
                        datarow["AggroLevel"] = AggroLevelUpDown.Text;
                        datarow["AggroRange"] = AggroRangeNumericUpDown.Text;
                        datarow["MeleeDamageType"] = Util.Find_DamageType_Value(MeleeDamageTypecomboBox.Text);
                        datarow["RespawnInterval"] = RespawnIntervalnumericUpDown.Value;
                        datarow["FactionID"] = FactioncomboBox.SelectedValue;
                        datarow["NPCTemplateID"] = NPCTemplatecomboBox.SelectedValue;
                        datarow["Race"] = RacecomboBox.SelectedValue != null && RacecomboBox.SelectedText != "None" ? RacecomboBox.SelectedValue : "0";
                        datarow["BodyType"] = Util.Find_BodyType_Value(BodyTypecomboBox.Text);
                        datarow["HouseNumber"] = HouseNumbertextBox.Text;
                        datarow["Brain"] = BraincomboBox.Text;

                        datarow["MaxDistance"] = MaxDistancetextBox.Text;
                        datarow["OwnerID"] = OwnerIDtextBox.Text;
                        datarow["Strength"] = StrengthtextBox.Text;
                        datarow["Constitution"] = ConstitutiontextBox.Text;
                        datarow["Dexterity"] = DexteritytextBox.Text;
                        datarow["Quickness"] = QuicknesstextBox.Text;
                        datarow["Intelligence"] = IntelligencetextBox.Text;
                        datarow["Piety"] = PietytextBox.Text;
                        datarow["Charisma"] = CharismatextBox.Text;
                        datarow["Empathy"] = EmpathytextBox.Text;
                        datarow["PackageID"] = PackageIDtextBox.Text;
                        datarow["RoamingRange"] = RoamingnumericUpDown.Value;
                        datarow["IsCloakHoodUp"] = Util.Find_Bool_Value(IsCloakHoodUpcomboBox.Text);
                        datarow["Gender"] = GendercomboBox.SelectedIndex;
                        datarow["VisibleWeaponSlots"] = VisibleWeaponSlotstextBox.Text;

                        if (DolEditor.Properties.Settings.Default.OriginsSettings)
                            datarow["IsCharmable"] = Util.Find_Bool_Value(IsCharmablecomboBox.Text);

                        datarow["TranslationId"] = TranslationIDtextBox.Text;
                        datarow["Suffix"] = SuffixtextBox.Text;
                        datarow["ExamineArticle"] = ExamineArticletextBox.Text;
                        datarow["MessageArticle"] = MessageArticletextBox.Text;

                        this.MobDatatable.Rows.Add(datarow);

                        if (MobsChoiceOpen != null)
                        {
                            MobsChoiceOpen.Close();
                            MobsChoiceOpen = null;
                        }

                        this.Validate();
                        this.MobbindingSource.EndEdit();

                        try
                        {
                            MobdataAdapter.Update(this.MobDatatable);
                        }
                        catch (Exception s)
                        {
                            MessageBox.Show(s.Message);
                        }

                        this.ControlEditor.Hide();
                        this.MobdataGridView.Show();
                        this.ControlMenu.Visible = true;
                        this.AddMobButton.Visible = true;
                        this.MobListingButton.Visible = false;
                        this.SaveNewbutton.Hide();
                        this.flags = 0X00;
                }
                catch (MySqlException s)
                {
                    MessageBox.Show(s.Message);
                }
            }
        }
Exemplo n.º 7
0
        private void SaveLoadedNPCTemplate_Click(object sender, EventArgs e)
        {
            if (!ValidMobData())
                return;

            if (MessageBox.Show("Save your modifications?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {

                this.MobdataGridView.ReadOnly = false;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["ClassType"].Value = ClassTypecomboBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Name"].Value = NametextBox.Text;

                if (DolEditor.Properties.Settings.Default.OriginsSettings)
                    this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["FRName"].Value = NametextBox.Text;

                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Guild"].Value = GuildtextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["X"].Value = XtextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Y"].Value = YtextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Z"].Value = ZtextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Speed"].Value = SpeedtextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Heading"].Value = HeadingtextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Region"].Value = RegiontextBox.Text;

                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Model"].Value = ModeltextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Size"].Value = SizenumericUpDown.Value;

                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Level"].Value = LevelnumericUpDown.Value;

                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Realm"].Value = Util.Find_Realm_Value(RealmcomboBox.Text);
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["EquipmentTemplateID"].Value = EquipmentTemplateIDtextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["ItemsListTemplateID"].Value = ItemsListTemplateIDtextBox.Text;

                uint flagsToSet = 0;

                if (GhostcheckBox.Checked == true)
                    flagsToSet ^= 0x01;
                if (StealthcheckBox.Checked == true)
                    flagsToSet ^= 0x02;
                if (DontShowNamecheckBox.Checked == true)
                    flagsToSet ^= 0x04;
                if (CantTargetcheckBox.Checked == true)
                    flagsToSet ^= 0x08;
                if (PeacecheckBox.Checked == true)
                    flagsToSet ^= 0x10;
                if (FlyingcheckBox.Checked == true)
                    flagsToSet ^= 0x20;
                if (TorchcheckBox.Checked == true)
                    flagsToSet ^= 0x40;
                if (StatuecheckBox.Checked == true)
                    flagsToSet ^= 0x80;
                if (SwimmingcheckBox.Checked == true)
                    flagsToSet ^= 0x100;

                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Flags"].Value = flagsToSet;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["AggroLevel"].Value = AggroLevelUpDown.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["AggroRange"].Value = AggroRangeNumericUpDown.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["MeleeDamageType"].Value = Util.Find_DamageType_Value(MeleeDamageTypecomboBox.Text);

                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["RespawnInterval"].Value = RespawnIntervalnumericUpDown.Value;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["FactionID"].Value = FactioncomboBox.SelectedValue;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["NPCTemplateID"].Value = NPCTemplatecomboBox.SelectedValue;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Race"].Value = RacecomboBox.SelectedValue != null && RacecomboBox.SelectedText != "None" ? RacecomboBox.SelectedValue : "0";
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["BodyType"].Value = Util.Find_BodyType_Value(BodyTypecomboBox.Text);
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["HouseNumber"].Value = HouseNumbertextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Brain"].Value = BraincomboBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["PathID"].Value = PathIDtextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["MaxDistance"].Value = MaxDistancetextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["OwnerID"].Value = OwnerIDtextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Strength"].Value = StrengthtextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Constitution"].Value = ConstitutiontextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Dexterity"].Value = DexteritytextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Quickness"].Value = QuicknesstextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Intelligence"].Value = IntelligencetextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Piety"].Value = PietytextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Charisma"].Value = CharismatextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Empathy"].Value = EmpathytextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["PackageID"].Value = PackageIDtextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["RoamingRange"].Value = RoamingnumericUpDown.Value;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["IsCloakHoodUp"].Value = Util.Find_Bool_Value(IsCloakHoodUpcomboBox.Text);
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Gender"].Value = GendercomboBox.SelectedIndex;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["VisibleWeaponSlots"].Value = VisibleWeaponSlotstextBox.Text;

                if (DolEditor.Properties.Settings.Default.OriginsSettings)
                    this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["IsCharmable"].Value = Util.Find_Bool_Value(IsCharmablecomboBox.Text);

                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["TranslationId"].Value = TranslationIDtextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["Suffix"].Value = SuffixtextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["ExamineArticle"].Value = ExamineArticletextBox.Text;
                this.MobdataGridView.Rows[MobdataGridView.CurrentCell.RowIndex].Cells["MessageArticle"].Value = MessageArticletextBox.Text;

                if (MobsChoiceOpen != null)
                {
                    MobsChoiceOpen.Close();
                    MobsChoiceOpen = null;
                }

                this.Validate();
                this.MobbindingSource.EndEdit();

                try
                {
                    MobdataAdapter.Update(this.MobDatatable);
                }
                catch (MySqlException s)
                {
                    MessageBox.Show(s.Message);
                }

                this.MobdataGridView.ReadOnly = true;
                this.Savebutton.Hide();
                this.SaveNewbutton.Hide();
                this.MobListingButton.Visible = false;
                this.AddMobButton.Visible = true;
                this.ControlMenu.Visible = true;
                this.MobdataGridView.Show();
                this.flags = 0X00;
            }
        }