Ejemplo n.º 1
0
        public static bool SaveBinds(Mod mod, Dictionary <string, string> binds)
        {
            try
            {
                if (SH2WorkshopFileHandler.IsModBindable(mod.ModGUID) == false)
                {
                    return(false);
                }
                var settings = SH2WorkshopFileHandler.GetSettings();
                if (string.IsNullOrWhiteSpace(settings.GameFolderLocation))
                {
                    return(false);
                }

                File.WriteAllText(Path.Combine(settings.GameFolderLocation, SH2WorkshopFileHandler.ModsInstalledFolder, mod.ModGUID, "binds.json"), JsonConvert.SerializeObject(binds, Formatting.Indented));
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public static List <Mod> GetInstalledMods(List <Mod> modList)
        {
            try
            {
                var settings = SH2WorkshopFileHandler.GetSettings();

                if (string.IsNullOrWhiteSpace(settings.GameFolderLocation))
                {
                    return(new List <Mod>());
                }

                if (Directory.Exists(Path.Combine(settings.GameFolderLocation, SH2WorkshopFileHandler.ModsInstalledFolder)) == false)
                {
                    return(new List <Mod>());
                }
                var modGuids = Directory.GetDirectories(Path.Combine(settings.GameFolderLocation, SH2WorkshopFileHandler.ModsInstalledFolder));

                var installedMods = new List <Mod>();
                foreach (var mgPath in modGuids)
                {
                    var mg = Path.GetFileName(mgPath);
                    if (modList.Any(p => p.ModGUID == mg))
                    {
                        var mod = modList.FirstOrDefault(p => p.ModGUID == mg);
                        if (mod == null)
                        {
                            continue;
                        }
                        installedMods.Add(mod);
                    }
                }
                return(installedMods);
            }
            catch
            {
                return(new List <Mod>());
            }
        }
Ejemplo n.º 3
0
        public static Dictionary <string, string> GetBinds(Mod mod)
        {
            try
            {
                if (SH2WorkshopFileHandler.IsModBindable(mod.ModGUID) == false)
                {
                    return(null);
                }
                var settings = SH2WorkshopFileHandler.GetSettings();
                if (string.IsNullOrWhiteSpace(settings.GameFolderLocation))
                {
                    return(null);
                }

                string bindsJson = File.ReadAllText(Path.Combine(settings.GameFolderLocation, SH2WorkshopFileHandler.ModsInstalledFolder, mod.ModGUID, "binds.json"));

                return(JsonConvert.DeserializeObject <Dictionary <string, string> >(bindsJson));
            }
            catch
            {
                return(null);
            }
        }
        public static Shrek2Config GetConfig(Mod mod)
        {
            try
            {
                if (SH2WorkshopFileHandler.IsModConfigable(mod.ModGUID) == false)
                {
                    return(null);
                }
                var settings = SH2WorkshopFileHandler.GetSettings();
                if (string.IsNullOrWhiteSpace(settings.GameFolderLocation))
                {
                    return(null);
                }

                string configJson = File.ReadAllText(Path.Combine(settings.GameFolderLocation, SH2WorkshopFileHandler.ModsInstalledFolder, mod.ModGUID, "config.json"));

                return(JsonConvert.DeserializeObject <Shrek2Config>(configJson));
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
            public static List <VisualMod> ToVisualMods(List <Mod> mods)
            {
                var installedMods = SH2WorkshopFileHandler.GetInstalledModObjects();

                return(mods.Select(p => new VisualMod(p, installedMods.Any(i => i.ModGUID == p.ModGUID), installedMods.Any(i => i.ModGUID == p.ModGUID && i.VersionNumber < p.VersionNumber))).ToList());
            }