solargraph-dragonruby 0.2.0

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.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +56 -0
  3. data/CODE_OF_CONDUCT.md +10 -0
  4. data/LICENSE.txt +21 -0
  5. data/NOTICE +8 -0
  6. data/README.md +185 -0
  7. data/Rakefile +13 -0
  8. data/lib/solargraph/dragonruby/convention.rb +43 -0
  9. data/lib/solargraph/dragonruby/macro_node.rb +44 -0
  10. data/lib/solargraph/dragonruby/version.rb +7 -0
  11. data/lib/solargraph/dragonruby.rb +15 -0
  12. data/lib/solargraph-dragonruby.rb +5 -0
  13. data/sig/solargraph/dragonruby.rbs +19 -0
  14. data/stubs/extensions/README.md +20 -0
  15. data/stubs/extensions/args.rb +91 -0
  16. data/stubs/extensions/array.rb +25 -0
  17. data/stubs/extensions/attr.rb +249 -0
  18. data/stubs/extensions/easing.rb +90 -0
  19. data/stubs/extensions/entity.rb +63 -0
  20. data/stubs/extensions/geometry.rb +528 -0
  21. data/stubs/extensions/grid.rb +247 -0
  22. data/stubs/extensions/inputs.rb +678 -0
  23. data/stubs/extensions/layout.rb +175 -0
  24. data/stubs/extensions/log.rb +158 -0
  25. data/stubs/extensions/main.rb +63 -0
  26. data/stubs/extensions/numeric.rb +395 -0
  27. data/stubs/extensions/outputs.rb +132 -0
  28. data/stubs/extensions/runtime.rb +436 -0
  29. data/stubs/extensions/string.rb +85 -0
  30. data/stubs/extensions/typing.rb +193 -0
  31. data/stubs/extensions/zlib.rb +24 -0
  32. data/stubs/upstream/LICENSE.txt +21 -0
  33. data/stubs/upstream/UPSTREAM +2 -0
  34. data/stubs/upstream/args.rb +61 -0
  35. data/stubs/upstream/constants.rb +8 -0
  36. data/stubs/upstream/controller.rb +90 -0
  37. data/stubs/upstream/easing.rb +119 -0
  38. data/stubs/upstream/geometry.rb +430 -0
  39. data/stubs/upstream/globals.rb +17 -0
  40. data/stubs/upstream/gtk.rb +476 -0
  41. data/stubs/upstream/inputs.rb +286 -0
  42. data/stubs/upstream/kernel.rb +7 -0
  43. data/stubs/upstream/keyboard.rb +38 -0
  44. data/stubs/upstream/layout.rb +32 -0
  45. data/stubs/upstream/numeric.rb +82 -0
  46. data/stubs/upstream/outputs.rb +55 -0
  47. data/stubs/upstream/outputs_array.rb +4 -0
  48. data/stubs/upstream/phantom_types.rb +25 -0
  49. data/stubs/upstream/toplevel.rb +13 -0
  50. metadata +107 -0
