Beispiel #1
0
        public MainViewModel()
        {
            this._projectsDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RimTrans", "Projects");
            var mods = new ObservableCollection <ModListBoxItem>();

            if (Directory.Exists(_projectsDir))
            {
                foreach (string projectFile in Directory.GetFiles(_projectsDir))
                {
                    ModListBoxItem modItem = null;
                    try
                    {
                        modItem = ModListBoxItem.Load(projectFile);
                    }
                    catch (Exception)
                    {
                    }
                    if (modItem == null)
                    {
                        try
                        {
                            File.Delete(projectFile);
                        }
                        catch (Exception)
                        {
                        }
                    }
                    else
                    {
                        mods.Add(modItem);
                    }
                }
            }
            Mods = mods;
        }
Beispiel #2
0
        public AddModViewModel()
        {
            var    modsInternal       = new ObservableCollection <ModListBoxItem>();
            var    modsWorkshop       = new ObservableCollection <ModListBoxItem>();
            string rimworldInstallDir = UserSettings.All.RimWorldInstallDir;
            string internalModsDir    = string.Empty;

            if (!string.IsNullOrWhiteSpace(rimworldInstallDir))
            {
                internalModsDir = Path.Combine(rimworldInstallDir, "Mods");
            }
            if (!string.IsNullOrWhiteSpace(internalModsDir) && Directory.Exists(internalModsDir))
            {
                foreach (var modItem in ModListBoxItem.GetModItems(internalModsDir, ModCategory.Internal))
                {
                    modsInternal.Add(modItem);
                }
            }
            string workshopModsDir = UserSettings.All.WorkshopModsDir;

            if (!string.IsNullOrWhiteSpace(workshopModsDir) && Directory.Exists(workshopModsDir))
            {
                foreach (var modItem in ModListBoxItem.GetModItems(workshopModsDir, ModCategory.Workshop))
                {
                    modsWorkshop.Add(modItem);
                }
            }
            ModsInternal = modsInternal;
            ModsWorkshop = modsWorkshop;
        }