Ejemplo n.º 1
0
        private void ConfirmButton_Click(object sender, RoutedEventArgs ev)
        {
            ProgressHandler handler = new ProgressHandler();
            Thread          t       = new Thread(delegate()
            {
                HttpWebRequest request   = (HttpWebRequest)WebRequest.Create("http://www.modapi.de/app/archives/" + this.newVersion + ".zip");
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream s            = response.GetResponseStream();
                byte[] buffer       = new byte[4096];
                MemoryStream memory = new MemoryStream();
                int count           = 0;
                long current        = 0;
                float progress      = 0f;
                handler.Task        = "Download";
                while ((count = s.Read(buffer, 0, buffer.Length)) > 0)
                {
                    memory.Write(buffer, 0, count);
                    current         += count;
                    progress         = (float)((((double)current / (double)response.ContentLength)) * 70.0);
                    handler.Progress = progress;
                }

                memory.Position  = 0;
                ZipFile zip      = ZipFile.Read(memory);
                string directory = "./_update";
                int n            = 0;
                handler.Task     = "Extracting";
                foreach (ZipEntry e in zip)
                {
                    try
                    {
                        e.Extract(directory, ExtractExistingFileAction.OverwriteSilently);
                    }
                    catch (Exception ex3)
                    {
                    }
                    n += 1;
                    handler.Progress = 70f + ((float)n / (float)zip.Count) * 30f;
                }

                Process p            = new Process();
                p.StartInfo.FileName = "Updater.exe";
                p.StartInfo.Verb     = "runas";
                p.Start();
                Environment.Exit(0);
            });

            ModAPI.Windows.SubWindows.OperationPending window = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", "Update", handler);
            if (!window.Completed)
            {
                window.ShowSubWindow();
                window.Show();
                Close();
            }
            t.Start();
        }
Ejemplo n.º 2
0
        private void StartGame(object sender, RoutedEventArgs e)
        {
            List <Data.Mod> mods = new List <Data.Mod>();

            foreach (ListViewItem i in Mods.Mods)
            {
                ModViewModel vm = (ModViewModel)i.DataContext;
                if (vm != null && vm.Selected)
                {
                    ModVersionViewModel vm2 = (ModVersionViewModel)vm.SelectedVersion.DataContext;
                    if (vm2 != null)
                    {
                        mods.Add(vm2.mod);
                    }
                }
            }
            ProgressHandler progressHandler = new ProgressHandler();

            progressHandler.OnComplete += (object o, EventArgs ex) => {
                if (Configuration.GetString("UseSteam") == "true" && App.Game.GameConfiguration.SteamAppID != "")
                {
                    Process p = new Process();
                    p.StartInfo.FileName  = Configuration.GetPath("Steam") + System.IO.Path.DirectorySeparatorChar + "Steam.exe";
                    p.StartInfo.Arguments = "-applaunch " + App.Game.GameConfiguration.SteamAppID;
                    p.Start();
                }
                else
                {
                    Process p = new Process();
                    p.StartInfo.FileName = App.Game.GamePath + System.IO.Path.DirectorySeparatorChar + App.Game.GameConfiguration.SelectFile;
                    p.Start();
                }
            };

            Thread thread = new Thread(delegate()
            {
                App.Game.ApplyMods(mods, progressHandler);
            });

            ModAPI.Windows.SubWindows.OperationPending window = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", "ApplyMods", progressHandler, null, true);
            if (!window.Completed)
            {
                window.ShowSubWindow();
                window.Show();
            }
            thread.Start();
        }
Ejemplo n.º 3
0
 private void CreateMod(object sender, RoutedEventArgs e)
 {
     if (CurrentModProjectViewModel != null)
     {
         ProgressHandler progressHandler = new ProgressHandler();
         Thread          thread          = new Thread(delegate() {
             CurrentModProjectViewModel.Project.Create(progressHandler);
         });
         ModAPI.Windows.SubWindows.OperationPending window = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", "CreateMod", progressHandler);
         if (!window.Completed)
         {
             window.ShowSubWindow();
             window.Show();
         }
         thread.Start();
     }
 }
Ejemplo n.º 4
0
        private void Restore_Click(object sender, RoutedEventArgs e)
        {
            ProgressHandler progressHandler = new ProgressHandler();
            progressHandler.OnComplete += (s, ev) => Dispatcher.Invoke((Action) delegate() {
                Task.Complete();
            });
            Thread t = new Thread(delegate() {
                try
                {
                    string steamPath = Configurations.Configuration.GetPath("Steam");
                    Process p = new Process();
                    p.StartInfo.FileName = steamPath + System.IO.Path.DirectorySeparatorChar + "Steam.exe";
                    p.StartInfo.Arguments = "steam://validate/" + App.Game.GameConfiguration.SteamAppID;
                    p.StartInfo.UseShellExecute = false;
                    p.Start();
                    progressHandler.Task = "Restore";
                    progressHandler.Progress = 50f;
                    int state = 0;
                    string lastLine = "";
                    while (true)
                    {
                        Process[] processes = Process.GetProcesses();
                        bool foundSteam = false;
                        foreach (Process pp in processes)
                        {
                            try
                            {
                                if (!pp.HasExited && pp.ProcessName == "Steam")
                                {
                                    foundSteam = true;
                                    break;
                                }
                            }
                            catch (System.Exception ex)
                            {
                            }
                        }

                        string logFile = steamPath + System.IO.Path.DirectorySeparatorChar + "logs" + System.IO.Path.DirectorySeparatorChar + "content_log.txt";
                        System.IO.FileStream s = new System.IO.FileStream(logFile, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
                        System.IO.FileInfo f = new System.IO.FileInfo(logFile);
                        byte[] data = new byte[f.Length];
                        s.Read(data, 0, (int)f.Length);
                        string content = System.Text.Encoding.UTF8.GetString(data);

                        string[] l = content.Split(new string[] { "\r\n" }, System.StringSplitOptions.None);// System.IO.File.ReadAllLines(SteamPath + "\\logs\\content_log.txt");
                        if (lastLine == "")
                            lastLine = l[l.Length - 2];
                        bool check = false;
                        foreach (string n in l)
                        {
                            if (n == lastLine)
                                check = true;
                            if (check)
                            {
                                if (n.EndsWith("AppID " + App.Game.GameConfiguration.SteamAppID + " state changed : Fully Installed,"))
                                    state = 3;
                                else if (n.Contains("AppID " + App.Game.GameConfiguration.SteamAppID) && n.Contains("(Suspended)"))
                                    state = 1;
                                else if (n.Contains("Failed to get list of download sources from any known CS!"))
                                    state = 2;
                            }
                        }

                        if (state == 0 && !foundSteam)
                        {
                            state = 4;
                        }

                        if (state > 0)
                            break;

                        Thread.Sleep(500);

                    }

                    if (state == 3)
                    {
                        progressHandler.Task = "Finish";
                        progressHandler.Progress = 100f;
                    }
                    else
                    {
                        if (state == 1)
                            progressHandler.Task = "Error.Cancelled";
                        else if (state == 2)
                            progressHandler.Task = "Error.NoConnection";
                        else if (state == 4)
                            progressHandler.Task = "Error.SteamClosed";

                        Dispatcher.Invoke((Action)delegate()
                        {
                            Task.Complete();
                        });
                    }

                }
                catch (Exception exx)
                {
                    System.Console.WriteLine(exx.ToString());
                }
            });

            Close();
            ModAPI.Windows.SubWindows.OperationPending win4 = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", "RestoreGameFiles", progressHandler, null, true);
            if (!win4.Completed)
            {
                win4.ShowSubWindow();
            }
            t.Start();
        }
Ejemplo n.º 5
0
        private void Restore_Click(object sender, RoutedEventArgs e)
        {
            ProgressHandler progressHandler = new ProgressHandler();

            progressHandler.OnComplete += (s, ev) => Dispatcher.Invoke((Action) delegate() {
                Task.Complete();
            });
            Thread t = new Thread(delegate() {
                try
                {
                    string steamPath            = Configurations.Configuration.GetPath("Steam");
                    Process p                   = new Process();
                    p.StartInfo.FileName        = steamPath + System.IO.Path.DirectorySeparatorChar + "Steam.exe";
                    p.StartInfo.Arguments       = "steam://validate/" + App.Game.GameConfiguration.SteamAppID;
                    p.StartInfo.UseShellExecute = false;
                    p.Start();
                    progressHandler.Task     = "Restore";
                    progressHandler.Progress = 50f;
                    int state       = 0;
                    string lastLine = "";
                    while (true)
                    {
                        Process[] processes = Process.GetProcesses();
                        bool foundSteam     = false;
                        foreach (Process pp in processes)
                        {
                            try
                            {
                                if (!pp.HasExited && pp.ProcessName == "Steam")
                                {
                                    foundSteam = true;
                                    break;
                                }
                            }
                            catch (System.Exception ex)
                            {
                            }
                        }

                        string logFile         = steamPath + System.IO.Path.DirectorySeparatorChar + "logs" + System.IO.Path.DirectorySeparatorChar + "content_log.txt";
                        System.IO.FileStream s = new System.IO.FileStream(logFile, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
                        System.IO.FileInfo f   = new System.IO.FileInfo(logFile);
                        byte[] data            = new byte[f.Length];
                        s.Read(data, 0, (int)f.Length);
                        string content = System.Text.Encoding.UTF8.GetString(data);

                        string[] l = content.Split(new string[] { "\r\n" }, System.StringSplitOptions.None);// System.IO.File.ReadAllLines(SteamPath + "\\logs\\content_log.txt");
                        if (lastLine == "")
                        {
                            lastLine = l[l.Length - 2];
                        }
                        bool check = false;
                        foreach (string n in l)
                        {
                            if (n == lastLine)
                            {
                                check = true;
                            }
                            if (check)
                            {
                                if (n.EndsWith("AppID " + App.Game.GameConfiguration.SteamAppID + " state changed : Fully Installed,"))
                                {
                                    state = 3;
                                }
                                else if (n.Contains("AppID " + App.Game.GameConfiguration.SteamAppID) && n.Contains("(Suspended)"))
                                {
                                    state = 1;
                                }
                                else if (n.Contains("Failed to get list of download sources from any known CS!"))
                                {
                                    state = 2;
                                }
                            }
                        }

                        if (state == 0 && !foundSteam)
                        {
                            state = 4;
                        }

                        if (state > 0)
                        {
                            break;
                        }

                        Thread.Sleep(500);
                    }

                    if (state == 3)
                    {
                        progressHandler.Task     = "Finish";
                        progressHandler.Progress = 100f;
                    }
                    else
                    {
                        if (state == 1)
                        {
                            progressHandler.Task = "Error.Cancelled";
                        }
                        else if (state == 2)
                        {
                            progressHandler.Task = "Error.NoConnection";
                        }
                        else if (state == 4)
                        {
                            progressHandler.Task = "Error.SteamClosed";
                        }

                        Dispatcher.Invoke((Action) delegate()
                        {
                            Task.Complete();
                        });
                    }
                }
                catch (Exception exx)
                {
                    System.Console.WriteLine(exx.ToString());
                }
            });

            Close();
            ModAPI.Windows.SubWindows.OperationPending win4 = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", "RestoreGameFiles", progressHandler, null, true);
            if (!win4.Completed)
            {
                win4.ShowSubWindow();
            }
            t.Start();
        }
Ejemplo n.º 6
0
        private void StartGame(object sender, RoutedEventArgs e)
        {
            List<Data.Mod> mods = new List<Data.Mod>();
            foreach (ListViewItem i in Mods.Mods)
            {
                ModViewModel vm = (ModViewModel)i.DataContext;
                if (vm != null && vm.Selected)
                {
                    ModVersionViewModel vm2 = (ModVersionViewModel)vm.SelectedVersion.DataContext;
                    if (vm2 != null)
                    {
                        mods.Add(vm2.mod);
                    }
                }
            }
            ProgressHandler progressHandler = new ProgressHandler();
            progressHandler.OnComplete += (object o, EventArgs ex) => {
                if (Configuration.GetString("UseSteam") == "true" && App.Game.GameConfiguration.SteamAppID != "")
                {

                    Process p = new Process();
                    p.StartInfo.FileName = Configuration.GetPath("Steam") + System.IO.Path.DirectorySeparatorChar + "Steam.exe";
                    p.StartInfo.Arguments = "-applaunch "+App.Game.GameConfiguration.SteamAppID;
                    p.Start();
                }
                else
                {
                    Process p = new Process();
                    p.StartInfo.FileName = App.Game.GamePath + System.IO.Path.DirectorySeparatorChar + App.Game.GameConfiguration.SelectFile;
                    p.Start();
                }
            };

            Thread thread = new Thread(delegate()
            {
                App.Game.ApplyMods(mods, progressHandler);

            });
            ModAPI.Windows.SubWindows.OperationPending window = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", "ApplyMods", progressHandler, null, true);
            if (!window.Completed)
            {
                window.ShowSubWindow();
                window.Show();
            }
            thread.Start();
        }
Ejemplo n.º 7
0
        void GUITick(object sender, EventArgs e)
        {
            LoginLoaderRotation.Angle += 5;
            UserAvatarLoaderRotation.Angle += 5;
            if (!FirstSetup)
            {
                List<Utils.Schedule.Task> Tasks = Utils.Schedule.GetTasks("GUI");
                foreach (Utils.Schedule.Task task in Tasks)
                {
                    if (!task.BeingHandled)
                    {
                        switch (task.Name)
                        {
                            case "SpecifyGamePath":
                                ModAPI.Windows.SubWindows.SpecifyGamePath win = new ModAPI.Windows.SubWindows.SpecifyGamePath("Lang.Windows.SpecifyGamePath", task);
                                win.ShowSubWindow();
                                //win.Show();
                                task.BeingHandled = true;
                                break;
                            case "SpecifySteamPath":
                                ModAPI.Windows.SubWindows.SpecifySteamPath win2 = new ModAPI.Windows.SubWindows.SpecifySteamPath("Lang.Windows.SpecifySteamPath", task);
                                win2.ShowSubWindow();
                                //win2.Show();
                                task.BeingHandled = true;
                                break;
                            case "RestoreGameFiles":
                                ModAPI.Windows.SubWindows.RestoreGameFiles win3 = new ModAPI.Windows.SubWindows.RestoreGameFiles("Lang.Windows.RestoreGameFiles", task);
                                win3.ShowSubWindow();
                                //win3.Show();
                                task.BeingHandled = true;
                                break;
                            case "OperationPending":
                                ModAPI.Windows.SubWindows.OperationPending win4 = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", task);
                                if (!win4.Completed)
                                {
                                    win4.ShowSubWindow();
                                  //  win4.Show();
                                }
                                task.BeingHandled = true;
                                break;
                            case "SelectNewestModVersions":
                                if (Mods != null)
                                {
                                    Mods.SelectNewestModVersions = true;
                                    task.BeingHandled = true;
                                }
                                break;
                        }
                    }
                }
            }
            if (BlendIn)
            {
                if (Opacity < 1f)
                {
                    Opacity += GUIDeltaTime * 5f;
                    if (Opacity >= 1f)
                    {
                        Opacity = 1f;
                    }
                }
            }

            if (currentWindow != null)
            {
                if (FadeBackground.Visibility == System.Windows.Visibility.Collapsed)
                    FadeBackground.Visibility = System.Windows.Visibility.Visible;
                if (FadeBackground.Opacity < 0.8f)
                {
                    FadeBackground.Opacity += GUIDeltaTime * 5f;
                    if (FadeBackground.Opacity >= 0.8f)
                    {
                        FadeBackground.Opacity = 0.8f;
                    }
                }
            }
            else
            {
                if (FadeBackground.Opacity > 0f)
                {
                    FadeBackground.Opacity -= GUIDeltaTime * 5f;
                    if (FadeBackground.Opacity <= 0f)
                    {
                        FadeBackground.Opacity = 0f;
                        FadeBackground.Visibility = System.Windows.Visibility.Collapsed;
                    }
                }
            }
        }
Ejemplo n.º 8
0
 private void CreateMod(object sender, RoutedEventArgs e)
 {
     if (CurrentModProjectViewModel != null)
     {
         ProgressHandler progressHandler = new ProgressHandler();
         Thread thread = new Thread(delegate() {
             CurrentModProjectViewModel.Project.Create(progressHandler);
         });
         ModAPI.Windows.SubWindows.OperationPending window = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", "CreateMod", progressHandler);
         if (!window.Completed)
         {
             window.ShowSubWindow();
             window.Show();
         }
         thread.Start();
     }
 }
Ejemplo n.º 9
0
        void GUITick(object sender, EventArgs e)
        {
            LoginLoaderRotation.Angle      += 5;
            UserAvatarLoaderRotation.Angle += 5;
            if (!FirstSetup)
            {
                List <Utils.Schedule.Task> Tasks = Utils.Schedule.GetTasks("GUI");
                foreach (Utils.Schedule.Task task in Tasks)
                {
                    if (!task.BeingHandled)
                    {
                        switch (task.Name)
                        {
                        case "SpecifyGamePath":
                            ModAPI.Windows.SubWindows.SpecifyGamePath win = new ModAPI.Windows.SubWindows.SpecifyGamePath("Lang.Windows.SpecifyGamePath", task);
                            win.ShowSubWindow();
                            //win.Show();
                            task.BeingHandled = true;
                            break;

                        case "SpecifySteamPath":
                            ModAPI.Windows.SubWindows.SpecifySteamPath win2 = new ModAPI.Windows.SubWindows.SpecifySteamPath("Lang.Windows.SpecifySteamPath", task);
                            win2.ShowSubWindow();
                            //win2.Show();
                            task.BeingHandled = true;
                            break;

                        case "RestoreGameFiles":
                            ModAPI.Windows.SubWindows.RestoreGameFiles win3 = new ModAPI.Windows.SubWindows.RestoreGameFiles("Lang.Windows.RestoreGameFiles", task);
                            win3.ShowSubWindow();
                            //win3.Show();
                            task.BeingHandled = true;
                            break;

                        case "OperationPending":
                            ModAPI.Windows.SubWindows.OperationPending win4 = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", task);
                            if (!win4.Completed)
                            {
                                win4.ShowSubWindow();
                                //  win4.Show();
                            }
                            task.BeingHandled = true;
                            break;

                        case "SelectNewestModVersions":
                            if (Mods != null)
                            {
                                Mods.SelectNewestModVersions = true;
                                task.BeingHandled            = true;
                            }
                            break;
                        }
                    }
                }
            }
            if (BlendIn)
            {
                if (Opacity < 1f)
                {
                    Opacity += GUIDeltaTime * 5f;
                    if (Opacity >= 1f)
                    {
                        Opacity = 1f;
                    }
                }
            }

            if (currentWindow != null)
            {
                if (FadeBackground.Visibility == System.Windows.Visibility.Collapsed)
                {
                    FadeBackground.Visibility = System.Windows.Visibility.Visible;
                }
                if (FadeBackground.Opacity < 0.8f)
                {
                    FadeBackground.Opacity += GUIDeltaTime * 5f;
                    if (FadeBackground.Opacity >= 0.8f)
                    {
                        FadeBackground.Opacity = 0.8f;
                    }
                }
            }
            else
            {
                if (FadeBackground.Opacity > 0f)
                {
                    FadeBackground.Opacity -= GUIDeltaTime * 5f;
                    if (FadeBackground.Opacity <= 0f)
                    {
                        FadeBackground.Opacity    = 0f;
                        FadeBackground.Visibility = System.Windows.Visibility.Collapsed;
                    }
                }
            }
        }