Skip to content

Commit

Permalink
implement ps3 fw update filter
Browse files Browse the repository at this point in the history
  • Loading branch information
13xforever committed Jan 22, 2024
1 parent 80d6a9b commit 40d2112
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
13 changes: 7 additions & 6 deletions Ps3DiscDumper/Dumper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ public void DetectDisc(string inDir = "", Func<Dumper, string> outputDirFormatte

// todo: maybe use discutils instead to read TOC as one block
var files = IOEx.GetFilepaths(InputDevicePath, "*", SearchOption.AllDirectories);
if (!SettingsProvider.Settings.CopyBdmv)
if (SettingsProvider.Settings.FilterRequired)
{
var prefixList = Settings.BdmvFolders
var prefixList = SettingsProvider.Settings.FilterDirList
.Select(f => Path.Combine(InputDevicePath, f) + Path.DirectorySeparatorChar)
.ToArray();
files = files.Where(f => !prefixList.Any(f.StartsWith));
Expand Down Expand Up @@ -527,15 +527,16 @@ public async Task DumpAsync(string output)
if (filesystemStructure is null)
{
(filesystemStructure, emptyDirStructure) = GetFilesystemStructure();
var prefixList = Settings.BdmvFolders.Select(f => f + Path.DirectorySeparatorChar).ToArray();
if (!SettingsProvider.Settings.CopyBdmv)
var filterDirList = SettingsProvider.Settings.FilterDirList;
var prefixList = filterDirList.Select(f => f + Path.DirectorySeparatorChar).ToArray();
if (SettingsProvider.Settings.FilterRequired)
{
filesystemStructure = filesystemStructure
.Where(r => !Settings.BdmvFolders.Any(f => r.TargetFileName == f) &&
.Where(r => !filterDirList.Any(f => r.TargetFileName == f) &&
!prefixList.Any(p => r.TargetFileName.StartsWith(p)))
.ToList();
emptyDirStructure = emptyDirStructure
.Where(r => !Settings.BdmvFolders.Any(f => r.TargetDirName == f) &&
.Where(r => !filterDirList.Any(f => r.TargetDirName == f) &&
!prefixList.Any(p => r.TargetDirName.StartsWith(p)))
.ToList();
}
Expand Down
18 changes: 16 additions & 2 deletions Ps3DiscDumper/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Text.Json.Serialization;
using Ps3DiscDumper.Utils;

Expand All @@ -12,7 +13,8 @@ public struct Settings
public Settings() { }

[JsonIgnore] public const string DefaultPattern = $"%{Patterns.Title}% [%{Patterns.ProductCode}%]";
[JsonIgnore] public static readonly string[] BdmvFolders = ["BDMV", "AACS", "CERTIFICATE"];
[JsonIgnore] public static readonly string[] BdmvFolders = ["BDMV", "AACS", "CERTIFICATE"];
[JsonIgnore] public static readonly string[] Ps3UpdateFolder = ["PS3_UPDATE"];

public string OutputDir { get; set; } = ".";
public string IrdDir { get; set; } = Path.Combine(Environment.GetFolderPath(SpecialFolder.ApplicationData) ,"ps3-iso-dumper", "ird");
Expand All @@ -22,6 +24,16 @@ public Settings() { }
public bool PreferSystemAccent { get; set; } = !OperatingSystem.IsWindows();
public bool StayOnTop { get; set; } = false;
public bool CopyBdmv { get; set; } = false;
public bool CopyPs3Update { get; set; } = false;

[JsonIgnore] public bool FilterRequired => !CopyBdmv || !CopyPs3Update;
[JsonIgnore] public string[] FilterDirList => (CopyBdmv, CopyPs3Update) switch
{
(false, false) => BdmvFolders.Concat(Ps3UpdateFolder).ToArray(),
(false, true) => BdmvFolders,
(true, false) => Ps3UpdateFolder,
_ => Array.Empty<string>(),
};

private static StringComparison Comparison => OperatingSystem.IsWindows() ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
private static StringComparer Comparer => OperatingSystem.IsWindows() ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal;
Expand All @@ -37,7 +49,8 @@ public bool Equals(Settings other)
&& EnableTransparency == other.EnableTransparency
&& PreferSystemAccent == other.PreferSystemAccent
&& StayOnTop == other.StayOnTop
&& CopyBdmv == other.CopyBdmv;
&& CopyBdmv == other.CopyBdmv
&& CopyPs3Update == other.CopyPs3Update;

public override int GetHashCode()
{
Expand All @@ -50,6 +63,7 @@ public override int GetHashCode()
hashCode.Add(PreferSystemAccent);
hashCode.Add(StayOnTop);
hashCode.Add(CopyBdmv);
hashCode.Add(CopyPs3Update);
return hashCode.ToHashCode();
}
}
4 changes: 4 additions & 0 deletions UI.Avalonia/ViewModels/ViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public partial class ViewModelBase: ObservableObject
[ObservableProperty] private static bool preferSystemAccent = SettingsProvider.Settings.PreferSystemAccent;
[ObservableProperty] private static bool stayOnTop = SettingsProvider.Settings.StayOnTop;
[ObservableProperty] private static bool copyBdmv = SettingsProvider.Settings.CopyBdmv;
[ObservableProperty] private static bool copyPs3Update = SettingsProvider.Settings.CopyPs3Update;

[ObservableProperty] private static string dimTextColor = "#00ff00"; //ThemeConsts.LightThemeDimGray;
[ObservableProperty] private static IPalette colorPalette = ThemeConsts.Debug;
Expand Down Expand Up @@ -142,6 +143,9 @@ partial void OnStayOnTopChanged(bool value)
partial void OnCopyBdmvChanged(bool value)
=> SettingsProvider.Settings = SettingsProvider.Settings with { CopyBdmv = value };

partial void OnCopyPs3UpdateChanged(bool value)
=> SettingsProvider.Settings = SettingsProvider.Settings with { CopyPs3Update = value };

private static Color ChangeColorLuminosity(Color color, double luminosityFactor)
{
var red = (double)color.R;
Expand Down
22 changes: 21 additions & 1 deletion UI.Avalonia/Views/Settings.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,27 @@

<!-- Processing -->
<TextBlock Classes="BodyStrongTextBlockStyle" Margin="0 32 0 0">Processing</TextBlock>
<!-- Skip video -->
<!-- Copy ps3 firmware update -->
<Border Classes="Card" Margin="0 8 0 0">
<Grid ColumnDefinitions="36,*,120">
<TextBlock Grid.Column="0" FontFamily="{Binding SymbolFontFamily}" FontSize="20"
VerticalAlignment="Center" HorizontalAlignment="Left"
Text="{Binding ItemSelectionSymbol}"/>
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Classes="BodyTextBlockStyle">Copy PS3 firmware update</TextBlock>
<TextBlock Classes="CaptionTextBlockStyle SecondaryTextBlockStyle">
Only useful for preservation purposes
</TextBlock>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" Margin="0 0 -12 0"
VerticalAlignment="Center" HorizontalAlignment="Right">
<TextBlock VerticalAlignment="Center" Margin="0 0 12 0"
Text="{Binding CopyPs3Update, Converter={StaticResource OnOffConverter}}"/>
<ToggleSwitch OnContent="" OffContent="" IsChecked="{Binding CopyPs3Update}"/>
</StackPanel>
</Grid>
</Border>
<!-- Copy video -->
<Border Classes="Card" Margin="0 8 0 0">
<Grid ColumnDefinitions="36,*,120">
<TextBlock Grid.Column="0" FontFamily="{Binding SymbolFontFamily}" FontSize="20"
Expand Down

0 comments on commit 40d2112

Please sign in to comment.