Skip to content

Fix mini-map interaction, dragging/resizing and state reprojection logic#1

Merged
Atothendrew merged 2 commits into
mainfrom
codex/find-and-fix-logic-errors
Apr 6, 2026
Merged

Fix mini-map interaction, dragging/resizing and state reprojection logic#1
Atothendrew merged 2 commits into
mainfrom
codex/find-and-fix-logic-errors

Conversation

@Atothendrew

Copy link
Copy Markdown
Owner

Motivation

  • The mini-map mishandled clicks by invoking delegate callbacks unconditionally instead of honoring the updatePositionOnClick flag.
  • Runtime toggling of the base marker (showBaseMarker) did not create or remove the marker after initialization, causing inconsistencies when enabling/disabling it.
  • Dragging, resizing and reprojection flows lost or misused state leading to incorrect coordinate math, stuck timeouts, and overlays that did not update after size changes.

Description

  • Made baseMarker mutable and implemented a didSet flow on showBaseMarker to dynamically create/remove the marker and reproject its position using cached scene state via currentBasePosition and currentSceneSize.
  • Guarded delegate invocation in handleClick(at:) so the delegate is only called when updatePositionOnClick is true.
  • Added cached state properties currentBasePosition, currentCameraPosition, currentCameraZoom, and ensured updateBasePosition and updateCameraViewFrame update those caches for later reprojection.
  • Hardened coordinate conversion (convertToMapPosition and convertFromMapPosition) to guard against zero-sized scene/map dimensions and allow conversions when the node is detached by using cached currentSceneSize.
  • Fixed dragging math by storing the local drag offset at start and converting pointer locations into the parent coordinate space during updates, and initialized lastDragTime/lastResizeTime at operation start to avoid premature stuck resets.
  • Made resizing stable: applied a safe zoom for camera viewport computation, corrected macOS Y-axis resize delta direction, and refreshed base marker, entities and camera frame after mapSize changes.

Testing

  • Ran swift test in this environment which could not complete due to the platform missing the SpriteKit framework (error: no such module 'SpriteKit'), so unit tests could not be executed here.
  • Changes were validated by static review and lightweight local execution where possible; logic and API behaviour were updated without modifying public method signatures.

Codex Task

@Atothendrew

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@Atothendrew
Atothendrew merged commit 07cf69f into main Apr 6, 2026
2 of 3 checks passed
@Atothendrew
Atothendrew deleted the codex/find-and-fix-logic-errors branch April 6, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant