Skip to content

Commit

Permalink
Merge pull request #1652 from pau-tomas/fix/checkbox-engine-field
Browse files Browse the repository at this point in the history
Fix checkbox not working on engine fields
  • Loading branch information
chrismaltby authored Nov 27, 2024
2 parents de1625e + 6627218 commit dc78420
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix issue where changing the dimensions of a sprite png image could cause the sprite editor's tile palette to display incorrectly
- Fix line numbers in code editor for GBVM scripts with more than 999 lines
- Fix issue preventing projects being created with the name "project"
- Fix issue preventing checkbox type working in engine fields [@pau-tomas](https://github.com/pau-tomas)
- Fix UI palette text control code. Palette indices now go from 1 to 8, because zero byte is a string terminator [@untoxa](https://github.com/untoxa)
- Fix issue where migrating old projects could cause gbvm symbols to become empty, preventing build from completing (opening a broken project will now automatically fix this issue)

Expand Down
6 changes: 2 additions & 4 deletions src/components/settings/EngineFieldsEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,12 @@ export const EngineFieldInput: FC<EngineFieldInputProps> = ({
);
}
if (field.type === "checkbox") {
const theValue =
typeof value === "boolean" ? Boolean(value) : Boolean(field.defaultValue);
return (
<Checkbox
id={field.key}
name={field.key}
checked={theValue}
onChange={(e) => onChange(e.currentTarget.checked)}
checked={value === 1 ? true : false}
onChange={(e) => onChange(e.currentTarget.checked === true ? 1 : 0)}
/>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/lib/entities/entitiesTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export type CustomEventNormalized = Omit<CustomEvent, "script"> & {

export type EngineFieldValue = {
id: string;
value?: number | string | boolean | undefined;
value?: number | string | undefined;
};

export type MetaspriteTile = {
Expand Down
4 changes: 1 addition & 3 deletions src/shared/lib/resources/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,7 @@ export type VariablesResource = Static<typeof VariablesResource>;

export const EngineFieldValueData = Type.Object({
id: Type.String(),
value: Type.Optional(
Type.Union([Type.String(), Type.Boolean(), Type.Number()])
),
value: Type.Optional(Type.Union([Type.String(), Type.Number()])),
});

export type EngineFieldValueData = Static<typeof EngineFieldValueData>;
Expand Down
2 changes: 1 addition & 1 deletion src/store/features/entities/entitiesState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4171,7 +4171,7 @@ const editEngineFieldValue: CaseReducer<
EntitiesState,
PayloadAction<{
engineFieldId: string;
value: string | number | boolean | undefined;
value: string | number | undefined;
}>
> = (state, action) => {
engineFieldValuesAdapter.upsertOne(state.engineFieldValues, {
Expand Down

0 comments on commit dc78420

Please sign in to comment.