Skip to content

Commit 9a5cc1d

Browse files
Szczyrkwitcher112
authored andcommitted
Rename struct Versions to ChangelogEntry, add exception that supports get current culture information
1 parent 20e70df commit 9a5cc1d

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

Assets/PatchKit Patcher/Scripts/Api/Models/Main/Changelog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ public struct Changelog
88
/// Structure Versions.
99
/// </summary>
1010
[JsonProperty("versions")]
11-
public Versions[] versions;
11+
public ChangelogEntry[] versions;
1212
}
1313
}

Assets/PatchKit Patcher/Scripts/Api/Models/Main/Versions.cs renamed to Assets/PatchKit Patcher/Scripts/Api/Models/Main/ChangelogEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PatchKit.Api.Models.Main
44
{
5-
public struct Versions
5+
public struct ChangelogEntry
66
{
77
/// <summary>
88
/// Version id.

Assets/PatchKit Patcher/Scripts/UI/Changelog/ChangelogList.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private void LoadChangelogFromCache(string appSecret)
6262
}
6363
}
6464

65-
private void CreateAndCacheChangelog(string appSecret, Versions[] versions)
65+
private void CreateAndCacheChangelog(string appSecret, ChangelogEntry[] versions)
6666
{
6767
try
6868
{
@@ -87,20 +87,20 @@ private void DestroyOldChangelog()
8787

8888
}
8989

90-
private void CreateChangelog(Versions[] versions)
90+
private void CreateChangelog(ChangelogEntry[] versions)
9191
{
9292
DestroyOldChangelog();
9393

94-
foreach (Versions version in versions)
94+
foreach (ChangelogEntry version in versions)
9595
{
9696
CreateVersionChangelog(version);
9797
}
9898
}
9999

100-
private void CreateVersionChangelog(Versions version)
100+
private void CreateVersionChangelog(ChangelogEntry changelogEntry)
101101
{
102-
CreateVersionTitleWithPublishData(version.VersionLabel, version.PublishTime);
103-
CreateVersionChangeList(version.Changes);
102+
CreateVersionTitleWithPublishData(changelogEntry.VersionLabel, changelogEntry.PublishTime);
103+
CreateVersionChangeList(changelogEntry.Changes);
104104
}
105105

106106
private void CreateVersionTitleWithPublishData(string label, long publishTime)
Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
using System.Globalization;
1+
using System;
2+
using System.Globalization;
23
using System.Linq;
4+
using PatchKit.Unity.Patcher.Debug;
35
using UnityEngine;
46

57
namespace PatchKit.Unity.Utilities
68
{
79
public static class CurrentCultureInfo
810
{
11+
private static readonly DebugLogger DebugLogger = new DebugLogger(typeof(CurrentCultureInfo));
12+
913
public static CultureInfo GetCurrentCultureInfo()
1014
{
11-
SystemLanguage currentLanguage = Application.systemLanguage;
12-
CultureInfo correspondingCultureInfo = CultureInfo.GetCultures(CultureTypes.AllCultures)
13-
.FirstOrDefault(x => x.EnglishName.Equals(currentLanguage.ToString()));
14-
return CultureInfo.CreateSpecificCulture(correspondingCultureInfo.TwoLetterISOLanguageName);
15+
try
16+
{
17+
SystemLanguage currentLanguage = Application.systemLanguage;
18+
CultureInfo correspondingCultureInfo = CultureInfo.GetCultures(CultureTypes.AllCultures)
19+
.FirstOrDefault(x => x.EnglishName.Equals(currentLanguage.ToString()));
20+
return CultureInfo.CreateSpecificCulture(correspondingCultureInfo.TwoLetterISOLanguageName);
21+
} catch(Exception e)
22+
{
23+
DebugLogger.LogWarning("Unable to get current culture info - " + e);
24+
return CultureInfo.CurrentCulture;
25+
}
1526
}
1627
}
1728
}

0 commit comments

Comments
 (0)