public static OsbSpriteWriter CreateWriter(OsbSprite osbSprite, AnimatedValue <CommandPosition> moveTimeline, AnimatedValue <CommandDecimal> moveXTimeline, AnimatedValue <CommandDecimal> moveYTimeline, AnimatedValue <CommandDecimal> scaleTimeline, AnimatedValue <CommandScale> scaleVecTimeline, AnimatedValue <CommandDecimal> rotateTimeline, AnimatedValue <CommandDecimal> fadeTimeline, AnimatedValue <CommandColor> colorTimeline, TextWriter writer, ExportSettings exportSettings, OsbLayer layer) { if (osbSprite is OsbAnimation osbAnimation) { return(new OsbAnimationWriter(osbAnimation, moveTimeline, moveXTimeline, moveYTimeline, scaleTimeline, scaleVecTimeline, rotateTimeline, fadeTimeline, colorTimeline, writer, exportSettings, layer)); } else { return(new OsbSpriteWriter(osbSprite, moveTimeline, moveXTimeline, moveYTimeline, scaleTimeline, scaleVecTimeline, rotateTimeline, fadeTimeline, colorTimeline, writer, exportSettings, layer)); } }
private void writeOsbSprite(OsbSprite sprite) { WriteHeader(sprite); foreach (var command in sprite.Commands) { command.WriteOsb(TextWriter, ExportSettings, 1); } }
protected override void WriteHeader(OsbSprite sprite) { if (sprite is OsbAnimation animation) { var frameDelay = animation.FrameDelay; TextWriter.WriteLine($"Animation,{OsbLayer},{animation.Origin},\"{animation.TexturePath.Trim()}\",{animation.InitialPosition.X.ToString(ExportSettings.NumberFormat)},{animation.InitialPosition.Y.ToString(ExportSettings.NumberFormat)},{animation.FrameCount},{frameDelay.ToString(ExportSettings.NumberFormat)},{animation.LoopType}"); } else { base.WriteHeader(sprite); } }
protected virtual OsbSprite CreateSprite(List <IFragmentableCommand> segment) { var sprite = new OsbSprite() { TexturePath = osbSprite.TexturePath, InitialPosition = osbSprite.InitialPosition, Origin = osbSprite.Origin, }; foreach (var command in segment) { sprite.AddCommand(command); } return(sprite); }
protected virtual void WriteHeader(OsbSprite sprite) { TextWriter.Write($"Sprite,{OsbLayer},{sprite.Origin},\"{sprite.TexturePath.Trim()}\""); if (!moveTimeline.HasCommands && !moveXTimeline.HasCommands) { TextWriter.Write($",{sprite.InitialPosition.X.ToString(ExportSettings.NumberFormat)}"); } else { TextWriter.Write($",0"); } if (!moveTimeline.HasCommands && !moveYTimeline.HasCommands) { TextWriter.WriteLine($",{sprite.InitialPosition.Y.ToString(ExportSettings.NumberFormat)}"); } else { TextWriter.WriteLine($",0"); } }
protected override OsbSprite CreateSprite(List <IFragmentableCommand> segment) { if (osbAnimation.LoopType == OsbLoopType.LoopOnce && segment.Min(c => c.StartTime) >= osbAnimation.AnimationEndTime) { //this shouldn't loop again so we need a sprite instead var sprite = new OsbSprite() { InitialPosition = osbAnimation.InitialPosition, Origin = osbAnimation.Origin, TexturePath = getLastFramePath(), }; foreach (var command in segment) { sprite.AddCommand(command); } return(sprite); } else { var animation = new OsbAnimation() { TexturePath = osbAnimation.TexturePath, InitialPosition = osbAnimation.InitialPosition, Origin = osbAnimation.Origin, FrameCount = osbAnimation.FrameCount, FrameDelay = osbAnimation.FrameDelay, LoopType = osbAnimation.LoopType, }; foreach (var command in segment) { animation.AddCommand(command); } return(animation); } }
public OsbSpriteWriter(OsbSprite osbSprite, AnimatedValue <CommandPosition> moveTimeline, AnimatedValue <CommandDecimal> moveXTimeline, AnimatedValue <CommandDecimal> moveYTimeline, AnimatedValue <CommandDecimal> scaleTimeline, AnimatedValue <CommandScale> scaleVecTimeline, AnimatedValue <CommandDecimal> rotateTimeline, AnimatedValue <CommandDecimal> fadeTimeline, AnimatedValue <CommandColor> colorTimeline, TextWriter writer, ExportSettings exportSettings, OsbLayer layer) { this.osbSprite = osbSprite; this.moveTimeline = moveTimeline; this.moveXTimeline = moveXTimeline; this.moveYTimeline = moveYTimeline; this.scaleTimeline = scaleTimeline; this.scaleVecTimeline = scaleVecTimeline; this.rotateTimeline = rotateTimeline; this.fadeTimeline = fadeTimeline; this.colorTimeline = colorTimeline; TextWriter = writer; ExportSettings = exportSettings; OsbLayer = layer; }