Skip to content

Commit

Permalink
added tips for addons editor
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfds committed Jun 20, 2024
1 parent 88caf7a commit a55853c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Avalonia/Core/Pages/DevPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@
Create ZIP
</Button>

<TextBlock VerticalAlignment="Center" Margin="5" Foreground="Red" Text="{Binding ErrorText}"/>
<TextBlock TextWrapping="Wrap" MaxWidth="400" VerticalAlignment="Center" Margin="5" Foreground="Red" Text="{Binding ErrorText}"/>

</StackPanel>
</StackPanel>
Expand Down
55 changes: 46 additions & 9 deletions src/Avalonia/Core/ViewModels/DevViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@ public sealed partial class DevViewModel : ObservableObject
private readonly FilesUploader _filesUploader;
private readonly GamesProvider _gamesProvider;

private readonly List<string> _forbiddenNames =
[
"duke3d.def",
"rr.def",
"rrra.def",
"nam.def",
"napalm.def",
"ww2gi.def",
"blood.def",
"sw.def",
"exhumed.def",
"game.con",
"defs.con",
"user.con",
"nam.con",
"napalm.con",
"ww2gi.con",
"blood.ini",
"cryptic.ini"
];

public DevViewModel(
IConfigProvider config,
FilesUploader filesUploader,
Expand Down Expand Up @@ -319,15 +340,6 @@ private async Task SelectAddonFolder()
{
return;
}

PathToAddonFolder = folders[0].Path.LocalPath;

//var addonJson = Path.Combine(PathToAddonFolder, "addon.json");

//if (File.Exists(addonJson))
//{
// LoadJson(addonJson);
//}
}

[RelayCommand]
Expand Down Expand Up @@ -614,6 +626,31 @@ private void CreateZip()

private AddonDto CreateJson()
{
var files = Directory.GetFiles(PathToAddonFolder!, "*", SearchOption.AllDirectories).Select(static x => Path.GetFileName(x).ToLower());
var forbidden = files.Intersect(_forbiddenNames);

if (forbidden.Any())
{
ThrowHelper.Exception($"Common files names can't be used. Rename these files: {string.Join(", ", forbidden)}");
}

if (IsBloodSelected)
{
if (files.Any(static x => x.EndsWith(".ART", StringComparison.InvariantCultureIgnoreCase)))
{
ThrowHelper.Exception($"Don't use ART files. Convert them to DEF.");
}
if (files.Any(static x => x.EndsWith(".DAT", StringComparison.InvariantCultureIgnoreCase)))
{
ThrowHelper.Exception($"Don't use DAT files. Convert them to DEF.");
}
if (files.Any(static x => x.EndsWith(".RFS", StringComparison.InvariantCultureIgnoreCase)))
{
ThrowHelper.Exception($"Addons with RFS files are not supported");
}
}


ErrorText = null;

var addonType =
Expand Down

0 comments on commit a55853c

Please sign in to comment.