-
Notifications
You must be signed in to change notification settings - Fork 9
Icarus readme position details #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -26,6 +26,76 @@ Dev log: https://youtu.be/dDn2rafvjMQ?si=mm1Sz-XrjvNQiRWE | |||||
| - Core strategy workflow is coordinated by `lib/providers/strategy_provider.dart`. | ||||||
| - UI is composed from screens in `lib/` and shared components under `lib/widgets/`. | ||||||
|
|
||||||
| ## Position Handling (Detailed) | ||||||
| Icarus stores object positions in a normalized coordinate system so layouts stay consistent across window sizes, zoom levels, screenshots, and saved files. | ||||||
|
|
||||||
| ### 1) Coordinate spaces | ||||||
| - **Screen space (pixels):** actual rendered location on the current canvas. | ||||||
| - **World space (normalized):** persisted positions for all placed objects. | ||||||
|
|
||||||
| World-space dimensions are defined in `lib/const/coordinate_system.dart`: | ||||||
| - `normalizedHeight = 1000` | ||||||
| - `worldAspectRatio = 16/9` | ||||||
| - `worldNormalizedWidth = normalizedHeight * worldAspectRatio` (about `1777.78`) | ||||||
|
|
||||||
| Core transforms: | ||||||
| - `screenToCoordinate`: converts drag/drop pixel offsets into normalized world positions. | ||||||
| - `coordinateToScreen`: converts stored normalized positions back to on-screen pixels. | ||||||
|
|
||||||
| This is why one saved strategy can be reopened at different resolutions without manual re-alignment. | ||||||
|
|
||||||
| ### 2) Drag/drop and update pipeline | ||||||
| For agents, abilities, utilities, text, images, and lineup placement: | ||||||
| 1. UI drag/drop handlers get a global pointer position. | ||||||
| 2. Position is converted to local widget coordinates (`globalToLocal`). | ||||||
| 3. Local position is converted to normalized world space (`screenToCoordinate`). | ||||||
| 4. Provider updates the relevant `Placed*` model with `updatePosition`. | ||||||
|
|
||||||
| Key references: | ||||||
| - Placement and drag-end conversion: `lib/widgets/draggable_widgets/placed_widget_builder.dart` | ||||||
| - Provider updates: `lib/providers/*_provider.dart` | ||||||
| - Base position/history model: `lib/const/placed_classes.dart` | ||||||
|
|
||||||
| ### 3) Zoom-aware dragging | ||||||
| The map can be scaled (`Transform.scale`). To keep drag behavior correct while zoomed: | ||||||
| - `screen_zoom_provider.dart` adjusts drag anchor strategy and offsets. | ||||||
| - Feedback widgets are wrapped in `ZoomTransform`. | ||||||
|
|
||||||
| Without this, dropped positions would drift when zoom is not `1.0`. | ||||||
|
|
||||||
| ### 4) Bounds checks and safe anchors | ||||||
| Position validity is checked in normalized space via `CoordinateSystem.isOutOfBounds(...)` with a small tolerance. | ||||||
|
|
||||||
| Different object types use different anchor/safe-area rules: | ||||||
| - **Agents:** center point check using configured agent size. | ||||||
|
||||||
| - **Agents:** center point check using configured agent size. | |
| - **Agents:** center point check using the current ability size from `strategySettingsProvider.abilitySize`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README states that zoom is implemented via
Transform.scale, but the main map zoom/pan is driven byInteractiveViewer+ aTransformationController(lib/interactive_map.dart).Transform.scaleis used for drag feedback inZoomTransform, not for the primary viewport scaling. Please update this section to referenceInteractiveViewerfor map zoom, and (optionally) mentionZoomTransform/ScreenZoomProvideras the mechanism that keeps draggable feedback/anchors consistent with the currentInteractiveViewerscale.