Inheritance: FSO.Client.UI.Framework.UIContainer
Example #1
0
 public void ClearPlacement()
 {
     PlacingName.Visible = false;
     PlacingDesc.Visible = false;
     Placement           = null;
     RedrawNext          = true;
 }
Example #2
0
        public void SetPlacement(ushort primType, byte[] operand = null)
        {
            PlacingName.Visible = true;
            PlacingDesc.Visible = true;

            if (primType == 254 || primType == 255)
            {
                var box = new TREEBox(null);
                box.Type            = (primType == 254) ? TREEBoxType.True : TREEBoxType.False;
                Placement           = new PrimitiveBox(box, BHAVView);
                PlacingName.Caption = "Placing Return " + ((primType == 254) ? "True" : "False");
            }
            else
            {
                Placement = new PrimitiveBox(new BHAVInstruction
                {
                    TruePointer  = 253,
                    FalsePointer = 253,
                    Opcode       = primType,
                    Operand      = operand == null ? new byte[8] : operand
                }, BHAVView);
                PlacingName.Caption = "Placing " + Placement.TitleText;
            }
            Placement.Parent = this;
        }
Example #3
0
 public void ClearPlacement()
 {
     PlacingName.Visible = false;
     PlacingDesc.Visible = false;
     Placement = null;
     RedrawNext = true;
 }
Example #4
0
        public void ShadDraw(UISpriteBatch batch)
        {
            if (!Visible)
            {
                return;
            }
            if (Destination != null && Destination.Dead)
            {
                Destination = null;
            }

            var res = EditorResource.Get();

            DrawLocalTexture(batch, res.NodeOutline, null, new Vector2(res.NodeOutline.Width / -2 + 5, res.NodeOutline.Height / -2 + 5), new Vector2(1f, 1f), ShadCol);

            if (!MouseDrag && Destination == null)
            {
                return;
            }

            var contextPos = Parent.Position + Position;

            ArrowVec = (MouseDrag)?DragVec:(Destination.NearestDestPt(contextPos) - contextPos);

            var dir = new Vector2(ArrowVec.X, ArrowVec.Y);

            dir.Normalize();

            DrawLine(res.WhiteTex, dir * 10 + new Vector2(5, 5), (ArrowVec - dir * 5) + new Vector2(5, 5), batch, 6, ShadCol);
            var arrowDir = (float)Math.Atan2(-dir.X, dir.Y);
            var arrowPos = LocalPoint((ArrowVec) + new Vector2(5, 5));

            batch.Draw(res.ArrowHeadOutline, arrowPos, null, ShadCol, arrowDir, new Vector2(9, 19), _Scale, SpriteEffects.None, 0);
        }
Example #5
0
 public ChangePointerCommand(PrimitiveBox instUI, PrimitiveBox destUI, bool trueBranch)
 {
     InstUI = instUI;
     DestUI = destUI;
     OldDestUI = trueBranch ? instUI.TrueUI : instUI.FalseUI;
     TrueBranch = trueBranch;
 }
Example #6
0
        public void UpdateOperand(PrimitiveBox target)
        {
            ForceRedraw = true;

            target.Descriptor.Operand.Write(target.Instruction.Operand);
            FSO.SimAntics.VM.BHAVChanged(EditTarget);
            target.UpdateDisplay();
        }
Example #7
0
        public void UpdateOperand(PrimitiveBox target)
        {
            var newOp = new byte[8];

            target.Descriptor.Operand.Write(newOp);

            QueueCommand(new OpModifyCommand(target, newOp));
        }
Example #8
0
 public void Select(PrimitiveBox box)
 {
     Selected.Clear();
     Selected.Add(box);
     if (OnSelectedChanged != null)
     {
         OnSelectedChanged(Selected);
     }
 }
Example #9
0
 public void RemovePrimitive(PrimitiveBox prim)
 {
     Primitives.Remove(prim);
     RealPrim.RemoveAt(prim.InstPtr);
     for (byte i = 0; i < RealPrim.Count; i++)
     {
         RealPrim[i].InstPtr = i;
     }
     this.Remove(prim);
 }
Example #10
0
 public void RemovePrimitive(PrimitiveBox prim)
 {
     if (prim.TreeBox.InternalID != -1)
     {
         EditTargetTree.DeleteBox(prim.TreeBox);
     }
     Primitives.Remove(prim);
     RealPrim.RemoveAt(prim.InstPtr);
     this.Remove(prim);
 }
Example #11
0
        public RemovePrimCommand(List<PrimitiveBox> realPrims, PrimitiveBox prim)
        {
            Primitive = prim;
            FromFalse = new List<PrimitiveBox>();
            FromTrue = new List<PrimitiveBox>();

            foreach(var from in realPrims)
            {
                if (from.TrueUI == prim) FromTrue.Add(from);
                if (from.FalseUI == prim) FromFalse.Add(from);
            }
        }
