Forum rules - please read before posting.

Lucasarts/ScummVM/Sierra-style save slots per game?

2»

Comments

  • So here's what I'm trying for the save image, if you click on the saveslist it puts it into save slot mode, which is desired; if you want to load, you can, if you want to save, you also can, all in one step. Is it possible to set the graphic to the currently selected slot? That way you can preview which game you're writing over with a screenshot if you're saving, but also determine which you'd like to load from. Here's an example of how I'm setting it up: https://gfycat.com/AdeptFrigidIndigobunting

  • @ChrisIceBox sorry, just wanted to tag you in case you missed the above, thanks!

  • You'd have to hook into the OnMenuElementClick custom event to update the save image with the correct one.

    The screenshot for a given save slot can be read with SaveSystem.GetSaveSlotScreenshot.

  • Ahh, that's what I thought you might say, and I have a fear of writing hooks! :D Okay, so this would be a fresh script, I'll assume, on the saveslist element (or the root RetroSaves with the appropriate public gameobjects) and then I'm using the hook to save the image appropriate to the slot chosen. Is any of this done with actionlists, or does it all have to go via the custom script?

    And for updating the screenshot image with whichever slot is clicked, this would all be with hooks, or can any of it be done in the actionlist?

  • The saving of the screenshot is automatic - when the save slot is written to, the screenshot will be updated regardless of whether you actually display it or not. That does not need a custom script.

    The only thing you should need to script here is what you were asking for - i.e. to update the single preview image in the Load menu. A single hook for OnMenuElementClick, to check if the Load menu's SavesList element was clicked on. If so, read the slot number to get the screenshot to load, and update the Image with it.

  • I've tried putting this into the RepositionSaveInputBox script, but I'm a little stuck on getting the image into the button with the correct public, and putting the correct slot/element name into the call, here's what I've gotten so far:
    `using UnityEngine;
    using UnityEngine.UI;
    using System.Collections;
    using AC;

    public class RepositionSaveInputBox : MonoBehaviour
    {

    public string menuName = "RetroSaves";
    public string savesListName = "SaveList";
    public GameObject myInputBoxGameObject;
    public Image screenshot;
    
    
    
    private void Awake ()
    {
        EventManager.OnMenuElementClick += OnMenuElementClick;
    }
    
    
    private void OnDestroy ()
    {
        EventManager.OnMenuElementClick -= OnMenuElementClick;
    }
    
    
    private void OnMenuElementClick (Menu _menu, MenuElement _element, int _slot, int buttonPressed)
    {
        if (_menu.title == menuName && _element.title == savesListName)
        {
            MenuSavesList savesList = _element as MenuSavesList;
            Vector3 position = savesList.uiSlots[_slot].uiButton.GetComponent <RectTransform>().position;
    
            GetComponent <RectTransform>().position = position;
    
            AC.KickStarter.playerMenus.SelectUIElement(myInputBoxGameObject);
    
            screenshot = AC.SaveSystem.GetSaveSlotScreenshot(_element, _slot, true);
        }
    }
    

    }
    `

  • GetSaveSlotScreenshot returns a texture - and you're trying to assign it into an Image variable.

    Texture2D screenshotTexture = AC.SaveSystem.GetSaveSlotScreenshot(_element, _slot, true);
    Sprite screenshotSprite = UnityEngine.Sprite.Create (screenshotTexture, new Rect (0f, 0f, screenshotTexture.width, screenshotTexture.height), new Vector2 (0.5f, 0.5f));
    screenshot.sprite = screenshotSprite;
    

    This is not AC related - see Unity's own API and forums: https://docs.unity3d.com/ScriptReference/UI.Image.html

  • Ahh sorry, is it because I should just use a Sprite instead a button?
  • A Sprite lives on an Image component, which itself can be part of a Button. Please refer to Unity's own documentation for this - this is not an AC issue.

  • Okay, I appreciate that, now. I'm sorry about this, it's a little out of my range, but your code works almost nicely as long as I change (_element, _slot, true) to (0, _slot, true) to give it an int, otherwise I get "cannot convert from AC.Element to int". I'm not sure this is working properly though, as it doesn't take into account the newest save slot is going to the top of the list (and the save screenshots are also offset). Does the save screenshot need to be saved with the slot index from variable, as per the actionlist? Here's the script so far:
    `using UnityEngine;
    using UnityEngine.UI;
    using System.Collections;
    using AC;

    public class RepositionSaveInputBox : MonoBehaviour
    {

    public string menuName = "RetroSaves";
    public string savesListName = "SaveList";
    public GameObject myInputBoxGameObject;
    public Image screenshot;
    
    
    
    private void Awake()
    {
        EventManager.OnMenuElementClick += OnMenuElementClick;
    }
    
    
    private void OnDestroy()
    {
        EventManager.OnMenuElementClick -= OnMenuElementClick;
    }
    
    
    private void OnMenuElementClick(Menu _menu, MenuElement _element, int _slot, int buttonPressed)
    {
        if (_menu.title == menuName && _element.title == savesListName)
        {
            MenuSavesList savesList = _element as MenuSavesList;
            Vector3 position = savesList.uiSlots[_slot].uiButton.GetComponent<RectTransform>().position;
    
            GetComponent<RectTransform>().position = position;
    
            AC.KickStarter.playerMenus.SelectUIElement(myInputBoxGameObject);
    
            Texture2D screenshotTexture = AC.SaveSystem.GetSaveSlotScreenshot(0, _slot, true);
            Sprite screenshotSprite = UnityEngine.Sprite.Create(screenshotTexture, new Rect(0f, 0f, screenshotTexture.width, screenshotTexture.height), new Vector2(0.5f, 0.5f));
            screenshot.sprite = screenshotSprite;
    
        }
    }
    

    }
    `

  • your code works almost nicely as long as I change (_element, _slot, true) to (0, _slot, true) to give it an int, otherwise I get "cannot convert from AC.Element to int"

    Quite right.

    I'm not sure this is working properly though, as it doesn't take into account the newest save slot is going to the top of the list (and the save screenshots are also offset). Does the save screenshot need to be saved with the slot index from variable, as per the actionlist?

    The script is unrelated to the saving of save screenshots - it's merely displaying an already-existing screenshot in your custom Image component.

    I'm unsure what you mean by this. Are the save files and screenshots themselves correct, but displayed in the wrong order? Check the Console message upon saving, as well as the files in the stated directory - are the correct files being updated?

  • The save files are saved, and then the latest save goes to the top, as you know. This seems to be the issue, as the save games seems to be offset, ie: save 5's picture appears on save 6, and the top save is incorrect. Does the save screenshot slot number need to be matched to the way retrosaves works by putting the newest save at 0? And am I supposed to use something else instead of 0 for _element?
  • The save files are saved, and then the latest save goes to the top, as you know

    Only if Order save lists by update time? is checked.

    This seems to be the issue, as the save games seems to be offset, ie: save 5's picture appears on save 6, and the top save is incorrect.

    Again, check the actual files. If you save in slot 5, do the save file and screenshot file for "5" get updated?

    And am I supposed to use something else instead of 0 for _element?

    It's ignored if the "useSaveID" parameter is True.

  • edited January 2019

    Here's with "order lists by update time" unchecked: https://gfycat.com/ReadySparseCobra
    The save games are all in correct order:

    Here's with "order lists by update time" checked: https://gfycat.com/FewClassicIberianemeraldlizard
    And the saves:

    I'm not entirely sure, the saves seems to be correct, but the script isn't correctly identifying the save that matches the slot? I'd like to use "order lists by update time" but even so, with that unchecked, it's still not bringing the screenshots in correctly?

  • My mistake - you need to pass the slot, not the saveID.

    Replace:

    AC.SaveSystem.GetSaveSlotScreenshot(0, _slot, true);
    

    with:

    AC.SaveSystem.GetSaveSlotScreenshot(_slot, 0, false);
    
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.