public void ShadDraw(UISpriteBatch batch) { var res = EditorResource.Get(); if (Style == null || Style.Background.A > 200) { DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(5, 5), new Vector2(Width, Height), ShadCol); } else { DrawTiledTexture(batch, res.DiagTile, new Rectangle(5, 5, Width, Height), ShadCol); } if (Type == PrimBoxType.Primitive) { int topInd = 0; if (Instruction.Breakpoint) { DrawLocalTexture(batch, res.Breakpoint, null, new Vector2(-15, 6 + ((topInd++) * 18)), new Vector2(1, 1), Color.Black * 0.2f); } if (Master.DebugPointer == this) { DrawLocalTexture(batch, res.CurrentArrow, null, new Vector2(-15, 6 + ((topInd++) * 18)), new Vector2(1, 1), Color.Black * 0.2f); } } foreach (var child in Nodes) { child.ShadDraw(batch); } }
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); }
public override void Draw(UISpriteBatch batch) { var res = EditorResource.Get(); DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(), new Vector2(batch.GraphicsDevice.Viewport.Width, 30), new Color(12, 61, 112) * 0.80f); DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(0, 30), new Vector2(batch.GraphicsDevice.Viewport.Width, 4), new Color(12, 61, 112) * 0.30f); }
public void NewBreak(VMStackFrame frame) { DebugGo.Tooltip = "Go"; DebugGo.Texture = EditorResource.Get().Indexed[0]; DebugStepIn.Disabled = false; DebugStepOut.Disabled = false; DebugStepOver.Disabled = false; DebugTrue.Disabled = false; DebugFalse.Disabled = false; var breakStr = frame.Thread.ThreadBreakString ?? "Stopped."; bool isException = breakStr[0] == '!'; if (isException) { DebugLabel.CaptionStyle.Color = new Color(255, 255, 155, 255); breakStr = breakStr.Substring(1); } else { DebugLabel.CaptionStyle.Color = Color.White; } DebugLabel.Caption = breakStr; RedrawNext = true; DebugFrame = frame; UpdateDebugPointer(DebugFrame); }
public void StartIDE(VM vm) { if (MainWindow.Instance == null) { EditorResource.Get().Init(GameFacade.GraphicsDevice); var content = Content.Content.Get(); EditorScope.Behaviour = new Files.Formats.IFF.IffFile( content.TS1 ? Path.Combine(content.TS1BasePath, "GameData/Behavior.iff") : content.GetPath("objectdata/globals/behavior.iff")); EditorScope.Globals = content.WorldObjectGlobals.Get("global"); Program.MainThread = Thread.CurrentThread; var t = new Thread(() => { var editor = new MainWindow(); editor.SwitchVM(vm); Application.Run(editor); }); //t.SetApartmentState(ApartmentState.STA); t.Start(); } else { var inst = MainWindow.Instance; inst.BeginInvoke(new Action(() => { inst.SwitchVM(vm); inst.Show(); })); } }
public override void Draw(UISpriteBatch batch) { base.Draw(batch); if (!Visible) { return; } Vector2 dir = new Vector2(); var res = EditorResource.Get(); if (MouseDrag || Destination != null) { //draw Line bg dir = new Vector2(ArrowVec.X, ArrowVec.Y); dir.Normalize(); DrawLine(res.WhiteTex, dir * 10, ArrowVec - dir * 5, batch, 6, Color.White); } //draw Node DrawLocalTexture(batch, res.NodeOutline, new Vector2(res.NodeOutline.Width / -2, res.NodeOutline.Height / -2)); DrawLocalTexture(batch, res.Node, null, new Vector2(res.Node.Width / -2, res.Node.Height / -2), new Vector2(1f, 1f), NodeColors[Type]); if (MouseDrag || Destination != null) { //draw Arrow var arrowDir = (float)Math.Atan2(-dir.X, dir.Y); var arrowPos = LocalPoint(ArrowVec); batch.Draw(res.ArrowHeadOutline, arrowPos, null, Color.White, arrowDir, new Vector2(9, 19), _Scale, SpriteEffects.None, 0); batch.Draw(res.ArrowHead, arrowPos, null, NodeColors[Type], arrowDir, new Vector2(9, 19), _Scale, SpriteEffects.None, 0); //draw Line DrawLine(res.WhiteTex, dir * 10, ArrowVec - dir * 5, batch, 4, NodeColors[Type]); } Texture2D icon; switch (Type) { case NodeType.False: icon = res.FalseNode; break; case NodeType.True: icon = res.TrueNode; break; default: icon = res.DoneNode; break; } DrawLocalTexture(batch, icon, IconPos[Direction] - new Vector2(icon.Width / 2, icon.Height / 2)); var shadRect = SmallShad[Direction]; DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(shadRect.X, shadRect.Y), new Vector2(shadRect.Width, shadRect.Height), Color.Black * 0.15f); }
public override void Draw(UISpriteBatch batch) { var res = EditorResource.Get(); DrawTiledTexture(batch, res.Background, new Rectangle((int)Math.Floor(this.Position.X / -200) * 200, (int)Math.Floor(this.Position.Y / -200) * 200, batch.Width + 200, batch.Height + 200), Color.White); foreach (var child in Primitives) { child.ShadDraw(batch); } base.Draw(batch); }
public void StartIDE(VM vm) { EditorResource.Get().Init(GameFacade.GraphicsDevice); EditorScope.Behaviour = new Files.Formats.IFF.IffFile(Content.Content.Get().GetPath("objectdata/globals/behavior.iff")); EditorScope.Globals = FSO.Content.Content.Get().WorldObjectGlobals.Get("global"); var t = new Thread(() => { var editor = new MainWindow(); editor.Test(vm); Application.Run(editor); }); //t.SetApartmentState(ApartmentState.STA); t.Start(); }
public void Resume() { DebugGo.Tooltip = "Pause"; DebugGo.Texture = EditorResource.Get().Indexed[7]; DebugStepIn.Disabled = true; DebugStepOut.Disabled = true; DebugStepOver.Disabled = true; DebugTrue.Disabled = true; DebugFalse.Disabled = true; DebugLabel.Caption = "Running..."; RedrawNext = true; if (DisableDebugger != null) { DisableDebugger(); } BHAVView.DebugPointer = null; }
public override void Draw(UISpriteBatch batch) { base.Draw(batch); var res = EditorResource.Get(); if (Type == PrimBoxType.Primitive) { if (InstPtr == 0) { DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(-3, -3), new Vector2(Width + 6, Height + 6), new Color(0x96, 0xFF, 0x73)); DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(-2, -2), new Vector2(Width + 4, Height + 4), new Color(0x46, 0x8C, 0x00)); //start point green } if (Style.Background.A > 200) { DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(), new Vector2(Width, Height), Master.Selected.Contains(this)?Color.Red:Color.White); //white outline } DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(1, 1), new Vector2(Width - 2, Height - 2), Style.Background); //background DrawTiledTexture(batch, res.DiagTile, new Rectangle(1, 1, Width - 2, Height - 2), Color.White * Style.DiagBrightness); DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(1, 1), new Vector2(Width - 2, 20), Color.White * 0.66f); //title bg Title.Draw(batch); if (BodyTextLabels != null) { TextRenderer.DrawText(BodyTextLabels.DrawingCommands, this, batch); } int topInd = 0; if (Instruction.Breakpoint) { DrawLocalTexture(batch, res.Breakpoint, null, new Vector2(-20, 1 + ((topInd++) * 18)), new Vector2(1, 1), Color.White); } if (Master.DebugPointer == this) { DrawLocalTexture(batch, res.CurrentArrow, null, new Vector2(-20, 1 + ((topInd++) * 18)), new Vector2(1, 1), Color.White); } } else { DrawLocalTexture(batch, (Type == PrimBoxType.True)?res.TrueReturn:res.FalseReturn, new Vector2()); } }
public override void Draw(UISpriteBatch batch) { var width = batch.GraphicsDevice.Viewport.Width; var height = batch.GraphicsDevice.Viewport.Height; BHAVView.Width = width; BHAVView.Height = height; base.Draw(batch); if (Placement != null) { Placement.PreDraw(batch); Placement.ShadDraw(batch); Placement.Draw(batch); } var res = EditorResource.Get(); DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(), new Vector2(4, height), Color.Black * 0.2f); DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(4, 0), new Vector2(width, 4), Color.Black * 0.2f); if (DebugMode) { if (width != LastWidth) { DebugTrue.Position = new Vector2(width - 80, 5); DebugFalse.Position = new Vector2(width - 55, 5); DebugReset.Position = new Vector2(width - 30, 5); GameThread.NextUpdate(x => Invalidate()); } } if (Placement != null) { DrawCutoutLines(CutoutPhase, 5, Color.Black * 0.2f, batch); DrawCutoutLines(CutoutPhase, 0, new Color(0, 102, 26), batch); } LastWidth = width; LastHeight = height; }
public override void Draw(UISpriteBatch batch) { base.Draw(batch); if (Placement != null) { Placement.ShadDraw(batch); Placement.Draw(batch); } var res = EditorResource.Get(); DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(), new Vector2(4, batch.Height), Color.Black * 0.2f); DrawLocalTexture(batch, res.WhiteTex, null, new Vector2(4, 0), new Vector2(batch.Width, 4), Color.Black * 0.2f); if (Placement != null) { DrawCutoutLines(CutoutPhase, 5, Color.Black * 0.2f, batch); DrawCutoutLines(CutoutPhase, 0, new Color(0, 102, 26), batch); } LastWidth = batch.Width; LastHeight = batch.Height; }
public UIBHAVEditor(BHAV target, EditorScope scope, VMEntity debugEnt) { if (debugEnt != null) { DebugMode = true; DebugEntity = debugEnt; } ContainerByID = new Dictionary <ushort, BHAVContainer>(); BHAVView = new BHAVContainer(target, scope); ContainerByID.Add(target.ChunkID, BHAVView); this.Add(BHAVView); GameThread.NextUpdate(x => { var basePrim = BHAVView.RealPrim.FirstOrDefault(); if (basePrim != null) { BHAVView.Position = GetCentralLocation(basePrim); } }); PlacingName = new UILabel(); PlacingName.Alignment = TextAlignment.Center; PlacingName.Size = new Vector2(1, 1); PlacingName.CaptionStyle = TextStyle.DefaultLabel.Clone(); PlacingName.CaptionStyle.Font = FSO.Client.GameFacade.EdithFont; PlacingName.CaptionStyle.VFont = FSO.Client.GameFacade.EdithVectorFont; PlacingName.CaptionStyle.Size = 15; PlacingName.CaptionStyle.Color = new Color(0, 102, 26); PlacingName.Caption = "Placing Report Metric"; PlacingDesc = new UILabel(); PlacingDesc.Alignment = TextAlignment.Center; PlacingDesc.Size = new Vector2(1, 1); PlacingDesc.CaptionStyle = TextStyle.DefaultLabel.Clone(); PlacingDesc.CaptionStyle.Font = FSO.Client.GameFacade.EdithFont; PlacingDesc.CaptionStyle.VFont = FSO.Client.GameFacade.EdithVectorFont; PlacingDesc.CaptionStyle.Size = 12; PlacingDesc.CaptionStyle.Color = new Color(0, 102, 26); PlacingDesc.Caption = "Press ESC to cancel."; this.Add(PlacingName); this.Add(PlacingDesc); if (DebugMode) { this.Add(new UITracerBar()); var resource = EditorResource.Get().Indexed; DebugFrame = debugEnt.Thread.Stack.LastOrDefault(); UpdateDebugPointer(DebugFrame); DebugGo = new UIButton(); DebugGo.Texture = resource[0]; DebugGo.Tooltip = "Go"; DebugGo.Position = new Vector2(10, 5); Add(DebugGo); DebugGo.OnButtonClick += DebugButtonClick; DebugStepIn = new UIButton(); DebugStepIn.Tooltip = "Step In"; DebugStepIn.Texture = resource[1]; DebugStepIn.Position = new Vector2(35, 5); Add(DebugStepIn); DebugStepIn.OnButtonClick += DebugButtonClick; DebugStepOver = new UIButton(); DebugStepOver.Tooltip = "Step Over"; DebugStepOver.Texture = resource[2]; DebugStepOver.Position = new Vector2(60, 5); Add(DebugStepOver); DebugStepOver.OnButtonClick += DebugButtonClick; DebugStepOut = new UIButton(); DebugStepOut.Tooltip = "Step Out"; DebugStepOut.Texture = resource[3]; DebugStepOut.Position = new Vector2(85, 5); Add(DebugStepOut); DebugStepOut.OnButtonClick += DebugButtonClick; DebugTrue = new UIButton(); DebugTrue.Tooltip = "Return True"; DebugTrue.Texture = resource[4]; DebugTrue.Position = new Vector2(LastWidth - 80, 5); Add(DebugTrue); DebugTrue.OnButtonClick += DebugButtonClick; DebugFalse = new UIButton(); DebugFalse.Tooltip = "Return False"; DebugFalse.Texture = resource[5]; DebugFalse.Position = new Vector2(LastWidth - 55, 5); Add(DebugFalse); DebugFalse.OnButtonClick += DebugButtonClick; DebugReset = new UIButton(); DebugReset.Tooltip = "Reset Object"; DebugReset.Texture = resource[6]; DebugReset.Position = new Vector2(LastWidth - 30, 5); Add(DebugReset); DebugReset.OnButtonClick += DebugButtonClick; DebugLabel = new UILabel(); DebugLabel.CaptionStyle = TextStyle.DefaultLabel.Clone(); DebugLabel.CaptionStyle.Font = FSO.Client.GameFacade.EdithFont; DebugLabel.CaptionStyle.VFont = FSO.Client.GameFacade.EdithVectorFont; DebugLabel.CaptionStyle.Size = 12; DebugLabel.CaptionStyle.Color = Color.White; DebugLabel.Caption = "Breakpoint Hit."; DebugLabel.Position = new Vector2(115, 9); Add(DebugLabel); } }
public void DrawCutoutLines(int phase, int offset, Color color, UISpriteBatch batch) { var width = batch.GraphicsDevice.Viewport.Width; var height = batch.GraphicsDevice.Viewport.Height; var res = EditorResource.Get(); int margin = 24; int boxWidth = width - margin * 2; int boxHeight = height - margin * 2; int i = phase % 32; bool draw = ((phase / 32) % 2) == 1; i -= 32; while (i < boxWidth) { if (draw) { DrawLine(res.WhiteTex, new Vector2(Math.Max(margin, margin + i) + offset, margin + offset), new Vector2(Math.Min(width - margin, margin + i + 32) + offset, margin + offset), batch, 4, color); } i += 32; draw = !draw; } i -= boxWidth + 32; draw = !draw; while (i < boxHeight) { if (draw) { DrawLine(res.WhiteTex, new Vector2(offset + width - margin, Math.Max(margin, margin + i) + offset), new Vector2(offset + width - margin, Math.Min(height - margin, margin + i + 32) + offset), batch, 4, color); } i += 32; draw = !draw; } i -= boxHeight + 32; draw = !draw; while (i < boxWidth) { if (draw) { DrawLine(res.WhiteTex, new Vector2(width - Math.Max(margin, margin + i) + offset, (height - margin) + offset), new Vector2(width - Math.Min(width - margin, margin + i + 32) + offset, (height - margin) + offset), batch, 4, color); } i += 32; draw = !draw; } i -= boxWidth + 32; draw = !draw; while (i < boxHeight) { if (draw) { DrawLine(res.WhiteTex, new Vector2(offset + margin, height - Math.Max(margin, margin + i) + offset), new Vector2(offset + margin, height - Math.Min(height - margin, margin + i + 32) + offset), batch, 4, color); } i += 32; draw = !draw; } }
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); } }