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
9c377e28
Commit
9c377e28
authored
6 years ago
by
picklesrus
Browse files
Options
Downloads
Patches
Plain Diff
Add variables to the sensing block menu based on the value in the garget menu.
parent
6ee270cd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib/blocks.js
+10
-3
10 additions, 3 deletions
src/lib/blocks.js
with
10 additions
and
3 deletions
src/lib/blocks.js
+
10
−
3
View file @
9c377e28
...
@@ -245,18 +245,25 @@ export default function (vm) {
...
@@ -245,18 +245,25 @@ export default function (vm) {
// The block was in the flyout so look up future block info there.
// The block was in the flyout so look up future block info there.
lookupBlocks
=
vm
.
runtime
.
flyoutBlocks
;
lookupBlocks
=
vm
.
runtime
.
flyoutBlocks
;
}
}
// Get all the stage variables (no lists) so we can add them to menu when the stage is selected.
const
stageVariableOptions
=
vm
.
runtime
.
getTargetForStage
().
getAllVariableNamesInScopeByType
(
''
);
const
stageVariableMenuItems
=
stageVariableOptions
.
map
(
variable
=>
[
variable
,
variable
]);
if
(
sensingOfBlock
.
inputs
.
OBJECT
.
shadow
!==
sensingOfBlock
.
inputs
.
OBJECT
.
block
)
{
if
(
sensingOfBlock
.
inputs
.
OBJECT
.
shadow
!==
sensingOfBlock
.
inputs
.
OBJECT
.
block
)
{
// There's a block dropped on top of the menu. It'd be nice to evaluate it and
// There's a block dropped on top of the menu. It'd be nice to evaluate it and
// return the correct list, but that is tricky. Scratch2 just returns stage options
// return the correct list, but that is tricky. Scratch2 just returns stage options
// so just do that here too.
// so just do that here too.
return
stageOptions
;
return
stageOptions
.
concat
(
stageVariableMenuItems
)
;
}
}
const
menuBlock
=
lookupBlocks
.
getBlock
(
sensingOfBlock
.
inputs
.
OBJECT
.
shadow
);
const
menuBlock
=
lookupBlocks
.
getBlock
(
sensingOfBlock
.
inputs
.
OBJECT
.
shadow
);
const
selectedItem
=
menuBlock
.
fields
.
OBJECT
.
value
;
const
selectedItem
=
menuBlock
.
fields
.
OBJECT
.
value
;
if
(
selectedItem
===
'
_stage_
'
)
{
if
(
selectedItem
===
'
_stage_
'
)
{
return
stageOptions
;
return
stageOptions
.
concat
(
stageVariableMenuItems
)
;
}
}
return
spriteOptions
;
// Get all the local variables (no lists) and add them to the menu.
const
spriteVariableOptions
=
vm
.
runtime
.
getSpriteTargetByName
(
selectedItem
).
getAllVariableNamesInScopeByType
(
''
,
true
);
const
spriteVariableMenuItems
=
spriteVariableOptions
.
map
(
variable
=>
[
variable
,
variable
]);
return
spriteOptions
.
concat
(
spriteVariableMenuItems
);
}
}
return
[[
''
,
''
]];
return
[[
''
,
''
]];
};
};
...
...
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