From d8d1810e436cba83144f4b2234fc3097a739208b Mon Sep 17 00:00:00 2001 From: Hardmath123 Date: Sun, 22 Dec 2013 16:28:11 -0800 Subject: Initial stop others block --- objects.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'objects.js') diff --git a/objects.js b/objects.js index 41b511d..614e7d7 100644 --- a/objects.js +++ b/objects.js @@ -591,6 +591,11 @@ SpriteMorph.prototype.initBlocks = function () { category: 'control', spec: 'stop all %stop' }, + doStopOthers: { + type: 'command', + category: 'control', + spec: 'stop other scripts in sprite' + }, doRun: { type: 'command', category: 'control', @@ -1649,6 +1654,7 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push(block('doStopBlock')); blocks.push(block('doStop')); blocks.push(block('doStopAll')); + blocks.push(block('doStopOthers')); blocks.push('-'); blocks.push(block('doRun')); blocks.push(block('fork')); -- cgit v1.3.1 From 8646dfc35ed3d11a2e23ecd545ecef47ef53f8b2 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 8 Jan 2014 12:18:04 +0100 Subject: support for TELL and ASK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The FOR reporter’s first input now also accepts blocks and scripts („rings“), and reports a copy that is bound to the sprite indicated by the second input. This lets you „zombify“ (or remote-control) sprites (and create custom TELL and ASK blocks) --- blocks.js | 3 +-- history.txt | 4 ++++ objects.js | 2 +- threads.js | 17 ++++++++++++++++- 4 files changed, 22 insertions(+), 4 deletions(-) (limited to 'objects.js') diff --git a/blocks.js b/blocks.js index 96d8b53..619a487 100644 --- a/blocks.js +++ b/blocks.js @@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2013-November-26'; +modules.blocks = '2014-January-08'; var SyntaxElementMorph; var BlockMorph; @@ -996,7 +996,6 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { 'attributesMenu', true ); - part.isStatic = true; break; case '%fun': part = new InputSlotMorph( diff --git a/history.txt b/history.txt index 642ea7f..d205744 100755 --- a/history.txt +++ b/history.txt @@ -2044,3 +2044,7 @@ ______ ------ * Objects: stage watchers for „mouse x“ and „mouse y“ sensing reporters. Thanks, Michael! * Store: fixed saving/loading/localisation of new mouse coordinate stage watchers + +140108 +------ +* Threads, Blocks, Objects: The FOR reporter’s first input now also accepts blocks and scripts („rings“), and reports a copy that is bound to the sprite indicated by the second input. This lets you „zombify“ (or remote-control) sprites (and create custom TELL and ASK blocks) diff --git a/objects.js b/objects.js index 41b511d..67eb143 100644 --- a/objects.js +++ b/objects.js @@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2013-December-19'; +modules.objects = '2014-January-08'; var SpriteMorph; var StageMorph; diff --git a/threads.js b/threads.js index d1e57d3..19f5fd8 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2013-December-11'; +modules.threads = '2014-January-08'; var ThreadManager; var Process; @@ -2377,6 +2377,9 @@ Process.prototype.reportAttributeOf = function (attribute, name) { thatObj = this.getOtherObject(name, thisObj, stage); } if (thatObj) { + if (attribute instanceof Context) { + return this.reportContextFor(attribute, thatObj); + } if (isString(attribute)) { return thatObj.variables.getVar(attribute); } @@ -2401,6 +2404,18 @@ Process.prototype.reportAttributeOf = function (attribute, name) { return ''; }; +Process.prototype.reportContextFor = function (context, otherObj) { + // Private - return a copy of the context + // and bind it to another receiver + var result = copy(context); + result.receiver = otherObj; + if (result.outerContext) { + result.outerContext = copy(result.outerContext); + result.outerContext.receiver = otherObj; + } + return result; +}; + Process.prototype.reportMouseX = function () { var stage, world; if (this.homeContext.receiver) { -- cgit v1.3.1 From 71c458e7e895d2f434cd2cb2401da882558b923a Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 8 Jan 2014 15:23:09 +0100 Subject: Only shrink-wrap sprite costumes thanks, Kartik, for this fix! --- history.txt | 1 + objects.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 37d1d6b..168b255 100755 --- a/history.txt +++ b/history.txt @@ -2050,3 +2050,4 @@ ______ * Threads, Blocks, Objects: The FOR reporter’s first input now also accepts blocks and scripts („rings“), and reports a copy that is bound to the sprite indicated by the second input. This lets you „zombify“ (or remote-control) sprites (and create custom TELL and ASK blocks) * Blocks: initial support for „sensing“ sprite-only custom block definitions, commented out for now * Paint: Add mouseLeaveDragging() event behavior, thanks, Kartik, for this fix! +* Objects: Only shrink-wrap sprite costumes, thanks, Kartik, for this fix! diff --git a/objects.js b/objects.js index 67eb143..e8a934e 100644 --- a/objects.js +++ b/objects.js @@ -5263,7 +5263,10 @@ Costume.prototype.edit = function (aWorld, anIDE, isnew, oncancel, onsubmit) { function (img, rc) { myself.contents = img; myself.rotationCenter = rc; - myself.shrinkWrap(); + if (anIDE.currentSprite instanceof SpriteMorph) { + // don't shrinkwrap stage costumes + myself.shrinkWrap(); + } myself.version = Date.now(); aWorld.changed(); if (anIDE) { -- cgit v1.3.1 From 1e959b8891df838b18c3bae40ba941c5f74df5cb Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 8 Jan 2014 17:51:34 +0100 Subject: fixed StopOthers blocks and added another option also updated the German translation --- blocks.js | 13 +++++++++++++ lang-de.js | 8 +++++++- locale.js | 4 ++-- objects.js | 3 ++- threads.js | 44 ++++++++++++++++++++++++++------------------ 5 files changed, 50 insertions(+), 22 deletions(-) (limited to 'objects.js') diff --git a/blocks.js b/blocks.js index 8b6bcc2..1ad2239 100644 --- a/blocks.js +++ b/blocks.js @@ -1037,6 +1037,19 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { ); part.setContents(['encode URI']); break; + case '%stopOthersChoices': + part = new InputSlotMorph( + null, + false, + { + 'all but this script' : ['all but this script'], + 'other scripts in sprite' : ['other scripts in sprite'] + }, + true + ); + part.setContents(['all but this script']); + part.isStatic = true; + break; case '%typ': part = new InputSlotMorph( null, diff --git a/lang-de.js b/lang-de.js index dec6092..1ed3f4f 100644 --- a/lang-de.js +++ b/lang-de.js @@ -185,7 +185,7 @@ SnapTranslator.dict.de = { 'translator_e-mail': 'jens@moenig.org', // optional 'last_changed': - '2013-10-04', // this, too, will appear in the Translators tab + '2018-01-08', // this, too, will appear in the Translators tab // GUI // control bar: @@ -453,6 +453,12 @@ SnapTranslator.dict.de = { 'stoppe dieses Skript', 'stop all %stop': 'stoppe alles %stop', + 'stop %stopOthersChoices': + 'stoppe %stopOthersChoices', + 'all but this script': + 'alles au\u00dfer diesem Skript', + 'other scripts in sprite': + 'andere Skripte in diesem Objekt', 'pause all %pause': 'pausiere alles %pause', 'run %cmdRing %inputs': diff --git a/locale.js b/locale.js index f894050..fd12371 100644 --- a/locale.js +++ b/locale.js @@ -42,7 +42,7 @@ /*global modules, contains*/ -modules.locale = '2013-December-04'; +modules.locale = '2014-January-08'; // Global stuff @@ -149,7 +149,7 @@ SnapTranslator.dict.de = { 'translator_e-mail': 'jens@moenig.org', 'last_changed': - '2013-10-04' + '2014-01-08' }; SnapTranslator.dict.it = { diff --git a/objects.js b/objects.js index fa9be12..9f892d4 100644 --- a/objects.js +++ b/objects.js @@ -594,7 +594,7 @@ SpriteMorph.prototype.initBlocks = function () { doStopOthers: { type: 'command', category: 'control', - spec: 'stop other scripts in sprite' + spec: 'stop %stopOthersChoices' }, doRun: { type: 'command', @@ -4361,6 +4361,7 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push(block('doStopBlock')); blocks.push(block('doStop')); blocks.push(block('doStopAll')); + blocks.push(block('doStopOthers')); blocks.push('-'); blocks.push(block('doRun')); blocks.push(block('fork')); diff --git a/threads.js b/threads.js index 7d7b50a..8c3eb25 100644 --- a/threads.js +++ b/threads.js @@ -151,26 +151,19 @@ ThreadManager.prototype.startProcess = function (block, isThreadSafe) { return newProc; }; -ThreadManager.prototype.stopAll = function () { +ThreadManager.prototype.stopAll = function (excpt) { + // excpt is optional this.processes.forEach(function (proc) { - proc.stop(); - }); -}; - -ThreadManager.prototype.stopAllForReceiver = function (rcvr) { - this.processes.forEach(function (proc) { - if (proc.homeContext.receiver === rcvr) { + if (proc !== excpt) { proc.stop(); - if (rcvr.isClone) { - proc.isDead = true; - } } }); }; -ThreadManager.prototype.stopAllForReceiverExcept = function (rcvr, excpt) { +ThreadManager.prototype.stopAllForReceiver = function (rcvr, excpt) { + // excpt is optional this.processes.forEach(function (proc) { - if (proc.homeContext.receiver === rcvr && proc != excpt) { + if (proc.homeContext.receiver === rcvr && proc !== excpt) { proc.stop(); if (rcvr.isClone) { proc.isDead = true; @@ -1379,12 +1372,25 @@ Process.prototype.doStopAll = function () { } }; -Process.prototype.doStopOthers = function () { - var stage, ide; +Process.prototype.doStopOthers = function (choice) { + var stage; if (this.homeContext.receiver) { stage = this.homeContext.receiver.parentThatIsA(StageMorph); if (stage) { - stage.threads.stopAllForReceiverExcept(this.homeContext.receiver, this); + + switch (this.inputOption(choice)) { + case 'all but this script': + stage.threads.stopAll(this); + break; + case 'other scripts in sprite': + stage.threads.stopAllForReceiver( + this.homeContext.receiver, + this + ); + break; + default: + nop(); + } } } }; @@ -1751,8 +1757,10 @@ Process.prototype.reportURL = function (url) { if (!this.httpRequest) { this.httpRequest = new XMLHttpRequest(); this.httpRequest.open("GET", 'http://' + url, true); - this.httpRequest.setRequestHeader("X-Requested-With", - "XMLHttpRequest"); + this.httpRequest.setRequestHeader( + "X-Requested-With", + "XMLHttpRequest" + ); this.httpRequest.setRequestHeader("X-Application", "Snap! 4.0"); this.httpRequest.send(null); } else if (this.httpRequest.readyState === 4) { -- cgit v1.3.1 From 8a1ca3116b834625e6f71c6376c115975d4f9d75 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 9 Jan 2014 15:34:12 +0100 Subject: Collapse STOP primitives into a single block with a dropdown of options --- blocks.js | 17 ++++++++++++++++- history.txt | 5 +++++ objects.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- threads.js | 19 +++++++++++++++++-- 4 files changed, 84 insertions(+), 12 deletions(-) (limited to 'objects.js') diff --git a/blocks.js b/blocks.js index 1ad2239..9997d70 100644 --- a/blocks.js +++ b/blocks.js @@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2014-January-08'; +modules.blocks = '2014-January-09'; var SyntaxElementMorph; var BlockMorph; @@ -1037,6 +1037,20 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { ); part.setContents(['encode URI']); break; + case '%stopChoices': + part = new InputSlotMorph( + null, + false, + { + 'all' : ['all'], + 'this script' : ['this script'], + 'this block' : ['this block'] + }, + true + ); + part.setContents(['all']); + part.isStatic = true; + break; case '%stopOthersChoices': part = new InputSlotMorph( null, @@ -3279,6 +3293,7 @@ CommandBlockMorph.prototype.snap = function () { CommandBlockMorph.prototype.isStop = function () { return ([ + 'doStopThis', 'doStop', 'doStopBlock', 'doStopAll', diff --git a/history.txt b/history.txt index a82204d..70c57bc 100755 --- a/history.txt +++ b/history.txt @@ -2055,3 +2055,8 @@ ______ * Threads, Blocks, Objects: Added StopOthers primitive, thanks, Kartik! * Added „all but this option“ to StopOthers primitive, fixed the implementation * Updated German translation with new strings + +140109 +------ +* Objects: Mechanism for migrating blocks in existing projects to newer versions +* Blocks, Objects, Threads: Collapse old STOP primitives into a single one with a dropdown of options diff --git a/objects.js b/objects.js index 9f892d4..3f3df76 100644 --- a/objects.js +++ b/objects.js @@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-January-08'; +modules.objects = '2014-January-09'; var SpriteMorph; var StageMorph; @@ -581,6 +581,9 @@ SpriteMorph.prototype.initBlocks = function () { category: 'control', spec: 'if %b %c else %c' }, + + /* migrated to a newer block version: + doStop: { type: 'command', category: 'control', @@ -591,6 +594,13 @@ SpriteMorph.prototype.initBlocks = function () { category: 'control', spec: 'stop all %stop' }, + */ + + doStopThis: { + type: 'command', + category: 'control', + spec: 'stop %stopChoices' + }, doStopOthers: { type: 'command', category: 'control', @@ -635,11 +645,13 @@ SpriteMorph.prototype.initBlocks = function () { category: 'control', spec: 'report %s' }, - doStopBlock: { + /* + doStopBlock: { // migrated to a newer block version type: 'command', category: 'control', spec: 'stop block' }, + */ doCallCC: { type: 'command', category: 'control', @@ -1084,6 +1096,25 @@ SpriteMorph.prototype.initBlocks = function () { SpriteMorph.prototype.initBlocks(); +SpriteMorph.prototype.initBlockMigrations = function () { + SpriteMorph.prototype.blockMigrations = { + doStopAll: { + selector: 'doStopThis', + inputs: [['all']] + }, + doStop: { + selector: 'doStopThis', + inputs: [['this script']] + }, + doStopBlock: { + selector: 'doStopThis', + inputs: [['this block']] + } + }; +}; + +SpriteMorph.prototype.initBlockMigrations(); + SpriteMorph.prototype.blockAlternatives = { // motion: turn: ['turnLeft'], @@ -1130,9 +1161,6 @@ SpriteMorph.prototype.blockAlternatives = { receiveClick: ['receiveGo'], doBroadcast: ['doBroadcastAndWait'], doBroadcastAndWait: ['doBroadcast'], - doStopBlock: ['doStop', 'doStopAll'], - doStop: ['doStopBlock', 'doStopAll'], - doStopAll: ['doStopBlock', 'doStop'], // sensing: getLastAnswer: ['getTimer'], @@ -1412,8 +1440,9 @@ SpriteMorph.prototype.colorFiltered = function (aColor) { // SpriteMorph block instantiation SpriteMorph.prototype.blockForSelector = function (selector, setDefaults) { - var info, block, defaults, inputs, i; - info = this.blocks[selector]; + var migration, info, block, defaults, inputs, i; + migration = this.blockMigrations[selector]; + info = this.blocks[migration ? migration.selector : selector]; if (!info) {return null; } block = info.type === 'command' ? new CommandBlockMorph() : info.type === 'hat' ? new HatBlockMorph() @@ -1426,8 +1455,8 @@ SpriteMorph.prototype.blockForSelector = function (selector, setDefaults) { block.isStatic = true; } block.setSpec(localize(info.spec)); - if (setDefaults && info.defaults) { - defaults = info.defaults; + if ((setDefaults && info.defaults) || (migration && migration.inputs)) { + defaults = migration ? migration.inputs : info.defaults; block.defaults = defaults; inputs = block.inputs(); if (inputs[0] instanceof MultiArgMorph) { @@ -1651,9 +1680,13 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('doReport')); blocks.push('-'); + /* + // old STOP variants, migrated to a newer version, now redundant blocks.push(block('doStopBlock')); blocks.push(block('doStop')); blocks.push(block('doStopAll')); + */ + blocks.push(block('doStopThis')); blocks.push(block('doStopOthers')); blocks.push('-'); blocks.push(block('doRun')); @@ -4358,9 +4391,13 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('doReport')); blocks.push('-'); + /* + // old STOP variants, migrated to a newer version, now redundant blocks.push(block('doStopBlock')); blocks.push(block('doStop')); blocks.push(block('doStopAll')); + */ + blocks.push(block('doStopThis')); blocks.push(block('doStopOthers')); blocks.push('-'); blocks.push(block('doRun')); diff --git a/threads.js b/threads.js index 8c3eb25..79af3b9 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2014-January-08'; +modules.threads = '2014-January-09'; var ThreadManager; var Process; @@ -1372,12 +1372,27 @@ Process.prototype.doStopAll = function () { } }; +Process.prototype.doStopThis = function (choice) { + switch (this.inputOption(choice)) { + case 'all': + this.doStopAll(); + break; + case 'this script': + this.doStop(); + break; + case 'this block': + this.doStopBlock(); + break; + default: + nop(); + } +}; + Process.prototype.doStopOthers = function (choice) { var stage; if (this.homeContext.receiver) { stage = this.homeContext.receiver.parentThatIsA(StageMorph); if (stage) { - switch (this.inputOption(choice)) { case 'all but this script': stage.threads.stopAll(this); -- cgit v1.3.1 From fa88fdc761faa224d307e833f74163df48cedb0c Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 9 Jan 2014 18:50:38 +0100 Subject: validated all source files against the latest JSLint version and pushed to this date --- README.md | 2 +- blocks.js | 2 +- byob.js | 4 ++-- cloud.js | 7 ++----- gui.js | 6 +++--- history.txt | 3 ++- lang-de.js | 2 +- lists.js | 4 ++-- locale.js | 2 +- objects.js | 2 +- paint.js | 4 ++-- store.js | 4 ++-- threads.js | 2 +- widgets.js | 4 ++-- 14 files changed, 23 insertions(+), 25 deletions(-) (limited to 'objects.js') diff --git a/README.md b/README.md index 8564d27..cf17e18 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ inspired by Scratch written by Jens Mönig and Brian Harvey jens@moenig.org, bh@cs.berkeley.edu -Copyright (C) 2013 by Jens Mönig and Brian Harvey +Copyright (C) 2014 by Jens Mönig and Brian Harvey Snap! is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/blocks.js b/blocks.js index 9997d70..0ce1478 100644 --- a/blocks.js +++ b/blocks.js @@ -9,7 +9,7 @@ written by Jens Mönig jens@moenig.org - Copyright (C) 2013 by Jens Mönig + Copyright (C) 2014 by Jens Mönig This file is part of Snap!. diff --git a/byob.js b/byob.js index 8093266..aff32ad 100644 --- a/byob.js +++ b/byob.js @@ -9,7 +9,7 @@ written by Jens Mönig jens@moenig.org - Copyright (C) 2013 by Jens Mönig + Copyright (C) 2014 by Jens Mönig This file is part of Snap!. @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2013-November-26'; +modules.byob = '2014-January-09'; // Declarations diff --git a/cloud.js b/cloud.js index 5ff2f77..17fc76b 100644 --- a/cloud.js +++ b/cloud.js @@ -6,7 +6,7 @@ written by Jens Mönig - Copyright (C) 2013 by Jens Mönig + Copyright (C) 2014 by Jens Mönig This file is part of Snap!. @@ -29,7 +29,7 @@ /*global modules, IDE_Morph, SnapSerializer, hex_sha512, alert, nop*/ -modules.cloud = '2013-November-26'; +modules.cloud = '2014-January-09'; // Global stuff @@ -37,9 +37,6 @@ var Cloud; var SnapCloud = new Cloud( 'https://snapcloud.miosoft.com/miocon/app/login?_app=SnapCloud' - //'192.168.2.110:8087/miocon/app/login?_app=SnapCloud' - //'192.168.186.146:8087/miocon/app/login?_app=SnapCloud' - // 'localhost/miocon/app/login?_app=SnapCloud' ); // Cloud ///////////////////////////////////////////////////////////// diff --git a/gui.js b/gui.js index d7f562e..0adc325 100644 --- a/gui.js +++ b/gui.js @@ -9,7 +9,7 @@ written by Jens Mönig jens@moenig.org - Copyright (C) 2013 by Jens Mönig + Copyright (C) 2014 by Jens Mönig This file is part of Snap!. @@ -68,7 +68,7 @@ sb, CommentMorph, CommandBlockMorph, BlockLabelPlaceHolderMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2013-November-07'; +modules.gui = '2014-January-09'; // Declarations @@ -2391,7 +2391,7 @@ IDE_Morph.prototype.aboutSnap = function () { world = this.world(); aboutTxt = 'Snap! 4.0\nBuild Your Own Blocks\n\n--- beta ---\n\n' - + 'Copyright \u24B8 2013 Jens M\u00F6nig and ' + + 'Copyright \u24B8 2014 Jens M\u00F6nig and ' + 'Brian Harvey\n' + 'jens@moenig.org, bh@cs.berkeley.edu\n\n' diff --git a/history.txt b/history.txt index 2411d8f..f0569ff 100755 --- a/history.txt +++ b/history.txt @@ -2062,4 +2062,5 @@ ______ * Blocks, Objects, Threads: Collapse old STOP primitives into a single one with a dropdown of options * German translation update for new (migrated) STOP block * Morphic: Fixed updateReferences() (how could nobody notice so long?!) -* Store: resolved unexpected assignment expressions (conform to the latest JSLint quibbles) +* XML: resolved unexpected assignment expressions (conform to the latest JSLint quibbles) +* validated all source files against the latest JSLint version diff --git a/lang-de.js b/lang-de.js index 2013833..0b438b5 100644 --- a/lang-de.js +++ b/lang-de.js @@ -6,7 +6,7 @@ written by Jens Mönig - Copyright (C) 2013 by Jens Mönig + Copyright (C) 2014 by Jens Mönig This file is part of Snap!. diff --git a/lists.js b/lists.js index 60cd7e3..3166bf1 100644 --- a/lists.js +++ b/lists.js @@ -7,7 +7,7 @@ written by Jens Mönig and Brian Harvey jens@moenig.org, bh@cs.berkeley.edu - Copyright (C) 2013 by Jens Mönig and Brian Harvey + Copyright (C) 2014 by Jens Mönig and Brian Harvey This file is part of Snap!. @@ -61,7 +61,7 @@ PushButtonMorph, SyntaxElementMorph, Color, Point, WatcherMorph, StringMorph, SpriteMorph, ScrollFrameMorph, CellMorph, ArrowMorph, MenuMorph, snapEquals, Morph, isNil, localize, MorphicPreferences*/ -modules.lists = '2013-December-04'; +modules.lists = '2014-January-09'; var List; var ListWatcherMorph; diff --git a/locale.js b/locale.js index eb79862..3b65ec9 100644 --- a/locale.js +++ b/locale.js @@ -6,7 +6,7 @@ written by Jens Mönig - Copyright (C) 2013 by Jens Mönig + Copyright (C) 2014 by Jens Mönig This file is part of Snap!. diff --git a/objects.js b/objects.js index 3f3df76..af482b1 100644 --- a/objects.js +++ b/objects.js @@ -9,7 +9,7 @@ written by Jens Mönig jens@moenig.org - Copyright (C) 2013 by Jens Mönig + Copyright (C) 2014 by Jens Mönig This file is part of Snap!. diff --git a/paint.js b/paint.js index 15b4172..1929f95 100644 --- a/paint.js +++ b/paint.js @@ -5,7 +5,7 @@ inspired by the Scratch paint editor. written by Kartik Chandra - Copyright (C) 2013 by Kartik Chandra + Copyright (C) 2014 by Kartik Chandra This file is part of Snap!. @@ -64,7 +64,7 @@ // Global stuff //////////////////////////////////////////////////////// -modules.paint = '2014-January-08'; +modules.paint = '2014-January-09'; // Declarations diff --git a/store.js b/store.js index 640f2d1..343dca6 100644 --- a/store.js +++ b/store.js @@ -7,7 +7,7 @@ written by Jens Mönig jens@moenig.org - Copyright (C) 2013 by Jens Mönig + Copyright (C) 2014 by Jens Mönig This file is part of Snap!. @@ -61,7 +61,7 @@ SyntaxElementMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2013-December-19'; +modules.store = '2014-January-09'; // XML_Serializer /////////////////////////////////////////////////////// diff --git a/threads.js b/threads.js index 79af3b9..722ce6b 100644 --- a/threads.js +++ b/threads.js @@ -9,7 +9,7 @@ written by Jens Mönig jens@moenig.org - Copyright (C) 2013 by Jens Mönig + Copyright (C) 2014 by Jens Mönig This file is part of Snap!. diff --git a/widgets.js b/widgets.js index 566d60c..c8dbd03 100644 --- a/widgets.js +++ b/widgets.js @@ -7,7 +7,7 @@ written by Jens Mönig jens@moenig.org - Copyright (C) 2013 by Jens Mönig + Copyright (C) 2014 by Jens Mönig This file is part of Snap!. @@ -74,7 +74,7 @@ HTMLCanvasElement, fontHeight, SymbolMorph, localize, SpeechBubbleMorph, ArrowMorph, MenuMorph, isString, isNil, SliderMorph, MorphicPreferences, ScrollFrameMorph*/ -modules.widgets = '2013-November-26'; +modules.widgets = '2014-January-09'; var PushButtonMorph; var ToggleButtonMorph; -- cgit v1.3.1 From b4eb1d1864df81692d40a059336b070c4006e209 Mon Sep 17 00:00:00 2001 From: Dean Brettle Date: Sat, 25 Jan 2014 22:17:12 -0800 Subject: Fixes issue #310 - play note block fails on Firefox due to use of deprecated WebAudio names. The fix uses the correct names and monkey-patches browsers that use the old ones. --- objects.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index af482b1..a0adada 100644 --- a/objects.js +++ b/objects.js @@ -5647,17 +5647,20 @@ Note.prototype.setupContext = function () { if (this.audioContext) { return; } var AudioContext = (function () { // cross browser some day? - return window.AudioContext || + var ctx = window.AudioContext || window.mozAudioContext || window.msAudioContext || window.oAudioContext || window.webkitAudioContext; + if (!ctx.prototype.hasOwnProperty('createGain')) + ctx.prototype.createGain = ctx.prototype.createGainNode; + return ctx; }()); if (!AudioContext) { throw new Error('Web Audio API is not supported\nin this browser'); } Note.prototype.audioContext = new AudioContext(); - Note.prototype.gainNode = Note.prototype.audioContext.createGainNode(); + Note.prototype.gainNode = Note.prototype.audioContext.createGain(); Note.prototype.gainNode.gain.value = 0.25; // reduce volume by 1/4 }; @@ -5665,17 +5668,21 @@ Note.prototype.setupContext = function () { Note.prototype.play = function () { this.oscillator = this.audioContext.createOscillator(); + if (!this.oscillator.start) + this.oscillator.start = this.oscillator.noteOn; + if (!this.oscillator.stop) + this.oscillator.stop = this.oscillator.noteOff; this.oscillator.type = 0; this.oscillator.frequency.value = Math.pow(2, (this.pitch - 69) / 12) * 440; this.oscillator.connect(this.gainNode); this.gainNode.connect(this.audioContext.destination); - this.oscillator.noteOn(0); // deprecated, renamed to start() + this.oscillator.start(0); }; Note.prototype.stop = function () { if (this.oscillator) { - this.oscillator.noteOff(0); // deprecated, renamed to stop() + this.oscillator.stop(0); this.oscillator = null; } }; -- cgit v1.3.1 From 1fb0b7799834280a759eb238b8d138b60223b1c2 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 4 Feb 2014 15:29:14 +0100 Subject: Flat line end option in the settings menu, saved with the project --- gui.js | 11 +++++++++++ history.txt | 1 + objects.js | 12 +++++++++--- store.js | 6 +++++- 4 files changed, 26 insertions(+), 4 deletions(-) (limited to 'objects.js') diff --git a/gui.js b/gui.js index 96903a0..7640393 100644 --- a/gui.js +++ b/gui.js @@ -2211,6 +2211,16 @@ IDE_Morph.prototype.settingsMenu = function () { 'uncheck for greater speed\nat variable frame rates', 'check for smooth, predictable\nanimations across computers' ); + addPreference( + 'Flat line ends', + function () { + SpriteMorph.prototype.useFlatLineEnds = + !SpriteMorph.prototype.useFlatLineEnds; + }, + SpriteMorph.prototype.useFlatLineEnds, + 'uncheck for round ends of lines', + 'check for flat ends of lines' + ); addPreference( 'Codification support', function () { @@ -2689,6 +2699,7 @@ IDE_Morph.prototype.newProject = function () { StageMorph.prototype.codeMappings = {}; StageMorph.prototype.codeHeaders = {}; StageMorph.prototype.enableCodeMapping = false; + SpriteMorph.prototype.useFlatLineEnds = false; this.setProjectName(''); this.projectNotes = ''; this.createStage(); diff --git a/history.txt b/history.txt index 577e17a..e44e138 100755 --- a/history.txt +++ b/history.txt @@ -2080,3 +2080,4 @@ ______ ------ * GUI: Import costumes and backgrounds from the project menu, thanks, Brian, for the changeset! * GUI: Import sounds from the project menu, thanks, Brian, for the changeset! +* Objects, Store, GUI: Flat line end option in the settings menu, saved with the project diff --git a/objects.js b/objects.js index af482b1..1c9a166 100644 --- a/objects.js +++ b/objects.js @@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-January-09'; +modules.objects = '2014-February-04'; var SpriteMorph; var StageMorph; @@ -186,6 +186,7 @@ SpriteMorph.prototype.sliderColor SpriteMorph.prototype.isCachingPrimitives = true; SpriteMorph.prototype.enableNesting = true; +SpriteMorph.prototype.useFlatLineEnds = false; SpriteMorph.prototype.highlightColor = new Color(250, 200, 130); SpriteMorph.prototype.highlightBorder = 8; @@ -2717,8 +2718,13 @@ SpriteMorph.prototype.drawLine = function (start, dest) { if (this.isDown) { context.lineWidth = this.size; context.strokeStyle = this.color.toString(); - context.lineCap = 'round'; - context.lineJoin = 'round'; + if (this.useFlatLineEnds) { + context.lineCap = 'butt'; + context.lineJoin = 'miter'; + } else { + context.lineCap = 'round'; + context.lineJoin = 'round'; + } context.beginPath(); context.moveTo(from.x, from.y); context.lineTo(to.x, to.y); diff --git a/store.js b/store.js index 343dca6..ae9a5d1 100644 --- a/store.js +++ b/store.js @@ -61,7 +61,7 @@ SyntaxElementMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2014-January-09'; +modules.store = '2014-February-04'; // XML_Serializer /////////////////////////////////////////////////////// @@ -378,6 +378,8 @@ SnapSerializer.prototype.loadProjectModel = function (xmlNode) { } project.stage.setTempo(model.stage.attributes.tempo); project.stage.setExtent(StageMorph.prototype.dimensions); + SpriteMorph.prototype.useFlatLineEnds = + model.stage.attributes.lines === 'flat'; project.stage.isThreadSafe = model.stage.attributes.threadsafe === 'true'; StageMorph.prototype.enableCodeMapping = @@ -1340,6 +1342,7 @@ StageMorph.prototype.toXML = function (serializer) { '$' + '$' + '' + '$' + @@ -1364,6 +1367,7 @@ StageMorph.prototype.toXML = function (serializer) { this.getCostumeIdx(), this.getTempo(), this.isThreadSafe, + SpriteMorph.prototype.useFlatLineEnds ? 'flat' : 'round', this.enableCodeMapping, StageMorph.prototype.frameRate !== 0, this.trailsCanvas.toDataURL('image/png'), -- cgit v1.3.1 From 0322b6e3db13355e8bf37db7ab6df7d88875d4b4 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 4 Feb 2014 16:14:16 +0100 Subject: integrate Dean's sound fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit so JSLint doesn’t complain (no functionality changes). Thanks, Dean! --- history.txt | 1 + objects.js | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 7746ef4..054387a 100755 --- a/history.txt +++ b/history.txt @@ -2082,3 +2082,4 @@ ______ * GUI: Import sounds from the project menu, thanks, Brian, for the changeset! * Objects, Store, GUI: Flat line end option in the settings menu, saved with the project * German translation update +* Objects: Enable playing sounds and notes on Firefox, thanks, Dean Brettle, for this fix!! diff --git a/objects.js b/objects.js index fd19bd6..52126e2 100644 --- a/objects.js +++ b/objects.js @@ -5658,8 +5658,9 @@ Note.prototype.setupContext = function () { window.msAudioContext || window.oAudioContext || window.webkitAudioContext; - if (!ctx.prototype.hasOwnProperty('createGain')) + if (!ctx.prototype.hasOwnProperty('createGain')) { ctx.prototype.createGain = ctx.prototype.createGainNode; + } return ctx; }()); if (!AudioContext) { @@ -5674,10 +5675,12 @@ Note.prototype.setupContext = function () { Note.prototype.play = function () { this.oscillator = this.audioContext.createOscillator(); - if (!this.oscillator.start) + if (!this.oscillator.start) { this.oscillator.start = this.oscillator.noteOn; - if (!this.oscillator.stop) + } + if (!this.oscillator.stop) { this.oscillator.stop = this.oscillator.noteOff; + } this.oscillator.type = 0; this.oscillator.frequency.value = Math.pow(2, (this.pitch - 69) / 12) * 440; -- cgit v1.3.1