Ejemplo n.º 1
0
        /// <summary>
        /// Loads a SkeletonBodyInfo from the given FilePath. Assumes the loading is from the ContentPaths.Dev.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        /// <returns>The loaded SkeletonBodyInfo, or null if the SkeletonBodyInfo failed to load.</returns>
        public static SkeletonBodyInfo LoadSkeletonBodyInfo(string filePath)
        {
            var bodyName     = Path.GetFileNameWithoutExtension(filePath);
            var realFilePath = SkeletonBodyInfo.GetFilePath(bodyName, ContentPaths.Dev);

            // Make sure the file exists
            if (!File.Exists(realFilePath))
            {
                const string errmsg = "Failed to load SkeletonBodyInfo `{0}` from `{1}` - file does not exist.";
                var          err    = string.Format(errmsg, bodyName, filePath);
                MessageBox.Show(err);
                return(null);
            }

            // Try to load the skeleton
            SkeletonBodyInfo ret;

            try
            {
                ret = new SkeletonBodyInfo(bodyName, ContentPaths.Dev);
            }
            catch (Exception ex)
            {
                const string errmsg = "Failed to load SkeletonBodyInfo `{0}` from `{1}`:{2}{3})";
                var          err    = string.Format(errmsg, bodyName, filePath, Environment.NewLine, ex);
                MessageBox.Show(err);
                return(null);
            }

            return(ret);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// When overridden in the derived class, gets the items to add to the list.
 /// </summary>
 /// <returns>The items to add to the list.</returns>
 protected override IEnumerable <string> GetListItems()
 {
     return(SkeletonBodyInfo.GetBodyNames(ContentPaths.Build).OrderBy(x => x, NaturalStringComparer.Instance));
 }