Description: This patch makes dropped reporters (that can become watchers) turn into watchers when dragged onto the stage.
!BlockMorph methodsFor: 'dropping/grabbing'!
justDroppedInto: newOwner event: evt
"Handle being dropped into a new situation."
| frame targetAssoc targetP targetBlock bottomBlockUsed upperBlock |
bottomBlockUsed _ false.
(frame _ newOwner ownerThatIsA: ScratchFrameMorph)
ifNotNil: [frame projectModified].
((self ownerThatIsA: ScratchViewerMorph) notNil) ifTrue: [
"delete myself when dropped in the blocks palette area"
self delete.
self receiver blocksBin changed.
^ self].
"blocks cannot be dropped onto the stage"
(owner isKindOf: ScratchStageMorph) ifTrue: [
(self canBecomeWatcher) ifTrue: [^ self createWatcher;toggleWatcher;delete]
ifFalse:[
^ self rejectDropEvent: evt]].
"okay to drop blocks into the world during development"
((owner == World) and: [Preferences noviceMode not]) ifTrue: [^ self].
((owner isKindOf: ScratchScriptsMorph) or:
[(owner isKindOf: BlockMorph) or:
[(owner isKindOf: ScratchStageMorph) and: [self isReporter]]]) ifFalse: [
^ self rejectDropEvent: evt].
self isReporter ifTrue: [^ self handleReporterDrop].
targetAssoc _ self closestAttachTargetIn: newOwner.
targetAssoc ifNil: [
(self bottomBlock isKindOf: CBlockMorph) ifFalse: [
targetAssoc _ self bottomBlock closestAttachTargetIn: newOwner.
targetAssoc ifNotNil:[
bottomBlockUsed _ true.
(targetAssoc value owner isKindOf: BlockMorph) ifTrue:[
targetAssoc _ nil]]]].
targetAssoc ifNil: [^ self].
"make sure no processes are running"
self = self topBlock ifTrue: [self stop].
targetP _ targetAssoc key.
targetBlock _ targetAssoc value.
targetP y = targetBlock top
ifTrue: [
"c-shaped block should nest the target block"
"((bottomBlockUsed not) and: [((targetBlock owner isKindOf: BlockMorph) not) and: [(self isKindOf: CBlockMorph)]]) ifTrue:["
((bottomBlockUsed not) and: [(self isKindOf: CBlockMorph)]) ifTrue:[
(targetBlock owner isKindOf: BlockMorph)
ifTrue: [(targetBlock owner) attachBlock: self]
ifFalse: [self position: (targetP x - self bracketThickness)@(targetP y - self topBarHeight - 3)].
self attachBlockNested: targetBlock. ^ self].
"for all other non-c-shaped blocks"
(bottomBlockUsed or:[((targetBlock owner isKindOf: BlockMorph) not) and: [(self isKindOf: CBlockMorph) not]]) ifTrue:[
ScratchTranslator isRTL
ifTrue: [self bottomBlock position: (targetP x - self bottomBlock width) @ (targetP y - (self bottomBlock height - 4))]
ifFalse: [self bottomBlock position: targetP x @ (targetP y - (self bottomBlock height - 4))].
upperBlock _ self bottomBlock owner.
[upperBlock isKindOf: BlockMorph] whileTrue: [
upperBlock nextBlock ifNotNil:[
ScratchTranslator isRTL
ifTrue: [upperBlock position: (targetP x - upperBlock width) @ (upperBlock nextBlock position y - (upperBlock height - 4))]
ifFalse: [upperBlock position: targetP x @ (upperBlock nextBlock position y - (upperBlock height - 4))].
upperBlock _ upperBlock owner]]].
((bottomBlockUsed not) and: [targetBlock owner isKindOf: BlockMorph]) ifTrue:[
ScratchTranslator isRTL
ifTrue: [self position: (targetP x - self width) @ (targetP y - (self height - 4))]
ifFalse: [self position: targetP x @ (targetP y - (self height - 4))]].
(targetBlock owner isKindOf: BlockMorph) ifTrue:[
ScratchTranslator isRTL
ifTrue: [self topBlock position: (targetP x - self topBlock width) @ targetP y]
ifFalse: [self topBlock position: targetP x @ targetP y].
targetBlock owner attachBlock: self topBlock].
ScratchTranslator isRTL
ifTrue: [targetBlock position: (targetP x - targetBlock width) @ (self bottomBlock position y + self bottomBlock height + 4)]
ifFalse: [targetBlock position: targetP x @ (self bottomBlock position y + self bottomBlock height + 4)].
((bottomBlockUsed not) and: [((targetBlock owner isKindOf: BlockMorph) not) and: [(self isKindOf: CBlockMorph)]]) ifFalse:[
self bottomBlock attachBlock: targetBlock]]
ifFalse: [
self assert: [(self isKindOf: HatBlockMorph) not]. "I am not a HatBlockMorph"
ScratchTranslator isRTL
ifTrue: [self position: (targetP - (self width @0))]
ifFalse: [self position: targetP].
targetBlock attachBlock: self].
! !Offline
I think there's a bug in the second line, first word: ustDroppedInto should be justDroppedInto.
EDIT: Never mind, FireFox clipped the whole first column.
I'm using an ancient version 3.1...
Last edited by Hardmath123 (2012-03-21 09:57:07)
Offline
Comment Block
'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 4 May 2012 at 8:50:37 pm'!
!ScratchScriptEditorMorph methodsFor: 'menu/button ops' stamp: 'Dreamod 5/4/2012 20:46'!
addComment: t1
| t2 t3 |
t3 _ (pageViewerMorph allMorphs select: [:t4 | t4 isKindOf: ScratchScriptsMorph]) first.
t3 addMorph: (t2 _ CommentBlockMorph new position: t1;comment: 'Your comment...').
^ World activeHand newKeyboardFocus: t2 commentMorph! !
!CommentBlockMorph methodsFor: 'other' stamp: 'Dreamod 5/4/2012 20:47'!
commentMorph
^ commentMorph! !
'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 4 May 2012 at 8:51:35 pm'!
!BlockMorph methodsFor: 'dropping/grabbing' stamp: 'Dreamod 5/4/2012 20:43'!
justDroppedInto: newOwner event: evt
"Handle being dropped into a new situation."
| frame targetAssoc targetP targetBlock bottomBlockUsed upperBlock |
bottomBlockUsed _ false.
(frame _ newOwner ownerThatIsA: ScratchFrameMorph)
ifNotNil: [frame projectModified].
((self ownerThatIsA: ScratchViewerMorph) notNil) ifTrue: [
"delete myself when dropped in the blocks palette area"
self delete.
(self isMemberOf: CommentBlockMorph) ifTrue: [^ self].
self receiver blocksBin changed.
^ self].
"blocks cannot be dropped onto the stage"
(owner isKindOf: ScratchStageMorph) ifTrue: [
^ self rejectDropEvent: evt].
"okay to drop blocks into the world during development"
((owner == World) and: [Preferences noviceMode not]) ifTrue: [^ self].
((owner isKindOf: ScratchScriptsMorph) or:
[(owner isKindOf: BlockMorph) or:
[(owner isKindOf: ScratchStageMorph) and: [self isReporter]]]) ifFalse: [
^ self rejectDropEvent: evt].
self isReporter ifTrue: [^ self handleReporterDrop].
targetAssoc _ self closestAttachTargetIn: newOwner.
targetAssoc ifNil: [
(self bottomBlock isKindOf: CBlockMorph) ifFalse: [
targetAssoc _ self bottomBlock closestAttachTargetIn: newOwner.
targetAssoc ifNotNil:[
bottomBlockUsed _ true.
(targetAssoc value owner isKindOf: BlockMorph) ifTrue:[
targetAssoc _ nil]]]].
targetAssoc ifNil: [^ self].
"make sure no processes are running"
self = self topBlock ifTrue: [self stop].
targetP _ targetAssoc key.
targetBlock _ targetAssoc value.
targetP y = targetBlock top
ifTrue: [
"c-shaped block should nest the target block"
"((bottomBlockUsed not) and: [((targetBlock owner isKindOf: BlockMorph) not) and: [(self isKindOf: CBlockMorph)]]) ifTrue:["
((bottomBlockUsed not) and: [(self isKindOf: CBlockMorph)]) ifTrue:[
(targetBlock owner isKindOf: BlockMorph)
ifTrue: [(targetBlock owner) attachBlock: self]
ifFalse: [self position: (targetP x - self bracketThickness)@(targetP y - self topBarHeight - 3)].
self attachBlockNested: targetBlock. ^ self].
"for all other non-c-shaped blocks"
(bottomBlockUsed or:[((targetBlock owner isKindOf: BlockMorph) not) and: [(self isKindOf: CBlockMorph) not]]) ifTrue:[
ScratchTranslator isRTL
ifTrue: [self bottomBlock position: (targetP x - self bottomBlock width) @ (targetP y - (self bottomBlock height - 4))]
ifFalse: [self bottomBlock position: targetP x @ (targetP y - (self bottomBlock height - 4))].
upperBlock _ self bottomBlock owner.
[upperBlock isKindOf: BlockMorph] whileTrue: [
upperBlock nextBlock ifNotNil:[
ScratchTranslator isRTL
ifTrue: [upperBlock position: (targetP x - upperBlock width) @ (upperBlock nextBlock position y - (upperBlock height - 4))]
ifFalse: [upperBlock position: targetP x @ (upperBlock nextBlock position y - (upperBlock height - 4))].
upperBlock _ upperBlock owner]]].
((bottomBlockUsed not) and: [targetBlock owner isKindOf: BlockMorph]) ifTrue:[
ScratchTranslator isRTL
ifTrue: [self position: (targetP x - self width) @ (targetP y - (self height - 4))]
ifFalse: [self position: targetP x @ (targetP y - (self height - 4))]].
(targetBlock owner isKindOf: BlockMorph) ifTrue:[
ScratchTranslator isRTL
ifTrue: [self topBlock position: (targetP x - self topBlock width) @ targetP y]
ifFalse: [self topBlock position: targetP x @ targetP y].
targetBlock owner attachBlock: self topBlock].
ScratchTranslator isRTL
ifTrue: [targetBlock position: (targetP x - targetBlock width) @ (self bottomBlock position y + self bottomBlock height + 4)]
ifFalse: [targetBlock position: targetP x @ (self bottomBlock position y + self bottomBlock height + 4)].
((bottomBlockUsed not) and: [((targetBlock owner isKindOf: BlockMorph) not) and: [(self isKindOf: CBlockMorph)]]) ifFalse:[
self bottomBlock attachBlock: targetBlock]]
ifFalse: [
self assert: [(self isKindOf: HatBlockMorph) not]. "I am not a HatBlockMorph"
ScratchTranslator isRTL
ifTrue: [self position: (targetP - (self width @0))]
ifFalse: [self position: targetP].
targetBlock attachBlock: self].
! !Offline
roijac wrote:
Hardmath123 wrote:
EDIT: Never mind, FireFox clipped the whole first column.
I'm using an ancient version 3.1...
WUT?
On a whim. I never bothered to update it, so here I am with 3.1 or something.
I'm mainly a die-hard Safari fan, so it doesn't matter.
Offline
PullJosh wrote:
...This may sound a bit dumb, but... What's a patch?
A patch is like an add-on to a program. It could fix a glitch, it could add a feature. For example, you could think of a Chrome extension (or FireFox add-on) as a patch. I hope that helped.
Offline
Hardmath123 wrote:
PullJosh wrote:
...This may sound a bit dumb, but... What's a patch?
A patch is like an add-on to a program. It could fix a glitch, it could add a feature. For example, you could think of a Chrome extension (or FireFox add-on) as a patch. I hope that helped.
![]()
Yeah, and it usually helps if the program you're adding the patch to is open source. lol
Offline
slinger wrote:
Hardmath123 wrote:
PullJosh wrote:
...This may sound a bit dumb, but... What's a patch?
A patch is like an add-on to a program. It could fix a glitch, it could add a feature. For example, you could think of a Chrome extension (or FireFox add-on) as a patch. I hope that helped.
![]()
Yeah, and it usually helps if the program you're adding the patch to is open source. lol
Well, some closed-source programs allow third-party patches with dev licenses, e.g. Safari.
Offline
Hardmath123 wrote:
PullJosh wrote:
...This may sound a bit dumb, but... What's a patch?
A patch is like an add-on to a program. It could fix a glitch, it could add a feature. For example, you could think of a Chrome extension (or FireFox add-on) as a patch. I hope that helped.
![]()
Okay. Thanks!

Offline
I have two basic ones:
1: Extended file menu
If you make a mod or just mess around with Scratch a lot, then this is a useful patch! It adds two options to the file menu
Reload Skin: Fairly obvious, reloads the Scratch skin.
Internal Restart: Basically restarts Scratch as if you closed it and opened it again.
!ScratchFrameMorph methodsFor: 'menu/button actions'!
fileMenu: t1
| t2 |
t2 _ CustomMenu new.
t2 add: 'New' action: #newScratchProject.
t2 add: 'Open' action: #openScratchProject.
t2 add: 'Save' action: #saveScratchProjectNoDialog.
t2 add: 'Save As' action: #saveScratchProject.
t2 addLine.
t2 add: 'Import Project' action: #importScratchProject.
t2 add: 'Export Sprite' action: #exportSprite.
t2 addLine.
t2 add: 'Project Notes' action: #editNotes.
t2 addLine.
t2 add: 'Reload Skin' action: #repairSkin.
t2 add: 'Internal Restart' action: #startup.
t2 addLine.
t2 add: 'Quit' action: #quitScratch.
t2 localize.
#(2 4 5 6 7 8 ) 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'!
repairSkin
ScratchFrameMorph readSkinFrom: (FileDirectory default directoryNamed: 'ScratchSkin').
World fullRepaintNeeded.
viewerPane rebuildCategorySelectors.
self updatePanes.
self
view: scriptsPane target
tab: scriptsPane tabPane currentTab
category: viewerPane currentCategory! !2: Mesh Enabler
Most people on this forum post probably already enabled mesh manually, but this not only enables mesh but also changes the share menu so you don't have to hold "Shift" to bring up the mesh options.
!ScratchFrameMorph methodsFor: 'menu/button actions' stamp: 'share menu addon comp'!
shareMenu: t1
| t2 |
t2 _ CustomMenu new.
t2 add: 'Share This Project Online' action: #share.
t2 add: 'Go To Scratch Website' action: #launchScratchWebsite.
self addServerCommandsTo: t2.
t2 localize.
#(1 2 ) 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]! !I also have the un-patch for the Extended File menu patch. It just returns the file menu to not having the new options.
!ScratchFrameMorph methodsFor: 'menu/button actions'!
fileMenu: t1
| t2 |
t2 _ CustomMenu new.
t2 add: 'New' action: #newScratchProject.
t2 add: 'Open' action: #openScratchProject.
t2 add: 'Save' action: #saveScratchProjectNoDialog.
t2 add: 'Save As' action: #saveScratchProject.
t2 addLine.
t2 add: 'Import Project' action: #importScratchProject.
t2 add: 'Export Sprite' action: #exportSprite.
t2 addLine.
t2 add: 'Project Notes' action: #editNotes.
t2 addLine.
t2 add: 'Quit' action: #quitScratch.
t2 localize.
#(2 4 5 6 7 8 ) 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)! !Offline
zippynk wrote:
How do you import a patch?
1. Copy and paste the text into Word/TextEdit and save it as a .txt file.
2. Then open Scratch, shift-click the R and select 'turn fill screen off'. Click in the white space and select 'open', then 'file list'.
3. From the file browser that just popped up, find your .txt file and option-click it, then select 'more' and then 'fileIn'.
4. Enjoy your new patch!
Offline
This is both a patch and MEGA-USEFUL for patches.
To convert your code to .patch, open Notepad, paste it in, save it is "[name].patch" and it should work.
Without quotes, bla bla, [name] is what you want to JUST USE COMMON SENSE.
Offline
I'm working on a patch downloading system, sort of like the Panther part of the block library. You select "Download Patch" from the file menu (That would be from a modified version of NXIII's patcher) and then put in the patch ID. I'll post again when I'm done!
EDIT: See the next post down for the patcher!
Last edited by Dominic1 (2012-08-25 17:52:22)
Offline
I finished the first version of the online patch downloader! You can download it as a .patch file here, or you can simply copy the source code and file it in manually below.
What it does:
It is a modified version of nXIII's patcher. It adds four buttons to the file menu.
1: Add patch
Full credit goes to nXIII for this one.
It opens a dialog to choose a .patch file from your computer.
2: Download patch
This asks you for a link, where you would put the link to a patch. Try these links:
-Full mesh enabler: http://db.tt/6K6tk8ii
-Forum code converter: http://dl.dropbox.com/u/11532575/progs/ScratchblocksPlugin.cs (This patch was made by LS97)
3: Reload Skin
Reloads the ScratchSkin from the default directory. Don't use this if you don't know what you're doing!
4: Internal Restart
Restarts Scratch as if you had closed and reopened it.
Patch source code (Install it like any other patch, simply file it in)
'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 18 June 2010 at 5:06:17 pm'!
!ScratchFileChooserDialog methodsFor: 'initialization'!
createPatchFileChooserFor: t1
scratchFrame _ nil.
readingScratchFile _ true.
list _ ScratchFilePicker new extensions: #(#patch ).
self removeAllMorphs.
bottomSpacer delete.
bottomSpacer _ nil.
mainColumn addMorphBack: list.
self title: 'Add Patch'.
list scratchInfoClient: nil.
mainColumn addMorphBack: (Morph new extent: 5 @ 9;
color: Color transparent);
addMorphBack: newTitleBin.
fileInfoColumn addMorphBack: buttonRow.
self addMorphBack: shortcutColumn;
addMorphBack: mainColumn;
addMorphBack: fileInfoColumn! !
!ScratchFrameMorph methodsFor: 'menu/button actions'!
addPatch
| t1 t2 t3 t4 |
t1 _ ScratchFileChooserDialog new createPatchFileChooserFor: self;
type: #patch.
t2 _ t1 getUserResponse.
t2 = #cancelled ifTrue: [^ self].
t3 _ (FileDirectory forFileName: t2)
oldFileNamed: t2.
t4 _ t3 contentsOfEntireFile.
(ReadWriteStream
on: t4
from: 1
to: t4 size) fileIn! !
!ScratchFrameMorph methodsFor: 'menu/button actions'!
downloadPatch
| t1 t2 |
t1 _ StringDialog ask: 'Please enter link:'.
t2 _ (HTTPSocket httpGet:t1) contents.
(ReadWriteStream
on: t2
from: 1
to: t2 size) fileIn! !
!ScratchFrameMorph methodsFor: 'menu/button actions'!
repairSkin
ScratchFrameMorph readSkinFrom: (FileDirectory default directoryNamed: 'ScratchSkin').
World fullRepaintNeeded.
viewerPane rebuildCategorySelectors.
self updatePanes.
self
view: scriptsPane target
tab: scriptsPane tabPane currentTab
category: viewerPane currentCategory! !
!ScratchFrameMorph methodsFor: 'menu/button actions'!
fileMenu: t1
| t2 |
t2 _ CustomMenu new.
t2 add: 'New' action: #newScratchProject.
t2 add: 'Open' action: #openScratchProject.
t2 add: 'Save' action: #saveScratchProjectNoDialog.
t2 add: 'Save As' action: #saveScratchProject.
t2 addLine.
t2 add: 'Import Project' action: #importScratchProject.
t2 add: 'Export Sprite' action: #exportSprite.
t2 addLine.
t2 add: 'Add Patch' action: #addPatch.
t2 add: 'Download Patch' action: #downloadPatch.
t2 add: 'Reload Skin' action: #repairSkin.
t2 add: 'Internal Restart' action: #startup.
t2 addLine.
t2 add: 'Project Notes' action: #editNotes.
Sensor shiftPressed
ifTrue:
[t2 addLine.
t2 add: 'Write Project Summary' action: #writeSummaryFile.
t2 add: 'Write Multiple Project Summaries' action: #writeMultipleSummaries].
t2 addLine.
t2 add: 'Quit' action: #quitScratch.
t2 localize.
#(2 4 5 6 7 8 ) 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)! !Credit to nXIII for the original patcher
Credit to LS97 for the forum code converter
Hope you guys enjoy!
Offline