More work completed on Symphony remastered and close to finishing loading XACT music packs. Finished new mod CustomAssetModifier that essentially can modify ObjectInformation.xnb information without modifying .xnb files.

This commit is contained in:
2018-02-02 18:15:00 -08:00
parent 100f43f486
commit b8965d77e4
14 changed files with 423 additions and 10 deletions

View File

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 14 for Windows Desktop
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomAssetModifier", "CustomAssetModifier\CustomAssetModifier.csproj", "{679F7D40-2728-47BB-A86F-D044816752E2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{679F7D40-2728-47BB-A86F-D044816752E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{679F7D40-2728-47BB-A86F-D044816752E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{679F7D40-2728-47BB-A86F-D044816752E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{679F7D40-2728-47BB-A86F-D044816752E2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewModdingAPI;
using System.IO;
using CustomAssetModifier.Framework.Editors;
using CustomAssetModifier.Framework;
namespace CustomAssetModifier
{
public class CustomAssetModifier : Mod
{
/// <summary>
/// Static reference to this mod's helper.
/// </summary>
public static IModHelper ModHelper;
/// <summary>
/// Static reference to this mod's monitor.
/// </summary>
public static IMonitor ModMonitor;
/// <summary>
/// Path for Mod/Content.
/// </summary>
public static string contentPath;
/// <summary>
/// Path for Mod/Content/Data
/// </summary>
public static string dataPath;
/// <summary>
/// Path for Mod/Content/Data/ObjectInformation
/// </summary>
public static string objectInformationPath;
/// <summary>
/// Path for Mod/Content/Templates/ObjectInformation
/// </summary>
public static string TemplatePath;
/// <summary>
/// Entry function for the mod.
/// </summary>
/// <param name="helper"></param>
public override void Entry(IModHelper helper)
{
ModHelper = helper;
ModMonitor = Monitor;
//Just setting up a bunch of paths for the mod.
contentPath = Path.Combine(ModHelper.DirectoryPath, "Content");
dataPath = Path.Combine(contentPath, "Data");
objectInformationPath = Path.Combine(dataPath, "ObjectInformation");
TemplatePath = Path.Combine(contentPath, "Templates");
createDirectories();
createBlankObjectTemplate();
//Add the ObjectInformationEditor asset editor to the list of asset editors that SMAPI uses.
ModHelper.Content.AssetEditors.Add(new ObjectInformationEditor());
}
/// <summary>
/// Creates the necessary directories for the mod.
/// </summary>
public void createDirectories()
{
//Create the Mod/Content directory.
if (!Directory.Exists(contentPath)){
Directory.CreateDirectory(contentPath);
}
//Create the Mod/Content/Data directory.
if (!Directory.Exists(dataPath))
{
Directory.CreateDirectory(dataPath);
}
//Create the Mod/Content/Data/ObjectInformation directory.
if (!Directory.Exists(objectInformationPath))
{
Directory.CreateDirectory(objectInformationPath);
}
//Create the Mod/Content/Template/ObjectInformation directory.
if (!Directory.Exists(TemplatePath))
{
Directory.CreateDirectory(TemplatePath);
}
}
/// <summary>
/// Creates the blank object example for dinosaur eggs.
/// </summary>
public void createBlankObjectTemplate()
{
var ok = new AssetInformation("107","Dinosaur Egg / 720 / -300 / Arch / A giant dino egg...The entire shell is still intact!/ Mine .01 Mountain .008 / Item 1 107");
ok.writeJson(Path.Combine(TemplatePath,"ObjectInformation",ok.id.ToString()+".json"));
}
}
}

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{679F7D40-2728-47BB-A86F-D044816752E2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CustomAssetModifier</RootNamespace>
<AssemblyName>CustomAssetModifier</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CustomAssetModifier.cs" />
<Compile Include="Framework\AssetInformation.cs" />
<Compile Include="Framework\Editors\ObjectInformationEditor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomAssetModifier.Framework
{
/// <summary>
/// Used to easily store Dictionary key pair values of (string,string) that are commonly used in .xnb files.
/// </summary>
public class AssetInformation
{
public string id; //
public string informationString;
/// <summary>
/// Blank constructor.
/// </summary>
public AssetInformation()
{
}
/// <summary>
/// Normal constructor.
/// </summary>
/// <param name="ID">The id key used in the asset file. Aslo will be the file's name.</param>
/// <param name="DataString">The data string that is to be set after the edit.</param>
public AssetInformation(string ID, string DataString)
{
this.id = ID;
this.informationString = DataString;
}
/// <summary>
/// Write the information to a .json file.
/// </summary>
/// <param name="path"></param>
public void writeJson(string path)
{
CustomAssetModifier.ModHelper.WriteJsonFile(path, this);
}
/// <summary>
/// Read the information from a .json file and return an instance of AssetInformation.
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static AssetInformation readJson(string path)
{
return CustomAssetModifier.ModHelper.ReadJsonFile<AssetInformation>(path);
}
}
}

View File

@ -0,0 +1,39 @@
using StardewModdingAPI;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomAssetModifier.Framework.Editors
{
/// <summary>
/// Asset editor for assets stored in ObjectInformation.xnb
/// </summary>
public class ObjectInformationEditor : IAssetEditor
{
/// <summary>Get whether this instance can edit the given asset.</summary>
/// <param name="asset">Basic metadata about the asset being loaded.</param>
public bool CanEdit<T>(IAssetInfo asset)
{
return asset.AssetNameEquals(@"Data\ObjectInformation");
}
/// <summary>Edit a matched asset.</summary>
/// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it.</param>
public void Edit<T>(IAssetData asset)
{
string[] files = Directory.GetFiles(CustomAssetModifier.objectInformationPath);
foreach (var file in files)
{
var ok = AssetInformation.readJson(file);
asset
.AsDictionary<int, string>()
.Set(Convert.ToInt32(ok.id), ok.informationString);
}
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CustomAssetModifier")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CustomAssetModifier")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("679f7d40-2728-47bb-a86f-d044816752e2")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,15 @@
{
"Name": "Custom Asset Editor",
"Author": "Alpha_Omegasis",
"Version": {
"MajorVersion": 1,
"MinorVersion": 0,
"PatchVersion": 0,
"Build": null
},
"MinimumApiVersion": "2.3",
"Description": "Allows players to edit basic vanilla assets using text files.",
"UniqueID": "Omegasis.CustomAssetModifier",
"EntryDll": "CustomAssetModifier.dll",
"UpdateKeys": [ "" ]
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Pathoschild.Stardew.ModBuildConfig" version="2.0.2" targetFramework="net45" />
</packages>

View File

@ -4,7 +4,7 @@
"Version": { "Version": {
"MajorVersion": 1, "MajorVersion": 1,
"MinorVersion": 4, "MinorVersion": 4,
"PatchVersion": 2, "PatchVersion": 3,
"Build": null "Build": null
}, },
"MinimumApiVersion": "1.15", "MinimumApiVersion": "1.15",

View File

@ -13,7 +13,7 @@ namespace StardewSymphonyRemastered.Framework
** Properties ** Properties
*********/ *********/
/// <summary>All of the music/soundbanks and their locations.</summary> /// <summary>All of the music/soundbanks and their locations.</summary>
private readonly XwbMusicPack MasterList; private readonly XACTMusicPack MasterList;
/// <summary>The registered soundbanks.</summary> /// <summary>The registered soundbanks.</summary>
private readonly List<string> SoundBanks = new List<string>(); private readonly List<string> SoundBanks = new List<string>();
@ -28,7 +28,7 @@ namespace StardewSymphonyRemastered.Framework
/// <summary>Construct an instance.</summary> /// <summary>Construct an instance.</summary>
/// <param name="masterList">All of the music/soundbanks and their locations.</param> /// <param name="masterList">All of the music/soundbanks and their locations.</param>
/// <param name="reset">The callback to reset the game audio.</param> /// <param name="reset">The callback to reset the game audio.</param>
public MusicHexProcessor(XwbMusicPack masterList, Action reset) public MusicHexProcessor(XACTMusicPack masterList, Action reset)
{ {
this.MasterList = masterList; this.MasterList = masterList;
this.Reset = reset; this.Reset = reset;
@ -41,7 +41,7 @@ namespace StardewSymphonyRemastered.Framework
this.SoundBanks.Add(path); this.SoundBanks.Add(path);
} }
public static List<string> ProcessSongNamesFromHex(XwbMusicPack musicPack, Action reset, string FileName) public static List<string> ProcessSongNamesFromHex(XACTMusicPack musicPack, Action reset, string FileName)
{ {
int counter = 0; int counter = 0;
List<string> cleanCueNames = new List<string>(); List<string> cleanCueNames = new List<string>();

View File

@ -223,7 +223,7 @@ namespace StardewSymphonyRemastered.Framework
/// Adds a valid xwb music pack to the list of music packs available. /// Adds a valid xwb music pack to the list of music packs available.
/// </summary> /// </summary>
/// <param name="xwbMusicPack"></param> /// <param name="xwbMusicPack"></param>
public void addMusicPack(XwbMusicPack xwbMusicPack) public void addMusicPack(XACTMusicPack xwbMusicPack)
{ {
this.musicPacks.Add(xwbMusicPack.musicPackInformation.name,xwbMusicPack); this.musicPacks.Add(xwbMusicPack.musicPackInformation.name,xwbMusicPack);
} }

View File

@ -12,7 +12,7 @@ namespace StardewSymphonyRemastered.Framework
/// <summary> /// <summary>
/// TODO: Make this work and add in overrided functions. /// TODO: Make this work and add in overrided functions.
/// </summary> /// </summary>
public class XwbMusicPack: MusicPack public class XACTMusicPack: MusicPack
{ {
public Microsoft.Xna.Framework.Audio.WaveBank WaveBank; public Microsoft.Xna.Framework.Audio.WaveBank WaveBank;
public Microsoft.Xna.Framework.Audio.SoundBank SoundBank; public Microsoft.Xna.Framework.Audio.SoundBank SoundBank;
@ -32,7 +32,7 @@ namespace StardewSymphonyRemastered.Framework
/// <param name="name"></param> /// <param name="name"></param>
/// <param name="directoryToXwb"></param> /// <param name="directoryToXwb"></param>
/// <param name="pathToXWB"></param> /// <param name="pathToXWB"></param>
public XwbMusicPack(string name, string directoryToXwb,string pathToXWB) public XACTMusicPack(string directoryToXwb,string pathToXWB)
{ {
this.directory = directoryToXwb; this.directory = directoryToXwb;
this.XWBPath = pathToXWB; this.XWBPath = pathToXWB;
@ -41,8 +41,8 @@ namespace StardewSymphonyRemastered.Framework
this.musicPackInformation = MusicPackMetaData.readFromJson(Path.Combine(directoryToXwb, "MusicPackInformation.json")); this.musicPackInformation = MusicPackMetaData.readFromJson(Path.Combine(directoryToXwb, "MusicPackInformation.json"));
if (this.musicPackInformation == null) if (this.musicPackInformation == null)
{ {
StardewSymphony.ModMonitor.Log("Error: MusicPackInformation.json not found at: " + directoryToXwb + ". Blank information will be put in place."); StardewSymphony.ModMonitor.Log("Error: MusicPackInformation.json not found at: " + directoryToXwb + ". Blank information will be put in place.",StardewModdingAPI.LogLevel.Warn);
this.musicPackInformation = new MusicPackMetaData(name,"???","","0.0.0"); this.musicPackInformation = new MusicPackMetaData("???","???","","0.0.0");
} }
} }

View File

@ -8,6 +8,7 @@ using Microsoft.Xna.Framework.Audio;
using StardewModdingAPI; using StardewModdingAPI;
using StardewValley; using StardewValley;
using StardewSymphonyRemastered.Framework; using StardewSymphonyRemastered.Framework;
using System.IO;
namespace StardewSymphonyRemastered namespace StardewSymphonyRemastered
{ {
@ -36,6 +37,11 @@ namespace StardewSymphonyRemastered
public static MusicManager musicManager; public static MusicManager musicManager;
private string MusicPath;
public static string WavMusicDirectory;
public static string XACTMusicDirectory;
public static string TemplateMusicDirectory;
public override void Entry(IModHelper helper) public override void Entry(IModHelper helper)
{ {
@ -48,9 +54,73 @@ namespace StardewSymphonyRemastered
StardewModdingAPI.Events.LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged; StardewModdingAPI.Events.LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged;
musicManager = new MusicManager(); musicManager = new MusicManager();
MusicPath = Path.Combine(ModHelper.DirectoryPath, "Content", "Music");
WavMusicDirectory = Path.Combine(MusicPath, "Wav");
XACTMusicDirectory = Path.Combine(MusicPath, "XACT");
TemplateMusicDirectory = Path.Combine(MusicPath, "Templates");
this.createDirectories();
this.createBlankXACTTemplate();
//load in all packs here. //load in all packs here.
} }
public void createDirectories()
{
if (!Directory.Exists(MusicPath)) Directory.CreateDirectory(MusicPath);
if (!Directory.Exists(WavMusicDirectory)) Directory.CreateDirectory(WavMusicDirectory);
if (!Directory.Exists(XACTMusicDirectory)) Directory.CreateDirectory(XACTMusicDirectory);
if (!Directory.Exists(TemplateMusicDirectory)) Directory.CreateDirectory(TemplateMusicDirectory);
}
public void createBlankXACTTemplate()
{
string path= Path.Combine(TemplateMusicDirectory, "XACT");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
if(!File.Exists(Path.Combine(path, "MusicPackInformation.json"))){
MusicPackMetaData blankMetaData = new MusicPackMetaData();
blankMetaData.writeToJson(Path.Combine(path, "MusicPackInformation.json"));
}
if (!File.Exists(Path.Combine(path, "readme.txt")))
{
string info = "Place the Wave Bank.xwb file and Sound Bank.xsb file you created in XACT in a similar directory in Content/Music/XACT/SoundPackName with a new meta data to load it!";
File.WriteAllText(Path.Combine(path, "readme.txt"),info);
}
}
public static void loadXACTMusicPacks()
{
string[] listOfDirectories= Directory.GetDirectories(XACTMusicDirectory);
foreach(string folder in listOfDirectories)
{
string waveBank = Path.Combine(folder, "Wave Bank.xwb");
string soundBank = Path.Combine(folder, "Sound Bank.xwb");
string metaData = Path.Combine(folder, "MusicPackInformation.json");
if (!File.Exists(waveBank))
{
ModMonitor.Log("Error loading in attempting to load music pack from: " + folder + ". There is no file Wave Bank.xwb located in this directory. AKA there is no valid music here.", LogLevel.Error);
return;
}
if (!File.Exists(soundBank))
{
ModMonitor.Log("Error loading in attempting to load music pack from: " + folder + ". There is no file Sound Bank.xwb located in this directory. This is needed to play the music from Wave Bank.xwb", LogLevel.Error);
return;
}
if (!File.Exists(metaData))
{
ModMonitor.Log("WARNING! Loading in a music pack from: " + folder + ". There is no MusicPackInformation.json associated with this music pack meaning that while songs can be played from this pack, no information about it will be displayed.", LogLevel.Error);
}
StardewSymphonyRemastered.Framework.XACTMusicPack musicPack = new XACTMusicPack(folder, waveBank);
musicManager.addMusicPack(musicPack);
}
}
/// <summary> /// <summary>
/// Raised when the player changes locations. This should determine the next song to play. /// Raised when the player changes locations. This should determine the next song to play.
/// </summary> /// </summary>

View File

@ -50,7 +50,7 @@
<Compile Include="Framework\MusicPack.cs" /> <Compile Include="Framework\MusicPack.cs" />
<Compile Include="Framework\SongSpecifics.cs" /> <Compile Include="Framework\SongSpecifics.cs" />
<Compile Include="Framework\WavMusicPack.cs" /> <Compile Include="Framework\WavMusicPack.cs" />
<Compile Include="Framework\XwbMusicPack.cs" /> <Compile Include="Framework\XACTMusicPack.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>