Forum rules - please read before posting.

[Scripting] Porting Load display/functionality to DoozyUI UIViews (or any 3rd party UI solution)

Hi there!

I recently decided to move to using DoozyUI to handle at least the main Menu.

What's the fastest way (using a 3rd party UI) to trigger code such as:

  • New Game or Resume last save
  • Populating a UI grid (actually a horizontal list) with Info about the available saved games, if any (not using profiles), and separately showing the autosave info
  • binding the above with appropriate code to execute on click

I'm trying to find a solution that doesn't rely on AC's builtin menu system (as I'd need to replicate the whole menu structure in AC as well).

The idea would be to find some code like:
SaveGameInfo[] = Kickstarter.GetSaveGamesInfo();

and then
clickedSaveGameInfo.Load();

Comments

  • New Game

    Just switch to the game's first scene:

    SceneInfo nextSceneInfo = new SceneInfo ("MyNewScene");
    KickStarter.sceneChanger.ChangeScene (newSceneInfo, false);
    

    Resume last save

    SaveSystem.ContinueGame ();
    

    Populating a UI grid (actually a horizontal list) with Info about the available saved games, if any (not using profiles), and separately showing the autosave info

    You can get a list of all save game info with:

    KickStarter.saveSystem.foundSaveFiles;
    

    See the SaveFile class in the Scripting Guide for details.

    A typical way to extract their labels might be:

    void GetSaveSlotLabels ()
    {
        int numSaves = GetNumSaves ();
    
        string autoSaveLabel = string.Empty;
        List<string> manualSaveLabels = new List<string>();
    
        for (int i=0; i<numSaves; i++)
        {
            SaveFile saveFile = KickStarter.saveSystem.foundSaveFiles[i];
            string saveLabel = saveFile.GetSafeLabel ();
            int saveID = saveFile.saveID;
    
            if (saveFile.isAutoSave)
            {
                autoSaveLabel = saveLabel;
            }
            else
            {
                manualSaveLabels.Add (saveLabel);
            }
        }
    }
    

    binding the above with appropriate code to execute on click

    To load the Autosave:

    SaveSystem.LoadAutoSave ();
    

    To load a save by ID number:

    SaveSystem.Load (saveID);
    

    To load a save by index within foundSaveFiles:

    SaveSystem.Load (index, 0, false);
    
  • Really straightforward, thanks for the point to point answer, that's really some full overview in a very compact format, I'm gonna bookmark this.

    I will have a look at the SaveFile class asap.

    Thanks again for the blazing fast reply!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.