示例#1
0
        public static bool OpenPackage(AMTPackage Package, string FileName)
        {
            AMTPackage ClonedPackage;

            try
            {
                ClonedPackage = (AMTPackage)JsonConvert.DeserializeObject <AMTPackage>(File.ReadAllText(FileName)).Clone();
            }
            catch
            {
                return(false);
            }
            if (!ClonedPackage.Animation.Manifest.Version.Equals(AMTConfig.Version))
            {
                MessageBox.Show("AMT file version does not match!", "Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            //Setting Variables
            Package.Animation    = ClonedPackage.Animation;
            Package.Resources    = ClonedPackage.Resources;
            Package.Name         = ClonedPackage.Name;
            Package.WorkingDir   = Path.GetDirectoryName(FileName);
            Package.PackageState = AMTUtil.State.READY;
            foreach (KeyValuePair <string, string> s in Package.Resources)
            {
                if (!File.Exists(AMTUtil.GetAbsPath(Package.WorkingDir, s + AMTConfig.ResourceExtension)))
                {
                    MessageBox.Show("Resource [" + s.Value + "] is not found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }
            return(true);
        }
示例#2
0
        public static AMTResource GetResourceFromName(AMTPackage Package, string ResourceName)
        {
            string AbsResourceName = AMTUtil.GetAbsPath(Package.WorkingDir, ResourceName + AMTConfig.ResourceExtension);

            if (Package.Resources.Exists(delegate(KeyValuePair <string, string> match)
            {
                return(match.Value == ResourceName);
            }))
            {
                return((AMTResource)JsonConvert.DeserializeObject <AMTResource>(File.ReadAllText(AbsResourceName)));
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        /// <summary>
        /// Expand Current action with action reference frames into Action with frame reference frames
        /// </summary>
        /// <param name="Animation">Current Animation</param>
        /// <param name="Action">Action to Expand</param>
        /// <returns>New expanded action</returns>
        public static AMTAction ExpandFrame(AMTAnimation Animation, AMTAction Action)
        {
            AMTAction ExpandedAction = new AMTAction();

            ExpandedAction.Name = Action.Name;
            ExpandedAction.Frames.Clear();
            foreach (AMTFrame f in Action.Frames)
            {
                if (f.ActionRef != null)
                {
                    AMTAction EmbeddedAction         = AMTUtil.GetActionFromName(Animation, f.ActionRef);
                    AMTAction ExpandedEmbeddedAction = ExpandFrame(Animation, EmbeddedAction);
                    foreach (AMTFrame fe in ExpandedEmbeddedAction.Frames)
                    {
                        ExpandedAction.Frames.Add(fe);
                    }
                }
                else
                {
                    ExpandedAction.Frames.Add(f);
                }
            }
            return(ExpandedAction);
        }