cyberarm_engine 0.19.0 → 0.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +8 -8
- data/.rubocop.yml +7 -7
- data/.travis.yml +5 -5
- data/Gemfile +6 -6
- data/LICENSE.txt +21 -21
- data/README.md +74 -74
- data/Rakefile +10 -10
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/cyberarm_engine.gemspec +39 -39
- data/lib/cyberarm_engine/animator.rb +219 -219
- data/lib/cyberarm_engine/background.rb +179 -179
- data/lib/cyberarm_engine/background_nine_slice.rb +142 -142
- data/lib/cyberarm_engine/bounding_box.rb +150 -150
- data/lib/cyberarm_engine/builtin/intro_state.rb +130 -130
- data/lib/cyberarm_engine/cache/download_manager.rb +121 -121
- data/lib/cyberarm_engine/cache.rb +4 -4
- data/lib/cyberarm_engine/common.rb +113 -113
- data/lib/cyberarm_engine/config_file.rb +46 -46
- data/lib/cyberarm_engine/console/command.rb +157 -157
- data/lib/cyberarm_engine/console/commands/help_command.rb +43 -43
- data/lib/cyberarm_engine/console/subcommand.rb +99 -99
- data/lib/cyberarm_engine/console.rb +248 -248
- data/lib/cyberarm_engine/game_object.rb +248 -248
- data/lib/cyberarm_engine/game_state.rb +97 -97
- data/lib/cyberarm_engine/model/material.rb +21 -21
- data/lib/cyberarm_engine/model/model_object.rb +131 -131
- data/lib/cyberarm_engine/model/parser.rb +74 -74
- data/lib/cyberarm_engine/model/parsers/collada_parser.rb +138 -138
- data/lib/cyberarm_engine/model/parsers/wavefront_parser.rb +154 -154
- data/lib/cyberarm_engine/model.rb +212 -212
- data/lib/cyberarm_engine/model_cache.rb +31 -31
- data/lib/cyberarm_engine/opengl/light.rb +50 -50
- data/lib/cyberarm_engine/opengl/orthographic_camera.rb +46 -46
- data/lib/cyberarm_engine/opengl/perspective_camera.rb +38 -38
- data/lib/cyberarm_engine/opengl/renderer/bounding_box_renderer.rb +249 -249
- data/lib/cyberarm_engine/opengl/renderer/g_buffer.rb +164 -164
- data/lib/cyberarm_engine/opengl/renderer/opengl_renderer.rb +298 -298
- data/lib/cyberarm_engine/opengl/renderer/renderer.rb +22 -22
- data/lib/cyberarm_engine/opengl/shader.rb +406 -406
- data/lib/cyberarm_engine/opengl/texture.rb +69 -69
- data/lib/cyberarm_engine/opengl.rb +28 -28
- data/lib/cyberarm_engine/ray.rb +56 -56
- data/lib/cyberarm_engine/stats.rb +21 -21
- data/lib/cyberarm_engine/text.rb +197 -197
- data/lib/cyberarm_engine/timer.rb +23 -23
- data/lib/cyberarm_engine/transform.rb +296 -296
- data/lib/cyberarm_engine/ui/border_canvas.rb +102 -102
- data/lib/cyberarm_engine/ui/dsl.rb +139 -139
- data/lib/cyberarm_engine/ui/element.rb +488 -488
- data/lib/cyberarm_engine/ui/elements/button.rb +97 -97
- data/lib/cyberarm_engine/ui/elements/check_box.rb +54 -54
- data/lib/cyberarm_engine/ui/elements/container.rb +256 -256
- data/lib/cyberarm_engine/ui/elements/edit_box.rb +179 -179
- data/lib/cyberarm_engine/ui/elements/edit_line.rb +263 -263
- data/lib/cyberarm_engine/ui/elements/flow.rb +15 -15
- data/lib/cyberarm_engine/ui/elements/image.rb +72 -72
- data/lib/cyberarm_engine/ui/elements/list_box.rb +88 -82
- data/lib/cyberarm_engine/ui/elements/progress.rb +51 -51
- data/lib/cyberarm_engine/ui/elements/radio.rb +6 -6
- data/lib/cyberarm_engine/ui/elements/slider.rb +104 -104
- data/lib/cyberarm_engine/ui/elements/stack.rb +11 -11
- data/lib/cyberarm_engine/ui/elements/text_block.rb +162 -162
- data/lib/cyberarm_engine/ui/elements/toggle_button.rb +65 -65
- data/lib/cyberarm_engine/ui/event.rb +54 -54
- data/lib/cyberarm_engine/ui/gui_state.rb +256 -256
- data/lib/cyberarm_engine/ui/style.rb +49 -49
- data/lib/cyberarm_engine/ui/theme.rb +207 -207
- data/lib/cyberarm_engine/vector.rb +293 -293
- data/lib/cyberarm_engine/version.rb +4 -4
- data/lib/cyberarm_engine/window.rb +120 -120
- data/lib/cyberarm_engine.rb +71 -71
- metadata +3 -3
@@ -1,97 +1,97 @@
|
|
1
|
-
module CyberarmEngine
|
2
|
-
class Element
|
3
|
-
class Button < TextBlock
|
4
|
-
def initialize(text_or_image, options = {}, block = nil)
|
5
|
-
@image = nil
|
6
|
-
@scale_x = 1
|
7
|
-
@scale_y = 1
|
8
|
-
|
9
|
-
@image = text_or_image if text_or_image.is_a?(Gosu::Image)
|
10
|
-
|
11
|
-
super(text_or_image, options, block)
|
12
|
-
|
13
|
-
@style.background_canvas.background = @style.background
|
14
|
-
end
|
15
|
-
|
16
|
-
def render
|
17
|
-
if @image
|
18
|
-
draw_image
|
19
|
-
else
|
20
|
-
draw_text
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def draw_image
|
25
|
-
@image.draw(
|
26
|
-
@style.border_thickness_left + @style.padding_left + @x,
|
27
|
-
@style.border_thickness_top + @style.padding_top + @y,
|
28
|
-
@z + 2,
|
29
|
-
@scale_x, @scale_y, @text.color
|
30
|
-
)
|
31
|
-
end
|
32
|
-
|
33
|
-
def draw_text
|
34
|
-
@text.draw
|
35
|
-
end
|
36
|
-
|
37
|
-
def recalculate
|
38
|
-
unless @enabled
|
39
|
-
@style.background_canvas.background = @style.disabled[:background]
|
40
|
-
@text.color = @style.disabled[:color]
|
41
|
-
else
|
42
|
-
@style.background_canvas.background = @style.background
|
43
|
-
@text.color = @style.color
|
44
|
-
end
|
45
|
-
|
46
|
-
if @image
|
47
|
-
@width = 0
|
48
|
-
@height = 0
|
49
|
-
|
50
|
-
_width = dimensional_size(@style.image_width, :width)
|
51
|
-
_height = dimensional_size(@style.image_height, :height)
|
52
|
-
|
53
|
-
if _width && _height
|
54
|
-
@scale_x = _width.to_f / @image.width
|
55
|
-
@scale_y = _height.to_f / @image.height
|
56
|
-
elsif _width
|
57
|
-
@scale_x = _width.to_f / @image.width
|
58
|
-
@scale_y = @scale_x
|
59
|
-
elsif _height
|
60
|
-
@scale_y = _height.to_f / @image.height
|
61
|
-
@scale_x = @scale_y
|
62
|
-
else
|
63
|
-
@scale_x = 1
|
64
|
-
@scale_y = 1
|
65
|
-
end
|
66
|
-
|
67
|
-
@width = _width || @image.width.round * @scale_x
|
68
|
-
@height = _height || @image.height.round * @scale_y
|
69
|
-
|
70
|
-
update_background
|
71
|
-
else
|
72
|
-
super
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def value
|
77
|
-
@image || super
|
78
|
-
end
|
79
|
-
|
80
|
-
def value=(value)
|
81
|
-
if value.is_a?(Gosu::Image)
|
82
|
-
@image = value
|
83
|
-
else
|
84
|
-
super
|
85
|
-
end
|
86
|
-
|
87
|
-
old_width = width
|
88
|
-
old_height = height
|
89
|
-
recalculate
|
90
|
-
|
91
|
-
root.gui_state.request_recalculate if old_width != width || old_height != height
|
92
|
-
|
93
|
-
publish(:changed, self.value)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
1
|
+
module CyberarmEngine
|
2
|
+
class Element
|
3
|
+
class Button < TextBlock
|
4
|
+
def initialize(text_or_image, options = {}, block = nil)
|
5
|
+
@image = nil
|
6
|
+
@scale_x = 1
|
7
|
+
@scale_y = 1
|
8
|
+
|
9
|
+
@image = text_or_image if text_or_image.is_a?(Gosu::Image)
|
10
|
+
|
11
|
+
super(text_or_image, options, block)
|
12
|
+
|
13
|
+
@style.background_canvas.background = @style.background
|
14
|
+
end
|
15
|
+
|
16
|
+
def render
|
17
|
+
if @image
|
18
|
+
draw_image
|
19
|
+
else
|
20
|
+
draw_text
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def draw_image
|
25
|
+
@image.draw(
|
26
|
+
@style.border_thickness_left + @style.padding_left + @x,
|
27
|
+
@style.border_thickness_top + @style.padding_top + @y,
|
28
|
+
@z + 2,
|
29
|
+
@scale_x, @scale_y, @text.color
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def draw_text
|
34
|
+
@text.draw
|
35
|
+
end
|
36
|
+
|
37
|
+
def recalculate
|
38
|
+
unless @enabled
|
39
|
+
@style.background_canvas.background = @style.disabled[:background]
|
40
|
+
@text.color = @style.disabled[:color]
|
41
|
+
else
|
42
|
+
@style.background_canvas.background = @style.background
|
43
|
+
@text.color = @style.color
|
44
|
+
end
|
45
|
+
|
46
|
+
if @image
|
47
|
+
@width = 0
|
48
|
+
@height = 0
|
49
|
+
|
50
|
+
_width = dimensional_size(@style.image_width, :width)
|
51
|
+
_height = dimensional_size(@style.image_height, :height)
|
52
|
+
|
53
|
+
if _width && _height
|
54
|
+
@scale_x = _width.to_f / @image.width
|
55
|
+
@scale_y = _height.to_f / @image.height
|
56
|
+
elsif _width
|
57
|
+
@scale_x = _width.to_f / @image.width
|
58
|
+
@scale_y = @scale_x
|
59
|
+
elsif _height
|
60
|
+
@scale_y = _height.to_f / @image.height
|
61
|
+
@scale_x = @scale_y
|
62
|
+
else
|
63
|
+
@scale_x = 1
|
64
|
+
@scale_y = 1
|
65
|
+
end
|
66
|
+
|
67
|
+
@width = _width || @image.width.round * @scale_x
|
68
|
+
@height = _height || @image.height.round * @scale_y
|
69
|
+
|
70
|
+
update_background
|
71
|
+
else
|
72
|
+
super
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def value
|
77
|
+
@image || super
|
78
|
+
end
|
79
|
+
|
80
|
+
def value=(value)
|
81
|
+
if value.is_a?(Gosu::Image)
|
82
|
+
@image = value
|
83
|
+
else
|
84
|
+
super
|
85
|
+
end
|
86
|
+
|
87
|
+
old_width = width
|
88
|
+
old_height = height
|
89
|
+
recalculate
|
90
|
+
|
91
|
+
root.gui_state.request_recalculate if old_width != width || old_height != height
|
92
|
+
|
93
|
+
publish(:changed, self.value)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -1,54 +1,54 @@
|
|
1
|
-
module CyberarmEngine
|
2
|
-
class Element
|
3
|
-
class CheckBox < Flow
|
4
|
-
def initialize(text, options, block = nil)
|
5
|
-
super(options, block)
|
6
|
-
options[:toggled] = options[:checked]
|
7
|
-
|
8
|
-
options[:parent] = self
|
9
|
-
@toggle_button = ToggleButton.new(options)
|
10
|
-
|
11
|
-
options[:parent] = self
|
12
|
-
@label = TextBlock.new(text, options)
|
13
|
-
|
14
|
-
@label.subscribe(:holding_left_mouse_button) do |sender, x, y|
|
15
|
-
@toggle_button.left_mouse_button(sender, x, y)
|
16
|
-
end
|
17
|
-
|
18
|
-
@label.subscribe(:released_left_mouse_button) do |sender, x, y|
|
19
|
-
@toggle_button.released_left_mouse_button(sender, x, y)
|
20
|
-
end
|
21
|
-
|
22
|
-
@label.subscribe(:clicked_left_mouse_button) do |sender, x, y|
|
23
|
-
@toggle_button.clicked_left_mouse_button(sender, x, y)
|
24
|
-
publish(:changed, @toggle_button.value)
|
25
|
-
end
|
26
|
-
|
27
|
-
@label.subscribe(:enter) do |sender|
|
28
|
-
@toggle_button.enter(sender)
|
29
|
-
end
|
30
|
-
|
31
|
-
@label.subscribe(:leave) do |sender|
|
32
|
-
@toggle_button.leave(sender)
|
33
|
-
end
|
34
|
-
|
35
|
-
add(@toggle_button)
|
36
|
-
add(@label)
|
37
|
-
end
|
38
|
-
|
39
|
-
def text=(text)
|
40
|
-
@label.text = text
|
41
|
-
recalculate
|
42
|
-
end
|
43
|
-
|
44
|
-
def value
|
45
|
-
@toggle_button.value
|
46
|
-
end
|
47
|
-
|
48
|
-
def value=(bool)
|
49
|
-
@toggle_button.value = bool
|
50
|
-
publish(:changed, @toggle_button.value)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
1
|
+
module CyberarmEngine
|
2
|
+
class Element
|
3
|
+
class CheckBox < Flow
|
4
|
+
def initialize(text, options, block = nil)
|
5
|
+
super(options, block)
|
6
|
+
options[:toggled] = options[:checked]
|
7
|
+
|
8
|
+
options[:parent] = self
|
9
|
+
@toggle_button = ToggleButton.new(options)
|
10
|
+
|
11
|
+
options[:parent] = self
|
12
|
+
@label = TextBlock.new(text, options)
|
13
|
+
|
14
|
+
@label.subscribe(:holding_left_mouse_button) do |sender, x, y|
|
15
|
+
@toggle_button.left_mouse_button(sender, x, y)
|
16
|
+
end
|
17
|
+
|
18
|
+
@label.subscribe(:released_left_mouse_button) do |sender, x, y|
|
19
|
+
@toggle_button.released_left_mouse_button(sender, x, y)
|
20
|
+
end
|
21
|
+
|
22
|
+
@label.subscribe(:clicked_left_mouse_button) do |sender, x, y|
|
23
|
+
@toggle_button.clicked_left_mouse_button(sender, x, y)
|
24
|
+
publish(:changed, @toggle_button.value)
|
25
|
+
end
|
26
|
+
|
27
|
+
@label.subscribe(:enter) do |sender|
|
28
|
+
@toggle_button.enter(sender)
|
29
|
+
end
|
30
|
+
|
31
|
+
@label.subscribe(:leave) do |sender|
|
32
|
+
@toggle_button.leave(sender)
|
33
|
+
end
|
34
|
+
|
35
|
+
add(@toggle_button)
|
36
|
+
add(@label)
|
37
|
+
end
|
38
|
+
|
39
|
+
def text=(text)
|
40
|
+
@label.text = text
|
41
|
+
recalculate
|
42
|
+
end
|
43
|
+
|
44
|
+
def value
|
45
|
+
@toggle_button.value
|
46
|
+
end
|
47
|
+
|
48
|
+
def value=(bool)
|
49
|
+
@toggle_button.value = bool
|
50
|
+
publish(:changed, @toggle_button.value)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|