import SpriteSettingsResource from "../data/SpriteSettingsResource" ; export default class SpriteSettingsEditor { projectClient : SupClient . ProjectClient ; resource : SpriteSettingsResource ; filteringRow : SupClient . table . RowParts ; fpsRow : SupClient . table . RowParts ; pixelsPerUnitRow : SupClient . table . RowParts ; alphaTestRow : SupClient . table . RowParts ; fields : { [ name ] : HTMLInputElement | HTMLSelectElement ; } = { } ; constructor ( container , projectClient ) { this . projectClient = projectClient ; const { tbody } = SupClient . table . createTable ( container ) ; this . filteringRow = SupClient . table . appendRow ( tbody , SupClient . i18n . t ( "settingsEditors:Sprite.filtering" ) ) ; this . fields [ "filtering" ] = SupClient . table . appendSelectBox ( this . filteringRow . valueCell , { pixelated : SupClient . i18n . t ( "settingsEditors:Sprite.pixelated" ) , smooth : SupClient . i18n . t ( "settingsEditors:Sprite.smooth" ) } ) ; this . fpsRow = SupClient . table . appendRow ( tbody , SupClient . i18n . t ( "settingsEditors:Sprite.framesPerSecond" ) ) ; this . fields [ "framesPerSecond" ] = SupClient . table . appendNumberField ( this . fpsRow . valueCell , "" ) ; this . pixelsPerUnitRow = SupClient . table . appendRow ( tbody , SupClient . i18n . t ( "settingsEditors:Sprite.pixelsPerUnit" ) ) ; this . fields [ "pixelsPerUnit" ] = SupClient . table . appendNumberField ( this . pixelsPerUnitRow . valueCell , "" ) ; this . alphaTestRow = SupClient . table . appendRow ( tbody , SupClient . i18n . t ( "settingsEditors:Sprite.alphaTesting" ) ) ; this . fields [ "alphaTest" ] = SupClient . table . appendNumberField ( this . alphaTestRow . valueCell , "" ) ; this . fields [ "filtering" ] . addEventListener ( "change" , ( event ) => { this . projectClient . editResource ( "spriteSettings" , "setProperty" , "filtering" , event . target . value ) ; } ) ; this . fields [ "framesPerSecond" ] . addEventListener ( "change" , ( event ) => { this . projectClient . editResource ( "spriteSettings" , "setProperty" , "framesPerSecond" , parseInt ( event . target . value , 10 ) ) ; } ) ; this . fields [ "pixelsPerUnit" ] . addEventListener ( "change" , ( event ) => { this . projectClient . editResource ( "spriteSettings" , "setProperty" , "pixelsPerUnit" , parseInt ( event . target . value , 10 ) ) ; } ) ; this . fields [ "alphaTest" ] . addEventListener ( "change" , ( event ) => { this . projectClient . editResource ( "spriteSettings" , "setProperty" , "alphaTest" , parseFloat ( event . target . value ) ) ; } ) ; this . projectClient . subResource ( "spriteSettings" , this ) ; } onResourceReceived = ( resourceId , resource ) => { this . resource = resource ; for ( const setting in resource . pub ) { this . fields [ setting ] . value = resource . pub [ setting ] ; } } ; onResourceEdited = ( resourceId , command , propertyName ) => { this . fields [ propertyName ] . value = this . resource . pub [ propertyName ] ; } ; }