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

#1 2011-03-12 12:52:59

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

The EASY way to rename categories

How to do it WITHOUT editing the ScratchSkin.

Go to Scratch-UI-Panes -> ScratchViewerMorph -> initialization -> rebuildCategorySelectors.

Then replace the code there with this:

Code:

rebuildCategorySelectors

    | catList nameList maxExtent buttons label offForm onForm overForm b pad leftColumnX rightColumnX x y count |
    catList _ #(
        motion        control
        looks        sensing
        sound        operators
        pen            variables).
    nameList _ #(
        custom1        custom2
        custom3        custom4
        custom5        custom6
        custom7        custom8).

    "First, delete the old category buttons"
    submorphs do: [:m | (m isKindOf: ResizableToggleButton2) ifTrue: [m delete]].

    "Create new buttons, keeping track of the maximum extent."
    maxExtent _ 75@0.
    count _ 0.
    buttons _ catList collect: [:cat |
        count _ count + 1.
        label _ (ScratchTranslator translationFor: (nameList at: count)) capitalized.
        offForm _ (ScratchFrameMorph skinAt: cat).
        onForm _ (ScratchFrameMorph skinAt: (cat, 'Pressed')).
        overForm _ (ScratchFrameMorph skinAt: (cat, 'Over')).
        ScratchTranslator isRTL
            ifTrue:[
                b _ ResizableToggleButton2 new
                    offForm:    (offForm flipBy: #horizontal centerAt: offForm center)
                    onForm:        (onForm flipBy: #horizontal centerAt: onForm center)
                    overForm:    (overForm flipBy: #horizontal centerAt: overForm center)]
            ifFalse:[
                b _ ResizableToggleButton2 new
                    offForm:    offForm
                    onForm:        onForm
                    overForm:    overForm].
        b
            label: label font: (ScratchFrameMorph getFont: #Category);
            setLabelColor: Color white;
            target: self;
            actionSelector: #currentCategory:;
            arguments: (Array with: cat);
            toggleButtonMode: true;
            toggleMode: false.
        ScratchTranslator isRTL
            ifTrue:[b rightJustifyInset: 10]
            ifFalse:[b leftJustifyInset: 10].
        maxExtent _ maxExtent max: (b extent + (3 @ -6)).
        b].

    "calculate catButtonsExtent"
    pad _ 15. "padding on left, right, and betwen the button columns"
    catButtonsExtent _ ((2 * maxExtent x) + (3 * pad)) @ (((catList size // 2) * (maxExtent y + 6)) + 25).

    "place the buttons"
    leftColumnX _ self left + 12 + pad.
    rightColumnX _ leftColumnX + maxExtent x + pad.
    x _ leftColumnX.
    y _ self top + 17.
    1 to: buttons size do: [:i |
        b _ buttons at: i.
        b extent: maxExtent.
        self addMorph: (b position: x@y).
        i even
            ifTrue: [x _ leftColumnX. y _ y + b height + 6]
            ifFalse: [x _ rightColumnX]].

    self width: catButtonsExtent x.
    pageViewer position: self position + (0@catButtonsExtent y).
    topSectionHeight _ catButtonsExtent y - 4.

That is for the source version. For the non-source version, well, if you want that, either work it out yourself or post a request.

NOTE: You cannot add categories using this. I might try and find a shortcut for that some time that doesn't use the ScratchSkin. For the moment, just wait...


/* No comment */

Offline

 

#2 2011-03-12 13:10:50

scratcher7_13
Scratcher
Registered: 2011-02-09
Posts: 1000+

Re: The EASY way to rename categories

Request!!!!!


♫ 90% of teens can't do math. If you are one of the 40% of teens who can, copy and paste this into your signature. ♫♪
http://dl.dropbox.com/u/6273449/BlockLibraryTitle.pnghttp://i.imgur.com/mr9Hf.gif

Offline

 

#3 2011-04-22 14:34:41

scratcher7_13
Scratcher
Registered: 2011-02-09
Posts: 1000+

Re: The EASY way to rename categories

Hey, It works with the non-source code version too!


♫ 90% of teens can't do math. If you are one of the 40% of teens who can, copy and paste this into your signature. ♫♪
http://dl.dropbox.com/u/6273449/BlockLibraryTitle.pnghttp://i.imgur.com/mr9Hf.gif

Offline

 

Board footer