'From Squeak3.2alpha of 3 October 2001 [latest update: #4451] on 29 October 2001 at 5:41:38 am'! "Change Set: scriptingCategory-sw Date: 29 October 2001 -- Manually Patched sw 10/29/2001 06:07 Author: Scott Wallace The 'miscellaneous' category was getting unwieldy in the etoy viewer, so the items that related to starting and stopping scripts are now moved off to their own 'scripting' category. (Caution: order is essential in this fileout)"! !Morph class methodsFor: 'scripting' stamp: 'sw 10/29/2001 05:27'! additionsToViewerCategoryScripting "Answer viewer additions for the 'scripting' category" ^#( scripting ( (command startScript: 'start the given script ticking' String) (command pauseScript: 'make the given script be "paused"' String) (command stopScript: 'make the given script be "normal"' String) (command startAll: 'start the given script ticking in the object and all of its siblings.' String) (command pauseAll: 'make the given script be "paused" in the object and all of its siblings' String) (command stopAll: 'make the given script be "normal" in the object and all of its siblings' String) (command doScript: 'run the given script once, on the next tick' String) (command tellAllSiblings: 'send a message to all siblings' String) ) ) ! ! !EToyVocabulary methodsFor: 'initialization' stamp: 'sw 10/29/2001 05:26'! setCategoryDocumentationStrings "Initialize the documentation strings associated with the old etoy categories, in English" self translateCategories: #( (basic 'basic' 'a few important things') (#'book navigation' 'book navigation' 'relating to book, stacks, etc') (button 'button' 'for thinking of this object as a push-button control') (collections 'collections' 'for thinking of this object as a collection') (fog 'fog' '3D fog') (geometry 'geometry' 'measurements and coordinates') (#'color & border' 'color & border' 'matters concerning the colors and borders of objects') (graphics 'graphics' 'for thinking of this object as a picture') (#'instance variables' 'instance variables' 'instance variables added by this object') (joystick 'joystick ' 'the object as a Joystick') (miscellaneous 'miscellaneous' 'various commands') (motion 'motion' 'matters relating to moving and turning') (paintbox 'paintbox' 'the painting palette') (#'pen trails' 'pen trails' 'relating to trails put down by pens') (#'pen use' 'pen use' 'use of an object''s "pen"') (playfield 'playfield' 'the object as a container for other visible objects') (sampling 'sampling' 'sampling') (scripting 'scripting' 'commands to start and stop scripts') (scripts 'scripts' 'methods added by this object') (slider 'slider' 'functions useful to sliders') (speaker 'speaker' 'the object as an audio Speaker') (#'stack navigation' 'stack navigation' 'navigation within a stck') (storyboard 'storyboard' 'storyboard') (tests 'tests' 'yes/no tests, to use in "Test" panes of scripts') (text 'text' 'The object as text') (vector 'vector' 'The object as a vector') (viewing 'viewing' 'matters relating to viewing') ) language: #English ! ! !EToyVocabulary methodsFor: 'language translations' stamp: 'sw 10/29/2001 05:36'! templateForLanguageTranslation "Edit this method such that the second element of each triplet has the translated wording and the third element has the translated help-message; give the edited method a name of the form #addLangVocabulary, and be sure to change the language name in the three places that it occurs, as #YourLanguage, below. A complete translation consists, as in #addKiswahiliVocabulary, of calls to three methods, namely: translateMethodInterfaceWordings:language: translateCategories:language: addToTranslationTableFrom:language: After editing this method into the one that holds your language translations, the next step is to edit #assureTranslationsAvailableFor: so that it calls the method you just created when appropriate. Consult #addKiswahiliVocabulary and its sender for a complete example to emulate." self translateMethodInterfaceWordings: #( (append: 'append' 'Add the object to my content') (beep: 'make sound' 'Make the specified sound') (bounce: 'bounce' 'bounce off the edge if hit') (cameraPoint #cameraPoint 'the camera point') (clear 'clear' 'Clear the graph of current contents') (clearOwnersPenTrails 'clear all pen trails' 'clear all pen trails in my containing playfield') (clearTurtleTrails 'clear pen trails' 'Clear all the pen trails in the interior.') (color:sees: 'color sees' 'whether the given color sees the given color') (deleteCard 'deleteCard' 'Delete the current card') (doMenuItem: 'do menu item' 'do the menu item') (doScript: 'do' 'run the given script once, on the next tick') (emptyScript 'emptyScript' 'an empty script') (fire 'fire' 'trigger any and all of this object''s button actions') (firstPage 'firstPage' 'go to first page') (followPath 'followPath' 'follow the yellow brick road') (forward: 'forward by' 'Moves the object forward in the direction it is heading') (getActWhen #actWhen 'When the script should fire') (getAllButFirstCharacter #allButFirst 'All my characters except the first one') (getAmount #amount 'The amount of displacement') (getAngle #angle 'The angular displacement') (getBorderColor #borderColor 'The color of the object''s border') (getBorderWidth #borderWidth 'The width of the object''s border') (getBottom #bottom 'The bottom edge') (getBrightnessUnder #brightnessUnder 'The brightness under the center of the object') (getCharacters #characters 'The characters in my contents') (getColor #color 'The color of the object') (getColorUnder #colorUnder 'The color under the center of the object') (getConePosition #conePosition 'the position of the speaker cone') (getCursor #cursor 'The current cursor location, wrapped back to the beginning if appropriate') (getDescending #descending 'Tells whether the smallest value is at the top/left (descending = false) or at the bottom/right (descending = true)') (getDistance #distance 'The length of the vector connecting the origin to the object''s position') (getFirstCharacter #firstCharacter 'The first character in my contents') (getFirstElement #firstElement 'The first object in my contents') (getFogColor #fogColor 'The color of fog being applied') (getFogDensity #fogDensity 'The density of fog being applied') (getFogRangeEnd #fogRangeEnd 'The range start of fog being applied') (getFogRangeStart #fogRangeStart 'The range start of fog being applied') (getFogType #fogType 'The type of fog being applied') (getGraphic #graphic 'The picture currently being worn') (getGraphicAtCursor #graphicAtCursor 'the graphic worn by the object at the cursor') (getHeading #heading 'Which direction the object is facing. 0 is straight up') (getHeight #height 'The height') (getHolder #holder 'the object''s container') (getIndexInOwner #elementNumber 'my index in my container') (getIsUnderMouse #isUnderMouse 'whether the object is under the current mouse position') (getKnobColor #knobColor 'The color of the slider') (getLabel #label 'The wording on the button') (getLastValue #lastValue 'The last value obtained') (getLeft #left 'The left edge') (getLeftRight #leftRight 'The horizontal displacement') (getLuminanceUnder #luminanceUnder 'The luminance under the center of the object') (getMaxVal #maxVal 'The number represented when the knob is at the right or bottom of the slider; the largest value returned by the slider.') (getMinVal #minVal 'The number represented when the knob is at the left or top of the slider; the smallest value returned by the slider.') (getMouseX #mouseX 'The x coordinate of the mouse pointer') (getMouseY #mouseY 'The y coordinate of the mouse pointer') (getNewClone #copy 'returns a copy of this object') (getNumberAtCursor #numberAtCursor 'the number at the cursor') (getNumericValue #numericValue 'A number representing the current position of the knob.') (getObtrudes #obtrudes 'whether the object sticks out over its container''s edge') (getPenColor #penColor 'the color of ink used by the pen') (getPenDown #penDown 'whether the pen is currently down') (getPenSize #penSize 'the width of the pen') (getRight #right 'The right edge') (getRoundedCorners #roundedCorners 'Whether corners should be rounded') (getSampleAtCursor #sampleAtCursor 'The sample value at the current cursor location') (getSaturationUnder #saturationUnder 'The saturation under the center of the object') (getScaleFactor #scaleFactor 'The factor by which the object is magnified') (getTheta #theta 'The angle between the positive x-axis and the vector connecting the origin to the object''s position') (getTop #top 'The top edge') (getTruncate #truncate 'If true, only whole numbers are used as values; if false, fractional values are allowed.') (getUpDown #upDown 'The vertical displacement') (getValueAtCursor #playerAtCursor 'the object currently at the cursor') (getViewingByIcon #viewingNormally 'whether contents are viewed normally') (getWidth #width 'The width') (getX #x 'The x coordinate') (getY #y 'The y coordinate') (goToFirstCardInBackground 'goToFirstCardInBackground' 'Go to the first card of the current background') (goToFirstCardOfStack 'goToFirstCardOfStack' 'Go to the first card of the entire stack') (goToLastCardInBackground 'goToLastCardInBackground' 'Go to the last card of the current background') (goToLastCardOfStack 'goToLastCardOfStack' 'Go to the last card of the entire stack') (goToNextCardInStack 'goToNextCardInStack' 'Go to the next card') (goToPreviousCardInStack 'goToPreviousCardInStack' 'Go to the previous card') (goToRightOf: 'align after' 'place this object to the right of another') (goto: 'goto:' 'go to the given page') (hide 'hide' 'make the object invisible') (initiatePainting 'initiatePainting' 'Initiate painting of a new object in the standard playfield.') (insertCard 'insertCard' 'Create a new card') (lastPage 'lastPage' 'go to last page') (liftAllPens 'lift all pens' 'Lift the pens on all the objects in my interior.') (loadSineWave 'loadSineWave' 'Load a sine wave as the current graph') (loadSound: 'loadSound:' 'Load the specified sound into the current graph') (lowerAllPens 'lower all pens' 'Lower the pens on all the objects in my interior.') (makeNewDrawingIn: 'start painting in' 'make a new drawing in the specified playfield') (moveToward: 'move toward' 'move toward the given object') (nextPage 'nextPage' 'go to next page') (pauseAll: 'pause all' 'make the given script be "paused" in the object and all of its siblings') (pauseScript: 'pause script' 'make the given script be "paused"') (play 'play' 'Play the current graph as a sound') (previousPage 'previousPage' 'go to previous page') (removeAll 'removeAll' 'Remove all elements from the playfield') (reverse 'reverse' 'Reverse the graph') (roundUpStrays 'roundUpStrays' 'Bring all out-of-container subparts back into view.') (seesColor: #isOverColor 'whether any part of the object is over the given color') (show 'show' 'make the object visible') (shuffleContents 'shuffleContents' 'Shuffle the contents of the playfield') (stampAndErase 'stampAndErase' 'add my image to the pen trails and go away') (startAll: 'start All' 'start the given script ticking in the object and all of its siblings.') (startScript: 'start script' 'start the given script ticking') (stopAll: 'stop all' 'make the given script be "normal" in the object and all of its siblings') (stopScript: 'stop script' 'make the given script be "normal"') (tellAllSiblings: 'tell all siblings' 'send a message to all siblings') (touchesA: #touchesA 'whether I touch something that looks like...') (turn: 'turn by' 'Change the heading of the object by the specified amount') (unhideHiddenObjects 'unhideHiddenObjects' 'Unhide all hidden objects.') (wearCostumeOf: 'look like' 'wear the costume of...') (wrap 'wrap' 'wrap off the edge if appropriate')) language: #YourLanguage. self translateCategories: #( (basic 'basic' 'a few important things') (#'book navigation' 'book navigation' 'relating to book, stacks, etc') (button 'button' 'for thinking of this object as a push-button control') (collections 'collections' 'for thinking of this object as a collection') (fog 'fog' '3D fog') (geometry 'geometry' 'measurements and coordinates') (#'color & border' 'color & border' 'matters concerning the colors and borders of objects') (graphics 'graphics' 'for thinking of this object as a picture') (#'instance variables' 'instance variables' 'instance variables added by this object') (joystick 'joystick ' 'the object as a Joystick') (miscellaneous 'miscellaneous' 'various commands') (scripting 'scripting' 'commands to start and stop scripts, etc.') (motion 'motion' 'matters relating to moving and turning') (paintbox 'paintbox' 'the painting palette') (#'pen trails' 'pen trails' 'relating to trails put down by pens') (#'pen use' 'pen use' 'use of an object''s "pen"') (playfield 'playfield' 'the object as a container for other visible objects') (sampling 'sampling' 'sampling') (scripts 'scripts' 'methods added by this object') (slider 'slider' 'functions useful to sliders') (speaker 'speaker' 'the object as an audio Speaker') (#'stack navigation' 'stack navigation' 'navigation within a stck') (storyboard 'storyboard' 'storyboard') (tests 'tests' 'yes/no tests, to use in "Test" panes of scripts') (text 'text' 'The object as text') (viewing 'viewing' 'matters relating to viewing') (vector 'vector' 'The object as a vector') ) language: #YourLanguage. self addToTranslationTableFrom: #( (: '_' 'assign value') (Incr: 'increase by' 'increase value by') (Decr: 'decrease by' 'decrease value by') (Mult: 'multiply by' 'multiply value by')) language: #YourLanguage ! ! !Morph methodsFor: 'scripting' stamp: 'sw 10/24/2001 19:44'! categoriesForViewer "Answer a list of symbols representing the categories to offer in the viewer, in order" | aClass aList predetermined genericItems | aClass _ self renderedMorph class. aList _ OrderedCollection new. [aClass == Morph] whileFalse: [(aClass class includesSelector: #additionsToViewerCategories) ifTrue: [aList addAllFirstUnlessAlreadyPresent: (aClass additionsToViewerCategories collect: [:categorySpec | categorySpec first])]. aClass _ aClass superclass]. genericItems _ Morph additionsToViewerCategories collect: [:categorySpec | categorySpec first]. aList removeAllFoundIn: genericItems. aList addAllFirstUnlessAlreadyPresent: (Morph additionsToViewerCategories collect: [:categorySpec | categorySpec first]) asSet asOrderedCollection. predetermined _ #(basic #'color & border' geometry motion #'pen use' tests scripting miscellaneous) select: [:sym | aList includes: sym]. "bulletproof agains change in those names elsewhere" aList removeAllFoundIn: predetermined. ^ predetermined, aList ! ! !Morph class methodsFor: 'scripting' stamp: 'sw 10/24/2001 19:45'! additionsToViewerCategories "Answer a list of ( ) pairs that characterize the phrases this kind of morph wishes to add to various Viewer categories." ^ { self additionsToViewerCategoryBasic. "note: if you change the thing below you also need to change #tileScriptCommands." self additionsToViewerCategoryScripts. self additionsToViewerCategoryColorAndBorder. self additionsToViewerCategoryGeometry. self additionsToViewerCategoryMiscellaneous. self additionsToViewerCategoryMotion. self additionsToViewerCategoryPenUse. self additionsToViewerCategoryScripting. self additionsToViewerCategoryTests. }! ! !Morph class methodsFor: 'scripting' stamp: 'sw 10/24/2001 19:45'! additionsToViewerCategoryMiscellaneous "Answer viewer additions for the 'miscellaneous' category" ^#( miscellaneous ( (command doMenuItem: 'do the menu item' Menu) (command show 'make the object visible') (command hide 'make the object invisible') (command wearCostumeOf: 'wear the costume of...' Player) (command fire 'trigger any and all of this object''s button actions') (slot copy 'returns a copy of this object' Player readOnly Player getNewClone unused unused) (slot elementNumber 'my index in my container' Number readWrite Player getIndexInOwner Player setIndexInOwner:) (slot holder 'the object''s container' Player readOnly Player getHolder Player setHolder:) (command stampAndErase 'add my image to the pen trails and go away') ) ) ! ! !StandardScriptingSystem methodsFor: 'utilities' stamp: 'sw 10/29/2001 05:38'! wordingForOperator: aString "Answer the wording to be seen by the user for the given operator symbol/string" | toTest | "StandardScriptingSystem initialize" toTest _ aString asString. #( (append: 'append') (beep: 'make sound') (bounce: 'bounce') (clearTurtleTrails 'clear pen trails') (clearOwnersPenTrails 'clear all pen trails') (colorSees 'color sees') (color:sees: 'color sees') (doMenuItem: 'do menu item') (doScript: 'do') (forward: 'forward by') (moveToward: 'move toward') (goToRightOf: 'align after') (isDivisibleBy: 'is divisible by') (liftAllPens 'lift all pens') (lowerAllPens 'lower all pens') (arrowheadsOnAllPens 'arrowheads on all pens') (noArrowheadsOnAllPens 'no arrowheads on pens') (pauseAll: 'pause all') (pauseScript: 'pause script') (max: 'max') (min: 'min') (seesColor: 'is over color') (makeNewDrawingIn: 'start painting in') (startAll: 'start all') (startScript: 'start script') (stopProgramatically 'stop') (stopAll: 'stop all') (stopScript: 'stop script') (tellAllSiblings: 'tell all') (turn: 'turn by') (wearCostumeOf: 'look like')) do: [:pair | toTest = pair first ifTrue: [^ pair second]]. ^ toTest! !