This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-03-21 09:32:04

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Post Your Patch

Do you have any patches you would like to share? Post your patches here with an explanation of what they do.
I think there should be a place where you can find and post patches small and large, so I made this topic.

Offline

 

#2 2012-03-21 09:35:27

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Post Your Patch

Description: This patch makes dropped reporters (that can become watchers) turn into watchers when dragged onto the stage.

Code:

!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

 

#3 2012-03-21 09:56:25

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Post Your Patch

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.  tongue  I'm using an ancient version 3.1...

Last edited by Hardmath123 (2012-03-21 09:57:07)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#4 2012-05-04 15:14:24

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Post Your Patch

Comment Block

Code:

'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

 

#5 2012-05-04 16:42:47

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Post Your Patch

Nice topic! I hope this gets lots of submissions!


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#6 2012-05-04 19:16:27

zippynk
Scratcher
Registered: 2011-07-23
Posts: 500+

Re: Post Your Patch

How do you import a patch?


https://dl.dropbox.com/u/60598636/trifocal_interlude_soundcloud_button.png

Offline

 

#7 2012-05-05 00:45:43

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Post Your Patch

sparks wrote:

Nice topic! I hope this gets lots of submissions!

thanks!

Offline

 

#8 2012-05-19 18:05:57

PullJosh
Scratcher
Registered: 2011-08-01
Posts: 500+

Re: Post Your Patch

...This may sound a bit dumb, but... What's a patch?


http://www.blocks.scratchr.org/API.php?action=text&string=I'm_on_vacation!&xpos=155&ypos=90&font_size=30&bgimage=http://imageshack.us/a/img339/7215/sspeechsigapiforwords.png

Offline

 

#9 2012-05-20 03:07:55

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: Post Your Patch

Hardmath123 wrote:

EDIT: Never mind, FireFox clipped the whole first column.  tongue  I'm using an ancient version 3.1...

WUT?

Offline

 

#10 2012-05-20 03:16:53

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Post Your Patch

roijac wrote:

Hardmath123 wrote:

EDIT: Never mind, FireFox clipped the whole first column.  tongue  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.  tongue  I'm mainly a die-hard Safari fan, so it doesn't matter.  smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#11 2012-05-20 04:20:17

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Post Your Patch

PullJosh wrote:

...This may sound a bit dumb, but... What's a patch?

Extremely simple explanation: A patch is a piece of code you add to another program to give more functionality.


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#12 2012-05-20 04:55:14

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Post Your Patch

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.  smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#13 2012-05-20 05:19:25

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Post Your Patch

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.  smile

Yeah, and it usually helps if the program you're adding the patch to is open source. lol


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#14 2012-05-20 05:24:01

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Post Your Patch

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.  smile

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.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#15 2012-05-20 06:46:48

PullJosh
Scratcher
Registered: 2011-08-01
Posts: 500+

Re: Post Your Patch

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.  smile

Okay. Thanks!  smile


http://www.blocks.scratchr.org/API.php?action=text&string=I'm_on_vacation!&xpos=155&ypos=90&font_size=30&bgimage=http://imageshack.us/a/img339/7215/sspeechsigapiforwords.png

Offline

 

#16 2012-08-18 20:09:39

Dominic1
Scratcher
Registered: 2009-07-30
Posts: 89

Re: Post Your Patch

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.

Code:

!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.

Code:

!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.

Code:

!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)! !

http://i49.tinypic.com/oiwvh5.jpg

Offline

 

#17 2012-08-20 17:16:11

ComputerProgrammer
Scratcher
Registered: 2008-08-25
Posts: 100+

Re: Post Your Patch

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!  smile


What do scratch blocks and oak trees have in common? Click here to find out!

Offline

 

#18 2012-08-21 12:52:59

whizzer
Scratcher
Registered: 2008-05-27
Posts: 500+

Re: Post Your Patch

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.


http://i46.tinypic.com/33df6me.png I'm whizzer0 for all things Minecraft.

Offline

 

#19 2012-08-25 15:44:12

Dominic1
Scratcher
Registered: 2009-07-30
Posts: 89

Re: Post Your Patch

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)


http://i49.tinypic.com/oiwvh5.jpg

Offline

 

#20 2012-08-25 17:50:43

Dominic1
Scratcher
Registered: 2009-07-30
Posts: 89

Re: Post Your Patch

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)

Code:

'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!  smile


http://i49.tinypic.com/oiwvh5.jpg

Offline

 

#21 2012-08-26 20:24:05

Dominic1
Scratcher
Registered: 2009-07-30
Posts: 89

Re: Post Your Patch

Now, just to top it off, I started a patch repository. Go to escratch.org/patch to see it!

Note: The Web Patcher in the repository is version 1.1 with more functions, so you might want to go check it out.


http://i49.tinypic.com/oiwvh5.jpg

Offline

 

Board footer