Skip to content

Commit 43d6827

Browse files
committed
Bugfix, minor changes, improvements
- Correctly handle RawInput now. (I forgot the value is a "flag", not numeric value). Now holding mouse buttons while scrolling will still work. - Improved PSO2 Updater Result dialog: Added name filter and export result to file. - Changed 'PSO2 Data Manager' dialog, as well as added 1 new option regarding Nvidia DLSS version. - Fixed COMException which make IE-based WebBrowser to load the pso2 news page. - Update MahApps.Metro to v2.4.10.
1 parent 1315553 commit 43d6827

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+832
-287
lines changed

LauncherCore/Classes/ConfigurationFile.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,29 @@ public bool LauncherCheckForSelfUpdates
404404
set => this.Set("launcher_checkselfupdates", value);
405405
}
406406

407+
public bool AllowNvidiaDlssModding
408+
{
409+
get
410+
{
411+
if (this.TryGetRaw("launcher_allowNvidiaDlssModding", out var val))
412+
{
413+
if (val.ValueKind == System.Text.Json.JsonValueKind.True)
414+
{
415+
return true;
416+
}
417+
else
418+
{
419+
return false;
420+
}
421+
}
422+
else
423+
{
424+
return false;
425+
}
426+
}
427+
set => this.Set("launcher_allowNvidiaDlssModding", value);
428+
}
429+
407430
public bool LauncherDisableInGameFileIntegrityCheck
408431
{
409432
get

LauncherCore/Classes/PSO2/DataTypes/PSO2Version.cs

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Buffers;
23
using System.Collections.Generic;
34
using System.Text;
45
using System.Threading.Tasks;
@@ -36,7 +37,7 @@ public static bool TryParse(ReadOnlySpan<char> versionString, out PSO2Version va
3637
// Or not
3738

3839
// WTF I am doing
39-
if (versionString.Length == 0 || versionString.IsWhiteSpace())
40+
if (versionString.IsEmpty || versionString.IsWhiteSpace())
4041
{
4142
value = default;
4243
return false;
@@ -99,8 +100,8 @@ public readonly int CompareTo(PSO2Version other)
99100
}
100101
else
101102
{
102-
thisRC = TakeDigitOnly(in this.ReleaseCandidate);
103-
otherRC = TakeDigitOnly(in other.ReleaseCandidate);
103+
thisRC = TakeDigitOnly(this.ReleaseCandidate.AsSpan());
104+
otherRC = TakeDigitOnly(other.ReleaseCandidate.AsSpan());
104105
return thisRC.CompareTo(otherRC);
105106
}
106107
}
@@ -110,19 +111,50 @@ public readonly int CompareTo(PSO2Version other)
110111
}
111112
}
112113

113-
private static int TakeDigitOnly(in string str)
114+
private static int TakeDigitOnly(ReadOnlySpan<char> span)
114115
{
115-
var span = str.AsSpan();
116-
var sb = new StringBuilder(span.Length);
117-
for (int i = 0; i < span.Length; i++)
116+
if (span.IsEmpty) return int.Parse(span);
117+
int i = 0, len = span.Length;
118+
bool foundNonDigit = false;
119+
for (i = 0; i < len; i++)
118120
{
119-
if (char.IsDigit(span[i]))
121+
if (!char.IsDigit(span[i]))
120122
{
121-
sb.Append(span[i]);
123+
foundNonDigit = true;
124+
break;
122125
}
123126
}
124127

125-
return int.Parse(sb.ToString());
128+
if (foundNonDigit)
129+
{
130+
char[]? arr = len > 512 ? ArrayPool<char>.Shared.Rent(len) : null;
131+
Span<char> buffer = arr == null ? stackalloc char[len] : arr;
132+
try
133+
{
134+
span.Slice(0, i).CopyTo(buffer);
135+
int dstIndex = i;
136+
for (; i < len; i++)
137+
{
138+
ref readonly var c = ref span[i];
139+
if (char.IsDigit(c))
140+
{
141+
buffer[dstIndex++] = c;
142+
}
143+
}
144+
return int.Parse(buffer.Slice(0, dstIndex));
145+
}
146+
finally
147+
{
148+
if (arr != null)
149+
{
150+
ArrayPool<char>.Shared.Return(arr);
151+
}
152+
}
153+
}
154+
else
155+
{
156+
return int.Parse(span);
157+
}
126158
}
127159

