Page 1 of 1

[Solved] Save Slot information

Posted: Tue Aug 06, 2024 2:53 pm
by Pixchel
Hello, I searched on the forum but didn't found any answer.
Can you help me to know how to add informations on the display slot informations ? (like default is :
"Slot X
Time : date/hour"

that's it

How can I add (for example) the player displayName (I store it in an other script) or the player level to this information?

PS : I use Menu FrameWork

Re: Save Slot information

Posted: Tue Aug 06, 2024 5:04 pm
by Tony Li
Hi,

For the Menu Framework in specific, see step 12 on page 4 of the Menu Framework manual:
During gameplay, you can set a Dialogue System text variable named "CurrentStage". The
contents of this variable will added to the saved game summary information, which is shown in
the details section of the load game panel when the player selects a saved game. For example,
you can use a DialogueSystemTrigger set to OnStart that sets Variable[“CurrentStage”] to the
name of the scene, or use a dialogue entry’s Script field to set “CurrentStage” after major story
events.

If you want to add more information to the saved game summary, assign your own delegate
methods to SaveHelper.RecordExtraSlotDetailsHandler.

To show saved game details differently in the load game panel, you can assign an event handler
to LoadGamePanel's On Set Details event.
In general (not Menu Framework), please see: How To: Include Summary Info In Saved Games

Re: Save Slot information

Posted: Wed Aug 07, 2024 2:00 am
by Pixchel
I already seen manual speak about CurrentStage, but I don't really get it... Can we have an example for this ? please. It would be helpfull

Re: Save Slot information

Posted: Wed Aug 07, 2024 2:38 pm
by Tony Li
Try adding a script like this to your MenuSystem GameObject/prefab:

AddMoreSaveInfo.cs

Code: Select all

using System;
using UnityEngine;
using PixelCrushers.DialogueSystem.MenuSystem;
public class AddMoreSaveInfo : MonoBehaviour
{
    private void Start()
    {
        GetComponent<SaveHelper>().RecordExtraSlotDetailsHandler = RecordExtraSlotDetails;
    }
    private void RecordExtraSlotDetails(int slotNum, ref string summaryInfo)
    {
        summaryInfo += $"\nSlot {slotNum}\nTime: {DateTime.Now}";
    }
}

Re: Save Slot information

Posted: Wed Aug 07, 2024 5:13 pm
by Pixchel
Okay, it add more detail on the summary when we press the slot button to load, but it not displayed in the button itself (in save and load menu)
ImageImage

Re: Save Slot information

Posted: Wed Aug 07, 2024 8:47 pm
by Tony Li
Hi,

Each save slot has two areas of information: slot summary, and slot details.

The script above adds information to the slot details.

To add information to the slot summary, you must make a subclass of SaveHelper, replace the SaveHelper component on your MenuSystem prefab with the subclass, and override the GetCurrentSummary() summary in your subclass. Something like:

Code: Select all

public class CustomSaveHelper : SaveHelper
{
    public override string GetCurrentSummary(int slotNum)
    {
        return base.GetCurrentSummary(slotNum) + "\n" + EXTRA INFO HERE;
    }
}

Re: Save Slot information

Posted: Thu Aug 08, 2024 1:30 pm
by Pixchel
Okay, got it, but if we add thing to summary, it will be added to detail too. So I have found the reference in the savehelper itself to modify it, Thanks for your answer and your time, you are the best

Re: Save Slot information

Posted: Thu Aug 08, 2024 4:49 pm
by Tony Li
Happy to help!