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; }
public PrimitiveBox(BHAVInstruction inst, BHAVContainer master) { TreeBox = new TREEBox(null); Master = master; Instruction = inst; HitTest = ListenForMouse(new Rectangle(0, 0, Width, Height), new UIMouseEvent(MouseEvents)); PreparePrimitive(); }
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; }
public void SetTreeBox(TREEBox box) { TreeBox = box; }
public PrimitiveBox(TREEBox box, BHAVContainer master) { TreeBox = box; Master = master; Nodes = new PrimitiveNode[0]; ApplyBoxPosition(); HitTest = ListenForMouse(new Rectangle(0, 0, Width, Height), new UIMouseEvent(MouseEvents)); Texture2D sliceTex = null; switch (Type) { case TREEBoxType.Primitive: Instruction = master.GetInstruction(box.TrueID); PreparePrimitive(); break; case TREEBoxType.True: case TREEBoxType.False: RecenterSize(32, 32); break; case TREEBoxType.Label: sliceTex = EditorResource.Get().LabelBox; Nodes = new PrimitiveNode[2]; Nodes[0] = new PrimitiveNode(); Nodes[0].Visible = false; Nodes[1] = new PrimitiveNode(); Nodes[1].Type = NodeType.Done; this.Add(Nodes[0]); this.Add(Nodes[1]); TextEdit = new UITextEdit(); TextEdit.OnChange += (elem) => { CommentChanged(); }; TextEdit.OnFocusOut += TextEdit_OnFocusOut; TextEdit.TextStyle = EditorResource.Get().TitleStyle; TextEdit.Alignment = TextAlignment.Center; TextEdit.CurrentText = TreeBox.Comment; TextEdit.NoFocusPassthrough += MouseEvents; Add(TextEdit); CommentResized(); break; case TREEBoxType.Goto: sliceTex = EditorResource.Get().GotoBox; Title = new UILabel(); Title.Alignment = TextAlignment.Middle | TextAlignment.Center; Title.Y = 0; Title.X = 0; this.Add(Title); Title.CaptionStyle = EditorResource.Get().TitleStyle; UpdateGotoLabel(); break; case TREEBoxType.Comment: sliceTex = EditorResource.Get().CommentBox; TextEdit = new UITextEdit(); TextEdit.OnChange += (elem) => { CommentChanged(); }; TextEdit.OnFocusOut += TextEdit_OnFocusOut; TextEdit.TextStyle = EditorResource.Get().CommentStyle; TextEdit.CurrentText = TreeBox.Comment; TextEdit.NoFocusPassthrough += MouseEvents; Add(TextEdit); CommentResized(); break; } if (sliceTex != null) { var sliceW = sliceTex.Width / 3; var sliceH = sliceTex.Height / 3; SliceBg = new UIImage(sliceTex).With9Slice(sliceW, sliceW, sliceH, sliceH); SliceBg.Width = Width; SliceBg.Height = Height; Add(SliceBg); } }