@@ -12,6 +12,7 @@ import FlatButton from '../../../UI/FlatButton';
1212import RaisedButton from '../../../UI/RaisedButton' ;
1313import { mapFor } from '../../../Utils/MapFor' ;
1414import SemiControlledTextField from '../../../UI/SemiControlledTextField' ;
15+ import Text from '../../../UI/Text' ;
1516import Dialog from '../../../UI/Dialog' ;
1617import HelpButton from '../../../UI/HelpButton' ;
1718import MiniToolbar , { MiniToolbarText } from '../../../UI/MiniToolbar' ;
@@ -30,7 +31,7 @@ import {
3031} from './Utils/SpriteObjectHelper' ;
3132import { type EditorProps } from '../EditorProps.flow' ;
3233import { type ResourceManagementProps } from '../../../ResourcesList/ResourceSource' ;
33- import { Column } from '../../../UI/Grid' ;
34+ import { Column , Line } from '../../../UI/Grid' ;
3435import { ResponsiveLineStackLayout } from '../../../UI/Layout' ;
3536import ScrollView from '../../../UI/ScrollView' ;
3637import Checkbox from '../../../UI/Checkbox' ;
@@ -58,6 +59,7 @@ type AnimationProps = {|
5859 ) => void ,
5960 objectName : string ,
6061 onChangeName : string => void ,
62+ isAnimationListLocked : boolean ,
6163| } ;
6264
6365class Animation extends React . Component < AnimationProps , void > {
@@ -75,50 +77,62 @@ class Animation extends React.Component<AnimationProps, void> {
7577 onReplaceDirection,
7678 objectName,
7779 onChangeName,
80+ isAnimationListLocked,
7881 } = this . props ;
7982
8083 const animationName = animation . getName ( ) ;
8184 return (
82- < div >
83- < MiniToolbar noPadding >
84- < DragHandle />
85- < MiniToolbarText > Animation #{ id } </ MiniToolbarText >
86- < Column expand >
87- < SemiControlledTextField
88- commitOnBlur
89- margin = "none"
90- value = { animation . getName ( ) }
91- translatableHintText = { t `Optional animation name` }
92- onChange = { text => onChangeName ( text ) }
93- fullWidth
94- />
95- </ Column >
96- < IconButton size = "small" onClick = { onRemove } >
97- < Delete />
98- </ IconButton >
99- </ MiniToolbar >
100- { mapFor ( 0 , animation . getDirectionsCount ( ) , i => {
101- const direction = animation . getDirection ( i ) ;
102- return (
103- < SpritesList
104- direction = { direction }
105- key = { i }
106- project = { project }
107- resourcesLoader = { resourcesLoader }
108- resourceManagementProps = { resourceManagementProps }
109- onSpriteContextMenu = { onSpriteContextMenu }
110- selectedSprites = { selectedSprites }
111- onSelectSprite = { onSelectSprite }
112- onReplaceByDirection = { newDirection =>
113- onReplaceDirection ( i , newDirection )
114- }
115- objectName = { objectName }
116- animationName = { animationName }
117- onChangeName = { onChangeName }
118- />
119- ) ;
120- } ) }
121- </ div >
85+ < Line expand >
86+ < Column expand noMargin >
87+ { isAnimationListLocked && (
88+ < Column expand noMargin >
89+ < Text size = "block-title" > { animation . getName ( ) } </ Text >
90+ </ Column >
91+ ) }
92+ { ! isAnimationListLocked && (
93+ < MiniToolbar noPadding >
94+ < DragHandle />
95+ < MiniToolbarText >
96+ { < Trans > Animation #{ id } </ Trans > }
97+ </ MiniToolbarText >
98+ < Column expand >
99+ < SemiControlledTextField
100+ commitOnBlur
101+ margin = "none"
102+ value = { animation . getName ( ) }
103+ translatableHintText = { t `Optional animation name` }
104+ onChange = { text => onChangeName ( text ) }
105+ fullWidth
106+ />
107+ </ Column >
108+ < IconButton size = "small" onClick = { onRemove } >
109+ < Delete />
110+ </ IconButton >
111+ </ MiniToolbar >
112+ ) }
113+ { mapFor ( 0 , animation . getDirectionsCount ( ) , i => {
114+ const direction = animation . getDirection ( i ) ;
115+ return (
116+ < SpritesList
117+ direction = { direction }
118+ key = { i }
119+ project = { project }
120+ resourcesLoader = { resourcesLoader }
121+ resourceManagementProps = { resourceManagementProps }
122+ onSpriteContextMenu = { onSpriteContextMenu }
123+ selectedSprites = { selectedSprites }
124+ onSelectSprite = { onSelectSprite }
125+ onReplaceByDirection = { newDirection =>
126+ onReplaceDirection ( i , newDirection )
127+ }
128+ objectName = { objectName }
129+ animationName = { animationName }
130+ onChangeName = { onChangeName }
131+ />
132+ ) ;
133+ } ) }
134+ </ Column >
135+ </ Line >
122136 ) ;
123137 }
124138}
@@ -140,6 +154,7 @@ const SortableAnimationsList = SortableContainer(
140154 selectedSprites,
141155 onSelectSprite,
142156 onReplaceDirection,
157+ isAnimationListLocked,
143158 } ) => {
144159 // Note that it's important to have <ScrollView> *inside* this
145160 // component, otherwise the sortable list won't work (because the
@@ -150,6 +165,7 @@ const SortableAnimationsList = SortableContainer(
150165 const animation = spriteConfiguration . getAnimation ( i ) ;
151166 return (
152167 < SortableAnimation
168+ isAnimationListLocked = { isAnimationListLocked }
153169 key = { i }
154170 index = { i }
155171 id = { i }
@@ -183,6 +199,7 @@ type AnimationsListContainerProps = {|
183199 onSizeUpdated : ( ) => void ,
184200 objectName : string ,
185201 onObjectUpdated ?: ( ) => void ,
202+ isAnimationListLocked : boolean ,
186203| } ;
187204
188205type AnimationsListContainerState = { |
@@ -322,6 +339,7 @@ class AnimationsListContainer extends React.Component<
322339 < React . Fragment >
323340 < SpacedDismissableTutorialMessage />
324341 < SortableAnimationsList
342+ isAnimationListLocked = { this . props . isAnimationListLocked }
325343 spriteConfiguration = { this . props . spriteConfiguration }
326344 objectName = { this . props . objectName }
327345 helperClass = "sortable-helper"
@@ -345,12 +363,14 @@ class AnimationsListContainer extends React.Component<
345363 noColumnMargin
346364 >
347365 { this . props . extraBottomTools }
348- < RaisedButton
349- label = { < Trans > Add an animation</ Trans > }
350- primary
351- onClick = { this . addAnimation }
352- icon = { < Add /> }
353- />
366+ { ! this . props . isAnimationListLocked && (
367+ < RaisedButton
368+ label = { < Trans > Add an animation</ Trans > }
369+ primary
370+ onClick = { this . addAnimation }
371+ icon = { < Add /> }
372+ />
373+ ) }
354374 </ ResponsiveLineStackLayout >
355375 </ Column >
356376 < ContextMenu
@@ -375,14 +395,41 @@ class AnimationsListContainer extends React.Component<
375395 }
376396}
377397
378- export default function SpriteEditor ( {
398+ export function LockedSpriteEditor ( {
379399 objectConfiguration,
380400 project,
381401 resourceManagementProps,
382402 onSizeUpdated,
383403 onObjectUpdated,
384404 objectName,
385405} : EditorProps ) {
406+ return (
407+ < SpriteEditor
408+ isAnimationListLocked
409+ objectConfiguration = { objectConfiguration }
410+ project = { project }
411+ resourceManagementProps = { resourceManagementProps }
412+ onSizeUpdated = { onSizeUpdated }
413+ onObjectUpdated = { onObjectUpdated }
414+ objectName = { objectName }
415+ />
416+ ) ;
417+ }
418+
419+ type SpriteEditorProps = { |
420+ ...EditorProps ,
421+ isAnimationListLocked ?: boolean ,
422+ | } ;
423+
424+ export default function SpriteEditor ( {
425+ objectConfiguration,
426+ project,
427+ resourceManagementProps,
428+ onSizeUpdated,
429+ onObjectUpdated,
430+ objectName,
431+ isAnimationListLocked = false ,
432+ } : SpriteEditorProps ) {
386433 const [ pointsEditorOpen , setPointsEditorOpen ] = React . useState ( false ) ;
387434 const [ advancedOptionsOpen , setAdvancedOptionsOpen ] = React . useState ( false ) ;
388435 const [
@@ -395,6 +442,7 @@ export default function SpriteEditor({
395442 return (
396443 < >
397444 < AnimationsListContainer
445+ isAnimationListLocked = { isAnimationListLocked }
398446 spriteConfiguration = { spriteConfiguration }
399447 resourcesLoader = { ResourcesLoader }
400448 resourceManagementProps = { resourceManagementProps }
@@ -410,18 +458,22 @@ export default function SpriteEditor({
410458 onClick = { ( ) => setCollisionMasksEditorOpen ( true ) }
411459 disabled = { spriteConfiguration . getAnimationsCount ( ) === 0 }
412460 />
413- < RaisedButton
414- label = { < Trans > Edit points</ Trans > }
415- primary = { false }
416- onClick = { ( ) => setPointsEditorOpen ( true ) }
417- disabled = { spriteConfiguration . getAnimationsCount ( ) === 0 }
418- />
419- < FlatButton
420- label = { < Trans > Advanced options</ Trans > }
421- primary = { false }
422- onClick = { ( ) => setAdvancedOptionsOpen ( true ) }
423- disabled = { spriteConfiguration . getAnimationsCount ( ) === 0 }
424- />
461+ { ! isAnimationListLocked && (
462+ < RaisedButton
463+ label = { < Trans > Edit points</ Trans > }
464+ primary = { false }
465+ onClick = { ( ) => setPointsEditorOpen ( true ) }
466+ disabled = { spriteConfiguration . getAnimationsCount ( ) === 0 }
467+ />
468+ ) }
469+ { ! isAnimationListLocked && (
470+ < FlatButton
471+ label = { < Trans > Advanced options</ Trans > }
472+ primary = { false }
473+ onClick = { ( ) => setAdvancedOptionsOpen ( true ) }
474+ disabled = { spriteConfiguration . getAnimationsCount ( ) === 0 }
475+ />
476+ ) }
425477 </ ResponsiveLineStackLayout >
426478 }
427479 />
0 commit comments