Skip to content

Commit 3043f7b

Browse files
gablmCryotechnic
andcommitted
Add more icons for Chinese socials
Co-Authored-By: Ron Friedman <[email protected]>
1 parent 3068159 commit 3043f7b

File tree

7 files changed

+625
-68
lines changed

7 files changed

+625
-68
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public class DNAApiResponseMediumInlet
4848

4949
[JsonPropertyName("inletUrl")]
5050
public string? Url { get; set; }
51+
52+
[JsonPropertyName("image")]
53+
public string? ImageUrl { get; set; }
54+
55+
[JsonPropertyName("imageText")]
56+
public string? ImageText { get; set; }
5157
}
5258

5359
public class DNAApiResponseMediumContent

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

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,11 @@ public override void GetNewsEntries(out nint handle, out int count, out bool isD
104104
isValid = time > DateTimeOffset.Now;
105105
}
106106

107-
return
108-
!string.IsNullOrEmpty(x.Event.Name) &&
109-
!string.IsNullOrEmpty(x.Event.Type) &&
110-
!string.IsNullOrEmpty(x.Event.Date) &&
111-
x.Event.Content != null && x.Event.Content.Count > 0
112-
&& isValid;
107+
return !string.IsNullOrEmpty(x.Event.Name)
108+
&& !string.IsNullOrEmpty(x.Event.Type)
109+
&& !string.IsNullOrEmpty(x.Event.Date)
110+
&& x.Event.Content != null && x.Event.Content.Count > 0
111+
&& isValid;
113112
})];
114113

115114
int entryCount = validEntries.Count;
@@ -186,9 +185,9 @@ public override void GetCarouselEntries(out nint handle, out int count, out bool
186185
isValid = time > DateTimeOffset.Now;
187186
}
188187

189-
return !string.IsNullOrEmpty(x.Name) &&
190-
x.Content != null && x.Content.Count > 0 &&
191-
isValid;
188+
return !string.IsNullOrEmpty(x.Name)
189+
&& x.Content != null && x.Content.Count > 0
190+
&& isValid;
192191
})];
193192

194193
int entryCount = validEntries.Count;
@@ -271,22 +270,27 @@ public override void GetSocialMediaEntries(out nint handle, out int count, out b
271270
var content = validEntries[i].Content!
272271
.First(x => x.Language != null && x.Language?.Code == LangCode);
273272

274-
var inlet = content.Inlets!.First();
273+
var inlet = content.Inlets!.First(x => x.Type == "1");
275274

276-
string socialMediaName = validEntries[i].Medium?.Code!;
275+
string codeName = validEntries[i].Medium?.Code!;
276+
string socialMediaName = inlet.Name!;
277277
string clickUrl = inlet.Url!;
278278

279-
byte[]? iconData = DNAImageData.GetEmbeddedData(socialMediaName);
280-
if (iconData == null)
281-
{
282-
continue;
283-
}
279+
byte[]? iconData = DNAImageData.GetEmbeddedData(codeName);
280+
iconData ??= DNAImageData.GetEmbeddedData("unknown");
284281

285282
ref LauncherSocialMediaEntry unmanagedEntry = ref memory[i];
286283

287284
unmanagedEntry.WriteIcon(iconData);
288285
unmanagedEntry.WriteDescription(socialMediaName);
289286
unmanagedEntry.WriteClickUrl(clickUrl);
287+
288+
var qrCode = content.Inlets!.FirstOrDefault(x => x.Type == "0");
289+
if (qrCode != null)
290+
{
291+
unmanagedEntry.WriteQrImage(qrCode.ImageUrl);
292+
unmanagedEntry.WriteQrImageDescription(qrCode.ImageText);
293+
}
290294
}
291295

292296
isAllocated = true;

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using Hi3Helper.Plugin.Core.Management;
22
using Hi3Helper.Plugin.DNA.Management.Api;
3-
using Hi3Helper.Plugin.DNA.Utility;
43
using System.Diagnostics.CodeAnalysis;
5-
using System.Net.Security;
64
using System.Runtime.InteropServices.Marshalling;
75

86
// ReSharper disable IdentifierTypo
@@ -13,7 +11,7 @@ namespace Hi3Helper.Plugin.DNA.Management.PresetConfig;
1311
[GeneratedComClass]
1412
public partial class DNABiliBilliPresetConfig : DNAChinaPresetConfig
1513
{
16-
private DNAApiResponseDetails ApiResponseDetails = new DNAApiResponseDetails()
14+
private readonly DNAApiResponseDetails ApiResponseDetails = new()
1715
{
1816
BaseUrls = [
1917
"http://pan01-cdn-dna-ali.shyxhy.com",

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Hi3Helper.Plugin.Core.Management;
22
using Hi3Helper.Plugin.Core.Management.Api;
33
using Hi3Helper.Plugin.DNA.Management.Api;
4-
using Hi3Helper.Plugin.DNA.Utility;
54
using System.Collections.Generic;
65
using System.Diagnostics.CodeAnalysis;
76
using System.IO;
@@ -17,7 +16,7 @@ namespace Hi3Helper.Plugin.DNA.Management.PresetConfig;
1716
[GeneratedComClass]
1817
public partial class DNAChinaPresetConfig : DNAPresetConfig
1918
{
20-
private DNAApiResponseDetails ApiResponseDetails = new DNAApiResponseDetails()
19+
private readonly DNAApiResponseDetails ApiResponseDetails = new()
2120
{
2221
BaseUrls = [
2322
"http://pan01-cdn-dna-ali.shyxhy.com",

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Hi3Helper.Plugin.Core.Management;
22
using Hi3Helper.Plugin.DNA.Management.Api;
3-
using Hi3Helper.Plugin.DNA.Utility;
43
using System.Diagnostics.CodeAnalysis;
54
using System.Runtime.InteropServices.Marshalling;
65

@@ -12,13 +11,13 @@ namespace Hi3Helper.Plugin.DNA.Management.PresetConfig;
1211
[GeneratedComClass]
1312
public partial class DNAEpicPresetConfig : DNAGlobalPresetConfig
1413
{
15-
private DNAApiResponseDetails ApiResponseDetails = new DNAApiResponseDetails()
14+
private readonly DNAApiResponseDetails ApiResponseDetails = new()
1615
{
1716
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/",
17+
"http://pan01-cdn-aws-jp.dna-panstudio.com",
18+
"http://pan01-cdn-ali-jp.dna-panstudio.com",
19+
"http://pan01-cdn-eo-jp.dna-panstudio.com",
20+
"http://pan01-cdn-hs-jp.dna-panstudio.com",
2221
],
2322
Tag = "PC_OBT_Global_Epic_Pub",
2423
Region = "Global",

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Hi3Helper.Plugin.Core.Management;
22
using Hi3Helper.Plugin.Core.Management.Api;
33
using Hi3Helper.Plugin.DNA.Management.Api;
4-
using Hi3Helper.Plugin.DNA.Utility;
54
using System.Collections.Generic;
65
using System.Diagnostics.CodeAnalysis;
76
using System.IO;
@@ -17,13 +16,13 @@ namespace Hi3Helper.Plugin.DNA.Management.PresetConfig;
1716
[GeneratedComClass]
1817
public partial class DNAGlobalPresetConfig : DNAPresetConfig
1918
{
20-
private DNAApiResponseDetails ApiResponseDetails = new DNAApiResponseDetails()
19+
private readonly DNAApiResponseDetails ApiResponseDetails = new()
2120
{
2221
BaseUrls = [
23-
"http://pan01-cdn-aws-jp.dna-panstudio.com/",
24-
"http://pan01-cdn-ali-jp.dna-panstudio.com/",
25-
"http://pan01-cdn-eo-jp.dna-panstudio.com/",
26-
"http://pan01-cdn-hs-jp.dna-panstudio.com/",
22+
"http://pan01-cdn-aws-jp.dna-panstudio.com",
23+
"http://pan01-cdn-ali-jp.dna-panstudio.com",
24+
"http://pan01-cdn-eo-jp.dna-panstudio.com",
25+
"http://pan01-cdn-hs-jp.dna-panstudio.com",
2726
],
2827
Tag = "PC_OBT_Global_Pub",
2928
Region = "Global",

0 commit comments

Comments
 (0)