smalruby-editor 0.0.12 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of smalruby-editor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.travis.yml +2 -0
- data/LEGAL +32 -0
- data/Rakefile +1 -1
- data/app/assets/demos/default.xml +126 -0
- data/app/assets/demos/rgb_led_anode.xml +83 -0
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/javascripts/application.js +18 -1
- data/app/assets/javascripts/block_mode.js.coffee.erb +10 -0
- data/app/assets/javascripts/blocks/blockly.js.coffee.erb +34 -0
- data/app/assets/javascripts/blocks/character.js.coffee.erb +76 -0
- data/app/assets/javascripts/blocks/control.js.coffee.erb +180 -0
- data/app/assets/javascripts/blocks/data.js.coffee.erb +6 -0
- data/app/assets/javascripts/blocks/etc.js.coffee.erb +6 -0
- data/app/assets/javascripts/blocks/events.js.coffee.erb +82 -0
- data/app/assets/javascripts/blocks/hardware.js.coffee.erb +313 -0
- data/app/assets/javascripts/blocks/looks.js.coffee.erb +163 -0
- data/app/assets/javascripts/blocks/motion.js.coffee.erb +297 -0
- data/app/assets/javascripts/blocks/operators.js.coffee.erb +279 -0
- data/app/assets/javascripts/blocks/pen.js.coffee.erb +6 -0
- data/app/assets/javascripts/blocks/ruby.js.coffee.erb +74 -0
- data/app/assets/javascripts/blocks/sensing.js.coffee.erb +241 -0
- data/app/assets/javascripts/blocks/sound.js.coffee.erb +75 -0
- data/{public/favicon.ico → app/assets/javascripts/collections/.keep} +0 -0
- data/app/assets/javascripts/collections/character_set.js.coffee +12 -0
- data/app/assets/javascripts/generators/ruby.js.coffee.erb +188 -0
- data/app/assets/javascripts/models/.keep +0 -0
- data/app/assets/javascripts/models/character.js.coffee +66 -0
- data/app/assets/javascripts/models/scene.js.coffee +5 -0
- data/app/assets/javascripts/models/source_code.js.coffee +64 -0
- data/app/assets/javascripts/routers/.keep +0 -0
- data/app/assets/javascripts/ruby_mode.js.coffee.erb +12 -0
- data/app/assets/javascripts/smalruby.js.coffee +97 -0
- data/app/assets/javascripts/views/.keep +0 -0
- data/app/assets/javascripts/views/character_modal_view.js.coffee +148 -0
- data/app/assets/javascripts/views/character_selector_view.js.coffee +109 -0
- data/app/assets/javascripts/views/main_menu_view.js.coffee +264 -0
- data/app/assets/stylesheets/editor.css.scss +318 -2
- data/app/assets/stylesheets/toolbox.css.scss.erb +62 -0
- data/app/assets/templates/.keep +0 -0
- data/app/controllers/application_controller.rb +19 -0
- data/app/controllers/editor_controller.rb +4 -0
- data/app/controllers/source_codes_controller.rb +8 -2
- data/app/helpers/application_helper.rb +1 -0
- data/app/helpers/editor_helper.rb +46 -0
- data/app/models/source_code.rb +49 -6
- data/app/views/editor/_block_tab.html.haml +53 -0
- data/app/views/editor/_character_modal.html.haml +53 -0
- data/app/views/editor/_toolbox.html.haml +384 -0
- data/app/views/editor/demo.html.erb +16 -0
- data/app/views/editor/index.html.haml +60 -0
- data/app/views/layouts/application.html.erb +7 -0
- data/config/application.rb +1 -0
- data/config/initializers/teaspoon.rb +79 -0
- data/config/routes.rb +4 -0
- data/lib/smalruby_editor/version.rb +1 -1
- data/lib/tasks/gem.rake +7 -4
- data/lib/tasks/release.rake +43 -0
- data/public/apple-touch-icon.png +0 -0
- data/public/blockly/media/1x1.gif +0 -0
- data/public/blockly/media/click.mp3 +0 -0
- data/public/blockly/media/click.ogg +0 -0
- data/public/blockly/media/click.wav +0 -0
- data/public/blockly/media/delete.mp3 +0 -0
- data/public/blockly/media/delete.ogg +0 -0
- data/public/blockly/media/delete.wav +0 -0
- data/public/blockly/media/handclosed.cur +0 -0
- data/public/blockly/media/handopen.cur +0 -0
- data/public/blockly/media/quote0.png +0 -0
- data/public/blockly/media/quote1.png +0 -0
- data/public/blockly/media/trashbody.png +0 -0
- data/public/blockly/media/trashlid.png +0 -0
- data/public/blockly/media/tree.png +0 -0
- data/public/browserconfig.xml +1 -0
- data/public/large.png +0 -0
- data/public/smalruby/assets/ball1.png +0 -0
- data/public/smalruby/assets/ball2.png +0 -0
- data/public/smalruby/assets/ball3.png +0 -0
- data/public/smalruby/assets/ball4.png +0 -0
- data/public/smalruby/assets/ball5.png +0 -0
- data/public/smalruby/assets/ball6.png +0 -0
- data/public/smalruby/assets/car1.png +0 -0
- data/public/smalruby/assets/car2.png +0 -0
- data/public/smalruby/assets/car3.png +0 -0
- data/public/smalruby/assets/car4.png +0 -0
- data/public/smalruby/assets/cat1.png +0 -0
- data/public/smalruby/assets/cat2.png +0 -0
- data/public/smalruby/assets/cat3.png +0 -0
- data/public/smalruby/assets/frog1.png +0 -0
- data/public/smalruby/assets/piano_do.wav +0 -0
- data/public/smalruby/assets/piano_do_2.wav +0 -0
- data/public/smalruby/assets/piano_fa.wav +0 -0
- data/public/smalruby/assets/piano_mi.wav +0 -0
- data/public/smalruby/assets/piano_ra.wav +0 -0
- data/public/smalruby/assets/piano_re.wav +0 -0
- data/public/smalruby/assets/piano_si.wav +0 -0
- data/public/smalruby/assets/piano_so.wav +0 -0
- data/public/square.png +0 -0
- data/public/tiny.png +0 -0
- data/public/wide.png +0 -0
- data/smalruby-editor.gemspec +4 -0
- data/spec/acceptance/block_mode/blocks/character/new.feature +136 -0
- data/spec/acceptance/block_mode/blocks/control/await.feature +20 -0
- data/spec/acceptance/block_mode/blocks/control/await_until.feature +39 -0
- data/spec/acceptance/block_mode/blocks/control/break.feature +20 -0
- data/spec/acceptance/block_mode/blocks/control/if.feature +68 -0
- data/spec/acceptance/block_mode/blocks/control/if_else.feature +78 -0
- data/spec/acceptance/block_mode/blocks/control/loop.feature +45 -0
- data/spec/acceptance/block_mode/blocks/control/next.feature +20 -0
- data/spec/acceptance/block_mode/blocks/control/redo.feature +20 -0
- data/spec/acceptance/block_mode/blocks/control/sleep.feature +41 -0
- data/spec/acceptance/block_mode/blocks/control/times.feature +72 -0
- data/spec/acceptance/block_mode/blocks/control/until.feature +68 -0
- data/spec/acceptance/block_mode/blocks/events/on_click.feature +75 -0
- data/spec/acceptance/block_mode/blocks/events/on_hit.feature +83 -0
- data/spec/acceptance/block_mode/blocks/events/on_key_push_or_down.feature +171 -0
- data/spec/acceptance/block_mode/blocks/events/on_start.feature +75 -0
- data/spec/acceptance/block_mode/blocks/hardware/init_hardware.feature +44 -0
- data/spec/acceptance/block_mode/blocks/hardware/led_off.feature +75 -0
- data/spec/acceptance/block_mode/blocks/hardware/led_on.feature +75 -0
- data/spec/acceptance/block_mode/blocks/hardware/on_sensor_change.feature +81 -0
- data/spec/acceptance/block_mode/blocks/hardware/rgb_led_off.feature +81 -0
- data/spec/acceptance/block_mode/blocks/hardware/rgb_led_on.feature +87 -0
- data/spec/acceptance/block_mode/blocks/hardware/sensor_value.feature +100 -0
- data/spec/acceptance/block_mode/blocks/looks/hide.feature +69 -0
- data/spec/acceptance/block_mode/blocks/looks/say.feature +106 -0
- data/spec/acceptance/block_mode/blocks/looks/show.feature +69 -0
- data/spec/acceptance/block_mode/blocks/looks/vanish.feature +69 -0
- data/spec/acceptance/block_mode/blocks/motion/change_x_by.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/change_y_by.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/move.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/reach_wall.feature +98 -0
- data/spec/acceptance/block_mode/blocks/motion/rotate_left.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/rotate_right.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/self_angle.feature +92 -0
- data/spec/acceptance/block_mode/blocks/motion/self_x.feature +92 -0
- data/spec/acceptance/block_mode/blocks/motion/self_y.feature +92 -0
- data/spec/acceptance/block_mode/blocks/motion/set_angle.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/set_x.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/set_x_y.feature +95 -0
- data/spec/acceptance/block_mode/blocks/motion/set_y.feature +81 -0
- data/spec/acceptance/block_mode/blocks/motion/turn.feature +69 -0
- data/spec/acceptance/block_mode/blocks/motion/turn_if_reach_wall.feature +69 -0
- data/spec/acceptance/block_mode/blocks/sensing/character_property.feature +114 -0
- data/spec/acceptance/block_mode/blocks/sensing/hit.feature +110 -0
- data/spec/acceptance/block_mode/blocks/sensing/input_key_push_or_down.feature +91 -0
- data/spec/acceptance/block_mode/blocks/sensing/input_mouse_pos_x.feature +39 -0
- data/spec/acceptance/block_mode/blocks/sensing/input_mouse_pos_y.feature +39 -0
- data/spec/acceptance/block_mode/blocks/sensing/input_mouse_push_or_down.feature +91 -0
- data/spec/acceptance/block_mode/blocks/sensing/time_now.feature +43 -0
- data/spec/acceptance/block_mode/blocks/sound/play.feature +81 -0
- data/spec/acceptance/block_mode/demo.feature +49 -0
- data/spec/acceptance/{text_editor → ruby_mode}/base.feature +11 -2
- data/spec/acceptance/{standalone → ruby_mode}/check.feature +8 -9
- data/spec/acceptance/ruby_mode/download.feature +33 -0
- data/spec/acceptance/{text_editor → ruby_mode}/load.feature +13 -13
- data/spec/acceptance/standalone/run.feature +17 -0
- data/spec/acceptance/standalone/save.feature +6 -6
- data/spec/helpers/editor_helper_spec.rb +110 -10
- data/spec/javascripts/collections/character_set_spec.coffee +41 -0
- data/spec/javascripts/models/character_spec.coffee +146 -0
- data/spec/javascripts/models/scene_spec.coffee +15 -0
- data/spec/javascripts/spec_helper.js +29 -0
- data/spec/spec_helper.rb +3 -8
- data/spec/steps/block_mode_steps.rb +37 -0
- data/spec/steps/global_variable.rb +30 -6
- data/spec/steps/text_editor_steps.rb +20 -2
- data/spec/teaspoon_env.rb +46 -0
- data/vendor/assets/javascripts/blockly/blockly_compressed.js +992 -0
- data/vendor/assets/javascripts/blockly/blocks_compressed.js +129 -0
- data/vendor/assets/javascripts/blockly/msg/js/ja.js +377 -0
- data/vendor/assets/javascripts/jquery.blockUI.js +619 -0
- metadata +290 -23
- data/app/assets/javascripts/editor.js.coffee.erb +0 -137
- data/app/views/editor/index.html.erb +0 -22
- data/spec/acceptance/text_editor/check.feature +0 -29
- data/spec/acceptance/text_editor/save.feature +0 -34
- data/spec/support/assets.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 126ba802bd6cec95a37c2c7d14837d040753de04
|
4
|
+
data.tar.gz: 735be187882da7063909c894b1dec884556c06d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c46ab79c4c18e41db1d1b5fdc0a1563471646c52143e2cfd2156d178f914b3cd3ed1fb777c4902da73e1a2cc5b544b0864db04c258d41a0707dbf1bf5095e3b4
|
7
|
+
data.tar.gz: c189469d83b49ec369b70b14f7d5d55f66a75f0b39786ba1a2aa0f0e1f9a1a648e506fc242e90d9ef36cf963cdb6c528acfe18311a7aae909ad187553682c886
|
data/.rubocop.yml
CHANGED
@@ -3,6 +3,7 @@ AllCops:
|
|
3
3
|
- db/seeds.rb
|
4
4
|
- spec/fixtures/**
|
5
5
|
|
6
|
+
# 日本語でのコメントを許可する
|
6
7
|
AsciiComments:
|
7
8
|
Enabled: false
|
8
9
|
|
@@ -17,3 +18,7 @@ Documentation:
|
|
17
18
|
# WindowsだとEndOfLine copが動作しないため無効にしている
|
18
19
|
EndOfLine:
|
19
20
|
Enabled: false
|
21
|
+
|
22
|
+
# diffが少なくなるためハッシュや配列の最後のカンマは許可する
|
23
|
+
TrailingComma:
|
24
|
+
Enabled: false
|
data/.travis.yml
CHANGED
data/LEGAL
CHANGED
@@ -11,3 +11,35 @@ public/fonts/fontawesome-webfont.woff:
|
|
11
11
|
|
12
12
|
These's license is SIL Open Font License (OFL) 1.1:
|
13
13
|
http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL .
|
14
|
+
|
15
|
+
vendor/assets/javascripts/blockly/**/*, public/blockly/**/*:
|
16
|
+
|
17
|
+
These's license is Apache License Version 2.0, January 2011:
|
18
|
+
http://www.apache.org/licenses/ .
|
19
|
+
|
20
|
+
vendor/assets/javascripts/jquery.blockUI.js:
|
21
|
+
|
22
|
+
Copyright © 2007-2013 M. Alsup.
|
23
|
+
|
24
|
+
The BlockUI plugin is dual licensed under the MIT and GPL licenses.
|
25
|
+
|
26
|
+
You may use either license. The MIT license is recommended for most
|
27
|
+
projects because it is simple and easy to understand and it places
|
28
|
+
almost no restrictions on what you can do with the plugin.
|
29
|
+
|
30
|
+
If the GPL suits your project better you are also free to use the
|
31
|
+
plugin under that license.
|
32
|
+
|
33
|
+
You do not have to do anything special to choose one license or the
|
34
|
+
other and you don't have to notify anyone which license you are
|
35
|
+
using. You are free to use the BlockUI plugin in commercial projects
|
36
|
+
as long as the copyright header is left intact.
|
37
|
+
|
38
|
+
https://github.com/malsup/blockui
|
39
|
+
|
40
|
+
public/favicon.ico, public/apple-touch-icon.png, public/large.png,
|
41
|
+
public/square.png, public/tiny.png, public/wide.png:
|
42
|
+
|
43
|
+
Copyright (C) Hikari Arakawa (Smalruby Project) 2013,
|
44
|
+
licensed under CC BY-SA 2.1 JP:
|
45
|
+
http://creativecommons.org/licenses/by-sa/2.1/jp/ .
|
data/Rakefile
CHANGED
@@ -0,0 +1,126 @@
|
|
1
|
+
<xml xmlns="http://www.w3.org/1999/xhtml">
|
2
|
+
<character name="car1" costumes="car2.png" angle="0" y="0" x="0" />
|
3
|
+
<character name="car2" costumes="car3.png" angle="0" y="415" x="0" />
|
4
|
+
<block type="ruby_comment" y="25" x="34">
|
5
|
+
<field name="COMMENT">逃げる車</field>
|
6
|
+
<next>
|
7
|
+
<block type="character_new">
|
8
|
+
<field name="NAME">car1</field>
|
9
|
+
<statement name="DO">
|
10
|
+
<block type="events_on_start">
|
11
|
+
<statement name="DO">
|
12
|
+
<block type="control_loop">
|
13
|
+
<statement name="DO">
|
14
|
+
<block type="motion_move" inline="true">
|
15
|
+
<value name="STEP">
|
16
|
+
<block type="math_number">
|
17
|
+
<field name="NUM">6</field>
|
18
|
+
</block>
|
19
|
+
</value>
|
20
|
+
<next>
|
21
|
+
<block type="control_if" inline="true">
|
22
|
+
<value name="COND">
|
23
|
+
<block type="motion_reach_wall" />
|
24
|
+
</value>
|
25
|
+
<statement name="THEN">
|
26
|
+
<block type="motion_turn" />
|
27
|
+
</statement>
|
28
|
+
</block>
|
29
|
+
</next>
|
30
|
+
</block>
|
31
|
+
</statement>
|
32
|
+
</block>
|
33
|
+
</statement>
|
34
|
+
<next>
|
35
|
+
<block type="events_on_key_push_or_down">
|
36
|
+
<field name="KEY">K_LEFT</field>
|
37
|
+
<field name="POD">down</field>
|
38
|
+
<statement name="DO">
|
39
|
+
<block type="motion_rotate_left" inline="true">
|
40
|
+
<value name="ANGLE">
|
41
|
+
<block type="math_number">
|
42
|
+
<field name="NUM">15</field>
|
43
|
+
</block>
|
44
|
+
</value>
|
45
|
+
</block>
|
46
|
+
</statement>
|
47
|
+
<next>
|
48
|
+
<block type="events_on_key_push_or_down">
|
49
|
+
<field name="KEY">K_RIGHT</field>
|
50
|
+
<field name="POD">down</field>
|
51
|
+
<statement name="DO">
|
52
|
+
<block type="motion_rotate_right" inline="true">
|
53
|
+
<value name="ANGLE">
|
54
|
+
<block type="math_number">
|
55
|
+
<field name="NUM">15</field>
|
56
|
+
</block>
|
57
|
+
</value>
|
58
|
+
</block>
|
59
|
+
</statement>
|
60
|
+
</block>
|
61
|
+
</next>
|
62
|
+
</block>
|
63
|
+
</next>
|
64
|
+
</block>
|
65
|
+
</statement>
|
66
|
+
</block>
|
67
|
+
</next>
|
68
|
+
</block>
|
69
|
+
<block type="ruby_comment" y="23" x="480">
|
70
|
+
<field name="COMMENT">追いかける車</field>
|
71
|
+
<next>
|
72
|
+
<block type="character_new">
|
73
|
+
<field name="NAME">car2</field>
|
74
|
+
<statement name="DO">
|
75
|
+
<block type="events_on_start">
|
76
|
+
<statement name="DO">
|
77
|
+
<block type="control_loop">
|
78
|
+
<statement name="DO">
|
79
|
+
<block type="motion_point_towards_character">
|
80
|
+
<field name="VAR">car1</field>
|
81
|
+
<next>
|
82
|
+
<block type="motion_move" inline="true">
|
83
|
+
<value name="STEP">
|
84
|
+
<block type="math_number">
|
85
|
+
<field name="NUM">3</field>
|
86
|
+
</block>
|
87
|
+
</value>
|
88
|
+
<next>
|
89
|
+
<block type="control_if_else" inline="true">
|
90
|
+
<value name="COND">
|
91
|
+
<block type="sensing_hit">
|
92
|
+
<field name="CHAR">car1</field>
|
93
|
+
</block>
|
94
|
+
</value>
|
95
|
+
<statement name="THEN">
|
96
|
+
<block type="looks_say" inline="true">
|
97
|
+
<value name="TEXT">
|
98
|
+
<block type="text">
|
99
|
+
<field name="TEXT">追いつきました!</field>
|
100
|
+
</block>
|
101
|
+
</value>
|
102
|
+
</block>
|
103
|
+
</statement>
|
104
|
+
<statement name="ELSE">
|
105
|
+
<block type="looks_say" inline="true">
|
106
|
+
<value name="TEXT">
|
107
|
+
<block type="text">
|
108
|
+
<field name="TEXT" />
|
109
|
+
</block>
|
110
|
+
</value>
|
111
|
+
</block>
|
112
|
+
</statement>
|
113
|
+
</block>
|
114
|
+
</next>
|
115
|
+
</block>
|
116
|
+
</next>
|
117
|
+
</block>
|
118
|
+
</statement>
|
119
|
+
</block>
|
120
|
+
</statement>
|
121
|
+
</block>
|
122
|
+
</statement>
|
123
|
+
</block>
|
124
|
+
</next>
|
125
|
+
</block>
|
126
|
+
</xml>
|
@@ -0,0 +1,83 @@
|
|
1
|
+
<xml xmlns="http://www.w3.org/1999/xhtml">
|
2
|
+
<character name="frog1" x="261" y="191" angle="0" costumes="frog1.png" />
|
3
|
+
<block type="hardware_init_hardware" x="40" y="6" />
|
4
|
+
<block type="character_new" x="45" y="50">
|
5
|
+
<field name="NAME">frog1</field>
|
6
|
+
<statement name="DO">
|
7
|
+
<block type="events_on_click">
|
8
|
+
<statement name="DO">
|
9
|
+
<block type="looks_say" inline="true">
|
10
|
+
<value name="TEXT">
|
11
|
+
<block type="text">
|
12
|
+
<field name="TEXT">ライトをぴかっとさせるでよ♪</field>
|
13
|
+
</block>
|
14
|
+
</value>
|
15
|
+
<next>
|
16
|
+
<block type="hardware_rgb_led_on">
|
17
|
+
<field name="AC">anode</field>
|
18
|
+
<field name="PIN">D3</field>
|
19
|
+
<field name="COLOUR">#3333ff</field>
|
20
|
+
<next>
|
21
|
+
<block type="control_sleep" inline="true">
|
22
|
+
<value name="SEC">
|
23
|
+
<block type="math_number">
|
24
|
+
<field name="NUM">1</field>
|
25
|
+
</block>
|
26
|
+
</value>
|
27
|
+
<next>
|
28
|
+
<block type="hardware_rgb_led_on">
|
29
|
+
<field name="AC">anode</field>
|
30
|
+
<field name="PIN">D3</field>
|
31
|
+
<field name="COLOUR">#ffff99</field>
|
32
|
+
<next>
|
33
|
+
<block type="control_sleep" inline="true">
|
34
|
+
<value name="SEC">
|
35
|
+
<block type="math_number">
|
36
|
+
<field name="NUM">1</field>
|
37
|
+
</block>
|
38
|
+
</value>
|
39
|
+
<next>
|
40
|
+
<block type="hardware_rgb_led_on">
|
41
|
+
<field name="AC">anode</field>
|
42
|
+
<field name="PIN">D3</field>
|
43
|
+
<field name="COLOUR">#ff0000</field>
|
44
|
+
<next>
|
45
|
+
<block type="control_sleep" inline="true">
|
46
|
+
<value name="SEC">
|
47
|
+
<block type="math_number">
|
48
|
+
<field name="NUM">1</field>
|
49
|
+
</block>
|
50
|
+
</value>
|
51
|
+
<next>
|
52
|
+
<block type="hardware_rgb_led_off">
|
53
|
+
<field name="AC">anode</field>
|
54
|
+
<field name="PIN">D3</field>
|
55
|
+
<next>
|
56
|
+
<block type="looks_say" inline="true">
|
57
|
+
<value name="TEXT">
|
58
|
+
<block type="text">
|
59
|
+
<field name="TEXT" />
|
60
|
+
</block>
|
61
|
+
</value>
|
62
|
+
</block>
|
63
|
+
</next>
|
64
|
+
</block>
|
65
|
+
</next>
|
66
|
+
</block>
|
67
|
+
</next>
|
68
|
+
</block>
|
69
|
+
</next>
|
70
|
+
</block>
|
71
|
+
</next>
|
72
|
+
</block>
|
73
|
+
</next>
|
74
|
+
</block>
|
75
|
+
</next>
|
76
|
+
</block>
|
77
|
+
</next>
|
78
|
+
</block>
|
79
|
+
</statement>
|
80
|
+
</block>
|
81
|
+
</statement>
|
82
|
+
</block>
|
83
|
+
</xml>
|
Binary file
|
@@ -12,10 +12,27 @@
|
|
12
12
|
//
|
13
13
|
//= require jquery
|
14
14
|
//= require jquery_ujs
|
15
|
+
//= require jquery.ui.draggable
|
16
|
+
//= require jquery.ui.droppable
|
17
|
+
//= require jquery.blockUI
|
15
18
|
//= require turbolinks
|
16
19
|
//= require ace/ace
|
17
20
|
//= require ace/theme-clouds.js
|
18
21
|
//= require ace/mode-ruby.js
|
19
22
|
//= require bootstrap.js
|
20
23
|
//= require jquery-fileupload/basic
|
21
|
-
//=
|
24
|
+
//= require blockly/blockly_compressed
|
25
|
+
//= require blockly/blocks_compressed
|
26
|
+
//= require blockly/msg/js/ja
|
27
|
+
//= require underscore
|
28
|
+
//= require backbone
|
29
|
+
//= require smalruby
|
30
|
+
//= require_tree ../templates
|
31
|
+
//= require_tree ./models
|
32
|
+
//= require_tree ./collections
|
33
|
+
//= require_tree ./views
|
34
|
+
//= require_tree ./routers
|
35
|
+
//= require ./block_mode
|
36
|
+
//= require_tree ./generators
|
37
|
+
//= require_tree ./blocks
|
38
|
+
//= require ./ruby_mode
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Blocklyが提供しているブロック
|
2
|
+
|
3
|
+
<% category = 'math' %>
|
4
|
+
|
5
|
+
<% n = "#{category}_number" %>
|
6
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
7
|
+
code = parseFloat(@getFieldValue('NUM'))
|
8
|
+
order = if code < 0 then Blockly.Ruby.ORDER_UNARY_SIGN else Blockly.Ruby.ORDER_ATOMIC
|
9
|
+
[code, order]
|
10
|
+
|
11
|
+
|
12
|
+
<% category = 'text' %>
|
13
|
+
|
14
|
+
<% n = "#{category}" %>
|
15
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
16
|
+
code = Blockly.Ruby.quote_(@getFieldValue('TEXT'))
|
17
|
+
[code, Blockly.Ruby.ORDER_ATOMIC]
|
18
|
+
|
19
|
+
|
20
|
+
# 変数
|
21
|
+
<% category = 'variables' %>
|
22
|
+
|
23
|
+
# [▼](変数)
|
24
|
+
<% n = "#{category}_get" %>
|
25
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
26
|
+
name = Blockly.Ruby.variableDB_.getName(block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE)
|
27
|
+
[name, Blockly.Ruby.ORDER_ATOMIC]
|
28
|
+
|
29
|
+
# セット[▼]宛先
|
30
|
+
<% n = "#{category}_set" %>
|
31
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
32
|
+
val = Blockly.Ruby.valueToCode(block, 'VALUE', Blockly.Ruby.ORDER_NONE) || '0'
|
33
|
+
name = Blockly.Ruby.variableDB_.getName(block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE)
|
34
|
+
name + ' = ' + val + '\n';
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# 「キャラクター」ジャンル
|
2
|
+
|
3
|
+
<%
|
4
|
+
category = 'character'
|
5
|
+
color = 198
|
6
|
+
%>
|
7
|
+
|
8
|
+
# キャラクター
|
9
|
+
<% n = "#{category}_new" %>
|
10
|
+
Blockly.Blocks['<%= n %>'] =
|
11
|
+
init: ->
|
12
|
+
@setHelpUrl('')
|
13
|
+
@setColour(<%= color %>)
|
14
|
+
|
15
|
+
size = Blockly.BlockSvg.FIELD_HEIGHT * 2
|
16
|
+
imageField = new Blockly.FieldImage(null, size, size)
|
17
|
+
|
18
|
+
nameField = new Blockly.FieldLabel('')
|
19
|
+
# HACK: ラベルをXMLとして出力させるためにEDITABLEをtrueにしている
|
20
|
+
nameField.EDITABLE = true
|
21
|
+
# HACK: 画像とラベルの縦位置を合わせる
|
22
|
+
nameField.textElement_.setAttribute('y', 10)
|
23
|
+
nameField.setText = _.bind(@nameFieldSetText_, @)
|
24
|
+
|
25
|
+
@appendDummyInput()
|
26
|
+
.appendField(imageField, 'COSTUME')
|
27
|
+
.appendField(nameField, 'NAME')
|
28
|
+
@appendStatementInput('DO')
|
29
|
+
@setPreviousStatement(true)
|
30
|
+
@setNextStatement(true)
|
31
|
+
@setTooltip('')
|
32
|
+
|
33
|
+
dispose: (healStack, animate) ->
|
34
|
+
@character.off 'change', @changeHandler
|
35
|
+
@character.unlink?(@)
|
36
|
+
Blockly.Block.prototype.dispose.apply(@, arguments)
|
37
|
+
|
38
|
+
nameFieldSetText_: (name) ->
|
39
|
+
charSet = Smalruby.Collections.CharacterSet
|
40
|
+
char = charSet.findWhere({ name: name })
|
41
|
+
if char
|
42
|
+
@setCharacter(char)
|
43
|
+
else
|
44
|
+
@fieldLableSetText_(@getField_('NAME'), name)
|
45
|
+
|
46
|
+
fieldLableSetText_: (field, text) ->
|
47
|
+
Blockly.FieldLabel.prototype.setText.call(field, text)
|
48
|
+
|
49
|
+
setCharacter: (character) ->
|
50
|
+
if @changeHandler
|
51
|
+
@character.off 'change', @changeHandler
|
52
|
+
|
53
|
+
@character = character
|
54
|
+
@setFieldValue(character.costumeUrl(), 'COSTUME')
|
55
|
+
@fieldLableSetText_(@getField_('NAME'), character.get('name'))
|
56
|
+
character.link(@)
|
57
|
+
|
58
|
+
@changeHandler = (model) =>
|
59
|
+
@setFieldValue(model.costumeUrl(), 'COSTUME')
|
60
|
+
@fieldLableSetText_(@getField_('NAME'), character.get('name'))
|
61
|
+
|
62
|
+
character.on 'change', @changeHandler
|
63
|
+
|
64
|
+
@
|
65
|
+
|
66
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
67
|
+
c = block.character
|
68
|
+
Blockly.Ruby.definitions_["character_#{c.get('name')}"] =
|
69
|
+
"#{c.get('name')} = Character.new(costume: #{Blockly.Ruby.quote_(c.costume())}, x: #{c.get('x')}, y: #{c.get('y')}, angle: #{c.get('angle')})"
|
70
|
+
Blockly.Ruby.cs_().push(c)
|
71
|
+
try
|
72
|
+
targetBlock = block.getInputTargetBlock('DO')
|
73
|
+
code = Blockly.Ruby.blockToCode(targetBlock) || '\n'
|
74
|
+
finally
|
75
|
+
Blockly.Ruby.cs_().pop()
|
76
|
+
code
|