gosu 1.4.6 → 1.5.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.
- checksums.yaml +4 -4
- data/COPYING +2 -1
- data/dependencies/SDL/include/SDL3/SDL.h +91 -0
- data/dependencies/SDL/include/SDL3/SDL_assert.h +710 -0
- data/dependencies/SDL/include/SDL3/SDL_asyncio.h +550 -0
- data/dependencies/SDL/include/SDL3/SDL_atomic.h +692 -0
- data/dependencies/SDL/include/SDL3/SDL_audio.h +2382 -0
- data/dependencies/SDL/include/SDL3/SDL_begin_code.h +553 -0
- data/dependencies/SDL/include/{SDL_bits.h → SDL3/SDL_bits.h} +47 -27
- data/dependencies/SDL/include/{SDL_blendmode.h → SDL3/SDL_blendmode.h} +59 -55
- data/dependencies/SDL/include/SDL3/SDL_camera.h +535 -0
- data/dependencies/SDL/include/SDL3/SDL_clipboard.h +331 -0
- data/dependencies/SDL/include/{close_code.h → SDL3/SDL_close_code.h} +9 -8
- data/dependencies/SDL/include/{SDL_types.h → SDL3/SDL_copying.h} +2 -9
- data/dependencies/SDL/include/SDL3/SDL_cpuinfo.h +374 -0
- data/dependencies/SDL/include/SDL3/SDL_dialog.h +343 -0
- data/dependencies/SDL/include/SDL3/SDL_dlopennote.h +234 -0
- data/dependencies/SDL/include/{SDL_egl.h → SDL3/SDL_egl.h} +11 -8
- data/dependencies/SDL/include/SDL3/SDL_endian.h +645 -0
- data/dependencies/SDL/include/SDL3/SDL_error.h +226 -0
- data/dependencies/SDL/include/SDL3/SDL_events.h +1651 -0
- data/dependencies/SDL/include/SDL3/SDL_filesystem.h +537 -0
- data/dependencies/SDL/include/SDL3/SDL_gamepad.h +1657 -0
- data/dependencies/SDL/include/SDL3/SDL_gpu.h +4637 -0
- data/dependencies/SDL/include/SDL3/SDL_guid.h +106 -0
- data/dependencies/SDL/include/SDL3/SDL_haptic.h +1461 -0
- data/dependencies/SDL/include/SDL3/SDL_hidapi.h +571 -0
- data/dependencies/SDL/include/SDL3/SDL_hints.h +5041 -0
- data/dependencies/SDL/include/SDL3/SDL_init.h +508 -0
- data/dependencies/SDL/include/SDL3/SDL_intrin.h +410 -0
- data/dependencies/SDL/include/SDL3/SDL_iostream.h +1379 -0
- data/dependencies/SDL/include/SDL3/SDL_joystick.h +1385 -0
- data/dependencies/SDL/include/SDL3/SDL_keyboard.h +615 -0
- data/dependencies/SDL/include/SDL3/SDL_keycode.h +348 -0
- data/dependencies/SDL/include/SDL3/SDL_loadso.h +145 -0
- data/dependencies/SDL/include/{SDL_locale.h → SDL3/SDL_locale.h} +40 -24
- data/dependencies/SDL/include/SDL3/SDL_log.h +541 -0
- data/dependencies/SDL/include/SDL3/SDL_main.h +704 -0
- data/dependencies/SDL/include/SDL3/SDL_main_impl.h +149 -0
- data/dependencies/SDL/include/{SDL_messagebox.h → SDL3/SDL_messagebox.h} +85 -48
- data/dependencies/SDL/include/{SDL_metal.h → SDL3/SDL_metal.h} +29 -29
- data/dependencies/SDL/include/{SDL_misc.h → SDL3/SDL_misc.h} +13 -12
- data/dependencies/SDL/include/SDL3/SDL_mouse.h +813 -0
- data/dependencies/SDL/include/SDL3/SDL_mutex.h +1117 -0
- data/dependencies/SDL/include/SDL3/SDL_oldnames.h +1339 -0
- data/dependencies/SDL/include/{SDL_opengl.h → SDL3/SDL_opengl.h} +1247 -278
- data/dependencies/SDL/include/{SDL_opengl_glext.h → SDL3/SDL_opengl_glext.h} +5 -1
- data/dependencies/SDL/include/{SDL_opengles.h → SDL3/SDL_opengles.h} +6 -7
- data/dependencies/SDL/include/{SDL_opengles2.h → SDL3/SDL_opengles2.h} +10 -11
- data/dependencies/SDL/include/SDL3/SDL_pen.h +198 -0
- data/dependencies/SDL/include/SDL3/SDL_pixels.h +1441 -0
- data/dependencies/SDL/include/{SDL_test_log.h → SDL3/SDL_platform.h} +25 -26
- data/dependencies/SDL/include/SDL3/SDL_platform_defines.h +497 -0
- data/dependencies/SDL/include/{SDL_power.h → SDL3/SDL_power.h} +40 -20
- data/dependencies/SDL/include/SDL3/SDL_process.h +441 -0
- data/dependencies/SDL/include/SDL3/SDL_properties.h +572 -0
- data/dependencies/SDL/include/SDL3/SDL_rect.h +528 -0
- data/dependencies/SDL/include/SDL3/SDL_render.h +3034 -0
- data/dependencies/SDL/include/SDL3/SDL_revision.h +56 -0
- data/dependencies/SDL/include/{SDL_scancode.h → SDL3/SDL_scancode.h} +60 -68
- data/dependencies/SDL/include/SDL3/SDL_sensor.h +321 -0
- data/dependencies/SDL/include/SDL3/SDL_stdinc.h +6186 -0
- data/dependencies/SDL/include/SDL3/SDL_storage.h +686 -0
- data/dependencies/SDL/include/SDL3/SDL_surface.h +1769 -0
- data/dependencies/SDL/include/SDL3/SDL_system.h +840 -0
- data/dependencies/SDL/include/{SDL_test.h → SDL3/SDL_test.h} +16 -22
- data/dependencies/SDL/include/{SDL_test_assert.h → SDL3/SDL_test_assert.h} +27 -34
- data/dependencies/SDL/include/{SDL_test_common.h → SDL3/SDL_test_common.h} +109 -52
- data/dependencies/SDL/include/{SDL_test_compare.h → SDL3/SDL_test_compare.h} +22 -14
- data/dependencies/SDL/include/{SDL_test_crc32.h → SDL3/SDL_test_crc32.h} +27 -30
- data/dependencies/SDL/include/{SDL_test_font.h → SDL3/SDL_test_font.h} +50 -49
- data/dependencies/SDL/include/{SDL_test_fuzzer.h → SDL3/SDL_test_fuzzer.h} +64 -79
- data/dependencies/SDL/include/{SDL_test_harness.h → SDL3/SDL_test_harness.h} +47 -30
- data/dependencies/SDL/include/SDL3/SDL_test_log.h +83 -0
- data/dependencies/SDL/include/{SDL_test_md5.h → SDL3/SDL_test_md5.h} +21 -28
- data/dependencies/SDL/include/{SDL_test_memory.h → SDL3/SDL_test_memory.h} +19 -16
- data/dependencies/SDL/include/SDL3/SDL_thread.h +602 -0
- data/dependencies/SDL/include/SDL3/SDL_time.h +249 -0
- data/dependencies/SDL/include/SDL3/SDL_timer.h +454 -0
- data/dependencies/SDL/include/SDL3/SDL_touch.h +184 -0
- data/dependencies/SDL/include/SDL3/SDL_tray.h +544 -0
- data/dependencies/SDL/include/SDL3/SDL_version.h +198 -0
- data/dependencies/SDL/include/SDL3/SDL_video.h +3497 -0
- data/dependencies/SDL/include/SDL3/SDL_vulkan.h +287 -0
- data/dependencies/SDL/lib/x64/libSDL3.dll.a +0 -0
- data/dependencies/SDL/lib/x86/libSDL3.dll.a +0 -0
- data/dependencies/SDL_sound/SDL3_sound/SDL_sound.h +755 -0
- data/dependencies/SDL_sound/SDL_sound.c +136 -215
- data/dependencies/SDL_sound/SDL_sound_aiff.c +55 -54
- data/dependencies/SDL_sound/SDL_sound_au.c +32 -32
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +24 -41
- data/dependencies/SDL_sound/SDL_sound_flac.c +32 -12
- data/dependencies/SDL_sound/SDL_sound_internal.h +33 -48
- data/dependencies/SDL_sound/SDL_sound_modplug.c +21 -29
- data/dependencies/SDL_sound/SDL_sound_mp3.c +35 -13
- data/dependencies/SDL_sound/SDL_sound_raw.c +14 -15
- data/dependencies/SDL_sound/SDL_sound_shn.c +82 -82
- data/dependencies/SDL_sound/SDL_sound_voc.c +30 -30
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +34 -25
- data/dependencies/SDL_sound/SDL_sound_wav.c +86 -82
- data/dependencies/SDL_sound/dr_flac.h +1890 -1301
- data/dependencies/SDL_sound/dr_mp3.h +1098 -660
- data/dependencies/SDL_sound/libmodplug/fastmix.c +1 -1
- data/dependencies/SDL_sound/libmodplug/libmodplug.h +5 -4
- data/dependencies/SDL_sound/libmodplug/load_ams.c +6 -3
- data/dependencies/SDL_sound/libmodplug/load_dsm.c +2 -1
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +2 -2
- data/dependencies/SDL_sound/libmodplug/modplug.h +2 -1
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +3 -3
- data/dependencies/SDL_sound/libmodplug/sndfile.c +3 -0
- data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -3
- data/dependencies/SDL_sound/stb_vorbis.h +397 -342
- data/dependencies/mojoAL/AL/alc.h +2 -2
- data/dependencies/mojoAL/mojoal.c +2120 -1885
- data/dependencies/stb/stb_image.h +1190 -1379
- data/dependencies/stb/stb_image_write.h +329 -129
- data/dependencies/stb/stb_truetype.h +304 -60
- data/dependencies/utf8proc/utf8proc.c +133 -75
- data/dependencies/utf8proc/utf8proc.h +131 -50
- data/dependencies/utf8proc/utf8proc_data.h +16213 -15658
- data/ext/gosu-ffi/extconf.rb +103 -0
- data/ext/gosu-ffi/gosu-ffi.def +467 -0
- data/ffi/Gosu.cpp +330 -0
- data/ffi/Gosu.h +84 -0
- data/ffi/Gosu_Channel.cpp +62 -0
- data/ffi/Gosu_Channel.h +17 -0
- data/ffi/Gosu_Color.cpp +176 -0
- data/ffi/Gosu_Color.h +31 -0
- data/ffi/Gosu_Constants.cpp +334 -0
- data/ffi/Gosu_FFI.h +34 -0
- data/ffi/Gosu_FFI_internal.h +160 -0
- data/ffi/Gosu_Font.cpp +97 -0
- data/ffi/Gosu_Font.h +32 -0
- data/ffi/Gosu_Image.cpp +239 -0
- data/ffi/Gosu_Image.h +71 -0
- data/ffi/Gosu_Sample.cpp +29 -0
- data/ffi/Gosu_Sample.h +14 -0
- data/ffi/Gosu_Song.cpp +69 -0
- data/ffi/Gosu_Song.h +18 -0
- data/ffi/Gosu_TextInput.cpp +94 -0
- data/ffi/Gosu_TextInput.h +25 -0
- data/ffi/Gosu_Window.cpp +314 -0
- data/ffi/Gosu_Window.h +78 -0
- data/include/Gosu/Audio.hpp +6 -11
- data/include/Gosu/Bitmap.hpp +38 -53
- data/include/Gosu/Buffer.hpp +54 -0
- data/include/Gosu/Color.hpp +29 -36
- data/include/Gosu/Directories.hpp +25 -28
- data/include/Gosu/Drawable.hpp +58 -0
- data/include/Gosu/Font.hpp +6 -5
- data/include/Gosu/Fwd.hpp +4 -6
- data/include/Gosu/Gosu.hpp +5 -5
- data/include/Gosu/Graphics.hpp +53 -61
- data/include/Gosu/GraphicsBase.hpp +1 -11
- data/include/Gosu/Image.hpp +12 -15
- data/include/Gosu/Math.hpp +50 -72
- data/include/Gosu/Transform.hpp +32 -0
- data/include/Gosu/Utility.hpp +77 -1
- data/include/Gosu/Version.hpp +2 -2
- data/include/Gosu/Window.hpp +15 -9
- data/lib/SDL3.dll +0 -0
- data/lib/gosu/channel.rb +50 -0
- data/lib/gosu/color.rb +173 -0
- data/lib/gosu/compat.rb +130 -17
- data/lib/gosu/constants.rb +386 -0
- data/lib/gosu/ffi.rb +269 -0
- data/lib/gosu/font.rb +62 -0
- data/lib/gosu/gl_tex_info.rb +33 -0
- data/lib/gosu/gosu.rb +250 -0
- data/lib/gosu/image.rb +179 -0
- data/lib/gosu/numeric.rb +17 -0
- data/lib/gosu/preview.rb +6 -6
- data/lib/gosu/sample.rb +25 -0
- data/lib/gosu/song.rb +57 -0
- data/lib/gosu/text_input.rb +83 -0
- data/lib/gosu/window.rb +249 -0
- data/lib/gosu.rb +29 -8
- data/lib64/SDL3.dll +0 -0
- data/rdoc/gosu.rb +2 -2
- data/src/Audio.cpp +30 -24
- data/src/AudioFile.hpp +5 -4
- data/src/AudioFileAudioToolbox.cpp +8 -8
- data/src/AudioFileSDLSound.cpp +12 -15
- data/src/BinPacker.cpp +188 -0
- data/src/BinPacker.hpp +55 -0
- data/src/Bitmap.cpp +172 -143
- data/src/BitmapIO.cpp +60 -86
- data/src/Buffer.cpp +150 -0
- data/src/ClipRectStack.cpp +38 -0
- data/src/ClipRectStack.hpp +17 -83
- data/src/Color.cpp +75 -80
- data/src/Directories.cpp +47 -0
- data/src/DirectoriesUIKit.cpp +50 -0
- data/src/DrawOp.hpp +20 -18
- data/src/DrawOpQueue.hpp +27 -33
- data/src/Drawable.cpp +95 -0
- data/src/EmptyDrawable.hpp +38 -0
- data/src/FPS.cpp +31 -0
- data/src/Font.cpp +104 -74
- data/src/GosuGLView.cpp +13 -11
- data/src/GosuViewController.cpp +2 -10
- data/src/Graphics.cpp +86 -145
- data/src/GraphicsImpl.hpp +14 -68
- data/src/Image.cpp +41 -35
- data/src/Input.cpp +73 -78
- data/src/Macro.cpp +46 -29
- data/src/Macro.hpp +23 -17
- data/src/MarkupParser.cpp +5 -5
- data/src/Math.cpp +48 -22
- data/src/OffScreenTarget.cpp +47 -50
- data/src/OffScreenTarget.hpp +13 -11
- data/src/OpenGLContext.cpp +116 -0
- data/src/OpenGLContext.hpp +41 -0
- data/src/RenderState.hpp +49 -71
- data/src/Resolution.cpp +65 -53
- data/src/TexChunk.cpp +35 -80
- data/src/TexChunk.hpp +44 -35
- data/src/Text.cpp +1 -1
- data/src/TextBuilder.cpp +35 -21
- data/src/TextBuilder.hpp +6 -9
- data/src/TextInput.cpp +9 -9
- data/src/Texture.cpp +62 -80
- data/src/Texture.hpp +25 -23
- data/src/TiledDrawable.cpp +149 -0
- data/src/TiledDrawable.hpp +47 -0
- data/src/TimingApple.cpp +1 -1
- data/src/Transform.cpp +45 -50
- data/src/TransformStack.hpp +16 -16
- data/src/TrueTypeFont.cpp +59 -51
- data/src/TrueTypeFont.hpp +6 -7
- data/src/TrueTypeFontApple.cpp +28 -19
- data/src/TrueTypeFontUnix.cpp +39 -32
- data/src/TrueTypeFontWin.cpp +30 -30
- data/src/Utility.cpp +113 -37
- data/src/UtilityWin.cpp +49 -0
- data/src/Window.cpp +121 -151
- data/src/WindowUIKit.cpp +14 -14
- metadata +165 -118
- data/dependencies/SDL/include/SDL.h +0 -233
- data/dependencies/SDL/include/SDL_assert.h +0 -320
- data/dependencies/SDL/include/SDL_atomic.h +0 -415
- data/dependencies/SDL/include/SDL_audio.h +0 -1500
- data/dependencies/SDL/include/SDL_clipboard.h +0 -141
- data/dependencies/SDL/include/SDL_config.h +0 -331
- data/dependencies/SDL/include/SDL_cpuinfo.h +0 -594
- data/dependencies/SDL/include/SDL_endian.h +0 -348
- data/dependencies/SDL/include/SDL_error.h +0 -163
- data/dependencies/SDL/include/SDL_events.h +0 -1166
- data/dependencies/SDL/include/SDL_filesystem.h +0 -149
- data/dependencies/SDL/include/SDL_gamecontroller.h +0 -1074
- data/dependencies/SDL/include/SDL_gesture.h +0 -117
- data/dependencies/SDL/include/SDL_guid.h +0 -100
- data/dependencies/SDL/include/SDL_haptic.h +0 -1341
- data/dependencies/SDL/include/SDL_hidapi.h +0 -451
- data/dependencies/SDL/include/SDL_hints.h +0 -2569
- data/dependencies/SDL/include/SDL_joystick.h +0 -1066
- data/dependencies/SDL/include/SDL_keyboard.h +0 -353
- data/dependencies/SDL/include/SDL_keycode.h +0 -358
- data/dependencies/SDL/include/SDL_loadso.h +0 -115
- data/dependencies/SDL/include/SDL_log.h +0 -404
- data/dependencies/SDL/include/SDL_main.h +0 -275
- data/dependencies/SDL/include/SDL_mouse.h +0 -465
- data/dependencies/SDL/include/SDL_mutex.h +0 -471
- data/dependencies/SDL/include/SDL_name.h +0 -33
- data/dependencies/SDL/include/SDL_pixels.h +0 -644
- data/dependencies/SDL/include/SDL_platform.h +0 -261
- data/dependencies/SDL/include/SDL_quit.h +0 -58
- data/dependencies/SDL/include/SDL_rect.h +0 -376
- data/dependencies/SDL/include/SDL_render.h +0 -1919
- data/dependencies/SDL/include/SDL_revision.h +0 -7
- data/dependencies/SDL/include/SDL_rwops.h +0 -841
- data/dependencies/SDL/include/SDL_sensor.h +0 -322
- data/dependencies/SDL/include/SDL_shape.h +0 -155
- data/dependencies/SDL/include/SDL_stdinc.h +0 -830
- data/dependencies/SDL/include/SDL_surface.h +0 -997
- data/dependencies/SDL/include/SDL_system.h +0 -623
- data/dependencies/SDL/include/SDL_syswm.h +0 -386
- data/dependencies/SDL/include/SDL_test_images.h +0 -78
- data/dependencies/SDL/include/SDL_test_random.h +0 -115
- data/dependencies/SDL/include/SDL_thread.h +0 -464
- data/dependencies/SDL/include/SDL_timer.h +0 -222
- data/dependencies/SDL/include/SDL_touch.h +0 -150
- data/dependencies/SDL/include/SDL_version.h +0 -204
- data/dependencies/SDL/include/SDL_video.h +0 -2150
- data/dependencies/SDL/include/SDL_vulkan.h +0 -215
- data/dependencies/SDL/include/begin_code.h +0 -187
- data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
- data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
- data/dependencies/SDL_sound/SDL_sound.h +0 -725
- data/ext/gosu/extconf.rb +0 -119
- data/include/Gosu/IO.hpp +0 -254
- data/include/Gosu/ImageData.hpp +0 -53
- data/include/Gosu/Inspection.hpp +0 -7
- data/lib/SDL2.dll +0 -0
- data/lib/gosu/patches.rb +0 -66
- data/lib/gosu/run.rb +0 -20
- data/lib/gosu/swig_patches.rb +0 -110
- data/lib64/SDL2.dll +0 -0
- data/src/BlockAllocator.cpp +0 -131
- data/src/BlockAllocator.hpp +0 -32
- data/src/DirectoriesApple.cpp +0 -69
- data/src/DirectoriesUnix.cpp +0 -46
- data/src/DirectoriesWin.cpp +0 -65
- data/src/EmptyImageData.hpp +0 -52
- data/src/FileUnix.cpp +0 -99
- data/src/FileWin.cpp +0 -88
- data/src/IO.cpp +0 -60
- data/src/Iconv.hpp +0 -51
- data/src/Inspection.cpp +0 -27
- data/src/LargeImageData.cpp +0 -215
- data/src/LargeImageData.hpp +0 -39
- data/src/Log.hpp +0 -19
- data/src/RubyGosu.cxx +0 -13100
- data/src/RubyGosu.h +0 -49
- data/src/WinUtility.cpp +0 -61
- data/src/WinUtility.hpp +0 -27
- /data/dependencies/SDL/include/{SDL_opengles2_gl2.h → SDL3/SDL_opengles2_gl2.h} +0 -0
- /data/dependencies/SDL/include/{SDL_opengles2_gl2ext.h → SDL3/SDL_opengles2_gl2ext.h} +0 -0
- /data/dependencies/SDL/include/{SDL_opengles2_gl2platform.h → SDL3/SDL_opengles2_gl2platform.h} +0 -0
- /data/dependencies/SDL/include/{SDL_opengles2_khrplatform.h → SDL3/SDL_opengles2_khrplatform.h} +0 -0
data/lib/gosu/compat.rb
CHANGED
|
@@ -9,26 +9,36 @@ module Gosu
|
|
|
9
9
|
klass.class_eval {
|
|
10
10
|
old = "_deprecated_#{name}"
|
|
11
11
|
alias_method old, name
|
|
12
|
-
define_method name do |*args, &block|
|
|
12
|
+
define_method name do |*args, **kwargs, &block|
|
|
13
13
|
Gosu.deprecation_message(self, name, repl)
|
|
14
|
-
send old, *args, &block
|
|
14
|
+
send old, *args, **kwargs, &block
|
|
15
15
|
end
|
|
16
16
|
}
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
# The old C extension accepted options as a trailing Hash (`options = {}`).
|
|
20
|
+
# -> Convert this to keyword arguments to support e.g. `super(640, 480, options)`.
|
|
21
|
+
# Returns the args and kwargs to pass to the new method.
|
|
22
|
+
def self.extract_legacy_options(args, kwargs, method_name)
|
|
23
|
+
return args, kwargs unless kwargs.empty? and args.last.is_a?(Hash)
|
|
24
|
+
|
|
25
|
+
deprecation_message("Passing options as a Hash to #{method_name} has been deprecated, use keyword arguments instead")
|
|
26
|
+
return args[0...-1], args.last
|
|
27
|
+
end
|
|
28
|
+
|
|
19
29
|
def self.deprecation_message(klass_or_full_message, name = nil, repl = nil)
|
|
20
30
|
@@_deprecations_shown ||= {}
|
|
21
31
|
|
|
22
32
|
msg = if klass_or_full_message.is_a?(String) and name.nil? and repl.nil?
|
|
23
33
|
[ "DEPRECATION WARNING: #{klass_or_full_message},
|
|
24
|
-
\n#Called from #{caller
|
|
34
|
+
\n#Called from #{caller.reject { |line| line.start_with?(__dir__) }.first(DEPRECATION_STACKTRACE_LINES)}"
|
|
25
35
|
]
|
|
26
36
|
else
|
|
27
37
|
# Class method deprecation warnings result in something like this:
|
|
28
38
|
# #<Class:Gosu::Window>::button_id_to_char is deprecated
|
|
29
39
|
# Remove the instance-inspect stuff to make it look a bit better:
|
|
30
|
-
if klass_or_full_message.kind_of?(Module)
|
|
31
|
-
|
|
40
|
+
target = if klass_or_full_message.kind_of?(Module)
|
|
41
|
+
"#{klass_or_full_message.to_s.gsub(/#<Class:(.*)>/, '\1')}::"
|
|
32
42
|
else
|
|
33
43
|
"#{klass_or_full_message.class}#"
|
|
34
44
|
end
|
|
@@ -55,38 +65,82 @@ end
|
|
|
55
65
|
Gosu.deprecate Gosu::Color, :bgr, :none
|
|
56
66
|
Gosu.deprecate Gosu::Color, :abgr, :none
|
|
57
67
|
|
|
68
|
+
class Gosu::Color
|
|
69
|
+
alias_method :initialize_without_rgb, :initialize
|
|
70
|
+
|
|
71
|
+
# The C++ constructor Color(red, green, blue) used to be available in Ruby as well.
|
|
72
|
+
def initialize(*args)
|
|
73
|
+
if args.size == 3
|
|
74
|
+
Gosu.deprecation_message("Color.new(r, g, b) has been deprecated, use Color.rgb(r, g, b) instead")
|
|
75
|
+
initialize_without_rgb(255, *args)
|
|
76
|
+
else
|
|
77
|
+
initialize_without_rgb(*args)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
58
82
|
# No need to pass a Window to Image.
|
|
59
83
|
class Gosu::Image
|
|
60
84
|
alias_method :initialize_without_window, :initialize
|
|
61
85
|
|
|
62
|
-
def initialize(*args)
|
|
86
|
+
def initialize(*args, **kwargs)
|
|
87
|
+
args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Image#initialize")
|
|
88
|
+
|
|
63
89
|
if args[0].is_a? Gosu::Window
|
|
64
|
-
|
|
90
|
+
# Old method signature: initialize(window, file_or_image, tileable = false, *rect)
|
|
91
|
+
Gosu.deprecation_message("Passing a Window to Image#initialize has been deprecated in Gosu 0.9, and this method now uses named arguments. https://www.libgosu.org/rdoc/Gosu/Image.html")
|
|
65
92
|
if args.size == 7
|
|
66
|
-
initialize_without_window args[1], tileable: args[2], rect: args[3..-1]
|
|
93
|
+
initialize_without_window args[1], tileable: args[2], rect: args[3..-1], **kwargs
|
|
94
|
+
elsif args.size == 3
|
|
95
|
+
initialize_without_window args[1], tileable: args[2], **kwargs
|
|
96
|
+
elsif args.size == 2
|
|
97
|
+
initialize_without_window args[1], **kwargs
|
|
67
98
|
else
|
|
68
|
-
|
|
99
|
+
raise ArgumentError, "wrong number of arguments (given #{args.size})"
|
|
69
100
|
end
|
|
70
101
|
else
|
|
71
|
-
initialize_without_window(*args)
|
|
102
|
+
initialize_without_window(*args, **kwargs)
|
|
72
103
|
end
|
|
73
104
|
end
|
|
74
105
|
|
|
75
106
|
class << self
|
|
76
107
|
alias_method :from_text_without_window, :from_text
|
|
108
|
+
alias_method :from_markup_without_hash, :from_markup
|
|
109
|
+
alias_method :load_tiles_without_window, :load_tiles
|
|
77
110
|
end
|
|
78
111
|
|
|
79
|
-
def self.from_text(*args)
|
|
80
|
-
|
|
81
|
-
|
|
112
|
+
def self.from_text(*args, **kwargs)
|
|
113
|
+
args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Image.from_text")
|
|
114
|
+
|
|
115
|
+
if args.first.is_a? Gosu::Window and args.size == 4
|
|
116
|
+
# Old method signature: from_text(window, text, font_name, font_height)
|
|
117
|
+
Gosu.deprecation_message("Passing a Window to Image.from_text has been deprecated in Gosu 0.9 and this method now uses named arguments. https://www.libgosu.org/rdoc/Gosu/Image.html")
|
|
82
118
|
from_text_without_window(args[1], args[3], font: args[2])
|
|
83
|
-
elsif args.size == 7
|
|
84
|
-
|
|
119
|
+
elsif args.first.is_a? Gosu::Window and args.size == 7
|
|
120
|
+
# Old method signature: from_text(window, text, font_name, font_height, line_spacing, width, align)
|
|
121
|
+
Gosu.deprecation_message("Passing a Window to Image.from_text has been deprecated in Gosu 0.9 and this method now uses named arguments. https://www.libgosu.org/rdoc/Gosu/Image.html")
|
|
85
122
|
from_text_without_window(args[1], args[3],
|
|
86
123
|
font: args[2], spacing: args[4], width: args[5],
|
|
87
124
|
align: args[6])
|
|
88
125
|
else
|
|
89
|
-
from_text_without_window(*args)
|
|
126
|
+
from_text_without_window(*args, **kwargs)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def self.from_markup(*args, **kwargs)
|
|
131
|
+
args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Image.from_markup")
|
|
132
|
+
from_markup_without_hash(*args, **kwargs)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def self.load_tiles(*args, **kwargs)
|
|
136
|
+
args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Image.load_tiles")
|
|
137
|
+
|
|
138
|
+
if args.first.is_a? Gosu::Window
|
|
139
|
+
# Old method signature: load_tiles(window, file_or_image, w, h, tileable)
|
|
140
|
+
Gosu.deprecation_message("Passing a Window to Image.load_tiles has been deprecated in Gosu 0.9, and this method now uses named arguments. https://www.libgosu.org/rdoc/Gosu/Image.html")
|
|
141
|
+
load_tiles_without_window(args[1], args[2], args[3], tileable: args[4], **kwargs)
|
|
142
|
+
else
|
|
143
|
+
load_tiles_without_window(*args, **kwargs)
|
|
90
144
|
end
|
|
91
145
|
end
|
|
92
146
|
end
|
|
@@ -117,7 +171,23 @@ class Gosu::Song
|
|
|
117
171
|
end
|
|
118
172
|
end
|
|
119
173
|
|
|
174
|
+
# No need to pass a Window to Font.
|
|
120
175
|
class Gosu::Font
|
|
176
|
+
alias_method :initialize_without_window, :initialize
|
|
177
|
+
|
|
178
|
+
# Old method signature: Font.new(window, name, height)
|
|
179
|
+
def initialize(*args, **kwargs)
|
|
180
|
+
args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Font#initialize")
|
|
181
|
+
|
|
182
|
+
if args.first.is_a? Gosu::Window
|
|
183
|
+
Gosu.deprecation_message("Passing a Window to Font#initialize has been deprecated in Gosu 0.9.")
|
|
184
|
+
_, name, height = args
|
|
185
|
+
initialize_without_window(height, name: name, **kwargs)
|
|
186
|
+
else
|
|
187
|
+
initialize_without_window(*args, **kwargs)
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
121
191
|
alias_method :draw, :draw_markup
|
|
122
192
|
Gosu.deprecate Gosu::Font, :draw, "Font#draw_text or Font#draw_markup"
|
|
123
193
|
|
|
@@ -131,8 +201,16 @@ class Gosu::Font
|
|
|
131
201
|
Gosu.deprecate Gosu::Font, :draw_rot, "Font#draw with Gosu.rotate"
|
|
132
202
|
end
|
|
133
203
|
|
|
134
|
-
# Moved some Window methods to the Gosu module.
|
|
135
204
|
class Gosu::Window
|
|
205
|
+
alias_method :initialize_without_hash, :initialize
|
|
206
|
+
|
|
207
|
+
# Without this, an options Hash would be interpreted as the positional `fullscreen` argument.
|
|
208
|
+
def initialize(*args, **kwargs)
|
|
209
|
+
args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Window#initialize")
|
|
210
|
+
initialize_without_hash(*args, **kwargs)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# Moved some Window methods to the Gosu module:
|
|
136
214
|
# Class methods that have been turned into module methods.
|
|
137
215
|
class << self
|
|
138
216
|
def button_id_to_char(id)
|
|
@@ -154,9 +232,41 @@ class Gosu::Window
|
|
|
154
232
|
end
|
|
155
233
|
end
|
|
156
234
|
|
|
235
|
+
def set_mouse_position(x, y)
|
|
236
|
+
self.mouse_x = x
|
|
237
|
+
self.mouse_y = y
|
|
238
|
+
end
|
|
239
|
+
|
|
157
240
|
Gosu.deprecate Gosu::Window, :set_mouse_position, "Window#mouse_x= and Window#mouse_y="
|
|
158
241
|
end
|
|
159
242
|
|
|
243
|
+
module Gosu
|
|
244
|
+
alias_method :render_without_hash, :render
|
|
245
|
+
module_function :render_without_hash
|
|
246
|
+
|
|
247
|
+
module_function def render(*args, **kwargs, &block)
|
|
248
|
+
args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Gosu.render")
|
|
249
|
+
render_without_hash(*args, **kwargs, &block)
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# The SWIG-based C extension exported these functions from Math.hpp. They have users in the wild.
|
|
254
|
+
module Gosu
|
|
255
|
+
%w(degrees_to_radians radians_to_degrees).each do |helper|
|
|
256
|
+
define_method helper do |angle|
|
|
257
|
+
Gosu.deprecation_message("Gosu.#{helper}(angle) has been deprecated, use angle.#{helper} instead")
|
|
258
|
+
angle.send(helper)
|
|
259
|
+
end
|
|
260
|
+
module_function helper
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def normalize_angle(angle)
|
|
264
|
+
Gosu.deprecation_message("Gosu.normalize_angle(angle) has been deprecated, use angle % 360.0 instead")
|
|
265
|
+
angle % 360.0
|
|
266
|
+
end
|
|
267
|
+
module_function :normalize_angle
|
|
268
|
+
end
|
|
269
|
+
|
|
160
270
|
# Constants
|
|
161
271
|
module Gosu
|
|
162
272
|
# This was renamed because it's not actually a "copyright notice".
|
|
@@ -190,6 +300,9 @@ module Gosu
|
|
|
190
300
|
|
|
191
301
|
deprecate_constant :Button
|
|
192
302
|
|
|
303
|
+
# The size of the textures that Gosu uses internally (Gosu/Drawable.hpp). TexPlay relies on this.
|
|
304
|
+
MAX_TEXTURE_SIZE = 1024
|
|
305
|
+
|
|
193
306
|
def self.language
|
|
194
307
|
@language_cache ||= (user_languages.first || "en_US")
|
|
195
308
|
end
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
module GosuFFI
|
|
2
|
+
# uint32
|
|
3
|
+
constants = [
|
|
4
|
+
"KB_ESCAPE",
|
|
5
|
+
"KB_F1",
|
|
6
|
+
"KB_F2",
|
|
7
|
+
"KB_F3",
|
|
8
|
+
"KB_F4",
|
|
9
|
+
"KB_F5",
|
|
10
|
+
"KB_F6",
|
|
11
|
+
"KB_F7",
|
|
12
|
+
"KB_F8",
|
|
13
|
+
"KB_F9",
|
|
14
|
+
"KB_F10",
|
|
15
|
+
"KB_F11",
|
|
16
|
+
"KB_F12",
|
|
17
|
+
"KB_0",
|
|
18
|
+
"KB_1",
|
|
19
|
+
"KB_2",
|
|
20
|
+
"KB_3",
|
|
21
|
+
"KB_4",
|
|
22
|
+
"KB_5",
|
|
23
|
+
"KB_6",
|
|
24
|
+
"KB_7",
|
|
25
|
+
"KB_8",
|
|
26
|
+
"KB_9",
|
|
27
|
+
"KB_TAB",
|
|
28
|
+
"KB_RETURN",
|
|
29
|
+
"KB_SPACE",
|
|
30
|
+
"KB_LEFT_SHIFT",
|
|
31
|
+
"KB_RIGHT_SHIFT",
|
|
32
|
+
"KB_LEFT_CONTROL",
|
|
33
|
+
"KB_RIGHT_CONTROL",
|
|
34
|
+
"KB_LEFT_ALT",
|
|
35
|
+
"KB_RIGHT_ALT",
|
|
36
|
+
"KB_LEFT_META",
|
|
37
|
+
"KB_RIGHT_META",
|
|
38
|
+
"KB_BACKSPACE",
|
|
39
|
+
"KB_LEFT",
|
|
40
|
+
"KB_RIGHT",
|
|
41
|
+
"KB_UP",
|
|
42
|
+
"KB_DOWN",
|
|
43
|
+
"KB_HOME",
|
|
44
|
+
"KB_END",
|
|
45
|
+
"KB_PRINT_SCREEN",
|
|
46
|
+
"KB_SCROLL_LOCK",
|
|
47
|
+
"KB_PAUSE",
|
|
48
|
+
"KB_INSERT",
|
|
49
|
+
"KB_DELETE",
|
|
50
|
+
"KB_PAGE_UP",
|
|
51
|
+
"KB_PAGE_DOWN",
|
|
52
|
+
"KB_ENTER",
|
|
53
|
+
"KB_BACKTICK",
|
|
54
|
+
"KB_MINUS",
|
|
55
|
+
"KB_EQUALS",
|
|
56
|
+
"KB_LEFT_BRACKET",
|
|
57
|
+
"KB_RIGHT_BRACKET",
|
|
58
|
+
"KB_BACKSLASH",
|
|
59
|
+
"KB_SEMICOLON",
|
|
60
|
+
"KB_APOSTROPHE",
|
|
61
|
+
"KB_COMMA",
|
|
62
|
+
"KB_PERIOD",
|
|
63
|
+
"KB_SLASH",
|
|
64
|
+
"KB_CAPS_LOCK",
|
|
65
|
+
"KB_A",
|
|
66
|
+
"KB_B",
|
|
67
|
+
"KB_C",
|
|
68
|
+
"KB_D",
|
|
69
|
+
"KB_E",
|
|
70
|
+
"KB_F",
|
|
71
|
+
"KB_G",
|
|
72
|
+
"KB_H",
|
|
73
|
+
"KB_I",
|
|
74
|
+
"KB_J",
|
|
75
|
+
"KB_K",
|
|
76
|
+
"KB_L",
|
|
77
|
+
"KB_M",
|
|
78
|
+
"KB_N",
|
|
79
|
+
"KB_O",
|
|
80
|
+
"KB_P",
|
|
81
|
+
"KB_Q",
|
|
82
|
+
"KB_R",
|
|
83
|
+
"KB_S",
|
|
84
|
+
"KB_T",
|
|
85
|
+
"KB_U",
|
|
86
|
+
"KB_V",
|
|
87
|
+
"KB_W",
|
|
88
|
+
"KB_X",
|
|
89
|
+
"KB_Y",
|
|
90
|
+
"KB_Z",
|
|
91
|
+
"KB_ISO",
|
|
92
|
+
"KB_NUMPAD_0",
|
|
93
|
+
"KB_NUMPAD_1",
|
|
94
|
+
"KB_NUMPAD_2",
|
|
95
|
+
"KB_NUMPAD_3",
|
|
96
|
+
"KB_NUMPAD_4",
|
|
97
|
+
"KB_NUMPAD_5",
|
|
98
|
+
"KB_NUMPAD_6",
|
|
99
|
+
"KB_NUMPAD_7",
|
|
100
|
+
"KB_NUMPAD_8",
|
|
101
|
+
"KB_NUMPAD_9",
|
|
102
|
+
"KB_NUMPAD_DELETE",
|
|
103
|
+
"KB_NUMPAD_PLUS",
|
|
104
|
+
"KB_NUMPAD_MINUS",
|
|
105
|
+
"KB_NUMPAD_MULTIPLY",
|
|
106
|
+
"KB_NUMPAD_DIVIDE",
|
|
107
|
+
|
|
108
|
+
"MS_LEFT",
|
|
109
|
+
"MS_MIDDLE",
|
|
110
|
+
"MS_RIGHT",
|
|
111
|
+
"MS_WHEEL_UP",
|
|
112
|
+
"MS_WHEEL_DOWN",
|
|
113
|
+
"MS_OTHER_0",
|
|
114
|
+
"MS_OTHER_1",
|
|
115
|
+
"MS_OTHER_2",
|
|
116
|
+
"MS_OTHER_3",
|
|
117
|
+
"MS_OTHER_4",
|
|
118
|
+
"MS_OTHER_5",
|
|
119
|
+
"MS_OTHER_6",
|
|
120
|
+
"MS_OTHER_7",
|
|
121
|
+
|
|
122
|
+
"GP_DPAD_LEFT",
|
|
123
|
+
"GP_DPAD_RIGHT",
|
|
124
|
+
"GP_DPAD_UP",
|
|
125
|
+
"GP_DPAD_DOWN",
|
|
126
|
+
"GP_LEFT",
|
|
127
|
+
"GP_RIGHT",
|
|
128
|
+
"GP_UP",
|
|
129
|
+
"GP_DOWN",
|
|
130
|
+
"GP_BUTTON_0",
|
|
131
|
+
"GP_BUTTON_1",
|
|
132
|
+
"GP_BUTTON_2",
|
|
133
|
+
"GP_BUTTON_3",
|
|
134
|
+
"GP_BUTTON_4",
|
|
135
|
+
"GP_BUTTON_5",
|
|
136
|
+
"GP_BUTTON_6",
|
|
137
|
+
"GP_BUTTON_7",
|
|
138
|
+
"GP_BUTTON_8",
|
|
139
|
+
"GP_BUTTON_9",
|
|
140
|
+
"GP_BUTTON_10",
|
|
141
|
+
"GP_BUTTON_11",
|
|
142
|
+
"GP_BUTTON_12",
|
|
143
|
+
"GP_BUTTON_13",
|
|
144
|
+
"GP_BUTTON_14",
|
|
145
|
+
"GP_BUTTON_15",
|
|
146
|
+
|
|
147
|
+
"GP_0_DPAD_LEFT",
|
|
148
|
+
"GP_0_DPAD_RIGHT",
|
|
149
|
+
"GP_0_DPAD_UP",
|
|
150
|
+
"GP_0_DPAD_DOWN",
|
|
151
|
+
"GP_0_LEFT",
|
|
152
|
+
"GP_0_RIGHT",
|
|
153
|
+
"GP_0_UP",
|
|
154
|
+
"GP_0_DOWN",
|
|
155
|
+
"GP_0_BUTTON_0",
|
|
156
|
+
"GP_0_BUTTON_1",
|
|
157
|
+
"GP_0_BUTTON_2",
|
|
158
|
+
"GP_0_BUTTON_3",
|
|
159
|
+
"GP_0_BUTTON_4",
|
|
160
|
+
"GP_0_BUTTON_5",
|
|
161
|
+
"GP_0_BUTTON_6",
|
|
162
|
+
"GP_0_BUTTON_7",
|
|
163
|
+
"GP_0_BUTTON_8",
|
|
164
|
+
"GP_0_BUTTON_9",
|
|
165
|
+
"GP_0_BUTTON_10",
|
|
166
|
+
"GP_0_BUTTON_11",
|
|
167
|
+
"GP_0_BUTTON_12",
|
|
168
|
+
"GP_0_BUTTON_13",
|
|
169
|
+
"GP_0_BUTTON_14",
|
|
170
|
+
"GP_0_BUTTON_15",
|
|
171
|
+
|
|
172
|
+
"GP_1_DPAD_LEFT",
|
|
173
|
+
"GP_1_DPAD_RIGHT",
|
|
174
|
+
"GP_1_DPAD_UP",
|
|
175
|
+
"GP_1_DPAD_DOWN",
|
|
176
|
+
"GP_1_LEFT",
|
|
177
|
+
"GP_1_RIGHT",
|
|
178
|
+
"GP_1_UP",
|
|
179
|
+
"GP_1_DOWN",
|
|
180
|
+
"GP_1_BUTTON_0",
|
|
181
|
+
"GP_1_BUTTON_1",
|
|
182
|
+
"GP_1_BUTTON_2",
|
|
183
|
+
"GP_1_BUTTON_3",
|
|
184
|
+
"GP_1_BUTTON_4",
|
|
185
|
+
"GP_1_BUTTON_5",
|
|
186
|
+
"GP_1_BUTTON_6",
|
|
187
|
+
"GP_1_BUTTON_7",
|
|
188
|
+
"GP_1_BUTTON_8",
|
|
189
|
+
"GP_1_BUTTON_9",
|
|
190
|
+
"GP_1_BUTTON_10",
|
|
191
|
+
"GP_1_BUTTON_11",
|
|
192
|
+
"GP_1_BUTTON_12",
|
|
193
|
+
"GP_1_BUTTON_13",
|
|
194
|
+
"GP_1_BUTTON_14",
|
|
195
|
+
"GP_1_BUTTON_15",
|
|
196
|
+
|
|
197
|
+
"GP_2_DPAD_LEFT",
|
|
198
|
+
"GP_2_DPAD_RIGHT",
|
|
199
|
+
"GP_2_DPAD_UP",
|
|
200
|
+
"GP_2_DPAD_DOWN",
|
|
201
|
+
"GP_2_LEFT",
|
|
202
|
+
"GP_2_RIGHT",
|
|
203
|
+
"GP_2_UP",
|
|
204
|
+
"GP_2_DOWN",
|
|
205
|
+
"GP_2_BUTTON_0",
|
|
206
|
+
"GP_2_BUTTON_1",
|
|
207
|
+
"GP_2_BUTTON_2",
|
|
208
|
+
"GP_2_BUTTON_3",
|
|
209
|
+
"GP_2_BUTTON_4",
|
|
210
|
+
"GP_2_BUTTON_5",
|
|
211
|
+
"GP_2_BUTTON_6",
|
|
212
|
+
"GP_2_BUTTON_7",
|
|
213
|
+
"GP_2_BUTTON_8",
|
|
214
|
+
"GP_2_BUTTON_9",
|
|
215
|
+
"GP_2_BUTTON_10",
|
|
216
|
+
"GP_2_BUTTON_11",
|
|
217
|
+
"GP_2_BUTTON_12",
|
|
218
|
+
"GP_2_BUTTON_13",
|
|
219
|
+
"GP_2_BUTTON_14",
|
|
220
|
+
"GP_2_BUTTON_15",
|
|
221
|
+
|
|
222
|
+
"GP_3_DPAD_LEFT",
|
|
223
|
+
"GP_3_DPAD_RIGHT",
|
|
224
|
+
"GP_3_DPAD_UP",
|
|
225
|
+
"GP_3_DPAD_DOWN",
|
|
226
|
+
"GP_3_LEFT",
|
|
227
|
+
"GP_3_RIGHT",
|
|
228
|
+
"GP_3_UP",
|
|
229
|
+
"GP_3_DOWN",
|
|
230
|
+
"GP_3_BUTTON_0",
|
|
231
|
+
"GP_3_BUTTON_1",
|
|
232
|
+
"GP_3_BUTTON_2",
|
|
233
|
+
"GP_3_BUTTON_3",
|
|
234
|
+
"GP_3_BUTTON_4",
|
|
235
|
+
"GP_3_BUTTON_5",
|
|
236
|
+
"GP_3_BUTTON_6",
|
|
237
|
+
"GP_3_BUTTON_7",
|
|
238
|
+
"GP_3_BUTTON_8",
|
|
239
|
+
"GP_3_BUTTON_9",
|
|
240
|
+
"GP_3_BUTTON_10",
|
|
241
|
+
"GP_3_BUTTON_11",
|
|
242
|
+
"GP_3_BUTTON_12",
|
|
243
|
+
"GP_3_BUTTON_13",
|
|
244
|
+
"GP_3_BUTTON_14",
|
|
245
|
+
"GP_3_BUTTON_15",
|
|
246
|
+
|
|
247
|
+
"GP_LEFT_STICK_X_AXIS",
|
|
248
|
+
"GP_LEFT_STICK_Y_AXIS",
|
|
249
|
+
"GP_RIGHT_STICK_X_AXIS",
|
|
250
|
+
"GP_RIGHT_STICK_Y_AXIS",
|
|
251
|
+
"GP_LEFT_TRIGGER_AXIS",
|
|
252
|
+
"GP_RIGHT_TRIGGER_AXIS",
|
|
253
|
+
|
|
254
|
+
"GP_0_LEFT_STICK_X_AXIS",
|
|
255
|
+
"GP_0_LEFT_STICK_Y_AXIS",
|
|
256
|
+
"GP_0_RIGHT_STICK_X_AXIS",
|
|
257
|
+
"GP_0_RIGHT_STICK_Y_AXIS",
|
|
258
|
+
"GP_0_LEFT_TRIGGER_AXIS",
|
|
259
|
+
"GP_0_RIGHT_TRIGGER_AXIS",
|
|
260
|
+
|
|
261
|
+
"GP_1_LEFT_STICK_X_AXIS",
|
|
262
|
+
"GP_1_LEFT_STICK_Y_AXIS",
|
|
263
|
+
"GP_1_RIGHT_STICK_X_AXIS",
|
|
264
|
+
"GP_1_RIGHT_STICK_Y_AXIS",
|
|
265
|
+
"GP_1_LEFT_TRIGGER_AXIS",
|
|
266
|
+
"GP_1_RIGHT_TRIGGER_AXIS",
|
|
267
|
+
|
|
268
|
+
"GP_2_LEFT_STICK_X_AXIS",
|
|
269
|
+
"GP_2_LEFT_STICK_Y_AXIS",
|
|
270
|
+
"GP_2_RIGHT_STICK_X_AXIS",
|
|
271
|
+
"GP_2_RIGHT_STICK_Y_AXIS",
|
|
272
|
+
"GP_2_LEFT_TRIGGER_AXIS",
|
|
273
|
+
"GP_2_RIGHT_TRIGGER_AXIS",
|
|
274
|
+
|
|
275
|
+
"GP_3_LEFT_STICK_X_AXIS",
|
|
276
|
+
"GP_3_LEFT_STICK_Y_AXIS",
|
|
277
|
+
"GP_3_RIGHT_STICK_X_AXIS",
|
|
278
|
+
"GP_3_RIGHT_STICK_Y_AXIS",
|
|
279
|
+
"GP_3_LEFT_TRIGGER_AXIS",
|
|
280
|
+
"GP_3_RIGHT_TRIGGER_AXIS",
|
|
281
|
+
]
|
|
282
|
+
|
|
283
|
+
constants = constants + [
|
|
284
|
+
"MAJOR_VERSION",
|
|
285
|
+
"MINOR_VERSION",
|
|
286
|
+
"POINT_VERSION",
|
|
287
|
+
]
|
|
288
|
+
|
|
289
|
+
constants = constants + [
|
|
290
|
+
"WF_WINDOWED",
|
|
291
|
+
"WF_FULLSCREEN",
|
|
292
|
+
"WF_RESIZABLE",
|
|
293
|
+
"WF_BORDERLESS",
|
|
294
|
+
|
|
295
|
+
"BM_DEFAULT",
|
|
296
|
+
"BM_INTERPOLATE",
|
|
297
|
+
"BM_ADD",
|
|
298
|
+
"BM_MULTIPLY",
|
|
299
|
+
|
|
300
|
+
"FF_BOLD",
|
|
301
|
+
"FF_ITALIC",
|
|
302
|
+
"FF_UNDERLINE",
|
|
303
|
+
"FF_COMBINATIONS",
|
|
304
|
+
|
|
305
|
+
"AL_LEFT",
|
|
306
|
+
"AL_RIGHT",
|
|
307
|
+
"AL_CENTER",
|
|
308
|
+
"AL_JUSTIFY",
|
|
309
|
+
|
|
310
|
+
"IF_SMOOTH",
|
|
311
|
+
"IF_TILEABLE_LEFT",
|
|
312
|
+
"IF_TILEABLE_TOP",
|
|
313
|
+
"IF_TILEABLE_RIGHT",
|
|
314
|
+
"IF_TILEABLE_BOTTOM",
|
|
315
|
+
"IF_TILEABLE",
|
|
316
|
+
"IF_RETRO",
|
|
317
|
+
]
|
|
318
|
+
|
|
319
|
+
constants.each do |const|
|
|
320
|
+
attach_variable const, "Gosu_#{const}", :uint32
|
|
321
|
+
# Reading an attached variable goes through FFI every time, which is too slow for every draw call.
|
|
322
|
+
# The values never change, so read them once and store them as Ruby constants.
|
|
323
|
+
value = GosuFFI.send(const)
|
|
324
|
+
const_set(const, value)
|
|
325
|
+
Gosu.const_set(const, value) if const =~ /^(KB|MS|GP)_/
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
Gosu.const_set("VERSION", GosuFFI.Gosu_version())
|
|
329
|
+
Gosu.const_set("LICENSES", GosuFFI.Gosu_licenses())
|
|
330
|
+
Gosu.const_set("MAJOR_VERSION", MAJOR_VERSION)
|
|
331
|
+
Gosu.const_set("MINOR_VERSION", MINOR_VERSION)
|
|
332
|
+
Gosu.const_set("POINT_VERSION", POINT_VERSION)
|
|
333
|
+
|
|
334
|
+
# SEE: https://github.com/gosu/gosu/blob/master/Gosu/GraphicsBase.hpp
|
|
335
|
+
|
|
336
|
+
def self.blend_mode(mode)
|
|
337
|
+
case mode
|
|
338
|
+
when :default
|
|
339
|
+
BM_DEFAULT
|
|
340
|
+
when :additive, :add
|
|
341
|
+
BM_ADD
|
|
342
|
+
when :multiply
|
|
343
|
+
BM_MULTIPLY
|
|
344
|
+
else
|
|
345
|
+
raise ArgumentError, "No such blend mode: #{mode}"
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
def self.image_flags(retro: false, tileable: false)
|
|
350
|
+
flags = 0
|
|
351
|
+
flags |= IF_RETRO if retro
|
|
352
|
+
flags |= IF_TILEABLE if tileable
|
|
353
|
+
flags
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
def self.font_alignment_flags(flags)
|
|
357
|
+
case flags
|
|
358
|
+
when :left
|
|
359
|
+
AL_LEFT
|
|
360
|
+
when :right
|
|
361
|
+
AL_RIGHT
|
|
362
|
+
when :center
|
|
363
|
+
AL_CENTER
|
|
364
|
+
when :justify
|
|
365
|
+
AL_JUSTIFY
|
|
366
|
+
else
|
|
367
|
+
raise ArgumentError, "No such font alignment: #{flags}"
|
|
368
|
+
end
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
def self.font_flags(bold, italic, underline)
|
|
372
|
+
flags = 0
|
|
373
|
+
flags |= FF_BOLD if bold
|
|
374
|
+
flags |= FF_ITALIC if italic
|
|
375
|
+
flags |= FF_UNDERLINE if underline
|
|
376
|
+
flags
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
def self.window_flags(fullscreen: false, resizable: false, borderless: false)
|
|
380
|
+
flags = WF_WINDOWED
|
|
381
|
+
flags |= WF_FULLSCREEN if fullscreen
|
|
382
|
+
flags |= WF_RESIZABLE if resizable
|
|
383
|
+
flags |= WF_BORDERLESS if borderless
|
|
384
|
+
flags
|
|
385
|
+
end
|
|
386
|
+
end
|