Пример #1
0
        private void Steam_ModDownloaded(object sender, string folder)
        {
            if (folder == null)
            {
                U3WorkshopModInstallationFinished?.Invoke(this, new U3WorkshopModInstalledEventArgs(currentID, "", false, QueueEmpty));
            }
            else
            {
                U3WorkshopMod_Managed mod = new U3WorkshopMod_Managed(new DirectoryInfo(folder));
                try
                {
                    DirectoryInfo destination = null;
                    switch (mod.Type)
                    {
                    case U3WorkshopModType.Map:
                        destination = new DirectoryInfo(MapFolder.FullName + "\\" + mod.ID);
                        break;

                    case U3WorkshopModType.Content:
                        destination = new DirectoryInfo(ContentFolder.FullName + "\\" + mod.ID);
                        break;

                    default:
                        U3WorkshopModInstallationFinished?.Invoke(this, new U3WorkshopModInstalledEventArgs(mod.ID, mod.Name, false, QueueEmpty));
                        return;
                    }


                    if (destination.Exists)
                    {
                        U3WorkshopModInstallStateChanged?.Invoke(this, new U3WorkshopModInstallStateChangedEventArgs(U3WorkshopModInstallState.RemoveOld, mod.ID, mod.Name));
                        mod.Delete();
                    }

                    U3WorkshopModInstallStateChanged?.Invoke(this, new U3WorkshopModInstallStateChangedEventArgs(U3WorkshopModInstallState.Installing, mod.ID, mod.Name));
                    UniversalOrganiserControls.UtilsGeneral.DirectoryCopy(folder, destination.FullName, true);

                    U3WorkshopModInstallationFinished?.Invoke(this, new U3WorkshopModInstalledEventArgs(mod.ID, mod.Name, true, QueueEmpty));
                }
                catch (Exception)
                {
                    U3WorkshopModInstallationFinished?.Invoke(this, new U3WorkshopModInstalledEventArgs(mod.ID, mod.Name, false, QueueEmpty));
                }
                currentID = null;
            }
        }
Пример #2
0
        private Task InstallationProcess()
        {
            return(Task.Run(async() =>
            {
                while (Active)
                {
                    if (!QueueEmpty & currentID != null)
                    {
                        currentID = InstallationQueue.Dequeue();
                        if (currentID == "-1")
                        {
                            Exit();
                        }

                        U3WorkshopModInstallStateChangedEventArgs args = new U3WorkshopModInstallStateChangedEventArgs(U3WorkshopModInstallState.Preparing, currentID);
                        U3WorkshopModInstallStateChanged?.Invoke(this, args);

                        string modTitle = U3WorkshopMod.getModTitle(currentID);

                        foreach (U3WorkshopMod_Managed Mod in server.GetWorkshopContentMods().Where((m) => { return m.ID == currentID; }))
                        {
                            args = new U3WorkshopModInstallStateChangedEventArgs(U3WorkshopModInstallState.RemoveOld, Mod.ID, Mod.Name);
                            U3WorkshopModInstallStateChanged?.Invoke(this, args);
                            Mod.Delete();
                        }


                        args = new U3WorkshopModInstallStateChangedEventArgs(U3WorkshopModInstallState.Installing, currentID, modTitle);
                        U3WorkshopModInstallStateChanged?.Invoke(this, args);


                        steam.getWorkshopMod("304930", currentID);
                        steam.sendCommand("help");
                    }
                    else
                    {
                        await Task.Delay(500);
                    }
                }
            }));
        }