Esempio n. 1
0
 private void SaveMyMods(object sender = null, PropertyChangedEventArgs e = null)
 {
     // Ignore property change events for CanUpdateMod and Enabled since those changes will be covered by the Status property changing
     if (canSaveData && e?.PropertyName != "CanUpdateMod" && e?.PropertyName != "Enabled")
     {
         try { TroveMod.SaveMyMods((from mod in MyMods select mod.DataObject).ToList()); }
         catch (Exception ex) { log.Error("Error saving my mods", ex); }
     }
 }
Esempio n. 2
0
 private void AddFile(string file)
 {
     try
     {
         string relativePath = TroveMod.MakeRelativePath(file, PrimaryLocationPath);
         if (!ModFiles.Contains(relativePath))
         {
             ModFiles.Add(relativePath);
         }
     }
     catch (Exception ex) { log.Error(string.Format("Error adding file {0}", file), ex); }
 }
Esempio n. 3
0
 private void UninstallAllMods(object param = null)
 {
     try
     {
         log.Info("Uninstalling all mods");
         foreach (dynamic mod in MyMods.Where(m => m.DataObject.Enabled))
         {
             mod.Enabled = false;
         }
         TroveMod.RemoveModFolders();
     }
     catch (Exception ex)
     {
         log.Error("Error uninstalling all mods", ex);
     }
 }
Esempio n. 4
0
        private void LoadYaml(string yamlPath)
        {
            try
            {
                log.InfoFormat("Loading YAML file: {0}", yamlPath);

                string yamlContents = File.ReadAllText(yamlPath);
                var    details      = ModDetails.LoadFromYaml(yamlContents);

                Clear();
                ModAuthor  = details.Author;
                ModTitle   = details.Title;
                ModNotes   = details.Notes;
                ModPreview = details.PreviewPath;
                string preview = TroveMod.GetOverridePath(details.PreviewPath, PrimaryLocationPath);
                if (!string.IsNullOrWhiteSpace(preview) && File.Exists(preview) && (preview.EndsWith(".png", StringComparison.OrdinalIgnoreCase) || preview.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase)))
                {
                    PreviewImage = preview;
                }

                foreach (string file in details.Files)
                {
                    ModFiles.Add(file);
                }

                foreach (string tag in details.Tags)
                {
                    var modTag = ModTags.FirstOrDefault(t => t.Title.Equals(tag, StringComparison.OrdinalIgnoreCase));
                    if (modTag != null)
                    {
                        modTag.Selected = true;
                    }
                    else
                    {
                        AdditionalTags = string.IsNullOrWhiteSpace(AdditionalTags) ? tag : string.Format("{0}, {1}", AdditionalTags, tag);
                    }
                }
            }
            catch (Exception ex) { log.Error(string.Format("Error loading YAML file {0}", yamlPath), ex); }
        }
Esempio n. 5
0
 private void UpdatePreview(string file)
 {
     try
     {
         if (!file.Contains(TroveMod.OverrideFolder))
         {
             string newFile = Path.Combine(PreviewLocation, Path.GetFileName(file));
             File.Copy(file, newFile, true);
             file = newFile;
         }
         if (file.EndsWith(".png", StringComparison.OrdinalIgnoreCase) || file.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase))
         {
             PreviewImage = file;
         }
         ModPreview = TroveMod.MakeRelativePath(file, PrimaryLocationPath);
         if (!ModFiles.Contains(ModPreview))
         {
             ModFiles.Add(ModPreview);
         }
     }
     catch (Exception ex) { log.Error(string.Format("Error updating preview to {0}", file), ex); }
 }