Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CollapseLauncher.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
<BuildType Solution="Publish|*" Project="Release" />
<Platform Project="x64" />
</Project>
<Project Path="Hi3Helper.LocaleSourceGen/Hi3Helper.LocaleSourceGen.csproj">
<Platform Project="x64" />
</Project>
<Project Path="Hi3Helper.Plugin.Core/Hi3Helper.Plugin.Core.csproj">
<BuildType Solution="Publish|*" Project="Release" />
<Platform Project="x64" />
Expand All @@ -66,6 +69,9 @@
<BuildType Solution="Publish|*" Project="Release" />
<Platform Project="x64" />
</Project>
<Project Path="Hi3Helper.SourceGen/Hi3Helper.SourceGen.csproj">
<BuildType Solution="Publish|*" Project="Release" />
</Project>
<Project Path="Hi3Helper.TaskScheduler/Hi3Helper.TaskScheduler.csproj">
<BuildType Solution="Publish|*" Project="Release" />
<Platform Project="x64" />
Expand Down
4 changes: 2 additions & 2 deletions CollapseLauncher/App.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- ReSharper disable Xaml.ConstructorWarning -->
<Application x:Class="CollapseLauncher.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand Down
8 changes: 4 additions & 4 deletions CollapseLauncher/Classes/CachesManagement/Honkai/Check.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CollapseLauncher.Helper.StreamUtility;
using CollapseLauncher.Helper;
using CollapseLauncher.Helper.StreamUtility;
using CollapseLauncher.Interfaces;
using Hi3Helper;
using System;
Expand All @@ -9,7 +10,6 @@
using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
using static Hi3Helper.Locale;
using static Hi3Helper.Logger;
// ReSharper disable CommentTypo

Expand Down Expand Up @@ -123,8 +123,8 @@ private async ValueTask CheckAsset(CacheAsset asset, List<CacheAsset> returnAsse
{
// Increment the count and update the status
Interlocked.Add(ref ProgressAllCountCurrent, 1);
Status.ActivityStatus = string.Format(Lang!._CachesPage!.CachesStatusChecking!, asset!.DataType, asset.N);
Status.ActivityAll = string.Format(Lang._CachesPage.CachesTotalStatusChecking!, ProgressAllCountCurrent, ProgressAllCountTotal);
Status.ActivityStatus = string.Format(Locale.Current.Lang?._CachesPage?.CachesStatusChecking ?? "", asset!.DataType, asset.N);
Status.ActivityAll = string.Format(Locale.Current.Lang?._CachesPage?.CachesTotalStatusChecking ?? "", ProgressAllCountCurrent, ProgressAllCountTotal);

// Assign the file info.
FileInfo fileInfo = new FileInfo(asset.ConcatPath).EnsureNoReadOnly(out bool isExist);
Expand Down
5 changes: 2 additions & 3 deletions CollapseLauncher/Classes/CachesManagement/Honkai/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using System.Threading;
using System.Threading.Tasks;
using static Hi3Helper.Data.ConverterTool;
using static Hi3Helper.Locale;
using static Hi3Helper.Logger;
// ReSharper disable SwitchStatementHandlesSomeKnownEnumValuesWithDefault
// ReSharper disable CommentTypo
Expand Down Expand Up @@ -127,7 +126,7 @@ private async Task BuildGameRepoURL(HttpClient client, CancellationToken token)
private async Task<(int, long)> FetchByType(CacheAssetType type, HttpClient client, List<CacheAsset> assetIndex, CancellationToken token)
{
// Set total activity string as "Fetching Caches Type: <type>"
Status.ActivityStatus = string.Format(Lang!._CachesPage!.CachesStatusFetchingType!, type);
Status.ActivityStatus = string.Format(Locale.Current.Lang?._CachesPage?.CachesStatusFetchingType ?? "", type);
Status.IsProgressAllIndetermined = true;
Status.IsIncludePerFileIndicator = false;
UpdateStatus();
Expand Down Expand Up @@ -282,7 +281,7 @@ await Parallel.ForEachAsync(EnumerateCacheTextAsset(type, dataTextAsset.GetStrin
if (content.DLM == 2)
{
// Update the status
Status.ActivityStatus = string.Format(Lang._CachesPage.Status2, type, content.N);
Status.ActivityStatus = string.Format(Locale.Current.Lang?._CachesPage?.Status2 ?? "", type, content.N);
Status.IsProgressAllIndetermined = true;
Status.IsProgressPerFileIndetermined = true;
UpdateStatus();
Expand Down
12 changes: 6 additions & 6 deletions CollapseLauncher/Classes/CachesManagement/Honkai/HonkaiCache.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using CollapseLauncher.Extension;
using CollapseLauncher.Helper;
using CollapseLauncher.Interfaces;
using Hi3Helper.Data;
using Hi3Helper.EncTool.Parser.KianaDispatch;
using Microsoft.UI.Xaml;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using static Hi3Helper.Locale;

namespace CollapseLauncher
{
Expand Down Expand Up @@ -72,8 +72,8 @@ private async Task<bool> CheckRoutine()
// either way, returns false.
return SummarizeStatusAndProgress(
UpdateAssetIndex,
string.Format(Lang!._CachesPage!.CachesStatusNeedUpdate!, ProgressAllCountFound, ConverterTool.SummarizeSizeSimple(ProgressAllSizeFound)),
Lang._CachesPage.CachesStatusUpToDate);
string.Format(Locale.Current.Lang?._CachesPage?.CachesStatusNeedUpdate ?? "", ProgressAllCountFound, ConverterTool.SummarizeSizeSimple(ProgressAllSizeFound)),
Locale.Current.Lang?._CachesPage?.CachesStatusUpToDate ?? "");
}

public async Task StartUpdateRoutine(bool showInteractivePrompt = false)
Expand All @@ -95,9 +95,9 @@ private async Task<bool> UpdateRoutine()
ResetStatusAndProgress();

// Set as completed
Status.IsCompleted = true;
Status.IsCanceled = false;
Status.ActivityStatus = Lang!._CachesPage!.CachesStatusUpToDate;
Status.IsCompleted = true;
Status.IsCanceled = false;
Status.ActivityStatus = Locale.Current.Lang?._CachesPage?.CachesStatusUpToDate;

// Update status and progress
UpdateAll();
Expand Down
3 changes: 1 addition & 2 deletions CollapseLauncher/Classes/CachesManagement/Honkai/Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using static Hi3Helper.Locale;
using static Hi3Helper.Logger;
// ReSharper disable CommentTypo
// ReSharper disable GrammarMistakeInComment
Expand Down Expand Up @@ -123,7 +122,7 @@ private async Task UpdateCacheAsset((CacheAsset AssetIndex, IAssetProperty Asset
{
// Increment total count and update the status
ProgressAllCountCurrent++;
Status.ActivityStatus = string.Format(Lang!._Misc!.Downloading + " {0}: {1}", asset!.AssetIndex.DataType, asset.AssetIndex.N);
Status.ActivityStatus = string.Format(Locale.Current.Lang?._Misc?.Downloading + " {0}: {1}", asset!.AssetIndex.DataType, asset.AssetIndex.N);
UpdateAll();

FileInfo fileInfo = new FileInfo(asset.AssetIndex.ConcatPath!)
Expand Down
52 changes: 24 additions & 28 deletions CollapseLauncher/Classes/DiscordPresence/DiscordPresenceManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CollapseLauncher.Helper.Metadata;
using CollapseLauncher.Helper;
using CollapseLauncher.Helper.Metadata;
using CollapseLauncher.Helper.Update;
using CollapseLauncher.Plugins;
using DiscordRPC;
Expand All @@ -8,7 +9,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Threading.Tasks.Dataflow;
using static Hi3Helper.Locale;
using static Hi3Helper.Shared.Region.LauncherConfig;
// ReSharper disable PartialTypeWithSinglePart
// ReSharper disable StringLiteralTypo
Expand Down Expand Up @@ -186,8 +186,8 @@ public void SetupPresence()
{
if (!IsRpcEnabled) return;

var gameCategory = GetAppConfigValue("GameCategory").ToString();
var isGameStatusEnabled = GetAppConfigValue("EnableDiscordGameStatus").ToBool();
string? gameCategory = GetAppConfigValue("GameCategory").ToString();
bool isGameStatusEnabled = GetAppConfigValue("EnableDiscordGameStatus").ToBool();

if (isGameStatusEnabled)
{
Expand Down Expand Up @@ -248,33 +248,33 @@ public void SetActivity(ActivityType activity, DateTime? activityOffset = null)
case ActivityType.Play:
{
bool isGameStatusEnabled = GetAppConfigValue("EnableDiscordGameStatus").ToBool();
BuildActivityGameStatus(isGameStatusEnabled ? Lang._Misc.DiscordRP_InGame : Lang._Misc.DiscordRP_Play,
BuildActivityGameStatus((isGameStatusEnabled ? Locale.Current.Lang?._Misc?.DiscordRP_InGame : Locale.Current.Lang?._Misc?.DiscordRP_Play) ?? "",
isGameStatusEnabled, activityOffset);
break;
}
case ActivityType.Update:
{
bool isGameStatusEnabled = GetAppConfigValue("EnableDiscordGameStatus").ToBool();
BuildActivityGameStatus(Lang._Misc.DiscordRP_Update, isGameStatusEnabled);
BuildActivityGameStatus(Locale.Current.Lang?._Misc?.DiscordRP_Update ?? "", isGameStatusEnabled);
break;
}
case ActivityType.Repair:
BuildActivityAppStatus(Lang._Misc.DiscordRP_Repair);
BuildActivityAppStatus(Locale.Current.Lang?._Misc?.DiscordRP_Repair ?? "");
break;
case ActivityType.Cache:
BuildActivityAppStatus(Lang._Misc.DiscordRP_Cache);
BuildActivityAppStatus(Locale.Current.Lang?._Misc?.DiscordRP_Cache ?? "");
break;
case ActivityType.GameSettings:
BuildActivityAppStatus(Lang._Misc.DiscordRP_GameSettings);
BuildActivityAppStatus(Locale.Current.Lang?._Misc?.DiscordRP_GameSettings ?? "");
break;
case ActivityType.AppSettings:
BuildActivityAppStatus(Lang._Misc.DiscordRP_AppSettings);
BuildActivityAppStatus(Locale.Current.Lang?._Misc?.DiscordRP_AppSettings ?? "");
break;
case ActivityType.Idle:
_lastPlayTime = null;
if (_cachedIsIdleEnabled)
{
BuildActivityAppStatus(Lang._Misc.DiscordRP_Idle);
BuildActivityAppStatus(Locale.Current.Lang?._Misc?.DiscordRP_Idle ?? "");
}
else
{
Expand All @@ -285,7 +285,7 @@ public void SetActivity(ActivityType activity, DateTime? activityOffset = null)
default:
_presence = new RichPresence
{
Details = Lang._Misc.DiscordRP_Default,
Details = Locale.Current.Lang?._Misc?.DiscordRP_Default,
Assets = new Assets
{
LargeImageKey = "launcher-logo-new",
Expand All @@ -302,16 +302,14 @@ public void SetActivity(ActivityType activity, DateTime? activityOffset = null)

private void BuildActivityGameStatus(string activityName, bool isGameStatusEnabled, DateTime? activityOffset = null)
{
var curGameName = LauncherMetadataHelper.CurrentMetadataConfigGameName;
var curGameRegion = LauncherMetadataHelper.CurrentMetadataConfigGameRegion;
string? curGameName = LauncherMetadataHelper.CurrentMetadataConfigGameName;
string? curGameRegion = LauncherMetadataHelper.CurrentMetadataConfigGameRegion;

if (string.IsNullOrEmpty(curGameName) || string.IsNullOrEmpty(curGameRegion))
return;

var curGameNameTranslate =
InnerLauncherConfig.GetGameTitleRegionTranslationString(curGameName, Lang._GameClientTitles);
var curGameRegionTranslate =
InnerLauncherConfig.GetGameTitleRegionTranslationString(curGameRegion, Lang._GameClientRegions);
string? curGameNameTranslate = LauncherMetadataHelper.GetGameTitleTranslation(curGameName);
string? curGameRegionTranslate = LauncherMetadataHelper.GetGameRegionTranslation(curGameRegion);

if (TryBuildActivityGameStatusFromPlugin(activityName,
curGameNameTranslate,
Expand All @@ -326,7 +324,7 @@ private void BuildActivityGameStatus(string activityName, bool isGameStatusEnabl
_presence = new RichPresence
{
Details = $"{activityName} {(!isGameStatusEnabled ? curGameNameTranslate : null)}",
State = $"{Lang._Misc.DiscordRP_Region} {curGameRegionTranslate}",
State = $"{Locale.Current.Lang?._Misc?.DiscordRP_Region} {curGameRegionTranslate}",
Assets = new Assets
{
LargeImageKey = $"game-{LauncherMetadataHelper.CurrentMetadataConfig?.GameType.ToString().ToLower()}-logo",
Expand Down Expand Up @@ -367,7 +365,7 @@ is not PluginPresetConfigWrapper asPluginPresetConfig ||
presence = new RichPresence
{
Details = $"{activityName} {(!isGameStatusEnabled ? translatedGameName : null)}",
State = $"{Lang._Misc.DiscordRP_Region} {translatedRegionName}",
State = $"{Locale.Current.Lang?._Misc?.DiscordRP_Region} {translatedRegionName}",
Assets = new Assets
{
LargeImageKey = largeIconUrl ?? CollapseLogoExt,
Expand Down Expand Up @@ -395,16 +393,14 @@ private DateTime GetCachedStartPlayTime(DateTime? activityOffset)

private void BuildActivityAppStatus(string activityName)
{
var curGameName = LauncherMetadataHelper.CurrentMetadataConfigGameName;
var curGameRegion = LauncherMetadataHelper.CurrentMetadataConfigGameRegion;
string? curGameName = LauncherMetadataHelper.CurrentMetadataConfigGameName;
string? curGameRegion = LauncherMetadataHelper.CurrentMetadataConfigGameRegion;

if (string.IsNullOrEmpty(curGameName) || string.IsNullOrEmpty(curGameRegion))
return;

var curGameNameTranslate =
InnerLauncherConfig.GetGameTitleRegionTranslationString(curGameName, Lang._GameClientTitles);
var curGameRegionTranslate =
InnerLauncherConfig.GetGameTitleRegionTranslationString(curGameRegion, Lang._GameClientRegions);
string? curGameNameTranslate = LauncherMetadataHelper.GetGameTitleTranslation(curGameName);
string? curGameRegionTranslate = LauncherMetadataHelper.GetGameRegionTranslation(curGameRegion);

if (TryBuildActivityAppStatusFromPlugin(activityName,
curGameNameTranslate,
Expand All @@ -417,7 +413,7 @@ private void BuildActivityAppStatus(string activityName)
_presence = new RichPresence
{
Details = activityName,
State = $"{Lang._Misc.DiscordRP_Region} {curGameRegionTranslate}",
State = $"{Locale.Current.Lang?._Misc?.DiscordRP_Region} {curGameRegionTranslate}",
Assets = new Assets
{
LargeImageKey = $"game-{LauncherMetadataHelper.CurrentMetadataConfig?.GameType.ToString().ToLower()}-logo",
Expand Down Expand Up @@ -453,7 +449,7 @@ is not PluginPresetConfigWrapper asPluginPresetConfig ||
presence = new RichPresence
{
Details = activityName,
State = $"{Lang._Misc.DiscordRP_Region} {translatedRegionName}",
State = $"{Locale.Current.Lang?._Misc?.DiscordRP_Region} {translatedRegionName}",
Assets = new Assets
{
LargeImageKey = largeIconUrl ?? CollapseLogoExt,
Expand Down
Loading
Loading