public void PreparePrimitive() { Descriptor = PrimitiveRegistry.GetDescriptor(Instruction.Opcode); Operand = (VMPrimitiveOperand)Activator.CreateInstance(Descriptor.OperandType); Operand.Read(Instruction.Operand); Nodes = new PrimitiveNode[2]; Nodes[0] = new PrimitiveNode(); Nodes[0].Type = NodeType.False; Nodes[1] = new PrimitiveNode(); Nodes[1].Type = NodeType.True; Title = new UILabel(); Title.Alignment = TextAlignment.Middle | TextAlignment.Center; Title.Y = 0; Title.X = 0; this.Add(Title); Title.CaptionStyle = TextStyle.DefaultLabel.Clone(); Title.CaptionStyle.Font = FSO.Client.GameFacade.EdithFont; Title.CaptionStyle.VFont = FSO.Client.GameFacade.EdithVectorFont; Title.CaptionStyle.Size = 14; Index = new UILabel(); Index.Alignment = TextAlignment.Right | TextAlignment.Center; Index.Y = 0; Index.X = 0; this.Add(Index); Index.CaptionStyle = TextStyle.DefaultLabel.Clone(); Index.CaptionStyle.Font = FSO.Client.GameFacade.EdithFont; Index.CaptionStyle.VFont = FSO.Client.GameFacade.EdithVectorFont; Index.CaptionStyle.Size = 10; Index.Visible = false; BodyTextStyle = TextStyle.DefaultLabel.Clone(); BodyTextStyle.Font = FSO.Client.GameFacade.EdithFont; BodyTextStyle.VFont = FSO.Client.GameFacade.EdithVectorFont; BodyTextStyle.Size = 12; CommentNode = new CommentContainer(TreeBox.Comment); CommentNode.OnCommentChanged += CommentNode_OnCommentChanged; CommentNode.Y = -3; Add(CommentNode); this.Add(Nodes[0]); this.Add(Nodes[1]); UpdateDisplay(); }
public PrimitiveBox(BHAVInstruction inst, byte ptr, BHAVContainer master) { Type = PrimBoxType.Primitive; Instruction = inst; Descriptor = PrimitiveRegistry.GetDescriptor(inst.Opcode); Operand = (VMPrimitiveOperand)Activator.CreateInstance(Descriptor.OperandType); Operand.Read(inst.Operand); InstPtr = ptr; Nodes = new PrimitiveNode[2]; Nodes[0] = new PrimitiveNode { Type = NodeType.False }; Nodes[1] = new PrimitiveNode { Type = NodeType.True }; Title = new UILabel { Alignment = TextAlignment.Middle | TextAlignment.Center, Y = 0, X = 0 }; this.Add(Title); Title.CaptionStyle = TextStyle.DefaultLabel.Clone(); Title.CaptionStyle.Font = Client.GameFacade.EdithFont; Title.CaptionStyle.Size = 14; BodyTextStyle = TextStyle.DefaultLabel.Clone(); BodyTextStyle.Font = Client.GameFacade.EdithFont; BodyTextStyle.Size = 12; this.Add(Nodes[0]); this.Add(Nodes[1]); HitTest = ListenForMouse(new Rectangle(0, 0, Width, Height), new UIMouseEvent(MouseEvents)); Master = master; UpdateDisplay(); }
public PrimitiveBox(BHAVInstruction inst, byte ptr, BHAVContainer master) { Type = PrimBoxType.Primitive; Instruction = inst; Descriptor = PrimitiveRegistry.GetDescriptor(inst.Opcode); Operand = (VMPrimitiveOperand)Activator.CreateInstance(Descriptor.OperandType); Operand.Read(inst.Operand); InstPtr = ptr; Nodes = new PrimitiveNode[2]; Nodes[0] = new PrimitiveNode(); Nodes[0].Type = NodeType.False; Nodes[1] = new PrimitiveNode(); Nodes[1].Type = NodeType.True; Title = new UILabel(); Title.Alignment = TextAlignment.Middle | TextAlignment.Center; Title.Y = 0; Title.X = 0; this.Add(Title); Title.CaptionStyle = TextStyle.DefaultLabel.Clone(); Title.CaptionStyle.Font = FSO.Client.GameFacade.EdithFont; Title.CaptionStyle.Size = 14; BodyTextStyle = TextStyle.DefaultLabel.Clone(); BodyTextStyle.Font = FSO.Client.GameFacade.EdithFont; BodyTextStyle.Size = 12; this.Add(Nodes[0]); this.Add(Nodes[1]); HitTest = ListenForMouse(new Rectangle(0, 0, Width, Height), new UIMouseEvent(MouseEvents)); Master = master; UpdateDisplay(); }
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); } }