Skip to content

Commit

Permalink
🐛 fix #3519 #3530
Browse files Browse the repository at this point in the history
增加战网账号切换支持国服国际服切换(建议重新保存一次账号)
修复国服国际服战网邮箱相同时无法同时保存账号问题
修复了一个账号切换的炸弹,可能会让GOG切换变好(未测试)
  • Loading branch information
rmbadmin committed Nov 21, 2024
1 parent 9843c01 commit e505e91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,10 @@ async ValueTask<bool> BasicCopyInAccount(string accId, PlatformAccount platform)

var regValue = regJson[accFile] ?? "";

if (DesktopBridge.IsRunningAsUwp)
if (!Registry2.SetRegistryKey(accFile[4..], regValue)) // Remove "REG:" and read data
{
await SetEpicCurrentUserAsync(regValue);
}
else
{
if (!Registry2.SetRegistryKey(accFile[4..], regValue)) // Remove "REG:" and read data
{
Toast.Show(ToastIcon.Error, AppResources.Error_WriteRegistryFailed);
return false;
}
Toast.Show(ToastIcon.Error, AppResources.Error_WriteRegistryFailed);
return false;
}
continue;
}
Expand All @@ -90,7 +83,7 @@ async ValueTask<bool> BasicCopyInAccount(string accId, PlatformAccount platform)
if (!JTokenHelper.ReplaceVarInJsonFile(path, selector, jToken))
{
Toast.Show(ToastIcon.Error, AppResources.Error_ModifyJsonFileFailed);
return false;
//return false;
}
continue;
}
Expand Down Expand Up @@ -143,7 +136,7 @@ public async ValueTask<bool> SwapToAccount(IAccount? account, PlatformAccount pl
}

//if (BasicSettings.AutoStart)
RunPlatformProcess(platform, true);
RunPlatformProcess(platform, false);

//if (accName != "" && BasicSettings.AutoStart && AppSettings.MinimizeOnSwitch) _ = AppData.InvokeVoidAsync("hideWindow");

Expand Down Expand Up @@ -197,21 +190,6 @@ async ValueTask<bool> ClearCurrentLoginUserCore(PlatformAccount platform)
return true;
}

async ValueTask SetEpicCurrentUserAsync(string userName)
{
#if WINDOWS
string contents =
$"""
Windows Registry Editor Version 5.00
; {AssemblyInfo.Trademark} BD.WTTS.Services.Implementation.BasicPlatformSwitcher.SetEpicCurrentUserAsync
[HKEY_CURRENT_USER\Software\Epic Games\Unreal Engine\Identifiers]
"AccountId"="{userName}"
""";
var regpath = IOPath.GetCacheFilePath(WindowsPlatformServiceImpl.CacheTempDirName, "SwitchEpicUser", FileEx.Reg);
await WindowsPlatformServiceImpl.StartProcessRegeditAsync(regpath, contents);
#endif
}

async ValueTask<bool> DeleteFileOrFolder(string accFile, PlatformAccount platform)
{
// The "file" is a registry key
Expand All @@ -225,14 +203,7 @@ async ValueTask<bool> DeleteFileOrFolder(string accFile, PlatformAccount platfor
}
else
{
if (DesktopBridge.IsRunningAsUwp)
{
await SetEpicCurrentUserAsync(string.Empty);
return true;
}
else
if (Registry2.SetRegistryKey(accFile[4..])) return true;

if (Registry2.SetRegistryKey(accFile[4..])) return true;
}
Toast.Show(ToastIcon.Error, AppResources.Error_WriteRegistryFailed);
return false;
Expand Down
10 changes: 7 additions & 3 deletions src/BD.WTTS.Client.Plugins.GameAccount/UI/Assets/Platforms.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,15 @@
"ExesToEnd": [ "Battle.net" ],
"ClearPaths": [ "SAME_AS_LOGIN_FILES" ],
"LoginFiles": {
"JSON_SELECT_FIRST,::%AppData%\\Battle.net\\Battle.net.config::$.Client.SavedAccountNames": "email.json"
"JSON_SELECT_FIRST,::%AppData%\\Battle.net\\Battle.net.config::$.Client.SavedAccountNames": "email.json",
"JSON_SELECT_FIRST,::%AppData%\\Battle.net\\Battle.net.config::$..Services.LastLoginRegion": "LastLoginRegion",
"JSON_SELECT_FIRST,::%AppData%\\Battle.net\\Battle.net.config::$..Services.LastLoginAddress": "LastLoginAddress",
"JSON_SELECT_FIRST,::%AppData%\\Battle.net\\Battle.net.config::$..Services.LastLoginTassadar": "LastLoginTassadar",
"%AppData%\\Battle.net\\WattToolkit.id": "WattToolkit.id"
},
"IsExitBeforeInteract": true,
"UniqueIdPath": "%AppData%\\Battle.net\\Battle.net.config::$.Client.SavedAccountNames",
"UniqueIdType": 5,
"UniqueIdPath": "%AppData%\\Battle.net\\WattToolkit.id",
"UniqueIdType": 1,
"AllFilesRequired": true
},
{
Expand Down

0 comments on commit e505e91

Please sign in to comment.