128160
public override readonly bool Equals(object? obj)

LauncherCore/Classes/PSO2/Enums.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ public enum FileScanFlags
5050
/// <remarks><para>Hash table file is <u>data/win32/d4455ebc2bef618f29106da7692ebc1a</u>.</para></remarks>
5151
IgnoreHashTableFile = 1 << 5,
5252

53+
/// <summary>Let the updater knows that it shouldn't re-download Nvidia DLSS binary file if the file is existed.</summary>
54+
/// <remarks>
55+
/// <para>However, this flag is meaningless if the file doesn't exist as it will be redownloaded to ensure the binary file isn't missing.</para>
56+
/// <para>The DLSS binary file is <u>nvngx_dlss.dll</u>.</para>
57+
/// </remarks>
58+
DoNotRedownloadNvidiaDlssBin = 1 << 6,
59+
5360
// Preset below
5461

5562
[EnumDisplayName("Prefer speed [Not recommended: Unreliable] (Check missing and compare the cached MD5-hash if the file is already existed)")]

LauncherCore/Classes/PSO2/GameClientUpdater.Events.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private void OnClientOperationComplete1(string dir_pso2bin, string? pso2tweaker_
125125
// Check whether Tweaker is targeting the same pso2_bin this launcher is managing.
126126
if (string.Equals(pso2tweakerconfig_pso2bin, dir_pso2bin, StringComparison.OrdinalIgnoreCase))
127127
{
128-
pso2tweakerconfig.ResetFanPatchVersion();
128+
pso2tweakerconfig.ResetFanPatchVersion(downloadMode);
129129
pso2tweakerconfig.PSO2JPRemoteVersion = versionStringRaw;
130130

131131
if (tweakerhashcacheDump != null)

LauncherCore/Classes/PSO2/GameClientUpdater.FileScan.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ namespace Leayal.PSO2Launcher.Core.Classes.PSO2
1515
#nullable enable
1616
partial class GameClientUpdater
1717
{
18-
private static readonly string __Filename_HashTableRelativePath = "data/win32/d4455ebc2bef618f29106da7692ebc1a";
18+
private static readonly string __Filename_HashTableRelativePath = "data/win32/d4455ebc2bef618f29106da7692ebc1a",
19+
__Filename_DlssBinaryFileRelativePath = "nvngx_dlss.dll";
1920

2021
const int ScanBufferSize = 1024 * 16; // 16KB buffer
2122
private async Task<PatchListMemory> InnerGetFilelistToScan(GameClientSelection selection, CancellationToken cancellationToken)
@@ -329,6 +330,9 @@ static async Task<string> ___GetFileMD5(FileStream fs, MD5 hashal, CancellationT
329330
[MethodImpl(MethodImplOptions.AggressiveInlining)]
330331
static bool IsHashTableFile(PatchListItem item) => (MemoryExtensions.Equals(item.GetSpanFilenameWithoutAffix(), __Filename_HashTableRelativePath, StringComparison.OrdinalIgnoreCase) || MemoryExtensions.Equals(item.GetSpanFilenameWithoutAffix(), __Filename_HashTableRelativePath.AsSpan(11), StringComparison.OrdinalIgnoreCase));
331332

333+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
334+
static bool IsDlssBinaryFile(PatchListItem item) => (MemoryExtensions.Equals(item.GetSpanFilenameWithoutAffix(), __Filename_DlssBinaryFileRelativePath, StringComparison.OrdinalIgnoreCase));
335+
332336
[MethodImpl(MethodImplOptions.AggressiveInlining)]
333337
static void AddItemToQueue(BlockingCollection<DownloadItem> queue, InnerDownloadQueueAddCallback callback, PatchListItem patchItem, string localFilePath, string dir_pso2bin, string? dir_classic_data, CancellationToken cancellationToken)
334338
{
@@ -410,6 +414,11 @@ static async Task<ReadOnlyMemory<byte>> Md5ComputeHash(IncrementalHash engine, F
410414
{
411415
continue;
412416
}
417+
if ((flags & FileScanFlags.DoNotRedownloadNvidiaDlssBin) != 0 && IsDlssBinaryFile(patchItem))
418+
{
419+
if (File.Exists(Path.Join(dir_pso2bin, patchItem.GetSpanFilenameWithoutAffix())))
420+
continue;
421+
}
413422
// data/win32/2b486d03bca4c2578f9e204b234f389b
414423
if (flags == FileScanFlags.MissingFilesOnly)
415424
{

LauncherCore/Classes/PSO2TweakerConfig.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Leayal.Shared;
1+
using Leayal.PSO2Launcher.Core.Classes.PSO2;
2+
using Leayal.Shared;
23
using System;
34
using System.Collections.Generic;
45
using System.IO;
@@ -19,10 +20,22 @@ public PSO2TweakerConfig(string path)
1920
this.Filename = path;
2021
}
2122

22-
public void ResetFanPatchVersion()
23+
public void ResetFanPatchVersion(GameClientSelection gameClientSelection)
2324
{
24-
this.Set("LatestWin32FanPatchVersion", "0");
25-
this.Set("LatestWin32RebootFanPatchVersion", "0");
25+
switch (gameClientSelection)
26+
{
27+
case GameClientSelection.Classic_Only:
28+
this.Set("LatestWin32FanPatchVersion", "0");
29+
break;
30+
case GameClientSelection.NGS_Only:
31+
case GameClientSelection.NGS_Prologue_Only:
32+
this.Set("LatestWin32RebootFanPatchVersion", "0");
33+
break;
34+
default:
35+
this.Set("LatestWin32FanPatchVersion", "0");
36+
this.Set("LatestWin32RebootFanPatchVersion", "0");
37+
break;
38+
}
2639
}
2740

2841
public string UpdateChecks

LauncherCore/LauncherCore.csproj

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

4949
<ItemGroup>
5050
<PackageReference Include="AvalonEdit" Version="6.3.0.90" />
51-
<PackageReference Include="MahApps.Metro" Version="2.4.9" />
51+
<PackageReference Include="MahApps.Metro" Version="2.4.10" />
5252
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="4.11.0" />
5353
</ItemGroup>
5454

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Runtime.CompilerServices;
2+
using System.Windows.Controls;
3+
4+
namespace Leayal.PSO2Launcher.Core.UIElements
5+
{
6+
static class ConvenientEventHandlers
7+
{
8+
/// <summary>When this method is added to a <seealso cref="System.Windows.Controls.Primitives.Selector.SelectionChanged"/>, prevent the control from selecting no items.</summary>
9+
/// <remarks>
10+
/// <para>You can also just pass-through the event handler to this handler.</para>
11+
/// <para>Currently supports only <seealso cref="TabControl"/>.</para>
12+
/// </remarks>
13+
/// <param name="sender">The element which raised this event. May be <see langword="null"/>.</param>
14+
/// <param name="e">The event parameters which associated with the event.</param>
15+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
16+
public static void TabControl_SelectionChanged_PreventSelectingNothing(object? sender, SelectionChangedEventArgs e)
17+
{
18+
if (e.AddedItems == null || e.AddedItems.Count == 0)
19+
{
20+
if (e.RemovedItems[0] is TabItem tab)
21+
{
22+
e.Handled = true;
23+
tab.IsSelected = true;
24+
}
25+
}
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)