Exemplo n.º 1
0
        public static async Task <bool> InstallValheimPlusUpdateAsync(bool manageClient, string valheimPlusVersion, bool freshInstall)
        {
            var settings = SettingsDAL.GetSettings();

            if (manageClient)
            {
                string zipPath     = @"Data/ValheimPlusGameClient/WindowsClient.zip";
                string extractPath = @"Data/ValheimPlusGameClient/Extracted";

                await Task.Run(() => ZipFile.ExtractToDirectory(zipPath, extractPath, true));

                if (!freshInstall)
                {
                    System.IO.File.Move(String.Format("{0}/BepInEx/config/valheim_plus.cfg", extractPath), String.Format("{0}/BepInEx/config/valheim_plus_latest.cfg", extractPath), true);
                }

                try
                {
                    FileManager.CopyFromTo(settings.ClientPath, settings.ClientInstallationPath);
                    settings.ValheimPlusGameClientVersion = valheimPlusVersion;
                    SettingsDAL.UpdateSettings(settings, true);
                }
                catch (Exception)
                {
                    return(false); // ToDo - handling of errors
                }
            }
            else
            {
                string zipPath     = @"Data/ValheimPlusServerClient/WindowsServer.zip";
                string extractPath = @"Data/ValheimPlusServerClient/Extracted";

                await Task.Run(() => ZipFile.ExtractToDirectory(zipPath, extractPath, true));

                if (!freshInstall)
                {
                    System.IO.File.Move(String.Format("{0}/BepInEx/config/valheim_plus.cfg", extractPath), String.Format("{0}/BepInEx/config/valheim_plus_latest.cfg", extractPath), true);
                }

                try
                {
                    FileManager.CopyFromTo(settings.ServerPath, settings.ServerInstallationPath);
                    settings.ValheimPlusServerClientVersion = valheimPlusVersion;
                    SettingsDAL.UpdateSettings(settings, false);
                }
                catch (Exception)
                {
                    return(false); // ToDo - handling of errors
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public static void CheckCurrentVersion(Settings settings)
        {
            try
            {
                System.Diagnostics.FileVersionInfo serverClientVersion =
                    System.Diagnostics.FileVersionInfo.GetVersionInfo(String.Format("{0}BepInEx/plugins/ValheimPlus.dll", settings.ServerInstallationPath));

                if (serverClientVersion.FileVersion != settings.ValheimPlusServerClientVersion)
                {
                    // This is a special case, since versions before 0.9 reported all clients as 1.0.0.0
                    if (serverClientVersion.FileVersion == "1.0.0.0")
                    {
                        settings.ValheimPlusServerClientVersion = "0.9.0";
                        SettingsDAL.UpdateSettings(settings, false);
                    }
                    else
                    {
                        SettingsDAL.UpdateSettings(settings, false);
                    }
                }
            }
            catch (Exception)
            {
                // ToDo
            }

            try
            {
                System.Diagnostics.FileVersionInfo gameClientVersion =
                    System.Diagnostics.FileVersionInfo.GetVersionInfo(String.Format("{0}BepInEx/plugins/ValheimPlus.dll", settings.ClientInstallationPath));

                if (gameClientVersion.FileVersion != settings.ValheimPlusGameClientVersion)
                {
                    // This is a special case, since versions before 0.9 reported all clients as 1.0.0.0
                    if (gameClientVersion.FileVersion == "1.0.0.0")
                    {
                        settings.ValheimPlusGameClientVersion = "0.9.0";
                        SettingsDAL.UpdateSettings(settings, true);
                    }
                    else
                    {
                        SettingsDAL.UpdateSettings(settings, true);
                    }
                }
            }
            catch (Exception)
            {
                // ToDo
            }
        }
Exemplo n.º 3
0
        private void setServerPathButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new Microsoft.Win32.OpenFileDialog
            {
                Filter = "Executeable|valheim_server.exe"
            };

            if (dialog.ShowDialog() == true)
            {
                var    fullPath      = dialog.FileName;
                string formattedPath = String.Format("{0}\\", System.IO.Path.GetDirectoryName(fullPath));
                string uriPath       = new Uri(formattedPath).AbsolutePath.ToString();
                uriPath = Uri.UnescapeDataString(uriPath);
                Settings.ServerInstallationPath = uriPath;

                SettingsDAL.UpdateSettings(Settings, false);

                FetchSettings();

                statusSnackBar.MessageQueue.Enqueue("Path for server client set");
            }
        }
Exemplo n.º 4
0
        public static bool CheckCurrentVersion(Settings settings)
        {
            try
            {
                System.Diagnostics.FileVersionInfo serverClientVersion =
                    System.Diagnostics.FileVersionInfo.GetVersionInfo(String.Format("{0}BepInEx/plugins/ValheimPlus.dll", settings.ServerInstallationPath));

                if (serverClientVersion.FileVersion != settings.ValheimPlusServerClientVersion)
                {
                    settings.ValheimPlusServerClientVersion = serverClientVersion.FileVersion;
                    bool success = SettingsDAL.UpdateSettings(settings, false);
                }
            }
            catch (Exception)
            {
                //
            }

            try
            {
                System.Diagnostics.FileVersionInfo gameClientVersion =
                    System.Diagnostics.FileVersionInfo.GetVersionInfo(String.Format("{0}BepInEx/plugins/ValheimPlus.dll", settings.ClientInstallationPath));

                if (gameClientVersion.FileVersion != settings.ValheimPlusGameClientVersion)
                {
                    settings.ValheimPlusGameClientVersion = gameClientVersion.FileVersion;
                    bool success = SettingsDAL.UpdateSettings(settings, true);
                }
            }
            catch (Exception)
            {
                //
            }

            return(true);
        }