Skip to content

Commit

Permalink
Fix default tilesetId for replace tile events
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismaltby committed Apr 4, 2024
1 parent 6ae74a3 commit b68418b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/script/AddScriptEventMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
musicSelectors,
sceneSelectors,
spriteSheetSelectors,
tilesetSelectors,
} from "store/features/entities/entitiesState";
import { useDebounce } from "ui/hooks/use-debounce";
import { ScriptEditorContext } from "./ScriptEditorContext";
Expand Down Expand Up @@ -72,6 +73,7 @@ interface InstanciateOptions {
defaultActorId: string;
defaultSpriteId: string;
defaultEmoteId: string;
defaultTilesetId: string;
defaultArgs?: Record<string, unknown>;
}

Expand All @@ -89,6 +91,7 @@ const instanciateScriptEvent = (
defaultActorId,
defaultSpriteId,
defaultEmoteId,
defaultTilesetId,
defaultArgs,
}: InstanciateOptions
): Omit<ScriptEventNormalized, "id"> => {
Expand Down Expand Up @@ -130,6 +133,8 @@ const instanciateScriptEvent = (
replaceValue = defaultSpriteId;
} else if (defaultValue === "LAST_EMOTE") {
replaceValue = defaultEmoteId;
} else if (defaultValue === "LAST_TILESET") {
replaceValue = defaultTilesetId;
} else if (defaultValue === "LAST_ACTOR") {
replaceValue = defaultActorId;
} else if (field.type === "events") {
Expand Down Expand Up @@ -462,6 +467,9 @@ const AddScriptEventMenu = ({
const lastEmoteId = useAppSelector(
(state) => emoteSelectors.selectIds(state)[0]
);
const lastTilesetId = useAppSelector(
(state) => tilesetSelectors.selectIds(state)[0]
);
const context = useContext(ScriptEditorContext);
const scriptEventDefs = useAppSelector((state) =>
selectScriptEventDefs(state)
Expand Down Expand Up @@ -639,6 +647,7 @@ const AddScriptEventMenu = ({
defaultSceneId: String(lastSceneId),
defaultSpriteId: String(lastSpriteId),
defaultEmoteId: String(lastEmoteId),
defaultTilesetId: String(lastTilesetId),
defaultArgs,
}),
],
Expand All @@ -652,6 +661,7 @@ const AddScriptEventMenu = ({
dispatch,
insertId,
lastEmoteId,
lastTilesetId,
lastMusicId,
lastSceneId,
lastSpriteId,
Expand Down
1 change: 1 addition & 0 deletions src/lib/events/eventReplaceTileXY.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const fields = [
type: "tileset",
label: l10n("FIELD_TILESET"),
description: l10n("FIELD_TILESET_DESC"),
defaultValue: "LAST_TILESET",
},
{
key: "tileIndex",
Expand Down
1 change: 1 addition & 0 deletions src/lib/events/eventReplaceTileXYSequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const fields = [
type: "tileset",
label: l10n("FIELD_TILESET"),
description: l10n("FIELD_TILESET_DESC"),
defaultValue: "LAST_TILESET",
},
{
type: "group",
Expand Down

0 comments on commit b68418b

Please sign in to comment.