private void SaveMod_Click(object sender, RoutedEventArgs e)
        {
            List <AbstractAsset> assets = App.Instance.MainWindow !.AssetTabControls.SelectMany(atc => atc.GetAssets()).ToList();

            List <UserAsset> userAssets = new List <UserAsset>();

            foreach (AbstractAsset asset in assets)
            {
                userAssets.Add(asset.ToUserAsset());
            }

            SaveFileDialog dialog = new SaveFileDialog {
                Filter = _modFileFilter
            };

            dialog.OpenModsRootFolder();

            bool?result = dialog.ShowDialog();

            if (!result.HasValue || !result.Value)
            {
                return;
            }

            JsonFileUtils.SerializeToFile(dialog.FileName, userAssets, true);
        }
Exemple #2
0
        /// <summary>
        /// Creates a mod file based on the assets found in the directory specified by <paramref name="path"/> and places it inside that directory.
        /// </summary>
        public static void CreateModFileFromPath(string path)
        {
            List <UserAsset> assets = GetAssets(path);

            string folderName = new DirectoryInfo(path).Name;

            JsonFileUtils.SerializeToFile(Path.Combine(path, $"{folderName}.ddae"), assets, true);
        }
        private static void SaveHexRepresentationFile(Dictionary <string, byte[]> particleChunks)
        {
            Dictionary <string, string> hex = new Dictionary <string, string>();

            foreach (KeyValuePair <string, byte[]> kvp in particleChunks)
            {
                hex[kvp.Key] = BitConverter.ToString(kvp.Value).Replace(" - ", "");
            }

            JsonFileUtils.SerializeToFile(@"C:\Program Files (x86)\Steam\steamapps\common\devildaggers\Extracted\particle\Particle.json", hex, false);
        }
Exemple #4
0
        public static List <UserAsset> GetAssetsFromModFilePath(string path)
        {
            List <UserAsset>?assets = JsonFileUtils.TryDeserializeFromFile <List <UserAsset> >(path, true);

            if (assets == null)
            {
                return(new List <UserAsset>());
            }

            UserHandler.Instance.Cache.OpenedModFilePath = path;

            return(assets);
        }
Exemple #5
0
 /// Execute the save action
 ///
 public void ExecuteSave()
 {
     JsonFileUtils.SaveDataToJsonFile(m_fileName, m_data, FileSystem.Location.Persistent);
 }