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
1 change: 1 addition & 0 deletions .github/agents/theasseteditor.agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ When tests are mixed-framework, preserve existing framework choice (NUnit and MS
- Avoid coupling business logic to UI framework types where possible; keep logic behind testable seams.
- Prefer existing abstractions and dependency injection instead of creating new layers purely for mocking.
- Avoid designs that require implementing fake classes to test core behavior.
- Test files should follow the same folder stucture as the file being tested.

## Safety Checklist Before Finalizing
- Change is limited to requested scope.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ public void Close()

public class PackFileListItem
{
public PackFileContainer Container { get; private set; }
public IPackFileContainer Container { get; private set; }

public PackFileListItem(PackFileContainer item)
public PackFileListItem(IPackFileContainer item)
{
Name.Value = item.Name;
Container = item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private void Step4_GenerateAnimation(AssetEditorTestRunner runner, AnimationReta
// Check player
}

private void Step5_UpdateAnimationSettingsAndGenerateAnimation(AssetEditorTestRunner runner, AnimationRetargetEditor editor, PackFileContainer outputPackFile)
private void Step5_UpdateAnimationSettingsAndGenerateAnimation(AssetEditorTestRunner runner, AnimationRetargetEditor editor, IPackFileContainer outputPackFile)
{
Assert.That(outputPackFile.FileList.Count, Is.EqualTo(0));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private void OnAudioProjectExplorerNodeSelected(AudioProjectExplorerNodeSelected

private void OnAudioFilesChanged(AudioFilesChangedEvent e) => SetButtonEnablement();

private void OnPackFileContainerSetAsMainEditable(PackFileContainer packFileContainer)
private void OnPackFileContainerSetAsMainEditable(IPackFileContainer packFileContainer)
{
if (packFileContainer == null)
return;
Expand All @@ -146,7 +146,7 @@ private void OnPackFileContainerSetAsMainEditable(PackFileContainer packFileCont
RefreshAudioFilesTree(packFileContainer);
}

private void RefreshAudioFilesTree(PackFileContainer packFileContainer)
private void RefreshAudioFilesTree(IPackFileContainer packFileContainer)
{
AudioFilesTree = _audioFilesTreeBuilder.BuildTree(packFileContainer);
CacheRootWaveformVisualisations();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ namespace Editors.Audio.AudioEditor.Presentation.AudioFilesExplorer
{
public interface IAudioFilesTreeBuilderService
{
ObservableCollection<AudioFilesTreeNode> BuildTree(PackFileContainer editablePack);
ObservableCollection<AudioFilesTreeNode> BuildTree(IPackFileContainer editablePack);
}

public class AudioFilesTreeBuilderService() : IAudioFilesTreeBuilderService
{
public ObservableCollection<AudioFilesTreeNode> BuildTree(PackFileContainer editablePack)
public ObservableCollection<AudioFilesTreeNode> BuildTree(IPackFileContainer editablePack)
{
var wavFilePaths = editablePack.FileList
.Where(x => x.Key.EndsWith(".wav", StringComparison.OrdinalIgnoreCase))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public DisplayImportFileToolCommand(IAbstractFormFactory<ImportWindow> exportWin
_importerViewModels = exporterViewModels;
}

public void Execute(PackFileContainer packFileContainer, string packPath)
public void Execute(IPackFileContainer packFileContainer, string packPath)
{
var fileExtentionFilters = GetFileDialogFilters();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public record GltfImporterSettings
(
string InputGltfFile,
string DestinationPackPath,
PackFileContainer DestinationPackFileContainer,
IPackFileContainer DestinationPackFileContainer,
GameTypeEnum SelectedGame,
bool ImportMeshes,
bool ImportMaterials,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public record AnimationBuilderSettings(
ModelRoot modelRoot,
string skeletonName,
float keysPerSecond,
PackFileContainer packFileContainer,
IPackFileContainer packFileContainer,
string packPath
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public RmvToGltfImporterViewModel(GltfImporter Importer)

public ImportSupportEnum CanImportFile(PackFile file) => _Importer.CanImportFile(file);

public void Execute(PackFile importSource, string outputPath, PackFileContainer packFileContainer, GameTypeEnum gameType)
public void Execute(PackFile importSource, string outputPath, IPackFileContainer packFileContainer, GameTypeEnum gameType)
{
var settings = new GltfImporterSettings(
InputGltfFile: importSource.Name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface IImporterViewModel
public string DisplayName { get; }
string OutputExtension { get; }
string[] InputExtensions { get; } // ADDed THIS!
public void Execute(PackFile exportSource, string outputPath, PackFileContainer packFileContainer, GameTypeEnum gameType);
public void Execute(PackFile exportSource, string outputPath, IPackFileContainer packFileContainer, GameTypeEnum gameType);
public ImportSupportEnum CanImportFile(PackFile file);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ImportWindow(ImporterCoreViewModel viewModel)
DataContext = _viewModel;
}

internal void Initialize(PackFileContainer packFileContainer, string packPath, string diskFile)
internal void Initialize(IPackFileContainer packFileContainer, string packPath, string diskFile)
{
_viewModel.Initialize(packFileContainer, packPath, diskFile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public partial class ImporterCoreViewModel : ObservableObject

private readonly IEnumerable<IImporterViewModel> _exporterViewModels;
PackFile? _inputFile;
PackFileContainer? _destPackFileContainer;
IPackFileContainer? _destPackFileContainer;
string _packPath = "";

[ObservableProperty] IImporterViewModel? _selectedImporterViewModel;
Expand All @@ -39,7 +39,7 @@ public ImporterCoreViewModel(IEnumerable<IImporterViewModel> exporterViewModels,
_applicationSettings = applicationSettings;
}

public void Initialize(PackFileContainer packFile, string packPath, string diskFile)
public void Initialize(IPackFileContainer packFile, string packPath, string diskFile)
{
_destPackFileContainer = packFile;
_packPath = packPath;
Expand Down
2 changes: 1 addition & 1 deletion Editors/Ipc/IpcEditor/ExternalPackLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Task<PackLoadResult> EnsureLoadedAsync(string packPathOnDisk, Cancellatio
}
}

private PackFileContainer AddContainerOnUiThread(PackFileContainer container)
private IPackFileContainer AddContainerOnUiThread(IPackFileContainer container)
{
var app = Application.Current;
if (app?.Dispatcher == null || app.Dispatcher.CheckAccess())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ public void Dispose()
_globalEventHub.UnRegister(this);
}

void PackfileContainerRefresh(PackFileContainer packFileContainer)
void PackfileContainerRefresh(IPackFileContainer packFileContainer)
{
UnloadAnimationFromContainer(packFileContainer);
LoadFromPackFileContainer(packFileContainer);
}

void PackfileContainerRemove(PackFileContainer packFileContainer)
void PackfileContainerRemove(IPackFileContainer packFileContainer)
{
UnloadAnimationFromContainer(packFileContainer);
}

void LoadFromPackFileContainer(PackFileContainer packFileContainer)
void LoadFromPackFileContainer(IPackFileContainer packFileContainer)
{
List<string> skeletonFileNameList = [];
Dictionary<string, List<AnimationReference>> animationList = [];
Expand Down Expand Up @@ -127,7 +127,7 @@ void LoadFromPackFileContainer(PackFileContainer packFileContainer)
}
}

void FileDiscovered(byte[] byteChunk, PackFileContainer container, string fullPath, ref List<string> skeletonFileNameList, ref Dictionary<string, List<AnimationReference>> animationList)
void FileDiscovered(byte[] byteChunk, IPackFileContainer container, string fullPath, ref List<string> skeletonFileNameList, ref Dictionary<string, List<AnimationReference>> animationList)
{
var brokenFiles = new string[]
{
Expand Down Expand Up @@ -172,7 +172,7 @@ void FileDiscovered(byte[] byteChunk, PackFileContainer container, string fullPa
}
}

void UnloadAnimationFromContainer(PackFileContainer packFileContainer)
void UnloadAnimationFromContainer(IPackFileContainer packFileContainer)
{
lock (_threadLock)
{
Expand Down Expand Up @@ -266,13 +266,13 @@ public ObservableCollection<AnimationReference> GetAnimationsForSkeleton(string
// Delete this piece of shit
public class AnimationReference
{
public AnimationReference(string animationFile, PackFileContainer container)
public AnimationReference(string animationFile, IPackFileContainer container)
{
AnimationFile = animationFile;
Container = container;
}
public string AnimationFile { get; set; }
public PackFileContainer Container { get; set; }
public IPackFileContainer Container { get; set; }

public override string ToString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace GameWorld.Core.Test.Rendering.Materials.Serialization
{
internal class MaterialToWsMaterialSerializerTests
{
PackFileContainer _outputPack;
IPackFileContainer _outputPack;
IPackFileService _pfs;

MaterialToWsMaterialSerializer _wsMaterialSerializer;
Expand Down
3 changes: 3 additions & 0 deletions Shared/SharedCore/Shared.Core/Assembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[assembly: InternalsVisibleTo("Test.GameWorld.Core")]
[assembly: InternalsVisibleTo("GameWorld.CoreTest")]
[assembly: InternalsVisibleTo("Shared.CoreTest")]
[assembly: InternalsVisibleTo("Shared.UiTest")]
[assembly: InternalsVisibleTo("Test.ImportExport")]
[assembly: InternalsVisibleTo("Test.AnimatioReTarget")]
4 changes: 2 additions & 2 deletions Shared/SharedCore/Shared.Core/ErrorHandling/PackFileLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class PackFileLog
private static readonly ILogger s_logger = Logging.CreateStatic(typeof(PackFileLog));
public static bool IsLoggingEnabled { get; set; } = true;

public static Dictionary<CompressionFormat, CompressionInformation> GetCompressionInformation(PackFileContainer container)
internal static Dictionary<CompressionFormat, CompressionInformation> GetCompressionInformation(PackFileContainer container)
{
var compressionInformation = new Dictionary<CompressionFormat, CompressionInformation>();
if(IsLoggingEnabled == false)
Expand All @@ -46,7 +46,7 @@ public static Dictionary<CompressionFormat, CompressionInformation> GetCompressi
return compressionInformation;
}

public static void LogPackCompression(PackFileContainer container)
internal static void LogPackCompression(PackFileContainer container)
{
if (IsLoggingEnabled == false)
return;
Expand Down
24 changes: 12 additions & 12 deletions Shared/SharedCore/Shared.Core/Events/Global/PackFileSavedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
namespace Shared.Core.Events.Global
{
public record PackFileSavedEvent(PackFile File);
public record PackFileContainerSavedEvent(PackFileContainer Container);
public record PackFileLookUpEvent(string FileName, PackFileContainer? Container, bool Found);
public record PackFileContainerSavedEvent(IPackFileContainer Container);
public record PackFileLookUpEvent(string FileName, IPackFileContainer? Container, bool Found);

public abstract record PackFileContainerManipulationEvent();
public record PackFileContainerAddedEvent(PackFileContainer Container) : PackFileContainerManipulationEvent;
public record PackFileContainerRemovedEvent(PackFileContainer Container) : PackFileContainerManipulationEvent;
public record PackFileContainerSetAsMainEditableEvent(PackFileContainer? Container);
public record PackFileContainerFilesUpdatedEvent(PackFileContainer Container, List<PackFile> ChangedFiles) : PackFileContainerManipulationEvent;
public record PackFileContainerFilesAddedEvent(PackFileContainer Container, List<PackFile> AddedFiles) : PackFileContainerManipulationEvent;
public record PackFileContainerFilesRemovedEvent(PackFileContainer Container, List<PackFile> RemovedFiles) : PackFileContainerManipulationEvent;
public record PackFileContainerFolderRemovedEvent(PackFileContainer Container, string Folder) : PackFileContainerManipulationEvent;
public record PackFileContainerFolderRenamedEvent(PackFileContainer Container, string NewNodePath) : PackFileContainerManipulationEvent;
public record PackFileContainerAddedEvent(IPackFileContainer Container) : PackFileContainerManipulationEvent;
public record PackFileContainerRemovedEvent(IPackFileContainer Container) : PackFileContainerManipulationEvent;
public record PackFileContainerSetAsMainEditableEvent(IPackFileContainer? Container);
public record PackFileContainerFilesUpdatedEvent(IPackFileContainer Container, List<PackFile> ChangedFiles) : PackFileContainerManipulationEvent;
public record PackFileContainerFilesAddedEvent(IPackFileContainer Container, List<PackFile> AddedFiles) : PackFileContainerManipulationEvent;
public record PackFileContainerFilesRemovedEvent(IPackFileContainer Container, List<PackFile> RemovedFiles) : PackFileContainerManipulationEvent;
public record PackFileContainerFolderRemovedEvent(IPackFileContainer Container, string Folder) : PackFileContainerManipulationEvent;
public record PackFileContainerFolderRenamedEvent(IPackFileContainer Container, string NewNodePath) : PackFileContainerManipulationEvent;

public class BeforePackFileContainerRemovedEvent(PackFileContainer removed)
public class BeforePackFileContainerRemovedEvent(IPackFileContainer removed)
{
public PackFileContainer Removed { get; internal set; } = removed;
public IPackFileContainer Removed { get; internal set; } = removed;
public bool AllowClose { get; set; } = true;
}
}
34 changes: 17 additions & 17 deletions Shared/SharedCore/Shared.Core/PackFiles/IPackFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ public interface IPackFileService
bool EnableFileLookUpEvents { get; set; }
bool EnforceGameFilesMustBeLoaded { get; set; }

PackFileContainer? AddContainer(PackFileContainer container, bool setToMainPackIfFirst = false);
void AddFilesToPack(PackFileContainer container, List<NewPackFileEntry> newFiles);
void CopyFileFromOtherPackFile(PackFileContainer source, string path, PackFileContainer target);
PackFileContainer CreateNewPackFileContainer(string name, PackFileVersion packFileVersion, PackFileCAType type, bool setEditablePack = false);
void DeleteFile(PackFileContainer pf, PackFile file);
void DeleteFolder(PackFileContainer pf, string folder);
PackFile? FindFile(string path, PackFileContainer? container = null);
List<PackFileContainer> GetAllPackfileContainers();
PackFileContainer? GetEditablePack();
string GetFullPath(PackFile file, PackFileContainer? container = null);
PackFileContainer? GetPackFileContainer(PackFile file);
void MoveFile(PackFileContainer pf, PackFile file, string newFolderPath);
void RenameDirectory(PackFileContainer pf, string currentNodeName, string newName);
void RenameFile(PackFileContainer pf, PackFile file, string newName);
IPackFileContainer? AddContainer(IPackFileContainer container, bool setToMainPackIfFirst = false);
void AddFilesToPack(IPackFileContainer container, List<NewPackFileEntry> newFiles);
void CopyFileFromOtherPackFile(IPackFileContainer source, string path, IPackFileContainer target);
IPackFileContainer CreateNewPackFileContainer(string name, PackFileVersion packFileVersion, PackFileCAType type, bool setEditablePack = false);
void DeleteFile(IPackFileContainer pf, PackFile file);
void DeleteFolder(IPackFileContainer pf, string folder);
PackFile? FindFile(string path, IPackFileContainer? container = null);
List<IPackFileContainer> GetAllPackfileContainers();
IPackFileContainer? GetEditablePack();
string GetFullPath(PackFile file, IPackFileContainer? container = null);
IPackFileContainer? GetPackFileContainer(PackFile file);
void MoveFile(IPackFileContainer pf, PackFile file, string newFolderPath);
void RenameDirectory(IPackFileContainer pf, string currentNodeName, string newName);
void RenameFile(IPackFileContainer pf, PackFile file, string newName);
void SaveFile(PackFile file, byte[] data);
void SavePackContainer(PackFileContainer pf, string path, bool createBackup, GameInformation gameInformation);
void SetEditablePack(PackFileContainer? pf);
void UnloadPackContainer(PackFileContainer pf);
void SavePackContainer(IPackFileContainer pf, string path, bool createBackup, GameInformation gameInformation);
void SetEditablePack(IPackFileContainer? pf);
void UnloadPackContainer(IPackFileContainer pf);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Shared.Core.Settings;

namespace Shared.Core.PackFiles.Models
{
internal class CachedPackFileContainer : IPackFileContainerInternal
{
public string Name { get; set; }
public bool IsCaPackFile { get => true; set { } }
public string SystemFilePath { get; set; }
public Dictionary<string, PackFile> FileList { get; set; } = [];
public HashSet<string> SourcePackFilePaths { get; set; } = [];

public CachedPackFileContainer(string name)
{
Name = name;
}

public PackFile? FindFile(string path)
{
var lowerPath = path.Replace('/', '\\').ToLower().Trim();
return FileList.TryGetValue(lowerPath, out var value) ? value : null;
}

public string? GetFullPath(PackFile file)
{
var res = FileList.FirstOrDefault(x => ReferenceEquals(x.Value, file)
|| string.Equals(x.Value.Name, file.Name, StringComparison.OrdinalIgnoreCase)).Key;
return string.IsNullOrWhiteSpace(res) ? null : res;
}

public List<PackFile> AddFiles(List<NewPackFileEntry> newFiles) =>
throw new InvalidOperationException("Cannot modify a cached CA pack file container.");

public PackFile? DeleteFile(PackFile file) =>
throw new InvalidOperationException("Cannot modify a cached CA pack file container.");

public void DeleteFolder(string folder) =>
throw new InvalidOperationException("Cannot modify a cached CA pack file container.");

public void MoveFile(PackFile file, string newFolderPath) =>
throw new InvalidOperationException("Cannot modify a cached CA pack file container.");

public string RenameDirectory(string currentNodeName, string newName) =>
throw new InvalidOperationException("Cannot modify a cached CA pack file container.");

public void RenameFile(PackFile file, string newName) =>
throw new InvalidOperationException("Cannot modify a cached CA pack file container.");

public void SaveFileData(PackFile file, byte[] data) =>
throw new InvalidOperationException("Cannot modify a cached CA pack file container.");

public void SaveToDisk(string path, bool createBackup, GameInformation gameInformation) =>
throw new InvalidOperationException("Cannot modify a cached CA pack file container.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Shared.Core.PackFiles.Models
{
public interface IPackFileContainer
{
string Name { get; }
bool IsCaPackFile { get; set; }
string SystemFilePath { get; }
Dictionary<string, PackFile> FileList { get; }
HashSet<string> SourcePackFilePaths { get; }
}
}
Loading
Loading