Skip to content

Commit

Permalink
Updated to latest available LSLib
Browse files Browse the repository at this point in the history
Fixed issue where a bad file could cause indexing to fail
Fixed orange color no longer working after Patch 3
Fixed bundling Pouch of Wonders not working with a custom Mod-folder
Standalone PAKs will now have the Mod-folder in the filename
Moved all files from GustavDev into the configured Mod-folder
  • Loading branch information
LennardF1989 committed Sep 24, 2023
1 parent d4f934e commit 2bedf1c
Show file tree
Hide file tree
Showing 21 changed files with 87 additions and 50 deletions.
Binary file removed Lib/NuGet/LSLib.1.0.0.nupkg
Binary file not shown.
Binary file removed Lib/NuGet/LSLib.1.0.0.symbols.nupkg
Binary file not shown.
Binary file added Lib/NuGet/LSLib.1.18.6-nightly-1.nupkg
Binary file not shown.
Binary file added Lib/NuGet/LSLib.1.18.6-nightly-1.symbols.nupkg
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Open the JSON-file in an editor (for example Visual Studio code, but even Notepa
- When `Custom` is set to `true`, the path `Content\Custom` is used instead and a 64x64 PNG-file is expected to be found.
- When `Generate` is set to `true`, the icon set under `Name` will shrunk to two-thirds of its size and be combined with the icon of a normal pouch.

`TooltipIcon` works exactly the same as `ItemIcon`. However, it is recommended use a 380x380 PNG-file when `Custom` is set to `true` and `Generate` is set to `false`. This will give the best results in-game.
`TooltipIcon` works exactly the same as `ItemIcon`. However, it is recommended to use a 380x380 PNG-file when `Custom` is set to `true` and `Generate` is set to `false`. This will give the best results in-game.

`Color` determines how the item is presented in-game. The following values are available:
- None
Expand Down
10 changes: 5 additions & 5 deletions Src/BG3.BagsOfSorting/BG3.BagsOfSorting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<UseWindowsForms>true</UseWindowsForms>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Title>BG3 - Bags of Sorting</Title>
<Version>1.4.0</Version>
<Version>1.4.1</Version>
<Authors>Lennard Fonteijn</Authors>
<Copyright>Copyright © 2023 Lennard Fonteijn</Copyright>
<ApplicationIcon>Icon.ico</ApplicationIcon>
Expand All @@ -29,19 +29,19 @@
<None Remove="Resources\zoom.png" />
<None Remove="Resources\text_list_bullets.png" />
<None Remove="Resources\bag.png" />
<None Include="..\..\Lib\Textconv\texconv.dll" Link="texconv.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Resource Include="Resources\folder_explore.png" />
<Resource Include="Resources\images.png" />
<Resource Include="Resources\package_go.png" />
<Resource Include="Resources\zoom.png" />
<Resource Include="Resources\text_list_bullets.png" />
<Resource Include="Resources\bag.png" />
<None Include="..\..\Lib\Textconv\texconv.dll" Link="texconv.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="LSLib" Version="1.0.0" />
<PackageReference Include="LSLib" Version="1.18.6-nightly-1" />
<PackageReference Include="Pfim" Version="0.11.2" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Src/BG3.BagsOfSorting/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace BG3.BagsOfSorting
public static class Constants
{
public const string DEFAULT_TREASURETABLE_FOLDERNAME = "PouchOfWonders";
public const string DEFAULT_TREASURETABLE_FOLDERNAME_STANDALONE = "BagsOfSorting";
public const string DEFAULT_TREASURETABLE_NAME = "POW_TT";

public const string BASE_ICON = "Item_LOOT_Bag_Blackpowder";
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<attribute id="Localized" type="bool" value="False" />
<attribute id="Name" type="LSString" value="POW_Container" />
<attribute id="SRGB" type="bool" value="True" />
<attribute id="SourceFile" type="LSString" value="Public/GustavDev/Assets/Textures/Icons/POW_Container.dds" />
<attribute id="SourceFile" type="LSString" value="Public/PouchOfWonders/Assets/Textures/Icons/POW_Container.dds" />
<attribute id="Streaming" type="bool" value="True" />
<attribute id="Template" type="FixedString" value="POW_Container" />
<attribute id="Type" type="int64" value="0" />
Expand Down
86 changes: 49 additions & 37 deletions Src/BG3.BagsOfSorting/Services/PAKGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ private static partial int Texconv(
<attribute id=""TechnicalDescription"" type=""TranslatedString"" handle=""{4}"" version=""1"" />
<attribute id=""Icon"" type=""FixedString"" value=""{1}"" />
<attribute id=""Stats"" type=""FixedString"" value=""{1}"" />
<attribute id=""StoryItem"" type=""bool"" value=""{5}"" />
<attribute id=""StoryItem"" type=""bool"" value=""{5}"" />
<attribute id=""ContainerAutoAddOnPickup"" type=""bool"" value=""{6}"" />
<attribute id=""ContainerContentFilterCondition"" type=""LSString"" value=""{7}"" />
<children>
<node id=""InventoryList"" />
</children>
</node>
</children>
</node>
Expand Down Expand Up @@ -121,7 +124,7 @@ private static partial int Texconv(
<attribute id=""Localized"" type=""bool"" value=""False"" />
<attribute id=""Name"" type=""LSString"" value=""{0}"" />
<attribute id=""SRGB"" type=""bool"" value=""True"" />
<attribute id=""SourceFile"" type=""LSString"" value=""Public/GustavDev/Assets/Textures/Icons/{0}.dds"" />
<attribute id=""SourceFile"" type=""LSString"" value=""Public/{2}/Assets/Textures/Icons/{0}.dds"" />
<attribute id=""Streaming"" type=""bool"" value=""True"" />
<attribute id=""Template"" type=""FixedString"" value=""{0}"" />
<attribute id=""Type"" type=""int64"" value=""0"" />
Expand Down Expand Up @@ -187,13 +190,8 @@ CanMerge 1

private static readonly string BAGS_OUTPUT_PATH = Path.Combine(Constants.OUTPUT_PATH, "Bags");
private static readonly string BAGS_OUTPUT_PATH_REMOVED = Path.Combine(Constants.OUTPUT_PATH, "Bags_Removed");
private static readonly string ICON_PATH = Path.Combine(BAGS_OUTPUT_PATH, "Public", "GustavDev", "Assets", "Textures", "Icons");
private static readonly string TOOLTIP_ICON_PATH = Path.Combine(BAGS_OUTPUT_PATH, "Public", "Game", "GUI", "Assets", "Tooltips", "ItemIcons");
private static readonly string CONTROLLER_ICON_PATH = Path.Combine(BAGS_OUTPUT_PATH, "Public", "Game", "GUI", "Assets", "ControllerUIIcons", "items_png");
private static readonly string ROOTTEMPLATES_PATH = Path.Combine(BAGS_OUTPUT_PATH, "Public", "GustavDev", "RootTemplates");
private static readonly string DATA_PATH = Path.Combine(BAGS_OUTPUT_PATH, "Public", "GustavDev", "Stats", "Generated", "Data");
private static readonly string ATLAS_PATH = Path.Combine(BAGS_OUTPUT_PATH, "Public", "GustavDev", "GUI");
private static readonly string TEXTUREBANK_PATH = Path.Combine(BAGS_OUTPUT_PATH, "Public", "GustavDev", "Content", "UI", "[PAK]_UI");
private static readonly string LOCALIZATION_PATH = Path.Combine(BAGS_OUTPUT_PATH, "Localization", "English");

private static readonly ResizeOptions _itemIconResizeOptions = new()
Expand Down Expand Up @@ -221,7 +219,7 @@ public static void Generate(Context context)
BundlePouchOfWonders(context);
GenerateBags(context);
GenerateTreasureTable(context);
CreatePackage(BAGS_OUTPUT_PATH, Constants.OUTPUT_PATH);
CreatePackage(context, BAGS_OUTPUT_PATH, Constants.OUTPUT_PATH);
}

private static void GenerateTreasureTable(Context context)
Expand All @@ -246,13 +244,11 @@ private static void GenerateTreasureTable(Context context)
treasureTablePath
);

//If the TreasureTable-folder is different from the default value, we need to generate a meta.lsx to load it
if (context.Configuration.TreasureTable != null &&
context.Configuration.TreasureTable.FolderName != Constants.DEFAULT_TREASURETABLE_FOLDERNAME
)
//NOTE: If the TreasureTable-folder is different from the default value, we need to generate a meta.lsx to load it.
if (context.Configuration.TreasureTable.FolderName != Constants.DEFAULT_TREASURETABLE_FOLDERNAME)
{
GenerateModsMeta(
context.Configuration.TreasureTable.FolderName,
context.Configuration.TreasureTable.FolderName,
$"Bags of Sorting - {context.Configuration.TreasureTable.FolderName}"
);
}
Expand All @@ -265,6 +261,9 @@ private static void BundlePouchOfWonders(Context context)
return;
}

//NOTE: Override the Mod-folder
context.Configuration.TreasureTable.FolderName = Constants.DEFAULT_TREASURETABLE_FOLDERNAME;

var sourceDirectory = new DirectoryInfo(Constants.CONTENT_POW_PATH);
var targetDirectory = new DirectoryInfo(BAGS_OUTPUT_PATH);

Expand All @@ -278,13 +277,20 @@ private static void GenerateBags(Context context)
return;
}

Directory.CreateDirectory(ICON_PATH);
var modFolder = context.Configuration.TreasureTable.FolderName;
var iconPath = Path.Combine(BAGS_OUTPUT_PATH, "Public", modFolder, "Assets", "Textures", "Icons");
var rootTemplatesPath = Path.Combine(BAGS_OUTPUT_PATH, "Public", modFolder, "RootTemplates");
var dataPath = Path.Combine(BAGS_OUTPUT_PATH, "Public", modFolder, "Stats", "Generated", "Data");
var atlasPath = Path.Combine(BAGS_OUTPUT_PATH, "Public", modFolder, "GUI");
var textureBankPath = Path.Combine(BAGS_OUTPUT_PATH, "Public", modFolder, "Content", "UI", "[PAK]_UI");

Directory.CreateDirectory(iconPath);
Directory.CreateDirectory(TOOLTIP_ICON_PATH);
Directory.CreateDirectory(CONTROLLER_ICON_PATH);
Directory.CreateDirectory(ROOTTEMPLATES_PATH);
Directory.CreateDirectory(DATA_PATH);
Directory.CreateDirectory(ATLAS_PATH);
Directory.CreateDirectory(TEXTUREBANK_PATH);
Directory.CreateDirectory(rootTemplatesPath);
Directory.CreateDirectory(dataPath);
Directory.CreateDirectory(atlasPath);
Directory.CreateDirectory(textureBankPath);
Directory.CreateDirectory(LOCALIZATION_PATH);

