Skip to content

Commit

Permalink
Make error case not bugging
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreSi committed Sep 16, 2024
1 parent 4e4af17 commit c3d3fc8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Extensions/TileMap/JsExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -2338,7 +2338,9 @@ module.exports = {
? this._editableTileMap.isEmpty()
: false;
let objectToChange;
if (isTileMapEmpty || !atlasImageResourceName) {
if (this.errorPixiObject) {
objectToChange = this.errorPixiObject;
} else if (isTileMapEmpty || !atlasImageResourceName) {
this.tileMapPixiObject.visible = false;
this._placeholderPixiObject.visible = true;
this._placeholderTextPixiObject.text = !atlasImageResourceName
Expand Down
12 changes: 7 additions & 5 deletions newIDE/app/src/InstancesEditor/TileMapPaintingPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ export const updateSceneToTileMapTransformation = (
scaleY = 1;
if (instance.hasCustomSize()) {
const editableTileMap = renderedInstance.getEditableTileMap();
if (!editableTileMap) {
if (editableTileMap) {
scaleX = instance.getCustomWidth() / editableTileMap.getWidth();
scaleY = instance.getCustomHeight() / editableTileMap.getHeight();
} else {
console.error(
`Could not find the editable tile map for instance of object ${instance.getObjectName()}.`
`Could not find the editable tile map for instance of object ${instance.getObjectName()}. Make sure the tile map object is correctly configured.`
);
return;
// Do not early return on error to make the preview still working to not give
// a sense of something broken.
}
scaleX = instance.getCustomWidth() / editableTileMap.getWidth();
scaleY = instance.getCustomHeight() / editableTileMap.getHeight();
}
const absScaleX = Math.abs(scaleX);
const absScaleY = Math.abs(scaleY);
Expand Down
1 change: 1 addition & 0 deletions newIDE/app/src/ObjectEditor/Editors/SimpleTileMapEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const SimpleTileMapEditor = ({
const onChangeAtlasImage = React.useCallback(
() => {
if (onObjectUpdated) onObjectUpdated();
setError(null);
onSizeUpdated();
forceUpdate();
},
Expand Down

0 comments on commit c3d3fc8

Please sign in to comment.