gosu 1.5.0 → 2.0.0.pre6
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/dependencies/SDL/include/SDL.h +233 -0
- data/dependencies/SDL/include/SDL_assert.h +320 -0
- data/dependencies/SDL/include/SDL_atomic.h +414 -0
- data/dependencies/SDL/include/SDL_audio.h +1500 -0
- data/dependencies/SDL/include/{SDL3/SDL_bits.h → SDL_bits.h} +27 -47
- data/dependencies/SDL/include/{SDL3/SDL_blendmode.h → SDL_blendmode.h} +55 -59
- data/dependencies/SDL/include/SDL_clipboard.h +141 -0
- data/dependencies/SDL/include/SDL_config.h +331 -0
- data/dependencies/SDL/include/SDL_cpuinfo.h +594 -0
- data/dependencies/SDL/include/{SDL3/SDL_egl.h → SDL_egl.h} +8 -11
- data/dependencies/SDL/include/SDL_endian.h +348 -0
- data/dependencies/SDL/include/SDL_error.h +163 -0
- data/dependencies/SDL/include/SDL_events.h +1166 -0
- data/dependencies/SDL/include/SDL_filesystem.h +149 -0
- data/dependencies/SDL/include/SDL_gamecontroller.h +1074 -0
- data/dependencies/SDL/include/SDL_gesture.h +117 -0
- data/dependencies/SDL/include/SDL_guid.h +100 -0
- data/dependencies/SDL/include/SDL_haptic.h +1341 -0
- data/dependencies/SDL/include/SDL_hidapi.h +451 -0
- data/dependencies/SDL/include/SDL_hints.h +2613 -0
- data/dependencies/SDL/include/SDL_joystick.h +1069 -0
- data/dependencies/SDL/include/SDL_keyboard.h +353 -0
- data/dependencies/SDL/include/SDL_keycode.h +358 -0
- data/dependencies/SDL/include/SDL_loadso.h +115 -0
- data/dependencies/SDL/include/{SDL3/SDL_locale.h → SDL_locale.h} +24 -40
- data/dependencies/SDL/include/SDL_log.h +404 -0
- data/dependencies/SDL/include/SDL_main.h +282 -0
- data/dependencies/SDL/include/{SDL3/SDL_messagebox.h → SDL_messagebox.h} +48 -85
- data/dependencies/SDL/include/{SDL3/SDL_metal.h → SDL_metal.h} +29 -29
- data/dependencies/SDL/include/{SDL3/SDL_misc.h → SDL_misc.h} +12 -13
- data/dependencies/SDL/include/SDL_mouse.h +464 -0
- data/dependencies/SDL/include/SDL_mutex.h +545 -0
- data/dependencies/SDL/include/SDL_name.h +33 -0
- data/dependencies/SDL/include/{SDL3/SDL_opengl.h → SDL_opengl.h} +252 -1221
- data/dependencies/SDL/include/{SDL3/SDL_opengles.h → SDL_opengles.h} +7 -6
- data/dependencies/SDL/include/{SDL3/SDL_opengles2.h → SDL_opengles2.h} +11 -10
- data/dependencies/SDL/include/SDL_pixels.h +644 -0
- data/dependencies/SDL/include/SDL_platform.h +261 -0
- data/dependencies/SDL/include/{SDL3/SDL_power.h → SDL_power.h} +19 -40
- data/dependencies/SDL/include/SDL_quit.h +58 -0
- data/dependencies/SDL/include/SDL_rect.h +376 -0
- data/dependencies/SDL/include/SDL_render.h +1924 -0
- data/dependencies/SDL/include/SDL_revision.h +7 -0
- data/dependencies/SDL/include/SDL_rwops.h +841 -0
- data/dependencies/SDL/include/{SDL3/SDL_scancode.h → SDL_scancode.h} +68 -60
- data/dependencies/SDL/include/SDL_sensor.h +322 -0
- data/dependencies/SDL/include/SDL_shape.h +155 -0
- data/dependencies/SDL/include/SDL_stdinc.h +838 -0
- data/dependencies/SDL/include/SDL_surface.h +997 -0
- data/dependencies/SDL/include/SDL_system.h +623 -0
- data/dependencies/SDL/include/SDL_syswm.h +386 -0
- data/dependencies/SDL/include/{SDL3/SDL_test.h → SDL_test.h} +22 -16
- data/dependencies/SDL/include/{SDL3/SDL_test_assert.h → SDL_test_assert.h} +34 -27
- data/dependencies/SDL/include/{SDL3/SDL_test_common.h → SDL_test_common.h} +52 -109
- data/dependencies/SDL/include/{SDL3/SDL_test_compare.h → SDL_test_compare.h} +14 -22
- data/dependencies/SDL/include/{SDL3/SDL_test_crc32.h → SDL_test_crc32.h} +30 -27
- data/dependencies/SDL/include/{SDL3/SDL_test_font.h → SDL_test_font.h} +49 -50
- data/dependencies/SDL/include/{SDL3/SDL_test_fuzzer.h → SDL_test_fuzzer.h} +79 -64
- data/dependencies/SDL/include/{SDL3/SDL_test_harness.h → SDL_test_harness.h} +30 -47
- data/dependencies/SDL/include/SDL_test_images.h +78 -0
- data/dependencies/SDL/include/{SDL3/SDL_platform.h → SDL_test_log.h} +26 -25
- data/dependencies/SDL/include/{SDL3/SDL_test_md5.h → SDL_test_md5.h} +28 -21
- data/dependencies/SDL/include/{SDL3/SDL_test_memory.h → SDL_test_memory.h} +16 -19
- data/dependencies/SDL/include/SDL_test_random.h +115 -0
- data/dependencies/SDL/include/SDL_thread.h +464 -0
- data/dependencies/SDL/include/SDL_timer.h +222 -0
- data/dependencies/SDL/include/SDL_touch.h +150 -0
- data/dependencies/SDL/include/{SDL3/SDL_copying.h → SDL_types.h} +9 -2
- data/dependencies/SDL/include/SDL_version.h +204 -0
- data/dependencies/SDL/include/SDL_video.h +2178 -0
- data/dependencies/SDL/include/SDL_vulkan.h +215 -0
- data/dependencies/SDL/include/begin_code.h +187 -0
- data/dependencies/SDL/include/{SDL3/SDL_close_code.h → close_code.h} +6 -7
- 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.c +215 -136
- data/dependencies/SDL_sound/SDL_sound.h +725 -0
- data/dependencies/SDL_sound/SDL_sound_aiff.c +54 -55
- data/dependencies/SDL_sound/SDL_sound_au.c +32 -32
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +41 -24
- data/dependencies/SDL_sound/SDL_sound_flac.c +12 -32
- data/dependencies/SDL_sound/SDL_sound_internal.h +48 -33
- data/dependencies/SDL_sound/SDL_sound_modplug.c +29 -21
- data/dependencies/SDL_sound/SDL_sound_mp3.c +13 -35
- data/dependencies/SDL_sound/SDL_sound_raw.c +15 -14
- 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 +25 -34
- data/dependencies/SDL_sound/SDL_sound_wav.c +82 -86
- data/dependencies/SDL_sound/dr_flac.h +1281 -1845
- data/dependencies/SDL_sound/dr_mp3.h +617 -1035
- data/dependencies/SDL_sound/libmodplug/fastmix.c +1 -1
- data/dependencies/SDL_sound/libmodplug/libmodplug.h +4 -5
- data/dependencies/SDL_sound/libmodplug/load_ams.c +3 -6
- data/dependencies/SDL_sound/libmodplug/load_dsm.c +1 -2
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +2 -2
- data/dependencies/SDL_sound/libmodplug/modplug.h +1 -2
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +3 -3
- data/dependencies/SDL_sound/libmodplug/sndfile.c +0 -3
- data/dependencies/SDL_sound/libmodplug/sndmix.c +3 -7
- data/dependencies/SDL_sound/stb_vorbis.h +343 -397
- data/dependencies/mojoAL/AL/alc.h +2 -2
- data/dependencies/mojoAL/mojoal.c +1878 -2113
- data/dependencies/stb/stb_image.h +1381 -1192
- data/dependencies/stb/stb_image_write.h +129 -329
- data/dependencies/stb/stb_truetype.h +60 -304
- data/dependencies/utf8proc/utf8proc.c +75 -133
- data/dependencies/utf8proc/utf8proc.h +50 -131
- data/dependencies/utf8proc/utf8proc_data.h +15658 -16213
- data/ext/gosu-ffi/extconf.rb +28 -11
- data/ext/gosu-ffi/gosu-ffi.def +0 -3
- data/ffi/Gosu.cpp +29 -52
- data/ffi/Gosu.h +4 -4
- data/ffi/Gosu_Color.cpp +36 -80
- data/ffi/Gosu_FFI_internal.h +13 -12
- data/ffi/Gosu_Font.cpp +11 -16
- data/ffi/Gosu_Font.h +4 -4
- data/ffi/Gosu_Image.cpp +36 -69
- data/ffi/Gosu_Image.h +5 -16
- data/include/Gosu/Bitmap.hpp +1 -1
- data/include/Gosu/Color.hpp +4 -5
- data/include/Gosu/Graphics.hpp +0 -2
- data/include/Gosu/Image.hpp +1 -1
- data/include/Gosu/Math.hpp +5 -5
- data/include/Gosu/Utility.hpp +1 -27
- data/include/Gosu/Version.hpp +2 -2
- data/lib/SDL2.dll +0 -0
- data/lib/gosu/channel.rb +0 -1
- data/lib/gosu/color.rb +13 -36
- data/lib/gosu/compat.rb +14 -106
- data/lib/gosu/constants.rb +24 -24
- data/lib/gosu/ffi.rb +13 -24
- data/lib/gosu/font.rb +13 -19
- data/lib/gosu/gosu.rb +61 -101
- data/lib/gosu/image.rb +34 -72
- data/lib/gosu/sample.rb +0 -1
- data/lib/gosu/song.rb +0 -1
- data/lib/gosu/text_input.rb +1 -15
- data/lib/gosu/window.rb +10 -31
- data/lib64/SDL2.dll +0 -0
- data/rdoc/gosu.rb +0 -2
- data/src/Audio.cpp +16 -22
- data/src/AudioFileSDLSound.cpp +5 -5
- data/src/BinPacker.cpp +4 -5
- data/src/Bitmap.cpp +9 -16
- data/src/Buffer.cpp +14 -5
- data/src/ClipRectStack.hpp +83 -17
- data/src/Directories.cpp +1 -1
- data/src/DrawOp.hpp +17 -14
- data/src/DrawOpQueue.hpp +31 -25
- data/src/Font.cpp +1 -1
- data/src/GosuGLView.cpp +7 -1
- data/src/Graphics.cpp +25 -32
- data/src/GraphicsImpl.hpp +24 -0
- data/src/Image.cpp +2 -2
- data/src/Input.cpp +70 -66
- data/src/Macro.cpp +26 -43
- data/src/Macro.hpp +16 -22
- data/src/Math.cpp +7 -20
- data/src/OffScreenTarget.cpp +10 -3
- data/src/OpenGLContext.cpp +8 -7
- data/src/OpenGLContext.hpp +2 -2
- data/src/RenderState.hpp +54 -30
- data/src/Resolution.cpp +38 -48
- data/src/TexChunk.cpp +2 -2
- data/src/TextInput.cpp +9 -9
- data/src/Texture.cpp +1 -1
- data/src/TiledDrawable.cpp +7 -6
- data/src/TrueTypeFontUnix.cpp +9 -12
- data/src/Utility.cpp +26 -39
- data/src/UtilityWin.cpp +2 -6
- data/src/Window.cpp +34 -54
- metadata +93 -99
- data/dependencies/SDL/include/SDL3/SDL.h +0 -91
- data/dependencies/SDL/include/SDL3/SDL_assert.h +0 -710
- data/dependencies/SDL/include/SDL3/SDL_asyncio.h +0 -550
- data/dependencies/SDL/include/SDL3/SDL_atomic.h +0 -692
- data/dependencies/SDL/include/SDL3/SDL_audio.h +0 -2382
- data/dependencies/SDL/include/SDL3/SDL_begin_code.h +0 -553
- data/dependencies/SDL/include/SDL3/SDL_camera.h +0 -535
- data/dependencies/SDL/include/SDL3/SDL_clipboard.h +0 -331
- data/dependencies/SDL/include/SDL3/SDL_cpuinfo.h +0 -374
- data/dependencies/SDL/include/SDL3/SDL_dialog.h +0 -343
- data/dependencies/SDL/include/SDL3/SDL_dlopennote.h +0 -234
- data/dependencies/SDL/include/SDL3/SDL_endian.h +0 -645
- data/dependencies/SDL/include/SDL3/SDL_error.h +0 -226
- data/dependencies/SDL/include/SDL3/SDL_events.h +0 -1651
- data/dependencies/SDL/include/SDL3/SDL_filesystem.h +0 -537
- data/dependencies/SDL/include/SDL3/SDL_gamepad.h +0 -1657
- data/dependencies/SDL/include/SDL3/SDL_gpu.h +0 -4637
- data/dependencies/SDL/include/SDL3/SDL_guid.h +0 -106
- data/dependencies/SDL/include/SDL3/SDL_haptic.h +0 -1461
- data/dependencies/SDL/include/SDL3/SDL_hidapi.h +0 -571
- data/dependencies/SDL/include/SDL3/SDL_hints.h +0 -5041
- data/dependencies/SDL/include/SDL3/SDL_init.h +0 -508
- data/dependencies/SDL/include/SDL3/SDL_intrin.h +0 -410
- data/dependencies/SDL/include/SDL3/SDL_iostream.h +0 -1379
- data/dependencies/SDL/include/SDL3/SDL_joystick.h +0 -1385
- data/dependencies/SDL/include/SDL3/SDL_keyboard.h +0 -615
- data/dependencies/SDL/include/SDL3/SDL_keycode.h +0 -348
- data/dependencies/SDL/include/SDL3/SDL_loadso.h +0 -145
- data/dependencies/SDL/include/SDL3/SDL_log.h +0 -541
- data/dependencies/SDL/include/SDL3/SDL_main.h +0 -704
- data/dependencies/SDL/include/SDL3/SDL_main_impl.h +0 -149
- data/dependencies/SDL/include/SDL3/SDL_mouse.h +0 -813
- data/dependencies/SDL/include/SDL3/SDL_mutex.h +0 -1117
- data/dependencies/SDL/include/SDL3/SDL_oldnames.h +0 -1339
- data/dependencies/SDL/include/SDL3/SDL_pen.h +0 -198
- data/dependencies/SDL/include/SDL3/SDL_pixels.h +0 -1441
- data/dependencies/SDL/include/SDL3/SDL_platform_defines.h +0 -497
- data/dependencies/SDL/include/SDL3/SDL_process.h +0 -441
- data/dependencies/SDL/include/SDL3/SDL_properties.h +0 -572
- data/dependencies/SDL/include/SDL3/SDL_rect.h +0 -528
- data/dependencies/SDL/include/SDL3/SDL_render.h +0 -3034
- data/dependencies/SDL/include/SDL3/SDL_revision.h +0 -56
- data/dependencies/SDL/include/SDL3/SDL_sensor.h +0 -321
- data/dependencies/SDL/include/SDL3/SDL_stdinc.h +0 -6186
- data/dependencies/SDL/include/SDL3/SDL_storage.h +0 -686
- data/dependencies/SDL/include/SDL3/SDL_surface.h +0 -1769
- data/dependencies/SDL/include/SDL3/SDL_system.h +0 -840
- data/dependencies/SDL/include/SDL3/SDL_test_log.h +0 -83
- data/dependencies/SDL/include/SDL3/SDL_thread.h +0 -602
- data/dependencies/SDL/include/SDL3/SDL_time.h +0 -249
- data/dependencies/SDL/include/SDL3/SDL_timer.h +0 -454
- data/dependencies/SDL/include/SDL3/SDL_touch.h +0 -184
- data/dependencies/SDL/include/SDL3/SDL_tray.h +0 -544
- data/dependencies/SDL/include/SDL3/SDL_version.h +0 -198
- data/dependencies/SDL/include/SDL3/SDL_video.h +0 -3497
- data/dependencies/SDL/include/SDL3/SDL_vulkan.h +0 -287
- 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 +0 -755
- data/lib/SDL3.dll +0 -0
- data/lib64/SDL3.dll +0 -0
- data/src/ClipRectStack.cpp +0 -38
- /data/dependencies/SDL/include/{SDL3/SDL_opengl_glext.h → SDL_opengl_glext.h} +0 -0
- /data/dependencies/SDL/include/{SDL3/SDL_opengles2_gl2.h → SDL_opengles2_gl2.h} +0 -0
- /data/dependencies/SDL/include/{SDL3/SDL_opengles2_gl2ext.h → SDL_opengles2_gl2ext.h} +0 -0
- /data/dependencies/SDL/include/{SDL3/SDL_opengles2_gl2platform.h → SDL_opengles2_gl2platform.h} +0 -0
- /data/dependencies/SDL/include/{SDL3/SDL_opengles2_khrplatform.h → SDL_opengles2_khrplatform.h} +0 -0
data/lib/gosu/compat.rb
CHANGED
|
@@ -9,36 +9,26 @@ module Gosu
|
|
|
9
9
|
klass.class_eval {
|
|
10
10
|
old = "_deprecated_#{name}"
|
|
11
11
|
alias_method old, name
|
|
12
|
-
define_method name do |*args,
|
|
12
|
+
define_method name do |*args, &block|
|
|
13
13
|
Gosu.deprecation_message(self, name, repl)
|
|
14
|
-
send old, *args,
|
|
14
|
+
send old, *args, &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
|
-
|
|
29
19
|
def self.deprecation_message(klass_or_full_message, name = nil, repl = nil)
|
|
30
20
|
@@_deprecations_shown ||= {}
|
|
31
21
|
|
|
32
22
|
msg = if klass_or_full_message.is_a?(String) and name.nil? and repl.nil?
|
|
33
23
|
[ "DEPRECATION WARNING: #{klass_or_full_message},
|
|
34
|
-
\n#Called from #{caller
|
|
24
|
+
\n#Called from #{caller[1, DEPRECATION_STACKTRACE_LINES]}"
|
|
35
25
|
]
|
|
36
26
|
else
|
|
37
27
|
# Class method deprecation warnings result in something like this:
|
|
38
28
|
# #<Class:Gosu::Window>::button_id_to_char is deprecated
|
|
39
29
|
# Remove the instance-inspect stuff to make it look a bit better:
|
|
40
|
-
|
|
41
|
-
"#{klass_or_full_message.to_s.gsub(/#<Class:(.*)>/, '\1')}::"
|
|
30
|
+
if klass_or_full_message.kind_of?(Module)
|
|
31
|
+
target = "#{klass_or_full_message.to_s.gsub(/#<Class:(.*)>/, '\1')}::"
|
|
42
32
|
else
|
|
43
33
|
"#{klass_or_full_message.class}#"
|
|
44
34
|
end
|
|
@@ -65,36 +55,18 @@ end
|
|
|
65
55
|
Gosu.deprecate Gosu::Color, :bgr, :none
|
|
66
56
|
Gosu.deprecate Gosu::Color, :abgr, :none
|
|
67
57
|
|
|
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
|
-
|
|
82
58
|
# No need to pass a Window to Image.
|
|
83
59
|
class Gosu::Image
|
|
84
60
|
alias_method :initialize_without_window, :initialize
|
|
85
61
|
|
|
86
62
|
def initialize(*args, **kwargs)
|
|
87
|
-
args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Image#initialize")
|
|
88
|
-
|
|
89
63
|
if args[0].is_a? Gosu::Window
|
|
90
|
-
# Old method signature: initialize(window, file_or_image, tileable
|
|
64
|
+
# Old method signature: initialize(window, file_or_image, tileable)
|
|
91
65
|
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")
|
|
92
66
|
if args.size == 7
|
|
93
|
-
initialize_without_window args[1], tileable: args[2], rect: args[3..-1]
|
|
67
|
+
initialize_without_window args[1], tileable: args[2], rect: args[3..-1]
|
|
94
68
|
elsif args.size == 3
|
|
95
|
-
initialize_without_window args[1], tileable: args[2]
|
|
96
|
-
elsif args.size == 2
|
|
97
|
-
initialize_without_window args[1], **kwargs
|
|
69
|
+
initialize_without_window args[1], tileable: args[2]
|
|
98
70
|
else
|
|
99
71
|
raise ArgumentError, "wrong number of arguments (given #{args.size})"
|
|
100
72
|
end
|
|
@@ -105,19 +77,13 @@ class Gosu::Image
|
|
|
105
77
|
|
|
106
78
|
class << self
|
|
107
79
|
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
|
|
110
80
|
end
|
|
111
81
|
|
|
112
82
|
def self.from_text(*args, **kwargs)
|
|
113
|
-
args
|
|
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)
|
|
83
|
+
if args.size == 4
|
|
117
84
|
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")
|
|
118
85
|
from_text_without_window(args[1], args[3], font: args[2])
|
|
119
|
-
elsif args.
|
|
120
|
-
# Old method signature: from_text(window, text, font_name, font_height, line_spacing, width, align)
|
|
86
|
+
elsif args.size == 7
|
|
121
87
|
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")
|
|
122
88
|
from_text_without_window(args[1], args[3],
|
|
123
89
|
font: args[2], spacing: args[4], width: args[5],
|
|
@@ -127,18 +93,14 @@ class Gosu::Image
|
|
|
127
93
|
end
|
|
128
94
|
end
|
|
129
95
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
from_markup_without_hash(*args, **kwargs)
|
|
96
|
+
class << self
|
|
97
|
+
alias_method :load_tiles_without_window, :load_tiles
|
|
133
98
|
end
|
|
134
99
|
|
|
135
100
|
def self.load_tiles(*args, **kwargs)
|
|
136
|
-
args, kwargs = Gosu.extract_legacy_options(args, kwargs, "Image.load_tiles")
|
|
137
|
-
|
|
138
101
|
if args.first.is_a? Gosu::Window
|
|
139
102
|
# Old method signature: load_tiles(window, file_or_image, w, h, tileable)
|
|
140
|
-
|
|
141
|
-
load_tiles_without_window(args[1], args[2], args[3], tileable: args[4], **kwargs)
|
|
103
|
+
load_tiles_without_window(args[1], args[2], args[3], tileable: args[4])
|
|
142
104
|
else
|
|
143
105
|
load_tiles_without_window(*args, **kwargs)
|
|
144
106
|
end
|
|
@@ -171,23 +133,7 @@ class Gosu::Song
|
|
|
171
133
|
end
|
|
172
134
|
end
|
|
173
135
|
|
|
174
|
-
# No need to pass a Window to Font.
|
|
175
136
|
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
|
-
|
|
191
137
|
alias_method :draw, :draw_markup
|
|
192
138
|
Gosu.deprecate Gosu::Font, :draw, "Font#draw_text or Font#draw_markup"
|
|
193
139
|
|
|
@@ -201,16 +147,8 @@ class Gosu::Font
|
|
|
201
147
|
Gosu.deprecate Gosu::Font, :draw_rot, "Font#draw with Gosu.rotate"
|
|
202
148
|
end
|
|
203
149
|
|
|
150
|
+
# Moved some Window methods to the Gosu module.
|
|
204
151
|
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:
|
|
214
152
|
# Class methods that have been turned into module methods.
|
|
215
153
|
class << self
|
|
216
154
|
def button_id_to_char(id)
|
|
@@ -240,33 +178,6 @@ class Gosu::Window
|
|
|
240
178
|
Gosu.deprecate Gosu::Window, :set_mouse_position, "Window#mouse_x= and Window#mouse_y="
|
|
241
179
|
end
|
|
242
180
|
|
|
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
|
-
|
|
270
181
|
# Constants
|
|
271
182
|
module Gosu
|
|
272
183
|
# This was renamed because it's not actually a "copyright notice".
|
|
@@ -300,9 +211,6 @@ module Gosu
|
|
|
300
211
|
|
|
301
212
|
deprecate_constant :Button
|
|
302
213
|
|
|
303
|
-
# The size of the textures that Gosu uses internally (Gosu/Drawable.hpp). TexPlay relies on this.
|
|
304
|
-
MAX_TEXTURE_SIZE = 1024
|
|
305
|
-
|
|
306
214
|
def self.language
|
|
307
215
|
@language_cache ||= (user_languages.first || "en_US")
|
|
308
216
|
end
|
data/lib/gosu/constants.rb
CHANGED
|
@@ -318,29 +318,27 @@ module GosuFFI
|
|
|
318
318
|
|
|
319
319
|
constants.each do |const|
|
|
320
320
|
attach_variable const, "Gosu_#{const}", :uint32
|
|
321
|
-
|
|
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)_/
|
|
321
|
+
Gosu.const_set(const, GosuFFI.send(const)) if const =~ /^(KB|MS|GP)_/
|
|
326
322
|
end
|
|
327
323
|
|
|
328
324
|
Gosu.const_set("VERSION", GosuFFI.Gosu_version())
|
|
329
325
|
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)
|
|
326
|
+
Gosu.const_set("MAJOR_VERSION", GosuFFI.MAJOR_VERSION)
|
|
327
|
+
Gosu.const_set("MINOR_VERSION", GosuFFI.MINOR_VERSION)
|
|
328
|
+
Gosu.const_set("POINT_VERSION", GosuFFI.POINT_VERSION)
|
|
333
329
|
|
|
334
330
|
# SEE: https://github.com/gosu/gosu/blob/master/Gosu/GraphicsBase.hpp
|
|
335
331
|
|
|
336
332
|
def self.blend_mode(mode)
|
|
337
333
|
case mode
|
|
338
334
|
when :default
|
|
339
|
-
BM_DEFAULT
|
|
335
|
+
GosuFFI.BM_DEFAULT
|
|
340
336
|
when :additive, :add
|
|
341
|
-
BM_ADD
|
|
337
|
+
GosuFFI.BM_ADD
|
|
342
338
|
when :multiply
|
|
343
|
-
BM_MULTIPLY
|
|
339
|
+
GosuFFI.BM_MULTIPLY
|
|
340
|
+
when Numeric
|
|
341
|
+
mode
|
|
344
342
|
else
|
|
345
343
|
raise ArgumentError, "No such blend mode: #{mode}"
|
|
346
344
|
end
|
|
@@ -348,21 +346,23 @@ module GosuFFI
|
|
|
348
346
|
|
|
349
347
|
def self.image_flags(retro: false, tileable: false)
|
|
350
348
|
flags = 0
|
|
351
|
-
flags |= IF_RETRO if retro
|
|
352
|
-
flags |= IF_TILEABLE if tileable
|
|
349
|
+
flags |= GosuFFI.IF_RETRO if retro
|
|
350
|
+
flags |= GosuFFI.IF_TILEABLE if tileable
|
|
353
351
|
flags
|
|
354
352
|
end
|
|
355
353
|
|
|
356
354
|
def self.font_alignment_flags(flags)
|
|
357
355
|
case flags
|
|
358
356
|
when :left
|
|
359
|
-
AL_LEFT
|
|
357
|
+
GosuFFI.AL_LEFT
|
|
360
358
|
when :right
|
|
361
|
-
AL_RIGHT
|
|
359
|
+
GosuFFI.AL_RIGHT
|
|
362
360
|
when :center
|
|
363
|
-
AL_CENTER
|
|
361
|
+
GosuFFI.AL_CENTER
|
|
364
362
|
when :justify
|
|
365
|
-
AL_JUSTIFY
|
|
363
|
+
GosuFFI.AL_JUSTIFY
|
|
364
|
+
when Numeric
|
|
365
|
+
flags
|
|
366
366
|
else
|
|
367
367
|
raise ArgumentError, "No such font alignment: #{flags}"
|
|
368
368
|
end
|
|
@@ -370,17 +370,17 @@ module GosuFFI
|
|
|
370
370
|
|
|
371
371
|
def self.font_flags(bold, italic, underline)
|
|
372
372
|
flags = 0
|
|
373
|
-
flags |= FF_BOLD if bold
|
|
374
|
-
flags |= FF_ITALIC if italic
|
|
375
|
-
flags |= FF_UNDERLINE if underline
|
|
373
|
+
flags |= GosuFFI.FF_BOLD if bold
|
|
374
|
+
flags |= GosuFFI.FF_ITALIC if italic
|
|
375
|
+
flags |= GosuFFI.FF_UNDERLINE if underline
|
|
376
376
|
flags
|
|
377
377
|
end
|
|
378
378
|
|
|
379
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
|
|
380
|
+
flags = GosuFFI.WF_WINDOWED
|
|
381
|
+
flags |= GosuFFI.WF_FULLSCREEN if fullscreen
|
|
382
|
+
flags |= GosuFFI.WF_RESIZABLE if resizable
|
|
383
|
+
flags |= GosuFFI.WF_BORDERLESS if borderless
|
|
384
384
|
flags
|
|
385
385
|
end
|
|
386
386
|
end
|
data/lib/gosu/ffi.rb
CHANGED
|
@@ -23,7 +23,7 @@ module GosuFFI
|
|
|
23
23
|
|
|
24
24
|
attach_function :Gosu_fps, [], :int
|
|
25
25
|
attach_function :Gosu_flush, [], :void
|
|
26
|
-
attach_function :Gosu_milliseconds, [], :
|
|
26
|
+
attach_function :Gosu_milliseconds, [], :long
|
|
27
27
|
attach_function :Gosu_default_font_name, [], :string
|
|
28
28
|
attach_function :Gosu_user_languages, [:_callback_with_string, :pointer], :void
|
|
29
29
|
|
|
@@ -50,12 +50,12 @@ module GosuFFI
|
|
|
50
50
|
attach_function :Gosu_clipboard, [], :string
|
|
51
51
|
attach_function :Gosu_set_clipboard, [:string], :void
|
|
52
52
|
|
|
53
|
-
attach_function :Gosu_draw_line, [:double, :double, :uint32, :double, :double, :uint32, :double, :uint32], :
|
|
53
|
+
attach_function :Gosu_draw_line, [:double, :double, :uint32, :double, :double, :uint32, :double, :uint32], :void
|
|
54
54
|
attach_function :Gosu_draw_triangle, [:double, :double, :uint32, :double, :double, :uint32,
|
|
55
|
-
:double, :double, :uint32, :double, :uint32], :
|
|
55
|
+
:double, :double, :uint32, :double, :uint32], :void
|
|
56
56
|
attach_function :Gosu_draw_quad, [:double, :double, :uint32, :double, :double, :uint32,
|
|
57
|
-
:double, :double, :uint32, :double, :double, :uint32, :double, :uint32], :
|
|
58
|
-
attach_function :Gosu_draw_rect, [:double, :double, :double, :double, :uint32, :double, :uint32], :
|
|
57
|
+
:double, :double, :uint32, :double, :double, :uint32, :double, :uint32], :void
|
|
58
|
+
attach_function :Gosu_draw_rect, [:double, :double, :double, :double, :uint32, :double, :uint32], :void
|
|
59
59
|
|
|
60
60
|
attach_function :Gosu_offset_x, [:double, :double], :double
|
|
61
61
|
attach_function :Gosu_offset_y, [:double, :double], :double
|
|
@@ -122,24 +122,23 @@ module GosuFFI
|
|
|
122
122
|
attach_function :Gosu_Font_markup_width, [:pointer, :string], :double
|
|
123
123
|
|
|
124
124
|
attach_function :Gosu_Font_draw_text, [:pointer, :string, :double, :double, :double,
|
|
125
|
-
:double, :double, :uint32, :uint32], :
|
|
125
|
+
:double, :double, :uint32, :uint32], :void
|
|
126
126
|
attach_function :Gosu_Font_draw_markup, [:pointer, :string, :double, :double, :double,
|
|
127
|
-
:double, :double, :uint32, :uint32], :
|
|
127
|
+
:double, :double, :uint32, :uint32], :void
|
|
128
128
|
|
|
129
129
|
attach_function :Gosu_Font_draw_text_rel, [:pointer, :string, :double, :double, :double,
|
|
130
|
-
:double, :double, :double, :double, :uint32, :uint32], :
|
|
130
|
+
:double, :double, :double, :double, :uint32, :uint32], :void
|
|
131
131
|
attach_function :Gosu_Font_draw_markup_rel, [:pointer, :string, :double, :double, :double,
|
|
132
|
-
:double, :double, :double, :double, :uint32, :uint32], :
|
|
132
|
+
:double, :double, :double, :double, :uint32, :uint32], :void
|
|
133
133
|
|
|
134
134
|
attach_function :Gosu_Font_set_image, [:pointer, :string, :uint32, :pointer], :void
|
|
135
135
|
|
|
136
136
|
attach_function :Gosu_Image_create, [:string, :uint32], :pointer
|
|
137
|
-
attach_function :Gosu_Image_create_from_rect, [:string, :int, :int, :int, :int, :uint32], :pointer
|
|
138
137
|
attach_function :Gosu_Image_destroy, [:pointer], :void
|
|
139
138
|
|
|
140
139
|
attach_function :Gosu_Image_create_from_markup, [:string, :string, :double, :int, :double, :uint32, :uint32, :uint32], :pointer
|
|
141
140
|
attach_function :Gosu_Image_create_from_text, [:string, :string, :double, :int, :double, :uint32, :uint32, :uint32], :pointer
|
|
142
|
-
attach_function :Gosu_Image_create_from_blob, [:pointer, :
|
|
141
|
+
attach_function :Gosu_Image_create_from_blob, [:pointer, :ulong, :int, :int, :uint32], :pointer
|
|
143
142
|
attach_function :Gosu_Image_create_from_subimage, [:pointer, :int, :int, :int, :int], :pointer
|
|
144
143
|
attach_function :Gosu_Image_create_from_tiles, [:string, :int, :int, :_callback_with_image, :pointer, :uint32], :void
|
|
145
144
|
attach_function :Gosu_Image_create_tiles_from_image, [:pointer, :int, :int, :_callback_with_image, :pointer, :uint32], :void
|
|
@@ -147,13 +146,11 @@ module GosuFFI
|
|
|
147
146
|
attach_function :Gosu_Image_width, [:pointer], :int
|
|
148
147
|
attach_function :Gosu_Image_height, [:pointer], :int
|
|
149
148
|
|
|
150
|
-
attach_function :Gosu_Image_draw, [:pointer, :double, :double, :double, :double, :double, :uint32, :uint32], :
|
|
151
|
-
attach_function :Gosu_Image_draw_quick, [:pointer, :double, :double, :double], :bool
|
|
149
|
+
attach_function :Gosu_Image_draw, [:pointer, :double, :double, :double, :double, :double, :uint32, :uint32], :void
|
|
152
150
|
attach_function :Gosu_Image_draw_rot, [:pointer, :double, :double, :double, :double, :double, :double,
|
|
153
|
-
:double, :double, :uint32, :uint32], :
|
|
154
|
-
attach_function :Gosu_Image_draw_rot_quick, [:pointer, :double, :double, :double, :double], :bool
|
|
151
|
+
:double, :double, :uint32, :uint32], :void
|
|
155
152
|
attach_function :Gosu_Image_draw_as_quad, [:pointer, :double, :double, :uint32, :double, :double, :uint32,
|
|
156
|
-
:double, :double, :uint32, :double, :double, :uint32, :double, :uint32], :
|
|
153
|
+
:double, :double, :uint32, :double, :double, :uint32, :double, :uint32], :void
|
|
157
154
|
|
|
158
155
|
attach_function :Gosu_Image_save, [:pointer, :string], :void
|
|
159
156
|
attach_function :Gosu_Image_to_blob, [:pointer], :pointer
|
|
@@ -258,12 +255,4 @@ module GosuFFI
|
|
|
258
255
|
end
|
|
259
256
|
value
|
|
260
257
|
end
|
|
261
|
-
|
|
262
|
-
# Raises and forgets the first exception from a block passed to Gosu.gl(z), see Gosu.gl.
|
|
263
|
-
def self.check_last_gl_error
|
|
264
|
-
if (err = $gosu_gl_exception)
|
|
265
|
-
$gosu_gl_exception = nil
|
|
266
|
-
raise err
|
|
267
|
-
end
|
|
268
|
-
end
|
|
269
258
|
end
|
data/lib/gosu/font.rb
CHANGED
|
@@ -4,7 +4,6 @@ module Gosu
|
|
|
4
4
|
__font = GosuFFI.Gosu_Font_create(height, name, GosuFFI.font_flags(bold, italic, underline), 0)
|
|
5
5
|
GosuFFI.check_last_error
|
|
6
6
|
@memory_pointer = FFI::AutoPointer.new(__font, GosuFFI.method(:Gosu_Font_destroy))
|
|
7
|
-
self
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
def __pointer
|
|
@@ -16,40 +15,35 @@ module Gosu
|
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
def height
|
|
19
|
-
|
|
20
|
-
@height ||= GosuFFI.check_last_error(GosuFFI.Gosu_Font_height(__pointer))
|
|
18
|
+
GosuFFI.check_last_error(GosuFFI.Gosu_Font_height(__pointer))
|
|
21
19
|
end
|
|
22
20
|
|
|
23
21
|
def text_width(text, scale_x = 1)
|
|
24
22
|
GosuFFI.check_last_error(GosuFFI.Gosu_Font_text_width(__pointer, text.to_s)) * scale_x
|
|
25
23
|
end
|
|
26
24
|
|
|
27
|
-
def markup_width(
|
|
28
|
-
GosuFFI.check_last_error(GosuFFI.Gosu_Font_markup_width(__pointer,
|
|
25
|
+
def markup_width(text, scale_x = 1)
|
|
26
|
+
GosuFFI.check_last_error(GosuFFI.Gosu_Font_markup_width(__pointer, text.to_s)) * scale_x
|
|
29
27
|
end
|
|
30
28
|
|
|
31
29
|
def draw_text(text, x, y, z, scale_x = 1, scale_y = 1, c = Gosu::Color::WHITE, mode = :default)
|
|
32
|
-
GosuFFI.
|
|
33
|
-
|
|
34
|
-
GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
|
|
30
|
+
GosuFFI.Gosu_Font_draw_text(__pointer, text.to_s, x, y, z, scale_x, scale_y, GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
|
|
31
|
+
GosuFFI.check_last_error
|
|
35
32
|
end
|
|
36
33
|
|
|
37
|
-
def draw_markup(
|
|
38
|
-
GosuFFI.
|
|
39
|
-
|
|
40
|
-
GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
|
|
34
|
+
def draw_markup(text, x, y, z, scale_x = 1, scale_y = 1, c = Gosu::Color::WHITE, mode = :default)
|
|
35
|
+
GosuFFI.Gosu_Font_draw_markup(__pointer, text.to_s, x, y, z, scale_x, scale_y, GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
|
|
36
|
+
GosuFFI.check_last_error
|
|
41
37
|
end
|
|
42
38
|
|
|
43
39
|
def draw_text_rel(text, x, y, z, rel_x, rel_y, scale_x = 1, scale_y = 1, c = Gosu::Color::WHITE, mode = :default)
|
|
44
|
-
GosuFFI.
|
|
45
|
-
|
|
46
|
-
GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
|
|
40
|
+
GosuFFI.Gosu_Font_draw_text_rel(__pointer, text.to_s, x, y, z, rel_x, rel_y, scale_x, scale_y, GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
|
|
41
|
+
GosuFFI.check_last_error
|
|
47
42
|
end
|
|
48
43
|
|
|
49
|
-
def draw_markup_rel(
|
|
50
|
-
GosuFFI.
|
|
51
|
-
|
|
52
|
-
GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
|
|
44
|
+
def draw_markup_rel(text, x, y, z, rel_x, rel_y, scale_x = 1, scale_y = 1, c = Gosu::Color::WHITE, mode = :default)
|
|
45
|
+
GosuFFI.Gosu_Font_draw_markup_rel(__pointer, text.to_s, x, y, z, rel_x, rel_y, scale_x, scale_y, GosuFFI.color_to_uint32(c), GosuFFI.blend_mode(mode))
|
|
46
|
+
GosuFFI.check_last_error
|
|
53
47
|
end
|
|
54
48
|
|
|
55
49
|
def []=(codepoint, image)
|