Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
logging-scratch-gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Goessmann
logging-scratch-gui
Commits
312fafab
Commit
312fafab
authored
8 years ago
by
Eric Rosenbaum
Browse files
Options
Downloads
Patches
Plain Diff
Dynamic menus for costumes and backdrops
parent
f2cad9c1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib/blocks.js
+49
-20
49 additions, 20 deletions
src/lib/blocks.js
with
49 additions
and
20 deletions
src/lib/blocks.js
+
49
−
20
View file @
312fafab
const
ScratchBlocks
=
require
(
'
scratch-blocks
'
);
module
.
exports
=
function
(
vm
)
{
const
jsonForMenuBlock
=
function
(
name
,
menuOptionsFn
,
colors
)
{
return
{
message0
:
'
%1
'
,
args0
:
[
{
type
:
'
field_dropdown
'
,
name
:
name
,
options
:
menuOptionsFn
}
],
inputsInline
:
true
,
output
:
'
String
'
,
colour
:
colors
.
secondary
,
colourSecondary
:
colors
.
secondary
,
colourTertiary
:
colors
.
tertiary
,
outputShape
:
ScratchBlocks
.
OUTPUT_SHAPE_ROUND
};
};
const
soundsMenu
=
function
()
{
return
vm
.
editingTarget
.
sprite
.
sounds
.
map
(
sound
=>
[
sound
.
name
,
sound
.
name
]);
};
const
costumesMenu
=
function
()
{
return
vm
.
editingTarget
.
sprite
.
costumes
.
map
(
costume
=>
[
costume
.
name
,
costume
.
name
]);
};
const
backdropsMenu
=
function
()
{
return
vm
.
runtime
.
targets
[
0
].
sprite
.
costumes
.
map
(
costume
=>
[
costume
.
name
,
costume
.
name
]);
};
const
soundColors
=
ScratchBlocks
.
Colours
.
sounds
;
const
looksColors
=
ScratchBlocks
.
Colours
.
looks
;
ScratchBlocks
.
Blocks
.
sound_sounds_menu
.
init
=
function
()
{
this
.
jsonInit
(
{
message0
:
'
%1
'
,
args0
:
[
{
type
:
'
field_dropdown
'
,
name
:
'
SOUND_MENU
'
,
options
:
function
()
{
const
menu
=
vm
.
editingTarget
.
sprite
.
sounds
.
map
(
sound
=>
[
sound
.
name
,
sound
.
name
]);
return
menu
;
}
}
],
inputsInline
:
true
,
output
:
'
String
'
,
colour
:
ScratchBlocks
.
Colours
.
sounds
.
secondary
,
colourSecondary
:
ScratchBlocks
.
Colours
.
sounds
.
secondary
,
colourTertiary
:
ScratchBlocks
.
Colours
.
sounds
.
tertiary
,
outputShape
:
ScratchBlocks
.
OUTPUT_SHAPE_ROUND
});
const
json
=
jsonForMenuBlock
(
'
SOUND_MENU
'
,
soundsMenu
,
soundColors
);
this
.
jsonInit
(
json
);
};
ScratchBlocks
.
Blocks
.
looks_costume
.
init
=
function
()
{
const
json
=
jsonForMenuBlock
(
'
COSTUME
'
,
costumesMenu
,
looksColors
);
this
.
jsonInit
(
json
);
};
ScratchBlocks
.
Blocks
.
looks_backdrops
.
init
=
function
()
{
const
json
=
jsonForMenuBlock
(
'
BACKDROP
'
,
backdropsMenu
,
looksColors
);
this
.
jsonInit
(
json
);
};
return
ScratchBlocks
;
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment