To add a mesh menu to your mod, or the scratch sourcecode, file all of these in.
To file something in, turn off fill-screen mode, open a workspace, paste one of these codes in, highlight all the code, then click the little button above the scroll bar, click more, and then click file in.
'From Gbear605 [No updates present.] on June 6, 2011 for Adding mesh to Scratch'!
!ScratchFrameMorph methodsFor: 'intialization'!
createMenuPanel
| t1 t2 |
menuPanel _ AlignmentMorph new color: Color transparent;
centering: #center;
inset: 0;
height: 0.
self addShortcutButtonsTo: menuPanel.
t1 _ #((#File #fileMenu:) (#Edit #editMenu:) (#Share #shareMenu:) (#Help #helpMenu:) (#Mesh #meshMenu:) ).
AllowSharing ifFalse: [t1 _ t1 select: [:t3 | t3 second ~= #shareMenu:]].
t1 do:
[:t3 |
t2 _ ScratchMenuTitleMorph new contents: (t3 at: 1) localized;
target: self selector: (t3 at: 2).
menuPanel addMorphBack: t2.
#meshMenu: = (t3 at: 2) ifFalse: [menuPanel addMorphBack: (Morph new color: Color transparent;
extent: 12 @ 5)]].
topPane addMorph: menuPanel! !
!ScratchFrameMorph methodsFor: 'menu/button actions'!
meshMenu: t1
| t2 |
t2 _ CustomMenu new.
self addServerCommandsTo: t2.
t2 localize.
#(1 ) do: [:t3 | t2 labels at: t3 put: ((t2 labels at: t3)
copyFrom: 1 to: (t2 labels at: t3) size - 1)
, ScratchTranslator ellipsesSuffix].
t2 invokeOn: self at: t1 bottomLeft + (0 @ 10)! !
!ScratchFrameMorph methodsFor: 'menu/button actions'!
addServerCommandsTo: t1
| t2 t3 |
t2 _ false.
t2 ifTrue: [^ self].
t1 addLine.
(workPane scratchServer notNil and: [workPane scratchServer sessionInProgress])
ifTrue:
[t1 add: 'Show IP Address' action: #showNetworkAddress.
t3 _ workPane scratchServer isHosting
ifTrue: ['Stop Hosting Mesh']
ifFalse: ['Leave Mesh'].
t1 add: t3 action: #exitScratchSession]
ifFalse:
[t1 add: 'Host Mesh' action: #startHostingScratchSession.
t1 add: 'Join Mesh' action: #joinScratchSession]! !Then save the image, and restart scratch. There should now be a mesh menu.
Last edited by gbear605 (2011-06-07 14:41:28)
Offline
bump
Offline
You do notice this is not ADDING mesh to scratch, it is simply enabling mesh.
It is just as easy or easier to change the false to true and have mesh, just not the menu, Making a menu sometimes doesn't work.
Offline