Пример #1
0
        private void cSaveButton_Click(object sender, EventArgs e)
        {
            if (cCodeName128.Text.Length > 0 &&
                cWorldList.SelectedIndex > -1 &&
                cRegionID.Text.Length > 0 &&
                cPosX.Text.Length > 0 &&
                cPosY.Text.Length > 0 &&
                cPosZ.Text.Length > 0 &&
                cGenAreaRadius.Text.Length > 0 &&
                cBindInteractionMask.Text.Length > 0 &&
                cFixedService.Text.Length > 0)
            {
                if (MessageBox.Show("Are you sure that you want to save changes to database?", "WARNING!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (SelectedTeleport.m_Status == EditStatus.New)
                    {
                        if (CTeleport.IsExistsTeleport(cCodeName128.Text))
                        {
                            MessageBox.Show("A Teleport already exists with that codename, try again!", "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }

                    SelectedTeleport.m_Service               = cService.Checked ? 1 : 0;
                    SelectedTeleport.m_CodeName128           = cCodeName128.Text.Trim();
                    SelectedTeleport.m_AssocRefObjCodeName   = cAssocObjectName.Text.Length > 0 ? cAssocObjectName.Text : "xxx";
                    SelectedTeleport.m_ZoneName128           = cZoneName128.Text.Length > 0 ? cZoneName128.Text : "xxx";
                    SelectedTeleport.m_GenWorldID            = (short)Globals.GameWorldIDList[cWorldList.SelectedItem.ToString()];
                    SelectedTeleport.m_GenRegionID           = Convert.ToInt16(cRegionID.Text);
                    SelectedTeleport.m_GenPos_X              = Convert.ToInt16(cPosX.Text);
                    SelectedTeleport.m_GenPos_Y              = Convert.ToInt16(cPosY.Text);
                    SelectedTeleport.m_GenPos_Z              = Convert.ToInt16(cPosZ.Text);
                    SelectedTeleport.m_GenAreaRadius         = Convert.ToInt16(cGenAreaRadius.Text);
                    SelectedTeleport.m_BindInteractionMask   = Convert.ToByte(cBindInteractionMask.Text);
                    SelectedTeleport.m_FixedService          = Convert.ToByte(cFixedService.Text);
                    SelectedTeleport.m_CanBeResurrectPos     = cCanBeReturnPoint.Checked;
                    SelectedTeleport.m_CanBeGotoResurrectPos = cCanGoResurrectPoint.Checked;

                    if (SelectedTeleport.m_Status != EditStatus.New)
                    {
                        SelectedTeleport.m_Status = EditStatus.Edited;
                    }

                    SelectedTeleport.SaveToDatabase();
                    cID.Text = SelectedTeleport.m_ID.ToString();
                    CTeleportBase.SaveToClient("teleportdata.txt");
                    MessageBox.Show("Your changes is successfully saved!", "NOTICE", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("All fields cannot be empty!", "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private void cSaveButton_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure that you want to save changes to database?", "WARNING!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                List <DataGridViewRow> rows = _linkgrid.Rows.Cast <DataGridViewRow>().ToList();
                _ = rows.Concat(RemovedRows).ToList();

                rows.ForEach(linkRow =>
                {
                    CTeleportLink link = new CTeleportLink();

                    link.m_Service               = bool.Parse(linkRow.Cells[0].Value.ToString()) ? 1 : 0;
                    link.m_OwnerTeleport         = linkRow.Cells[1].Value.ToString();
                    link.m_TargetTeleport        = linkRow.Cells[2].Value.ToString();
                    link.m_Fee                   = Convert.ToInt32(linkRow.Cells[3].Value.ToString());
                    link.m_RestrictBindMethod    = 0;
                    link.m_RunTimeTeleportMethod = 0;
                    link.m_ChectResult           = 0;

                    link.Restrict1 = new STeleportRestrict(GetRestrictType(linkRow.Cells[4].Value.ToString()),
                                                           Convert.ToInt32(linkRow.Cells[5].Value.ToString()),
                                                           Convert.ToInt32(linkRow.Cells[6].Value.ToString()));
                    link.Restrict2 = new STeleportRestrict(GetRestrictType(linkRow.Cells[7].Value.ToString()),
                                                           Convert.ToInt32(linkRow.Cells[8].Value.ToString()),
                                                           Convert.ToInt32(linkRow.Cells[9].Value.ToString()));
                    link.Restrict3 = new STeleportRestrict(GetRestrictType(linkRow.Cells[10].Value.ToString()),
                                                           Convert.ToInt32(linkRow.Cells[11].Value.ToString()),
                                                           Convert.ToInt32(linkRow.Cells[12].Value.ToString()));
                    link.Restrict4 = new STeleportRestrict(GetRestrictType(linkRow.Cells[13].Value.ToString()),
                                                           Convert.ToInt32(linkRow.Cells[14].Value.ToString()),
                                                           Convert.ToInt32(linkRow.Cells[15].Value.ToString()));
                    link.Restrict5 = new STeleportRestrict(GetRestrictType(linkRow.Cells[16].Value.ToString()),
                                                           Convert.ToInt32(linkRow.Cells[17].Value.ToString()),
                                                           Convert.ToInt32(linkRow.Cells[18].Value.ToString()));

                    link.m_Status = (EditStatus)linkRow.Tag;

                    link.SaveToDatabase();

                    if ((EditStatus)linkRow.Tag != EditStatus.Removed)
                    {
                        linkRow.Cells[1].ReadOnly = true;
                        linkRow.Cells[2].ReadOnly = true;
                        linkRow.Tag = EditStatus.Notr;
                    }
                });

                RemovedRows.Clear();
                CTeleportBase.SaveToClient("teleportlink.txt");
                MessageBox.Show("Your changes is successfully saved!", "NOTICE", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #3
0
 private void cRemoveButton_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show($"Are you sure that you want to permamently delete {cCodeName128.Text} portal?", "WARNING!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         SelectedTeleport.m_Status = EditStatus.Removed;
         SelectedTeleport.SaveToDatabase();
         ClearControls();
         cPortalList.Items.Remove(SelectedTeleport.m_CodeName128);
         CTeleportBase.SaveToClient("teleportdata.txt");
         CTeleportBase.SaveToClient("teleportlink.txt");
         ChangeStatus(false);
     }
 }
Пример #4
0
        private void cSaveButton_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure that you want to save changes to database?", "WARNING!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                List <DataGridViewRow> rows = cTpGrid.Rows.Cast <DataGridViewRow>().ToList();
                _ = rows.Concat(RemovedRows).ToList();

                rows.ForEach(row =>
                {
                    COptionalTeleport tp = new COptionalTeleport();

                    tp.m_Service       = bool.Parse(row.Cells[0].Value.ToString()) ? (byte)1 : (byte)0;
                    tp.m_ID            = Convert.ToInt32(row.Cells[1].Value);
                    tp.m_ObjName128    = row.Cells[2].Value.ToString();
                    tp.m_ZoneName128   = row.Cells[3].Value.ToString();
                    tp.m_GenRegionID   = Convert.ToInt16(row.Cells[4].Value);
                    tp.m_GenPos_X      = Convert.ToInt16(row.Cells[5].Value);
                    tp.m_GenPos_Y      = Convert.ToInt16(row.Cells[6].Value);
                    tp.m_GenPos_Z      = Convert.ToInt16(row.Cells[7].Value);
                    tp.m_GenWorldID    = (short)Globals.GameWorldIDList[row.Cells[8].Value.ToString()];
                    tp.m_RegionIDGroup = Convert.ToInt32(row.Cells[9].Value);
                    tp.m_MapPoint      = bool.Parse(row.Cells[10].Value.ToString()) ? (byte)1 : (byte)0;
                    tp.m_LevelMin      = Convert.ToInt16(row.Cells[11].Value);
                    tp.m_LevelMax      = Convert.ToInt16(row.Cells[12].Value);
                    tp.m_Status        = (EditStatus)row.Tag;

                    if (tp.m_Status == EditStatus.New)
                    {
                        tp.m_ID = row.Index;
                    }

                    tp.SaveToDatabase();

                    if ((EditStatus)row.Tag != EditStatus.Removed)
                    {
                        row.Tag            = EditStatus.Notr;
                        row.Cells[1].Value = tp.m_ID;
                    }
                });
                RemovedRows.Clear();
                CTeleportBase.SaveToClient("refoptionalteleport.txt");
                MessageBox.Show("Your changes is successfully saved!", "NOTICE", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }