Skip to content

Commit

Permalink
Merge branch 'game-config-improvements'
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed Oct 20, 2024
2 parents c3260b1 + 5f04b62 commit 0d606ca
Show file tree
Hide file tree
Showing 38 changed files with 828 additions and 806 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@

namespace CollapseLauncher
{
internal class ZenlessCache : ZenlessRepair, ICache, ICacheBase<ZenlessCache>
internal class ZenlessCache(UIElement parentUI, IGameVersionCheck gameVersionManager, ZenlessSettings gameSettings)
: ZenlessRepair(parentUI, gameVersionManager, gameSettings, false, null, true), ICache, ICacheBase<ZenlessCache>
{
public ZenlessCache(UIElement parentUI, IGameVersionCheck gameVersionManager, ZenlessSettings gameSettings)
: base(parentUI, gameVersionManager, gameSettings, false, null, true)
{ }

public ZenlessCache AsBaseType() => this;

public async Task StartUpdateRoutine(bool showInteractivePrompt = false)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#nullable enable
namespace CollapseLauncher.GameSettings.Zenless.JsonProperties;

public struct SystemSettingLocalData<TData>
public readonly struct SystemSettingLocalData<TData>
where TData : struct
{
private const string TypeKey = "MoleMole.SystemSettingLocalData";
Expand Down Expand Up @@ -44,7 +44,7 @@ public SystemSettingLocalData([NotNull] JsonNode node, TData defaultData = defau
public static class SystemSettingLocalDataExt
{
public static SystemSettingLocalData<TData> AsSystemSettingLocalData<TData>(
[NotNull] this JsonNode node, string keyName, TData defaultData = default, int defaultVersion = 1)
[NotNull] this JsonNode? node, string keyName, TData defaultData = default, int defaultVersion = 1)
where TData : struct
{
ArgumentNullException.ThrowIfNull(node, nameof(node));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public GameTypeGenshinVersion(UIElement parentUIElement, RegionResourceProp game
return base.TryFindGamePathFromExecutableAndConfig(path, executableName);
}

return null;
return basePath;
}

protected override bool IsExecutableFileExist(string? executableName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,10 @@ protected virtual async Task StartPackageInstallationInner(List<GameInstallPacka
{
indexOfArgument = asset.RunCommand.IndexOf(' ');
}
else
{
indexOfArgument = -1;
}

if (indexOfArgument >= 0)
{
Expand Down
32 changes: 22 additions & 10 deletions CollapseLauncher/Classes/Interfaces/Class/GamePropertyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,23 @@ public GamePropertyBase(UIElement parentUI, IGameVersionCheck gameVersionManager
public GamePropertyBase(UIElement parentUI, IGameVersionCheck gameVersionManager, string gamePath, string gameRepoURL, string versionOverride)
{
_gameVersionManager = gameVersionManager;
_parentUI = parentUI;
_gamePathField = gamePath;
_gameRepoURL = gameRepoURL;
_token = new CancellationTokenSourceWrapper();
AssetEntry = new ObservableCollection<IAssetProperty>();
_parentUI = parentUI;
_gamePathField = gamePath;
_gameRepoURL = gameRepoURL;
_token = new CancellationTokenSourceWrapper();
AssetEntry = new ObservableCollection<IAssetProperty>();
_isVersionOverride = versionOverride != null;

// If the version override is not null, then assign the override value
if (_isVersionOverride = versionOverride != null)
if (_isVersionOverride)
{
_gameVersionOverride = new GameVersion(versionOverride);
}
}

protected const int _bufferLength = 4 << 10;
protected const int _bufferMediumLength = 512 << 10;
protected const int _bufferBigLength = 1 << 20;
protected const int _bufferLength = 4 << 10; // 4 KiB
protected const int _bufferMediumLength = 4 << 17; // 512 KiB
protected const int _bufferBigLength = 1 << 20; // 1 MiB
protected const int _sizeForMultiDownload = 10 << 20;
protected const int _downloadThreadCountReserved = 16;
protected virtual string _userAgent { get; set; } = "UnityPlayer/2017.4.18f1 (UnityWebRequest/1.0, libcurl/7.51.0-DEV)";
Expand All @@ -51,7 +52,18 @@ public GamePropertyBase(UIElement parentUI, IGameVersionCheck gameVersionManager
protected Stopwatch _stopwatch { get; set; }
protected Stopwatch _refreshStopwatch { get; set; }
protected Stopwatch _downloadSpeedRefreshStopwatch { get; set; }
protected GameVersion _gameVersion { get => _isVersionOverride ? _gameVersionOverride : _gameVersionManager.GetGameExistingVersion().Value; }
protected GameVersion _gameVersion
{
get
{
if (_gameVersionManager != null && _isVersionOverride)
{
return _gameVersionOverride;
}
return _gameVersionManager?.GetGameExistingVersion() ?? throw new NullReferenceException();
}
}

protected IGameVersionCheck _gameVersionManager { get; set; }
protected IGameSettings _gameSettings { get; set; }
protected string _gamePath { get => string.IsNullOrEmpty(_gamePathField) ? _gameVersionManager.GameDirPath : _gamePathField; }
Expand Down
Loading

0 comments on commit 0d606ca

Please sign in to comment.