Skip to content

Commit

Permalink
Merge pull request #166 from entrylabs/issue/list21
Browse files Browse the repository at this point in the history
Issue/list21
  • Loading branch information
boolgom committed Feb 3, 2016
2 parents 66755e9 + 8e9af33 commit 6907f93
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 15 deletions.
12 changes: 10 additions & 2 deletions dist/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -3041,13 +3041,14 @@ Entry.block.change_to_nth_shape = function(a, b) {
};
Blockly.Blocks.change_to_next_shape = {init:function() {
this.setColour("#EC4466");
this.appendDummyInput().appendField(Lang.Blocks.LOOKS_change_to_next_shape).appendField(new Blockly.FieldIcon(Entry.mediaFilePath + "block_icon/looks_03.png", "*"));
this.appendDummyInput().appendField(Lang.Blocks.LOOKS_change_to_near_shape_1).appendField(new Blockly.FieldDropdown([[Lang.Blocks.LOOKS_change_shape_next, "next"], [Lang.Blocks.LOOKS_change_shape_prev, "prev"]]), "DRIECTION").appendField(Lang.Blocks.LOOKS_change_to_near_shape_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath + "block_icon/looks_03.png", "*"));
this.setInputsInline(!0);
this.setPreviousStatement(!0);
this.setNextStatement(!0);
}};
Entry.block.change_to_next_shape = function(a, b) {
var c = a.parent.getNextPicture(a.picture.id);
var c;
c = "prev" !== b.getStringField("DRIECTION") ? a.parent.getNextPicture(a.picture.id) : a.parent.getPrevPicture(a.picture.id);
a.setImage(c);
return b.callReturn();
};
Expand Down Expand Up @@ -7333,6 +7334,13 @@ Entry.EntryObject.prototype.setPicture = function(a) {
}
throw Error("No picture found");
};
Entry.EntryObject.prototype.getPrevPicture = function(a) {
for (var b = this.pictures, c = b.length, d = 0;d < c;d++) {
if (b[d].id == a) {
return b[0 == d ? c - 1 : d - 1];
}
}
};
Entry.EntryObject.prototype.getNextPicture = function(a) {
for (var b = this.pictures, c = b.length, d = 0;d < c;d++) {
if (b[d].id == a) {
Expand Down
7 changes: 4 additions & 3 deletions dist/entry.min.js

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

30 changes: 20 additions & 10 deletions src/blocks/block_looks.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,29 @@ Entry.block.change_to_nth_shape = function (sprite, script) {

// 다음 모양으로 바꾸기
Blockly.Blocks.change_to_next_shape = {
init: function() {
this.setColour("#EC4466");
this.appendDummyInput()
.appendField(Lang.Blocks.LOOKS_change_to_next_shape)
.appendField(new Blockly.FieldIcon(Entry.mediaFilePath + 'block_icon/looks_03.png', '*'));
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
}
init: function() {
this.setColour("#EC4466");
this.appendDummyInput()
.appendField(Lang.Blocks.LOOKS_change_to_near_shape_1)
.appendField(new Blockly.FieldDropdown([
[Lang.Blocks.LOOKS_change_shape_next,"next"],
[Lang.Blocks.LOOKS_change_shape_prev,"prev"]
]), "DRIECTION")
.appendField(Lang.Blocks.LOOKS_change_to_near_shape_2)
.appendField(new Blockly.FieldIcon(Entry.mediaFilePath + 'block_icon/looks_03.png', '*'));
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
}
};

Entry.block.change_to_next_shape = function (sprite, script) {
var picture = sprite.parent.getNextPicture(sprite.picture.id);
var picture;
if(script.getStringField("DRIECTION") !== 'prev') {
picture = sprite.parent.getNextPicture(sprite.picture.id);
} else {
picture = sprite.parent.getPrevPicture(sprite.picture.id);
}
sprite.setImage(picture);
return script.callReturn();
};
Expand Down
15 changes: 15 additions & 0 deletions src/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,21 @@ Entry.EntryObject.prototype.setPicture = function(picture) {
throw new Error('No picture found');
};

/**
* Get previous picture object by Id.
* @param {?string} pictureId
* @return {picture object}
*/
Entry.EntryObject.prototype.getPrevPicture = function(pictureId) {
var pictures = this.pictures,
len = pictures.length;
for (var i = 0; i < len; i++) {
var picture = pictures[i];
if (picture.id == pictureId)
return pictures[i == 0 ? len-1 : i-1];
}
};

/**
* Get next picture object by Id.
* @param {?string} pictureId
Expand Down

0 comments on commit 6907f93

Please sign in to comment.