Skip to content

Commit

Permalink
Merge pull request #157 from entrylabs/issue/list-09
Browse files Browse the repository at this point in the history
Issue/list 09
  • Loading branch information
chanlee committed Feb 2, 2016
2 parents 066de2a + 044fe28 commit 66755e9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
14 changes: 9 additions & 5 deletions dist/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -4123,7 +4123,9 @@ Entry.block.sound_something_second_wait_with_block = function(a, b) {
};
Blockly.Blocks.sound_from_to = {init:function() {
this.setColour("#A4D01D");
this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_1).appendField(new Blockly.FieldDropdownDynamic("sounds"), "SOUND").appendField(Lang.Blocks.SOUND_sound_from_to_2);
this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_1);
this.appendValueInput("VALUE").setCheck(["Number", "String"]);
this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_2);
this.appendValueInput("START").setCheck(["String", "Number"]);
this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_3);
this.appendValueInput("END").setCheck(["String", "Number"]);
Expand All @@ -4133,7 +4135,7 @@ Blockly.Blocks.sound_from_to = {init:function() {
this.setPreviousStatement(!0);
}};
Entry.block.sound_from_to = function(a, b) {
var c = b.getField("SOUND", b);
var c = b.getStringValue("VALUE", b);
if (c = a.parent.getSound(c)) {
var d = 1E3 * b.getNumberValue("START", b), e = 1E3 * b.getNumberValue("END", b);
createjs.Sound.play(c.id, {startTime:Math.min(d, e), duration:Math.max(d, e) - Math.min(d, e)});
Expand All @@ -4142,7 +4144,9 @@ Entry.block.sound_from_to = function(a, b) {
};
Blockly.Blocks.sound_from_to_and_wait = {init:function() {
this.setColour("#A4D01D");
this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_and_wait_1).appendField(new Blockly.FieldDropdownDynamic("sounds"), "SOUND").appendField(Lang.Blocks.SOUND_sound_from_to_and_wait_2);
this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_and_wait_1);
this.appendValueInput("VALUE").setCheck(["Number", "String"]);
this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_and_wait_2);
this.appendValueInput("START").setCheck(["String", "Number"]);
this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_and_wait_3);
this.appendValueInput("END").setCheck(["String", "Number"]);
Expand All @@ -4162,8 +4166,8 @@ Entry.block.sound_from_to_and_wait = function(a, b) {
}
b.isPlay = !0;
b.playState = 1;
var c = a.parent.getSound(b.getField("SOUND", b));
if (c) {
var c = b.getStringValue("VALUE", b);
if (c = a.parent.getSound(c)) {
var d = 1E3 * b.getNumberValue("START", b), e = 1E3 * b.getNumberValue("END", b), f = Math.min(d, e), d = Math.max(d, e) - f;
createjs.Sound.play(c.id, {startTime:f, duration:d});
setTimeout(function() {
Expand Down
10 changes: 5 additions & 5 deletions dist/entry.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions extern/util/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@ EntryStatic.blockInfo = {
"xml": "<block type='hamster_set_output_to'><value name='VALUE'><block type='text'><field name='NAME'>100</field></block></value></block>",
"class": "hamster_port"
},

"albert_hand_found": {
"isNotFor": ["albert"],
"xml": "<block type='albert_hand_found'></block>",
Expand Down Expand Up @@ -1720,12 +1720,12 @@ EntryStatic.blockInfo = {
},
"sound_from_to": {
"isNotFor": [""],
"xml": "<block type='sound_from_to'><value name='START'><block type='text'><field name='NAME'>1</field></block></value><value name='END'><block type='text'><field name='NAME'>10</field></block></value></block>",
"xml": "<block type='sound_from_to'><value name='VALUE'><block type='get_sounds'></block></value><value name='START'><block type='text'><field name='NAME'>1</field></block></value><value name='END'><block type='text'><field name='NAME'>10</field></block></value></block>",
"class": ""
},
"sound_from_to_and_wait": {
"isNotFor": [""],
"xml": "<block type='sound_from_to_and_wait'><value name='START'><block type='text'><field name='NAME'>1</field></block></value><value name='END'><block type='text'><field name='NAME'>10</field></block></value></block>",
"xml": "<block type='sound_from_to_and_wait'><value name='VALUE'><block type='get_sounds'></block></value><value name='START'><block type='text'><field name='NAME'>1</field></block></value><value name='END'><block type='text'><field name='NAME'>10</field></block></value></block>",
"class": "sound_play"
},
"quotient_and_mod": {
Expand Down
19 changes: 13 additions & 6 deletions src/blocks/block_sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,10 @@ Blockly.Blocks.sound_from_to = {
init: function() {
this.setColour("#A4D01D");
this.appendDummyInput()
.appendField(Lang.Blocks.SOUND_sound_from_to_1)
.appendField(new Blockly.FieldDropdownDynamic("sounds"), "SOUND")
.appendField(Lang.Blocks.SOUND_sound_from_to_1);
this.appendValueInput("VALUE")
.setCheck(["Number", "String"]);
this.appendDummyInput()
.appendField(Lang.Blocks.SOUND_sound_from_to_2);
this.appendValueInput("START")
.setCheck(["String", "Number"]);
Expand All @@ -411,7 +413,7 @@ Blockly.Blocks.sound_from_to = {
};

Entry.block.sound_from_to = function (sprite, script) {
var soundId = script.getField("SOUND", script);
var soundId = script.getStringValue("VALUE", script);
var sound = sprite.parent.getSound(soundId);

if (sound) {
Expand All @@ -425,12 +427,16 @@ Entry.block.sound_from_to = function (sprite, script) {
return script.callReturn();
};



Blockly.Blocks.sound_from_to_and_wait = {
init: function() {
this.setColour("#A4D01D");
this.appendDummyInput()
.appendField(Lang.Blocks.SOUND_sound_from_to_and_wait_1)
.appendField(new Blockly.FieldDropdownDynamic("sounds"), "SOUND")
.appendField(Lang.Blocks.SOUND_sound_from_to_and_wait_1);
this.appendValueInput("VALUE")
.setCheck(["Number", "String"]);
this.appendDummyInput()
.appendField(Lang.Blocks.SOUND_sound_from_to_and_wait_2);
this.appendValueInput("START")
.setCheck(["String", "Number"]);
Expand All @@ -451,7 +457,8 @@ Entry.block.sound_from_to_and_wait = function (sprite, script) {
if (!script.isPlay) {
script.isPlay = true;
script.playState = 1;
var sound = sprite.parent.getSound(script.getField("SOUND", script));
var soundId = script.getStringValue("VALUE", script);
var sound = sprite.parent.getSound(soundId);
if (sound) {
var start = script.getNumberValue("START", script)*1000;
var end = script.getNumberValue("END", script)*1000;
Expand Down

0 comments on commit 66755e9

Please sign in to comment.