Module: RbSDL2
- Extended by:
- SingleForwardable
- Defined in:
- lib/rb_sdl2.rb,
lib/rb_sdl2/sdl.rb,
lib/rb_sdl2/hint.rb,
lib/rb_sdl2/rect.rb,
lib/rb_sdl2/error.rb,
lib/rb_sdl2/timer.rb,
lib/rb_sdl2/video.rb,
lib/rb_sdl2/cursor.rb,
lib/rb_sdl2/errors.rb,
lib/rb_sdl2/display.rb,
lib/rb_sdl2/palette.rb,
lib/rb_sdl2/surface.rb,
lib/rb_sdl2/version.rb,
lib/rb_sdl2/cpu_info.rb,
lib/rb_sdl2/platform.rb,
lib/rb_sdl2/clipboard.rb,
lib/rb_sdl2/filesystem.rb,
lib/rb_sdl2/power_info.rb,
lib/rb_sdl2/text_input.rb,
lib/rb_sdl2/audio/audio.rb,
lib/rb_sdl2/event/event.rb,
lib/rb_sdl2/message_box.rb,
lib/rb_sdl2/mouse/mouse.rb,
lib/rb_sdl2/sdl_pointer.rb,
lib/rb_sdl2/display_mode.rb,
lib/rb_sdl2/window/flash.rb,
lib/rb_sdl2/window/shape.rb,
lib/rb_sdl2/window/state.rb,
lib/rb_sdl2/rw_ops/rw_ops.rb,
lib/rb_sdl2/window/window.rb,
lib/rb_sdl2/keyboard/state.rb,
lib/rb_sdl2/rw_ops/rw_file.rb,
lib/rb_sdl2/window/display.rb,
lib/rb_sdl2/window/accessor.rb,
lib/rb_sdl2/window/hit_test.rb,
lib/rb_sdl2/audio/audio_spec.rb,
lib/rb_sdl2/event/event_type.rb,
lib/rb_sdl2/rw_ops/rw_memory.rb,
lib/rb_sdl2/rw_ops/rw_object.rb,
lib/rb_sdl2/event/event_queue.rb,
lib/rb_sdl2/keyboard/keyboard.rb,
lib/rb_sdl2/mouse/mouse_class.rb,
lib/rb_sdl2/mouse/mouse_wheel.rb,
lib/rb_sdl2/pixel_format_enum.rb,
lib/rb_sdl2/ref_count_pointer.rb,
lib/rb_sdl2/audio/audio_buffer.rb,
lib/rb_sdl2/audio/audio_device.rb,
lib/rb_sdl2/event/event_filter.rb,
lib/rb_sdl2/keyboard/mod_state.rb,
lib/rb_sdl2/mouse/global_mouse.rb,
lib/rb_sdl2/mouse/mouse_button.rb,
lib/rb_sdl2/surface/blend_mode.rb,
lib/rb_sdl2/event/event_pointer.rb,
lib/rb_sdl2/mouse/relative_mouse.rb,
lib/rb_sdl2/surface/pixel_format.rb,
lib/rb_sdl2/rw_ops/rw_ops_pointer.rb,
lib/rb_sdl2/audio/audio_spec_reader.rb
Defined Under Namespace
Modules: CPUInfo, Clipboard, EventType, Filesystem, Hint, Keyboard, MessageBox, Mouse, PixelFormatEnum, Platform, SDL, TextInput, Timer, Version, Video
Classes: Audio, Cursor, Display, DisplayMode, Error, Event, EventFilter, EventPointer, EventQueue, Palette, PowerInfo, RWFile, RWMemory, RWObject, RWOps, RbSDL2Error, Rect, RefCountPointer, SDLPointer, Surface, Window
Class Method Summary
collapse
Class Method Details
.alert(message) ⇒ Object
51
|
# File 'lib/rb_sdl2.rb', line 51
def alert(message) = MessageBox.simple(0, message)
|
.confirm(message) ⇒ Object
Also known as:
confirm?
48
|
# File 'lib/rb_sdl2.rb', line 48
def confirm(message) = MessageBox.show(0, message, buttons: %w(Cancel OK), default: 1) == 1
|
.error_alert(message) ⇒ Object
.hide_cursor ⇒ Object
44
|
# File 'lib/rb_sdl2.rb', line 44
def hide_cursor = Cursor.hide
|
.info_alert(message) ⇒ Object
.load(path) ⇒ Object
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/rb_sdl2.rb', line 59
def load(path)
::SDL.load_lib(path)
at_exit { ::SDL.Quit }
::SDL.module_exec do
attach_function :SDL_AtomicAdd, [:pointer, :int], :int
attach_function :SDL_GetPreferredLocales, [], :pointer
end
end
|
.locales ⇒ Object
> [“ja”, “JP”, “en”, “US”]
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/rb_sdl2.rb', line 76
def locales
ptr = SDLPointer.new(::SDL.SDL_GetPreferredLocales)
return [] if ptr.null?
ptr_size = ::FFI::Pointer.size
a = []
until (c = ptr.read_pointer).null?
a << c.read_string
ptr += ptr_size
end
a
end
|
.loop ⇒ Object
70
71
72
73
|
# File 'lib/rb_sdl2.rb', line 70
def loop
Event.clear
yield until Event.quit?
end
|
.open_rw(obj) ⇒ Object
90
91
92
93
94
95
96
97
|
# File 'lib/rb_sdl2.rb', line 90
def open_rw(obj, ...)
case obj
when String then RWFile.open(obj, ...)
when ::FFI::Pointer then RWMemory.open(obj, ...)
when RWOps then block_given? ? yield(obj) : obj
else RWObject.open(obj, ...)
end
end
|
.open_url(url) ⇒ Object
url に与えた URL に応じたアプリケーションが起動します。 URL はローカルファイルを指定することができます。 その場合は “file:///full/path/to/file” の形式の文字列を使います。 Windows 環境では “file:///C:/full/path/to/file” のようにドライブレターも含みます。 (パス区切り文字は ‘/’ でも ‘' でも問題はない) 主な使い方としてユーザに提示したい Web サイトをブラウザーを起動して見せたい場合に使用します。 成功時にアプリケーションへのフォーカスが失われる場合もあります。 成功しても何も起きていない場合もある。確実な動作のためには実働テストを行う必要がある。 未対応の環境ではエラーになる。
108
109
110
111
|
# File 'lib/rb_sdl2.rb', line 108
def open_url(url)
err = ::SDL.OpenURL(SDL.str_to_sdl(url))
raise RbSDL2Error if err < 0
end
|
.power_info ⇒ Object
113
|
# File 'lib/rb_sdl2.rb', line 113
def power_info = PowerInfo.new
|
.show_cursor ⇒ Object
46
|
# File 'lib/rb_sdl2.rb', line 46
def show_cursor = Cursor.show
|
.warn_alert(message) ⇒ Object