public ImageSelectForm(Pat.Project project) { InitializeComponent(); _Project = project; RefreshList(); }
private void OpenFile(string file) { _RecentFileList.AddToRecentList(file); Pat.Project proj = null; if (System.IO.Path.GetExtension(file) == ".pat") { proj = ProjectGenerater.Generate(file); } else if (System.IO.Path.GetExtension(file) == ".patproj") { proj = ProjectSerializer.OpenProject(file); } else { MessageBox.Show("Unknown file extension."); } if (proj != null) { _Editor.Project = proj; } SetupToolbarEnabled(); openFileDialog1.FileName = ""; }
public void FinishExporter() { //save pat if (System.IO.File.Exists(_OutputFile)) { System.IO.File.Delete(_OutputFile); } using (var stream = System.IO.File.Open(_OutputFile, System.IO.FileMode.CreateNew)) { using (var writer = new System.IO.BinaryWriter(stream)) { GSPat.GSPatWriter.Write(_OutputData, writer); } } //save codes foreach (var code in _Codes) { code.Finish(); } //reset referenced objects _Codes.Clear(); _Project = null; _ImageList = null; _OutputData = null; }
private static FunctionBlock GenerateBeginAirJump(PlayerExporter exporter, Pat.Project proj) { return(new FunctionBlock("BeginAirJump", new string[0], new ILineObject[] { new ControlBlock(ControlBlockType.If, "this.u.jumpCount == 0", new ILineObject[] { new SimpleLineObject("this.ChangeFreeMove();"), new SimpleLineObject("this.sitLabel = this.u.BeginSit;"), new SimpleLineObject("this.u.jumpCount++;"), new SimpleLineObject("this.isAir = true;"), new SimpleLineObject("this.collisionMask = 8 | 16;"), new SimpleLineObject("this.vy = -15.0;"), new SimpleLineObject("this.PlaySE(1000);"), new ControlBlock(ControlBlockType.If, "this.input.x * this.input.x >= 0.01", new ILineObject[] { new SimpleLineObject("this.vx = this.input.x >= 0.1 ? 4.0 : -4.0;"), new SimpleLineObject("this.direction = this.input.x >= 0.1 ? 1.0 : -1.0;"), new SimpleLineObject("this.SetMotion(this.u.CA + 4, 0);"), new SimpleLineObject("return;"), }).Statement(), new ControlBlock(ControlBlockType.Else, new ILineObject[] { new SimpleLineObject("this.vx = 0.0;"), new SimpleLineObject("this.SetMotion(this.u.CA + 3, 0);"), new SimpleLineObject("return;"), }).Statement(), }).Statement(), })); }
public override void ShowOptionDialog(Pat.Project proj) { Environment = new EditableEnvironment(proj); Animations.Environment = Environment; var dialog = new PlayerExporterOptionsForm(proj, this); dialog.ShowDialog(); }
public AnimationPropertyFrom(Pat.Project proj) { InitializeComponent(); comboBox1.Items.AddRange(proj.Actions .Select(a => a.Category) .Where(s => s != null && s.Length != 0) .Distinct() .ToArray()); }
public static void Generate(PlayerExporter exporter, Pat.Project proj, CodeGenerator output) { output.WriteStatement(GenerateBeginAirJump(exporter, proj).Statement()); output.WriteStatement(GenerateBeginAirSlide(exporter, proj).Statement()); output.WriteStatement(GenerateBeginJump(exporter, proj).Statement()); output.WriteStatement(GenerateBeginWalk(exporter, proj).Statement()); output.WriteStatement(GenerateInputCancelMove(exporter, proj).Statement()); output.WriteStatement(GenerateInputAttack(exporter, proj).Statement()); }
public ActionEditForm(Pat.Project proj, Pat.Action action) { InitializeComponent(); _Project = proj; _Action = action; AdjustListSize(); RefreshList(); }
private static FunctionBlock GenerateBeginAirSlide(PlayerExporter exporter, Pat.Project proj) { return(new FunctionBlock("BeginAirSlide", new string[0], new ILineObject[] { new ControlBlock(ControlBlockType.If, "this.input.x", new ILineObject[] { new SimpleLineObject("this.vx += this.input.x > 0 ? 0.2 : -0.2;"), new ControlBlock(ControlBlockType.If, "this.Abs(this.vx) > 4.0", new ILineObject[] { new SimpleLineObject("this.vx = this.vx > 0.0 ? 4.0 : -4.0;"), }).Statement(), }).Statement(), })); }
public EffectListEditForm(Pat.Project proj, Pat.EffectList effects) { InitializeComponent(); treeView1.LinkedPropertyGrid = propertyGrid1; treeView1.LinkedDeleteButton = button1; treeView1.LinkedResetButton = button2; treeView1.LinkedMoveDownButton = button3; treeView1.LinkedMoveUpButton = button4; treeView1.Nodes.AddEditableList(new EditableEnvironment(proj), effects.Effects); }
public ActionBehaviorEditForm(Pat.Project proj, Pat.Action action) { InitializeComponent(); treeView1.LinkedPropertyGrid = propertyGrid1; treeView1.LinkedDeleteButton = button1; treeView1.LinkedResetButton = button2; treeView1.LinkedMoveDownButton = button3; treeView1.LinkedMoveUpButton = button4; treeView1.Nodes.AddEditableList(new EditableEnvironment(proj), action.Behaviors); }
public Editor(Pat.Project proj) { ProjectReset += ResetActionIndex; AnimationReset += ResetPreviewMode; AnimationReset += ResetEditMode; Project = proj; AnimationFramesUI = new AnimationFrames(this); PreviewWindowUI = new PreviewWindow(this); AnimationListUI = new AnimationList(this); }
private static FunctionBlock GenerateInputAttack(PlayerExporter exporter, Pat.Project proj) { return(new FunctionBlock("InputAttack", new string[0], new ILineObject[] { new ControlBlock(ControlBlockType.If, "this.input.b0 == 1", new ILineObject[] { new SimpleLineObject("this.u.inputCountA = 10;"), }).Statement(), new ControlBlock(ControlBlockType.If, "this.input.b1 == 1", new ILineObject[] { new SimpleLineObject("this.u.inputCountB = 10;"), }).Statement(), new ControlBlock(ControlBlockType.If, "this.input.b3 == 1", new ILineObject[] { new SimpleLineObject("this.u.inputCountC = 10;"), }).Statement(), new SimpleLineObject("this.u.inputCountA--;"), new SimpleLineObject("this.u.inputCountB--;"), new SimpleLineObject("this.u.inputCountC--;"), }.Concat(SkillGenerator.GenerateInputAttackFunction(exporter)))); }
private static FunctionBlock GenerateBeginWalk(PlayerExporter exporter, Pat.Project proj) { return(new FunctionBlock("BeginWalk", new string[0], new ILineObject[] { new ControlBlock(ControlBlockType.If, "this.input.x > 0", new ILineObject[] { new SimpleLineObject("this.direction = 1.0;"), new SimpleLineObject("this.vx = 4.0;"), }).Statement(), new ControlBlock(ControlBlockType.Else, new ILineObject[] { new SimpleLineObject("this.direction = -1.0;"), new SimpleLineObject("this.vx = -4.0;"), }).Statement(), new ControlBlock(ControlBlockType.If, "this.motion != this.u.CA + 1", new ILineObject[] { new SimpleLineObject("this.ChangeFreeMove();"), new SimpleLineObject("this.fallLabel = this.u.BeginFall;"), new SimpleLineObject("this.SetMotion(this.u.CA + 1, 0);"), }).Statement(), })); }
public void InitExporter(Pat.Project proj, string outputFile) { _Project = proj; _OutputFile = outputFile; _OutputDir = Path.GetDirectoryName(outputFile); _ImageList = new ImageListExporter(); _OutputData = new GSPat.GSPatFile() { Animations = new List <GSPat.Animation>(), Images = new List <string>(), }; _Codes.Clear(); //first export images foreach (var img in proj.Images) { _ImageList.AddImage(_OutputData, img); } }
public override void Export(Pat.Project proj) { _Project = proj; _GeneratedActionID.Clear(); _SSERecorder = new SegmentStartEventRecorder(); _NextFreeActionID = 20; //init script var actorCommon = base.AddCodeFile("actorCommon.add.cv4"); PlayerInitFunctionGenerator.Generate(this, proj, actorCommon); //actions ExportAction(Animations.Stand, 0); ExportAction(Animations.Walk, 1); ExportAction(Animations.JumpUp, 3); ExportAction(Animations.JumpFront, 4); ExportAction(Animations.Fall, 8); ExportAction(Animations.Damage, 10); ExportReviveLightAction(17); ExportAction(Animations.Dead, 18); ExportAction(Animations.Lost, 19); var playerScript = base.AddCodeFile(ScriptFileName + ".cv4"); SystemActionFunctionGenerator.Generate(this, proj, playerScript); this.GenEnv = SkillGenerator.CreateEnv(this, playerScript); SkillGenerator.GenerateSkills(this, playerScript); this.GenEnv = null; SkillGenerator.GenerateStartMotionFunction(_SSERecorder, playerScript); ExportAction(Animations.Stand, 100); ExportAction(Animations.Stand, 101); ExportAction(Animations.Stand, 102); ExportAction(Animations.Stand, 103); }
public PlayerExporterOptionsForm(Pat.Project proj, PlayerExporter exporter) { InitializeComponent(); treeView1.LinkedPropertyGrid = propertyGrid1; treeView1.LinkedDeleteButton = button1; treeView1.LinkedResetButton = button2; treeView1.LinkedMoveDownButton = button3; treeView1.LinkedMoveUpButton = button4; var env = new EditableEnvironment(proj); treeView1.Nodes.Add(new TreeNode { Text = "Export Options", Tag = exporter, }); treeView1.Nodes.Add(new TreeNode { Text = "System Animations", Tag = exporter.Animations, }); treeView1.Nodes.Add(new TreeNode { Text = "Player Information", Tag = exporter.PlayerInformation, }); var skills = new TreeNode { Text = "Skills", }; treeView1.Nodes.Add(skills); skills.Nodes.AddEditableList(env, exporter.Skills); }
public static void Generate(PlayerExporter exporter, Pat.Project proj, CodeGenerator writer) { var func = new FunctionBlock( "Init_" + exporter.PlayerName, new[] { "t" }, new ILineObject[] { new SimpleLineObject("this.type = 0;"), new SimpleLineObject("this.fontType = 0;"), new SimpleLineObject("this.PlayerInit(\"homura\", t.playerID);"), new SimpleLineObject("this.CompileFile(\"data/actor/" + exporter.ScriptFileName + ".nut\", this.u);"), new SimpleLineObject("this.u.CA = " + exporter.BaseIndex + ";"), new SimpleLineObject("this.u.regainCycle = " + exporter.PlayerInformation.RegainCycle + ";"), new SimpleLineObject("this.u.regainRate = " + exporter.PlayerInformation.RegainRate + ";"), new SimpleLineObject("this.u.magicUse = " + exporter.PlayerInformation.MagicUse + ";"), new SimpleLineObject("this.u.atkOffset = " + exporter.PlayerInformation.AtkOffset + ";"), new SimpleLineObject("this.SetMotion(this.u.CA + 0, 0);"), new SimpleLineObject("this.SetUpdateFunction(this.u.Update_Normal);"), new SimpleLineObject("this.fallLabel = this.u.BeginFall;"), new SimpleLineObject("this.u.dexLV = 5;"), new SimpleLineObject("this.world2d.CreateActor(this.x, this.y, this.direction, this.Player_Shadow, this.DefaultShotTable());"), }); writer.WriteStatement(new BlockStatement(func)); }
public static void ShowEditorForm(Pat.Project proj) { using (var frm = new EditorForm()) { using (var editor = new Editor(proj)) { Program.EditorForBackup = editor; frm._Editor = editor; editor.AnimationFramesUI.Init(frm.animationFrames); editor.PreviewWindowUI.Init(frm.previewWindow); editor.AnimationListUI.Init(frm.animations); #region init clipboards frm._ClipboardPhysical = new ClipboardUIProvider(editor.PreviewWindowUI.PhysicalEditing) { New = new ClipboardUIElementToolstripItem(frm.newPhysicalToolStripMenuItem), Cut = new ClipboardUIElementToolstripItem(frm.cutPhysicalToolStripMenuItem), Copy = new ClipboardUIElementToolstripItem(frm.copyPhysicalToolStripMenuItem), Paste = new ClipboardUIElementToolstripItem(frm.pastePhysicalToolStripMenuItem), Delete = new ClipboardUIElementToolstripItem(frm.deletePhysicalToolStripMenuItem), }; frm._ClipboardHit = new ClipboardUIProvider(editor.PreviewWindowUI.HitEditing) { New = new ClipboardUIElementToolstripItem(frm.newHitToolStripMenuItem), Cut = new ClipboardUIElementToolstripItem(frm.cutHitToolStripMenuItem), Copy = new ClipboardUIElementToolstripItem(frm.copyHitToolStripMenuItem), Paste = new ClipboardUIElementToolstripItem(frm.pasteHitToolStripMenuItem), Delete = new ClipboardUIElementToolstripItem(frm.deleteHitToolStripMenuItem), }; frm._ClipboardAttack = new ClipboardUIProvider(editor.PreviewWindowUI.AttackEditing) { New = new ClipboardUIElementToolstripItem(frm.newAttackToolStripMenuItem), Cut = new ClipboardUIElementToolstripItem(frm.cutAttackToolStripMenuItem), Copy = new ClipboardUIElementToolstripItem(frm.copyAttackToolStripMenuItem), Paste = new ClipboardUIElementToolstripItem(frm.pasteAttackToolStripMenuItem), Delete = new ClipboardUIElementToolstripItem(frm.deleteAttackToolStripMenuItem), }; frm._ClipboardFrame = new ClipboardUIProvider(editor.AnimationFramesUI) { Cut = new ClipboardUIElementToolstripItem(frm.toolStripMenuItemCutFrame), Copy = new ClipboardUIElementToolstripItem(frm.toolStripMenuItemCopyFrame), Paste = new ClipboardUIElementToolstripItem(frm.toolStripMenuItemPasteFrame), Delete = new ClipboardUIElementToolstripItem(frm.toolStripMenuItemDeleteFrame), }; #endregion #region init edit menu visible groups frm._GroupEditPhysical = new VisibleGroup( frm.physicalToolStripMenuItem1, frm.newPhysicalToolStripMenuItem, frm.cutPhysicalToolStripMenuItem, frm.copyPhysicalToolStripMenuItem, frm.pastePhysicalToolStripMenuItem, frm.deletePhysicalToolStripMenuItem ); frm._GroupEditHit = new VisibleGroup( frm.hitToolStripMenuItem, frm.newHitToolStripMenuItem, frm.cutHitToolStripMenuItem, frm.copyHitToolStripMenuItem, frm.pasteHitToolStripMenuItem, frm.deleteHitToolStripMenuItem ); frm._GroupEditAttack = new VisibleGroup( frm.attackToolStripMenuItem2, frm.newAttackToolStripMenuItem, frm.cutAttackToolStripMenuItem, frm.copyAttackToolStripMenuItem, frm.pasteAttackToolStripMenuItem, frm.deleteAttackToolStripMenuItem ); #endregion #region init tool bar groups frm._GroupToolAnimationList = new VisibleGroup( frm.toolStripButtonNew, frm.toolStripButtonOpen, frm.toolStripButtonSave, frm.toolStripButtonSaveAs, frm.toolStripButtonDirectories, frm.toolStripSeparator13, frm.toolStripButtonImport, frm.toolStripSeparator14, frm.toolStripButtonExporter, frm.toolStripButtonExport, frm.toolStripSeparator7, frm.toolStripButtonNewAnimation, frm.toolStripButtonRemoveAnimation, frm.toolStripButtonEditAnimation, frm.toolStripButtonAnimationProperty ); frm._GroupToolAnimation = new VisibleGroup( frm.toolStripExpandAll, frm.toolStripCollapseAll, frm.toolStripSeparator1, frm.toolStripButtonToolCursor, frm.toolStripButtonToolMove, frm.toolStripButtonToolPhysics, frm.toolStripButtonToolHit, frm.toolStripButtonToolAttack, frm.toolStripButtonToolPoint, frm.toolStripSeparator2, frm.toolStripSplitBoxVisible, frm.toolStripSeparator3, frm.toolStripSplitEdit, frm.toolStripSplitButtonKeyFrame, frm.toolStripSeparator6, frm.toolStripButtonPlay, frm.toolStripButtonEditAction, frm.toolStripSeparator12, frm.toolStripButtonBack ); frm._GroupToolImageList = new VisibleGroup(new ToolStripButton[0]); frm.SetupToolbarEnabled(); #endregion editor.AnimationListUI.SelectedChange += frm.SetupToolbarEnabled; editor.FrameReset += delegate() { var action = editor.CurrentAction; var seg = editor.CurrentSegment; if (action != null && seg != null && seg.Frames.Count > 0) { var isKeyFrame = editor.CurrentFrame == seg.Frames[0]; var isLoop = isKeyFrame ? editor.CurrentSegment.IsLoop : false; frm.keyFrameToolStripMenuItem.Enabled = true; frm.keyFrameToolStripMenuItem.Checked = isKeyFrame; frm.editDamageToolStripMenuItem.Enabled = isKeyFrame; frm.loopToolStripMenuItem.Enabled = isKeyFrame; frm.loopToolStripMenuItem.Checked = isLoop; } else { frm.keyFrameToolStripMenuItem.Enabled = false; frm.keyFrameToolStripMenuItem.Checked = false; frm.editDamageToolStripMenuItem.Enabled = false; frm.loopToolStripMenuItem.Enabled = false; frm.loopToolStripMenuItem.Checked = false; } }; editor.EditModeChanged += frm.OnEditModeChanged; editor.PreviewModeChanged += frm.OnPreviewModeChanged; editor.CurrentUISwitched += delegate() { switch (editor.CurrentUI) { case EditorUI.AnimationList: frm.ChangeActivePanel(0); break; case EditorUI.Animation: frm.ChangeActivePanel(1); editor.EditMode = FrameEditMode.None; frm.ResetPreviewPosition(1.0f); break; } frm.OnPreviewModeChanged(); }; editor.CurrentUI = EditorUI.AnimationList; frm.Show(); frm.RunRenderLoop(); Program.EditorForBackup = null; } } }
public SystemAnimationProvider(Pat.Project proj) { _Project = proj; }
public ImportPatAnimationForm(Pat.Project proj) { InitializeComponent(); _Project = proj; }
public abstract void ShowOptionDialog(Pat.Project proj);
public FrameReferenceEditForm(Pat.Project proj) { InitializeComponent(); _Project = proj; }
public abstract void Export(Pat.Project proj);
private static FunctionBlock GenerateInputCancelMove(PlayerExporter exporter, Pat.Project proj) { return(new FunctionBlock("InputCancelMove", new string[0], new ILineObject[] { new ControlBlock(ControlBlockType.If, "this.flagState & 2097152 && this.input.b2 > 0 && this.input.b2 < 10", new ILineObject[] { new ControlBlock(ControlBlockType.If, "this.isAir", new ILineObject[] { new SimpleLineObject("this.u.BeginAirJump.call(this);"), }).Statement(), new ControlBlock(ControlBlockType.Else, new ILineObject[] { new SimpleLineObject("this.u.BeginJump.call(this);"), }).Statement(), }).Statement(), })); }