Skip to content

Commit 4bab712

Browse files
author
minhnq
committed
fix: checkWall, checkMove and import Skin duplicate key
1 parent b0e2a10 commit 4bab712

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/app/aneko-builder/components/StateList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ export default function StateList({ onEditState }: StateListProps) {
101101
<div className={styles.panelContent}>
102102
{state.skinData.states.length > 0 ? (
103103
<div className={styles.stateList}>
104-
{state.skinData.states.map((motionState) => {
104+
{state.skinData.states.map((motionState, index) => {
105105
const isRequired = isRequiredState(motionState.state);
106106
return (
107107
<div
108-
key={motionState.state}
108+
key={`${motionState.state}-${index}`}
109109
className={`${styles.stateItem} ${state.selectedStateId === motionState.state ? styles.selected : ''}`}
110110
onClick={() => selectState(motionState.state)}
111111
>

src/lib/utils/skinExport.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ function generateSkinXml(skinData: SkinData): string {
2525

2626
// Build motion elements
2727
const motions = states.map(state => {
28-
const motionAttrs: Record<string, unknown> = {
28+
const motionAttrs: Record<string, string> = {
2929
'@_state': state.state,
3030
};
3131

32-
if (state.checkMove) motionAttrs['@_checkMove'] = 'true';
33-
if (state.checkWall) motionAttrs['@_checkWall'] = 'true';
32+
// Only add boolean attributes if they are truthy
33+
// Use Boolean() to handle any edge cases from various data sources
34+
if (Boolean(state.checkMove)) motionAttrs['@_checkMove'] = 'true';
35+
if (Boolean(state.checkWall)) motionAttrs['@_checkWall'] = 'true';
3436
if (state.nextState) motionAttrs['@_nextState'] = state.nextState;
3537

3638
const children = buildAnimationItems(state.items);
@@ -66,6 +68,7 @@ function generateSkinXml(skinData: SkinData): string {
6668
format: true,
6769
indentBy: ' ',
6870
suppressEmptyNode: true,
71+
suppressBooleanAttributes: false,
6972
});
7073

7174
return builder.build(xmlObj);

0 commit comments

Comments
 (0)