Skip to content

Commit

Permalink
fix(map, ui): tooltip is misplaced when 'Align Solar Systems to Grid'…
Browse files Browse the repository at this point in the history
… is enabled
  • Loading branch information
MichaelMakesGames committed Feb 14, 2024
1 parent 4d7204d commit b7f9375
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions src/renderer/src/lib/map/MapContainer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -278,27 +278,30 @@
if (system) {
const settings = get(mapSettings);
const processedSystem = dataOrNull?.systems.find((s) => s.id === system.id);
const systemPoint: [number, number] = [-system.coordinate.x, system.coordinate.y];
const tooltipPoint: [number, number] = [
(transform || zoomIdentity).applyX(
((systemPoint[0] + viewBoxWidth / 2) * outputWidth) / viewBoxWidth,
),
(transform || zoomIdentity).applyY(
((systemPoint[1] + viewBoxHeight / 2) * outputHeight) / viewBoxHeight,
),
];
if (settings.terraIncognita && !processedSystem?.systemIsKnown) {
tooltip = null;
} else if (Math.hypot(tooltipPoint[0] - e.offsetX, tooltipPoint[1] - e.offsetY) > 32) {
if (processedSystem == null) {
tooltip = null;
} else {
tooltip = {
x: tooltipPoint[0],
y: tooltipPoint[1],
system: system,
};
const systemPoint: [number, number] = [processedSystem.x, processedSystem.y];
const tooltipPoint: [number, number] = [
(transform || zoomIdentity).applyX(
((systemPoint[0] + viewBoxWidth / 2) * outputWidth) / viewBoxWidth,
),
(transform || zoomIdentity).applyY(
((systemPoint[1] + viewBoxHeight / 2) * outputHeight) / viewBoxHeight,
),
];
if (settings.terraIncognita && !processedSystem.systemIsKnown) {
tooltip = null;
} else if (Math.hypot(tooltipPoint[0] - e.offsetX, tooltipPoint[1] - e.offsetY) > 32) {
tooltip = null;
} else {
tooltip = {
x: tooltipPoint[0],
y: tooltipPoint[1],
system: system,
};
}
}
}
}
Expand Down

0 comments on commit b7f9375

Please sign in to comment.