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,102 +1,102 @@
|
|
1
|
-
module CyberarmEngine
|
2
|
-
class BorderCanvas
|
3
|
-
attr_reader :element, :top, :right, :bottom, :left
|
4
|
-
|
5
|
-
def initialize(element:)
|
6
|
-
@element = element
|
7
|
-
|
8
|
-
@top = Background.new
|
9
|
-
@right = Background.new
|
10
|
-
@bottom = Background.new
|
11
|
-
@left = Background.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def color=(color)
|
15
|
-
if color.is_a?(Numeric)
|
16
|
-
@top.background = color
|
17
|
-
@right.background = color
|
18
|
-
@bottom.background = color
|
19
|
-
@left.background = color
|
20
|
-
|
21
|
-
elsif color.is_a?(Gosu::Color)
|
22
|
-
@top.background = color
|
23
|
-
@right.background = color
|
24
|
-
@bottom.background = color
|
25
|
-
@left.background = color
|
26
|
-
|
27
|
-
elsif color.is_a?(Array)
|
28
|
-
if color.size == 1
|
29
|
-
color = color.first
|
30
|
-
|
31
|
-
elsif color.size == 2
|
32
|
-
@top.background = color.first
|
33
|
-
@right.background = color.first
|
34
|
-
@bottom.background = color.last
|
35
|
-
@left.background = color.last
|
36
|
-
|
37
|
-
elsif color.size == 4
|
38
|
-
@top.background = color[0]
|
39
|
-
@right.background = color[1]
|
40
|
-
@bottom.background = color[2]
|
41
|
-
@left.background = color[3]
|
42
|
-
else
|
43
|
-
raise ArgumentError, "color array was empty or had wrong number of elements (expected 2 or 4 elements)"
|
44
|
-
end
|
45
|
-
|
46
|
-
elsif color.is_a?(Hash)
|
47
|
-
@top.background = color[:top]
|
48
|
-
@right.background = color[:right]
|
49
|
-
@bottom.background = color[:bottom]
|
50
|
-
@left.background = color[:left]
|
51
|
-
else
|
52
|
-
raise ArgumentError, "color '#{color}' of type '#{color.class}' was not able to be processed"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def draw
|
57
|
-
@top.draw
|
58
|
-
@right.draw
|
59
|
-
@bottom.draw
|
60
|
-
@left.draw
|
61
|
-
end
|
62
|
-
|
63
|
-
def update
|
64
|
-
# TOP
|
65
|
-
@top.x = @element.x # + @element.border_thickness_left
|
66
|
-
@top.y = @element.y
|
67
|
-
@top.z = @element.z
|
68
|
-
|
69
|
-
@top.width = @element.width
|
70
|
-
@top.height = @element.style.border_thickness_top
|
71
|
-
|
72
|
-
# RIGHT
|
73
|
-
@right.x = @element.x + @element.width
|
74
|
-
@right.y = @element.y + @element.style.border_thickness_top
|
75
|
-
@right.z = @element.z
|
76
|
-
|
77
|
-
@right.width = -@element.style.border_thickness_right
|
78
|
-
@right.height = @element.height - @element.style.border_thickness_top
|
79
|
-
|
80
|
-
# BOTTOM
|
81
|
-
@bottom.x = @element.x
|
82
|
-
@bottom.y = @element.y + @element.height
|
83
|
-
@bottom.z = @element.z
|
84
|
-
|
85
|
-
@bottom.width = @element.width - @element.style.border_thickness_right
|
86
|
-
@bottom.height = -@element.style.border_thickness_bottom
|
87
|
-
|
88
|
-
# LEFT
|
89
|
-
@left.x = @element.x
|
90
|
-
@left.y = @element.y
|
91
|
-
@left.z = @element.z
|
92
|
-
|
93
|
-
@left.width = @element.style.border_thickness_left
|
94
|
-
@left.height = @element.height - @element.style.border_thickness_bottom
|
95
|
-
|
96
|
-
@top.update
|
97
|
-
@right.update
|
98
|
-
@bottom.update
|
99
|
-
@left.update
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
1
|
+
module CyberarmEngine
|
2
|
+
class BorderCanvas
|
3
|
+
attr_reader :element, :top, :right, :bottom, :left
|
4
|
+
|
5
|
+
def initialize(element:)
|
6
|
+
@element = element
|
7
|
+
|
8
|
+
@top = Background.new
|
9
|
+
@right = Background.new
|
10
|
+
@bottom = Background.new
|
11
|
+
@left = Background.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def color=(color)
|
15
|
+
if color.is_a?(Numeric)
|
16
|
+
@top.background = color
|
17
|
+
@right.background = color
|
18
|
+
@bottom.background = color
|
19
|
+
@left.background = color
|
20
|
+
|
21
|
+
elsif color.is_a?(Gosu::Color)
|
22
|
+
@top.background = color
|
23
|
+
@right.background = color
|
24
|
+
@bottom.background = color
|
25
|
+
@left.background = color
|
26
|
+
|
27
|
+
elsif color.is_a?(Array)
|
28
|
+
if color.size == 1
|
29
|
+
color = color.first
|
30
|
+
|
31
|
+
elsif color.size == 2
|
32
|
+
@top.background = color.first
|
33
|
+
@right.background = color.first
|
34
|
+
@bottom.background = color.last
|
35
|
+
@left.background = color.last
|
36
|
+
|
37
|
+
elsif color.size == 4
|
38
|
+
@top.background = color[0]
|
39
|
+
@right.background = color[1]
|
40
|
+
@bottom.background = color[2]
|
41
|
+
@left.background = color[3]
|
42
|
+
else
|
43
|
+
raise ArgumentError, "color array was empty or had wrong number of elements (expected 2 or 4 elements)"
|
44
|
+
end
|
45
|
+
|
46
|
+
elsif color.is_a?(Hash)
|
47
|
+
@top.background = color[:top]
|
48
|
+
@right.background = color[:right]
|
49
|
+
@bottom.background = color[:bottom]
|
50
|
+
@left.background = color[:left]
|
51
|
+
else
|
52
|
+
raise ArgumentError, "color '#{color}' of type '#{color.class}' was not able to be processed"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def draw
|
57
|
+
@top.draw
|
58
|
+
@right.draw
|
59
|
+
@bottom.draw
|
60
|
+
@left.draw
|
61
|
+
end
|
62
|
+
|
63
|
+
def update
|
64
|
+
# TOP
|
65
|
+
@top.x = @element.x # + @element.border_thickness_left
|
66
|
+
@top.y = @element.y
|
67
|
+
@top.z = @element.z
|
68
|
+
|
69
|
+
@top.width = @element.width
|
70
|
+
@top.height = @element.style.border_thickness_top
|
71
|
+
|
72
|
+
# RIGHT
|
73
|
+
@right.x = @element.x + @element.width
|
74
|
+
@right.y = @element.y + @element.style.border_thickness_top
|
75
|
+
@right.z = @element.z
|
76
|
+
|
77
|
+
@right.width = -@element.style.border_thickness_right
|
78
|
+
@right.height = @element.height - @element.style.border_thickness_top
|
79
|
+
|
80
|
+
# BOTTOM
|
81
|
+
@bottom.x = @element.x
|
82
|
+
@bottom.y = @element.y + @element.height
|
83
|
+
@bottom.z = @element.z
|
84
|
+
|
85
|
+
@bottom.width = @element.width - @element.style.border_thickness_right
|
86
|
+
@bottom.height = -@element.style.border_thickness_bottom
|
87
|
+
|
88
|
+
# LEFT
|
89
|
+
@left.x = @element.x
|
90
|
+
@left.y = @element.y
|
91
|
+
@left.z = @element.z
|
92
|
+
|
93
|
+
@left.width = @element.style.border_thickness_left
|
94
|
+
@left.height = @element.height - @element.style.border_thickness_bottom
|
95
|
+
|
96
|
+
@top.update
|
97
|
+
@right.update
|
98
|
+
@bottom.update
|
99
|
+
@left.update
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -1,139 +1,139 @@
|
|
1
|
-
module CyberarmEngine
|
2
|
-
module DSL
|
3
|
-
def flow(options = {}, &block)
|
4
|
-
container(CyberarmEngine::Element::Flow, options, &block)
|
5
|
-
end
|
6
|
-
|
7
|
-
def stack(options = {}, &block)
|
8
|
-
container(CyberarmEngine::Element::Stack, options, &block)
|
9
|
-
end
|
10
|
-
|
11
|
-
# TODO: Remove in version 0.16.0+
|
12
|
-
def label(text, options = {}, &block)
|
13
|
-
options[:parent] = element_parent
|
14
|
-
options[:theme] = current_theme
|
15
|
-
|
16
|
-
add_element(Element::TextBlock.new(text, options, block))
|
17
|
-
end
|
18
|
-
|
19
|
-
[
|
20
|
-
"Banner",
|
21
|
-
"Title",
|
22
|
-
"Subtitle",
|
23
|
-
"Tagline",
|
24
|
-
"Caption",
|
25
|
-
"Para",
|
26
|
-
"Inscription",
|
27
|
-
"Link"
|
28
|
-
].each do |const|
|
29
|
-
define_method(:"#{const.downcase}") do |text, options = {}, &block|
|
30
|
-
options[:parent] = element_parent
|
31
|
-
options[:theme] = current_theme
|
32
|
-
|
33
|
-
add_element(Element.const_get(const).new(text, options, block))
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def button(text, options = {}, &block)
|
38
|
-
options[:parent] = element_parent
|
39
|
-
options[:theme] = current_theme
|
40
|
-
|
41
|
-
add_element(Element::Button.new(text, options, block) { block.call if block.is_a?(Proc) })
|
42
|
-
end
|
43
|
-
|
44
|
-
def list_box(options = {}, &block)
|
45
|
-
options[:parent] = element_parent
|
46
|
-
options[:theme] = current_theme
|
47
|
-
|
48
|
-
add_element(Element::ListBox.new(options, block) { block.call if block.is_a?(Proc) })
|
49
|
-
end
|
50
|
-
|
51
|
-
def edit_line(text, options = {}, &block)
|
52
|
-
options[:parent] = element_parent
|
53
|
-
options[:theme] = current_theme
|
54
|
-
|
55
|
-
add_element(Element::EditLine.new(text, options, block))
|
56
|
-
end
|
57
|
-
|
58
|
-
def edit_box(text, options = {}, &block)
|
59
|
-
options[:parent] = element_parent
|
60
|
-
options[:theme] = current_theme
|
61
|
-
|
62
|
-
add_element(Element::EditBox.new(text, options, block))
|
63
|
-
end
|
64
|
-
|
65
|
-
def toggle_button(options = {}, &block)
|
66
|
-
options[:parent] = element_parent
|
67
|
-
options[:theme] = current_theme
|
68
|
-
|
69
|
-
add_element(Element::ToggleButton.new(options, block))
|
70
|
-
end
|
71
|
-
|
72
|
-
def check_box(text, options = {}, &block)
|
73
|
-
options[:parent] = element_parent
|
74
|
-
options[:theme] = current_theme
|
75
|
-
|
76
|
-
add_element(Element::CheckBox.new(text, options, block))
|
77
|
-
end
|
78
|
-
|
79
|
-
def image(path, options = {}, &block)
|
80
|
-
options[:parent] = element_parent
|
81
|
-
options[:theme] = current_theme
|
82
|
-
|
83
|
-
add_element(Element::Image.new(path, options, block))
|
84
|
-
end
|
85
|
-
|
86
|
-
def progress(options = {}, &block)
|
87
|
-
options[:parent] = element_parent
|
88
|
-
options[:theme] = current_theme
|
89
|
-
|
90
|
-
add_element(Element::Progress.new(options, block))
|
91
|
-
end
|
92
|
-
|
93
|
-
def slider(options = {}, &block)
|
94
|
-
options[:parent] = element_parent
|
95
|
-
options[:theme] = current_theme
|
96
|
-
|
97
|
-
add_element(Element::Slider.new(options, block))
|
98
|
-
end
|
99
|
-
|
100
|
-
def background(color = Gosu::Color::NONE)
|
101
|
-
element_parent.style.default[:background] = color
|
102
|
-
end
|
103
|
-
|
104
|
-
def theme(theme)
|
105
|
-
element_parent.options[:theme] = theme
|
106
|
-
end
|
107
|
-
|
108
|
-
def current_theme
|
109
|
-
element_parent.options[:theme]
|
110
|
-
end
|
111
|
-
|
112
|
-
private def add_element(element)
|
113
|
-
element_parent.add(element)
|
114
|
-
|
115
|
-
element
|
116
|
-
end
|
117
|
-
|
118
|
-
private def element_parent
|
119
|
-
$__current_container__
|
120
|
-
end
|
121
|
-
|
122
|
-
private def container(klass, options = {}, &block)
|
123
|
-
options[:parent] = element_parent
|
124
|
-
options[:theme] = current_theme
|
125
|
-
|
126
|
-
_container = klass.new(options, block)
|
127
|
-
|
128
|
-
old_parent = element_parent
|
129
|
-
$__current_container__ = _container
|
130
|
-
|
131
|
-
_container.build
|
132
|
-
_container.parent.add(_container)
|
133
|
-
|
134
|
-
$__current_container__ = old_parent
|
135
|
-
|
136
|
-
_container
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
1
|
+
module CyberarmEngine
|
2
|
+
module DSL
|
3
|
+
def flow(options = {}, &block)
|
4
|
+
container(CyberarmEngine::Element::Flow, options, &block)
|
5
|
+
end
|
6
|
+
|
7
|
+
def stack(options = {}, &block)
|
8
|
+
container(CyberarmEngine::Element::Stack, options, &block)
|
9
|
+
end
|
10
|
+
|
11
|
+
# TODO: Remove in version 0.16.0+
|
12
|
+
def label(text, options = {}, &block)
|
13
|
+
options[:parent] = element_parent
|
14
|
+
options[:theme] = current_theme
|
15
|
+
|
16
|
+
add_element(Element::TextBlock.new(text, options, block))
|
17
|
+
end
|
18
|
+
|
19
|
+
[
|
20
|
+
"Banner",
|
21
|
+
"Title",
|
22
|
+
"Subtitle",
|
23
|
+
"Tagline",
|
24
|
+
"Caption",
|
25
|
+
"Para",
|
26
|
+
"Inscription",
|
27
|
+
"Link"
|
28
|
+
].each do |const|
|
29
|
+
define_method(:"#{const.downcase}") do |text, options = {}, &block|
|
30
|
+
options[:parent] = element_parent
|
31
|
+
options[:theme] = current_theme
|
32
|
+
|
33
|
+
add_element(Element.const_get(const).new(text, options, block))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def button(text, options = {}, &block)
|
38
|
+
options[:parent] = element_parent
|
39
|
+
options[:theme] = current_theme
|
40
|
+
|
41
|
+
add_element(Element::Button.new(text, options, block) { block.call if block.is_a?(Proc) })
|
42
|
+
end
|
43
|
+
|
44
|
+
def list_box(options = {}, &block)
|
45
|
+
options[:parent] = element_parent
|
46
|
+
options[:theme] = current_theme
|
47
|
+
|
48
|
+
add_element(Element::ListBox.new(options, block) { block.call if block.is_a?(Proc) })
|
49
|
+
end
|
50
|
+
|
51
|
+
def edit_line(text, options = {}, &block)
|
52
|
+
options[:parent] = element_parent
|
53
|
+
options[:theme] = current_theme
|
54
|
+
|
55
|
+
add_element(Element::EditLine.new(text, options, block))
|
56
|
+
end
|
57
|
+
|
58
|
+
def edit_box(text, options = {}, &block)
|
59
|
+
options[:parent] = element_parent
|
60
|
+
options[:theme] = current_theme
|
61
|
+
|
62
|
+
add_element(Element::EditBox.new(text, options, block))
|
63
|
+
end
|
64
|
+
|
65
|
+
def toggle_button(options = {}, &block)
|
66
|
+
options[:parent] = element_parent
|
67
|
+
options[:theme] = current_theme
|
68
|
+
|
69
|
+
add_element(Element::ToggleButton.new(options, block))
|
70
|
+
end
|
71
|
+
|
72
|
+
def check_box(text, options = {}, &block)
|
73
|
+
options[:parent] = element_parent
|
74
|
+
options[:theme] = current_theme
|
75
|
+
|
76
|
+
add_element(Element::CheckBox.new(text, options, block))
|
77
|
+
end
|
78
|
+
|
79
|
+
def image(path, options = {}, &block)
|
80
|
+
options[:parent] = element_parent
|
81
|
+
options[:theme] = current_theme
|
82
|
+
|
83
|
+
add_element(Element::Image.new(path, options, block))
|
84
|
+
end
|
85
|
+
|
86
|
+
def progress(options = {}, &block)
|
87
|
+
options[:parent] = element_parent
|
88
|
+
options[:theme] = current_theme
|
89
|
+
|
90
|
+
add_element(Element::Progress.new(options, block))
|
91
|
+
end
|
92
|
+
|
93
|
+
def slider(options = {}, &block)
|
94
|
+
options[:parent] = element_parent
|
95
|
+
options[:theme] = current_theme
|
96
|
+
|
97
|
+
add_element(Element::Slider.new(options, block))
|
98
|
+
end
|
99
|
+
|
100
|
+
def background(color = Gosu::Color::NONE)
|
101
|
+
element_parent.style.default[:background] = color
|
102
|
+
end
|
103
|
+
|
104
|
+
def theme(theme)
|
105
|
+
element_parent.options[:theme] = theme
|
106
|
+
end
|
107
|
+
|
108
|
+
def current_theme
|
109
|
+
element_parent.options[:theme]
|
110
|
+
end
|
111
|
+
|
112
|
+
private def add_element(element)
|
113
|
+
element_parent.add(element)
|
114
|
+
|
115
|
+
element
|
116
|
+
end
|
117
|
+
|
118
|
+
private def element_parent
|
119
|
+
$__current_container__
|
120
|
+
end
|
121
|
+
|
122
|
+
private def container(klass, options = {}, &block)
|
123
|
+
options[:parent] = element_parent
|
124
|
+
options[:theme] = current_theme
|
125
|
+
|
126
|
+
_container = klass.new(options, block)
|
127
|
+
|
128
|
+
old_parent = element_parent
|
129
|
+
$__current_container__ = _container
|
130
|
+
|
131
|
+
_container.build
|
132
|
+
_container.parent.add(_container)
|
133
|
+
|
134
|
+
$__current_container__ = old_parent
|
135
|
+
|
136
|
+
_container
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|