public static AnimationCollection Load(string path) { List<Frame> frames = new List<Frame>(); List<Animation> animations = new List<Animation>(); using(StreamReader r = new StreamReader(path)) { // frames int frameCount = int.Parse(r.ReadLine()); for (int i = 0; i < frameCount; i++) { string fName = r.ReadLine(); List<FramePart> fps = new List<FramePart>(); int fpCount = int.Parse(r.ReadLine()); for (int j = 0; j < fpCount; j++) { string[] pos = r.ReadLine().Split(','); Vector2 position = new Vector2(float.Parse(pos[0], CultureInfo.InvariantCulture), float.Parse(pos[1], CultureInfo.InvariantCulture)); string[] src = r.ReadLine().Split(','); Rectangle source = new Rectangle(int.Parse(src[0]), int.Parse(src[1]), int.Parse(src[2]),int.Parse(src[3])); float rotation = float.Parse(r.ReadLine(), CultureInfo.InvariantCulture); float scale = float.Parse(r.ReadLine(), CultureInfo.InvariantCulture); fps.Add(new FramePart(position, rotation, scale) { Source = source }); } Frame f = new Frame(null, fps) { Name = fName }; frames.Add(f); } int animCount = int.Parse(r.ReadLine()); for (int i = 0; i < animCount; i++) { string animName = r.ReadLine(); List<KeyFrame> keyFrames = new List<KeyFrame>(); int kfCount = int.Parse(r.ReadLine()); for (int j = 0; j < kfCount; j++) { float duration = float.Parse(r.ReadLine(), CultureInfo.InvariantCulture); int fIndex = int.Parse(r.ReadLine()); string[] scripts = new string[int.Parse(r.ReadLine())]; for (int x = 0; x < scripts.Length; x++) { scripts[x] = r.ReadLine(); } List<KeyFrameScript> s = new List<KeyFrameScript>(); KeyFrame kf = new KeyFrame(frames[fIndex], duration, scripts); keyFrames.Add(kf); } Animation a = new Animation(keyFrames) { Name = animName }; animations.Add(a); } AnimationCollection collection = new AnimationCollection(frames, animations); return collection; } }
public void SetAnimation(Animation anim) { this.anim = anim; }
void btnNewAnimClicked() { Animation ani = new Animation(new List<NibLib.Frames.KeyFrame>()) { Name = "a" }; animList.AddNew(ani); AnimChanged(ani); }
void animList_OnDoubleClickedEvent(Animation item) { textBox.Show(item); }
void animList_OnClickedEvent(Animation item) { animCompo.SetAnimation(item); AnimChanged(item); }
void AnimChanged(Animation ani) { if (ani == null) { kfList.items = new List<KeyFrame>(); } else { kfList.items = ani.Keyframes; } }