Skip to content

Fix initial cursor position for in-game UI elements#1120

Open
ayushthoren wants to merge 1 commit intosmartcmd:mainfrom
ayushthoren:cursor-position-fix
Open

Fix initial cursor position for in-game UI elements#1120
ayushthoren wants to merge 1 commit intosmartcmd:mainfrom
ayushthoren:cursor-position-fix

Conversation

@ayushthoren
Copy link
Contributor

Description

Fixes cursor behavior in UI containers such that the position is now deterministic depending on the type of input being used (controller vs KBM).

The cursor now defaults to the first hotbar slot on controller, and defaults to the center of the UI container on KBM.

Changes

Previous Behavior

Cursor position persisted across menu closes/reopens.

Root Cause

Cursor state was being saved (to g_savedInventoryCursorPos.x and g_savedInventoryCursorPos.y) when containers were closed and restored, using those cached values on next open.

New Behavior

Cursor position no longer persists between menu sessions.

  • Controller inputs open with the cursor at the first hotbar slot.
  • KBM inputs open with the cursor at the center of the menu panel (not forced to a slot).

Fix Implementation

Removed cursor persistence logic:

  • Deleted SavedInventoryCursorPos declaration/usage.
  • Removed save and restore logic.

Updated UIScene_AbstractContainerMenu::PlatformInitialize():

  • Kept existing default pointer to first hotbar slot.
  • Added Windows64 check: if iPad == 0 && g_KBMInput.IsKBMActive(), place pointer at panel center.
    • Checking if iPad ==0 ensures that KBM inputs only affect the primary player's experience on splitscreen, since additional players are guaranteed to be using controllers.

AI Use Disclosure

No AI was used to implement these changes.

Related Issues

  • Fixes Discord Thread 1480743335579877517

Signed-off-by: Ayush Thoren <ayushthoren@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant