Skip to content

Commit

Permalink
Preview 1.80.3 Release #460 from CollapseLauncher/main
Browse files Browse the repository at this point in the history
  • Loading branch information
bagusnl authored May 8, 2024
2 parents 8a041d1 + a03c18c commit 95acda8
Show file tree
Hide file tree
Showing 33 changed files with 603 additions and 356 deletions.
139 changes: 134 additions & 5 deletions CollapseLauncher/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@
TintColor="#222222"
TintLuminosityOpacity="0.30"
TintOpacity="0.0"/>
<!-- Window Caption Button Brush -->
<SolidColorBrush x:Key="WindowCaptionBackground"
Color="#00FFFFFF"/>
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled"
Color="#00000000"/>
<SolidColorBrush x:Key="WindowCaptionBackgroundClose"
Color="#00FF0000"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<!-- For light theme -->
Expand Down Expand Up @@ -610,6 +617,13 @@
TintColor="#FFFFFF"
TintLuminosityOpacity="0.80"
TintOpacity="0.0"/>
<!-- Window Caption Button Brush -->
<SolidColorBrush x:Key="WindowCaptionBackground"
Color="#00000000"/>
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled"
Color="#00000000"/>
<SolidColorBrush x:Key="WindowCaptionBackgroundClose"
Color="#00FF0000"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<!-- Font families -->
Expand All @@ -618,6 +632,7 @@
<FontFamily x:Key="FontAwesomeSolid">ms-appx:///Assets/Fonts/FontAwesomeSolid6.otf#Font Awesome 6 Free Solid</FontFamily>
<!-- Navigation title-bar border thickness -->
<Thickness x:Key="NavigationViewContentMargin">0,47,0,0</Thickness>

<!-- START: ToggleButton styles -->
<Style x:Key="AcrylicToggleButtonStyle"
TargetType="ToggleButton">
Expand Down Expand Up @@ -2482,11 +2497,125 @@
<Style BasedOn="{StaticResource DefaultComboBoxStyle}"
TargetType="ComboBox"/>
<!-- WindowChrome min max close styles -->
<x:Double x:Key="WindowCaptionButtonStrokeWidth">1</x:Double>
<SolidColorBrush x:Key="WindowCaptionBackground"
Color="#00000000"/>
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled"
Color="#00000000"/>
<x:Double x:Key="WindowCaptionButtonStrokeWidth">2</x:Double>

<Style x:Key="WindowCaptionButton" TargetType="Button">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="{ThemeResource WindowCaptionBackground}" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />

<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="LayoutRoot"
Background="{TemplateBinding Background}"
BackgroundSizing="{TemplateBinding BackgroundSizing}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
Padding="{TemplateBinding Padding}">
<Border.BackgroundTransition>
<BrushTransition Duration="0:0:0.050"/>
</Border.BackgroundTransition>

<Path x:Name="Path"
StrokeThickness="{ThemeResource WindowCaptionButtonStrokeWidth}"
Stroke="{TemplateBinding Foreground}"
Data="{TemplateBinding Content}"
Stretch="Fill"
UseLayoutRounding="True"
Width="10"
Height="10"
StrokeEndLineCap="Round"
StrokeStartLineCap="Round">
</Path>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource WindowCaptionButtonBackgroundPointerOver}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Path"
Storyboard.TargetProperty="Stroke">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource WindowCaptionForeground}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>

<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource WindowCaptionButtonBackgroundPressed}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Path"
Storyboard.TargetProperty="Stroke">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource WindowCaptionForegroundDisabled}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<!-- these 2 states are only for Close button, needed because they use fixed colors for a theme and cannot be changed by user -->
<VisualState x:Name="CloseButtonPointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource WindowCaptionButtonBackgroundPointerOver}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Path"
Storyboard.TargetProperty="Stroke">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource WindowCaptionButtonStrokePointerOver}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>

<VisualState x:Name="CloseButtonPressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource WindowCaptionButtonBackgroundPressed}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Path"
Storyboard.TargetProperty="Stroke">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{ThemeResource WindowCaptionButtonStrokePressed}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>

</VisualStateGroup>

<VisualStateGroup x:Name="MinMaxStates">
<VisualState x:Name="WindowStateNormal">
<VisualState.Setters>
<Setter Target="Path.Data" Value="M 1.516 -0.001 L 7.451 0.009 C 8.751 0.019 9 1 8.981 1.477 L 9.002 7.558 M 9.002 7.547 C 8.929 8.669 8 9 7.43 9.015 L 1.464 9.005 C 0.374 8.973 0 8 -0.004 7.484 L -0.004 1.477 C 0 1 0.415 0.009 1.527 -0.001" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="WindowStateMaximized">
<VisualState.Setters>
<Setter Target="Path.Data" Value="M 1.516 -0.001 L 7.451 0.009 C 8.751 0.019 9 1 8.981 1.477 L 9.002 7.558 M 11 6 L 11 2 C 11 0 10 -2 8.011 -1.946 L 7.06 -1.969 L 3 -2 M 9.002 7.547 C 8.929 8.669 8 9 7.43 9.015 L 1.464 9.005 C 0.374 8.973 0 8 -0.004 7.484 L -0.004 1.477 C 0 1 0.415 0.009 1.527 -0.001" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>

</VisualStateManager.VisualStateGroups>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
<!-- Custom controls styles -->
<ResourceDictionary Source="ms-appx:///XAMLs/Theme/ContentDialogCollapse.xaml"/>
Expand Down
57 changes: 29 additions & 28 deletions CollapseLauncher/Classes/CachesManagement/Honkai/Check.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,35 @@ private async Task<List<CacheAsset>> Check(List<CacheAsset> assetIndex, Cancella

// Reset stopwatch
RestartStopwatch();

await Task.Run(() =>
try
{
try
// Create the cache directory if it doesn't exist
if (!Directory.Exists(_gamePath))
{
// Create the cache directory if it doesn't exist
if (!Directory.Exists(_gamePath))
{
Directory.CreateDirectory(_gamePath!);
}
Directory.CreateDirectory(_gamePath!);
}

// Check for unused files
CheckUnusedAssets(assetIndex, returnAsset);
// Check for unused files
CheckUnusedAssets(assetIndex, returnAsset);

// Do check in parallelization.
Parallel.ForEach(assetIndex!, new ParallelOptions { MaxDegreeOfParallelism = _threadCount }, (asset) =>
{
CheckAsset(asset, returnAsset, token);
});
}
catch (AggregateException ex)
// Do check in parallelization.
await Parallel.ForEachAsync(assetIndex!, new ParallelOptions
{
throw ex.Flatten().InnerExceptions.First();
}
});
MaxDegreeOfParallelism = _threadCount,
CancellationToken = token
}, async (asset, localToken) =>
{
await CheckAsset(asset, returnAsset, localToken);
}).ConfigureAwait(false);
}
catch (AggregateException ex)
{
throw ex.Flatten().InnerExceptions.First();
}
catch (Exception)
{
throw;
}

// Return the asset index
return returnAsset;
Expand Down Expand Up @@ -100,15 +104,12 @@ private void CheckUnusedAssets(List<CacheAsset> assetIndex, List<CacheAsset> ret
}
}

private void CheckAsset(CacheAsset asset, List<CacheAsset> returnAsset, CancellationToken token)
private async ValueTask CheckAsset(CacheAsset asset, List<CacheAsset> returnAsset, CancellationToken token)
{
// Increment the count and update the status
lock (this)
{
_progressTotalCountCurrent++;
_status!.ActivityStatus = string.Format(Lang!._CachesPage!.CachesStatusChecking!, asset!.DataType, asset.N);
_status!.ActivityTotal = string.Format(Lang._CachesPage.CachesTotalStatusChecking!, _progressTotalCountCurrent, _progressTotalCount);
}
Interlocked.Add(ref _progressTotalCountCurrent, 1);
_status!.ActivityStatus = string.Format(Lang!._CachesPage!.CachesStatusChecking!, asset!.DataType, asset.N);
_status!.ActivityTotal = string.Format(Lang._CachesPage.CachesTotalStatusChecking!, _progressTotalCountCurrent, _progressTotalCount);

// Assign the file info.
FileInfo fileInfo = new FileInfo(asset.ConcatPath!);
Expand Down Expand Up @@ -137,7 +138,7 @@ private void CheckAsset(CacheAsset asset, List<CacheAsset> returnAsset, Cancella
using (FileStream fs = new FileStream(asset.ConcatPath, FileMode.Open, FileAccess.Read, FileShare.None, _bufferBigLength))
{
// Calculate the asset CRC (SHA1)
byte[] hashArray = CheckHash(fs, new HMACSHA1(_gameSalt!), token);
byte[] hashArray = await CheckHashAsync(fs, new HMACSHA1(_gameSalt!), token);

// If the asset CRC doesn't match, then add the file to asset index.
if (!IsArrayMatch(asset.CRCArray, hashArray))
Expand Down
Loading

0 comments on commit 95acda8

Please sign in to comment.