Esempio n. 1
0
        public override void Undo(BHAV bhav, UIBHAVEditor editor)
        {
            var tree = editor.GetSavableTree();

            if (TrueBranch)
            {
                if (InstUI.Instruction != null)
                {
                    InstUI.Instruction.TruePointer = (OldDestUI == null) ? (byte)253 : OldDestUI.InstPtr;
                }
                InstUI.TrueUI = OldDestUI;
                InstUI.TreeBox.TruePointer = (OldDestUI == null) ? (short)-1 : OldDestUI.TreeBox.InternalID;
            }
            else
            {
                if (InstUI.Instruction != null)
                {
                    InstUI.Instruction.FalsePointer = (OldDestUI == null) ? (byte)253 : OldDestUI.InstPtr;
                }
                InstUI.FalseUI = OldDestUI;
                InstUI.TreeBox.FalsePointer = (OldDestUI == null) ? (short)-1 : OldDestUI.TreeBox.InternalID;
            }

            if (InstUI.Type == TREEBoxType.Label)
            {
                editor.BHAVView.UpdateLabelPointers(InstUI.TreeBox.InternalID);
            }

            Content.Content.Get().Changes.ChunkChanged(bhav);
            FSO.SimAntics.VM.BHAVChanged(bhav);
            Content.Content.Get().Changes.ChunkChanged(tree);
        }
Esempio n. 2
0
        public override void Undo(BHAV bhav, UIBHAVEditor editor)
        {
            var tree = editor.GetSavableTree();

            if (NewPrimitive.Type != TREEBoxType.Primitive)
            {
                if (NewPrimitive.TreeBox.InternalID != -1)
                {
                    tree.DeleteBox(NewPrimitive.TreeBox);
                }
                editor.BHAVView.Primitives.Remove(NewPrimitive);
                editor.BHAVView.Remove(NewPrimitive);
            }
            else
            {
                //primitive we added should be at the end
                var newInst = new BHAVInstruction[bhav.Instructions.Length - 1];
                for (int i = 0; i < newInst.Length; i++)
                {
                    newInst[i] = bhav.Instructions[i];
                }

                bhav.Instructions = newInst;
                editor.BHAVView.RemovePrimitive(NewPrimitive);
                Content.Content.Get().Changes.ChunkChanged(bhav);
                FSO.SimAntics.VM.BHAVChanged(bhav);
            }
            Content.Content.Get().Changes.ChunkChanged(tree);
        }
Esempio n. 3
0
        public override void Undo(BHAV bhav, UIBHAVEditor editor)
        {
            var tree = editor.GetSavableTree();

            Box.SetComment(OldComment);
            Box.ApplyBoxPositionCentered();
            NotifyGotos();
            Content.Content.Get().Changes.ChunkChanged(tree);
        }
        public override void Execute(BHAV bhav, UIBHAVEditor editor)
        {
            var tree = editor.GetSavableTree();

            Box.TreeBox.X      = (short)AfterPos.X;
            Box.TreeBox.Y      = (short)AfterPos.Y;
            Box.TreeBox.Width  = (short)AfterSize.X;
            Box.TreeBox.Height = (short)AfterSize.Y;
            Content.Content.Get().Changes.ChunkChanged(tree);
        }
        public override void Undo(BHAV bhav, UIBHAVEditor editor)
        {
            var tree = editor.GetSavableTree();

            Box.TreeBox.X      = (short)BeforePos.X;
            Box.TreeBox.Y      = (short)BeforePos.Y;
            Box.TreeBox.Width  = (short)BeforeSize.X;
            Box.TreeBox.Height = (short)BeforeSize.Y;
            Box.ApplyBoxPositionCentered();
            Content.Content.Get().Changes.ChunkChanged(tree);
        }
Esempio n. 6
0
        public override void Execute(BHAV bhav, UIBHAVEditor editor)
        {
            var tree = editor.GetSavableTree();

            if (NewPrimitive.Type != TREEBoxType.Primitive)
            {
                var ptr     = NewPrimitive.TreeBox.TruePointer; //if this is a goto, this will contain the label id
                var comment = NewPrimitive.TreeBox.Comment;
                NewPrimitive.SetTreeBox(tree.MakeNewSpecialBox(NewPrimitive.Type));
                NewPrimitive.TreeBox.TruePointer = ptr;
                NewPrimitive.TreeBox.Comment     = comment;
                NewPrimitive.CopyPosToTree();
                editor.BHAVView.Primitives.Add(NewPrimitive);
                editor.BHAVView.Add(NewPrimitive);
            }
            else
            {
                var newInst = new BHAVInstruction[bhav.Instructions.Length + 1];
                for (int i = 0; i < bhav.Instructions.Length; i++)
                {
                    newInst[i] = bhav.Instructions[i];
                }
                newInst[newInst.Length - 1] = NewPrimitive.Instruction;
                NewPrimitive.SetTreeBox(tree.MakeNewPrimitiveBox(TREEBoxType.Primitive));
                NewPrimitive.CopyPosToTree();

                bhav.Instructions = newInst;
                editor.BHAVView.AddPrimitive(NewPrimitive);
                NewPrimitive.UpdateDisplay();

                Content.Content.Get().Changes.ChunkChanged(bhav);

                FSO.SimAntics.VM.BHAVChanged(bhav);
            }
            Content.Content.Get().Changes.ChunkChanged(tree);
        }
        public override void Execute(BHAV bhav, UIBHAVEditor editor)
        {
            var tree = editor.GetSavableTree();

            if (Primitive.Type != TREEBoxType.Primitive)
            {
                if (Primitive.TreeBox.InternalID != -1)
                {
                    tree.DeleteBox(Primitive.TreeBox);
                }
                editor.BHAVView.Primitives.Remove(Primitive);
                editor.BHAVView.Remove(Primitive);
            }
            else
            {
                var  newInst = new BHAVInstruction[bhav.Instructions.Length - 1];
                byte index   = 0;
                for (int i = 0; i < bhav.Instructions.Length; i++)
                {
                    if (i != Primitive.InstPtr)
                    {
                        var inst = bhav.Instructions[i];
                        newInst[index++] = inst;
                        if (inst.TruePointer < 253 && inst.TruePointer > Primitive.InstPtr)
                        {
                            inst.TruePointer--;
                        }
                        if (inst.FalsePointer < 253 && inst.FalsePointer > Primitive.InstPtr)
                        {
                            inst.FalsePointer--;
                        }
                    }
                }

                bhav.Instructions = newInst;
                editor.BHAVView.RemovePrimitive(Primitive);
            }

            foreach (var prim in FromTrue)
            {
                prim.TrueUI = null;
                prim.TreeBox.TruePointer = -1;
                if (prim.Instruction != null)
                {
                    prim.Instruction.TruePointer = 253;
                }
                if (prim.Type == TREEBoxType.Label)
                {
                    editor.BHAVView.UpdateLabelPointers(prim.TreeBox.InternalID);
                }
            }

            foreach (var prim in FromFalse)
            {
                prim.FalseUI = null;
                prim.TreeBox.FalsePointer = -1;
                if (prim.Instruction != null)
                {
                    prim.Instruction.FalsePointer = 253;
                }
                if (prim.Type == TREEBoxType.Label)
                {
                    editor.BHAVView.UpdateLabelPointers(prim.TreeBox.InternalID);
                }
            }
            Content.Content.Get().Changes.ChunkChanged(bhav);
            FSO.SimAntics.VM.BHAVChanged(bhav);
            Content.Content.Get().Changes.ChunkChanged(tree);
        }
        public override void Undo(BHAV bhav, UIBHAVEditor editor)
        {
            var tree = editor.GetSavableTree();

            if (Primitive.Type != TREEBoxType.Primitive)
            {
                //put the tree item back at the end
                if (Primitive.TreeBox.InternalID != -1)
                {
                    tree.InsertRemovedBox(Primitive.TreeBox);
                }
                editor.BHAVView.Primitives.Add(Primitive);
                editor.BHAVView.Add(Primitive);
            }
            else
            {
                var  newInst = new BHAVInstruction[bhav.Instructions.Length + 1];
                byte index   = 0;
                for (int i = 0; i < newInst.Length; i++)
                {
                    if (i == Primitive.InstPtr)
                    {
                        newInst[i] = Primitive.Instruction;
                    }
                    else
                    {
                        var inst = bhav.Instructions[index++];
                        newInst[i] = inst;
                        if (inst.TruePointer < 252 && inst.TruePointer >= Primitive.InstPtr)
                        {
                            inst.TruePointer++;
                        }
                        if (inst.FalsePointer < 252 && inst.FalsePointer >= Primitive.InstPtr)
                        {
                            inst.FalsePointer++;
                        }
                    }
                }

                bhav.Instructions = newInst;
                editor.BHAVView.AddPrimitive(Primitive);
                //insert the tree item
                if (Primitive.TreeBox.InternalID != -1)
                {
                    tree.InsertRemovedBox(Primitive.TreeBox);
                }
            }

            foreach (var prim in FromTrue)
            {
                prim.TrueUI = Primitive;
                prim.TreeBox.TruePointer = Primitive.TreeBox.InternalID;
                if (prim.Instruction != null)
                {
                    prim.Instruction.TruePointer = Primitive.InstPtr;
                }
                if (prim.Type == TREEBoxType.Label)
                {
                    editor.BHAVView.UpdateLabelPointers(prim.TreeBox.InternalID);
                }
            }

            foreach (var prim in FromFalse)
            {
                prim.FalseUI = Primitive;
                prim.TreeBox.FalsePointer = Primitive.TreeBox.InternalID;
                if (prim.Instruction != null)
                {
                    prim.Instruction.FalsePointer = Primitive.InstPtr;
                }
                if (prim.Type == TREEBoxType.Label)
                {
                    editor.BHAVView.UpdateLabelPointers(prim.TreeBox.InternalID);
                }
            }

            Content.Content.Get().Changes.ChunkChanged(bhav);
            FSO.SimAntics.VM.BHAVChanged(bhav);
            Content.Content.Get().Changes.ChunkChanged(tree);
        }