Exemple #1
0
        public bool Install()
        {
            var steam = SteamInstance.Get();
            var dota  = steam.GetGame(AppIDs.DOTA2_ID);

            return(dota.Install(ModContainer));
        }
        public MainWindow()
        {
            Utilities.Utilities.RegisterException();

            _updater = new Updater();
            CheckForUpdates();
            ResizeMode = ResizeMode.NoResize;

            _steam = SteamInstance.Get();
            _steam.IndexAllGames();
            _dota = _steam.GetGame(AppIDs.DOTA2_ID);

            DataContext = this;
            InitializeComponent();

            d2.Title += " V" + _currentVersion;

            BringToFront();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Parser.Default.ParseArguments <Options>(args)
            .WithParsed(option =>
            {
                var updater = new Updater();
                if (updater.CheckForUpdate())
                {
                    Console.WriteLine("Update available!");
                    Console.WriteLine(updater.GetChangeLog());
                }
                var modPack  = Utilities.ReadModConfig(Path.Join(Utilities.AssemblyDirectory(), "config.xml"));
                var modNames = modPack.Mods.Select(mod => mod.DisplayName).Prepend(ALL);
                HashSet <string> selectedMods;
                if (option.All)
                {
                    selectedMods = new HashSet <string>(new[] { ALL });
                }
                else
                {
                    selectedMods = Prompt.MultiSelect("Select mods to install:", modNames).ToHashSet();
                }
                if (selectedMods.Contains(ALL))
                {
                    foreach (var m in modPack.Mods)
                    {
                        m.Selected = true;
                    }
                }
                else
                {
                    foreach (var mod in modPack.Mods.Where(mod => selectedMods.Contains(mod.DisplayName)))
                    {
                        mod.Selected = true;
                    }
                }
                if (option.DotaLocation == null)
                {
                    var steam = SteamInstance.Get();

                    steam.IndexAllGames();
                    var dota = new Dota(steam.LocateGame(AppIDs.DOTA2_ID));
                    if (!dota.Validate())
                    {
                        throw new Exception("Unable to find dota");
                    }
                    if (option.TrySDK)
                    {
                        if (!dota.SDKInstall(modPack, steam))
                        {
                            throw new Exception($"Unable to install mods using source sdk");
                        }
                    }
                    else
                    {
                        if (!dota.Install(modPack))
                        {
                            throw new Exception($"Unable to install mods at \"{steam.LocateGame(AppIDs.DOTA2_ID)}\"");
                        }
                    }
                }
                else
                {
                    if (option.TrySDK)
                    {
                        throw new Exception("Unable to use sdk and custom location at the same time!");
                    }
                    var dota = new Dota(option.DotaLocation);
                    if (!dota.Validate())
                    {
                        throw new Exception($"Unable to find dota at \"{option.DotaLocation}\"");
                    }
                    if (!dota.Install(modPack))
                    {
                        throw new Exception($"Unable to install mods at \"{option.DotaLocation}\"");
                    }
                }
            });
        }