@@ -0,0 +1,249 @@
1
+ # Class macros from dragon/attr_dr.rb, attr_sprite.rb, attr_label.rb and
2
+ # attr_line.rb. Each one includes a module into the class it's called in. The
3
+ # plugin's MacroNode adds those includes for calls in your game's code, so the
4
+ # module methods complete on `self` and on instances.
5
+
6
+ class ::Module
7
+ # Class macro that includes AttrDR, adding DragonRuby's environment methods
8
+ # (`args`, `state`, `inputs`, `outputs`, `audio`, `grid`, `events`, ...) to
9
+ # instances of the class, so `args` doesn't have to be passed around. Set
10
+ # `instance.args = args` before using them.
11
+ #
12
+ # @return [void]
13
+ def attr_dr; end
14
+
15
+ # Older name for #attr_dr.
16
+ # @return [void]
17
+ def attr_gtk; end
18
+
19
+ # Class macro that includes AttrSprite, so instances can be pushed into
20
+ # `args.outputs.sprites` (or `args.outputs.primitives`) directly.
21
+ #
22
+ # @return [void]
23
+ def attr_sprite; end
24
+
25
+ # Class macro that includes AttrRect: `left`/`right`/`top`/`bottom` and the
26
+ # Geometry functions, for a class that defines `x`, `y`, `w` and `h`.
27
+ #
28
+ # @return [void]
29
+ def attr_rect; end
30
+
31
+ # Class macro that includes AttrLabel, adding accessors for the label
32
+ # properties (`x`, `y`, `text`, `size_px`, `font`, ...).
33
+ #
34
+ # @return [void]
35
+ def attr_label; end
36
+
37
+ # Class macro that includes AttrLine, so instances can be pushed into
38
+ # `args.outputs.lines` (or `args.outputs.primitives`) directly.
39
+ #
40
+ # @return [void]
41
+ def attr_line; end
42
+ end
43
+
44
+ # Added to a class by `attr_dr` (or `attr_gtk`). Every method reads from
45
+ # `args`, which must be assigned first.
46
+ module AttrDR
47
+ # @return [GTK::Args]
48
+ attr_accessor :args
49
+
50
+ # Same as `args.inputs.keyboard`.
51
+ # @return [GTK::Keyboard]
52
+ def keyboard; end
53
+
54
+ # Same as `args.grid`.
55
+ # @return [GTK::Grid]
56
+ def grid; end
57
+
58
+ # Same as `args.state`.
59
+ # @return [GTK::OpenEntity]
60
+ def state; end
61
+
62
+ # Same as `args.temp_state`, which is cleared every tick.
63
+ # @return [GTK::OpenEntity]
64
+ def temp_state; end
65
+
66
+ # Same as `args.inputs`.
67
+ # @return [GTK::Inputs]
68
+ def inputs; end
69
+
70
+ # Same as `args.outputs`.
71
+ # @return [GTK::Outputs]
72
+ def outputs; end
73
+
74
+ # Same as `args.gtk`.
75
+ # @return [GTK::Runtime]
76
+ def gtk; end
77
+
78
+ # Same as `args.passes`.
79
+ # @return [Array]
80
+ def passes; end
81
+
82
+ # Same as `args.pixel_arrays`.
83
+ # @return [Hash{Symbol => GTK::PixelArray}]
84
+ def pixel_arrays; end
85
+
86
+ # Same as `args.geometry`.
87
+ # @return [Module<GTK::Geometry>]
88
+ def geometry; end
89
+
90
+ # Same as `args.layout`.
91
+ # @return [Module<GTK::Layout>]
92
+ def layout; end
93
+
94
+ # Same as `args.easing`.
95
+ # @return [Module<GTK::Easing>]
96
+ def easing; end
97
+
98
+ # Same as `args.audio`.
99
+ # @return [AudioHash]
100
+ def audio; end
101
+
102
+ # Same as `args.events`.
103
+ # @return [GTK::Events]
104
+ def events; end
105
+
106
+ # Same as `args.cvars`.
107
+ # @return [Hash]
108
+ def cvars; end
109
+
110
+ # Same as `state.new_entity`.
111
+ #
112
+ # @param entity_type [Symbol]
113
+ # @param init_hash [Hash, nil] initial property values
114
+ # @yieldparam entity [GTK::OpenEntity]
115
+ # @return [GTK::OpenEntity]
116
+ def new_entity entity_type, init_hash = nil, &block; end
117
+
118
+ # Same as `state.new_entity_strict`.
119
+ #
120
+ # @param entity_type [Symbol]
121
+ # @param init_hash [Hash, nil] the allowed properties and their initial values
122
+ # @yieldparam entity [GTK::StrictEntity]
123
+ # @return [GTK::StrictEntity]
124
+ def new_entity_strict entity_type, init_hash = nil, &block; end
125
+
126
+ # Same as `Kernel.tick_count`.
127
+ # @return [Integer]
128
+ def tick_count; end
129
+
130
+ # Same as `Kernel.global_tick_count`.
131
+ # @return [Integer]
132
+ def global_tick_count; end
133
+ end
134
+
135
+ # Older name for AttrDR.
136
+ AttrGTK = AttrDR
137
+
138
+ # Added to a class by `attr_rect` (and by `attr_sprite`). Expects the class to
139
+ # respond to `x`, `y`, `w` and `h`.
140
+ module AttrRect
141
+ include Typing::GeometryMixin
142
+
143
+ # @return [Numeric] same as `x`
144
+ def left; end
145
+
146
+ # @return [Numeric] `x + w`
147
+ def right; end
148
+
149
+ # @return [Numeric] same as `y`
150
+ def bottom; end
151
+
152
+ # @return [Numeric] `y + h`
153
+ def top; end
154
+
155
+ # @return [Numeric] same as `x`
156
+ def x1; end
157
+
158
+ # @return [Numeric] same as `y`
159
+ def y1; end
160
+ end
161
+
162
+ # Added to a class by `attr_sprite`. Instances render as sprites.
163
+ module AttrSprite
164
+ include AttrRect
165
+
166
+ # @return [Numeric]
167
+ attr_accessor :x, :y, :w, :h, :z, :angle, :angle_x, :angle_y,
168
+ :angle_anchor_x, :angle_anchor_y, :anchor_x, :anchor_y,
169
+ :tile_x, :tile_y, :tile_w, :tile_h,
170
+ :source_x, :source_y, :source_w, :source_h,
171
+ :x2, :y2, :x3, :y3, :source_x2, :source_y2, :source_x3, :source_y3
172
+
173
+ # @return [Integer] 0-255
174
+ attr_accessor :r, :g, :b, :a, :r2, :g2, :b2, :a2, :r3, :g3, :b3, :a3
175
+
176
+ # @return [String, Symbol] image file path, or a render target name
177
+ attr_accessor :path
178
+
179
+ # @return [Boolean]
180
+ attr_accessor :flip_horizontally, :flip_vertically
181
+
182
+ # @return [Integer]
183
+ attr_accessor :blendmode_enum, :scale_quality_enum
184
+
185
+ # @return [Symbol, Integer]
186
+ attr_accessor :blendmode
187
+
188
+ # @return [Object]
189
+ attr_accessor :id
190
+
191
+ # @return [Symbol] always `:sprite`
192
+ def primitive_marker; end
193
+
194
+ # @return [self]
195
+ def sprite; end
196
+
197
+ # @param value [Numeric]
198
+ # @return [void]
199
+ def x1= value; end
200
+
201
+ # @param value [Numeric]
202
+ # @return [void]
203
+ def y1= value; end
204
+
205
+ # @return [Hash] the sprite properties
206
+ def serialize; end
207
+ end
208
+
209
+ # Added to a class by `attr_label`.
210
+ module AttrLabel
211
+ # @return [Numeric]
212
+ attr_accessor :x, :y, :z, :anchor_x, :anchor_y, :size_px
213
+
214
+ # @return [String]
215
+ attr_accessor :text
216
+
217
+ # @return [Integer]
218
+ attr_accessor :size_enum, :alignment_enum, :vertical_alignment_enum, :blendmode_enum
219
+
220
+ # @return [Integer] 0-255
221
+ attr_accessor :r, :g, :b, :a
222
+
223
+ # @return [String] font file path
224
+ attr_accessor :font
225
+ end
226
+
227
+ # Added to a class by `attr_line`. Instances render as lines.
228
+ module AttrLine
229
+ # @return [Numeric]
230
+ attr_accessor :x, :y, :x2, :y2, :w, :h
231
+
232
+ # @return [Integer] 0-255
233
+ attr_accessor :r, :g, :b, :a
234
+
235
+ # @return [Integer]
236
+ attr_accessor :blendmode_enum
237
+
238
+ # @return [Numeric] same as `x`
239
+ attr_accessor :x1
240
+
241
+ # @return [Numeric] same as `y`
242
+ attr_accessor :y1
243
+
244
+ # @return [Symbol] always `:line`
245
+ def primitive_marker; end
246
+
247
+ # @return [self]
248
+ def line; end
249
+ end
@@ -0,0 +1,90 @@
1
+ module GTK
2
+ module Easing
3
+ class << self
4
+ # Progress along a series of 4-point bezier curves, each given an equal
5
+ # share of `duration`.
6
+ #
7
+ # @example linear out and back
8
+ # Easing.spline 10, Kernel.tick_count, 300, [[0, 0.25, 0.75, 1.0], [1.0, 0.75, 0.25, 0]]
9
+ #
10
+ # @param start_tick [Integer]
11
+ # @param current_tick [Integer]
12
+ # @param duration [Integer] duration in ticks
13
+ # @param spline [Array<Array<Numeric>>] bezier definitions, four values each
14
+ # @return [Float] the value on the curve; the last point of the spline once `duration` has passed
15
+ def spline start_tick, current_tick, duration, spline; end
16
+
17
+ # Progress (`0.0` to `1.0`) of chained easing definitions over `duration`.
18
+ #
19
+ # @example
20
+ # Easing.ease 60, Kernel.tick_count, 120, :smooth_stop_quad
21
+ #
22
+ # @param start_tick [Integer]
23
+ # @param current_tick [Integer]
24
+ # @param duration [Integer] duration in ticks
25
+ # @param definitions [Array<Symbol, Proc>] `:identity`, `:flip`, `:quad`, `:cube`, `:quart`, `:quint`,
26
+ # `:smooth_start_quad`, `:smooth_stop_quad`, ..., or lambdas taking `x`
27
+ # @return [Float]
28
+ def ease start_tick, current_tick, duration, *definitions; end
29
+
30
+ # Same as #spline.
31
+ #
32
+ # @param start_tick [Integer]
33
+ # @param current_tick [Integer]
34
+ # @param duration [Integer] duration in ticks
35
+ # @param spline [Array<Array<Numeric>>] bezier definitions, four values each
36
+ # @return [Float]
37
+ def ease_spline start_tick, current_tick, duration, spline; end
38
+
39
+ # Accelerating ease (`perc ** power`). Pass either
40
+ # `initial:`, `final:`, `perc:` or `start_at:` with `end_at:` or `duration:`.
41
+ #
42
+ # @example percentage-based
43
+ # Easing.smooth_start initial: 0, final: 1280, perc: 0.5, power: 2
44
+ # @example time-based
45
+ # Easing.smooth_start start_at: 60, duration: 120, power: 3
46
+ #
47
+ # @param initial [Float, nil] starting value
48
+ # @param final [Float, nil] ending value
49
+ # @param perc [Float, nil] current percentage (over `1.0` overshoots `final`)
50
+ # @param start_at [Integer, nil] tick the easing starts
51
+ # @param end_at [Integer, nil] tick the easing ends
52
+ # @param duration [Integer, nil] ticks from `start_at` to the end
53
+ # @param tick_count [Integer, nil] current tick (defaults to `Kernel.tick_count`)
54
+ # @param power [Numeric] `1` linear, `2` quadratic, `3` cubic, ...
55
+ # @param flip [Boolean] return `1 - result` (go from 1 to 0)
56
+ # @return [Float]
57
+ def smooth_start initial: nil, final: nil, perc: nil, start_at: nil, end_at: nil, duration: nil, tick_count: nil, power: 1, flip: false; end
58
+
59
+ # Decelerating ease (`1 - (1 - perc) ** power`). Takes the same
60
+ # arguments as #smooth_start.
61
+ #
62
+ # @param initial [Float, nil] starting value
63
+ # @param final [Float, nil] ending value
64
+ # @param perc [Float, nil] current percentage (over `1.0` overshoots `final`)
65
+ # @param start_at [Integer, nil] tick the easing starts
66
+ # @param end_at [Integer, nil] tick the easing ends
67
+ # @param duration [Integer, nil] ticks from `start_at` to the end
68
+ # @param tick_count [Integer, nil] current tick (defaults to `Kernel.tick_count`)
69
+ # @param power [Numeric] `1` linear, `2` quadratic, `3` cubic, ...
70
+ # @param flip [Boolean] return `1 - result` (go from 1 to 0)
71
+ # @return [Float]
72
+ def smooth_stop initial: nil, final: nil, perc: nil, start_at: nil, end_at: nil, duration: nil, tick_count: nil, power: 1, flip: false; end
73
+
74
+ # 50/50 mix of #smooth_start and #smooth_stop. Takes the same arguments
75
+ # as #smooth_start.
76
+ #
77
+ # @param initial [Float, nil] starting value
78
+ # @param final [Float, nil] ending value
79
+ # @param perc [Float, nil] current percentage (over `1.0` overshoots `final`)
80
+ # @param start_at [Integer, nil] tick the easing starts
81
+ # @param end_at [Integer, nil] tick the easing ends
82
+ # @param duration [Integer, nil] ticks from `start_at` to the end
83
+ # @param tick_count [Integer, nil] current tick (defaults to `Kernel.tick_count`)
84
+ # @param power [Numeric] `1` linear, `2` quadratic, `3` cubic, ...
85
+ # @param flip [Boolean] return `1 - result` (go from 1 to 0)
86
+ # @return [Float]
87
+ def smooth_step initial: nil, final: nil, perc: nil, start_at: nil, end_at: nil, duration: nil, tick_count: nil, power: 1, flip: false; end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,63 @@
1
+ module Typing
2
+ # phantom type for the properties every DragonRuby entity has
3
+ module Entity
4
+ # @return [Integer] automatically assigned id
5
+ attr_reader :entity_id
6
+
7
+ # @return [Symbol, nil]
8
+ attr_reader :entity_type
9
+
10
+ # @return [Integer] `Kernel.tick_count` when the entity was created
11
+ attr_reader :created_at
12
+
13
+ # @return [Integer] ticks elapsed since creation
14
+ def created_at_elapsed; end
15
+
16
+ # @return [Integer] `Kernel.global_tick_count` when the entity was created
17
+ attr_reader :global_created_at
18
+
19
+ # @return [Integer] global ticks elapsed since creation
20
+ def global_created_at_elapsed; end
21
+
22
+ # @return [Hash] the entity cast to a `Hash`, so values can be updated as if it were a `Hash`
23
+ def as_hash; end
24
+ end
25
+ end
26
+
27
+ module GTK
28
+ # Backing type of `args.state`. Any property can be read or assigned
29
+ # (`args.state.player.x ||= 0`); only the built-in ones are listed here.
30
+ class OpenEntity
31
+ include Typing::Entity
32
+
33
+ # @return [Integer] the current tick of the game (same as `Kernel.tick_count`)
34
+ def tick_count; end
35
+
36
+ # Creates a new entity that accepts arbitrary properties.
37
+ #
38
+ # @example
39
+ # args.state.bullets << args.state.new_entity(:bullet) do |b|
40
+ # b.x = 0
41
+ # end
42
+ #
43
+ # @param entity_type [Symbol]
44
+ # @param init_hash [Hash, nil] initial property values
45
+ # @yieldparam entity [GTK::OpenEntity]
46
+ # @return [GTK::OpenEntity]
47
+ def new_entity entity_type, init_hash = nil, &block; end
48
+
49
+ # Creates a new entity that only allows the properties given in `init_hash`.
50
+ #
51
+ # @param entity_type [Symbol]
52
+ # @param init_hash [Hash, nil] the allowed properties and their initial values
53
+ # @yieldparam entity [GTK::StrictEntity]
54
+ # @return [GTK::StrictEntity]
55
+ def new_entity_strict entity_type, init_hash = nil, &block; end
56
+ end
57
+
58
+ # Entity returned by `new_entity_strict`; only the properties it was created
59
+ # with can be read or assigned.
60
+ class StrictEntity
61
+ include Typing::Entity
62
+ end
63
+ end