Beispiel #1
0
        private void ButtonXAddCtrlClick(object sender, EventArgs e)
        {
            if (AI == null)
            {
                MessageBox.Show(Resources.openAIPolicy + Resources.AddCtrl);
                return;
            }
            if (AI != null && textBoxX_CtrlID.Text != "")
            {
                var acCount = AI.ActionControllerCount;
                if (!Program.IsNumber(textBoxX_CtrlID.Text))
                {
                    MessageBox.Show(Resources.NoNumCtrl);
                    return;
                }
                var ctrlID = Convert.ToInt32(textBoxX_CtrlID.Text);
                for (var i = 0; i < acCount; i++)
                {
                    if (ctrlID != AI.ActionController[i].ID || ctrlID <= 0) continue;
                    MessageBox.Show(Resources.CtrlExists);
                    return;
                }
                acCount++;
                var aIPolicy = new AIPolicy();
                aIPolicy.Signature = 0;
                aIPolicy.ActionControllerCount = acCount;
                aIPolicy.ActionController = new ActionController[acCount];

                for (var j = 0; j < aIPolicy.ActionController.Length - 1; j++)
                {
                    aIPolicy.ActionController[j] = AI.ActionController[j];
                    aIPolicy.ActionController[j].Signature = AI.ActionController[j].Signature;
                    aIPolicy.ActionController[j].ID = AI.ActionController[j].ID;
                    aIPolicy.ActionController[j].ActionSetsCount = AI.ActionController[j].ActionSetsCount;
                    aIPolicy.ActionController[j].ActionSet = AI.ActionController[j].ActionSet;
                }
                AI = aIPolicy;
                AI.ActionController[acCount - 1] = new ActionController();
                AI.ActionController[acCount - 1].Signature = 0;
                AI.ActionController[acCount - 1].ActionSetsCount = 0;
                AI.ActionController[acCount - 1].ActionSet = new ActionSet[aIPolicy.ActionController[acCount - 1].ActionSetsCount];
                AI.ActionController[acCount - 1].ID = ctrlID;
                listBox_Controller.Items.Clear();

                for (var k = 0; k < AI.ActionControllerCount; k++)
                {
                    var iD = AI.ActionController[k].ID;
                    listBox_Controller.Items.Add(iD.ToString(CultureInfo.InvariantCulture));
                }
                listBox_ActionSet.Items.Clear();
                textBoxX_Condition.Clear();
                listBox_Procedure.Items.Clear();
            }
            MessageBox.Show(Resources.CtrlIDwith + textBoxX_CtrlID.Text + Resources.beenAdded);
        }
Beispiel #2
0
        private void ButtonXDelCtrlClick(object sender, EventArgs e)
        {
            if (AI == null)
            {
                MessageBox.Show(Resources.openAIPolicy + Resources.DelCtrl);
                return;
            }

            if (SafeMode && MessageBox.Show(Resources.sureDelete + Resources.ACtrl + textBoxX_CtrlID.Text +
                        Resources.QMark, Resources.DelACtrl, MessageBoxButtons.YesNo) == DialogResult.No) return;

            if (AI != null && textBoxX_CtrlID.Text != "")
            {
                var actionControllerCount = AI.ActionControllerCount;
                var ctrlID = -1;
                if (!Program.IsNumber(textBoxX_CtrlID.Text))
                {
                    MessageBox.Show(Resources.NoNumCtrl);
                    return;
                }
                var delCtrlID = Convert.ToInt32(textBoxX_CtrlID.Text);
                
                for (var i = 0; i < actionControllerCount; i++)
                    if (delCtrlID == AI.ActionController[i].ID) ctrlID = i;
                
                if (ctrlID < 0)
                {
                    MessageBox.Show(Resources.CtrlNoExist);
                    return;
                }
                var aIPolicy = new AIPolicy();
                aIPolicy.Signature = 0;
                aIPolicy.ActionControllerCount = actionControllerCount - 1;
                var aIPolicy2 = aIPolicy;
                aIPolicy2.ActionController = new ActionController[aIPolicy2.ActionControllerCount];

                for (var j = 0; j < aIPolicy.ActionController.Length; j++)
                {
                    if (j < ctrlID) aIPolicy.ActionController[j] = AI.ActionController[j];
                    if (j >= ctrlID) aIPolicy.ActionController[j] = AI.ActionController[j + 1];

                }
                AI = aIPolicy;
                listBox_Controller.Items.Clear();

                for (var k = 0; k < AI.ActionControllerCount; k++)
                {
                    var iD = AI.ActionController[k].ID;
                    listBox_Controller.Items.Add(iD.ToString(CultureInfo.InvariantCulture));
                }
                listBox_ActionSet.Items.Clear();
                textBoxX_Condition.Clear();
                listBox_Procedure.Items.Clear();
            }
            MessageBox.Show(Resources.CtrlIDwith + textBoxX_CtrlID.Text + Resources.beenDel);
        }