//Include a backup of the Bags.json in the PAK
Expand All @@ -307,7 +313,15 @@ private static void GenerateBags(Context context)
{
try
{
GenerateBag(context, bag);
bag.Name = CLIMethods.GetNameForBag(bag);

GenerateLocalization(bag, LOCALIZATION_PATH);
GenerateItemIcon(context, bag, iconPath);
GenerateTooltipIcon(context, bag, TOOLTIP_ICON_PATH, CONTROLLER_ICON_PATH);
GenerateRootTemplate(bag, rootTemplatesPath);
GenerateData(bag, dataPath);
GenerateAtlas(bag, atlasPath);
GenerateTextureBank(bag, textureBankPath, modFolder);
}
catch (Exception ex)
{
Expand All @@ -316,19 +330,6 @@ private static void GenerateBags(Context context)
}
}

private static void GenerateBag(Context context, Configuration.Bag bag)
{
bag.Name = CLIMethods.GetNameForBag(bag);

GenerateLocalization(bag, LOCALIZATION_PATH);
GenerateItemIcon(context, bag, ICON_PATH);
GenerateTooltipIcon(context, bag, TOOLTIP_ICON_PATH, CONTROLLER_ICON_PATH);
GenerateRootTemplate(bag, ROOTTEMPLATES_PATH);
GenerateData(bag, DATA_PATH);
GenerateAtlas(bag, ATLAS_PATH);
GenerateTextureBank(bag, TEXTUREBANK_PATH);
}

private static void GenerateLocalization(Configuration.Bag bag, string outputPath)
{
var guid1 = GenerateLocalizationGuid();
Expand Down Expand Up @@ -605,12 +606,13 @@ private static void GenerateAtlas(Configuration.Bag bag, string outputPath)
ConvertLSXToLSF(contents, lsxPath, lsfPath);
}

private static void GenerateTextureBank(Configuration.Bag bag, string outputPath)
private static void GenerateTextureBank(Configuration.Bag bag, string outputPath, string modFolder)
{
var contents = string.Format(
TEXTUREBANK_FORMAT,
bag.Name,
bag.MapKey
bag.MapKey,
modFolder
);

var lsxPath = Path.Combine(outputPath, $"{bag.Name}.lsx");
Expand Down Expand Up @@ -677,16 +679,25 @@ private static void GenerateModsMeta(string folderName, string modName)
ConvertLSXToLSF(contents, lsxPath, lsfPath);
}

