reight 0.1.7 β 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +12 -0
- data/CONTRIBUTING.md +7 -0
- data/ChangeLog.md +29 -0
- data/README.md +7 -6
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/r8 +18 -8
- data/lib/reight/all.rb +1 -0
- data/lib/reight/app/chips.rb +124 -0
- data/lib/reight/app/map/canvas.rb +6 -2
- data/lib/reight/app/map/editor.rb +40 -13
- data/lib/reight/app/map.rb +0 -1
- data/lib/reight/app/navigator.rb +6 -20
- data/lib/reight/app/runner.rb +32 -17
- data/lib/reight/app/sound/editor.rb +1 -1
- data/lib/reight/app/sprite/canvas.rb +5 -3
- data/lib/reight/app/sprite/editor.rb +49 -25
- data/lib/reight/app/sprite.rb +0 -1
- data/lib/reight/app.rb +5 -4
- data/lib/reight/button.rb +3 -3
- data/lib/reight/chip.rb +8 -0
- data/lib/reight/index.rb +32 -21
- data/lib/reight/map.rb +13 -3
- data/lib/reight/project.rb +11 -0
- data/lib/reight/reight.rb +11 -13
- data/lib/reight/text.rb +22 -14
- data/reight.gemspec +7 -7
- metadata +31 -30
- data/lib/reight/app/map/chips.rb +0 -88
- data/lib/reight/app/sprite/chips.rb +0 -97
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbdffdfb7d51855ef6fdab7ead00886530a5fe7510dbe257edc908d26e1221d1
|
4
|
+
data.tar.gz: e1896619ec746ad694474cf2a1aef637092ffb56f726f724bc99e4ea48fb4d9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b12a7fe380ce0bb554318a2bd0584eebe3fce8cb72594c906f9232b136ecebde0ab3a840ef5c79684f04ac3d3fef15a7ae89b740e3d25887879b827baf73243
|
7
|
+
data.tar.gz: 5f2e53eba4f7669c1181fd7419e5b768046a9e23fac616381595bf677c085e5437e57d957d4ce5b82f1afde3d7ecc8308fdd89435fa249145af47871e4280349
|
@@ -0,0 +1,12 @@
|
|
1
|
+
## Pull Requests Not Accepted π«
|
2
|
+
|
3
|
+
Thank you for your interest in contributing!
|
4
|
+
However, this repository does not accept pull requests directly.
|
5
|
+
|
6
|
+
### Where to Contribute?
|
7
|
+
|
8
|
+
Please submit your changes to the [xord/all](https://github.com/xord/all) monorepo, which serves as the primary repository for all our main libraries.
|
9
|
+
|
10
|
+
For more details, please refer to our [contribution guidelines](../CONTRIBUTING.md).
|
11
|
+
|
12
|
+
Thanks for your understanding! π
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Contribution Guide
|
2
|
+
|
3
|
+
Thank you for your interest in contributing!
|
4
|
+
However, this repository does not accept pull requests.
|
5
|
+
Instead, please submit your changes to the [xord/all](https://github.com/xord/all) monorepo, which serves as the primary repository for all our main libraries.
|
6
|
+
|
7
|
+
For any questions, feel free to open an issue.
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,35 @@
|
|
1
1
|
# reight ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.1.9] - 2025-04-08
|
5
|
+
|
6
|
+
- Update README
|
7
|
+
|
8
|
+
|
9
|
+
## [v0.1.8] - 2025-03-24
|
10
|
+
|
11
|
+
- Add '--edit' command-line option to enable edit mode
|
12
|
+
- Add Text#editable?
|
13
|
+
- Add SpriteEditor::chips_index
|
14
|
+
- Add frame_changed and selection_changed to Sprite::Canvas
|
15
|
+
- Add Index control for maps
|
16
|
+
- Add PULL_REQUEST_TEMPLATE.md
|
17
|
+
- Add CONTRIBUTING.md
|
18
|
+
- Update layout
|
19
|
+
- Share the chips.rb
|
20
|
+
- Move chip_sizes above chips
|
21
|
+
- Refine visuals of button and index
|
22
|
+
- Index has min and max
|
23
|
+
- Text::initialize can take 'align:' keyword parameter
|
24
|
+
- The text input area will not be shaked if the value determined by the click is empty
|
25
|
+
- Fix the text value if not reverted on exiting edit mode with invalid value
|
26
|
+
- Delete App#name
|
27
|
+
- Simplify inspect() text
|
28
|
+
- Update readme: Add link to examples (by @kaibadash)
|
29
|
+
|
30
|
+
- Fix some crashes
|
31
|
+
|
32
|
+
|
4
33
|
## [v0.1.7] - 2025-03-07
|
5
34
|
|
6
35
|
- Add Reight::Context
|
data/README.md
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
# Reight - A Retro Game Engine for Ruby
|
3
2
|
|
4
3
|
Reight is an open-source Ruby library inspired by the powerful [Processing](https://processing.org/) API, designed to make creative coding accessible and enjoyable for everyone. With support for both Mac and Windows, this library brings the joy of visual programming to Ruby developers.
|
@@ -38,20 +37,22 @@ Hereβs a simple example to get you started:
|
|
38
37
|
# Create a window and draw something
|
39
38
|
draw do
|
40
39
|
background 0
|
41
|
-
|
42
|
-
|
40
|
+
$sprites ||= project.maps.first.map(&:to_sprite)
|
41
|
+
sprite $sprites
|
43
42
|
end
|
44
43
|
```
|
45
44
|
|
46
45
|
Run the script and watch your window come to life!
|
47
46
|
|
47
|
+
```bash
|
48
|
+
$ bundle exec r8 --edit .
|
48
49
|
```
|
49
|
-
|
50
|
-
|
50
|
+
|
51
|
+
You can find example projects in [xord/reight-examples](https://github.com/xord/reight-examples).
|
51
52
|
|
52
53
|
## Documentation
|
53
54
|
|
54
|
-
Comprehensive documentation and guides can be found [here](https://www.rubydoc.info/gems/reight/
|
55
|
+
Comprehensive documentation and guides can be found [here](https://www.rubydoc.info/gems/reight/).
|
55
56
|
|
56
57
|
## License
|
57
58
|
|
data/Rakefile
CHANGED
@@ -29,5 +29,5 @@ build_ruby_gem
|
|
29
29
|
task :run do
|
30
30
|
libs = %w[xot rucy beeps rays reflex processing rubysketch]
|
31
31
|
.map {|lib| "-I#{ENV['ALL']}/#{lib}/lib"}
|
32
|
-
sh %( ruby #{libs.join ' '} -Ilib bin/r8 '#{ENV["dir"] || "
|
32
|
+
sh %( ruby #{libs.join ' '} -Ilib bin/r8 --edit '#{ENV["dir"] || "demo/hello"}' )
|
33
33
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.9
|
data/bin/r8
CHANGED
@@ -1,21 +1,31 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'optparse'
|
3
4
|
require 'reight'
|
4
|
-
using Reight
|
5
5
|
|
6
6
|
|
7
|
-
|
7
|
+
opt = OptionParser.new
|
8
|
+
opt.banner = "Usage: r8 [options] [DIR]"
|
9
|
+
opt.version = Reight::Extension.version
|
10
|
+
|
11
|
+
opt.on '-e', '--edit', "edit mode"
|
12
|
+
opt.on_tail '-h', '--help'
|
13
|
+
|
14
|
+
params = {}
|
15
|
+
argv = opt.parse! ARGV, into: params
|
8
16
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
END
|
17
|
+
if params.key? :help
|
18
|
+
puts opt.help
|
19
|
+
exit
|
13
20
|
end
|
14
21
|
|
22
|
+
|
23
|
+
def r8 = $r8__
|
24
|
+
|
15
25
|
Reight::CONTEXT__.tap do |c|
|
16
|
-
path =
|
26
|
+
path = argv.shift || '.'
|
17
27
|
path = File.expand_path path, Dir.pwd unless path.start_with?('/')
|
18
|
-
c.setup {Reight::R8.new(path).setup}
|
28
|
+
c.setup {Reight::R8.new(path, edit: params[:edit]).setup}
|
19
29
|
c.draw {r8.draw}
|
20
30
|
c.key_pressed {r8.key_pressed}
|
21
31
|
c.key_released {r8.key_released}
|
data/lib/reight/all.rb
CHANGED
@@ -0,0 +1,124 @@
|
|
1
|
+
using Reight
|
2
|
+
|
3
|
+
|
4
|
+
class Reight::App::Chips
|
5
|
+
|
6
|
+
include Reight::Hookable
|
7
|
+
|
8
|
+
def initialize(
|
9
|
+
app, chips, size = 8,
|
10
|
+
page_width = app.project.chips_page_width,
|
11
|
+
page_height = app.project.chips_page_height)
|
12
|
+
|
13
|
+
hook :frame_changed
|
14
|
+
hook :offset_changed
|
15
|
+
|
16
|
+
@app, @chips = app, chips
|
17
|
+
@page_size = create_vector page_width, page_height
|
18
|
+
@offset = create_vector 0, 0
|
19
|
+
|
20
|
+
set_frame 0, 0, size, size
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :x, :y, :size, :offset
|
24
|
+
|
25
|
+
def chip = @chips.at x, y, size, size
|
26
|
+
|
27
|
+
def set_frame(x, y, w = size, h = size)
|
28
|
+
raise 'Chips: width != height' if w != h
|
29
|
+
@x = align_to_grid(x).clamp(0..@chips.image.width)
|
30
|
+
@y = align_to_grid(y).clamp(0..@chips.image.height)
|
31
|
+
@size = w
|
32
|
+
frame_changed! @x, @y, @size, @size
|
33
|
+
end
|
34
|
+
|
35
|
+
def offset=(pos)
|
36
|
+
sp = sprite
|
37
|
+
x = pos.x.clamp([-(@chips.image.width - sp.w), 0].min..0)
|
38
|
+
y = pos.y.clamp([-(@chips.image.height - sp.h), 0].min..0)
|
39
|
+
offset = create_vector x, y
|
40
|
+
return if offset == @offset
|
41
|
+
@offset = offset
|
42
|
+
offset_changed! @offset
|
43
|
+
end
|
44
|
+
|
45
|
+
def index2offset(index)
|
46
|
+
pw, ph = @page_size.x.to_i, @page_size.y.to_i
|
47
|
+
size = @chips.image.width / pw
|
48
|
+
create_vector -(index % size).to_i * pw, -(index / size).to_i * ph
|
49
|
+
end
|
50
|
+
|
51
|
+
def offset2index(offset = self.offset)
|
52
|
+
iw = @chips.image.width
|
53
|
+
pw, ph = @page_size.x.to_i, @page_size.y.to_i
|
54
|
+
x, y = (-offset.x / ph).to_i, (-offset.y / pw).to_i
|
55
|
+
w = (iw / pw).to_i
|
56
|
+
y * w + x
|
57
|
+
end
|
58
|
+
|
59
|
+
def draw()
|
60
|
+
sp = sprite
|
61
|
+
clip sp.x, sp.y, sp.w, sp.h
|
62
|
+
|
63
|
+
fill 0
|
64
|
+
no_stroke
|
65
|
+
rect 0, 0, sp.w, sp.h
|
66
|
+
|
67
|
+
translate offset.x, offset.y
|
68
|
+
draw_offset_grids
|
69
|
+
image @chips.image, 0, 0
|
70
|
+
draw_frame
|
71
|
+
end
|
72
|
+
|
73
|
+
def draw_offset_grids()
|
74
|
+
no_fill
|
75
|
+
stroke 50
|
76
|
+
iw, ih = @chips.image.width, @chips.image.height
|
77
|
+
cw, ch = @page_size.x, @page_size.y
|
78
|
+
(cw...iw).step(cw) {|x| line x, 0, x, ih}
|
79
|
+
(ch...ih).step(ch) {|y| line 0, y, iw, y}
|
80
|
+
end
|
81
|
+
|
82
|
+
def draw_frame()
|
83
|
+
no_fill
|
84
|
+
stroke 255
|
85
|
+
stroke_weight 1
|
86
|
+
rect @x, @y, @size, @size
|
87
|
+
end
|
88
|
+
|
89
|
+
def mouse_pressed(x, y)
|
90
|
+
@prev_pos = create_vector x, y
|
91
|
+
end
|
92
|
+
|
93
|
+
def mouse_released(x, y)
|
94
|
+
end
|
95
|
+
|
96
|
+
def mouse_dragged(x, y)
|
97
|
+
pos = create_vector x, y
|
98
|
+
self.offset += pos - @prev_pos if @prev_pos
|
99
|
+
@prev_pos = pos
|
100
|
+
end
|
101
|
+
|
102
|
+
def mouse_clicked(x, y)
|
103
|
+
set_frame(
|
104
|
+
-offset.x + align_to_grid(x),
|
105
|
+
-offset.y + align_to_grid(y))
|
106
|
+
end
|
107
|
+
|
108
|
+
def sprite()
|
109
|
+
@sprite ||= RubySketch::Sprite.new.tap do |sp|
|
110
|
+
sp.draw {draw}
|
111
|
+
sp.mouse_pressed {mouse_pressed sp.mouse_x, sp.mouse_y}
|
112
|
+
sp.mouse_released {mouse_released sp.mouse_x, sp.mouse_y}
|
113
|
+
sp.mouse_dragged {mouse_dragged sp.mouse_x, sp.mouse_y}
|
114
|
+
sp.mouse_clicked {mouse_clicked sp.mouse_x, sp.mouse_y}
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
private
|
119
|
+
|
120
|
+
def align_to_grid(n)
|
121
|
+
n.to_i / 8 * 8
|
122
|
+
end
|
123
|
+
|
124
|
+
end# Chips
|
@@ -3,8 +3,8 @@ using Reight
|
|
3
3
|
|
4
4
|
class Reight::MapEditor::Canvas
|
5
5
|
|
6
|
-
def initialize(app, map
|
7
|
-
@app, @map
|
6
|
+
def initialize(app, map)
|
7
|
+
@app, @map = app, map
|
8
8
|
@x, @y, @tool, @cursor = 0, 0, nil, nil, nil
|
9
9
|
end
|
10
10
|
|
@@ -12,6 +12,10 @@ class Reight::MapEditor::Canvas
|
|
12
12
|
|
13
13
|
attr_reader :map, :cursor
|
14
14
|
|
15
|
+
def map=(map)
|
16
|
+
@map = map
|
17
|
+
end
|
18
|
+
|
15
19
|
def save()
|
16
20
|
@app.project.save
|
17
21
|
end
|
@@ -4,11 +4,15 @@ using Reight
|
|
4
4
|
class Reight::MapEditor < Reight::App
|
5
5
|
|
6
6
|
def canvas()
|
7
|
-
@canvas ||= Canvas.new self, project.maps.first
|
7
|
+
@canvas ||= Canvas.new self, project.maps.first
|
8
8
|
end
|
9
9
|
|
10
10
|
def chips()
|
11
|
-
@chips ||= Chips.new
|
11
|
+
@chips ||= Chips.new(self, project.chips).tap do |chips|
|
12
|
+
chips.offset_changed do |offset|
|
13
|
+
chips_index.index = chips.offset2index offset
|
14
|
+
end
|
15
|
+
end
|
12
16
|
end
|
13
17
|
|
14
18
|
def setup()
|
@@ -42,25 +46,36 @@ class Reight::MapEditor < Reight::App
|
|
42
46
|
|
43
47
|
def window_resized()
|
44
48
|
super
|
49
|
+
[chip_sizes, tools].flatten.map(&:sprite)
|
50
|
+
.each {|sp| sp.w = sp.h = BUTTON_SIZE}
|
51
|
+
|
52
|
+
chips_index.sprite.tap do |sp|
|
53
|
+
sp.w, sp.h = INDEX_SIZE, BUTTON_SIZE
|
54
|
+
sp.x = SPACE
|
55
|
+
sp.y = NAVIGATOR_HEIGHT + SPACE
|
56
|
+
end
|
57
|
+
chip_sizes.reverse.map {_1.sprite}.each.with_index do |sp, index|
|
58
|
+
sp.x = SPACE + CHIPS_WIDTH - (sp.w + (sp.w + 1) * index)
|
59
|
+
sp.y = chips_index.sprite.y
|
60
|
+
end
|
45
61
|
chips.sprite.tap do |sp|
|
46
62
|
sp.x = SPACE
|
47
|
-
sp.y =
|
48
|
-
sp.
|
63
|
+
sp.y = chip_sizes.last.sprite.bottom + SPACE
|
64
|
+
sp.right = chip_sizes.last.sprite.right
|
49
65
|
sp.bottom = height - SPACE
|
50
66
|
end
|
67
|
+
map_index.sprite.tap do |sp|
|
68
|
+
sp.w, sp.h = INDEX_SIZE, BUTTON_SIZE
|
69
|
+
sp.x = chip_sizes.last.sprite.right + SPACE
|
70
|
+
sp.y = chip_sizes.last.sprite.y
|
71
|
+
end
|
51
72
|
tools.map {_1.sprite}.each.with_index do |sp, index|
|
52
|
-
sp.w = sp.h = BUTTON_SIZE
|
53
73
|
sp.x = chips.sprite.right + SPACE + (sp.w + 1) * index
|
54
74
|
sp.y = height - (SPACE + sp.h)
|
55
75
|
end
|
56
|
-
chip_sizes.reverse.map {_1.sprite}.each.with_index do |sp, index|
|
57
|
-
sp.w = sp.h = BUTTON_SIZE
|
58
|
-
sp.x = width - (SPACE + sp.w * (index + 1) + index)
|
59
|
-
sp.y = height - (SPACE + sp.h)
|
60
|
-
end
|
61
76
|
canvas.sprite.tap do |sp|
|
62
|
-
sp.x =
|
63
|
-
sp.y =
|
77
|
+
sp.x = map_index.sprite.x
|
78
|
+
sp.y = map_index.sprite.bottom + SPACE
|
64
79
|
sp.right = width - SPACE
|
65
80
|
sp.bottom = tools.first.sprite.top - SPACE
|
66
81
|
end
|
@@ -93,10 +108,16 @@ class Reight::MapEditor < Reight::App
|
|
93
108
|
private
|
94
109
|
|
95
110
|
def sprites()
|
96
|
-
[
|
111
|
+
[chips_index, *chip_sizes, chips, map_index, *tools, canvas]
|
97
112
|
.map(&:sprite) + super
|
98
113
|
end
|
99
114
|
|
115
|
+
def chips_index()
|
116
|
+
@chips_index ||= Reight::Index.new max: project.chips_npages - 1 do |index|
|
117
|
+
chips.offset = chips.index2offset index if index != chips.offset2index
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
100
121
|
def chip_sizes()
|
101
122
|
@chip_sizes ||= group(*[8, 16, 32].map {|size|
|
102
123
|
Reight::Button.new name: "#{size}x#{size}", label: size do
|
@@ -105,6 +126,12 @@ class Reight::MapEditor < Reight::App
|
|
105
126
|
})
|
106
127
|
end
|
107
128
|
|
129
|
+
def map_index()
|
130
|
+
@map_index ||= Reight::Index.new do |index|
|
131
|
+
canvas.map = project.maps[index] ||= Reight::Map.new
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
108
135
|
def tools()
|
109
136
|
@tools ||= group brush, line, stroke_rect, fill_rect
|
110
137
|
end
|
data/lib/reight/app/map.rb
CHANGED
data/lib/reight/app/navigator.rb
CHANGED
@@ -32,7 +32,7 @@ class Reight::Navigator
|
|
32
32
|
|
33
33
|
def key_pressed()
|
34
34
|
index = [F1, F2, F3, F4, F5].index(key_code)
|
35
|
-
app_buttons[index]
|
35
|
+
app_buttons[index]&.click if index
|
36
36
|
end
|
37
37
|
|
38
38
|
def window_resized()
|
@@ -77,20 +77,11 @@ class Reight::Navigator
|
|
77
77
|
private
|
78
78
|
|
79
79
|
def app_buttons()
|
80
|
-
@app_buttons ||=
|
81
|
-
Reight::Button.new(name:
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
switch_app Reight::SpriteEditor
|
86
|
-
},
|
87
|
-
Reight::Button.new(name: 'Map Editor', icon: @app.icon(2, 0, 8)) {
|
88
|
-
switch_app Reight::MapEditor
|
89
|
-
},
|
90
|
-
Reight::Button.new(name: 'Sound Editor', icon: @app.icon(3, 0, 8)) {
|
91
|
-
switch_app Reight::SoundEditor
|
92
|
-
},
|
93
|
-
]
|
80
|
+
@app_buttons ||= r8.apps.map.with_index {|app, index|
|
81
|
+
Reight::Button.new(name: app.label, icon: app.icon(index, 0, 8)) {
|
82
|
+
r8.current = app
|
83
|
+
}
|
84
|
+
}
|
94
85
|
end
|
95
86
|
|
96
87
|
def history_buttons()
|
@@ -134,11 +125,6 @@ class Reight::Navigator
|
|
134
125
|
@message ||= Message.new
|
135
126
|
end
|
136
127
|
|
137
|
-
def switch_app(klass)
|
138
|
-
app = r8.apps.find {_1.class == klass}
|
139
|
-
r8.current = app if app
|
140
|
-
end
|
141
|
-
|
142
128
|
end# Navigator
|
143
129
|
|
144
130
|
|
data/lib/reight/app/runner.rb
CHANGED
@@ -6,6 +6,12 @@ class Reight::Runner < Reight::App
|
|
6
6
|
|
7
7
|
TEMPORARY_HASH = {}
|
8
8
|
|
9
|
+
def label = 'Run'
|
10
|
+
|
11
|
+
def setup()
|
12
|
+
navigator.visible = false
|
13
|
+
end
|
14
|
+
|
9
15
|
def activated()
|
10
16
|
run force: true
|
11
17
|
@context.call_activated__ {|&b| call_event(ignore_pause: true, &b)}
|
@@ -61,7 +67,7 @@ class Reight::Runner < Reight::App
|
|
61
67
|
|
62
68
|
def mouse_moved()
|
63
69
|
super
|
64
|
-
navigator.visible = ROOT_CONTEXT.mouse_y < NAVIGATOR_HEIGHT
|
70
|
+
navigator.visible = ROOT_CONTEXT.mouse_y < NAVIGATOR_HEIGHT if r8.edit?
|
65
71
|
call_event {@context.mouse_moved}
|
66
72
|
end
|
67
73
|
|
@@ -113,15 +119,18 @@ class Reight::Runner < Reight::App
|
|
113
119
|
private
|
114
120
|
|
115
121
|
def call_event(push: true, ignore_pause: false, &block)
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
122
|
+
if @context
|
123
|
+
@context.beginDraw__
|
124
|
+
@context.push if push
|
125
|
+
block.call unless paused?
|
126
|
+
end
|
120
127
|
rescue ScriptError, StandardError => e
|
121
128
|
puts e.full_message
|
122
129
|
ensure
|
123
|
-
@context
|
124
|
-
|
130
|
+
if @context
|
131
|
+
@context.pop if push
|
132
|
+
@context.endDraw__
|
133
|
+
end
|
125
134
|
end
|
126
135
|
|
127
136
|
def running? = @context && !@paused
|
@@ -175,6 +184,10 @@ class Reight::Runner < Reight::App
|
|
175
184
|
caller.call {draw}
|
176
185
|
end
|
177
186
|
|
187
|
+
def inspect()
|
188
|
+
"#<#{self.class.name}:0x#{object_id}>"
|
189
|
+
end
|
190
|
+
|
178
191
|
methods = (instance_methods - Object.instance_methods)
|
179
192
|
.reject {_1.end_with? '__'}
|
180
193
|
Processing.to_snake_case__(methods).each do |camel, snake|
|
@@ -255,23 +268,17 @@ class Reight::Runner < Reight::App
|
|
255
268
|
TEMPORARY_HASH.delete :params
|
256
269
|
end
|
257
270
|
|
271
|
+
EXCLUDE_GLOBAL_VARS = [:$FILENAME]
|
272
|
+
|
258
273
|
def backup_global_vars()
|
259
|
-
@global_vars = global_variables
|
274
|
+
@global_vars = (global_variables - EXCLUDE_GLOBAL_VARS)
|
260
275
|
.each.with_object({}) {|name, hash| hash[name] = eval name.to_s}
|
261
276
|
.freeze
|
262
277
|
end
|
263
278
|
|
264
|
-
def clear_all_timers()
|
265
|
-
prefix = Reight::Context::TIMER_PREFIX__
|
266
|
-
ROOT_CONTEXT.instance_eval do
|
267
|
-
@timers__ .delete_if {|id| id in [prefix, _]}
|
268
|
-
@firingTimers__.delete_if {|id| id in [prefix, _]}
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
279
|
def restore_global_vars()
|
273
280
|
return unless @global_vars
|
274
|
-
global_variables
|
281
|
+
(global_variables - EXCLUDE_GLOBAL_VARS)
|
275
282
|
.map {|name| [name, eval(name.to_s)]}
|
276
283
|
.select {|name, value| value != nil && @global_vars[name] == nil}
|
277
284
|
.each {|name, value| global_var_set name, nil}
|
@@ -289,4 +296,12 @@ class Reight::Runner < Reight::App
|
|
289
296
|
TEMPORARY_HASH.delete :value
|
290
297
|
end
|
291
298
|
|
299
|
+
def clear_all_timers()
|
300
|
+
prefix = Reight::Context::TIMER_PREFIX__
|
301
|
+
ROOT_CONTEXT.instance_eval do
|
302
|
+
@timers__ .delete_if {|id| id in [prefix, _]}
|
303
|
+
@firingTimers__.delete_if {|id| id in [prefix, _]}
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
292
307
|
end# Runner
|
@@ -107,7 +107,7 @@ class Reight::SoundEditor < Reight::App
|
|
107
107
|
|
108
108
|
def bpm()
|
109
109
|
@bpm ||= Reight::Text.new(
|
110
|
-
canvas.sound.bpm, label: 'BPM ', regexp: /^\-?\d
|
110
|
+
canvas.sound.bpm, label: 'BPM ', regexp: /^\-?\d+$/, editable: true
|
111
111
|
) do |str, text|
|
112
112
|
bpm = str.to_i.clamp(0, Reight::Sound::BPM_MAX)
|
113
113
|
next text.revert if bpm <= 0
|
@@ -6,6 +6,8 @@ class Reight::SpriteEditor::Canvas
|
|
6
6
|
include Reight::Hookable
|
7
7
|
|
8
8
|
def initialize(app, image, path)
|
9
|
+
hook :frame_changed
|
10
|
+
hook :selection_changed
|
9
11
|
hook :color_changed
|
10
12
|
|
11
13
|
@app, @image, @path = app, image, path
|
@@ -34,7 +36,7 @@ class Reight::SpriteEditor::Canvas
|
|
34
36
|
new = correct_bounds x, y, w, h
|
35
37
|
return if new == old
|
36
38
|
@x, @y, @w, @h = new
|
37
|
-
|
39
|
+
frame_changed! old, new
|
38
40
|
end
|
39
41
|
|
40
42
|
def frame = [x, y, w, h]
|
@@ -50,7 +52,7 @@ class Reight::SpriteEditor::Canvas
|
|
50
52
|
new = correct_bounds x, y, w, h
|
51
53
|
return if new == old
|
52
54
|
@selection = new
|
53
|
-
|
55
|
+
selection_changed! old, new
|
54
56
|
end
|
55
57
|
|
56
58
|
def selection()
|
@@ -65,7 +67,7 @@ class Reight::SpriteEditor::Canvas
|
|
65
67
|
def deselect()
|
66
68
|
return if @selection == nil
|
67
69
|
old, @selection = @selection, nil
|
68
|
-
|
70
|
+
selection_changed! old, nil
|
69
71
|
end
|
70
72
|
|
71
73
|
def paint(&block)
|