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

#1 2010-09-12 08:27:34

pwiter
Scratcher
Registered: 2010-06-02
Posts: 100+

Scratch Source questions

1.Some mods don't have scratch skin folders(panther)!How do they make new catogories?
2.Why is the code different for scratch and scratch source,they both squeak smalltalk?!
3.How do you make one catogory!?


http://i.imgur.com/YBeXc.png

Offline

 

#2 2010-09-12 10:16:10

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Scratch Source questions

pwiter wrote:

1.Some mods don't have scratch skin folders(panther)!How do they make new catogories?
2.Why is the code different for scratch and scratch source,they both squeak smalltalk?!
3.How do you make one catogory!?

1. They loaded it into the mod before distribution.
2. The source code is the decompiled version.
3. In this code:

!ScratchViewerMorph methodsFor: 'initialization'!
rebuildCategorySelectors
    | t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 |
    t1 _ #(#motion #control #looks #sensing #sound #operators #pen #variables #(new category)).
    submorphs do: [:t14 | (t14 isKindOf: ResizableToggleButton2)
            ifTrue: [t14 delete]].
    t2 _ 75 @ 0.
    t3 _ t1
                collect:
                    [:t15 |
                    t4 _ (ScratchTranslator translationFor: t15 asString) capitalized.
                    t5 _ ScratchFrameMorph skinAt: t15.
                    t6 _ ScratchFrameMorph skinAt: t15 , 'Pressed'.
                    t7 _ ScratchFrameMorph skinAt: t15 , 'Over'.
                    ScratchTranslator isRTL
                        ifTrue: [t8 _ ResizableToggleButton2 new
                                        offForm: (t5 flipBy: #horizontal centerAt: t5 center)
                                        onForm: (t6 flipBy: #horizontal centerAt: t6 center)
                                        overForm: (t7 flipBy: #horizontal centerAt: t7 center)]
                        ifFalse: [t8 _ ResizableToggleButton2 new
                                        offForm: t5
                                        onForm: t6
                                        overForm: t7].
                    t8 label: t4 font: (ScratchFrameMorph getFont: #Category);
                     setLabelColor: Color white;
                     target: self;
                     actionSelector: #currentCategory:;
                     arguments: (Array with: t15);
                     toggleButtonMode: true;
                     toggleMode: false.
                    ScratchTranslator isRTL
                        ifTrue: [t8 rightJustifyInset: 10]
                        ifFalse: [t8 leftJustifyInset: 10].
                    t2 _ t2 max: t8 extent + (3 @ -6).
                    t8].
    t9 _ 15.
    catButtonsExtent _ 2 * t2 x + (3 * t9) @ (t1 size // 2 * (t2 y + 6) + 25).
    t10 _ self left + 12 + t9.
    t11 _ t10 + t2 x + t9.
    t12 _ t10.
    t13 _ self top + 17.
    1 to: t3 size do:
        [:t16 |
        t8 _ t3 at: t16.
        t8 extent: t2.
        self addMorph: (t8 position: t12 @ t13).
        t16 even
            ifTrue:
                [t12 _ t10.
                t13 _ t13 + t8 height + 6]
            ifFalse: [t12 _ t11]].
    self width: catButtonsExtent x.
    pageViewer position: self position + (0 @ catButtonsExtent y).
    topSectionHeight _ catButtonsExtent y - 4! !

!ScratchViewerMorph methodsFor: 'accessing'!
currentCategory: t1
    World activeHand newKeyboardFocus: nil.
    currentCategory _ t1.
    self lightUpSelectorForCurrentCategory.
    self updateContents.
    World restoreDisplay! !

(I didn't make that!) replace the "t1 size // 2" with "t1 size / 2) rounded

You're welcome  tongue


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#3 2010-09-12 10:55:25

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Scratch Source questions

No, the source code is not decompiled. It just has a changes file. In fact, one could argue that the non-source methods are decompiled, as I believe they are retrieved from compiled methods.


nXIII

Offline

 

Board footer