Example #12
0
        public BHAVContainer(BHAV target, EditorScope scope)
        {
            Scope      = scope;
            EditTarget = target;

            Selected   = new List <PrimitiveBox>();
            Primitives = new List <PrimitiveBox>();
            RealPrim   = new List <PrimitiveBox>();

            byte i = 0;

            foreach (var inst in EditTarget.Instructions)
            {
                var ui = new PrimitiveBox(inst, i++, this);
                Primitives.Add(ui);
                RealPrim.Add(ui);
                this.Add(ui);
            }

            var RealPrims = new List <PrimitiveBox>(Primitives);

            foreach (var prim in RealPrims)
            {
                if (prim.Instruction.FalsePointer > 252 && prim.Returns != PrimitiveReturnTypes.Done)
                {
                    var dest = new PrimitiveBox((prim.Instruction.FalsePointer == 254) ? PrimBoxType.True : PrimBoxType.False, this);
                    Primitives.Add(dest);
                    this.Add(dest);
                    prim.FalseUI = dest;
                }
                else if (prim.Instruction.FalsePointer < RealPrim.Count)
                {
                    prim.FalseUI = RealPrim[prim.Instruction.FalsePointer];
                }

                if (prim.Instruction.TruePointer > 252)
                {
                    var dest = new PrimitiveBox((prim.Instruction.TruePointer == 254) ? PrimBoxType.True : PrimBoxType.False, this);
                    Primitives.Add(dest);
                    this.Add(dest);
                    prim.TrueUI = dest;
                }
                else if (prim.Instruction.TruePointer < RealPrim.Count)
                {
                    prim.TrueUI = RealPrim[prim.Instruction.TruePointer];
                }
            }
            CleanPosition();

            HitTest = ListenForMouse(new Rectangle(Int32.MinValue / 2, Int32.MinValue / 2, Int32.MaxValue, Int32.MaxValue), new UIMouseEvent(DragMouseEvents));
        }
Example #13
0
        public BHAVContainer(BHAV target, EditorScope scope)
        {
            Scope = scope;
            EditTarget = target;

            Selected = new List<PrimitiveBox>();
            Primitives = new List<PrimitiveBox>();
            RealPrim = new List<PrimitiveBox>();

            byte i = 0;
            foreach (var inst in EditTarget.Instructions)
            {
                var ui = new PrimitiveBox(inst, i++, this);
                Primitives.Add(ui);
                RealPrim.Add(ui);
                this.Add(ui);
            }

            var RealPrims = new List<PrimitiveBox>(Primitives);
            foreach (var prim in RealPrims)
            {
                if (prim.Instruction.FalsePointer > 252 && prim.Returns != PrimitiveReturnTypes.Done)
                {
                    var dest = new PrimitiveBox((prim.Instruction.FalsePointer == 254) ? PrimBoxType.True : PrimBoxType.False, this);
                    Primitives.Add(dest);
                    this.Add(dest);
                    prim.FalseUI = dest;
                }
                else if (prim.Instruction.FalsePointer < RealPrim.Count) prim.FalseUI = RealPrim[prim.Instruction.FalsePointer];

                if (prim.Instruction.TruePointer > 252)
                {
                    var dest = new PrimitiveBox((prim.Instruction.TruePointer == 254) ? PrimBoxType.True : PrimBoxType.False, this);
                    Primitives.Add(dest);
                    this.Add(dest);
                    prim.TrueUI = dest;
                }
                else if (prim.Instruction.TruePointer < RealPrim.Count) prim.TrueUI = RealPrim[prim.Instruction.TruePointer];
            }
            CleanPosition();

            HitTest = ListenForMouse(new Rectangle(Int32.MinValue/2, Int32.MinValue / 2, Int32.MaxValue, Int32.MaxValue), new UIMouseEvent(DragMouseEvents));
        }
Example #14
0
        public SetFirstCommand(List<PrimitiveBox> realPrims, PrimitiveBox prim)
        {
            Primitive = prim;
            var prim0 = realPrims.FirstOrDefault(x => x.InstPtr == 0);
            Old0 = prim0;
            OldPtr = Primitive.InstPtr;
            FromFalse = new List<PrimitiveBox>();
            FromTrue = new List<PrimitiveBox>();
            FromFalse0 = new List<PrimitiveBox>();
            FromTrue0 = new List<PrimitiveBox>();

            foreach (var from in realPrims)
            {
                if (from.TrueUI == prim) FromTrue.Add(from);
                if (from.FalseUI == prim) FromFalse.Add(from);
                if (from.TrueUI == prim0) FromTrue0.Add(from);
                if (from.FalseUI == prim0) FromFalse0.Add(from);
            }
        }
