Skip to content

Commit 46560f7

Browse files
committed
Add CN & Bilibili regions
1 parent 982f5b2 commit 46560f7

File tree

11 files changed

+254
-28
lines changed

11 files changed

+254
-28
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
namespace Hi3Helper.Plugin.DNA.Management.Api;
6+
7+
public class DNAApiResponseDetails
8+
{
9+
public List<string> BaseUrls { get; init; } = null!;
10+
11+
public string BaseUrl {
12+
get
13+
{
14+
int index = (int)Math.Floor((DateTime.Now.Day - 1) / 8.0);
15+
if (index >= BaseUrls.Count) return BaseUrls.First();
16+
17+
return BaseUrls[index];
18+
}
19+
}
20+
21+
public string Region { get; init; } = null!;
22+
public string RegionLong { get; init; } = null!;
23+
public string Tag { get; init; } = null!;
24+
}

Hi3Helper.Plugin.DNA/Management/Api/DNAGlobalLauncherApiMedia.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace Hi3Helper.Plugin.DNA.Management.Api;
1515

1616
[GeneratedComClass]
17-
internal partial class DNAGlobalLauncherApiMedia(string apiResponseBaseUrl, string logoUrl, string backgroundUrl) : LauncherApiMediaBase
17+
internal partial class DNAGlobalLauncherApiMedia(DNAApiResponseDetails apiResponseDetails, string logoUrl, string backgroundUrl) : LauncherApiMediaBase
1818
{
1919
[field: AllowNull, MaybeNull]
2020
protected override HttpClient ApiResponseHttpClient
@@ -30,7 +30,7 @@ protected HttpClient ApiDownloadHttpClient
3030
set;
3131
}
3232

33-
protected override string ApiResponseBaseUrl { get; } = apiResponseBaseUrl;
33+
protected override string ApiResponseBaseUrl { get; } = apiResponseDetails.BaseUrl;
3434

3535
protected string LogoUrl { get; } = logoUrl;
3636
protected string BackgroundUrl { get; } = backgroundUrl;

Hi3Helper.Plugin.DNA/Management/Api/DNAGlobalLauncherApiNews.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
namespace Hi3Helper.Plugin.DNA.Management.Api;
2424

2525
[GeneratedComClass]
26-
internal partial class DNAGlobalLauncherApiNews(string apiResponseBaseUrl) : LauncherApiNewsBase
26+
internal partial class DNAGlobalLauncherApiNews(DNAApiResponseDetails apiResponseDetails, string? forceLang = null) : LauncherApiNewsBase
2727
{
2828
[field: AllowNull, MaybeNull]
2929
protected override HttpClient ApiResponseHttpClient
@@ -39,34 +39,35 @@ protected HttpClient ApiDownloadHttpClient
3939
set;
4040
}
4141

42-
protected override string ApiResponseBaseUrl { get; } = apiResponseBaseUrl;
42+
protected override string ApiResponseBaseUrl { get; } = apiResponseDetails.BaseUrl;
43+
protected DNAApiResponseDetails ApiResponseDetails { get; } = apiResponseDetails;
4344

4445
private DNAApiResponseNotices? NoticesApiResponse { get; set; }
4546

4647
private DNAApiResponseCarousel? CarouselApiResponse { get; set; }
4748

4849
private DNAApiResponseSocials? SocialApiResponse { get; set; }
4950

50-
private string LangCode => DNAUtility.GetApiLangFromLauncherLocale();
51+
private string LangCode => forceLang ?? DNAUtility.GetApiLangFromLauncherLocale();
5152

