GeezerVison is showing github.com — fix: temporarily disable functionality in scratch-gui for compatibili… · SnoopyMod/snoopymod.github.io@905f043
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/containers/blocks.jsx +33-22Lines changed: 33 additions & 22 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -95,14 +95,24 @@ class Blocks extends React.Component { | 95 | 95 | this.ScratchBlocks.statusButtonCallback = this.handleConnectionModalStart; | 96 | 96 | this.ScratchBlocks.recordSoundCallback = this.handleOpenSoundRecorder; | 97 | 97 |
| 98 | | - this.ScratchBlocks.FieldColourSlider.activateEyedropper_ = this.props.onActivateColorPicker; | | 98 | + // this.ScratchBlocks.FieldColourSlider.activateEyedropper_ = this.props.onActivateColorPicker; | 99 | 99 | this.ScratchBlocks.Procedures.externalProcedureDefCallback = this.props.onActivateCustomProcedures; | 100 | 100 | this.ScratchBlocks.ScratchMsgs.setLocale(this.props.locale); | 101 | 101 |
| | 102 | + const theme = this.ScratchBlocks.Theme.defineTheme('Scratch', { | | 103 | + 'base': this.ScratchBlocks.Themes.Zelos, | | 104 | + 'startHats': true | | 105 | + }); | 102 | 106 | const workspaceConfig = defaultsDeep({}, | 103 | 107 | Blocks.defaultOptions, | 104 | 108 | this.props.options, | 105 | | - {rtl: this.props.isRtl, toolbox: this.props.toolboxXML, colours: getColorsForTheme(this.props.theme)} | | 109 | + { | | 110 | + rtl: this.props.isRtl, | | 111 | + toolbox: this.props.toolboxXML, | | 112 | + colours: getColorsForTheme(this.props.theme), | | 113 | + renderer: 'zelos', | | 114 | + theme: theme, | | 115 | + } | 106 | 116 | ); | 107 | 117 | this.workspace = this.ScratchBlocks.inject(this.blocks, workspaceConfig); | 108 | 118 |
| @@ -129,10 +139,11 @@ class Blocks extends React.Component { | 129 | 139 | // we actually never want the workspace to enable "refresh toolbox" - this basically re-renders the | 130 | 140 | // entire toolbox every time we reset the workspace. We call updateToolbox as a part of | 131 | 141 | // componentDidUpdate so the toolbox will still correctly be updated | 132 | | - this.setToolboxRefreshEnabled = this.workspace.setToolboxRefreshEnabled.bind(this.workspace); | 133 | | - this.workspace.setToolboxRefreshEnabled = () => { | 134 | | - this.setToolboxRefreshEnabled(false); | 135 | | - }; | | 142 | + this.setToolboxRefreshEnabled = () => {}; | | 143 | + // this.workspace.setToolboxRefreshEnabled.bind(this.workspace); | | 144 | + // this.workspace.setToolboxRefreshEnabled = () => { | | 145 | + // this.setToolboxRefreshEnabled(false); | | 146 | + // }; | 136 | 147 |
| 137 | 148 | // @todo change this when blockly supports UI events | 138 | 149 | addFunctionListener(this.workspace, 'translate', this.onWorkspaceMetricsChange); | @@ -213,20 +224,20 @@ class Blocks extends React.Component { | 213 | 224 | this.ScratchBlocks.ScratchMsgs.setLocale(this.props.locale); | 214 | 225 | this.props.vm.setLocale(this.props.locale, this.props.messages) | 215 | 226 | .then(() => { | 216 | | - this.workspace.getFlyout().setRecyclingEnabled(false); | | 227 | + // this.workspace.getFlyout().setRecyclingEnabled(false); | 217 | 228 | this.props.vm.refreshWorkspace(); | 218 | 229 | this.requestToolboxUpdate(); | 219 | 230 | this.withToolboxUpdates(() => { | 220 | | - this.workspace.getFlyout().setRecyclingEnabled(true); | | 231 | + // this.workspace.getFlyout().setRecyclingEnabled(true); | 221 | 232 | }); | 222 | 233 | }); | 223 | 234 | } | 224 | 235 |
| 225 | 236 | updateToolbox () { | 226 | 237 | this.toolboxUpdateTimeout = false; | 227 | 238 |
| 228 | | - const categoryId = this.workspace.toolbox_.getSelectedCategoryId(); | 229 | | - const offset = this.workspace.toolbox_.getCategoryScrollOffset(); | | 239 | + // const categoryId = this.workspace.toolbox_.getSelectedItem().getId(); | | 240 | + // const offset = this.workspace.toolbox_.getCategoryScrollOffset(); | 230 | 241 | this.workspace.updateToolbox(this.props.toolboxXML); | 231 | 242 | this._renderedToolboxXML = this.props.toolboxXML; | 232 | 243 |
| @@ -235,13 +246,13 @@ class Blocks extends React.Component { | 235 | 246 | // Using the setter function will rerender the entire toolbox which we just rendered. | 236 | 247 | this.workspace.toolboxRefreshEnabled_ = true; | 237 | 248 |
| 238 | | - const currentCategoryPos = this.workspace.toolbox_.getCategoryPositionById(categoryId); | 239 | | - const currentCategoryLen = this.workspace.toolbox_.getCategoryLengthById(categoryId); | 240 | | - if (offset < currentCategoryLen) { | 241 | | - this.workspace.toolbox_.setFlyoutScrollPos(currentCategoryPos + offset); | 242 | | - } else { | 243 | | - this.workspace.toolbox_.setFlyoutScrollPos(currentCategoryPos); | 244 | | - } | | 249 | + // const currentCategoryPos = this.workspace.toolbox_.getCategoryPositionById(categoryId); | | 250 | + // const currentCategoryLen = this.workspace.toolbox_.getCategoryLengthById(categoryId); | | 251 | + // if (offset < currentCategoryLen) { | | 252 | + // this.workspace.toolbox_.setFlyoutScrollPos(currentCategoryPos + offset); | | 253 | + // } else { | | 254 | + // this.workspace.toolbox_.setFlyoutScrollPos(currentCategoryPos); | | 255 | + // } | 245 | 256 |
| 246 | 257 | const queue = this.toolboxUpdateQueue; | 247 | 258 | this.toolboxUpdateQueue = []; | @@ -329,16 +340,16 @@ class Blocks extends React.Component { | 329 | 340 | } | 330 | 341 | } | 331 | 342 | onScriptGlowOn (data) { | 332 | | - this.workspace.glowStack(data.id, true); | | 343 | + // this.workspace.glowStack(data.id, true); | 333 | 344 | } | 334 | 345 | onScriptGlowOff (data) { | 335 | | - this.workspace.glowStack(data.id, false); | | 346 | + // this.workspace.glowStack(data.id, false); | 336 | 347 | } | 337 | 348 | onBlockGlowOn (data) { | 338 | | - this.workspace.glowBlock(data.id, true); | | 349 | + // this.workspace.glowBlock(data.id, true); | 339 | 350 | } | 340 | 351 | onBlockGlowOff (data) { | 341 | | - this.workspace.glowBlock(data.id, false); | | 352 | + // this.workspace.glowBlock(data.id, false); | 342 | 353 | } | 343 | 354 | onVisualReport (data) { | 344 | 355 | this.workspace.reportValue(data.id, data.value); | @@ -382,7 +393,7 @@ class Blocks extends React.Component { | 382 | 393 |
| 383 | 394 | // Remove and reattach the workspace listener (but allow flyout events) | 384 | 395 | this.workspace.removeChangeListener(this.props.vm.blockListener); | 385 | | - const dom = this.ScratchBlocks.Xml.textToDom(data.xml); | | 396 | + const dom = this.ScratchBlocks.utils.xml.textToDom(data.xml); | 386 | 397 | try { | 387 | 398 | this.ScratchBlocks.Xml.clearWorkspaceAndLoadFromXml(dom, this.workspace); | 388 | 399 | } catch (error) { | |
Collapse file Copy file name to clipboardExpand all lines: src/lib/blocks.js +25-15Lines changed: 25 additions & 15 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 5 | 5 | * @return {ScratchBlocks} ScratchBlocks connected with the vm | 6 | 6 | */ | 7 | 7 | export default function (vm, useCatBlocks) { | 8 | | - const ScratchBlocks = useCatBlocks ? require('cat-blocks') : require('scratch-blocks'); | | 8 | + const {ScratchBlocks} = useCatBlocks ? require('cat-blocks') : require('scratch-blocks'); | 9 | 9 | const jsonForMenuBlock = function (name, menuOptionsFn, colors, start) { | 10 | 10 | return { | 11 | 11 | message0: '%1', | @@ -82,7 +82,7 @@ export default function (vm, useCatBlocks) { | 82 | 82 | } | 83 | 83 | menu.push([ | 84 | 84 | ScratchBlocks.ScratchMsgs.translate('SOUND_RECORD', 'record...'), | 85 | | - ScratchBlocks.recordSoundCallback | | 85 | + 'SOUND_RECORD' | 86 | 86 | ]); | 87 | 87 | return menu; | 88 | 88 | }; | @@ -158,6 +158,16 @@ export default function (vm, useCatBlocks) { | 158 | 158 | ScratchBlocks.Blocks.sound_sounds_menu.init = function () { | 159 | 159 | const json = jsonForMenuBlock('SOUND_MENU', soundsMenu, soundColors, []); | 160 | 160 | this.jsonInit(json); | | 161 | + this.inputList[0].removeField('SOUND_MENU'); | | 162 | + this.inputList[0].appendField(new ScratchBlocks.FieldDropdown(() => { | | 163 | + return soundsMenu(); | | 164 | + }, (newValue) => { | | 165 | + if (newValue === 'SOUND_RECORD') { | | 166 | + ScratchBlocks.recordSoundCallback(); | | 167 | + return null; | | 168 | + } | | 169 | + return newValue; | | 170 | + }), 'SOUND_MENU'); | 161 | 171 | }; | 162 | 172 |
| 163 | 173 | ScratchBlocks.Blocks.looks_costume.init = function () { | @@ -323,16 +333,16 @@ export default function (vm, useCatBlocks) { | 323 | 333 | return monitoredBlock ? monitoredBlock.isMonitored : false; | 324 | 334 | }; | 325 | 335 |
| 326 | | - ScratchBlocks.FlyoutExtensionCategoryHeader.getExtensionState = function (extensionId) { | 327 | | - if (vm.getPeripheralIsConnected(extensionId)) { | 328 | | - return ScratchBlocks.StatusButtonState.READY; | 329 | | - } | 330 | | - return ScratchBlocks.StatusButtonState.NOT_READY; | 331 | | - }; | 332 | | - | 333 | | - ScratchBlocks.FieldNote.playNote_ = function (noteNum, extensionId) { | 334 | | - vm.runtime.emit('PLAY_NOTE', noteNum, extensionId); | 335 | | - }; | | 336 | + // ScratchBlocks.FlyoutExtensionCategoryHeader.getExtensionState = function (extensionId) { | | 337 | + // if (vm.getPeripheralIsConnected(extensionId)) { | | 338 | + // return ScratchBlocks.StatusButtonState.READY; | | 339 | + // } | | 340 | + // return ScratchBlocks.StatusButtonState.NOT_READY; | | 341 | + // }; | | 342 | + // | | 343 | + // ScratchBlocks.FieldNote.playNote_ = function (noteNum, extensionId) { | | 344 | + // vm.runtime.emit('PLAY_NOTE', noteNum, extensionId); | | 345 | + // }; | 336 | 346 |
| 337 | 347 | // Use a collator's compare instead of localeCompare which internally | 338 | 348 | // creates a collator. Using this is a lot faster in browsers that create a | @@ -341,9 +351,9 @@ export default function (vm, useCatBlocks) { | 341 | 351 | sensitivity: 'base', | 342 | 352 | numeric: true | 343 | 353 | }); | 344 | | - ScratchBlocks.scratchBlocksUtils.compareStrings = function (str1, str2) { | 345 | | - return collator.compare(str1, str2); | 346 | | - }; | | 354 | + // ScratchBlocks.scratchBlocksUtils.compareStrings = function (str1, str2) { | | 355 | + // return collator.compare(str1, str2); | | 356 | + // }; | 347 | 357 |
| 348 | 358 | // Blocks wants to know if 3D CSS transforms are supported. The cross | 349 | 359 | // section of browsers Scratch supports and browsers that support 3D CSS | |
Collapse file Copy file name to clipboardExpand all lines: src/lib/make-toolbox-xml.js +10-10Lines changed: 10 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import ScratchBlocks from 'scratch-blocks'; | | 1 | +import {ScratchBlocks} from 'scratch-blocks'; | 2 | 2 | import {defaultColors} from './themes'; | 3 | 3 |
| 4 | 4 | const categorySeparator = '<sep gap="36"/>'; | @@ -13,7 +13,7 @@ const motion = function (isInitialSetup, isStage, targetId, colors) { | 13 | 13 | ); | 14 | 14 | // Note: the category's secondaryColour matches up with the blocks' tertiary color, both used for border color. | 15 | 15 | return ` | 16 | | - <category name="%{BKY_CATEGORY_MOTION}" id="motion" colour="${colors.primary}" secondaryColour="${colors.tertiary}"> | | 16 | + <category name="${ScratchBlocks.ScratchMsgs.translate('CATEGORY_MOTION', 'Motion')}" id="motion" colour="${colors.primary}" secondaryColour="${colors.tertiary}"> | 17 | 17 | ${isStage ? ` | 18 | 18 | <label text="${stageSelected}"></label> | 19 | 19 | ` : ` | @@ -158,7 +158,7 @@ const looks = function (isInitialSetup, isStage, targetId, costumeName, backdrop | 158 | 158 | const hmm = ScratchBlocks.ScratchMsgs.translate('LOOKS_HMM', 'Hmm...'); | 159 | 159 | // Note: the category's secondaryColour matches up with the blocks' tertiary color, both used for border color. | 160 | 160 | return ` | 161 | | - <category name="%{BKY_CATEGORY_LOOKS}" id="looks" colour="${colors.primary}" secondaryColour="${colors.tertiary}"> | | 161 | + <category name="${ScratchBlocks.ScratchMsgs.translate('CATEGORY_LOOKS', 'Looks')}" id="looks" colour="${colors.primary}" secondaryColour="${colors.tertiary}"> | 162 | 162 | ${isStage ? '' : ` | 163 | 163 | <block type="looks_sayforsecs"> | 164 | 164 | <value name="MESSAGE"> | @@ -294,7 +294,7 @@ const looks = function (isInitialSetup, isStage, targetId, costumeName, backdrop | 294 | 294 | const sound = function (isInitialSetup, isStage, targetId, soundName, colors) { | 295 | 295 | // Note: the category's secondaryColour matches up with the blocks' tertiary color, both used for border color. | 296 | 296 | return ` | 297 | | - <category name="%{BKY_CATEGORY_SOUND}" id="sound" colour="${colors.primary}" secondaryColour="${colors.tertiary}"> | | 297 | + <category name="${ScratchBlocks.ScratchMsgs.translate('CATEGORY_SOUND', 'Sound')}" id="sound" colour="${colors.primary}" secondaryColour="${colors.tertiary}"> | 298 | 298 | <block id="${targetId}_sound_playuntildone" type="sound_playuntildone"> | 299 | 299 | <value name="SOUND_MENU"> | 300 | 300 | <shadow type="sound_sounds_menu"> | @@ -350,7 +350,7 @@ const sound = function (isInitialSetup, isStage, targetId, soundName, colors) { | 350 | 350 | const events = function (isInitialSetup, isStage, targetId, colors) { | 351 | 351 | // Note: the category's secondaryColour matches up with the blocks' tertiary color, both used for border color. | 352 | 352 | return ` | 353 | | - <category name="%{BKY_CATEGORY_EVENTS}" id="events" colour="${colors.primary}" secondaryColour="${colors.tertiary}"> | | 353 | + <category name="${ScratchBlocks.ScratchMsgs.translate('CATEGORY_EVENTS', 'Events')}" id="events" colour="${colors.primary}" secondaryColour="${colors.tertiary}"> | 354 | 354 | <block type="event_whenflagclicked"/> | 355 | 355 | <block type="event_whenkeypressed"> | 356 | 356 | </block> | @@ -391,7 +391,7 @@ const control = function (isInitialSetup, isStage, targetId, colors) { | 391 | 391 | // Note: the category's secondaryColour matches up with the blocks' tertiary color, both used for border color. | 392 | 392 | return ` | 393 | 393 | <category | 394 | | - name="%{BKY_CATEGORY_CONTROL}" | | 394 | + name="${ScratchBlocks.ScratchMsgs.translate('CATEGORY_CONTROL', 'Control')}" | 395 | 395 | id="control" | 396 | 396 | colour="${colors.primary}" | 397 | 397 | secondaryColour="${colors.tertiary}"> | @@ -444,7 +444,7 @@ const sensing = function (isInitialSetup, isStage, targetId, colors) { | 444 | 444 | // Note: the category's secondaryColour matches up with the blocks' tertiary color, both used for border color. | 445 | 445 | return ` | 446 | 446 | <category | 447 | | - name="%{BKY_CATEGORY_SENSING}" | | 447 | + name="${ScratchBlocks.ScratchMsgs.translate('CATEGORY_SENSING', 'Sensing')}" | 448 | 448 | id="sensing" | 449 | 449 | colour="${colors.primary}" | 450 | 450 | secondaryColour="${colors.tertiary}"> | @@ -526,7 +526,7 @@ const operators = function (isInitialSetup, isStage, targetId, colors) { | 526 | 526 | // Note: the category's secondaryColour matches up with the blocks' tertiary color, both used for border color. | 527 | 527 | return ` | 528 | 528 | <category | 529 | | - name="%{BKY_CATEGORY_OPERATORS}" | | 529 | + name="${ScratchBlocks.ScratchMsgs.translate('CATEGORY_OPERATORS', 'Operators')}" | 530 | 530 | id="operators" | 531 | 531 | colour="${colors.primary}" | 532 | 532 | secondaryColour="${colors.tertiary}"> | @@ -715,7 +715,7 @@ const variables = function (isInitialSetup, isStage, targetId, colors) { | 715 | 715 | // Note: the category's secondaryColour matches up with the blocks' tertiary color, both used for border color. | 716 | 716 | return ` | 717 | 717 | <category | 718 | | - name="%{BKY_CATEGORY_VARIABLES}" | | 718 | + name="${ScratchBlocks.ScratchMsgs.translate('CATEGORY_VARIABLES', 'Variables')}" | 719 | 719 | id="variables" | 720 | 720 | colour="${colors.primary}" | 721 | 721 | secondaryColour="${colors.tertiary}" | @@ -728,7 +728,7 @@ const myBlocks = function (isInitialSetup, isStage, targetId, colors) { | 728 | 728 | // Note: the category's secondaryColour matches up with the blocks' tertiary color, both used for border color. | 729 | 729 | return ` | 730 | 730 | <category | 731 | | - name="%{BKY_CATEGORY_MYBLOCKS}" | | 731 | + name="${ScratchBlocks.ScratchMsgs.translate('CATEGORY_MYBLOCKS', 'My Blocks')}" | 732 | 732 | id="myBlocks" | 733 | 733 | colour="${colors.primary}" | 734 | 734 | secondaryColour="${colors.tertiary}" | |
|