mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
1 Commits
40c576bc2d
...
try-fix-cr
Author | SHA1 | Date | |
---|---|---|---|
![]() |
db7ba76727 |
@@ -43,6 +43,7 @@ export default class HighlightedInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setInstance(instance: gdInitialInstance | null) {
|
setInstance(instance: gdInitialInstance | null) {
|
||||||
|
console.log('setting instance', instance);
|
||||||
this.isHighlightedInstanceOf3DObject = instance
|
this.isHighlightedInstanceOf3DObject = instance
|
||||||
? this.isInstanceOf3DObject(instance)
|
? this.isInstanceOf3DObject(instance)
|
||||||
: false;
|
: false;
|
||||||
|
@@ -12,6 +12,8 @@ import { makeDoubleClickable } from './PixiDoubleClickEvent';
|
|||||||
import Rectangle from '../../Utils/Rectangle'; // TODO (3D): add support for zMin/zMax/depth.
|
import Rectangle from '../../Utils/Rectangle'; // TODO (3D): add support for zMin/zMax/depth.
|
||||||
import { rotatePolygon, type Polygon } from '../../Utils/PolygonHelper';
|
import { rotatePolygon, type Polygon } from '../../Utils/PolygonHelper';
|
||||||
import Rendered3DInstance from '../../ObjectsRendering/Renderers/Rendered3DInstance';
|
import Rendered3DInstance from '../../ObjectsRendering/Renderers/Rendered3DInstance';
|
||||||
|
import { shouldPreventRenderingInstanceEditors } from '../../UI/MaterialUISpecificUtil';
|
||||||
|
import { isMouseOnSceneEditorCanvas } from '../../UI/DragAndDrop/CustomDragLayer';
|
||||||
const gd: libGDevelop = global.gd;
|
const gd: libGDevelop = global.gd;
|
||||||
|
|
||||||
export default class LayerRenderer {
|
export default class LayerRenderer {
|
||||||
@@ -379,19 +381,41 @@ export default class LayerRenderer {
|
|||||||
renderedInstance._pixiObject.eventMode = 'static';
|
renderedInstance._pixiObject.eventMode = 'static';
|
||||||
panable(renderedInstance._pixiObject);
|
panable(renderedInstance._pixiObject);
|
||||||
makeDoubleClickable(renderedInstance._pixiObject);
|
makeDoubleClickable(renderedInstance._pixiObject);
|
||||||
|
renderedInstance._pixiObject.addEventListener('mousemove', event => {
|
||||||
|
console.log('mousemove');
|
||||||
|
if (
|
||||||
|
shouldPreventRenderingInstanceEditors() ||
|
||||||
|
!isMouseOnSceneEditorCanvas({ x: event.clientX, y: event.clientY })
|
||||||
|
) {
|
||||||
|
this.onOutInstance(instance);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
renderedInstance._pixiObject.addEventListener('click', event => {
|
renderedInstance._pixiObject.addEventListener('click', event => {
|
||||||
|
console.log('click');
|
||||||
if (event.data.originalEvent.button === 0)
|
if (event.data.originalEvent.button === 0)
|
||||||
this.onInstanceClicked(instance);
|
this.onInstanceClicked(instance);
|
||||||
});
|
});
|
||||||
renderedInstance._pixiObject.addEventListener('doubleclick', () => {
|
renderedInstance._pixiObject.addEventListener('doubleclick', () => {
|
||||||
|
console.log('double click');
|
||||||
this.onInstanceDoubleClicked(instance);
|
this.onInstanceDoubleClicked(instance);
|
||||||
});
|
});
|
||||||
renderedInstance._pixiObject.addEventListener('mouseover', () => {
|
renderedInstance._pixiObject.addEventListener('mouseover', event => {
|
||||||
|
console.log('mouseover', event);
|
||||||
|
if (
|
||||||
|
shouldPreventRenderingInstanceEditors() ||
|
||||||
|
!isMouseOnSceneEditorCanvas({ x: event.clientX, y: event.clientY })
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('onoverinstance');
|
||||||
this.onOverInstance(instance);
|
this.onOverInstance(instance);
|
||||||
});
|
});
|
||||||
renderedInstance._pixiObject.addEventListener(
|
renderedInstance._pixiObject.addEventListener(
|
||||||
'mousedown',
|
'mousedown',
|
||||||
(event: PIXI.InteractionEvent) => {
|
(event: PIXI.InteractionEvent) => {
|
||||||
|
console.log('mousedown');
|
||||||
if (event.data.originalEvent.button === 0) {
|
if (event.data.originalEvent.button === 0) {
|
||||||
const viewPoint = event.data.global;
|
const viewPoint = event.data.global;
|
||||||
const scenePoint = this.viewPosition.toSceneCoordinates(
|
const scenePoint = this.viewPosition.toSceneCoordinates(
|
||||||
@@ -405,6 +429,7 @@ export default class LayerRenderer {
|
|||||||
renderedInstance._pixiObject.addEventListener(
|
renderedInstance._pixiObject.addEventListener(
|
||||||
'rightclick',
|
'rightclick',
|
||||||
interactionEvent => {
|
interactionEvent => {
|
||||||
|
console.log('rightclick');
|
||||||
const {
|
const {
|
||||||
data: { global: viewPoint, originalEvent: event },
|
data: { global: viewPoint, originalEvent: event },
|
||||||
} = interactionEvent;
|
} = interactionEvent;
|
||||||
@@ -430,6 +455,7 @@ export default class LayerRenderer {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
renderedInstance._pixiObject.addEventListener('touchstart', event => {
|
renderedInstance._pixiObject.addEventListener('touchstart', event => {
|
||||||
|
console.log('touchstart');
|
||||||
if (shouldBeHandledByPinch(event.data && event.data.originalEvent)) {
|
if (shouldBeHandledByPinch(event.data && event.data.originalEvent)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -441,12 +467,15 @@ export default class LayerRenderer {
|
|||||||
);
|
);
|
||||||
this.onDownInstance(instance, scenePoint[0], scenePoint[1]);
|
this.onDownInstance(instance, scenePoint[0], scenePoint[1]);
|
||||||
});
|
});
|
||||||
renderedInstance._pixiObject.addEventListener('mouseout', () => {
|
renderedInstance._pixiObject.addEventListener('mouseout', event => {
|
||||||
|
console.log('mouseout');
|
||||||
|
console.log('onoutinstance');
|
||||||
this.onOutInstance(instance);
|
this.onOutInstance(instance);
|
||||||
});
|
});
|
||||||
renderedInstance._pixiObject.addEventListener(
|
renderedInstance._pixiObject.addEventListener(
|
||||||
'panmove',
|
'panmove',
|
||||||
(event: PanMoveEvent) => {
|
(event: PanMoveEvent) => {
|
||||||
|
console.log('panmove');
|
||||||
if (shouldBeHandledByPinch(event.data && event.data.originalEvent)) {
|
if (shouldBeHandledByPinch(event.data && event.data.originalEvent)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -455,6 +484,7 @@ export default class LayerRenderer {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
renderedInstance._pixiObject.addEventListener('panend', event => {
|
renderedInstance._pixiObject.addEventListener('panend', event => {
|
||||||
|
console.log('panend');
|
||||||
this.onMoveInstanceEnd();
|
this.onMoveInstanceEnd();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -767,6 +767,7 @@ export default class InstancesEditor extends Component<Props> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_onOverInstance = (instance: gdInitialInstance) => {
|
_onOverInstance = (instance: gdInitialInstance) => {
|
||||||
|
console.log('_onOverInstance');
|
||||||
if (!this.instancesMover.isMoving())
|
if (!this.instancesMover.isMoving())
|
||||||
this.highlightedInstance.setInstance(instance);
|
this.highlightedInstance.setInstance(instance);
|
||||||
};
|
};
|
||||||
|
@@ -72,15 +72,12 @@ type InternalCustomDragLayerProps = {|
|
|||||||
isDragging?: boolean,
|
isDragging?: boolean,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
const shouldHidePreviewBecauseDraggingOnSceneEditorCanvas = ({
|
export const isMouseOnSceneEditorCanvas = ({ x, y }: XYCoord) => {
|
||||||
x,
|
|
||||||
y,
|
|
||||||
}: XYCoord) => {
|
|
||||||
const swipeableDrawerContainer = document.querySelector(
|
const swipeableDrawerContainer = document.querySelector(
|
||||||
`#${swipeableDrawerContainerId}`
|
`#${swipeableDrawerContainerId}`
|
||||||
);
|
);
|
||||||
// If the swipeable drawer exists, we are on mobile, and we want to show the preview
|
// If the swipeable drawer exists, we are on mobile, and we consider that if we are not on
|
||||||
// only when the user is dragging in the drawer, otherwise they are on the canvas.
|
// the drawer, we are on the canvas.
|
||||||
// (the drawer is on top of the canvas)
|
// (the drawer is on top of the canvas)
|
||||||
if (swipeableDrawerContainer) {
|
if (swipeableDrawerContainer) {
|
||||||
const drawerRect = swipeableDrawerContainer.getBoundingClientRect();
|
const drawerRect = swipeableDrawerContainer.getBoundingClientRect();
|
||||||
@@ -90,13 +87,14 @@ const shouldHidePreviewBecauseDraggingOnSceneEditorCanvas = ({
|
|||||||
y >= drawerRect.top &&
|
y >= drawerRect.top &&
|
||||||
y <= drawerRect.bottom
|
y <= drawerRect.bottom
|
||||||
) {
|
) {
|
||||||
|
// Inside the drawer, not on the canvas.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Outside the drawer, on the canvas.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, we are on desktop, and we want to hide the preview when the user
|
// Otherwise, we are on desktop, so we can check if we are on the canvas.
|
||||||
// is dragging on the canvas.
|
|
||||||
const activeCanvas = document.querySelector(
|
const activeCanvas = document.querySelector(
|
||||||
`#scene-editor[data-active=true] #${instancesEditorId}`
|
`#scene-editor[data-active=true] #${instancesEditorId}`
|
||||||
);
|
);
|
||||||
@@ -108,9 +106,12 @@ const shouldHidePreviewBecauseDraggingOnSceneEditorCanvas = ({
|
|||||||
y >= canvasRect.top &&
|
y >= canvasRect.top &&
|
||||||
y <= canvasRect.bottom
|
y <= canvasRect.bottom
|
||||||
) {
|
) {
|
||||||
|
// Inside the canvas.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Otherwise, we are not on the canvas.
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -127,7 +128,9 @@ const CustomDragLayer = ({
|
|||||||
() => {
|
() => {
|
||||||
if (!item || !clientOffset) return null;
|
if (!item || !clientOffset) return null;
|
||||||
|
|
||||||
if (shouldHidePreviewBecauseDraggingOnSceneEditorCanvas(clientOffset)) {
|
// We don't want to show the preview if the mouse is on the scene editor canvas,
|
||||||
|
// as we already have the instance dragged.
|
||||||
|
if (isMouseOnSceneEditorCanvas(clientOffset)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user