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
58 changes: 58 additions & 0 deletions PckTool.Abstractions/Batch/ActionExecutionResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
namespace PckTool.Abstractions.Batch;

/// <summary>
/// Represents the result of executing a project action.
/// </summary>
public sealed class ActionExecutionResult
{
private ActionExecutionResult(bool success, string message, IProjectAction action)
{
Success = success;
Message = message;
Action = action;
}

/// <summary>
/// Gets a value indicating whether the action executed successfully.
/// </summary>
public bool Success { get; }

/// <summary>
/// Gets a message describing the result of the action.
/// </summary>
public string Message { get; }

/// <summary>
/// Gets the action that was executed.
/// </summary>
public IProjectAction Action { get; }

/// <summary>
/// Gets or sets additional details about the execution result.
/// </summary>
public WemReplacementResult? WemResult { get; init; }

/// <summary>
/// Creates a successful execution result.
/// </summary>
/// <param name="action">The action that was executed.</param>
/// <param name="message">A message describing the successful execution.</param>
/// <param name="wemResult">Optional WEM replacement result details.</param>
public static ActionExecutionResult Succeeded(
IProjectAction action,
string message,
WemReplacementResult? wemResult = null)
{
return new ActionExecutionResult(true, message, action) { WemResult = wemResult };
}

/// <summary>
/// Creates a failed execution result.
/// </summary>
/// <param name="action">The action that failed.</param>
/// <param name="message">A message describing the failure.</param>
public static ActionExecutionResult Failed(IProjectAction action, string message)
{
return new ActionExecutionResult(false, message, action);
}
}
40 changes: 40 additions & 0 deletions PckTool.Abstractions/Batch/ActionValidationResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace PckTool.Abstractions.Batch;

/// <summary>
/// Represents the result of validating a project action.
/// </summary>
public sealed class ActionValidationResult
{
private ActionValidationResult(bool isValid, string? errorMessage = null)
{
IsValid = isValid;
ErrorMessage = errorMessage;
}

/// <summary>
/// Gets a value indicating whether the action is valid.
/// </summary>
public bool IsValid { get; }

/// <summary>
/// Gets the error message if the action is invalid.
/// </summary>
public string? ErrorMessage { get; }

/// <summary>
/// Creates a successful validation result.
/// </summary>
public static ActionValidationResult Success()
{
return new ActionValidationResult(true);
}

/// <summary>
/// Creates a failed validation result with an error message.
/// </summary>
/// <param name="errorMessage">The error message describing why validation failed.</param>
public static ActionValidationResult Failure(string errorMessage)
{
return new ActionValidationResult(false, errorMessage);
}
}
42 changes: 42 additions & 0 deletions PckTool.Abstractions/Batch/BatchExecutionResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace PckTool.Abstractions.Batch;

/// <summary>
/// Represents the result of executing a batch project.
/// </summary>
public sealed class BatchExecutionResult
{
/// <summary>
/// Gets or sets the project that was executed.
/// </summary>
public required IBatchProject Project { get; init; }

/// <summary>
/// Gets or sets the list of action execution results.
/// </summary>
public required IReadOnlyList<ActionExecutionResult> ActionResults { get; init; }

/// <summary>
/// Gets a value indicating whether all actions executed successfully.
/// </summary>
public bool AllSucceeded => ActionResults.All(r => r.Success);

/// <summary>
/// Gets the number of successful actions.
/// </summary>
public int SuccessCount => ActionResults.Count(r => r.Success);

/// <summary>
/// Gets the number of failed actions.
/// </summary>
public int FailureCount => ActionResults.Count(r => !r.Success);

/// <summary>
/// Gets the total number of actions executed.
/// </summary>
public int TotalActions => ActionResults.Count;

/// <summary>
/// Gets a summary of the execution result.
/// </summary>
public string Summary => $"Executed {TotalActions} actions: {SuccessCount} succeeded, {FailureCount} failed";
}
49 changes: 49 additions & 0 deletions PckTool.Abstractions/Batch/BatchProjectValidationResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace PckTool.Abstractions.Batch;

/// <summary>
/// Represents the result of validating a batch project.
/// </summary>
public sealed class BatchProjectValidationResult
{
private BatchProjectValidationResult(bool isValid, IReadOnlyList<string> errors)
{
IsValid = isValid;
Errors = errors;
}

/// <summary>
/// Gets a value indicating whether the project is valid.
/// </summary>
public bool IsValid { get; }

/// <summary>
/// Gets the list of validation errors.
/// </summary>
public IReadOnlyList<string> Errors { get; }

/// <summary>
/// Creates a successful validation result.
/// </summary>
public static BatchProjectValidationResult Success()
{
return new BatchProjectValidationResult(true, Array.Empty<string>());
}

/// <summary>
/// Creates a failed validation result with error messages.
/// </summary>
/// <param name="errors">The list of validation errors.</param>
public static BatchProjectValidationResult Failure(IEnumerable<string> errors)
{
return new BatchProjectValidationResult(false, errors.ToList().AsReadOnly());
}

/// <summary>
/// Creates a failed validation result with a single error message.
/// </summary>
/// <param name="error">The validation error.</param>
public static BatchProjectValidationResult Failure(string error)
{
return new BatchProjectValidationResult(false, new[] { error });
}
}
44 changes: 44 additions & 0 deletions PckTool.Abstractions/Batch/IBatchProject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
namespace PckTool.Abstractions.Batch;

