Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | import React, { FC, useCallback } from "react"; import { FormContainer, FormField, FormRow } from "ui/form/layout/FormLayout"; import entitiesActions from "store/features/entities/entitiesActions"; import { ActorNormalized, CollisionGroup, } from "shared/lib/entities/entitiesTypes"; import { SidebarColumn } from "ui/sidebars/Sidebar"; import { SpriteSheetSelectButton } from "components/forms/SpriteSheetSelectButton"; import { AnimationSpeedSelect } from "components/forms/AnimationSpeedSelect"; import { MovementSpeedSelect } from "components/forms/MovementSpeedSelect"; import CollisionMaskPicker from "components/forms/CollisionMaskPicker"; import l10n from "shared/lib/lang/l10n"; import { useAppDispatch } from "store/hooks"; interface ActorEditorPropertiesProps { actor: ActorNormalized; } export const ActorEditorProperties: FC<ActorEditorPropertiesProps> = ({ actor, }) => { const dispatch = useAppDispatch(); const onChangeActorProp = useCallback( <K extends keyof ActorNormalized>(key: K, value: ActorNormalized[K]) => { dispatch( entitiesActions.editActor({ actorId: actor.id, changes: { [key]: value, }, }) ); }, [dispatch, actor.id] ); const onChangeSpriteSheetId = useCallback( (e: string) => onChangeActorProp("spriteSheetId", e), [onChangeActorProp] ); const onChangeMoveSpeed = useCallback( (e: number) => onChangeActorProp("moveSpeed", e), [onChangeActorProp] ); const onChangeAnimSpeed = useCallback( (e: number) => onChangeActorProp("animSpeed", e), [onChangeActorProp] ); const onChangeCollisionGroup = useCallback( (e: CollisionGroup) => onChangeActorProp("collisionGroup", e), [onChangeActorProp] ); Iif (!actor) { return <div />; } const showAnimSpeed = true; const showCollisionGroup = !actor.isPinned; return ( <> <SidebarColumn> <FormContainer> <FormRow> <FormField name="actorSprite" label={l10n("FIELD_SPRITE_SHEET")}> <SpriteSheetSelectButton name="actorSprite" value={actor.spriteSheetId} direction={actor.direction} frame={0} onChange={onChangeSpriteSheetId} includeInfo /> </FormField> </FormRow> </FormContainer> </SidebarColumn> <SidebarColumn> <FormContainer> <FormRow> <FormField name="actorMoveSpeed" label={l10n("FIELD_MOVEMENT_SPEED")} > <MovementSpeedSelect name="actorMoveSpeed" value={actor.moveSpeed} onChange={onChangeMoveSpeed} /> </FormField> {showAnimSpeed && ( <FormField name="actorAnimSpeed" label={l10n("FIELD_ANIMATION_SPEED")} > <AnimationSpeedSelect name="actorAnimSpeed" value={actor.animSpeed} onChange={onChangeAnimSpeed} /> </FormField> )} </FormRow> </FormContainer> </SidebarColumn> {showCollisionGroup && ( <SidebarColumn> <FormContainer> <FormRow> <FormField name="actorCollisionGroup" label={l10n("FIELD_COLLISION_GROUP")} > <CollisionMaskPicker id="actorCollisionGroup" value={actor.collisionGroup} onChange={onChangeCollisionGroup} includeNone /> </FormField> </FormRow> </FormContainer> </SidebarColumn> )} </> ); }; |