'From Squeakland.396-Nihongo7.29 of 18 March 2005 [latest update: #98] on 9 June 2005 at 5:56:17 pm'! "Change Set: MinimalVocabulary Date: 29 May 2005 Author: Takashi Yamamiya "! EToyVocabulary subclass: #MinimalVocabulary instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'MinimalVocabulary'! !Object methodsFor: 'viewer' stamp: 'tak 5/29/2005 00:57'! methodInterfacesInPresentationOrderFrom: interfaceList forCategory: aCategory "Answer the interface list sorted in desired presentation order, using a static master-ordering list, q.v. The category parameter allows an escape in case one wants to apply different order strategies in different categories, but for now a single master-priority-ordering is used -- see the comment in method EToyVocabulary.masterOrderingOfPhraseSymbols" | masterOrder ordered unordered index | masterOrder := self currentVocabulary masterOrderingOfPhraseSymbols. ordered := SortedCollection sortBlock: [:a :b | a key < b key]. unordered := SortedCollection sortBlock: [:a :b | a wording < b wording]. interfaceList do: [:interface | index := masterOrder indexOf: interface elementSymbol. index isZero ifTrue: [unordered add: interface] ifFalse: [ordered add: index -> interface]]. ^ Array streamContents: [:stream | ordered do: [:assoc | stream nextPut: assoc value]. stream nextPutAll: unordered]! ! !CategoryViewer methodsFor: 'categories' stamp: 'tak 5/29/2005 02:29'! nextCategory "Change the receiver to point at the category following the one currently seen" | aList anIndex newIndex already aChoice | aList _ (scriptedPlayer categoriesForViewer: self) collect: [:aCatSymbol | self currentVocabulary categoryWordingAt: aCatSymbol]. already _ self outerViewer ifNil: [#()] ifNotNil: [self outerViewer categoriesCurrentlyShowing]. anIndex _ aList indexOf: self currentCategory ifAbsent: [0]. [anIndex _ anIndex + 1. aChoice _ aList atWrap: anIndex. already size < aList size and: [already includes: aChoice]] whileTrue. self chooseCategoryWhoseTranslatedWordingIs: aChoice! ! !CategoryViewer methodsFor: 'categories' stamp: 'tak 5/29/2005 02:29'! previousCategory "Change the receiver to point at the category preceding the one currently seen" | aList anIndex newIndex already aChoice | aList _ (scriptedPlayer categoriesForViewer: self) collect: [:aCatSymbol | self currentVocabulary categoryWordingAt: aCatSymbol]. already _ self outerViewer ifNil: [#()] ifNotNil: [self outerViewer categoriesCurrentlyShowing]. anIndex _ aList indexOf: self currentCategory ifAbsent: [aList size + 1]. [anIndex _ anIndex - 1. aChoice _ aList atWrap: anIndex. already size < aList size and: [already includes: aChoice]] whileTrue. self chooseCategoryWhoseTranslatedWordingIs: aChoice! ! !PasteUpMorph methodsFor: 'world state' stamp: 'tak 5/29/2005 01:57'! initForProject: aWorldState worldState _ aWorldState. bounds _ Display boundingBox. color _ (Color r:0.937 g: 0.937 b: 0.937). self addHand: HandMorph new. self setProperty: #automaticPhraseExpansion toValue: true. self setProperty: #optimumExtentFromAuthor toValue: Display extent. self setProperty: #currentVocabularySymbol toValue: (ActiveWorld valueOfProperty: #currentVocabularySymbol). self wantsMouseOverHalos: Preferences mouseOverHalos. self borderWidth: 0. model _ nil. ! ! !Preferences class methodsFor: 'user level' stamp: 'tak 5/29/2005 01:16'! userLevel self eToyFriendly ifFalse: [^ #senior]. ^ (ActiveWorld valueOfProperty: #currentVocabularySymbol) = #Minimal ifTrue: [#beginner] ifFalse: [#intermediate]! ! !Preferences class methodsFor: 'user level' stamp: 'tak 5/29/2005 01:38'! userLevel: aSymbol aSymbol = #beginner ifTrue: [self takanawa. ActiveWorld setProperty: #currentVocabularySymbol toValue: #Minimal. ^ aSymbol]. ActiveWorld abandonVocabularyPreference. aSymbol = #intermediate ifTrue: [self takanawa] ifFalse: [self outOfTheBox]. ^ aSymbol! ! !ProjectNavigationMorph methodsFor: 'the actions' stamp: 'tak 5/29/2005 01:24'! changeLevel | aMenu yesNo | aMenu := MenuMorph new defaultTarget: Preferences. #(#senior #intermediate #beginner ) do: [:each | yesNo := Preferences userLevel = each ifTrue: [''] ifFalse: ['']. aMenu add: yesNo , each translated target: Preferences selector: #userLevel: argument: each]. aMenu popUpInWorld! ! !ProjectNavigationMorph methodsFor: 'the buttons' stamp: 'tak 12/4/2004 14:30'! buttonLevel ^self makeButton: 'LEVEL' balloonText: 'Change user level' for: #changeLevel! ! !ProjectNavigationMorph methodsFor: 'buttons' stamp: 'tak 5/29/2005 02:50'! makeTheSimpleButtons ^{ self buttonNewProject. self buttonPrev. self buttonNext. self buttonPublish. self buttonFind. " self buttonFullScreen." self buttonPaint. self buttonUndo. " self buttonQuit." self buttonLevel. } ! ! !StandardViewer methodsFor: 'initialization' stamp: 'tak 11/29/2004 22:49'! initializeFor: aPlayer barHeight: anInteger includeDismissButton: aBoolean showCategories: categoryInfo "Initialize the receiver to be a look inside the given Player. The categoryInfo, if present, describes which categories should be present in it, in which order" scriptedPlayer _ aPlayer. self listDirection: #topToBottom; hResizing: #shrinkWrap; vResizing: #shrinkWrap; borderWidth: 1. self color: self standardViewerColor. self addHeaderMorphWithBarHeight: anInteger includeDismissButton: aBoolean. categoryInfo isEmptyOrNil ifFalse: "Reincarnating an pre-existing list" [categoryInfo do: [:aCat | self addCategoryViewerFor: aCat]] ifTrue: "starting fresh" [self currentVocabulary addCategoryViewerFor: self].! ! !Vocabulary methodsFor: 'queries' stamp: 'tak 11/29/2004 22:48'! addCategoryViewerFor: aViewer aViewer addSearchPane. aViewer addCategoryViewer. aViewer addCategoryViewer! ! !Vocabulary methodsFor: 'method list' stamp: 'tak 5/29/2005 01:00'! masterOrderingOfPhraseSymbols ^ Vocabulary eToyVocabulary masterOrderingOfPhraseSymbols! ! !MinimalVocabulary methodsFor: 'initialization' stamp: 'tak 6/9/2005 17:53'! categoryDefinition "Vocabulary initialize" ^#(( driveACar ( (slot x 'The x coordinate' Number readWrite Player getX Player setX:) (slot y 'The y coordinate' Number readWrite Player getY Player setY:) (slot heading 'Which direction the object is facing. 0 is straight up' Number readWrite Player getHeading Player setHeading:) (command forward: 'Moves the object forward in the direction it is heading' Number) (command turn: 'Change the heading of the object by the specified amount' Number) (slot colorSees 'whether the given color sees the given color' Boolean readOnly Player color:sees: unused unused) (slot penDown 'whether the pen is currently down' Boolean readWrite Player getPenDown Player setPenDown:) (slot penColor 'the color of ink used by the pen' Color readWrite Player getPenColor Player setPenColor:) (command clearOwnersPenTrails 'clear all pen trails in my containing playfield') (slot cursor 'The index of the chosen element' Number readWrite Player getCursor Player setCursorWrapped:) (slot graphic 'The picture currently being worn' Graphic readWrite Player getGraphic Player setGraphic:) (slot graphicAtCursor 'the graphic worn by the object at the cursor' Graphic readOnly player getGraphicAtCursor unused unused) ) )) ! ! !MinimalVocabulary methodsFor: 'initialization' stamp: 'tak 11/30/2004 00:13'! initialize "Vocabulary initialize" super initialize. self vocabularyName: #Minimal. self documentation: 'This vocabulary is for beginner.'. self initializeCategory ! ! !MinimalVocabulary methodsFor: 'initialization' stamp: 'tak 11/30/2004 00:25'! initializeCategory "it is similar than EToyVocabulary >> initialize" | aMethodInterface selectors selector aMethodCategory | selectors _ Set new. self categoryDefinition do: [:each | aMethodCategory _ ElementCategory new categoryName: each first. each second do: [:anElement | aMethodInterface _ self methodInterfaceFrom: anElement. selectors add: (selector _ aMethodInterface selector). (methodInterfaces includesKey: selector) ifFalse: [methodInterfaces at: selector put: aMethodInterface]]. (selectors copyWithout: #unused) asSortedArray do: [:aSelector | aMethodCategory elementAt: aSelector put: (methodInterfaces at: aSelector). self addCategory: aMethodCategory]]! ! !MinimalVocabulary methodsFor: 'category list' stamp: 'tak 11/30/2004 00:57'! categoryListForInstance: anObject ofClass: aClass limitClass: mostGenericClass (anObject isKindOf: Player) ifFalse: [^ super categoryListForInstance: anObject ofClass: aClass limitClass: mostGenericClass]. ^ #(#driveACar scripts)! ! !MinimalVocabulary methodsFor: 'queries' stamp: 'tak 11/30/2004 13:32'! addCategoryViewerFor: aViewer aViewer scriptedPlayer hasUserDefinedScripts ifTrue: [aViewer addCategoryViewerFor: ScriptingSystem nameForScriptsCategory atEnd: true]. aViewer addCategoryViewerFor: #driveACar atEnd: true! ! !MinimalVocabulary methodsFor: 'method list' stamp: 'tak 12/6/2004 04:20'! masterOrderingOfPhraseSymbols ^ #(#getX #getY #getHeading #forward: #turn: #clearOwnersPenTrails #getPenColor #getPenDown #color:sees: )! ! !Vocabulary class methodsFor: 'class initialization' stamp: 'tak 1/5/2005 09:57'! initializeStandardVocabularies "Initialize a few standard vocabularies and place them in the AllStandardVocabularies list." AllStandardVocabularies _ nil. self addStandardVocabulary: EToyVocabulary new. self addStandardVocabulary: EToyVectorVocabulary new. self addStandardVocabulary: self newPublicVocabulary. self addStandardVocabulary: FullVocabulary new. self addStandardVocabulary: MinimalVocabulary new. self addStandardVocabulary: self newQuadVocabulary. self addStandardVocabulary: ColorType new. self addStandardVocabulary: BooleanType new. self addStandardVocabulary: GraphicType new. self addStandardVocabulary: PlayerType new. self addStandardVocabulary: SoundType new. self addStandardVocabulary: StringType new. self addStandardVocabulary: MenuType new. self addStandardVocabulary: UnknownType new. self addStandardVocabulary: ScriptNameType new. self addStandardVocabulary: (SymbolListType new symbols: #(simple raised inset complexFramed complexRaised complexInset complexAltFramed complexAltRaised complexAltInset); vocabularyName: #BorderStyle; yourself). self addStandardVocabulary: (SymbolListType new symbols: #(lines arrows arrowheads dots); vocabularyName: #TrailStyle; yourself). self addStandardVocabulary: (SymbolListType new symbols: #(leftToRight rightToLeft topToBottom bottomToTop); vocabularyName: #ListDirection; yourself). self addStandardVocabulary: (SymbolListType new symbols: #(topLeft bottomRight center justified); vocabularyName: #ListCentering; yourself). self addStandardVocabulary: (SymbolListType new symbols: #(buttonDown whilePressed buttonUp); vocabularyName: #ButtonPhase; yourself). self addStandardVocabulary: (SymbolListType new symbols: #(rotate #'do not rotate' #'flip left right' #'flip up down'); vocabularyName: #RotationStyle; yourself). self addStandardVocabulary: (SymbolListType new symbols: #(rigid spaceFill shrinkWrap); vocabularyName: #Resizing; yourself). self addStandardVocabulary: self newSystemVocabulary. "A custom vocabulary for Smalltalk -- still under development)" self numberVocabulary. "creates and adds it" self wonderlandVocabulary. "creates and adds it" self vocabularyForClass: Time. "creates and adds it" "Vocabulary initialize"! ! !MinimalVocabulary class methodsFor: 'miscellaneous ' stamp: 'tak 5/29/2005 01:53'! initialize Vocabulary initialize. (Preferences preferenceAt: #uniTilesClassic) changeInformee: nil changeSelector: nil! ! MinimalVocabulary initialize! "Postscript: Leave the line above, and replace the rest of this comment by a useful one. Executable statements should follow this comment, and should be separated by periods, with no exclamation points (!!). Be sure to put any further comments in double-quotes, like this one." Flaps disableGlobalFlaps: false. Flaps addAndEnableEToyFlaps. ActiveWorld addGlobalFlaps. Flaps sharedFlapsAlongBottom. !