mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
IncludeSteamWorkshopItems fixes
This commit is contained in:
parent
79c962bccd
commit
fbe2f05f60
@ -23,7 +23,7 @@ namespace Wabbajack.Common.StoreHandlers
|
||||
{
|
||||
public readonly SteamGame Game;
|
||||
public int ItemID;
|
||||
public int Size;
|
||||
public long Size;
|
||||
|
||||
public SteamWorkshopItem(SteamGame game)
|
||||
{
|
||||
@ -210,7 +210,7 @@ namespace Wabbajack.Common.StoreHandlers
|
||||
.Where(f => f.IsFile)
|
||||
.Do(f =>
|
||||
{
|
||||
if (f.FileName.ToString() != $"appworkshop{game.ID}.acf")
|
||||
if (f.FileName.ToString() != $"appworkshop_{game.ID}.acf")
|
||||
return;
|
||||
|
||||
Utils.Log($"Found Steam Workshop item file {f} for \"{game.Name}\"");
|
||||
@ -284,7 +284,7 @@ namespace Wabbajack.Common.StoreHandlers
|
||||
return;
|
||||
|
||||
if (currentLine == bracketStart + 1)
|
||||
if (!int.TryParse(GetVdfValue(l), out currentItem.Size))
|
||||
if (!long.TryParse(GetVdfValue(l), out currentItem.Size))
|
||||
return;
|
||||
|
||||
if (bracketStart == 0 || bracketEnd == 0 || currentItem.ItemID == 0 || currentItem.Size == 0)
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
@ -10,31 +11,55 @@ namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
public class IncludeSteamWorkshopItems : ACompilationStep
|
||||
{
|
||||
private readonly SteamGame _game;
|
||||
private readonly Regex _regex = new Regex("steamWorkshopItem_\\d*\\.meta$");
|
||||
private readonly bool _isGenericGame;
|
||||
private readonly SteamGame? _game;
|
||||
|
||||
public IncludeSteamWorkshopItems(ACompiler compiler, SteamGame steamGame) : base(compiler)
|
||||
public IncludeSteamWorkshopItems(ACompiler compiler) : base(compiler)
|
||||
{
|
||||
_game = steamGame;
|
||||
var mo2Compiler = (MO2Compiler)compiler;
|
||||
_isGenericGame = mo2Compiler.CompilingGame.IsGenericMO2Plugin;
|
||||
_game = (SteamGame)StoreHandler.Instance.SteamHandler.Games.FirstOrDefault(x =>
|
||||
mo2Compiler.CompilingGame.SteamIDs!.Contains(x.ID));
|
||||
}
|
||||
|
||||
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
||||
{
|
||||
if (!_isGenericGame)
|
||||
return null;
|
||||
|
||||
if (_game == null)
|
||||
return null;
|
||||
|
||||
if (!_regex.IsMatch((string)source.Path))
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
var lines = await source.AbsolutePath.ReadAllLinesAsync();
|
||||
var id = 0;
|
||||
lines.Where(l => l.StartsWith("itemID=")).Do(l => int.TryParse(l.Replace("itemID=", ""), out id));
|
||||
var sID = lines.FirstOrDefault(l => l.StartsWith("itemID="))?.Replace("itemID=", "");
|
||||
if (string.IsNullOrEmpty(sID))
|
||||
{
|
||||
Utils.Error($"Found no itemID= in file {source.AbsolutePath}!");
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!int.TryParse(sID, out var id))
|
||||
{
|
||||
Utils.Error($"Unable to parse int {sID} in {source.AbsolutePath}");
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get-ChildItem -Name -Directory | ForEach-Object -Process {Out-File -FilePath .\steamWorkshopItem_$_.meta -InputObject "itemID=$($_)" -Encoding utf8}
|
||||
if (id == 0)
|
||||
return null;
|
||||
|
||||
SteamWorkshopItem? item = null;
|
||||
_game.WorkshopItems.Where(i => i.ItemID == id).Do(i => item = i);
|
||||
SteamWorkshopItem? item = _game.WorkshopItems.FirstOrDefault(x => x.ItemID == id);
|
||||
if (item == null)
|
||||
{
|
||||
Utils.Error($"Unable to find workshop item with ID {id} in loaded workshop item list!");
|
||||
return null;
|
||||
}
|
||||
|
||||
var fromSteam = source.EvolveTo<SteamMeta>();
|
||||
fromSteam.SourceDataID = await _compiler.IncludeFile(source.AbsolutePath);
|
||||
|
@ -591,6 +591,7 @@ namespace Wabbajack.Lib
|
||||
{
|
||||
new IgnoreGameFilesIfGameFolderFilesExist(this),
|
||||
new IncludePropertyFiles(this),
|
||||
//new IncludeSteamWorkshopItems(this),
|
||||
new IgnoreSaveFiles(this),
|
||||
new IgnoreStartsWith(this,"logs\\"),
|
||||
new IgnoreStartsWith(this, "downloads\\"),
|
||||
|
Loading…
Reference in New Issue
Block a user