public static void ExportAnimation(GSPat.GSPatFile file, ImageListExporter images, Pat.Action action, int id) { { var eAnimation = new GSPat.Animation() { AnimationID = id, AttackLevel = 0, CancelLevel = ExportCancelLevel(action.Segments[0].CancelLevel), IsLoop = action.Segments[0].IsLoop, Type = GSPat.AnimationType.Normal, }; ExportFrames(eAnimation, action.Segments[0], images); file.Animations.Add(eAnimation); } for (int i = 1; i < action.Segments.Count; ++i) { var eAnimation = new GSPat.Animation() { AnimationID = -2, AttackLevel = 0, CancelLevel = ExportCancelLevel(action.Segments[i].CancelLevel), IsLoop = action.Segments[i].IsLoop, Type = GSPat.AnimationType.Normal, }; ExportFrames(eAnimation, action.Segments[i], images); file.Animations.Add(eAnimation); } }
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; }
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); } }
private void ImportPatAnimationForm_Shown(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() != System.Windows.Forms.DialogResult.OK) { CancelDialog(); return; } var file = openFileDialog1.FileName; var path = Path.GetDirectoryName(file); var palFile = Path.Combine(path, "palette000.pal"); if (!File.Exists(palFile)) { if (MessageBox.Show("Palette file not found. Please choose one.", "Animation Import", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.OK) { if (openFileDialog2.ShowDialog() != System.Windows.Forms.DialogResult.OK) { CancelDialog(); return; } palFile = openFileDialog2.FileName; } else { palFile = null; } } //create objects GSPat.GSPatFile gspat; using (var s = File.OpenRead(file)) { gspat = GSPat.GSPatReader.ReadFromStream(s); } var pal = palFile != null?Images.CV2Palette.ReadPaletteFile(palFile) : null; //create image manager _Images = new GSPat.ImageManager(gspat, path, pal); //refresh list var lastIndex = -1; var segmentIndex = 0; foreach (var animation in gspat.Animations) { ++segmentIndex; if (animation.AnimationID == -1) { //can't import clone animation lastIndex = -1; continue; } else if (animation.AnimationID == -2) { AddFollowerAnimation(animation, lastIndex, segmentIndex); } else { AddAnimation(animation); lastIndex = animation.AnimationID; segmentIndex = 0; } } _GSPatFile = gspat; _Path = path; _Palette = palFile; }
public void AddImage(GSPat.GSPatFile file, Pat.FrameImage image) { _ImageToFile.Add(image.ImageID, file.Images.Count); file.Images.Add(image.Resource.ResourceID); _ImageIDToObj.Add(image.ImageID, image); }