'From Squeakland 3.8.5976 of 25 August 2004 [latest update: #387] on 28 January 2005 at 1:57:53 am'! "Change Set: suppressSounds-sw Date: 29 January 2005 Author: Scott Wallace Allows certain of the standard 'built-in' sounds to be suppressed from sound-choice popups except when they are the current choice. This affects both SoundTiles and SoundReadoutTiles. The list of formerly-standard sounds that should be suppressed is hard-coded in method StandardScriptingSystem.soundNamesToSuppress; for now, these are 'scrape' and 'peaks'."! !SoundTile commentStamp: 'sw 1/28/2005 01:42' prior: 0! A scripting tile representing a 'sound' constant. Sounds are represented by their names, which are strings; the actual sounds live in SampleSound's SoundLibrary.! !StandardScriptingSystem methodsFor: 'utilities' stamp: 'sw 1/28/2005 01:34'! soundNamesToSuppress "Answer a list of sound-names that are not to be offered in sound-choice pop-ups unless they are the current choice" ^ #('scrape' 'peaks')! ! !TileMorph methodsFor: 'misc' stamp: 'sw 1/28/2005 00:54'! soundChoices "Answer a list of sound choices. This applies only to tiles that have sound-names as their literals, viz. SoundTiles and SoundReadoutTiles." | aList | aList _ SoundService default sampledSoundChoices asOrderedCollection. aList removeAllFoundIn: (ScriptingSystem soundNamesToSuppress copyWithout: literal). ^ aList asSortedArray! ! !SoundReadoutTile methodsFor: 'arrows' stamp: 'sw 1/28/2005 00:57'! arrowAction: delta "Do what is appropriate when an arrow on the tile is pressed; delta will be +1 or -1" | soundChoices index | soundChoices _ self soundChoices. index _ soundChoices indexOf: literal. self literal: (soundChoices atWrap: (index + delta)). self playSoundNamed: literal! ! !SoundReadoutTile methodsFor: 'arrows' stamp: 'sw 1/28/2005 00:56'! mouseDown: evt "Handle a mouse down event" | aPoint index isUp soundChoices adjustment | upArrow ifNotNil: [((isUp _ upArrow containsPoint: (aPoint _ evt cursorPoint)) or: [downArrow containsPoint: aPoint]) ifTrue: [soundChoices _ self soundChoices. index _ soundChoices indexOf: literal ifAbsent: [1]. index > 0 ifTrue: [adjustment _ isUp ifTrue: [1] ifFalse: [-1]. self literal: (soundChoices atWrap: (index + adjustment))]. self playSoundNamed: literal. ^ self]]. self soundNameFromUser ifNotNilDo: [:aSoundName | self literal: aSoundName. self playSoundNamed: literal]! ! !SoundReadoutTile methodsFor: 'arrows' stamp: 'sw 1/28/2005 00:59'! soundNameFromUser "Obtain a sound from the user. Exclude the items designated as being discouraged, except that if the current selection is one of those, show it anyway" ^ (SelectionMenu selections: self soundChoices) startUpWithCaption: 'Sounds' translated! ! !SoundReadoutTile methodsFor: 'literal' stamp: 'sw 1/28/2005 00:57'! setLiteralTo: anObject width: w "Set the literal and width of the tile as indicated" | soundChoices index | soundChoices _ self soundChoices. index _ soundChoices indexOf: anObject. self setLiteral: (soundChoices atWrap: index)! ! !SoundTile methodsFor: 'event handling' stamp: 'sw 1/28/2005 01:49'! options "Answer the options of the tile for an arrow" | soundChoices | soundChoices _ self soundChoices. ^ {soundChoices. soundChoices}! ! !SoundTile methodsFor: 'initialization' stamp: 'sw 1/28/2005 01:00'! initialize "Initialize the state of the receiver. Pick the croak sound if available, otherwise any sound." | soundChoices startingSoundName | super initialize. soundChoices _ self soundChoices. startingSoundName _ (soundChoices includes: 'croak') ifTrue: ['croak'] ifFalse: [[soundChoices anyOne] ifError: ['silence']]. self addArrows; setLiteral: startingSoundName. self labelMorph useStringFormat! ! AbstractSoundSystem removeSelector: #soundNameFromUser!