public string NameOf(Animation.Frame frame, Animation.Element element) { int precedingOccurences = occurenceCache.GetPrecedingOccurencesCount(frame, element); string name = $"{HashToName[element.Image]}_{element.Index}_{precedingOccurences}"; return(name); }
/** * Gets the number of times the sprite used by this element was used by elements * in the given frame that came before this element in the frame's element list. * * Uses a simple caching scheme based on the frame for performance improvements. */ public int GetPrecedingOccurencesCount(Animation.Frame frame, Animation.Element element) { if (frame != associatedFrame) { RebuildCache(frame); } return(occurenceMap[element]); }
private XmlElement MakeBoneRefNode(XmlDocument scml, Animation.Frame frame, Animation.Element element, int frameId, SymbolIdProvider symbolIdProvider) { XmlElement boneRef = scml.CreateElement(string.Empty, "bone_ref", string.Empty); int id = symbolIdProvider.GetId(frame, element); boneRef.SetAttribute("id", id.ToString()); boneRef.SetAttribute("timeline", id.ToString()); boneRef.SetAttribute("key", frameId.ToString()); return(boneRef); }
private XmlElement MakeObjectRefNode(XmlDocument scml, Animation.Frame frame, Animation.Element element, int frameId, int elementId, SpriteIdProvider spriteIdProvider, SymbolIdProvider symbolIdProvider) { XmlElement objectRef = scml.CreateElement(string.Empty, "object_ref", string.Empty); string id = spriteIdProvider.GetId(frame, element).ToString(); objectRef.SetAttribute("id", id); objectRef.SetAttribute("parent", symbolIdProvider.GetId(frame, element).ToString()); objectRef.SetAttribute("timeline", id); objectRef.SetAttribute("key", frameId.ToString()); objectRef.SetAttribute("z_index", (frame.Elements - elementId).ToString()); return(objectRef); }
public void ImportFrame() { if (Instance.ViewModel.LoadedAnimationFile == null || Instance.ViewModel.SelectedAnimation == null) return; var fd = new OpenFileDialog(); fd.DefaultExt = "*.frame"; fd.Filter = "RSDK Frame Files|*.frame"; if (fd.ShowDialog() == true) { var importFrame = new Animation.Frame(); importFrame.ImportFrom(EngineType.RSDKv5, fd.FileName); Instance.ViewModel.LoadedAnimationFile.Animations[Instance.ViewModel.SelectedAnimationIndex].Frames.Add(importFrame); } }
private XmlElement MakeMainlineKeyNode(XmlDocument scml, Animation.Frame frame, int frameId, int rate, SpriteIdProvider spriteIdProvider, SymbolIdProvider symbolIdProvider) { XmlElement key = scml.CreateElement(string.Empty, "key", string.Empty); key.SetAttribute("id", frameId.ToString()); key.SetAttribute("time", (frameId * rate).ToString()); int elementId = 0; foreach (Animation.Element element in frame.ElementsList) { key.AppendChild(MakeBoneRefNode(scml, frame, element, frameId, symbolIdProvider)); key.AppendChild(MakeObjectRefNode(scml, frame, element, frameId, elementId++, spriteIdProvider, symbolIdProvider)); } return(key); }
private void RebuildCache(Animation.Frame frame) { occurenceMap = new Dictionary <Animation.Element, int>(); associatedFrame = frame; Dictionary <string, int> rollingOccurenceCount = new Dictionary <string, int>(); foreach (Animation.Element element in frame.ElementsList) { string name = $"{HashToName[element.Image]}_{element.Index}"; if (!rollingOccurenceCount.ContainsKey(name)) { rollingOccurenceCount.Add(name, 0); } occurenceMap.Add(element, rollingOccurenceCount[name]++); } }
public static bool ConnectToFrame(GH_Component com, out Animation.Frame frameComponent) { if (Animation.Frame.Component == null || Animation.Frame.Component.OnPingDocument() != com.OnPingDocument()) { com.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please Set Frame Component First!"); frameComponent = null; return(false); } else if (Animation.Frame.Component.Params.Input[0].SourceCount == 0) { com.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please Finish Frame Component!"); frameComponent = null; return(false); } else { frameComponent = Animation.Frame.Component; return(true); } }
public int GetId(Animation.Frame frame, Animation.Element element) { string name = NameOf(frame, element); return(IdMap[name]); }