1. Hey Guest! We've announced our new game Wargroove, check out the new forums!
    Dismiss Notice

RELEASED Serializer Replacing Utility (Standalone Mod)

Discussion in 'Mods' started by Advize, Apr 18, 2016.

  1. Advize

    Advize Subatomic Cosmonaut

    This is a SMAPI mod/utility that functions as a dependency for any mod that would like to include extra types for serialization. It allows all mods (that use it) to remain compatible if they need to replace the game's XML Serializer.

    Currently it is impossible to create a derived/child class of an object, location, or anything like that in a mod without the game being unable to save it. This utility allows other mods to add object types to be included into the game's serializer.

    For Mod Users:

    **BACKUP YOUR SAVE GAMES***
    If the serializer utility or a mod using it is uninstalled, Stardew Valley will be unable to load your save game. Please avoid save corruption/loss by backing up your saves before using such a mod.

    Download from the link below and install like any other SMAPI mod (either in %appdata%\StardewValley\Mods directory, or copy it to your Game\Mods directory (default C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Content\Mods).

    For Modders:

    List this mod as a dependency for your mod, and instruct your users to download it. Add it as a reference to your Visual Studio project in order to make use of it. See the code below for instructions on how to use it.

    Download:

    Download HERE
    Code:
    /* How to use in your mod*/
    
    /* Add the utility as a reference in your Visual Studio project, add the following using statement to your .cs file*/
    using SerializerUtils;
    
    /* During your mod initialization (entry method), subscribe to Include_Types command by adding this line*/
    public override void Entry(params object[] objects)
    {
        Command.RegisterCommand("include_types", "Includes types to serialize").CommandFired += Command_IncludeTypes;
    }
    
    /* Include a method in which you state types to be added when the serializer fires the command*/
    private static void Command_IncludeTypes(object sender, EventArgsCommand e)
    {
        SerializerUtility.AddType(typeof(/*ClassNameHere*/)); //Adds a type to SaveGame.serializer
        SerializerUtility.AddFarmerType(typeof(/*Class2NameHere*/)); //Adds a type to SaveGame.farmerSerializer
    }
    
    Code will be made open source and uploaded to GitHub when I find time. All are welcome to contribute to it. This utility will likely be deprecated once the FarmHand API is released and serialization tools are implemented into it.
     
      Last edited: Apr 19, 2016
      wty4321, Androxilogin, SKKN and 7 others like this.
    • Androxilogin

      Androxilogin Subatomic Cosmonaut

      I used to use this on my old save (great work, btw) but had to revert back to my old unmodded save after the new update. Is there a way to remove things from my save file to excuse the changes this mod? I'd love to get back to work on my farm in full glory.

      [EDIT] Nevermind, sorry- I realize I already asked this long ago with your FarmExtension mod, I just couldn't find which mod it was I commented on back then.


      QUOTE:
      Let me begin by saying that I've exaggerated the save game issue. Your save is never harmed or damaged, it just has information added into it that can't be loaded unless the mod is still present. If you uninstall the mod at a later date, the unloadable information can easily be removed manually from your save file using a text editor.

      The mod in its current state will NOT work unless the serializer utility is present. If you wish to avoid using it, the 1.3 version is still available for download which didn't have the animals/buildings support.

      Also, here's a screenshot showing what information to remove from your save file to repair it should you ever want to uninstall the mod:
      (Click to enlarge)

      [​IMG]

      As you can see in the image, you just need to search for "FarmExtension" in your save file, and remove a few lines of text starting with "<GameLocation xsi:type="FarmExtension">" up to and including the next closing tag of "</GameLocation>".
       
        Last edited: Jan 14, 2017

      Share This Page