pen, operators, looks, variables, etc...
Offline
Okay. Here's how you do it. Unfortunately, I can't help you at the moment with giving the category a new color. But anyways, here it is:
First, hack Scratch. (duh).
Now, middle-click on the Scratch, and press the little red button that shows a menu. A menu should pop up. Now, select 'debug...' and then 'inspect morph'. In the window that pops up, copy the following code into the pane at the bottom. Replace all (category) with the new category you want to add.
ScratchSkin at: #(category) put: (ScratchFrameMorph skinAt: #control). ScratchSkin at: #(category)Over put: (ScratchFrameMorph skinAt: #controlOver). ScratchSkin at: #(category)Pressed put: (ScratchFrameMorph skinAt: #controlPressed).
Now highlight it, right-click on the text, and select 'do it'.
Step 1 done. What you just did allows you to add a new category without getting an error.
Now, click the gray, select 'open...' on the menu, and select 'workspace'. Then copy the following code into the text area. Again, replace the (category) with the new category name.
!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! !Highlight all the text, right-click on the text, select 'more...' and then 'file it in'.
Step 2 done. Now you have added a new category.
Done! Now all you have to do is save the Scratch image. Open Scratch back up, and you will see a new category! It is the same color as the 'Control' category, but I can't fix that right now. I'll ask one of the Panther devs about that (Panther has 2 new categories: Files and Colors, which have their own colors.). Also, you need to have an even number of categories, so be sure to do this an even number of times.
Last edited by rubiks_cube_guy238 (2010-07-02 18:47:21)
Offline
any result on colours yet?
Offline
rubiks_cube_guy238 wrote:
Code:
ScratchSkin at: #(category) put: (ScratchFrameMorph skinAt: #control). ScratchSkin at: #(category)Over put: (ScratchFrameMorph skinAt: #controlOver). ScratchSkin at: #(category)Pressed put: (ScratchFrameMorph skinAt: #controlPressed).
If you change control to (for example) operators, then the new category's color changes to green, motion to blue, etc.
Offline