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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +8 -8
  3. data/.rubocop.yml +7 -7
  4. data/.travis.yml +5 -5
  5. data/Gemfile +6 -6
  6. data/LICENSE.txt +21 -21
  7. data/README.md +74 -74
  8. data/Rakefile +10 -10
  9. data/bin/console +14 -14
  10. data/bin/setup +8 -8
  11. data/cyberarm_engine.gemspec +39 -39
  12. data/lib/cyberarm_engine/animator.rb +219 -219
  13. data/lib/cyberarm_engine/background.rb +179 -179
  14. data/lib/cyberarm_engine/background_nine_slice.rb +142 -142
  15. data/lib/cyberarm_engine/bounding_box.rb +150 -150
  16. data/lib/cyberarm_engine/builtin/intro_state.rb +130 -130
  17. data/lib/cyberarm_engine/cache/download_manager.rb +121 -121
  18. data/lib/cyberarm_engine/cache.rb +4 -4
  19. data/lib/cyberarm_engine/common.rb +113 -113
  20. data/lib/cyberarm_engine/config_file.rb +46 -46
  21. data/lib/cyberarm_engine/console/command.rb +157 -157
  22. data/lib/cyberarm_engine/console/commands/help_command.rb +43 -43
  23. data/lib/cyberarm_engine/console/subcommand.rb +99 -99
  24. data/lib/cyberarm_engine/console.rb +248 -248
  25. data/lib/cyberarm_engine/game_object.rb +248 -248
  26. data/lib/cyberarm_engine/game_state.rb +97 -97
  27. data/lib/cyberarm_engine/model/material.rb +21 -21
  28. data/lib/cyberarm_engine/model/model_object.rb +131 -131
  29. data/lib/cyberarm_engine/model/parser.rb +74 -74
  30. data/lib/cyberarm_engine/model/parsers/collada_parser.rb +138 -138
  31. data/lib/cyberarm_engine/model/parsers/wavefront_parser.rb +154 -154
  32. data/lib/cyberarm_engine/model.rb +212 -212
  33. data/lib/cyberarm_engine/model_cache.rb +31 -31
  34. data/lib/cyberarm_engine/opengl/light.rb +50 -50
  35. data/lib/cyberarm_engine/opengl/orthographic_camera.rb +46 -46
  36. data/lib/cyberarm_engine/opengl/perspective_camera.rb +38 -38
  37. data/lib/cyberarm_engine/opengl/renderer/bounding_box_renderer.rb +249 -249
  38. data/lib/cyberarm_engine/opengl/renderer/g_buffer.rb +164 -164
  39. data/lib/cyberarm_engine/opengl/renderer/opengl_renderer.rb +298 -298
  40. data/lib/cyberarm_engine/opengl/renderer/renderer.rb +22 -22
  41. data/lib/cyberarm_engine/opengl/shader.rb +406 -406
  42. data/lib/cyberarm_engine/opengl/texture.rb +69 -69
  43. data/lib/cyberarm_engine/opengl.rb +28 -28
  44. data/lib/cyberarm_engine/ray.rb +56 -56
  45. data/lib/cyberarm_engine/stats.rb +21 -21
  46. data/lib/cyberarm_engine/text.rb +197 -197
  47. data/lib/cyberarm_engine/timer.rb +23 -23
  48. data/lib/cyberarm_engine/transform.rb +296 -296
  49. data/lib/cyberarm_engine/ui/border_canvas.rb +102 -102
  50. data/lib/cyberarm_engine/ui/dsl.rb +139 -139
  51. data/lib/cyberarm_engine/ui/element.rb +488 -488
  52. data/lib/cyberarm_engine/ui/elements/button.rb +97 -97
  53. data/lib/cyberarm_engine/ui/elements/check_box.rb +54 -54
  54. data/lib/cyberarm_engine/ui/elements/container.rb +256 -256
  55. data/lib/cyberarm_engine/ui/elements/edit_box.rb +179 -179
  56. data/lib/cyberarm_engine/ui/elements/edit_line.rb +263 -263
  57. data/lib/cyberarm_engine/ui/elements/flow.rb +15 -15
  58. data/lib/cyberarm_engine/ui/elements/image.rb +72 -72
  59. data/lib/cyberarm_engine/ui/elements/list_box.rb +88 -82
  60. data/lib/cyberarm_engine/ui/elements/progress.rb +51 -51
  61. data/lib/cyberarm_engine/ui/elements/radio.rb +6 -6
  62. data/lib/cyberarm_engine/ui/elements/slider.rb +104 -104
  63. data/lib/cyberarm_engine/ui/elements/stack.rb +11 -11
  64. data/lib/cyberarm_engine/ui/elements/text_block.rb +162 -162
  65. data/lib/cyberarm_engine/ui/elements/toggle_button.rb +65 -65
  66. data/lib/cyberarm_engine/ui/event.rb +54 -54
  67. data/lib/cyberarm_engine/ui/gui_state.rb +256 -256
  68. data/lib/cyberarm_engine/ui/style.rb +49 -49
  69. data/lib/cyberarm_engine/ui/theme.rb +207 -207
  70. data/lib/cyberarm_engine/vector.rb +293 -293
  71. data/lib/cyberarm_engine/version.rb +4 -4
  72. data/lib/cyberarm_engine/window.rb +120 -120
  73. data/lib/cyberarm_engine.rb +71 -71
  74. metadata +3 -3
@@ -1,207 +1,207 @@
1
- module CyberarmEngine
2
- module Theme
3
- def default(*args)
4
- value = @options
5
- args.each do |arg|
6
- value = value.dig(arg)
7
- end
8
-
9
- value
10
- end
11
-
12
- def theme_defaults(options)
13
- raise "Error" unless self.class.ancestors.include?(CyberarmEngine::Element)
14
-
15
- _theme = THEME
16
- _theme = deep_merge(_theme, options[:theme]) if options[:theme]
17
- _theme.delete(:theme) if options[:theme]
18
-
19
- hash = {}
20
- class_names = self.class.ancestors
21
- class_names = class_names[0..class_names.index(CyberarmEngine::Element)].map! do |c|
22
- c.to_s.split("::").last.to_sym
23
- end.reverse!
24
-
25
- class_names.each do |klass|
26
- next unless data = _theme.dig(klass)
27
-
28
- data.each do |_key, _value|
29
- hash.merge!(data)
30
- end
31
- end
32
-
33
- deep_merge(hash, options)
34
- end
35
-
36
- # Derived from Rails Hash#deep_merge!
37
- # Enables passing partial themes through Element options without issue
38
- def deep_merge(original, intergrate, &block)
39
- original.merge(intergrate) do |key, this_val, other_val|
40
- if this_val.is_a?(Hash) && other_val.is_a?(Hash)
41
- deep_merge(this_val, other_val, &block)
42
- elsif block_given?
43
- block.call(key, this_val, other_val)
44
- else
45
- other_val
46
- end
47
- end
48
- end
49
-
50
- THEME = {
51
- Element: {
52
- x: 0,
53
- y: 0,
54
- z: 30,
55
-
56
- width: nil,
57
- height: nil,
58
- color: Gosu::Color::WHITE,
59
- background: Gosu::Color::NONE,
60
- margin: 0,
61
- padding: 0,
62
- border_thickness: 0,
63
- border_color: Gosu::Color::NONE,
64
- border_radius: 0
65
- },
66
-
67
- Container: { # < Element (Base class for Stack and Flow)
68
- debug_color: Gosu::Color::YELLOW
69
- },
70
-
71
- Button: { # < Label
72
- margin: 1,
73
- padding: 4,
74
- border_thickness: 1,
75
- border_color: ["ffd59674".hex, "ffff8746".hex],
76
- border_radius: 0,
77
- background: ["ffc75e61".to_i(16), "ffe26623".to_i(16)],
78
- text_align: :center,
79
- text_wrap: :none,
80
-
81
- hover: {
82
- color: Gosu::Color.rgb(200, 200, 200),
83
- background: ["ffB23E41".to_i(16), "ffFF7C00".to_i(16)]
84
- },
85
-
86
- active: {
87
- color: Gosu::Color::BLACK,
88
- background: ["ffB23E41".to_i(16)]
89
- },
90
-
91
- disabled: {
92
- color: Gosu::Color::GRAY,
93
- background: 0xff303030
94
- }
95
- },
96
-
97
- EditLine: { # < Button
98
- type: :text,
99
- width: 200,
100
- password_character: "•",
101
- caret_width: 2,
102
- caret_color: Gosu::Color::WHITE,
103
- caret_interval: 500,
104
- selection_color: Gosu::Color.rgba(255, 128, 50, 200),
105
- text_align: :left
106
- },
107
-
108
- Image: { # < Element
109
- color: Gosu::Color::WHITE,
110
- tileable: false,
111
- retro: false
112
- },
113
-
114
- TextBlock: { # < Element
115
- text_size: 28,
116
- text_wrap: :word_wrap, # :word_wrap, :break_word, :none
117
- text_shadow: false,
118
- text_border: false,
119
- text_align: :left,
120
- font: "Arial",
121
- margin: 0,
122
- padding: 2,
123
- disabled: {
124
- color: Gosu::Color.rgb(175, 175, 175),
125
- }
126
- },
127
-
128
- Banner: { # < TextBlock
129
- text_size: 48
130
- },
131
-
132
- Title: { # < TextBlock
133
- text_size: 34
134
- },
135
-
136
- Subtitle: { # < TextBlock
137
- text_size: 26
138
- },
139
-
140
- Tagline: { # < TextBlock
141
- text_size: 24
142
- },
143
-
144
- Caption: { # < TextBlock
145
- text_size: 22
146
- },
147
-
148
- Para: { # < TextBlock
149
- text_size: 18
150
- },
151
-
152
- Inscription: { # < TextBlock
153
- text_size: 16
154
- },
155
-
156
- ToolTip: { # < TextBlock
157
- color: Gosu::Color::WHITE,
158
- padding_top: 4,
159
- padding_bottom: 4,
160
- padding_left: 8,
161
- padding_right: 8,
162
- border_thickness: 1,
163
- border_color: 0xffaaaaaa,
164
- background: 0xff404040
165
- },
166
- Link: { # < TextBlock
167
- color: Gosu::Color::BLUE,
168
- border_thickness: 1,
169
- border_bottom_color: Gosu::Color::BLUE,
170
- hover: {
171
- color: 0xff_ff00ff,
172
- border_bottom_color: 0xff_ff00ff
173
- },
174
- active: {
175
- color: 0xff_ff0000,
176
- border_bottom_color: 0xff_ff0000
177
- }
178
- },
179
-
180
- ToggleButton: { # < Button
181
- checkmark: "√"
182
- },
183
-
184
- CheckBox: { # < Flow
185
- text_wrap: :none
186
- },
187
-
188
- Progress: { # < Element
189
- width: 250,
190
- height: 36,
191
- background: 0xff111111,
192
- fraction_background: [0xffc75e61, 0xffe26623],
193
- border_thickness: 1,
194
- border_color: [0xffd59674, 0xffff8746]
195
- },
196
-
197
- Slider: { # < Element
198
- width: 250,
199
- height: 36,
200
- background: 0xff111111,
201
- fraction_background: [0xffc75e61, 0xffe26623],
202
- border_thickness: 1,
203
- border_color: [0xffd59674, 0xffff8746]
204
- }
205
- }.freeze
206
- end
207
- end
1
+ module CyberarmEngine
2
+ module Theme
3
+ def default(*args)
4
+ value = @options
5
+ args.each do |arg|
6
+ value = value.dig(arg)
7
+ end
8
+
9
+ value
10
+ end
11
+
12
+ def theme_defaults(options)
13
+ raise "Error" unless self.class.ancestors.include?(CyberarmEngine::Element)
14
+
15
+ _theme = THEME
16
+ _theme = deep_merge(_theme, options[:theme]) if options[:theme]
17
+ _theme.delete(:theme) if options[:theme]
18
+
19
+ hash = {}
20
+ class_names = self.class.ancestors
21
+ class_names = class_names[0..class_names.index(CyberarmEngine::Element)].map! do |c|
22
+ c.to_s.split("::").last.to_sym
23
+ end.reverse!
24
+
25
+ class_names.each do |klass|
26
+ next unless data = _theme.dig(klass)
27
+
28
+ data.each do |_key, _value|
29
+ hash.merge!(data)
30
+ end
31
+ end
32
+
33
+ deep_merge(hash, options)
34
+ end
35
+
36
+ # Derived from Rails Hash#deep_merge!
37
+ # Enables passing partial themes through Element options without issue
38
+ def deep_merge(original, intergrate, &block)
39
+ original.merge(intergrate) do |key, this_val, other_val|
40
+ if this_val.is_a?(Hash) && other_val.is_a?(Hash)
41
+ deep_merge(this_val, other_val, &block)
42
+ elsif block_given?
43
+ block.call(key, this_val, other_val)
44
+ else
45
+ other_val
46
+ end
47
+ end
48
+ end
49
+
50
+ THEME = {
51
+ Element: {
52
+ x: 0,
53
+ y: 0,
54
+ z: 30,
55
+
56
+ width: nil,
57
+ height: nil,
58
+ color: Gosu::Color::WHITE,
59
+ background: Gosu::Color::NONE,
60
+ margin: 0,
61
+ padding: 0,
62
+ border_thickness: 0,
63
+ border_color: Gosu::Color::NONE,
64
+ border_radius: 0
65
+ },
66
+
67
+ Container: { # < Element (Base class for Stack and Flow)
68
+ debug_color: Gosu::Color::YELLOW
69
+ },
70
+
71
+ Button: { # < Label
72
+ margin: 1,
73
+ padding: 4,
74
+ border_thickness: 1,
75
+ border_color: ["ffd59674".hex, "ffff8746".hex],
76
+ border_radius: 0,
77
+ background: ["ffc75e61".to_i(16), "ffe26623".to_i(16)],
78
+ text_align: :center,
79
+ text_wrap: :none,
80
+
81
+ hover: {
82
+ color: Gosu::Color.rgb(200, 200, 200),
83
+ background: ["ffB23E41".to_i(16), "ffFF7C00".to_i(16)]
84
+ },
85
+
86
+ active: {
87
+ color: Gosu::Color::BLACK,
88
+ background: ["ffB23E41".to_i(16)]
89
+ },
90
+
91
+ disabled: {
92
+ color: Gosu::Color::GRAY,
93
+ background: 0xff303030
94
+ }
95
+ },
96
+
97
+ EditLine: { # < Button
98
+ type: :text,
99
+ width: 200,
100
+ password_character: "•",
101
+ caret_width: 2,
102
+ caret_color: Gosu::Color::WHITE,
103
+ caret_interval: 500,
104
+ selection_color: Gosu::Color.rgba(255, 128, 50, 200),
105
+ text_align: :left
106
+ },
107
+
108
+ Image: { # < Element
109
+ color: Gosu::Color::WHITE,
110
+ tileable: false,
111
+ retro: false
112
+ },
113
+
114
+ TextBlock: { # < Element
115
+ text_size: 28,
116
+ text_wrap: :word_wrap, # :word_wrap, :break_word, :none
117
+ text_shadow: false,
118
+ text_border: false,
119
+ text_align: :left,
120
+ font: "Arial",
121
+ margin: 0,
122
+ padding: 2,
123
+ disabled: {
124
+ color: Gosu::Color.rgb(175, 175, 175),
125
+ }
126
+ },
127
+
128
+ Banner: { # < TextBlock
129
+ text_size: 48
130
+ },
131
+
132
+ Title: { # < TextBlock
133
+ text_size: 34
134
+ },
135
+
136
+ Subtitle: { # < TextBlock
137
+ text_size: 26
138
+ },
139
+
140
+ Tagline: { # < TextBlock
141
+ text_size: 24
142
+ },
143
+
144
+ Caption: { # < TextBlock
145
+ text_size: 22
146
+ },
147
+
148
+ Para: { # < TextBlock
149
+ text_size: 18
150
+ },
151
+
152
+ Inscription: { # < TextBlock
153
+ text_size: 16
154
+ },
155
+
156
+ ToolTip: { # < TextBlock
157
+ color: Gosu::Color::WHITE,
158
+ padding_top: 4,
159
+ padding_bottom: 4,
160
+ padding_left: 8,
161
+ padding_right: 8,
162
+ border_thickness: 1,
163
+ border_color: 0xffaaaaaa,
164
+ background: 0xff404040
165
+ },
166
+ Link: { # < TextBlock
167
+ color: Gosu::Color::BLUE,
168
+ border_thickness: 1,
169
+ border_bottom_color: Gosu::Color::BLUE,
170
+ hover: {
171
+ color: 0xff_ff00ff,
172
+ border_bottom_color: 0xff_ff00ff
173
+ },
174
+ active: {
175
+ color: 0xff_ff0000,
176
+ border_bottom_color: 0xff_ff0000
177
+ }
178
+ },
179
+
180
+ ToggleButton: { # < Button
181
+ checkmark: "√"
182
+ },
183
+
184
+ CheckBox: { # < Flow
185
+ text_wrap: :none
186
+ },
187
+
188
+ Progress: { # < Element
189
+ width: 250,
190
+ height: 36,
191
+ background: 0xff111111,
192
+ fraction_background: [0xffc75e61, 0xffe26623],
193
+ border_thickness: 1,
194
+ border_color: [0xffd59674, 0xffff8746]
195
+ },
196
+
197
+ Slider: { # < Element
198
+ width: 250,
199
+ height: 36,
200
+ background: 0xff111111,
201
+ fraction_background: [0xffc75e61, 0xffe26623],
202
+ border_thickness: 1,
203
+ border_color: [0xffd59674, 0xffff8746]
204
+ }
205
+ }.freeze
206
+ end
207
+ end