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,158 +1,158 @@
1
- # frozen_string_literal: true
2
-
3
- module CyberarmEngine
4
- class Console
5
- module Style
6
- def self.error(string)
7
- "<c=ff5555>#{string}</c>"
8
- end
9
-
10
- def self.warn(string)
11
- "<c=ff7700>#{string}</c>"
12
- end
13
-
14
- def self.notice(string)
15
- "<c=55ff55>#{string}</c>"
16
- end
17
-
18
- def self.highlight(string, color = "5555ff")
19
- "<c=#{color}>#{string}</c>"
20
- end
21
- end
22
-
23
- class Command
24
- def self.inherited(subclass)
25
- @list ||= []
26
- @commands ||= []
27
- @list << subclass
28
- end
29
-
30
- def self.setup
31
- @list ||= []
32
- @commands = []
33
- @list.each do |subclass|
34
- cmd = subclass.new
35
- if @commands.detect { |c| c.command == cmd.command }
36
- raise "Command '#{cmd.command}' from '#{cmd.class}' already exists!"
37
- end
38
-
39
- @commands << cmd
40
- end
41
- end
42
-
43
- def self.use(command, arguments, console)
44
- found_command = @commands.detect { |cmd| cmd.command == command.to_sym }
45
-
46
- if found_command
47
- found_command.handle(arguments, console)
48
- else
49
- console.stdin("Command #{Style.error(command)} not found.")
50
- end
51
- end
52
-
53
- def self.find(command)
54
- @commands.detect { |cmd| cmd.command == command.to_sym }
55
- end
56
-
57
- def self.list_commands
58
- @commands
59
- end
60
-
61
- def initialize
62
- @store = {}
63
- @subcommands = []
64
-
65
- setup
66
- end
67
-
68
- def setup
69
- end
70
-
71
- def subcommand(command, type)
72
- if @subcommands.detect { |subcmd| subcmd.command == command.to_sym }
73
- raise "Subcommand '#{command}' for '#{self.command}' already exists!"
74
- end
75
-
76
- @subcommands << SubCommand.new(self, command, type)
77
- end
78
-
79
- def get(key)
80
- @store[key]
81
- end
82
-
83
- def set(key, value)
84
- @store[key] = value
85
- end
86
-
87
- def group
88
- raise NotImplementedError
89
- end
90
-
91
- def command
92
- raise NotImplementedError
93
- end
94
-
95
- def handle(arguments, console)
96
- raise NotImplementedError
97
- end
98
-
99
- def autocomplete(console)
100
- split = console.text_input.text.split(" ")
101
-
102
- if @subcommands.size.positive?
103
- if !console.text_input.text.end_with?(" ") && split.size == 2
104
- list = console.abbrev_search(@subcommands.map { |cmd| cmd.command.to_s }, split.last)
105
-
106
- if list.size == 1
107
- console.text_input.text = "#{split.first} #{list.first} "
108
- else
109
- return unless list.size.positive?
110
-
111
- console.stdin(list.map { |cmd| Console::Style.highlight(cmd) }.join(", ").to_s)
112
- end
113
-
114
- # List available options on subcommand
115
- elsif (console.text_input.text.end_with?(" ") && split.size == 2) || !console.text_input.text.end_with?(" ") && split.size == 3
116
- subcommand = @subcommands.detect { |cmd| cmd.command.to_s == (split[1]) }
117
-
118
- if subcommand
119
- if split.size == 2
120
- console.stdin("Available options: #{subcommand.values.map { |value| Console::Style.highlight(value) }.join(',')}")
121
- else
122
- list = console.abbrev_search(subcommand.values, split.last)
123
- if list.size == 1
124
- console.text_input.text = "#{split.first} #{split[1]} #{list.first} "
125
- elsif list.size.positive?
126
- console.stdin("Available options: #{list.map { |value| Console::Style.highlight(value) }.join(',')}")
127
- end
128
- end
129
- end
130
-
131
- # List available subcommands if command was entered and has only a space after it
132
- elsif console.text_input.text.end_with?(" ") && split.size == 1
133
- console.stdin("Available subcommands: #{@subcommands.map { |cmd| Console::Style.highlight(cmd.command) }.join(', ')}")
134
- end
135
- end
136
- end
137
-
138
- def handle_subcommand(arguments, console)
139
- if arguments.size.zero?
140
- console.stdin(usage)
141
- return
142
- end
143
- subcommand = arguments.delete_at(0)
144
-
145
- found_command = @subcommands.detect { |cmd| cmd.command == subcommand.to_sym }
146
- if found_command
147
- found_command.handle(arguments, console)
148
- else
149
- console.stdin("Unknown subcommand #{Style.error(subcommand)} for #{Style.highlight(command)}")
150
- end
151
- end
152
-
153
- def usage
154
- raise NotImplementedError
155
- end
156
- end
157
- end
1
+ # frozen_string_literal: true
2
+
3
+ module CyberarmEngine
4
+ class Console
5
+ module Style
6
+ def self.error(string)
7
+ "<c=ff5555>#{string}</c>"
8
+ end
9
+
10
+ def self.warn(string)
11
+ "<c=ff7700>#{string}</c>"
12
+ end
13
+
14
+ def self.notice(string)
15
+ "<c=55ff55>#{string}</c>"
16
+ end
17
+
18
+ def self.highlight(string, color = "5555ff")
19
+ "<c=#{color}>#{string}</c>"
20
+ end
21
+ end
22
+
23
+ class Command
24
+ def self.inherited(subclass)
25
+ @list ||= []
26
+ @commands ||= []
27
+ @list << subclass
28
+ end
29
+
30
+ def self.setup
31
+ @list ||= []
32
+ @commands = []
33
+ @list.each do |subclass|
34
+ cmd = subclass.new
35
+ if @commands.detect { |c| c.command == cmd.command }
36
+ raise "Command '#{cmd.command}' from '#{cmd.class}' already exists!"
37
+ end
38
+
39
+ @commands << cmd
40
+ end
41
+ end
42
+
43
+ def self.use(command, arguments, console)
44
+ found_command = @commands.detect { |cmd| cmd.command == command.to_sym }
45
+
46
+ if found_command
47
+ found_command.handle(arguments, console)
48
+ else
49
+ console.stdin("Command #{Style.error(command)} not found.")
50
+ end
51
+ end
52
+
53
+ def self.find(command)
54
+ @commands.detect { |cmd| cmd.command == command.to_sym }
55
+ end
56
+
57
+ def self.list_commands
58
+ @commands
59
+ end
60
+
61
+ def initialize
62
+ @store = {}
63
+ @subcommands = []
64
+
65
+ setup
66
+ end
67
+
68
+ def setup
69
+ end
70
+
71
+ def subcommand(command, type)
72
+ if @subcommands.detect { |subcmd| subcmd.command == command.to_sym }
73
+ raise "Subcommand '#{command}' for '#{self.command}' already exists!"
74
+ end
75
+
76
+ @subcommands << SubCommand.new(self, command, type)
77
+ end
78
+
79
+ def get(key)
80
+ @store[key]
81
+ end
82
+
83
+ def set(key, value)
84
+ @store[key] = value
85
+ end
86
+
87
+ def group
88
+ raise NotImplementedError
89
+ end
90
+
91
+ def command
92
+ raise NotImplementedError
93
+ end
94
+
95
+ def handle(arguments, console)
96
+ raise NotImplementedError
97
+ end
98
+
99
+ def autocomplete(console)
100
+ split = console.text_input.text.split(" ")
101
+
102
+ if @subcommands.size.positive?
103
+ if !console.text_input.text.end_with?(" ") && split.size == 2
104
+ list = console.abbrev_search(@subcommands.map { |cmd| cmd.command.to_s }, split.last)
105
+
106
+ if list.size == 1
107
+ console.text_input.text = "#{split.first} #{list.first} "
108
+ else
109
+ return unless list.size.positive?
110
+
111
+ console.stdin(list.map { |cmd| Console::Style.highlight(cmd) }.join(", ").to_s)
112
+ end
113
+
114
+ # List available options on subcommand
115
+ elsif (console.text_input.text.end_with?(" ") && split.size == 2) || !console.text_input.text.end_with?(" ") && split.size == 3
116
+ subcommand = @subcommands.detect { |cmd| cmd.command.to_s == (split[1]) }
117
+
118
+ if subcommand
119
+ if split.size == 2
120
+ console.stdin("Available options: #{subcommand.values.map { |value| Console::Style.highlight(value) }.join(',')}")
121
+ else
122
+ list = console.abbrev_search(subcommand.values, split.last)
123
+ if list.size == 1
124
+ console.text_input.text = "#{split.first} #{split[1]} #{list.first} "
125
+ elsif list.size.positive?
126
+ console.stdin("Available options: #{list.map { |value| Console::Style.highlight(value) }.join(',')}")
127
+ end
128
+ end
129
+ end
130
+
131
+ # List available subcommands if command was entered and has only a space after it
132
+ elsif console.text_input.text.end_with?(" ") && split.size == 1
133
+ console.stdin("Available subcommands: #{@subcommands.map { |cmd| Console::Style.highlight(cmd.command) }.join(', ')}")
134
+ end
135
+ end
136
+ end
137
+
138
+ def handle_subcommand(arguments, console)
139
+ if arguments.size.zero?
140
+ console.stdin(usage)
141
+ return
142
+ end
143
+ subcommand = arguments.delete_at(0)
144
+
145
+ found_command = @subcommands.detect { |cmd| cmd.command == subcommand.to_sym }
146
+ if found_command
147
+ found_command.handle(arguments, console)
148
+ else
149
+ console.stdin("Unknown subcommand #{Style.error(subcommand)} for #{Style.highlight(command)}")
150
+ end
151
+ end
152
+
153
+ def usage
154
+ raise NotImplementedError
155
+ end
156
+ end
157
+ end
158
158
  end
