Skip to content
Merged
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 src/Filee.Core/Presets/BuiltInData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public static class BuiltInData
public static bool AcceptsFolders(Preset preset) => !preset.IsGroup
&& (preset.IsCopyToFolder || SupportsFolderTarget(preset.TargetFormat));

/// <summary>The preset that makes Valve textures (.vtf).</summary>
public const string VtfId = "to-vtf";

/// <summary>Creates the default preset list.</summary>
public static List<Preset> CreatePresets() =>
[
Expand All @@ -47,6 +50,9 @@ public static List<Preset> CreatePresets() =>
new() { Id = "to-gif", Name = "GIF", TargetFormat = "gif" },
new() { Id = "to-avif", Name = "AVIF", TargetFormat = "avif", Image = { Quality = 60 } },
new() { Id = "to-heic", Name = "HEIC", TargetFormat = "heic", Image = { Quality = 80 } },
// Valve textures for Garry's Mod and other Source games (#1478, added to the library in settings schema 98): in
// the palette only, in the Games field (off in a new install).
new() { Id = VtfId, Name = "VTF", TargetFormat = "vtf" },
new()
{
Id = "half-size", NameKey = "preset.half_size", TargetFormat = SameAsSource,
Expand Down
2 changes: 1 addition & 1 deletion src/Filee.Core/Settings/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public static bool IsFlipKeyAllowed(string key, IEnumerable<TriggerGesture> gest
public sealed class AppSettings
{
/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>
public const int CurrentSchemaVersion = 97;
public const int CurrentSchemaVersion = 98;

public int SchemaVersion { get; set; } = CurrentSchemaVersion;

Expand Down
3 changes: 3 additions & 0 deletions src/Filee.Core/Settings/UserDataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,9 @@ public static bool ApplyToLibrary(int from, List<Preset> presets, List<ToolbarPr
// game packs the user removed stay removed.
if (from < 97)
changed |= AddGma(presets);
// v98: "VTF" (any picture to a Valve texture) joins the palette after HEIC, not a donut.
if (from < 98 && presets.All(p => p.Id != BuiltInData.VtfId))
changed |= AddLikeNewLibrary(presets, BuiltInData.VtfId);
return changed;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Filee.Core.Tests/TranslatePresetMigrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void Translate_goes_after_the_built_in_preset_before_it()
var defaults = BuiltInData.CreatePresets();
List<Preset> Only(params string[] ids) => ids.Select(id => defaults.Single(p => p.Id == id)).ToList();
// Later steps add their own presets; what is checked here is where Translate lands.
static IEnumerable<string> Ids(List<Preset> presets) => presets.Select(p => p.Id).Where(id => id is not (BuiltInData.MetadataId or BuiltInData.UpscaleId or BuiltInData.RingtoneId or BuiltInData.PdfAId or "to-iso" or "to-gma"));
static IEnumerable<string> Ids(List<Preset> presets) => presets.Select(p => p.Id).Where(id => id is not (BuiltInData.MetadataId or BuiltInData.UpscaleId or BuiltInData.RingtoneId or BuiltInData.PdfAId or "to-iso" or "to-gma" or BuiltInData.VtfId));
List<ToolbarProfile> Profiles()
{
var profiles = BuiltInData.CreateProfiles();
Expand Down
16 changes: 16 additions & 0 deletions tests/Filee.Core.Tests/VtfFormatTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,20 @@ public void Version_94_libraries_learn_vtf_without_taking_custom_claims()
Assert.DoesNotContain("vtf", images.Extensions); // the user's own donut has it
Assert.Equal("my-textures", ProfileSelector.Select(profiles, ["spray.vtf"])?.Id);
}

[Fact]
public void Version_97_libraries_get_the_vtf_preset_after_heic()
{
var presets = BuiltInData.CreatePresets();
presets.RemoveAll(p => p.Id == BuiltInData.VtfId);
var profiles = BuiltInData.CreateProfiles();

Assert.True(SettingsMigrations.ApplyToLibrary(97, presets, profiles));
Assert.Equal(BuiltInData.CreatePresets().Select(p => p.Id), presets.Select(p => p.Id)); // right after HEIC
Assert.Equal("vtf", presets.Single(p => p.Id == BuiltInData.VtfId).TargetFormat);
Assert.False(SettingsMigrations.ApplyToLibrary(97, presets, profiles));
// In the palette only, not on a donut.
Assert.DoesNotContain(BuiltInData.CreateProfiles(),
p => p.PresetIds.Contains(BuiltInData.VtfId) || p.BackPresetIds?.Contains(BuiltInData.VtfId) == true);
}
}
Loading