コード例 #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;
            }
        }
コード例 #2
0
        public static Task <string> GiConfirmAction(string action, bool value)
        {
            Globals.DebugWriteLine($@"[JSInvoke:General\GeneralInvocableFuncs.GiConfirmAction] action={action.Split(":")[0]}, value={value}");
            if (!value)
            {
                return(Task.FromResult(""));
            }

            var split = action.Split(":");

            if (split.Length > 1)
            {
                var accName = split[1];

                if (action.StartsWith("AcceptForgetBasicAcc:"))
                {
                    BasicSettings.SetForgetAcc(true);
                    _ = GeneralFuncs.ForgetAccount_Generic(accName, CurrentPlatform.SafeName, true);
                    return(Task.FromResult("refresh"));
                }

                if (action.StartsWith("AcceptForgetSteamAcc:"))
                {
                    SteamSettings.SetForgetAcc(true);
                    _ = SteamSwitcherFuncs.ForgetAccount(accName);
                    return(Task.FromResult("refresh"));
                }

                if (action.StartsWith("AcceptForgetBattleNetAcc:"))
                {
                    BattleNetSettings.SetForgetAcc(true);
                    BattleNetSwitcherFuncs.ForgetAccount(accName);
                    return(Task.FromResult("refresh"));
                }
            }
            switch (action)
            {
            case "ClearBattleNetIgnored":
                BattleNetSwitcherFuncs.ClearIgnored_Confirmed();
                break;

            case "RestartAsAdmin":
                break;
            }

            return(Task.FromResult(""));
        }
コード例 #3
0
 public static Task GiLoadSettings(string file)
 {
     Globals.DebugWriteLine($@"[JSInvoke:General\GeneralInvocableFuncs.GiLoadSettings] file={file}");
     return(Task.FromResult(GeneralFuncs.LoadSettings(file).ToString()));
 }
コード例 #4
0
 public static void GiSaveOrder(string file, string jsonString)
 {
     Globals.DebugWriteLine($@"[JSInvoke:General\GeneralInvocableFuncs.GiSaveOrder] file={file}, jsonString.length={jsonString.Length}");
     GeneralFuncs.SaveOrder(file, JArray.Parse(jsonString));
 }
コード例 #5
0
 public static void GiSaveSettings(string file, string jsonString)
 {
     Globals.DebugWriteLine($@"[JSInvoke:General\GeneralInvocableFuncs.GiSaveSettings] file={file}, jsonString.length={jsonString.Length}");
     GeneralFuncs.SaveSettings(file, JObject.Parse(jsonString));
 }
コード例 #6
0
        public static void CreateShortcut(string page, string accId, string accName, string args = "")
        {
            Globals.DebugWriteLine(@"[JSInvoke:General\GeneralInvocableFuncs.CreateShortcut]");
            var platform = page;

            page = page.ToLowerInvariant();
            if (args.Length > 0 && args[0] != ':')
            {
                args = $" {args}";                                    // Add a space before arguments if doesn't start with ':'
            }
            var platformName      = $"Switch to {accName} [{platform}]";
            var originalAccId     = accId;
            var primaryPlatformId = "" + page[0];
            var bgImg             = Path.Join(GeneralFuncs.WwwRoot(), $"\\img\\platform\\{page}.png");

            switch (page)
            {
            case "steam":
            {
                var ePersonaState = -1;
                if (args.Length == 2)
                {
                    _ = int.TryParse(args[1].ToString(), out ePersonaState);
                }
                platformName = $"Switch to {accName} {(args.Length > 0 ? $"({SteamSwitcherFuncs.PersonaStateToString(ePersonaState)})" : "")} [{platform}]";
                break;
            }

            case "basic":
                page = CurrentPlatform.SafeName;
                primaryPlatformId = CurrentPlatform.PrimaryId;
                platform          = CurrentPlatform.FullName;
                platformName      = $"Switch to {accName} [{platform}]";

                var platformImgPath        = "\\img\\platform\\" + CurrentPlatform.SafeName + ".png";
                var currentPlatformImgPath = Path.Join(GeneralFuncs.WwwRoot(), platformImgPath);
                bgImg = File.Exists(currentPlatformImgPath)
                        ? Path.Join(currentPlatformImgPath)
                        : Path.Join(GeneralFuncs.WwwRoot(), "\\img\\BasicDefault.png");
                break;
            }

            var fgImg = Path.Join(GeneralFuncs.WwwRoot(), $"\\img\\profiles\\{page}\\{accId}.jpg");

            if (!File.Exists(fgImg))
            {
                fgImg = Path.Join(GeneralFuncs.WwwRoot(), $"\\img\\profiles\\{page}\\{accId}.png");
            }
            if (!File.Exists(fgImg))
            {
                _ = ShowToast("error", Lang["Toast_CantFindImage"], Lang["Toast_CantCreateShortcut"], "toastarea");
                return;
            }

            var s = new Shortcut();

            _ = s.Shortcut_Platform(
                Shortcut.Desktop,
                platformName,
                $"+{primaryPlatformId}:{originalAccId}{args}",
                $"Switch to {accName} [{platform}] in TcNo Account Switcher",
                true);
            s.CreateCombinedIcon(bgImg, fgImg, $"{accId}.ico");
            s.TryWrite();

            _ = AppSettings.StreamerModeTriggered
                ? ShowToast("success", Lang["Toast_ShortcutCreated"], Lang["Success"], "toastarea")
                : ShowToast("success", Lang["ForName", new { name = accName }], Lang["Toast_ShortcutCreated"], "toastarea");
        }