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); }
public override void Execute(BHAV bhav, UIBHAVEditor editor) { if (NewPrimitive.Type != PrimBoxType.Primitive) { 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.InstPtr = (byte)(newInst.Length - 1); bhav.Instructions = newInst; editor.BHAVView.AddPrimitive(NewPrimitive); NewPrimitive.UpdateDisplay(); Content.GameContent.Get.Changes.ChunkChanged(bhav); SimAntics.VM.BHAVChanged(bhav); } }
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 AbstractTranslationPrimitive(BHAVInstruction instruction, byte index) { if (instruction.Opcode > 255) { Primitive = SharedPrimitives.Subroutine; } else { Primitive = (SharedPrimitives)instruction.Opcode; } Instruction = instruction; Index = index; }
public override void Undo(BHAV bhav, UIBHAVEditor editor) { if (Primitive.Type != PrimBoxType.Primitive) { 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); } foreach (var prim in FromTrue) { prim.TrueUI = Primitive; prim.Instruction.TruePointer = Primitive.InstPtr; } foreach (var prim in FromFalse) { prim.FalseUI = Primitive; prim.Instruction.FalsePointer = Primitive.InstPtr; } Content.GameContent.Get.Changes.ChunkChanged(bhav); SimAntics.VM.BHAVChanged(bhav); }
private void OutputBinaryBranch(BHAVInstruction inst, CSTranslationClass cls) { WriteLine("{"); IndentLevel++; OutputReturnBlockOrJump(inst.TruePointer, cls); IndentLevel--; WriteLine("}"); WriteLine("else"); WriteLine("{"); IndentLevel++; OutputReturnBlockOrJump(inst.FalsePointer, cls); IndentLevel--; WriteLine("}"); }
public AbstractTranslationPrimitive GetPrimitive(BHAVInstruction instruction, byte index) { Type primType; var prim = (SharedPrimitives)Math.Min((ushort)255, instruction.Opcode); if (!Map.TryGetValue(prim, out primType)) { return(GetFallbackPrim(instruction, index)); } else { return((AbstractTranslationPrimitive)Activator.CreateInstance(primType, new object[] { instruction, index })); } }
public override void Execute(BHAV bhav, UIBHAVEditor editor) { if (Primitive.Type != PrimBoxType.Primitive) { 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.Instruction.TruePointer = 253; } foreach (var prim in FromFalse) { prim.FalseUI = null; prim.Instruction.FalsePointer = 253; } Content.GameContent.Get.Changes.ChunkChanged(bhav); SimAntics.VM.BHAVChanged(bhav); }
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 override void Undo(BHAV bhav, UIBHAVEditor editor) { if (NewPrimitive.Type != PrimBoxType.Primitive) { 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.GameContent.Get.Changes.ChunkChanged(bhav); SimAntics.VM.BHAVChanged(bhav); } }
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 CSExpressionPrimitive(BHAVInstruction instruction, byte index) : base(instruction, index) { }
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); } }
public CSFallbackPrimitive(BHAVInstruction instruction, byte index) : base(instruction, index) { }
public CSCreateObjectInstancePrimitive(BHAVInstruction instruction, byte index) : base(instruction, index) { Op = GetOperand <VMCreateObjectInstanceOperand>(); }
public CSGenericSimsCallPrimitive(BHAVInstruction instruction, byte index) : base(instruction, index) { Op = GetOperand <VMGenericTS1CallOperand>(); }
public CSSubroutinePrimitive(BHAVInstruction instruction, byte index) : base(instruction, index) { }
public BlockAnalysisInstruction(TranslationContext ctx, BHAVInstruction instruction, byte index) { Translator = ctx.Primitives.GetPrimitive(instruction, index); Instruction = instruction; }
protected virtual AbstractTranslationPrimitive GetFallbackPrim(BHAVInstruction instruction, byte index) { return(new AbstractTranslationPrimitive(instruction, index)); }
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); }
protected override AbstractTranslationPrimitive GetFallbackPrim(BHAVInstruction instruction, byte index) { return(new CSFallbackPrimitive(instruction, index)); }
public CSSetToNextPrimitive(BHAVInstruction instruction, byte index) : base(instruction, index) { }