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,476 @@
1
+ module GTK
2
+ class Runtime
3
+ # @return [GTK::Args] args
4
+ attr_reader :args
5
+
6
+ # Given a file_path to a sprite, this function returns a Hash with w, h, and pixels.
7
+ # The pixels key contains an array of hexadecimal values representing the ABGR of each pixel in a sprite with item 0 representing the top left corner of the png.
8
+ #
9
+ # @param file_path [String] path to a sprite
10
+ # @return [Typing::PixelsHash] returns a Hash with w, h, and pixels. The pixels key contains an array of hexadecimal values representing the ABGR of each pixel in a sprite with item 0 representing the top left corner of the png.
11
+ def get_pixels file_path; end
12
+
13
+ def dlopen file_path; end
14
+
15
+ # @return [Boolean] Returns true if the window is currently in fullscreen mode.
16
+ def window_fullscreen?; end
17
+
18
+ # @return [Boolean] Returns true if the window can be resized on the platform the game is running on. This is useful for conditionally showing a “Toggle Fullscreen” option in your game.
19
+ def can_resize_window?; end
20
+
21
+ # Set the fullscreen state of the game.
22
+ #
23
+ # @param fullscreen [Boolean] true to make the game fullscreen, false to return the game back to windowed mode.
24
+ def set_window_fullscreen fullscreen; end
25
+
26
+ # Toggles the fullscreen state of the window.
27
+ def toggle_window_fullscreen; end
28
+
29
+ # This function takes in a float value and uses that to resize the game window to a percentage of 1280x720 (or 720x1280 in portrait mode).
30
+ #
31
+ # @param scale [Float] valid scale options are 0.1, 0.25, 0.5, 0.75, 1.25, 1.5, 2.0, 2.5, 3.0, and 4.0. The float value you pass in will be floored to the nearest valid scale option.
32
+ def set_window_scale scale; end
33
+
34
+ # Set the title of the game in the Menu Bar
35
+ # Note: The default title for your game is specified in via the gametitle property in mygame/metadata/game_metadata.txt.
36
+ #
37
+ # @param title [String] the title of the game in the Menu Bar.
38
+ def set_window_title title; end
39
+
40
+ # @return [Boolean] Returns true if quitting is allowed on the platform you are releasing to (eg: iOS and Web games do not allow exiting).
41
+ def can_close_window?; end
42
+
43
+ # If you have multiple monitors, this function can be used to move the game to the next monitor. The function will cycle back to the first monitor if needed.
44
+ def move_window_to_next_display; end
45
+
46
+ # If #can_resize_window? returns true, this functions will maximize the game window.
47
+ def maximize_window; end
48
+
49
+ # @return [Boolean] Returns true if the game’s orientation can be altered while the game is running.
50
+ def can_change_orientation?; end
51
+
52
+ # If #can_change_orientation? returns true, the orientation of the game will be changed from landscape to portrait (or portrait to landscape) while the game is running.
53
+ # This function is useful for testing rendering of games that support both portrait and landscape orientations.
54
+ def toggle_orientation; end
55
+
56
+ # @param orientation [Symbol] accepts :landscape, or :portrait to set the game’s orientation while the game is running.
57
+ def set_orientation orientation; end
58
+
59
+ # Function accepts on of the following Integer values:
60
+ # see [scale values](https://docs.dragonruby.org/#/api/runtime?id=set_hd_max_scale) for valid values
61
+ #
62
+ # @param scale [Integer] scale value
63
+ def set_hd_max_scale scale; end
64
+
65
+ # Adds or removes the letterbox within your game while it’s running. This is useful for testing how your game renders on edge to edge displays.
66
+ def toggle_hd_letterbox; end
67
+
68
+ # @param letterbox [Boolean]
69
+ def set_hd_letterbox letterbox; end
70
+
71
+ # Returns the render width and render height as a tuple for a piece of text.
72
+ #
73
+ # @param text [String] the text you want to get the width and height of.
74
+ # @param size_enum [Integer] number representing the render size for the text.
75
+ # @param font [String] path to a font file that the width and height will be based off of.
76
+ def calcstringbox text, size_enum, font; end
77
+
78
+ # Returns the render width and render height as a tuple for a piece of text.
79
+ #
80
+ # @param text [String] the text you want to get the width and height of.
81
+ # @param size_enum [Integer] number representing the render size for the text.
82
+ # @param font [String] path to a font file that the width and height will be based off of.
83
+ def get_string_rect text, size_enum, font; end
84
+
85
+
86
+ # Call this function to exit your game.
87
+ # You will be given one additional tick if you need to perform any housekeeping before that game closes.
88
+ def request_quit; end
89
+
90
+ # @return [Boolean] will return true if the game is about to exit (either from the user closing the game or if request_quit was invoked).
91
+ def quit_requested?; end
92
+
93
+ # You can ask DragonRuby which platform your game is currently being run on.
94
+ # This can be useful if you want to perform different pieces of logic based on where the game is running.
95
+ # The raw platform string value is available via args.gtk.platform? which takes in a symbol representing the platform’s categorization/mapping.
96
+ # You can see all available platform categorizations via the #platform_mappings function.
97
+ #
98
+ # @param cateogry [Symbol]
99
+ def platform? category; end
100
+
101
+ # Returns true if the game is being run in a released/shipped state.
102
+ # If you want to simulate a production build. Add an empty file called dragonruby_production_build inside of the metadata folder.
103
+ #
104
+ # @return [Boolean] Returns true if the game is being run in a released/shipped state.
105
+ def production?; end
106
+
107
+ # @return [Hash]
108
+ attr_reader :platform_mappings
109
+
110
+ # This fuction will open the uri in the user’s default browser.
111
+ #
112
+ # @param url [String] a uri represented as a string.
113
+ def open_url url; end
114
+
115
+ # Given an OS dependent cli command represented as a string, this function executes the command and puts the results to the DragonRuby Console (returns nil).
116
+ #
117
+ # @param command [String] an OS dependent cli command represented as a string
118
+ def system command; end
119
+
120
+ # Given an OS dependent cli command represented as a string, this function executes the command and puts the results to the DragonRuby Console (returns nil).
121
+ #
122
+ # @param command [String] an OS dependent cli command represented as a string
123
+ def exec command; end
124
+
125
+ # shows the mouse cursor.
126
+ def show_cursor; end
127
+
128
+ # Hides the mouse cursor.
129
+ def hide_cursor; end
130
+
131
+ # @return [Boolean] Returns true if the mouse cursor is visible.
132
+ def cursor_shown?; end
133
+
134
+ # @param mode [Integer] 0: Ungrabs the mouse, 1: Grabs the mouse, 2: Hides the cursor, grabs the mouse and puts it in relative position mode accessible via args.inputs.mouse.relative_x or y.
135
+ def set_mouse_grab mode; end
136
+
137
+ # Set cursor if available.
138
+ #
139
+ # @param cursor [String] valid values are "arrow", "ibeam", "wait", or "hand"
140
+ def set_system_cursor cursor; end
141
+
142
+ # Replaces the mouse cursor with a sprite.
143
+ #
144
+ # @param path [String] a path to the sprite
145
+ # @param rel_x [Integer] relative positioning the sprite will have to the cursor
146
+ # @param rel_y [Integer] relative positioning the sprite will have to the cursor
147
+ def set_cursor path, rel_x, rel_y; end
148
+
149
+ # @return [String] Returns a UUID/GUID as a String value. The UUID uses srand and is not cryptographically secure.
150
+ def create_uuid; end
151
+
152
+ # List files within a directory.
153
+ #
154
+ # @param directory [String]
155
+ # @return [Array<String>] returns an Array of String representing all files within the directory.
156
+ def list_files directory; end
157
+
158
+ # Get file attributes for a file_path
159
+ #
160
+ # ```ruby
161
+ # {
162
+ # path: String,
163
+ # file_size: Int,
164
+ # mod_time: Int,
165
+ # create_time: Int,
166
+ # access_time: Int,
167
+ # readonly: Boolean,
168
+ # file_type: Symbol (:regular, :directory, :symlink, :other),
169
+ # }
170
+ # ```
171
+ #
172
+ # @param file_path [String] the path to the FileTest
173
+ # @return [Hash,nil] returns nil if the file doesn’t exist otherwise it returns a Hash with the attributes.
174
+ def stat_file file_path; end
175
+
176
+ # Given a file path, a string will be returned representing the contents of the file.
177
+ #
178
+ # @param file_path [String] path to the file to read.
179
+ # @return [String,nil] a string will be returned representing the contents of the file. nil will be returned if the file does not exist.
180
+ def read_file file_path; end
181
+
182
+ # Write contents of a string to a file.
183
+ #
184
+ # @param file_path [String] path to write to.
185
+ # @param contents [String] contents to write to.
186
+ def write_file file_path, contents; end
187
+
188
+ # Append contents of a string to a file.
189
+ #
190
+ # @param file_path [String] path to append to.
191
+ # @param contents [String] contents to append to.
192
+ def append_file file_path, contents; end
193
+
194
+ # Delete a file or directory
195
+ #
196
+ # Here is a list of reasons an exception could be raised:
197
+ # - If the path is still open (for reading or writing).
198
+ # - If the path is not a file or directory.
199
+ # - If the path is a circular symlink.
200
+ # - If you do not have permissions to delete the path.
201
+ # - If the directory attempting to be deleted is not empty.
202
+ #
203
+ # Notes:
204
+ # - Use stat_file to determine if a path exists.
205
+ # - Use list_files to determine if a directory is empty.
206
+ # - You cannot delete files outside of your sandboxed game environment.
207
+ #
208
+ # @param file_path [String] file or directory to delete.
209
+ def delete_file file_path; end
210
+
211
+ # @param json_string [String] json blob
212
+ # @return [Hash] hash representing the json data
213
+ def parse_json json_string; end
214
+
215
+ # @param file_path [String] file to json
216
+ # @return [Hash] hash representing the json data
217
+ def parse_json_file file_path; end
218
+
219
+ # @param xml_string [String] xml blob
220
+ # @return [Hash] hash representing the xml data
221
+ def parse_xml xml_string; end
222
+
223
+ # @param file_path [String] file to xml
224
+ # @return [Hash] hash representing the xml data
225
+ def parse_xml_file file_path; end
226
+
227
+ # Async http get.
228
+ #
229
+ # @param uri [String] uri
230
+ # @return [Object] Returns an object that represents an http response which will eventually have a value.
231
+ # Check for completion before attempting to read results.
232
+ def http_get uri; end
233
+
234
+ # Async http POST.
235
+ #
236
+ # @param uri [String] uri
237
+ # @param form_content [Hash] form fields to send
238
+ # @param headers [Array] HTTP Headers to send
239
+ # Note: Content-Type must be form encoded flavor. If you are unsure of what to pass in, set the content type to application/x-www-form-urlencoded
240
+ # @return [Object] Returns an object that represents an http response which will eventually have a value.
241
+ # Check for completion before attempting to read results.
242
+ def http_post uri, form_content, headers; end
243
+
244
+ # Async http POST.
245
+ #
246
+ # @param uri [String] uri
247
+ # @param string_content [String] String that represents body to send
248
+ # @param headers [Array] HTTP Headers to send
249
+ # Note: Content-Type must be form encoded flavor. If you are unsure of what to pass in, set the content type to application/x-www-form-urlencoded
250
+ # @return [Object] Returns an object that represents an http response which will eventually have a value.
251
+ # Check for completion before attempting to read results.
252
+ def http_post_body uri, string_content, headers; end
253
+
254
+ # Starts a in-game http server that can be process http requests.
255
+ # When your game is running in development mode, a dev server is started at http://localhost:9001
256
+ def start_server!; end
257
+
258
+ # @return [String] Returns a string representing the version of DragonRuby you are running.
259
+ def version; end
260
+
261
+ # @return [Boolean] Returns true if the version of DragonRuby is NOT Standard Edition.
262
+ def version_pro?; end
263
+
264
+ # @return [String] Returns a version string within mygame/game_metadata.txt.
265
+ def game_version; end
266
+
267
+ # Resets DragonRuby’s internal state as if it were just started.
268
+ #
269
+ # Kernel.tick_count is set to 0 and args.state is cleared of any values.
270
+ #
271
+ # This function is helpful when you are developing your game and want to reset everything as if the game just booted up.
272
+ def reset; end
273
+
274
+ # Has the same behavior as reset except the reset occurs before tick is executed again.
275
+ def reset_next_tick; end
276
+
277
+ # Reset a single sprite path.
278
+ #
279
+ # @param path [String] path to a previously loaded sprite, invalidates the cache record of the sprite so that updates on from the disk can be loaded.
280
+ def reset_sprite path; end
281
+
282
+ # This method invalidates the cache record of all sprites so that updates on from the disk can be loaded.
283
+ def reset_sprites; end
284
+
285
+ # @param path [String]
286
+ # @return [Array] Given a path to a sprite, this method returns the width and height of a sprite as a tuple.
287
+ def calcspritebox path; end
288
+
289
+ # @param path [String]
290
+ # @return [Hash] Performs the same function as calcspritebox, but returns a Hash with keys x (always 0), y (always 0), w, h, and center (Hash with x, y).
291
+ def get_sprite_rect path; end
292
+
293
+ # @return [Integer] Returns a float value representing the framerate of your game.
294
+ #
295
+ # This is an approximation/moving average of your framerate and should eventually settle to 60fps.
296
+ def current_framerate; end
297
+
298
+ # Get detailed information about the speed of your simulation.
299
+ #
300
+ # ```
301
+ # def tick args
302
+ # args.outputs.primitives << args.gtk.framerate_diagnostics_primitives
303
+ # end
304
+ # ```
305
+ # @return [Array] Returns a set of primitives that can be rendered to the screen which provide more detailed information about the speed of your simulation (framerate, draw call count, mouse position, etc).
306
+ def framerate_diagnostics_primitives; end
307
+
308
+ # This function helps you audit your game of usages of array-based primitives.
309
+ def warn_array_primitives!; end
310
+
311
+ # Given a string, this function will present a message at the bottom of your game.
312
+ #
313
+ # This method is only invoked in dev mode and is useful for debugging.
314
+ #
315
+ # @param message [String] message to print
316
+ # @param duration [Integer] number of ticks to show message
317
+ def notify! message, duration; end
318
+
319
+ def notify_extended! opts; end
320
+
321
+ # Given a numeric value representing the factor of 60fps. This function will bring your simulation loop down to slower rate.
322
+ #
323
+ # This method is intended to be used for debugging purposes.
324
+ #
325
+ # ```
326
+ # def tick args
327
+ # \# set your simulation speed to (15 fps): args.gtk.slowmo! 4
328
+ # \# set your simulation speed to (1 fps): args.gtk.slowmo! 60
329
+ # \# set your simulation speed to (30 fps):
330
+ # args.gtk.slowmo! 2
331
+ # end
332
+ # ```
333
+ #
334
+ # @param factor [Integer] slowmo factor
335
+ def slowmo! factor; end
336
+
337
+ # Shows the DragonRuby console. Useful when debugging/customizing an in-game dev workflow.
338
+ def show_console; end
339
+
340
+ # Shows the DragonRuby console. Useful when debugging/customizing an in-game dev workflow.
341
+ def hide_console; end
342
+
343
+ # Enables the DragonRuby Console so that it can be presented by pressing the tilde key (the key next to the number 1 key).
344
+ def enable_console; end
345
+
346
+ # Disables the DragonRuby Console so that it won’t show up even if you press the tilde key or call args.gtk.show_console.
347
+ def disable_console; end
348
+
349
+ # Disable the ability to reset via ctrl-r
350
+ def disable_reset_via_ctrl_r; end
351
+
352
+ # DragonRuby has a built-in controller configuration/mapping wizard. You can disable this wizard by calling this method.
353
+ def disable_controller_config; end
354
+
355
+ # DragonRuby has a built-in controller configuration/mapping wizard. You can re-enable this wizard by calling this method.
356
+ def enable_controller_config; end
357
+
358
+ # Resets the game to tick 0 and starts recording gameplay. Useful for visual regression tests/verification.
359
+ def start_recording; end
360
+
361
+ # Stop recording gameplay
362
+ #
363
+ # @param path [String] destination file for the currently recording gameplay.
364
+ def stop_recording path; end
365
+
366
+ # cancels a gameplay recording session and discards the replay.
367
+ def cancel_recording; end
368
+
369
+ # Run a recording against the current codebase.
370
+ #
371
+ # @param replay_file_path [String] a file that represents a recording.
372
+ def start_replay replay_file_path; end
373
+
374
+ # Function stops a replay that is currently executing.
375
+ def stop_replay; end
376
+
377
+ # Returns the path to the location of the dragonruby binary.
378
+ #
379
+ # In production mode, this value will be the same as the value returned by get_game_dir.
380
+ #
381
+ # Function should only be used for debugging/development workflows.
382
+ def get_base_dir; end
383
+
384
+ # Returns the location within sandbox storage that the game is running.
385
+ #
386
+ # When developing your game, this value will be your mygame directory.
387
+ #
388
+ # In production, it’ll return a value that is OS specific (eg the Roaming directory on Windows or the Application Support directory on Mac).
389
+ #
390
+ # Invocations of (write\|append)_file will write to this sandboxed directory.
391
+ #
392
+ # @return [String] a location within sandbox storage that the game is running.
393
+ def get_game_dir; end
394
+
395
+ # @return [String] Returns a url encoded string representing the sandbox location for game data.
396
+ def get_game_dir_url; end
397
+
398
+ # Opens the game directory in the OS’s file explorer. This should be used for debugging purposes only.
399
+ def open_game_dir; end
400
+
401
+ # Given a file path and contents, the contents will be written to a directory outside of the game directory.
402
+ #
403
+ # This method should be used for development purposes only.
404
+ #
405
+ # In production this method will write to the same sandboxed location as write_file.
406
+ #
407
+ # @param filepath [String] filepath to write to.
408
+ # @param contents [String] contents to write to file.
409
+ def write_file_root filepath, contents; end
410
+
411
+ # Given a file path and contents, the contents will be appended to a file outside of the game directory.
412
+ #
413
+ # This method should be used for development purposes only.
414
+ #
415
+ # In production this method will append to the same sandboxed location as write_file.
416
+ #
417
+ # @param filepath [String] filepath to append to.
418
+ # @param contents [String] contents to append to file.
419
+ def append_file_root filepath, contents; end
420
+
421
+ # Returns a string representing the command line arguments passed to the DragonRuby binary.
422
+ #
423
+ # This should be used for development/debugging purposes only.
424
+ #
425
+ # @return [String] Returns a string representing the command line arguments passed to the DragonRuby binary.
426
+ def argv; end
427
+
428
+ # Returns a Hash for command line arguments in the format of --switch value (two hyphens preceding the switch flag with the value seperated by a space).
429
+ #
430
+ # This should be used for development/debugging purposes only.
431
+ #
432
+ # @return [Hash] Returns a Hash for command line arguments in the format of --switch value (two hyphens preceding the switch flag with the value seperated by a space).
433
+ def cli_arguments; end
434
+
435
+ # This should be used for development/debugging purposes only.
436
+ #
437
+ # @return [Hash] Returns a Hash representing the code files that have be loaded for your game along with timings for the events.
438
+ def reload_history; end
439
+
440
+ # This should be used for development/debugging purposes only.
441
+ #
442
+ # @return [Hash] Returns a Hash representing the code files that have be loaded for your game along with timings for the events.
443
+ def reload_history_pending; end
444
+
445
+ # Given a file name, this function will queue the file for reload if it’s been modified.
446
+ #
447
+ # An optional second parameter can be passed in to signify if the file should be forced loaded regardless of modified time (true means to force load, false means to load only if the file has been modified).
448
+ #
449
+ # This function should be used for development/debugging purposes only.
450
+ #
451
+ # @param filename [String] file to reload
452
+ def reload_if_needed filename; end
453
+
454
+ # Will print caller alongside each puts, allowing you to locate/hunt down rogue puts.
455
+ def add_caller_to_puts!; end
456
+
457
+ # alternative to `Object#instance_variable_get`
458
+ # this method exists on `Object`, but shall be left here for now, as not to clutter the api listing
459
+ #
460
+ # @param variable [Symbol, String] the instance variable name, *shall not include the leading `@`*
461
+ # @return [Object] the value of the instance variable named by `variable`
462
+ def ivar variable; end
463
+
464
+ # alternative to `Object#instance_variable_set`
465
+ # this method exists on `Object`, but shall be left here for now, as not to clutter the api listing
466
+ #
467
+ # @param variable [Symbol, String] the instance variable name, *shall not include the leading `@`*
468
+ # @param value [Object] the value the instance variable named by `variable` will be set to
469
+ def ivar! variable, value; end
470
+
471
+ # Invoking `$gtk.reboot`` will reset your game as if it were started for the first time.
472
+ #
473
+ # Any methods that were added to classes during hotload will be removed (leaving you with a pristine environment).
474
+ def reboot; end
475
+ end
476
+ end