Beispiel #3
0
        //**********************************************

        private void ButtonItemOpenClick(object sender, EventArgs e)
        {
            using (var openFileDialog = new OpenFileDialog { Filter = Resources.AIPolicyFilter })
            {
                if (openFileDialog.ShowDialog() != DialogResult.OK || !File.Exists(openFileDialog.FileName)) return;
                try
                {
                    Cursor = Cursors.WaitCursor;
                    listBox_Controller.Items.Clear();
                    listBox_ActionSet.Items.Clear();
                    textBoxX_Condition.Clear();
                    listBox_Procedure.Items.Clear();
                    using (var fileStream = File.OpenRead(openFileDialog.FileName))
                    {
                        using (var binaryReader = new BinaryReader(fileStream))
                        {
                            AI = new AIPolicy();
                            AI.Signature = binaryReader.ReadInt32();
                            AI.ActionControllerCount = binaryReader.ReadInt32();
                            AI.ActionController = new ActionController[AI.ActionControllerCount];
                            for (var i = 0; i < AI.ActionController.Length; i++)
                            {
                                if (i == 1818)
                                {
                                    
                                }
                                AI.ActionController[i] = new ActionController();
                                AI.ActionController[i].Signature = binaryReader.ReadInt32();
                                AI.ActionController[i].ID = binaryReader.ReadInt32();
                                AI.ActionController[i].ndx = AI.ActionController[i].ID;
                                AI.ActionController[i].ActionSetsCount = binaryReader.ReadInt32();
                                AI.ActionController[i].ActionSet = new ActionSet[AI.ActionController[i].ActionSetsCount];
                                var iD = AI.ActionController[i].ID;
                                listBox_Controller.Items.Add(iD.ToString(CultureInfo.InvariantCulture));

                                for (var j = 0; j < AI.ActionController[i].ActionSet.Length; j++)
                                {
                                    AI.ActionController[i].ActionSet[j] = new ActionSet();
                                    AI.ActionController[i].ActionSet[j].Version = binaryReader.ReadInt32();
                                    var version = AI.ActionController[i].ActionSet[j].Version;
                                    AI.ActionController[i].ActionSet[j].ID = binaryReader.ReadInt32();
                                    AI.ActionController[i].ActionSet[j].Flags = binaryReader.ReadBytes(3);
                                    AI.ActionController[i].ActionSet[j].ActionSetName = binaryReader.ReadBytes(128);

                                    // Jade Dynasty
                                    if (JDSelected)
                                    {
                                        AI.ActionController[i].ActionSet[j].Condition = LoadCondition(binaryReader);
                                        AI.ActionController[i].ActionSet[j].ProcedureCount = binaryReader.ReadInt32();
                                        AI.ActionController[i].ActionSet[j].Procedure = new Procedure[AI.ActionController[i].ActionSet[j].ProcedureCount];

                                        for (var k = 0; k < AI.ActionController[i].ActionSet[j].Procedure.Length; ++k)
                                        {
                                            AI.ActionController[i].ActionSet[j].Procedure[k] = new Procedure { Type = binaryReader.ReadInt32() };
                                            var procedure = AI.ActionController[i].ActionSet[j].Procedure[k];
                                            var mainWindow = this;
                                            var type = mainWindow.AI.ActionController[i].ActionSet[j].Procedure[k].Type;
                                            var br2 = binaryReader;
                                            var ver = version;
                                            var objArray = mainWindow.JDReadParameters(type, br2, ver);
                                            procedure.Parameter = objArray;
                                            AI.ActionController[i].ActionSet[j].Procedure[k].Target = binaryReader.ReadInt32();
                                        }
                                    }
                                    // Perfect World
                                    else if (PWSelected)
                                    {
                                        AI.ActionController[i].ActionSet[j].Condition = LoadCondition(binaryReader);
                                        AI.ActionController[i].ActionSet[j].ProcedureCount = binaryReader.ReadInt32();
                                        AI.ActionController[i].ActionSet[j].Procedure = new Procedure[AI.ActionController[i].ActionSet[j].ProcedureCount];

                                        for (var k = 0; k < AI.ActionController[i].ActionSet[j].Procedure.Length; ++k)
                                        {
                                            AI.ActionController[i].ActionSet[j].Procedure[k] = new Procedure();
                                            AI.ActionController[i].ActionSet[j].Procedure[k].Type = binaryReader.ReadInt32();
                                            AI.ActionController[i].ActionSet[j].Procedure[k].Parameter = PWReadParameters(AI.ActionController[i].ActionSet[j].Procedure[k].Type, binaryReader);
                                            AI.ActionController[i].ActionSet[j].Procedure[k].Target = binaryReader.ReadInt32();
                                            if (AI.ActionController[i].ActionSet[j].Procedure[k].Target == 6)
                                            {
                                                AI.ActionController[i].ActionSet[j].Procedure[k].TargetParams = PWReadTargetParameters(AI.ActionController[i].ActionSet[j].Procedure[k].Target, binaryReader);
                                            }
                                        }
                                    }
                                    // Forsaken World
                                    else if (FWSelected)
                                    {
                                        AI.ActionController[i].ActionSet[j].Condition = LoadCondition(binaryReader);
                                        AI.ActionController[i].ActionSet[j].ProcedureCount = binaryReader.ReadInt32();
                                        AI.ActionController[i].ActionSet[j].Procedure = new Procedure[AI.ActionController[i].ActionSet[j].ProcedureCount];

                                        for (var k = 0; k < AI.ActionController[i].ActionSet[j].Procedure.Length; k++)
                                        {
                                            AI.ActionController[i].ActionSet[j].Procedure[k] = new Procedure();
                                            AI.ActionController[i].ActionSet[j].Procedure[k].Type = binaryReader.ReadInt32();
                                            AI.ActionController[i].ActionSet[j].Procedure[k].Parameter =
                                                FWReadParameters(AI.ActionController[i].ActionSet[j].Procedure[k].Type, binaryReader);
                                            AI.ActionController[i].ActionSet[j].Procedure[k].Target = binaryReader.ReadInt32();
                                        }
                                    }
                                }
                            }
                            binaryReader.Dispose();
                        }
                        fileStream.Dispose();
                    }
                    Cursor = Cursors.Default;
                    openFileDialog.Dispose();
                }
                catch (Exception ex)
                {
                    Cursor = Cursors.Default;
                    MessageBox.Show(Resources.ErrFileLoad + ex.Message);
                }
            }
        }