private void TryImport(OpenedFile[] files)
        {
            // Whether at least one file was successfully imported
            var successfulImport = false;
            // Whether at least one .creat file failed to be imported
            var            failedImport       = false;
            CreatureDesign lastImportedDesign = null;

            foreach (var file in files)
            {
                var extension = file.Extension.ToLower();
                if (extension.Equals(".creat"))
                {
                    var nameFromFile = CreatureSerializer.EXTENSION_PATTERN.Replace(file.Name, "");
                    var encoded      = file.ToUTF8String();
                    try {
                        var design = CreatureSerializer.ParseCreatureDesign(encoded, nameFromFile);
                        CreatureSerializer.SaveCreatureDesign(design, false);
                        lastImportedDesign = design;
                    } catch {
                        failedImport = true;
                        Debug.LogError(string.Format("Failed to parse .creat file contents: {0}", encoded));
                        continue;
                    }
                    successfulImport = true;
                }
            }
            RefreshCache();
            try {
                viewController.Refresh();
            } catch {}
            if (successfulImport)
            {
                importIndicator.FadeInOut();
                CloseAndLoadOnNextFrame(lastImportedDesign.Name);
            }
            if (failedImport)
            {
                failedImportIndicator.FadeInOut(1.8f);
            }
        }
Beispiel #2
0
 public void SaveDesign(CreatureDesign design)
 {
     CreatureSerializer.SaveCreatureDesign(design);
 }