private static void CreatePackage(string inputPath, string outputPath)
private static void CreatePackage(Context context, string inputPath, string outputPath)
{
var packager = new Packager();

var containsModsMeta = context.Configuration.BundlePouchOfWonders ||
context.Configuration.TreasureTable.FolderName != Constants.DEFAULT_TREASURETABLE_FOLDERNAME;

var pakName = containsModsMeta
? $"BagsOfSorting_{context.Configuration.TreasureTable.FolderName}.pak"
: "BagsOfSorting.pak";

packager.CreatePackage(
Path.GetFullPath(Path.Combine(outputPath, "BagsOfSorting.pak")),
Path.GetFullPath(Path.Combine(outputPath, pakName)),
Path.GetFullPath(inputPath),
new PackageCreationOptions
{
Priority = byte.MaxValue,
Priority = containsModsMeta
? (byte)0
: byte.MaxValue,
Version = PackageVersion.V18,
Compression = CompressionMethod.LZ4
}
Expand All @@ -701,6 +712,7 @@ private static string ConvertColorToRarity(Configuration.EColor color)
Configuration.EColor.Blue => "Rare",
Configuration.EColor.Pink => "VeryRare",
Configuration.EColor.Gold => "Legendary",
Configuration.EColor.Orange => "",
_ => "Common"
};
}
Expand Down
22 changes: 19 additions & 3 deletions Src/BG3.BagsOfSorting/Services/SearchIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,16 @@ private static void IndexTags(SearchIndex searchIndex, Package package)

foreach (var abstractFileInfo in tagFiles)
{
var resource = abstractFileInfo.ReadResource();
Resource resource;

try
{
resource = abstractFileInfo.ReadResource();
}
catch
{
continue;
}

var result = resource?.Regions
?.Get("Tags");
Expand Down Expand Up @@ -273,9 +282,16 @@ private static void IndexGameObjects(SearchIndex searchIndex, Package package)

foreach (var abstractFileInfo in rootTemplateFiles)
{
using var stream = abstractFileInfo.MakeStream();
Resource resource;

var resource = abstractFileInfo.ReadResource();
try
{
resource = abstractFileInfo.ReadResource();
}
catch
{
continue;
}

var gameObjects = resource?.Regions
?.Get("Templates")?.Children
Expand Down
2 changes: 1 addition & 1 deletion Src/BG3.BagsOfSorting/Views/Tabs/BagsTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<TextBlock>
When enabled, the Pouch of Wonders will be included in the generated PAK.<LineBreak/>
<LineBreak/>
It is recommended not to enabled this if you plan on redistributing your custom bags to not force players into using Pouch of Wonders.
It is recommended not to enable this if you plan on redistributing your custom bags to not force players into using Pouch of Wonders.
</TextBlock>
</CheckBox.ToolTip>
</CheckBox>
Expand Down
12 changes: 10 additions & 2 deletions Src/BG3.BagsOfSorting/Views/Tabs/TreasureTableTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@
<Button Content="Add Treasure" Padding="5" Margin="0,0,5,0" Click="AddAdditionalTreasure" />
<Button Content="Remove Treasure" Padding="5" Click="RemoveAdditionalTreasure" />
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" ToolTip="If you are not using Pouch of Wonders, these settings can be used to generate a standalone mod.">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<StackPanel.ToolTip>
<TextBlock>
If you are not using Pouch of Wonders, these settings can be used to generate a standalone mod, instead of acting as an override.
<LineBreak />
If you decide to bundle Pouch of Wonders, changing the "Mod Folder" will have no effect and the PAK will show up as "Pouch Of Wonders" in your Mod Manager.
</TextBlock>
</StackPanel.ToolTip>
<Label Content="(?)" />
<Label Content="Mod Folder" />
<ComboBox Text="{Binding TreasureTableFolderName, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Width="128" VerticalContentAlignment="Center" IsEditable="True">
<ComboBoxItem Content="{x:Static bagsOfSorting:Constants.DEFAULT_TREASURETABLE_FOLDERNAME}" ToolTip="Pouch of Wonders"/>
<ComboBoxItem Content="{x:Static bagsOfSorting:Constants.DEFAULT_TREASURETABLE_FOLDERNAME}" ToolTip="Pouch of Wonders (Override, unless bundled)"/>
<ComboBoxItem Content="{x:Static bagsOfSorting:Constants.DEFAULT_TREASURETABLE_FOLDERNAME_STANDALONE}" ToolTip="Bags of Sorting (Standalone)"/>
</ComboBox>
<Label Content="Treasure Table" />
<ComboBox Text="{Binding TreasureTableName, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Width="128" VerticalContentAlignment="Center" IsEditable="True">
Expand Down

0 comments on commit 2bedf1c

Please sign in to comment.