@@ -1,43 +1,43 @@
1
- # frozen_string_literal: true
2
-
3
- module CyberarmEngine
4
- class Console
5
- class HelpCommand < CyberarmEngine::Console::Command
6
- def group
7
- :global
8
- end
9
-
10
- def command
11
- :help
12
- end
13
-
14
- def handle(arguments, console)
15
- console.stdin(usage(arguments.first))
16
- end
17
-
18
- def autocomplete(console)
19
- split = console.text_input.text.split(" ")
20
- if !console.text_input.text.start_with?(" ") && split.size == 2
21
- list = console.abbrev_search(Command.list_commands.map { |cmd| cmd.command.to_s }, split.last)
22
- if list.size == 1
23
- console.text_input.text = "#{split.first} #{list.first} "
24
- elsif list.size > 1
25
- console.stdin(list.map { |cmd| Style.highlight(cmd) }.join(", "))
26
- end
27
- end
28
- end
29
-
30
- def usage(command = nil)
31
- if command
32
- if cmd = Command.find(command)
33
- cmd.usage
34
- else
35
- "#{Style.error(command)} is not a command"
36
- end
37
- else
38
- "Available commands:\n#{Command.list_commands.map { |cmd| Style.highlight(cmd.command).to_s }.join(', ')}"
39
- end
40
- end
41
- end
42
- end
43
- end
1
+ # frozen_string_literal: true
2
+
3
+ module CyberarmEngine
4
+ class Console
5
+ class HelpCommand < CyberarmEngine::Console::Command
6
+ def group
7
+ :global
8
+ end
9
+
10
+ def command
11
+ :help
12
+ end
13
+
14
+ def handle(arguments, console)
15
+ console.stdin(usage(arguments.first))
16
+ end
17
+
18
+ def autocomplete(console)
19
+ split = console.text_input.text.split(" ")
20
+ if !console.text_input.text.start_with?(" ") && split.size == 2
21
+ list = console.abbrev_search(Command.list_commands.map { |cmd| cmd.command.to_s }, split.last)
22
+ if list.size == 1
23
+ console.text_input.text = "#{split.first} #{list.first} "
24
+ elsif list.size > 1
25
+ console.stdin(list.map { |cmd| Style.highlight(cmd) }.join(", "))
26
+ end
27
+ end
28
+ end
29
+
30
+ def usage(command = nil)
31
+ if command
32
+ if cmd = Command.find(command)
33
+ cmd.usage
34
+ else
35
+ "#{Style.error(command)} is not a command"
36
+ end
37
+ else
38
+ "Available commands:\n#{Command.list_commands.map { |cmd| Style.highlight(cmd.command).to_s }.join(', ')}"
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,100 +1,100 @@
1
- # frozen_string_literal: true
2
-
3
- module CyberarmEngine
4
- class Console
5
- class Command
6
- class SubCommand
7
- def initialize(parent, command, type)
8
- @parent = parent
9
- @command = command
10
- @type = type
11
- end
12
-
13
- attr_reader :command
14
-
15
- def handle(arguments, console)
16
- if arguments.size > 1
17
- console.stdin("to many arguments for #{Style.highlight(command.to_s)}, got #{Style.error(arguments.size)} expected #{Style.notice(1)}.")
18
- return
19
- end
20
-
21
- case @type
22
- when :boolean
23
- case arguments.last
24
- when "", nil
25
- var = @parent.get(command.to_sym) || false
26
- console.stdin("#{command}: #{Style.highlight(var)}")
27
- when "on"
28
- var = @parent.set(command.to_sym, true)
29
- console.stdin("#{command} => #{Style.highlight(var)}")
30
- when "off"
31
- var = @parent.set(command.to_sym, false)
32
- console.stdin("#{command} => #{Style.highlight(var)}")
33
- else
34
- console.stdin("Invalid argument for #{Style.highlight(command.to_s)}, got #{Style.error(arguments.last)} expected #{Style.notice('on')}, or #{Style.notice('off')}.")
35
- end
36
- when :string
37
- case arguments.last
38
- when "", nil
39
- var = @parent.get(command.to_sym) || "\"\""
40
- console.stdin("#{command}: #{Style.highlight(var)}")
41
- else
42
- var = @parent.set(command.to_sym, arguments.last)
43
- console.stdin("#{command} => #{Style.highlight(var)}")
44
- end
45
- when :integer
46
- case arguments.last
47
- when "", nil
48
- var = @parent.get(command.to_sym) || "nil"
49
- console.stdin("#{command}: #{Style.highlight(var)}")
50
- else
51
- begin
52
- var = @parent.set(command.to_sym, Integer(arguments.last))
53
- console.stdin("#{command} => #{Style.highlight(var)}")
54
- rescue ArgumentError
55
- console.stdin("Error: #{Style.error("Expected an integer, got '#{arguments.last}'")}")
56
- end
57
- end
58
- when :decimal
59
- case arguments.last
60
- when "", nil
61
- var = @parent.get(command.to_sym) || "nil"
62
- console.stdin("#{command}: #{Style.highlight(var)}")
63
- else
64
- begin
65
- var = @parent.set(command.to_sym, Float(arguments.last))
66
- console.stdin("#{command} => #{Style.highlight(var)}")
67
- rescue ArgumentError
68
- console.stdin("Error: #{Style.error("Expected a decimal or integer, got '#{arguments.last}'")}")
69
- end
70
- end
71
- else
72
- raise RuntimeError
73
- end
74
- end
75
-
76
- def values
77
- case @type
78
- when :boolean
79
- %w[on off]
80
- else
81
- []
82
- end
83
- end
84
-
85
- def usage
86
- case @type
87
- when :boolean
88
- "#{Style.highlight(command)} #{Style.notice('[on|off]')}"
89
- when :string
90
- "#{Style.highlight(command)} #{Style.notice('[string]')}"
91
- when :integer
92
- "#{Style.highlight(command)} #{Style.notice('[0]')}"
93
- when :decimal
94
- "#{Style.highlight(command)} #{Style.notice('[0.0]')}"
95
- end
96
- end
97
- end
98
- end
99
- end
1
+ # frozen_string_literal: true
2
+
3
+ module CyberarmEngine
4
+ class Console
5
+ class Command
6
+ class SubCommand
7
+ def initialize(parent, command, type)
8
+ @parent = parent
9
+ @command = command
10
+ @type = type
11
+ end
12
+
13
+ attr_reader :command
14
+
15
+ def handle(arguments, console)
16
+ if arguments.size > 1
17
+ console.stdin("to many arguments for #{Style.highlight(command.to_s)}, got #{Style.error(arguments.size)} expected #{Style.notice(1)}.")
18
+ return
19
+ end
20
+
21
+ case @type
22
+ when :boolean
23
+ case arguments.last
24
+ when "", nil
25
+ var = @parent.get(command.to_sym) || false
26
+ console.stdin("#{command}: #{Style.highlight(var)}")
27
+ when "on"
28
+ var = @parent.set(command.to_sym, true)
29
+ console.stdin("#{command} => #{Style.highlight(var)}")
30
+ when "off"
31
+ var = @parent.set(command.to_sym, false)
32
+ console.stdin("#{command} => #{Style.highlight(var)}")
33
+ else
34
+ console.stdin("Invalid argument for #{Style.highlight(command.to_s)}, got #{Style.error(arguments.last)} expected #{Style.notice('on')}, or #{Style.notice('off')}.")
35
+ end
36
+ when :string
37
+ case arguments.last
38
+ when "", nil
39
+ var = @parent.get(command.to_sym) || "\"\""
40
+ console.stdin("#{command}: #{Style.highlight(var)}")
41
+ else
42
+ var = @parent.set(command.to_sym, arguments.last)
43
+ console.stdin("#{command} => #{Style.highlight(var)}")
44
+ end
45
+ when :integer
46
+ case arguments.last
47
+ when "", nil
48
+ var = @parent.get(command.to_sym) || "nil"
49
+ console.stdin("#{command}: #{Style.highlight(var)}")
50
+ else
51
+ begin
52
+ var = @parent.set(command.to_sym, Integer(arguments.last))
53
+ console.stdin("#{command} => #{Style.highlight(var)}")
54
+ rescue ArgumentError
55
+ console.stdin("Error: #{Style.error("Expected an integer, got '#{arguments.last}'")}")
56
+ end
57
+ end
58
+ when :decimal
59
+ case arguments.last
60
+ when "", nil
61
+ var = @parent.get(command.to_sym) || "nil"
62
+ console.stdin("#{command}: #{Style.highlight(var)}")
63
+ else
64
+ begin
65
+ var = @parent.set(command.to_sym, Float(arguments.last))
66
+ console.stdin("#{command} => #{Style.highlight(var)}")
67
+ rescue ArgumentError
68
+ console.stdin("Error: #{Style.error("Expected a decimal or integer, got '#{arguments.last}'")}")
69
+ end
70
+ end
71
+ else
72
+ raise RuntimeError
73
+ end
74
+ end
75
+
76
+ def values
77
+ case @type
78
+ when :boolean
79
+ %w[on off]
80
+ else
81
+ []
82
+ end
83
+ end
84
+
85
+ def usage
86
+ case @type
87
+ when :boolean
88
+ "#{Style.highlight(command)} #{Style.notice('[on|off]')}"
89
+ when :string
90
+ "#{Style.highlight(command)} #{Style.notice('[string]')}"
91
+ when :integer
92
+ "#{Style.highlight(command)} #{Style.notice('[0]')}"
93
+ when :decimal
94
+ "#{Style.highlight(command)} #{Style.notice('[0.0]')}"
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
100
  end