Skip to content
Snippets Groups Projects
Commit ce629bc4 authored by Christopher Willis-Ford's avatar Christopher Willis-Ford
Browse files

Attempt to get monitor labels from VM

parent ed20a273
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ import MonitorComponent, {monitorModes} from '../components/monitor/monitor.jsx'
import {addMonitorRect, getInitialPosition, resizeMonitorRect, removeMonitorRect} from '../reducers/monitor-layout';
import {connect} from 'react-redux';
import VM from 'scratch-vm';
const availableModes = opcode => (
monitorModes.filter(t => {
......@@ -147,12 +148,14 @@ Monitor.propTypes = {
PropTypes.number
]))
]), // eslint-disable-line react/no-unused-prop-types
vm: PropTypes.instanceOf(VM),
width: PropTypes.number,
x: PropTypes.number,
y: PropTypes.number
};
const mapStateToProps = state => ({
monitorLayout: state.scratchGui.monitorLayout
monitorLayout: state.scratchGui.monitorLayout,
vm: state.scratchGui.vm
});
const mapDispatchToProps = dispatch => ({
addMonitorRect: (id, rect, savePosition) =>
......
......@@ -11,10 +11,11 @@ const isUndefined = a => typeof a === 'undefined';
* @param {string} block.opcode - The opcode of the monitor
* @param {object} block.params - Extra params to the monitor block
* @param {string|number|Array} block.value - The monitor value
* @param {VirtualMachine} block.vm - the VM instance which owns the block
* @return {object} The adapted monitor with label and category
*/
export default function ({id, spriteName, opcode, params, value}) {
let {label, category, labelFn} = OpcodeLabels(opcode);
export default function ({id, spriteName, opcode, params, value, vm}) {
let {label, category, labelFn} = (vm && vm.runtime.getLabelForOpcode(opcode)) || OpcodeLabels(opcode);
// Use labelFn if provided for dynamic labelling (e.g. variables)
if (!isUndefined(labelFn)) label = labelFn(params);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment