Forum rules - please read before posting.

Cycling cursor - default cursor not excluded (no texture)

Hi, I am not sure if this is intended but I don't think so.
When you set the default cursor's Display cursor property to Only when paused the default cursor is not excluded or skipped when cycling the cursors, instead the icon is not drawn (https://i.imgur.com/t0aRdER.png). So I had to modify PlayerCursor:

private void DrawMainCursor (){

            if (!showCursor)
            {
                return;
            }

            if (KickStarter.cursorManager.cursorDisplay == CursorDisplay.Never || !KickStarter.cursorManager.allowMainCursor)
            {
                return;
            }

            if (KickStarter.stateHandler.gameState != GameState.Paused && KickStarter.cursorManager.cursorDisplay == CursorDisplay.OnlyWhenPaused)
            {
                // added by me
                // default cursor no texture fix
                selectedCursor++;
                return;
            }
...}

Of course this only works if there is at least one additional cursor. Would be nice to have it automatically excluded or skipped when the game is not paused in future versions.

Comments

  • edited June 2019

    Not necessarily, this may be a separate option.

    So that I can recreate the issue accurately, please share your exact interface settings, and describe precisely the interface behaviour you're looking to achieve.

  • edited June 2019

    Your Manager shots are incomplete - please shared uncropped images.

    Again, please describe precisely the interface behaviour you're looking to achieve. How is it that you want to be able to detect Hotspots if the regular cursor is hidden? Is the "walk" cursor set to display at all other times?

    You can use the OnChangeCursorMode custom event to change the active cursor, rather than having to edit the source code.

  • Oh yeah, sorry. When the game is in normal state I want to cycle (by right-click) through use and look at (default is excluded, cause it does nothing). When I go into conversation only the default cursor is enabled.
    I did this by making the change above and changed the
    private int selectedCursor = -1;
    to public. Then I can do what ever I want with the cursor.
    Also when the pointer, mouse, is over menu I change it to only default.

  • I edited my post above shortly before you replied, did you see my mention of the custom event and Manager shots?

    When I go into conversation only the default cursor is enabled.

    Is that what you want, or is that what's occuring and you don't want it? It's also possible to change the "Display cursor" property (and any Manager field) at runtime through script - just right-click the field's label to get an API reference to it.

  • edited June 2019

    Oh I didn't see.
    Well my point was that when the main cursor display cursor property is set to never or only when paused it cycles through -1, 0 and 1, but you cannot see texture of the main cursor.
    This is with my modification: https://imgur.com/cqdlUwg
    And this is without modification: https://imgur.com/YbgKibN
    Sorry for the quality :#
    At first I tried the SetSelectedCursorID(int) but it didn't work as intended.
    So I had to do this with the 2 modifications to your script mentioned above.
    `
    using AC;
    using UnityEngine;
    using UnityEngine.Assertions;

    public class MyPlayerCursor : PlayerCursor
    {
    private bool isOverItem, isOverMenu;

    private Menu inventoryExpandedMenu, inventoryOpenMenu;
    
    private bool deselectedEnabled = true;
    
    public bool EnableItemDeselectedMethod
    {
        get { return deselectedEnabled; }
        set { deselectedEnabled = value; }
    }
    
    protected void Start()
    {
        KickStarter.cursorManager.cursorDisplay = CursorDisplay.OnlyWhenPaused;
    
        inventoryExpandedMenu = PlayerMenus.GetMenuWithName("InventoryExpanded");
        inventoryOpenMenu = PlayerMenus.GetMenuWithName("Inventory");
    
        Assert.IsNotNull(inventoryExpandedMenu);
        Assert.IsNotNull(inventoryOpenMenu);
    
        EventManager.OnEnterGameState += EnteredGameState;
        EventManager.OnExitGameState += ExitedGameState;
        EventManager.OnInventoryDeselect += ItemDeselected;
    }
    
    private void OnDestroy()
    {
        EventManager.OnEnterGameState -= EnteredGameState;
        EventManager.OnExitGameState -= ExitedGameState;
        EventManager.OnInventoryDeselect -= ItemDeselected;
    }
    
    private void Update()
    {
        if (KickStarter.runtimeInventory.hoverItem != null && !isOverItem)
        {
            isOverItem = true;
            KickStarter.cursorManager.cursorDisplay = CursorDisplay.Always;
            return;
        }
    
        if (isOverItem && KickStarter.runtimeInventory.hoverItem == null &&
            KickStarter.stateHandler.gameState != GameState.DialogOptions)
        {
            isOverItem = false;
            KickStarter.cursorManager.cursorDisplay = CursorDisplay.OnlyWhenPaused;
            CycleCursors();
        }
    
        Vector2 invertedMouse = KickStarter.playerInput.GetInvertedMouse();
        if (inventoryExpandedMenu.IsOn() && inventoryExpandedMenu.IsVisible() &&
            inventoryExpandedMenu.IsPointInside(invertedMouse))
        {
            isOverMenu = true;
            KickStarter.cursorManager.cursorDisplay = CursorDisplay.Always;
            KickStarter.playerCursor.ResetSelectedCursor();
        }
        else if (inventoryOpenMenu.IsOn() && inventoryOpenMenu.IsVisible() &&
                 inventoryOpenMenu.IsPointInside(invertedMouse))
        {
            isOverMenu = true;
            KickStarter.cursorManager.cursorDisplay = CursorDisplay.Always;
            KickStarter.playerCursor.ResetSelectedCursor();
        }
        else if (isOverMenu && KickStarter.stateHandler.gameState != GameState.DialogOptions)
        {
            isOverMenu = false;
            KickStarter.cursorManager.cursorDisplay = CursorDisplay.OnlyWhenPaused;
            CycleCursors();
        }
    }
    
    private void ItemDeselected(InvItem item)
    {
        if (!deselectedEnabled)
            return;
    
        CycleCursors();
    }
    
    private void EnteredGameState(GameState gameState)
    {
        if (gameState == GameState.DialogOptions)
        {
            KickStarter.cursorManager.cursorDisplay = CursorDisplay.Always;
            SetCursorFromID(-1);
        }
    }
    
    private void ExitedGameState(GameState gameState)
    {
        if (gameState == GameState.Paused || gameState == GameState.DialogOptions)
            CycleCursors();
    }
    
    public void CycleCursors()
    {
        var cursorId = KickStarter.playerCursor.GetSelectedCursorID();
        // disable the default cursor
        if (cursorId == -1 && KickStarter.stateHandler.gameState == GameState.Normal)
        {
            KickStarter.playerCursor.selectedCursor = cursorId++;
        }
    }
    

    }
    `

  • edited June 2019

    I will look into it. Manager shots are still welcome, though.

  • As mentioned above, the OnChangeCursorMode event can be used to react to the default cursor becoming selected. The following will skip over the default:

    using UnityEngine;
    using System.Collections;
    using AC;
    
    public class SkipMainCursor : MonoBehaviour
    {
    
        private void OnEnable ()
        {
            EventManager.OnChangeCursorMode += OnChangeCursorMode;
        }
    
    
        private void OnDisable ()
        {
            EventManager.OnChangeCursorMode -= OnChangeCursorMode;
        }
    
    
        private void Start ()
        {
            KickStarter.playerCursor.gameObject.SendMessage ("CycleCursors");
        }
    
    
        private void OnChangeCursorMode (int mode)
        {
            if (mode == -1)
            {
                KickStarter.playerCursor.gameObject.SendMessage ("CycleCursors");
            }
        }
    
    }
    

    The Start() function is currently necessary because the event is not used for the cursor's initial value. However, I will correct this in the next update.

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.