Create an account

HSExtSave v1.0.1  

Upload: 17 Nov 2023, 16:19
Uploaded by: Aqxaro

Even though this one is a plugin as well, I chose to put it in the "Modding resources" section for obvious reasons.

On its own it does nothing, but it offers a way to save/load data directly into a scene/character/coordinate png file. I am aware HSStudioNEOExtSave does the same thing for scene, but this one is not compatible with scene importing. Also, there is no need to worry, both are compatible and won't run into each other.

How to use? (For modders only)

In Visual Studio reference this dll as you would do with any other dll. Also, since it's a plugin, it needs to be in your Plugins folder to work, obviously.
Then, you'll want to register the callbacks you need with the method "RegisterHandler", like this:

//HSExtSave plugin

public delegate void ExtSaveCharReadHandler(CharFile charFile, XmlNode node);
public delegate void ExtSaveCharWriteHandler(CharFile charFile, XmlTextWriter writer);
public delegate void ExtSaveSceneReadHandler(string path, XmlNode node);
public delegate void ExtSaveSceneWriteHandler(string path, XmlTextWriter writer);
public delegate void ExtSaveClothesReadHandler(CharFileInfoClothes clothesInfo, XmlNode node);
public delegate void ExtSaveClothesWriteHandler(CharFileInfoClothes clothesInfo, XmlTextWriter writer);

/// <summary>
/// Used to register a handler.
/// </summary>
/// <param name="name">Name of the handler: it must be unique and without special characters.</param>
/// <param name="onCharRead">Callback that will be called when the plugin reads a character card.</param>
/// <param name="onCharWrite">Callback that will be called when the plugin saves a character card.</param>
/// <param name="onSceneLoad">Callback that will be called when the plugin reads a scene card.</param>
/// <param name="onSceneImport">Callback that will be called when the plugin reads a scene card (import).</param>
/// <param name="onSceneWrite">Callback that will be called when the plugin saves a scene card.</param>
/// <returns>true if the operation was successful, otherwise false</returns>
public static bool RegisterHandler(string name, ExtSaveCharReadHandler onCharRead, ExtSaveCharWriteHandler onCharWrite, ExtSaveSceneReadHandler onSceneLoad, ExtSaveSceneReadHandler onSceneImport, ExtSaveSceneWriteHandler onSceneWrite, ExtSaveClothesReadHandler onClothesRead, ExtSaveClothesWriteHandler onClothesWrite)

//Your plugin

public void OnApplicationStart()
{
    HSExtSave.HSExtSave.RegisterHandler("theNameOfYourModForExample", null, null, this.OnSceneLoad, this.OnSceneImport, this.OnSceneSave, null, null);
}

private void OnSceneLoad(string path, XmlNode node)
{
    //Stuff
}

private void OnSceneImport(string path, XmlNode node)
{
    //Stuff
}

private void OnSceneSave(string path, XmlTextWriter writer)
{
    //Even more stuff
}

As you can see, I'm not registering everything since in this case I don't care about loading or saving chars and coordinates.
A note about loading callbacks (onCharRead, onSceneLoad, onSceneImport and onClothesRead): if the target doesn't contain any additional data, these methods will be called with a NULL XmlNode.

One last thing: if you're using ILMerge to integrate one or several dlls in your plugin, make sure not to merge this one!

Comments
The minimum comment length is 10 characters.