/// <summary>
/// Represents a batch project that defines operations to perform on Wwise audio files.
/// </summary>
public interface IBatchProject
{
/// <summary>
/// Gets or sets the schema version for forward compatibility.
/// </summary>
int SchemaVersion { get; set; }

/// <summary>
/// Gets or sets the project name.
/// </summary>
string Name { get; set; }

/// <summary>
/// Gets or sets an optional description for the project.
/// </summary>
string? Description { get; set; }

/// <summary>
/// Gets or sets the list of input file paths (.pck or .bnk files).
/// </summary>
IList<string> InputFiles { get; set; }

/// <summary>
/// Gets or sets the output directory for modified files.
/// If null, files may be modified in place or use a default location.
/// </summary>
string? OutputDirectory { get; set; }

/// <summary>
/// Gets the list of actions to perform.
/// </summary>
IList<IProjectAction> Actions { get; }

/// <summary>
/// Validates the entire project configuration.
/// </summary>
/// <returns>A result indicating whether the project is valid.</returns>
BatchProjectValidationResult Validate();
}
23 changes: 23 additions & 0 deletions PckTool.Abstractions/Batch/IProjectAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace PckTool.Abstractions.Batch;

/// <summary>
/// Represents a single action to be performed in a batch project.
/// </summary>
public interface IProjectAction
{
/// <summary>
/// Gets the type of action to perform.
/// </summary>
ProjectActionType ActionType { get; }

/// <summary>
/// Gets or sets an optional description for this action.
/// </summary>
string? Description { get; set; }

/// <summary>
/// Validates that this action is properly configured.
/// </summary>
/// <returns>A result indicating whether the action is valid.</returns>
ActionValidationResult Validate();
}
22 changes: 22 additions & 0 deletions PckTool.Abstractions/Batch/ProjectActionType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace PckTool.Abstractions.Batch;

/// <summary>
/// Defines the type of action to perform in a batch project.
/// </summary>
public enum ProjectActionType
{
/// <summary>
/// Replace an existing WEM or BNK with new data.
/// </summary>
Replace,

/// <summary>
/// Add a new WEM or BNK (placeholder for future implementation).
/// </summary>
Add,

/// <summary>
/// Remove an existing WEM or BNK (placeholder for future implementation).
/// </summary>
Remove
}
17 changes: 17 additions & 0 deletions PckTool.Abstractions/Batch/TargetType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace PckTool.Abstractions.Batch;

/// <summary>
/// Defines the type of target for a batch action.
/// </summary>
public enum TargetType
{
/// <summary>
/// Target a WEM (audio) file.
/// </summary>
Wem,

/// <summary>
/// Target a BNK (soundbank) file.
/// </summary>
Bnk
}
66 changes: 66 additions & 0 deletions PckTool.Core/Games/GameMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
namespace PckTool.Core.Games;

/// <summary>
/// Base metadata for a supported game. Extend for game-specific behavior.
/// </summary>
public abstract class GameMetadata
{
/// <summary>
/// Gets the game this metadata is for.
/// </summary>
public SupportedGame Game { get; protected init; }

/// <summary>
/// Gets the default input files for this game (relative paths from game directory).
/// </summary>
/// <param name="gameDirectory">The game installation directory (used to verify files exist).</param>
/// <returns>List of input file paths (relative to game directory).</returns>
public abstract IEnumerable<string> GetDefaultInputFiles(string gameDirectory);

/// <summary>
/// Gets the metadata for a specific game.
/// </summary>
/// <param name="game">The game to get metadata for.</param>
/// <returns>The game metadata, or null if not supported.</returns>
public static GameMetadata? GetMetadata(SupportedGame game)
{
return game switch
{
SupportedGame.HaloWars => HaloWarsMetadata.Instance,
_ => null
};
}
}

/// <summary>
/// Metadata for Halo Wars: Definitive Edition.
/// </summary>
public class HaloWarsMetadata : GameMetadata
{
private HaloWarsMetadata()
{
Game = SupportedGame.HaloWars;
}

/// <summary>
/// Singleton instance.
/// </summary>
public static HaloWarsMetadata Instance { get; } = new();

/// <summary>
/// Relative path to the Sounds.pck file from the game directory.
/// </summary>
public static string SoundsPackageRelativePath =>
Path.Combine("sound", "wwise_2013", "GeneratedSoundBanks", "Windows", "Sounds.pck");

/// <inheritdoc />
public override IEnumerable<string> GetDefaultInputFiles(string gameDirectory)
{
var absolutePath = Path.Combine(gameDirectory, SoundsPackageRelativePath);

if (File.Exists(absolutePath))
{
yield return SoundsPackageRelativePath;
}
}
}
Loading