Example #15
0
        public void Init()
        {
            Selected   = new List <PrimitiveBox>();
            Primitives = new List <PrimitiveBox>();
            RealPrim   = new List <PrimitiveBox>();

            var childCopy = GetChildren().ToList();

            foreach (var child in childCopy)
            {
                Remove(child);
            }

            HoverPrim = null;

            foreach (var box in EditTargetTree.Entries)
            {
                var ui = new PrimitiveBox(box, this);
                Primitives.Add(ui);
                if (box.Type == TREEBoxType.Primitive)
                {
                    RealPrim.Add(ui);
                }
                this.Add(ui);
            }

            foreach (var prim in Primitives)
            {
                var box = prim.TreeBox;
                if (box.TruePointer != -1)
                {
                    prim.TrueUI = Primitives[box.TruePointer];
                }
                if (box.FalsePointer != -1)
                {
                    prim.FalseUI = Primitives[box.FalsePointer];
                }
            }

            CleanPosition();
        }
Example #16
0
        public void SetPlacement(ushort primType)
        {
            PlacingName.Visible = true;
            PlacingDesc.Visible = true;

            if (primType == 254 || primType == 255)
            {
                Placement           = new PrimitiveBox((primType == 254) ? PrimBoxType.True : PrimBoxType.False, BHAVView);
                PlacingName.Caption = "Placing Return " + ((primType == 254) ? "True" : "False");
            }
            else
            {
                Placement = new PrimitiveBox(new BHAVInstruction
                {
                    TruePointer  = 253,
                    FalsePointer = 253,
                    Opcode       = primType,
                    Operand      = new byte[8]
                }, 255, BHAVView);
                PlacingName.Caption = "Placing " + Placement.TitleText;
            }
            Placement.Parent = this;
        }
Example #17
0
        public void SetPlacement(TREEBoxType type, PrimitiveBox target)
        {
            PlacingName.Visible = true;
            PlacingDesc.Visible = true;

            var tree = BHAVView.EditTargetTree;
            var box  = new TREEBox(tree);

            if (target != null)
            {
                box.TruePointer = target.TreeBox.InternalID;
            }
            box.Width  = 200;
            box.Height = 60;
            box.Type   = type;
            if (type == TREEBoxType.Label)
            {
                box.Comment = "Label " + (tree.Entries.Count(x => x.Type == TREEBoxType.Label) + 1);
            }
            Placement           = new PrimitiveBox(box, BHAVView);
            PlacingName.Caption = "Placing " + type.ToString();
            Placement.Parent    = this;
        }
Example #18
0
 public void SetPlacement(ushort primType)
 {
     PlacingName.Visible = true;
     PlacingDesc.Visible = true;
     Placement = new PrimitiveBox(new BHAVInstruction
     {
         TruePointer = 253,
         FalsePointer = 253,
         Opcode = primType,
         Operand = new byte[8]
     }, 255, BHAVView);
     PlacingName.Caption = "Placing "+Placement.TitleText;
     Placement.Parent = this;
 }
 public ToggleBreakpointCommand(PrimitiveBox instUI)
 {
     InstUI = instUI;
 }
Example #20
0
 public Vector2 GetCentralLocation(PrimitiveBox box)
 {
     return(new Vector2(((UIExternalContainer)Parent).Width / 2 - (box.X + box.Width / 2), ((UIExternalContainer)Parent).Height / 2 - (box.Y + box.Height / 2)));
 }
Example #21
0
        private void recurseTree(HashSet<PrimitiveBox> notTraversed, List<List<PrimitiveBox>> instructionTree, PrimitiveBox primUI, byte depth)
        {
            if (primUI == null || !notTraversed.Contains(primUI)) return;

            while (depth >= instructionTree.Count) instructionTree.Add(new List<PrimitiveBox>());
            instructionTree[depth].Add(primUI);
            notTraversed.Remove(primUI);

            //traverse false then true branch
            recurseTree(notTraversed, instructionTree, primUI.TrueUI, (byte)(depth + 1));
            recurseTree(notTraversed, instructionTree, primUI.FalseUI, (byte)(depth + 1));
        }
Example #22
0
        private void recurseTree(HashSet <PrimitiveBox> notTraversed, List <List <PrimitiveBox> > instructionTree, PrimitiveBox primUI, byte depth)
        {
            if (primUI == null || !notTraversed.Contains(primUI))
            {
                return;
            }

            while (depth >= instructionTree.Count)
            {
                instructionTree.Add(new List <PrimitiveBox>());
            }
            instructionTree[depth].Add(primUI);
            notTraversed.Remove(primUI);

            //traverse false then true branch
            recurseTree(notTraversed, instructionTree, primUI.TrueUI, (byte)(depth + 1));
            recurseTree(notTraversed, instructionTree, primUI.FalseUI, (byte)(depth + 1));
        }
