forked from Perfare/AssetStudio
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updated projects and dependencies
- Loading branch information
Showing
33 changed files
with
2,074 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFrameworks>net472;net6.0;net7.0</TargetFrameworks> | ||
<AssemblyTitle>AssetStudio Mod by VaDiM</AssemblyTitle> | ||
<Version>0.16.48.1</Version> | ||
<Copyright>Copyright © Perfare; Copyright © aelurum 2023</Copyright> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>embedded</DebugType> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\AssetStudioUtility\AssetStudioUtility.csproj" /> | ||
<ProjectReference Include="..\AssetStudio\AssetStudio.csproj" /> | ||
</ItemGroup> | ||
|
||
<!-- Use local compiled win-x86 and win-x64 Texture2DDecoder libs, because libs from Kyaru.Texture2DDecoder.Windows were compiled with /MD flag --> | ||
|
||
<Target Name="CopyExtraFilesPortable" AfterTargets="AfterBuild" Condition=" '$(RuntimeIdentifier)' == '' "> | ||
<Message Text="Copying extra files for $(TargetFramework)... " Importance="high" /> | ||
<Copy SourceFiles="$(SolutionDir)Texture2DDecoderNative\bin\Win32\$(Configuration)\Texture2DDecoderNative.dll" DestinationFolder="$(TargetDir)runtimes\win-x86\native" ContinueOnError="false" /> | ||
<Copy SourceFiles="$(SolutionDir)Texture2DDecoderNative\bin\x64\$(Configuration)\Texture2DDecoderNative.dll" DestinationFolder="$(TargetDir)runtimes\win-x64\native" ContinueOnError="false" /> | ||
<Copy SourceFiles="$(ProjectDir)Libraries\win-x86\fmod.dll" DestinationFolder="$(TargetDir)runtimes\win-x86\native" ContinueOnError="false" /> | ||
<Copy SourceFiles="$(ProjectDir)Libraries\win-x64\fmod.dll" DestinationFolder="$(TargetDir)runtimes\win-x64\native" ContinueOnError="false" /> | ||
</Target> | ||
|
||
<Target Name="CopyExtraFilesPortableNet" AfterTargets="AfterBuild" Condition=" '$(RuntimeIdentifier)' == '' AND '$(TargetFramework)' != 'net472' "> | ||
<Message Text="Copying extra files for .NET ($(TargetFramework))... " Importance="high" /> | ||
<Copy SourceFiles="$(ProjectDir)Libraries\linux-x86\libfmod.so" DestinationFolder="$(TargetDir)runtimes\linux-x86\native" ContinueOnError="false" /> | ||
<Copy SourceFiles="$(ProjectDir)Libraries\linux-x64\libfmod.so" DestinationFolder="$(TargetDir)runtimes\linux-x64\native" ContinueOnError="false" /> | ||
<Copy SourceFiles="$(ProjectDir)Libraries\osx-x64\libfmod.dylib" DestinationFolder="$(TargetDir)runtimes\osx-x64\native" ContinueOnError="false" /> | ||
<Copy SourceFiles="$(ProjectDir)Libraries\osx-arm64\libfmod.dylib" DestinationFolder="$(TargetDir)runtimes\osx-arm64\native" ContinueOnError="false" /> | ||
</Target> | ||
|
||
<Target Name="PublishExtraFilesPortable" AfterTargets="Publish" Condition=" '$(RuntimeIdentifier)' == '' "> | ||
<Message Text="Publishing extra files for Portable build ($(TargetFramework))... " Importance="high" /> | ||
<Copy SourceFiles="$(TargetDir)runtimes\win-x86\native\Texture2DDecoderNative.dll" DestinationFolder="$(PublishDir)runtimes\win-x86\native" ContinueOnError="false" /> | ||
<Copy SourceFiles="$(TargetDir)runtimes\win-x64\native\Texture2DDecoderNative.dll" DestinationFolder="$(PublishDir)runtimes\win-x64\native" ContinueOnError="false" /> | ||
<Copy SourceFiles="$(TargetDir)runtimes\win-x86\native\fmod.dll" DestinationFolder="$(PublishDir)runtimes\win-x86\native" ContinueOnError="false" /> | ||
<Copy SourceFiles="$(TargetDir)runtimes\win-x64\native\fmod.dll" DestinationFolder="$(PublishDir)runtimes\win-x64\native" ContinueOnError="false" /> | ||
</Target> | ||
|
||
<Target Name="PublishExtraFilesPortableNet" AfterTargets="Publish" Condition=" '$(RuntimeIdentifier)' == '' AND '$(TargetFramework)' != 'net472' "> | ||
<Message Text="Publishing extra files for Portable .NET build ($(TargetFramework))... " Importance="high" /> | ||
<Copy SourceFiles="$(TargetDir)runtimes\linux-x86\native\libfmod.so" DestinationFolder="$(PublishDir)runtimes\linux-x86\native" ContinueOnError="false" /> | ||
<Copy SourceFiles="$(TargetDir)runtimes\linux-x64\native\libfmod.so" DestinationFolder="$(PublishDir)runtimes\linux-x64\native" ContinueOnError="false" /> | ||
<Copy SourceFiles="$(TargetDir)runtimes\osx-x64\native\libfmod.dylib" DestinationFolder="$(PublishDir)runtimes\osx-x64\native" ContinueOnError="false" /> | ||
<Copy SourceFiles="$(TargetDir)runtimes\osx-arm64\native\libfmod.dylib" DestinationFolder="$(PublishDir)runtimes\osx-arm64\native" ContinueOnError="false" /> | ||
</Target> | ||
|
||
<Target Name="CopyExtraFilesWin86" AfterTargets="AfterBuild" Condition=" '$(RuntimeIdentifier)' == 'win-x86' "> | ||
<Message Text="Copying extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" /> | ||
<Copy SourceFiles="$(SolutionDir)Texture2DDecoderNative\bin\Win32\$(Configuration)\Texture2DDecoderNative.dll" DestinationFolder="$(TargetDir)" ContinueOnError="false" /> | ||
<Copy SourceFiles="$$(ProjectDir)Libraries\win-x86\fmod.dll" DestinationFolder="$(TargetDir)" ContinueOnError="false" /> | ||
</Target> | ||
|
||
<Target Name="CopyExtraFilesWin64" AfterTargets="AfterBuild" Condition=" '$(RuntimeIdentifier)' == 'win-x64' "> | ||
<Message Text="Copying extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" /> | ||
<Copy SourceFiles="$(SolutionDir)Texture2DDecoderNative\bin\x64\$(Configuration)\Texture2DDecoderNative.dll" DestinationFolder="$(TargetDir)" ContinueOnError="false" /> | ||
<Copy SourceFiles="$(ProjectDir)Libraries\win-x64\fmod.dll" DestinationFolder="$(TargetDir)" ContinueOnError="false" /> | ||
</Target> | ||
|
||
<Target Name="PublishExtraFilesWin" AfterTargets="Publish" Condition=" $(RuntimeIdentifier.Contains('win-x')) "> | ||
<Message Text="Publishing extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" /> | ||
<Copy SourceFiles="$(TargetDir)\Texture2DDecoderNative.dll" DestinationFolder="$(PublishDir)" ContinueOnError="false" /> | ||
<Copy SourceFiles="$(TargetDir)\fmod.dll" DestinationFolder="$(PublishDir)" ContinueOnError="false" /> | ||
</Target> | ||
|
||
<Target Name="CopyExtraFilesLinux64" AfterTargets="AfterBuild" Condition=" '$(RuntimeIdentifier)' == 'linux-x64' "> | ||
<Message Text="Copying extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" /> | ||
<Copy SourceFiles="$(ProjectDir)Libraries\linux-x64\libfmod.so" DestinationFolder="$(TargetDir)" ContinueOnError="false" /> | ||
</Target> | ||
|
||
<Target Name="PublishExtraFilesLinux64" AfterTargets="Publish" Condition=" '$(RuntimeIdentifier)' == 'linux-x64' "> | ||
<Message Text="Publishing extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" /> | ||
<Copy SourceFiles="$(TargetDir)\libfmod.so" DestinationFolder="$(PublishDir)" ContinueOnError="false" /> | ||
</Target> | ||
|
||
<Target Name="CopyExtraFilesMac64" AfterTargets="AfterBuild" Condition=" '$(RuntimeIdentifier)' == 'osx-x64' "> | ||
<Message Text="Copying extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" /> | ||
<Copy SourceFiles="$(ProjectDir)Libraries\osx-x64\libfmod.dylib" DestinationFolder="$(TargetDir)" ContinueOnError="false" /> | ||
</Target> | ||
|
||
<Target Name="CopyExtraFilesMacArm64" AfterTargets="AfterBuild" Condition=" '$(RuntimeIdentifier)' == 'osx-arm64' "> | ||
<Message Text="Copying extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" /> | ||
<Copy SourceFiles="$(ProjectDir)Libraries\osx-arm64\libfmod.dylib" DestinationFolder="$(TargetDir)" ContinueOnError="false" /> | ||
</Target> | ||
|
||
<Target Name="PublishExtraFilesMac" AfterTargets="Publish" Condition=" $(RuntimeIdentifier.Contains('osx-')) "> | ||
<Message Text="Publishing extra files for $(RuntimeIdentifier)($(TargetFramework))... " Importance="high" /> | ||
<Copy SourceFiles="$(TargetDir)\libfmod.dylib" DestinationFolder="$(PublishDir)" ContinueOnError="false" /> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
using AssetStudio; | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
using AssetStudioCLI.Options; | ||
|
||
namespace AssetStudioCLI | ||
{ | ||
internal enum LogOutputMode | ||
{ | ||
Console, | ||
File, | ||
Both, | ||
} | ||
|
||
internal class CLILogger : ILogger | ||
{ | ||
private readonly LogOutputMode logOutput; | ||
private readonly LoggerEvent logMinLevel; | ||
public string LogName; | ||
public string LogPath; | ||
|
||
public CLILogger(CLIOptions options) | ||
{ | ||
logOutput = options.o_logOutput.Value; | ||
logMinLevel = options.o_logLevel.Value; | ||
LogName = $"AssetStudioCLI_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.log"; | ||
LogPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, LogName); | ||
|
||
var ver = typeof(Program).Assembly.GetName().Version; | ||
LogToFile(LoggerEvent.Verbose, $"---AssetStudioCLI v{ver} | Logger launched---\n" + | ||
$"CMD Args: {string.Join(" ", options.cliArgs)}"); | ||
} | ||
|
||
private static string ColorLogLevel(LoggerEvent logLevel) | ||
{ | ||
string formattedLevel = $"[{logLevel}]"; | ||
switch (logLevel) | ||
{ | ||
case LoggerEvent.Info: | ||
return $"{formattedLevel.Color(CLIAnsiColors.BrightCyan)}"; | ||
case LoggerEvent.Warning: | ||
return $"{formattedLevel.Color(CLIAnsiColors.BrightYellow)}"; | ||
case LoggerEvent.Error: | ||
return $"{formattedLevel.Color(CLIAnsiColors.BrightRed)}"; | ||
default: | ||
return formattedLevel; | ||
} | ||
} | ||
|
||
private static string FormatMessage(LoggerEvent logMsgLevel, string message, bool consoleMode = false) | ||
{ | ||
var curTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); | ||
message = message.TrimEnd(); | ||
var multiLine = message.Contains('\n'); | ||
|
||
string formattedMessage; | ||
if (consoleMode) | ||
{ | ||
string colorLogLevel = ColorLogLevel(logMsgLevel); | ||
formattedMessage = $"{colorLogLevel} {message}"; | ||
if (multiLine) | ||
{ | ||
formattedMessage = formattedMessage.Replace("\n", $"\n{colorLogLevel} "); | ||
} | ||
} | ||
else | ||
{ | ||
message = Regex.Replace(message, @"\e\[[0-9;]*m(?:\e\[K)?", ""); //Delete ANSI colors | ||
var logLevel = $"{logMsgLevel.ToString().ToUpper(),-7}"; | ||
formattedMessage = $"{curTime} | {logLevel} | {message}"; | ||
if (multiLine) | ||
{ | ||
formattedMessage = formattedMessage.Replace("\n", $"\n{curTime} | {logLevel} | "); | ||
} | ||
} | ||
return formattedMessage; | ||
} | ||
|
||
public void LogToConsole(LoggerEvent logMsgLevel, string message) | ||
{ | ||
if (logOutput != LogOutputMode.File) | ||
{ | ||
Console.WriteLine(FormatMessage(logMsgLevel, message, consoleMode: true)); | ||
} | ||
} | ||
|
||
public async void LogToFile(LoggerEvent logMsgLevel, string message) | ||
{ | ||
if (logOutput != LogOutputMode.Console) | ||
{ | ||
using (var sw = new StreamWriter(LogPath, append: true, System.Text.Encoding.UTF8)) | ||
{ | ||
await sw.WriteLineAsync(FormatMessage(logMsgLevel, message)); | ||
} | ||
} | ||
} | ||
|
||
public void Log(LoggerEvent logMsgLevel, string message) | ||
{ | ||
if (logMsgLevel < logMinLevel || string.IsNullOrEmpty(message)) | ||
{ | ||
return; | ||
} | ||
|
||
if (logOutput != LogOutputMode.File) | ||
{ | ||
LogToConsole(logMsgLevel, message); | ||
} | ||
if (logOutput != LogOutputMode.Console) | ||
{ | ||
LogToFile(logMsgLevel, message); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.