Exemplo n.º 1
0
        public static void GiUpdatePath(string file, string path)
        {
            Globals.DebugWriteLine($@"[JSInvoke:General\GeneralInvocableFuncs.GiUpdatePath] file={file}, path={path}");
            var settingsFile = file;

            if (BasicPlatforms.PlatformExists(file))
            {
                settingsFile = CurrentPlatform.SettingsFile;
            }

            var settings = GeneralFuncs.LoadSettings(settingsFile);

            settings["FolderPath"] = path;
            GeneralFuncs.SaveSettings(settingsFile, settings);
            path = Path.GetDirectoryName(path); // Remove .exe
            switch (file)
            {
            case "BattleNetSettings":
                BattleNetSettings.FolderPath = path;
                break;

            case "BasicSettings":
                BasicSettings.FolderPath = path;
                break;

            case "SteamSettings":
                SteamSettings.FolderPath = path;
                break;
            }
        }
Exemplo n.º 2
0
 public static string GiCurrentBasicPlatform(string platform)
 {
     if (platform == "Basic")
     {
         return(CurrentPlatform.FullName);
     }
     return(BasicPlatforms.PlatformExists(platform)
         ? BasicPlatforms.PlatformFullName(platform)
         : platform);
 }
Exemplo n.º 3
0
 public static string GiCurrentBasicPlatformExe(string platform)
 {
     // EXE name from current platform by name:
     if (platform == "Basic")
     {
         return(CurrentPlatform.ExeName);
     }
     return(BasicPlatforms.PlatformExists(platform)
         ? BasicPlatforms.GetExeNameFromPlatform(platform)
         : platform);
 }
Exemplo n.º 4
0
        public static void GiCreatePlatformShortcut(string platform)
        {
            Globals.DebugWriteLine(@$ "[Func:Pages\General\GeneralInvocableFuncs.GiCreatePlatformShortcut] platform={platform}");
            var platId = platform.ToLowerInvariant();

            platform = BasicPlatforms.PlatformFullName(platform); // If it's a basic platform

            var s = new Shortcut();

            _ = s.Shortcut_Platform(Shortcut.Desktop, platform, platId);
            s.ToggleShortcut(true);
        }
Exemplo n.º 5
0
        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;
            }
        }
Exemplo n.º 6
0
        public static async Task <string> GiExportAccountList(string platform)
        {
            Globals.DebugWriteLine(@$ "[Func:Pages\General\GeneralInvocableFuncs.GiExportAccountList] platform={platform}");
            platform = BasicPlatforms.PlatformFullName(platform);
            if (!Directory.Exists(Path.Join("LoginCache", platform)))
            {
                _ = ShowToast("error", Lang["Toast_AddAccountsFirst"], Lang["Toast_AddAccountsFirstTitle"], "toastarea");
                return("");
            }

            var s = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator; // Different regions use different separators in csv files.

            List <string> allAccountsTable = new();

            if (platform == "Steam")
            {
                // Add headings and separator for programs like Excel
                allAccountsTable.Add("SEP=,");
                allAccountsTable.Add("Account name:,Community name:,SteamID:,VAC status:,Last login:,Saved profile image:");

                var userAccounts   = SteamSwitcherFuncs.GetSteamUsers(SteamSettings.LoginUsersVdf());
                var vacStatusList  = new List <SteamSwitcherFuncs.VacStatus>();
                var loadedVacCache = SteamSwitcherFuncs.LoadVacInfo(ref vacStatusList);

                foreach (var ua in userAccounts)
                {
                    var vacInfo = "";
                    // Get VAC/Limited info
                    if (loadedVacCache)
                    {
                        foreach (var vsi in vacStatusList.Where(vsi => vsi.SteamId == ua.SteamId))
                        {
                            if (vsi.Vac && vsi.Ltd)
                            {
                                vacInfo += "VAC + Limited";
                            }
                            else
                            {
                                vacInfo += (vsi.Vac ? "VAC" : "") + (vsi.Ltd ? "Limited" : "");
                            }
                            break;
                        }
                    }
                    else
                    {
                        vacInfo += "N/A";
                    }

                    var imagePath = Path.GetFullPath($"{SteamSettings.SteamImagePath + ua.SteamId}.jpg");
                    allAccountsTable.Add(ua.AccName + s +
                                         ua.Name + s +
                                         ua.SteamId + s +
                                         vacInfo + s +
                                         SteamSwitcherFuncs.UnixTimeStampToDateTime(ua.LastLogin) + s +
                                         (File.Exists(imagePath) ? imagePath : "Missing from disk"));
                }
            }
            else if (platform == "BattleNet")
            {
                // Add headings and separator for programs like Excel
                allAccountsTable.Add("SEP=,");
                allAccountsTable.Add("Email:,BattleTag:,Overwatch Support SR:,Overwatch DPS SR:,Overwatch Tank SR:,Saved profile image:");

                await BattleNetSwitcherFuncs.LoadProfiles();

                foreach (var ba in BattleNetSettings.Accounts)
                {
                    var imagePath = Path.GetFullPath($"wwwroot\\img\\profiles\\battlenet\\{ba.Email}.png");
                    allAccountsTable.Add(ba.Email + s +
                                         ba.BTag + s +
                                         (ba.OwSupportSr != 0 ? ba.OwSupportSr : "") + s +
                                         (ba.OwDpsSr != 0 ? ba.OwDpsSr : "") + s +
                                         (ba.OwTankSr != 0 ? ba.OwTankSr : "") + s +
                                         (File.Exists(imagePath) ? imagePath : "Missing from disk"));
                }
            }
            else
            {
                // Platform does not have specific details other than usernames saved.
                allAccountsTable.Add("Account name:");
                foreach (var accDirectory in Directory.GetDirectories(Path.Join("LoginCache", platform)))
                {
                    allAccountsTable.Add(Path.GetFileName(accDirectory));
                }
            }

            var outputFolder = Path.Join("wwwroot", "Exported");

            _ = Directory.CreateDirectory(outputFolder);

            var outputFile = Path.Join(outputFolder, platform + ".csv");
            await File.WriteAllLinesAsync(outputFile, allAccountsTable).ConfigureAwait(false);

            return(Path.Join("Exported", platform + ".csv"));
        }