5253
protected override async Task<int> InitAsync(CancellationToken token)
5354
{
5455
using HttpResponseMessage notices = await ApiResponseHttpClient
55-
.GetAsync(ApiResponseBaseUrl + "/OperationLauncherNotice/OperationLauncherNoticeProductionGlobalonline.json", HttpCompletionOption.ResponseHeadersRead, token);
56+
.GetAsync($"{ApiResponseBaseUrl}/OperationLauncherNotice/OperationLauncherNoticeProduction{ApiResponseDetails.RegionLong}online.json", HttpCompletionOption.ResponseHeadersRead, token);
5657
notices.EnsureSuccessStatusCode();
5758

5859
string noticesJsonResponse = await notices.Content.ReadAsStringAsync(token);
5960
NoticesApiResponse = JsonSerializer.Deserialize(noticesJsonResponse, DNAApiResponseContext.Default.DNAApiResponseNotices);
6061

6162
using HttpResponseMessage carousel = await ApiResponseHttpClient
62-
.GetAsync(ApiResponseBaseUrl + "/OperationLauncherHeadImage/OperationLauncherHeadImageProductionGlobalonline.json", HttpCompletionOption.ResponseHeadersRead, token);
63+
.GetAsync($"{ApiResponseBaseUrl}/OperationLauncherHeadImage/OperationLauncherHeadImageProduction{ApiResponseDetails.RegionLong}online.json", HttpCompletionOption.ResponseHeadersRead, token);
6364
carousel.EnsureSuccessStatusCode();
6465

6566
string carouselJsonResponse = await carousel.Content.ReadAsStringAsync(token);
6667
CarouselApiResponse = JsonSerializer.Deserialize(carouselJsonResponse, DNAApiResponseContext.Default.DNAApiResponseCarousel);
6768

6869
using HttpResponseMessage socials = await ApiResponseHttpClient
69-
.GetAsync(ApiResponseBaseUrl + "/OperationLauncherSocialMedia/OperationLauncherSocialMediaProductionGlobalonline.json", HttpCompletionOption.ResponseHeadersRead, token);
70+
.GetAsync($"{ApiResponseBaseUrl}/OperationLauncherSocialMedia/OperationLauncherSocialMediaProduction{ApiResponseDetails.RegionLong}online.json", HttpCompletionOption.ResponseHeadersRead, token);
7071
socials.EnsureSuccessStatusCode();
7172

7273
string socialsJsonResponse = await socials.Content.ReadAsStringAsync(token);

Hi3Helper.Plugin.DNA/Management/DNAGameInstaller.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
namespace Hi3Helper.Plugin.DNA.Management;
1717

1818
[GeneratedComClass]
19-
internal partial class DNAGameInstaller(IGameManager? gameManager, string apiResponseBaseUrl, string apiResponseTag) : GameInstallerBase(gameManager)
19+
internal partial class DNAGameInstaller(IGameManager? gameManager, DNAApiResponseDetails apiResponseDetails) : GameInstallerBase(gameManager)
2020
{
2121
private HttpClient _downloadHttpClient = DNAUtility.CreateApiHttpClient();
2222
private DNAGameManager? _gameManager = gameManager as DNAGameManager;
2323

24-
private string? _baseVersionUrl = $"{apiResponseBaseUrl}/Packages/Global/WindowsNoEditor/{apiResponseTag}/";
24+
private string? _baseVersionUrl = $"{apiResponseDetails.BaseUrl}/Packages/{apiResponseDetails.Region}/WindowsNoEditor/{apiResponseDetails.Tag}/";
2525
private const string _baseVersion = "BaseVersion.json";
2626

2727
private string? _gamePath = null;

Hi3Helper.Plugin.DNA/Management/DNAGameManager.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ internal partial class DNAGameManager : GameManagerBase
2929
{
3030
internal DNAGameManager(
3131
string gameExecutableNameByPreset,
32-
string apiResponseBaseUrl,
33-
string apiResponseTag,
32+
DNAApiResponseDetails details,
3433
DNAPresetConfig preset)
3534
{
3635
CurrentGameExecutableByPreset = gameExecutableNameByPreset;
37-
ApiResponseBaseUrl = apiResponseBaseUrl;
38-
ApiResponseTag = apiResponseTag;
36+
ApiResponseBaseUrl = details.BaseUrl;
37+
ApiResponseDetails = details;
3938
Preset = preset;
4039
}
4140

@@ -54,7 +53,7 @@ protected HttpClient ApiDownloadHttpClient
5453
}
5554

5655
protected override string ApiResponseBaseUrl { get; }
57-
protected string ApiResponseTag { get; }
56+
protected DNAApiResponseDetails ApiResponseDetails { get; }
5857

5958
private string CurrentGameExecutableByPreset { get; }
6059

@@ -117,7 +116,7 @@ internal async Task<int> InitAsyncInner(bool forceInit = false, CancellationToke
117116
if (!forceInit && IsInitialized)
118117
return 0;
119118

120-
var apiUrl = ApiResponseBaseUrl + $"/Packages/Global/WindowsNoEditor/{ApiResponseTag}/BaseVersion.json";
119+
var apiUrl = $"{ApiResponseDetails.BaseUrl}/Packages/{ApiResponseDetails.Region}/WindowsNoEditor/{ApiResponseDetails.Tag}/BaseVersion.json";
121120

122121
using HttpResponseMessage versionResponse =
123122
await ApiResponseHttpClient.GetAsync(apiUrl, HttpCompletionOption.ResponseHeadersRead, token);
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using Hi3Helper.Plugin.Core.Management;
2+
using Hi3Helper.Plugin.DNA.Management.Api;
3+
using Hi3Helper.Plugin.DNA.Utility;
4+
using System.Diagnostics.CodeAnalysis;
5+
using System.Net.Security;
6+
using System.Runtime.InteropServices.Marshalling;
7+
8+
// ReSharper disable IdentifierTypo
9+
// ReSharper disable InconsistentNaming
10+
11+
namespace Hi3Helper.Plugin.DNA.Management.PresetConfig;
12+
13+
[GeneratedComClass]
14+
public partial class DNABiliBilliPresetConfig : DNAChinaPresetConfig
15+
{
16+
private DNAApiResponseDetails ApiResponseDetails = new DNAApiResponseDetails()
17+
{
18+
BaseUrls = [
19+
"http://pan01-cdn-dna-ali.shyxhy.com",
20+
"http://pan01-cdn-dna-aws.shyxhy.com",
21+
"http://pan01-1-eo.shyxhy.com",
22+
"http://pan01-1-hs.shyxhy.com"
23+
],
24+
Tag = "PC_OBT_Bili_Pub",
25+
Region = "CN",
26+
RegionLong = "China"
27+
};
28+
29+
[field: AllowNull, MaybeNull]
30+
public override string GameRegistryKeyName => field ??= base.GameRegistryKeyName + " bilibili";
31+
32+
[field: AllowNull, MaybeNull]
33+
public override string ProfileName => field ??= "DNABilibili";
34+
35+
[field: AllowNull, MaybeNull]
36+
public override string ZoneName => field ??= "Bilibili";
37+
38+
[field: AllowNull, MaybeNull]
39+
public override string ZoneFullName => field ??= "Duet Night Abyss (Bilibili)";
40+
41+
public override IGameManager? GameManager
42+
{
43+
get => field ??= new DNAGameManager(ExecutableName, ApiResponseDetails, this);
44+
set;
45+
}
46+
47+
public override IGameInstaller? GameInstaller
48+
{
49+
get => field ??= new DNAGameInstaller(GameManager, ApiResponseDetails);
50+
set;
51+
}
52+
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
using Hi3Helper.Plugin.Core.Management;
2+
using Hi3Helper.Plugin.Core.Management.Api;
3+
using Hi3Helper.Plugin.DNA.Management.Api;
4+
using Hi3Helper.Plugin.DNA.Utility;
5+
using System.Collections.Generic;
6+
using System.Diagnostics.CodeAnalysis;
7+
using System.IO;
8+
using System.Runtime.InteropServices.Marshalling;
9+
using System.Threading;
10+
using System.Threading.Tasks;
11+
12+
// ReSharper disable IdentifierTypo
13+
// ReSharper disable InconsistentNaming
14+
15+
namespace Hi3Helper.Plugin.DNA.Management.PresetConfig;
16+
17+
[GeneratedComClass]
18+
public partial class DNAChinaPresetConfig : DNAPresetConfig
19+
{
20+
private DNAApiResponseDetails ApiResponseDetails = new DNAApiResponseDetails()
21+
{
22+
BaseUrls = [
23+
"http://pan01-cdn-dna-ali.shyxhy.com",
24+
"http://pan01-cdn-dna-aws.shyxhy.com",
25+
"http://pan01-1-eo.shyxhy.com",
26+
"http://pan01-1-hs.shyxhy.com"
27+
],
28+
Tag = "PC_OBT_CN_Pub",
29+
Region = "CN",
30+
RegionLong = "China"
31+
};
32+
33+
protected const string ExecutableName = "EM.exe";
34+
private const string EngineExecutableName = "EM-Win64-Shipping.exe";
35+
private const string VendorName = "Hero Games";
36+
protected const string BackgroundUrl = "https://video.yingxiong.com/fhd/2899ab9bef7c4a9eaf971b43fc109ec4.mp4";
37+
38+
private static readonly List<string> _supportedLanguages = ["Simplified Chinese", "Tradicional Chinese"];
39+
40+
public override string GameName => "Duet Night Abyss";
41+
42+
[field: AllowNull, MaybeNull]
43+
public override string GameExecutableName => field ??= Path.Combine("EM", "Binaries", "Win64", EngineExecutableName);
44+
45+
[field: AllowNull, MaybeNull]
46+
public override string StartExecutableName => field ??= ExecutableName;
47+
48+
public override string GameAppDataPath {
49+
get
50+
{
51+
string? path = null;
52+
GameManager?.GetGamePath(out path);
53+
if (path == null)
54+
return string.Empty;
55+
return Path.Combine(path, "EM", "Saved");
56+
}
57+
}
58+
59+
[field: AllowNull, MaybeNull]
60+
public override string GameLogFileName => field ??= Path.Combine("Logs", "EM.log");
61+
62+
[field: AllowNull, MaybeNull]
63+
public override string GameRegistryKeyName => field ??= "二重螺旋";
64+
65+
[field: AllowNull, MaybeNull]
66+
public override string GameVendorName => field ??= VendorName;
67+
68+
[field: AllowNull, MaybeNull]
69+
public override string ProfileName => field ??= "DNAChina";
70+
71+
[field: AllowNull, MaybeNull]
72+
public override string ZoneDescription => field ??=
73+
"《二重螺旋》是英雄游戏旗下潘神工作室自研的一款幻想风多维战斗爽游。\n游戏以「多维武器组合×立体战斗」为核心玩法,以「双视角」讲述「恶魔」的故事。";
74+
75+
[field: AllowNull, MaybeNull]
76+
public override string ZoneName => field ??= "China";
77+
78+
[field: AllowNull, MaybeNull]
79+
public override string ZoneFullName => field ??= "Duet Night Abyss (China)";
80+
81+
[field: AllowNull, MaybeNull]
82+
public override string ZoneLogoUrl => field ??= "https://cdnstatic.herogame.com/static/duetnightabyss/4.0/imgs/icon/black-logo-en.png";
83+
84+
[field: AllowNull, MaybeNull]
85+
public override string ZonePosterUrl => field ??= "https://cdnstatic.herogame.com/static/duetnightabyss/4.0/imgs/worldview/pc/2.jpg";
86+
87+
[field: AllowNull, MaybeNull]
88+
public override string ZoneHomePageUrl => field ??= "https://duetnightabyss.dna-panstudio.com/";
89+
90+
public override GameReleaseChannel ReleaseChannel => GameReleaseChannel.Public;
91+
92+
[field: AllowNull, MaybeNull]
93+
public override string GameMainLanguage => field ??= "en";
94+
95+
[field: AllowNull, MaybeNull]
96+
public override string LauncherGameDirectoryName => field ??= "DNA Game";
97+
98+
public override List<string> SupportedLanguages => _supportedLanguages;
99+
100+
public override ILauncherApiMedia? LauncherApiMedia
101+
{
102+
get => field ??= new DNAGlobalLauncherApiMedia(ApiResponseDetails, ZoneLogoUrl, BackgroundUrl);
103+
set;
104+
}
105+
106+
public override ILauncherApiNews? LauncherApiNews
107+
{
108+
get => field ??= new DNAGlobalLauncherApiNews(ApiResponseDetails, "CN");
109+
set;
110+
}
111+
112+
public override IGameManager? GameManager
113+
{
114+
get => field ??= new DNAGameManager(ExecutableName, ApiResponseDetails, this);
115+
set;
116+
}
117+
118+
public override IGameInstaller? GameInstaller
119+
{
120+
get => field ??= new DNAGameInstaller(GameManager, ApiResponseDetails);
121+
set;
122+
}
123+
124+
protected override Task<int> InitAsync(CancellationToken token)
125+
{
126+
return Task.FromResult(0);
127+
}
128+
}

Hi3Helper.Plugin.DNA/Management/PresetConfig/DNAEpicPresetConfig.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using Hi3Helper.Plugin.Core.Management;
2+
using Hi3Helper.Plugin.DNA.Management.Api;
3+
using Hi3Helper.Plugin.DNA.Utility;
24
using System.Diagnostics.CodeAnalysis;
35
using System.Runtime.InteropServices.Marshalling;
46

@@ -10,8 +12,18 @@ namespace Hi3Helper.Plugin.DNA.Management.PresetConfig;
1012
[GeneratedComClass]
1113
public partial class DNAEpicPresetConfig : DNAGlobalPresetConfig
1214
{
13-
private const string ApiResponseUrl = "http://pan01-cdn-hs-jp.dna-panstudio.com/";
14-
private const string ApiResponseTag = "PC_OBT_Global_Epic_Pub";
15+
private DNAApiResponseDetails ApiResponseDetails = new DNAApiResponseDetails()
16+
{
17+
BaseUrls = [
18+
"http://pan01-cdn-aws-jp.dna-panstudio.com/",
19+
"http://pan01-cdn-ali-jp.dna-panstudio.com/",
20+
"http://pan01-cdn-eo-jp.dna-panstudio.com/",
21+
"http://pan01-cdn-hs-jp.dna-panstudio.com/",
22+
],
23+
Tag = "PC_OBT_Global_Epic_Pub",
24+
Region = "Global",
25+
RegionLong = "Global"
26+
};
1527

1628
[field: AllowNull, MaybeNull]
1729
public override string ProfileName => field ??= "DNAEpic";
@@ -24,13 +36,13 @@ public partial class DNAEpicPresetConfig : DNAGlobalPresetConfig
2436

2537
public override IGameManager? GameManager
2638
{
27-
get => field ??= new DNAGameManager(ExecutableName, ApiResponseUrl, ApiResponseTag, this);
39+
get => field ??= new DNAGameManager(ExecutableName, ApiResponseDetails, this);
2840
set;
2941
}
3042

3143
public override IGameInstaller? GameInstaller
3244
{
33-
get => field ??= new DNAGameInstaller(GameManager, ApiResponseUrl, ApiResponseTag);
45+
get => field ??= new DNAGameInstaller(GameManager, ApiResponseDetails);
3446
set;
3547
}
3648
}

0 commit comments

Comments
 (0)