/// <summary> /// Verify updater files and start update /// </summary> public void UpdateNow() { try { if (Globals.InstalledToProgramFiles() && !IsAdmin() || !Globals.HasFolderAccess(Globals.AppDataFolder)) { _ = GeneralInvocableFuncs.ShowModal("notice:RestartAsAdmin"); return; } Directory.SetCurrentDirectory(Globals.AppDataFolder); // Download latest hash list var hashFilePath = Path.Join(Globals.UserDataFolder, "hashes.json"); Globals.DownloadFile("https://tcno.co/Projects/AccSwitcher/latest/hashes.json", hashFilePath); // Verify updater files var verifyDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Globals.ReadAllText(hashFilePath)); if (verifyDictionary == null) { _ = GeneralInvocableFuncs.ShowToast("error", Lang["Toast_UpdateVerifyFail"]); return; } var updaterDict = verifyDictionary.Where(pair => pair.Key.StartsWith("updater")).ToDictionary(pair => pair.Key, pair => pair.Value); // Download and replace broken files Globals.RecursiveDelete("newUpdater", false); foreach (var(key, value) in updaterDict) { if (key == null) { continue; } if (File.Exists(key) && value == GeneralFuncs.GetFileMd5(key)) { continue; } Globals.DownloadFile("https://tcno.co/Projects/AccSwitcher/latest/" + key.Replace('\\', '/'), key); } AutoStartUpdaterAsAdmin(); } catch (Exception e) { _ = GeneralInvocableFuncs.ShowToast("error", Lang["Toast_FailedUpdateCheck"]); Globals.WriteToLog("Failed to check for updates:" + e); } Directory.SetCurrentDirectory(Globals.UserDataFolder); }
public void Check(string platform) { Globals.DebugWriteLine($@"[Func:Index.Check] platform={platform}"); switch (platform) { case "BattleNet": if (!GeneralFuncs.CanKillProcess(BattleNetSettings.Processes, BattleNetSettings.ClosingMethod)) { return; } if (Directory.Exists(BattleNetSettings.FolderPath) && File.Exists(BattleNetSettings.Exe())) { AppData.ActiveNavMan.NavigateTo("/BattleNet/"); } else { _ = GeneralInvocableFuncs.ShowModal("find:BattleNet:Battle.net.exe:BattleNetSettings"); } break; case "Steam": if (!GeneralFuncs.CanKillProcess(SteamSettings.Processes, SteamSettings.ClosingMethod)) { return; } if (!Directory.Exists(SteamSettings.FolderPath) || !File.Exists(SteamSettings.Exe())) { _ = GeneralInvocableFuncs.ShowModal("find:Steam:Steam.exe:SteamSettings"); return; } if (SteamSwitcherFuncs.SteamSettingsValid()) { AppData.ActiveNavMan.NavigateTo("/Steam/"); } else { _ = GeneralInvocableFuncs.ShowModal(Lang["Toast_Steam_CantLocateLoginusers"]); } break; default: if (BasicPlatforms.PlatformExistsFromShort(platform)) // Is a basic platform! { BasicPlatforms.SetCurrentPlatformFromShort(platform); if (!GeneralFuncs.CanKillProcess(CurrentPlatform.ExesToEnd, BasicSettings.ClosingMethod)) { return; } if (Directory.Exists(BasicSettings.FolderPath) && File.Exists(BasicSettings.Exe())) { AppData.ActiveNavMan.NavigateTo("/Basic/"); } else { _ = GeneralInvocableFuncs.ShowModal($"find:{CurrentPlatform.SafeName}:{CurrentPlatform.ExeName}:{CurrentPlatform.SafeName}"); } } break; } }
// BUTTON: Pick folder public void PickFolder() { Globals.DebugWriteLine(@"[ButtonClicked:Basic\Settings.razor.cs.PickFolder]"); _ = GeneralInvocableFuncs.ShowModal("find:Basic:BasicGamesLauncher.exe:BasicSettings"); }
// BUTTON: Pick folder public void PickFolder() { Globals.DebugWriteLine(@"[ButtonClicked:Steam\Settings.razor.cs.PickFolder]"); _ = GeneralInvocableFuncs.ShowModal("find:Steam:Steam.exe:SteamSettings"); }
// BUTTON: Pick folder public void PickFolder() { Globals.DebugWriteLine(@"[ButtonClicked:BattleNet\Settings.razor.cs.PickFolder]"); _ = GeneralInvocableFuncs.ShowModal("find:BattleNet:Battle.net.exe:BattleNetSettings"); }