Esempio n. 1
0
        private static SteamModCollection GetSteamMods()
        {
            SteamModCollection currentMods = new SteamModCollection();

            if (Properties.Settings.Default.steamMods != null)
            {
                currentMods = Properties.Settings.Default.steamMods;
            }

            return(currentMods);
        }
        private static void AddMod(bool multiple, int modId)
        {
            var duplicate   = false;
            var currentMods = GetSteamMods();

            if (currentMods.Count > 0)
            {
                foreach (var steamMod in currentMods.Where(steamMod => steamMod.WorkshopId == modId))
                {
                    duplicate = true;
                }
            }

            if (!duplicate)
            {
                try
                {
                    var modInfo = GetModInfo(modId);

                    if (modInfo != null)
                    {
                        var modName         = modInfo.Item1;
                        var steamUpdateTime = modInfo.Item3;
                        var author          = modInfo.Item2;

                        currentMods.Add(new SteamMod(modId, modName, author, steamUpdateTime));

                        var modCollection = new SteamModCollection {
                            CollectionName = "Steam", SteamMods = currentMods
                        };

                        Properties.Settings.Default.steamMods = modCollection;
                        Properties.Settings.Default.Save();
                    }
                    else
                    {
                        MainWindow.Instance.IMessageDialog.IsOpen   = true;
                        MainWindow.Instance.IMessageDialogText.Text = "This is a workshop Item for a different game.";
                    }
                }
                catch (Exception e) { Crashes.TrackError(e, new Dictionary <string, string> {
                        { "Name", Properties.Settings.Default.steamUserName }
                    }); }
            }
            else if (!multiple)
            {
                MainWindow.Instance.IMessageDialog.IsOpen   = true;
                MainWindow.Instance.IMessageDialogText.Text = "Mod already imported.";
            }
        }
Esempio n. 3
0
        public static void AddSteamMod(string modUrl, bool multiple = false)
        {
            int modId   = 0;
            var invalid = false;

            if (int.TryParse(modUrl, out _))
            {
                modId = int.Parse(modUrl);
            }
            else if (modUrl.Contains("://steamcommunity.com/") && modUrl.Contains("/filedetails/?id="))
            {
                modId = SteamIdFromUrl(modUrl);
            }
            else
            {
                invalid = true;
            }

            if (!invalid)
            {
                var duplicate   = false;
                var currentMods = GetSteamMods();

                if (currentMods.Count > 0)
                {
                    foreach (var steamMod in currentMods)
                    {
                        if (steamMod.WorkshopId == modId)
                        {
                            duplicate = true;
                        }
                    }
                }

                if (!duplicate)
                {
                    try
                    {
                        var modInfo = GetModInfo(modId);

                        if (modInfo != null)
                        {
                            var modName         = modInfo.Item1;
                            var steamUpdateTime = modInfo.Item3;
                            var author          = modInfo.Item2;

                            currentMods.Add(new SteamMod(modId, modName, author, steamUpdateTime));

                            var modCollection = new SteamModCollection
                            {
                                CollectionName = "Steam",
                                SteamMods      = currentMods
                            };

                            Properties.Options.Default.steamMods = modCollection;
                            Properties.Options.Default.Save();
                        }
                        else
                        {
                            MainWindow.Instance.IMessageDialog.IsOpen   = true;
                            MainWindow.Instance.IMessageDialogText.Text = "This is a workshop Item for a different game.";
                        }
                    }
                    catch (Exception)
                    { /*ignored*/ }
                }
                else if (!multiple)
                {
                    MainWindow.Instance.IMessageDialog.IsOpen   = true;
                    MainWindow.Instance.IMessageDialogText.Text = "Mod already imported.";
                }
            }
            else
            {
                MainWindow.Instance.IMessageDialog.IsOpen   = true;
                MainWindow.Instance.IMessageDialogText.Text = "Please use format: https://steamcommunity.com/sharedfiles/filedetails/?id=*********";
            }
        }