Example #23
0
 public void AddPrimitive(PrimitiveBox prim)
 {
     Primitives.Add(prim);
     RealPrim.Add(prim);
     this.Add(prim);
 }
Example #24
0
 public void RemovePrimitive(PrimitiveBox prim)
 {
     Primitives.Remove(prim);
     RealPrim.RemoveAt(prim.InstPtr);
     for (byte i=0; i<RealPrim.Count; i++)
     {
         RealPrim[i].InstPtr = i;
     }
     this.Remove(prim);
 }
Example #25
0
        public void SetActivePrimitive(PrimitiveBox prim)
        {
            if (InvokeRequired)
            {

                //HasGameThread = true;

                new Thread(() =>
                {
                    var del = new SetActiveDelegate(SetActivePrimitive);
                    Invoke(del, new object[] { prim });
                }).Start();
                //HasGameThread = false;
            }
            else
            {
                if (prim == null || prim.Descriptor == null || ActivePrim == prim) return;
                ActivePrim = prim;
                var panel = OperandEditTable;
                panel.Controls.Clear();
                panel.RowCount = 0;
                panel.RowStyles.Clear();
                for (int i=0; i<10; i++) panel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                prim.Descriptor.PopulateOperandView(this, EditorCont.Scope, panel);
            }
        }
Example #26
0
 public void Select(PrimitiveBox box)
 {
     Selected.Clear();
     Selected.Add(box);
     if (OnSelectedChanged != null) OnSelectedChanged(Selected);
 }
Example #27
0
        public void SetPlacement(ushort primType)
        {
            PlacingName.Visible = true;
            PlacingDesc.Visible = true;

            if (primType == 254 || primType == 255)
            {
                Placement = new PrimitiveBox((primType == 254) ? PrimBoxType.True : PrimBoxType.False, BHAVView);
                PlacingName.Caption = "Placing Return " + ((primType == 254) ? "True" : "False");
            }
            else
            {
                Placement = new PrimitiveBox(new BHAVInstruction
                {
                    TruePointer = 253,
                    FalsePointer = 253,
                    Opcode = primType,
                    Operand = new byte[8]
                }, 255, BHAVView);
                PlacingName.Caption = "Placing " + Placement.TitleText;
            }
            Placement.Parent = this;
        }
Example #28
0
        public void ShadDraw(UISpriteBatch batch)
        {
            if (!Visible) return;
            if (Destination != null && Destination.Dead) Destination = null;

            var res = EditorResource.Get();
            DrawLocalTexture(batch, res.NodeOutline, null, new Vector2(res.NodeOutline.Width / -2 + 5, res.NodeOutline.Height / -2 + 5), new Vector2(1f, 1f), ShadCol);

            if (!MouseDrag && Destination == null) return;

            var contextPos = Parent.Position + Position;
            ArrowVec = (MouseDrag)?DragVec:(Destination.NearestDestPt(contextPos) - contextPos);

            var dir = new Vector2(ArrowVec.X, ArrowVec.Y);
            dir.Normalize();

            DrawLine(res.WhiteTex, dir * 10 + new Vector2(5,5), (ArrowVec - dir * 5)+new Vector2(5,5), batch, 6, ShadCol);
            var arrowDir = (float)Math.Atan2(-dir.X, dir.Y);
            var arrowPos = LocalPoint((ArrowVec) + new Vector2(5,5));
            batch.Draw(res.ArrowHeadOutline, arrowPos, null, ShadCol, arrowDir, new Vector2(9, 19), _Scale, SpriteEffects.None, 0);
        }
Example #29
0
        public void UpdateOperand(PrimitiveBox target)
        {
            ForceRedraw = true;

            target.Descriptor.Operand.Write(target.Instruction.Operand);
            FSO.SimAntics.VM.BHAVChanged(EditTarget);
            target.UpdateDisplay();
        }
Example #30
0
        public void UpdateOperand(PrimitiveBox target)
        {
            var newOp = new byte[8];
            target.Descriptor.Operand.Write(newOp);

            QueueCommand(new OpModifyCommand(target, newOp));
        }
Example #31
0
 public AddPrimCommand(PrimitiveBox prim)
 {
     NewPrimitive = prim;
 }
Example #32
0
 public OpModifyCommand(PrimitiveBox prim, byte[] newOp)
 {
     Prim = prim;
     NewOp = newOp;
     OldOp = prim.Instruction.Operand;
 }
Example #33
0
 public void AddPrimitive(PrimitiveBox prim)
 {
     Primitives.Add(prim);
     RealPrim.Add(prim);
     this.Add(prim);
 }