gosu 1.1.1.1 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dependencies/SDL/include/SDL.h +108 -14
- data/dependencies/SDL/include/SDL_assert.h +81 -50
- data/dependencies/SDL/include/SDL_atomic.h +135 -35
- data/dependencies/SDL/include/SDL_audio.h +960 -355
- data/dependencies/SDL/include/SDL_bits.h +11 -6
- data/dependencies/SDL/include/SDL_blendmode.h +91 -14
- data/dependencies/SDL/include/SDL_clipboard.h +30 -7
- data/dependencies/SDL/include/SDL_config.h +277 -27
- data/dependencies/SDL/include/SDL_config_android.h +13 -38
- data/dependencies/SDL/include/SDL_config_iphoneos.h +21 -62
- data/dependencies/SDL/include/SDL_config_macosx.h +23 -92
- data/dependencies/SDL/include/SDL_config_minimal.h +1 -4
- data/dependencies/SDL/include/SDL_config_pandora.h +15 -22
- data/dependencies/SDL/include/SDL_config_psp.h +16 -37
- data/dependencies/SDL/include/SDL_config_windows.h +28 -91
- data/dependencies/SDL/include/SDL_config_winrt.h +33 -61
- data/dependencies/SDL/include/SDL_config_wiz.h +28 -56
- data/dependencies/SDL/include/SDL_copying.h +1 -1
- data/dependencies/SDL/include/SDL_cpuinfo.h +331 -71
- data/dependencies/SDL/include/SDL_egl.h +906 -280
- data/dependencies/SDL/include/SDL_endian.h +101 -47
- data/dependencies/SDL/include/SDL_error.h +70 -19
- data/dependencies/SDL/include/SDL_events.h +387 -79
- data/dependencies/SDL/include/SDL_filesystem.h +73 -64
- data/dependencies/SDL/include/SDL_gamecontroller.h +585 -125
- data/dependencies/SDL/include/SDL_gesture.h +36 -6
- data/dependencies/SDL/include/SDL_haptic.h +304 -210
- data/dependencies/SDL/include/SDL_hidapi.h +451 -0
- data/dependencies/SDL/include/SDL_hints.h +1286 -897
- data/dependencies/SDL/include/SDL_joystick.h +577 -130
- data/dependencies/SDL/include/SDL_keyboard.h +162 -63
- data/dependencies/SDL/include/SDL_keycode.h +7 -5
- data/dependencies/SDL/include/SDL_loadso.h +42 -8
- data/dependencies/SDL/include/SDL_locale.h +34 -32
- data/dependencies/SDL/include/SDL_log.h +212 -19
- data/dependencies/SDL/include/SDL_main.h +72 -17
- data/dependencies/SDL/include/SDL_messagebox.h +70 -23
- data/dependencies/SDL/include/SDL_metal.h +27 -32
- data/dependencies/SDL/include/SDL_misc.h +19 -15
- data/dependencies/SDL/include/SDL_mouse.h +262 -110
- data/dependencies/SDL/include/SDL_mutex.h +286 -66
- data/dependencies/SDL/include/SDL_name.h +1 -1
- data/dependencies/SDL/include/SDL_opengl.h +1 -1
- data/dependencies/SDL/include/SDL_opengles.h +1 -1
- data/dependencies/SDL/include/SDL_opengles2.h +2 -2
- data/dependencies/SDL/include/SDL_pixels.h +199 -34
- data/dependencies/SDL/include/SDL_platform.h +39 -2
- data/dependencies/SDL/include/SDL_power.h +23 -10
- data/dependencies/SDL/include/SDL_quit.h +1 -1
- data/dependencies/SDL/include/SDL_rect.h +78 -28
- data/dependencies/SDL/include/SDL_render.h +1204 -472
- data/dependencies/SDL/include/SDL_revision.h +2 -2
- data/dependencies/SDL/include/SDL_rwops.h +605 -33
- data/dependencies/SDL/include/SDL_scancode.h +1 -1
- data/dependencies/SDL/include/SDL_sensor.h +76 -42
- data/dependencies/SDL/include/SDL_shape.h +38 -27
- data/dependencies/SDL/include/SDL_stdinc.h +96 -24
- data/dependencies/SDL/include/SDL_surface.h +571 -139
- data/dependencies/SDL/include/SDL_system.h +339 -101
- data/dependencies/SDL/include/SDL_syswm.h +50 -20
- data/dependencies/SDL/include/SDL_test.h +1 -1
- data/dependencies/SDL/include/SDL_test_assert.h +2 -2
- data/dependencies/SDL/include/SDL_test_common.h +23 -6
- data/dependencies/SDL/include/SDL_test_compare.h +1 -1
- data/dependencies/SDL/include/SDL_test_crc32.h +1 -1
- data/dependencies/SDL/include/SDL_test_font.h +3 -3
- data/dependencies/SDL/include/SDL_test_fuzzer.h +28 -26
- data/dependencies/SDL/include/SDL_test_harness.h +6 -6
- data/dependencies/SDL/include/SDL_test_images.h +1 -1
- data/dependencies/SDL/include/SDL_test_log.h +1 -1
- data/dependencies/SDL/include/SDL_test_md5.h +1 -1
- data/dependencies/SDL/include/SDL_test_memory.h +1 -1
- data/dependencies/SDL/include/SDL_test_random.h +2 -2
- data/dependencies/SDL/include/SDL_thread.h +226 -128
- data/dependencies/SDL/include/SDL_timer.h +129 -22
- data/dependencies/SDL/include/SDL_touch.h +48 -8
- data/dependencies/SDL/include/SDL_types.h +1 -1
- data/dependencies/SDL/include/SDL_version.h +72 -46
- data/dependencies/SDL/include/SDL_video.h +1266 -460
- data/dependencies/SDL/include/SDL_vulkan.h +100 -161
- data/dependencies/SDL/include/begin_code.h +22 -1
- data/dependencies/SDL/include/close_code.h +1 -1
- 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 +83 -7
- data/dependencies/SDL_sound/SDL_sound.h +4 -4
- data/dependencies/SDL_sound/SDL_sound_aiff.c +9 -12
- data/dependencies/SDL_sound/SDL_sound_au.c +7 -7
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +3 -3
- data/dependencies/SDL_sound/SDL_sound_flac.c +1 -1
- data/dependencies/SDL_sound/SDL_sound_internal.h +17 -10
- data/dependencies/SDL_sound/SDL_sound_modplug.c +25 -27
- data/dependencies/SDL_sound/SDL_sound_mp3.c +5 -17
- data/dependencies/SDL_sound/SDL_sound_raw.c +11 -11
- data/dependencies/SDL_sound/SDL_sound_shn.c +8 -7
- data/dependencies/SDL_sound/SDL_sound_voc.c +6 -4
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +6 -11
- data/dependencies/SDL_sound/SDL_sound_wav.c +35 -29
- data/dependencies/SDL_sound/dr_flac.h +618 -220
- data/dependencies/SDL_sound/dr_mp3.h +263 -94
- data/dependencies/SDL_sound/libmodplug/fastmix.c +58 -64
- data/dependencies/SDL_sound/libmodplug/libmodplug.h +25 -103
- data/dependencies/SDL_sound/libmodplug/load_669.c +14 -17
- data/dependencies/SDL_sound/libmodplug/load_amf.c +11 -7
- data/dependencies/SDL_sound/libmodplug/load_ams.c +65 -22
- data/dependencies/SDL_sound/libmodplug/load_dbm.c +8 -4
- data/dependencies/SDL_sound/libmodplug/load_dmf.c +55 -25
- data/dependencies/SDL_sound/libmodplug/load_far.c +9 -13
- data/dependencies/SDL_sound/libmodplug/load_gdm.c +448 -0
- data/dependencies/SDL_sound/libmodplug/load_it.c +45 -49
- data/dependencies/SDL_sound/libmodplug/load_mdl.c +80 -53
- data/dependencies/SDL_sound/libmodplug/load_med.c +20 -12
- data/dependencies/SDL_sound/libmodplug/load_mod.c +40 -15
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +29 -17
- data/dependencies/SDL_sound/libmodplug/load_okt.c +12 -8
- data/dependencies/SDL_sound/libmodplug/load_psm.c +101 -78
- data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -17
- data/dependencies/SDL_sound/libmodplug/load_s3m.c +9 -7
- data/dependencies/SDL_sound/libmodplug/load_stm.c +3 -2
- data/dependencies/SDL_sound/libmodplug/load_ult.c +2 -2
- data/dependencies/SDL_sound/libmodplug/load_umx.c +315 -35
- data/dependencies/SDL_sound/libmodplug/load_xm.c +25 -21
- data/dependencies/SDL_sound/libmodplug/mmcmp.c +295 -149
- data/dependencies/SDL_sound/libmodplug/modplug.c +7 -123
- data/dependencies/SDL_sound/libmodplug/modplug.h +32 -29
- data/dependencies/SDL_sound/libmodplug/snd_dsp.c +0 -1
- data/dependencies/SDL_sound/libmodplug/snd_flt.c +2 -2
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +24 -18
- data/dependencies/SDL_sound/libmodplug/sndfile.c +55 -156
- data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -12
- data/dependencies/SDL_sound/libmodplug/tables.h +10 -15
- data/dependencies/SDL_sound/stb_vorbis.h +508 -325
- data/dependencies/{al_soft → mojoAL}/AL/al.h +38 -30
- data/dependencies/{al_soft → mojoAL}/AL/alc.h +27 -56
- data/dependencies/mojoAL/mojoal.c +4594 -0
- data/ext/gosu/extconf.rb +29 -30
- data/include/Gosu/Audio.hpp +70 -85
- data/include/Gosu/Color.hpp +63 -107
- data/include/Gosu/Font.hpp +44 -48
- data/include/Gosu/Fwd.hpp +1 -1
- data/include/Gosu/Graphics.hpp +64 -75
- data/include/Gosu/GraphicsBase.hpp +32 -39
- data/include/Gosu/Image.hpp +56 -62
- data/include/Gosu/ImageData.hpp +23 -27
- data/include/Gosu/Inspection.hpp +1 -4
- data/include/Gosu/Math.hpp +4 -16
- data/include/Gosu/Platform.hpp +1 -51
- data/include/Gosu/Text.hpp +37 -40
- data/include/Gosu/TextInput.hpp +34 -40
- data/include/Gosu/Utility.hpp +10 -8
- data/include/Gosu/Version.hpp +1 -1
- data/include/Gosu/Window.hpp +73 -70
- data/lib/SDL2.dll +0 -0
- data/lib/gosu/compat.rb +28 -37
- data/lib/gosu/swig_patches.rb +31 -3
- data/lib/gosu.rb +2 -2
- data/lib64/SDL2.dll +0 -0
- data/rdoc/gosu.rb +9 -1
- data/src/Audio.cpp +88 -86
- data/src/AudioFile.hpp +6 -6
- data/src/AudioFileAudioToolbox.cpp +1 -1
- data/src/AudioFileSDLSound.cpp +1 -1
- data/src/AudioImpl.hpp +5 -5
- data/src/Bitmap.cpp +13 -13
- data/src/BitmapIO.cpp +0 -20
- data/src/BlockAllocator.cpp +2 -1
- data/src/Channel.cpp +22 -20
- data/src/Color.cpp +62 -55
- data/src/EmptyImageData.hpp +16 -18
- data/src/FileUnix.cpp +1 -1
- data/src/FileWin.cpp +1 -1
- data/src/Font.cpp +52 -57
- data/src/GosuViewController.cpp +2 -0
- data/src/Graphics.cpp +135 -143
- data/src/Image.cpp +42 -42
- data/src/Input.cpp +1 -1
- data/src/InputUIKit.cpp +1 -1
- data/src/LargeImageData.cpp +120 -113
- data/src/LargeImageData.hpp +18 -16
- data/src/Log.hpp +6 -6
- data/src/Macro.cpp +35 -37
- data/src/Macro.hpp +11 -11
- data/src/Math.cpp +8 -1
- data/src/RenderState.hpp +5 -5
- data/src/Resolution.cpp +12 -7
- data/src/RubyGosu.cxx +471 -502
- data/src/RubyGosu.h +3 -2
- data/src/TexChunk.cpp +50 -41
- data/src/TexChunk.hpp +22 -22
- data/src/Text.cpp +58 -59
- data/src/TextBuilder.cpp +60 -57
- data/src/TextBuilder.hpp +20 -20
- data/src/TextInput.cpp +127 -135
- data/src/TrueTypeFont.cpp +108 -108
- data/src/TrueTypeFont.hpp +39 -38
- data/src/TrueTypeFontApple.cpp +27 -23
- data/src/TrueTypeFontUnix.cpp +21 -26
- data/src/TrueTypeFontWin.cpp +30 -30
- data/src/Utility.cpp +82 -23
- data/src/WinUtility.hpp +2 -1
- data/src/Window.cpp +103 -86
- data/src/WindowUIKit.cpp +48 -51
- metadata +8 -20
- data/dependencies/SDL/include/SDL_config_os2.h +0 -188
- data/dependencies/SDL_sound/libmodplug/load_abc.c +0 -4725
- data/dependencies/SDL_sound/libmodplug/load_mid.c +0 -1405
- data/dependencies/SDL_sound/libmodplug/load_pat.c +0 -1143
- data/dependencies/SDL_sound/libmodplug/load_pat.h +0 -25
- data/dependencies/al_soft/AL/alext.h +0 -585
- data/dependencies/al_soft/AL/efx-creative.h +0 -3
- data/dependencies/al_soft/AL/efx-presets.h +0 -402
- data/dependencies/al_soft/AL/efx.h +0 -762
- data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
- data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
- data/lib/OpenAL32.dll +0 -0
- data/lib64/OpenAL32.dll +0 -0
- data/src/UtilityApple.cpp +0 -16
- data/src/UtilityWin.cpp +0 -17
data/include/Gosu/Inspection.hpp
CHANGED
data/include/Gosu/Math.hpp
CHANGED
@@ -67,17 +67,7 @@ namespace Gosu
|
|
67
67
|
{
|
68
68
|
return value * value;
|
69
69
|
}
|
70
|
-
|
71
|
-
//! Returns min if value is smaller than min, max if value is larger than
|
72
|
-
//! max and value otherwise.
|
73
|
-
template<typename T>
|
74
|
-
T clamp(T value, T min, T max)
|
75
|
-
{
|
76
|
-
if (value < min) return min;
|
77
|
-
if (value > max) return max;
|
78
|
-
return value;
|
79
|
-
}
|
80
|
-
|
70
|
+
|
81
71
|
//! Returns (value-min) % (max-min) + min, where % always has a positive
|
82
72
|
//! result for max > min. The results are undefined for max <= min.
|
83
73
|
//! Note: This means that max is exclusive.
|
@@ -100,12 +90,10 @@ namespace Gosu
|
|
100
90
|
//! Returns the distance between two points.
|
101
91
|
double distance(double x1, double y1, double x2, double y2);
|
102
92
|
|
103
|
-
//!
|
104
|
-
//! Examples: interpolate(0, 10, 0.5) == 5, interpolate(-10, 10, 0.25) == 5,
|
105
|
-
//! interpolate(0, 10, -0.5) == -5.
|
93
|
+
//! Placeholder for std::lerp, will be removed when Gosu requires C++20.
|
106
94
|
template<typename T>
|
107
|
-
T
|
95
|
+
T lerp(T a, T b, double t = 0.5)
|
108
96
|
{
|
109
|
-
return a * (1.0 -
|
97
|
+
return a * (1.0 - t) + b * t;
|
110
98
|
}
|
111
99
|
}
|
data/include/Gosu/Platform.hpp
CHANGED
@@ -1,51 +1,5 @@
|
|
1
|
-
//! \file Platform.hpp
|
2
|
-
//! Macros and utility functions to facilitate programming on all of Gosu's supported platforms.
|
3
|
-
|
4
1
|
#pragma once
|
5
2
|
|
6
|
-
#ifdef __BIG_ENDIAN__
|
7
|
-
# define GOSU_IS_BIG_ENDIAN
|
8
|
-
# define IDENTITY_FUN big_to_native
|
9
|
-
# define IDENTITY_FUN2 native_to_big
|
10
|
-
# define CONV_FUN little_to_native
|
11
|
-
# define CONV_FUN2 native_to_little
|
12
|
-
#else
|
13
|
-
# define GOSU_IS_LITTLE_ENDIAN
|
14
|
-
# define IDENTITY_FUN little_to_native
|
15
|
-
# define IDENTITY_FUN2 native_to_little
|
16
|
-
# define CONV_FUN big_to_native
|
17
|
-
# define CONV_FUN2 native_to_big
|
18
|
-
#endif
|
19
|
-
|
20
|
-
#include <algorithm>
|
21
|
-
|
22
|
-
namespace Gosu
|
23
|
-
{
|
24
|
-
template<typename T> T IDENTITY_FUN(T t) { return t; }
|
25
|
-
template<typename T> T IDENTITY_FUN2(T t) { return t; }
|
26
|
-
|
27
|
-
template<typename T>
|
28
|
-
T CONV_FUN(T t)
|
29
|
-
{
|
30
|
-
char* begin = reinterpret_cast<char*>(&t);
|
31
|
-
std::reverse(begin, begin + sizeof t);
|
32
|
-
return t;
|
33
|
-
}
|
34
|
-
|
35
|
-
template<typename T> T CONV_FUN2(T t) { return CONV_FUN(t); }
|
36
|
-
}
|
37
|
-
|
38
|
-
#undef IDENTITY_FUN
|
39
|
-
#undef IDENTITY_FUN2
|
40
|
-
#undef CONV_FUN
|
41
|
-
#undef CONV_FUN2
|
42
|
-
|
43
|
-
#if defined(_MSC_VER)
|
44
|
-
# define GOSU_NORETURN __declspec(noreturn)
|
45
|
-
#elif defined(__GNUC__)
|
46
|
-
# define GOSU_NORETURN __attribute__ ((noreturn))
|
47
|
-
#endif
|
48
|
-
|
49
3
|
#if defined(WIN32) || defined(_WIN64)
|
50
4
|
# define GOSU_IS_WIN
|
51
5
|
#else
|
@@ -63,9 +17,5 @@ namespace Gosu
|
|
63
17
|
#endif
|
64
18
|
|
65
19
|
#ifndef GOSU_DEPRECATED
|
66
|
-
#
|
67
|
-
# define GOSU_DEPRECATED __declspec(deprecated)
|
68
|
-
# else
|
69
|
-
# define GOSU_DEPRECATED __attribute__((__deprecated__))
|
70
|
-
# endif
|
20
|
+
# define GOSU_DEPRECATED [[deprecated]]
|
71
21
|
#endif
|
data/include/Gosu/Text.hpp
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
//! \file Text.hpp
|
2
|
-
//! Functions to output text on bitmaps.
|
3
|
-
|
4
1
|
#pragma once
|
5
2
|
|
6
3
|
#include <Gosu/Fwd.hpp>
|
@@ -10,55 +7,55 @@
|
|
10
7
|
|
11
8
|
namespace Gosu
|
12
9
|
{
|
13
|
-
|
10
|
+
/// Returns the name of a neutral font that is available on the current platform.
|
14
11
|
std::string default_font_name();
|
15
12
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
/// Returns the width that an unformatted line of text would span on a bitmap if it were drawn
|
14
|
+
/// using draw_text with the same arguments.
|
15
|
+
/// @param text A UCS-4 string, normalization: NFC.
|
16
|
+
/// @param font_name Name of a system font, or filename of a TTF file (must contain '/' or '.').
|
20
17
|
double text_width(const std::u32string& text, const std::string& font_name, double font_height,
|
21
18
|
unsigned font_flags = 0);
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
20
|
+
/// Draws a line of plain text on a bitmap. This is a low-level function that does not
|
21
|
+
/// understand any of Gosu's HTML-like markup.
|
22
|
+
/// @param text A UCS-4 string, normalization: NFC.
|
23
|
+
/// @param font_name Name of a system font, or filename of a TTF file (must contain '/' or '.').
|
24
|
+
/// @param font_height Height, in pixels, of the text.
|
25
|
+
/// @param font_flags Binary combination of members of the FontFlags enum.
|
29
26
|
double draw_text(Bitmap& bitmap, double x, double y, Color c, const std::u32string& text,
|
30
27
|
const std::string& font_name, double font_height, unsigned font_flags = 0);
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
29
|
+
/// Creates a bitmap that is filled with the plain text given to the function.
|
30
|
+
/// The line can contain line breaks and HTML-like markup.
|
31
|
+
/// @param text Plain text.
|
32
|
+
/// @param font_name Name of a system font, or filename of a TTF file (must contain '/' or '.').
|
33
|
+
/// @param font_height Height of the font in pixels.
|
34
|
+
/// @param line_spacing Spacing between two lines of text in pixels. Can be negative to make
|
35
|
+
/// text stick together more closely.
|
36
|
+
/// @param width Width of the bitmap that will be returned.
|
37
|
+
/// Text will be split into multiple lines to avoid drawing over the right border.
|
38
|
+
/// When a single word is too long, it will be truncated.
|
39
|
+
/// A width smaller than 0 indicates that lines should not be wrapped, and the resulting
|
40
|
+
/// bitmap will be as wide as the widest line.
|
41
|
+
/// @param font_flags Binary combination of members of the FontFlags enum.
|
45
42
|
Bitmap layout_text(const std::string& text, const std::string& font_name,
|
46
43
|
double font_height, double line_spacing = 0,
|
47
44
|
int width = -1, Alignment align = AL_LEFT, unsigned font_flags = 0);
|
48
45
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
46
|
+
/// Creates a bitmap that is filled with the formatted text given to the function.
|
47
|
+
/// The line can contain line breaks and HTML-like markup.
|
48
|
+
/// @param markup Formatted text.
|
49
|
+
/// @param font_name Name of a system font, or filename of a TTF file (must contain '/' or '.').
|
50
|
+
/// @param font_height Height of the font in pixels.
|
51
|
+
/// @param line_spacing Spacing between two lines of text in pixels. Can be negative to make
|
52
|
+
/// text stick together more closely.
|
53
|
+
/// @param width Width of the bitmap that will be returned.
|
54
|
+
/// Text will be split into multiple lines to avoid drawing over the right border.
|
55
|
+
/// When a single word is too long, it will be truncated.
|
56
|
+
/// A width smaller than 0 indicates that lines should not be wrapped, and the resulting
|
57
|
+
/// bitmap will be as wide as the widest line.
|
58
|
+
/// @param font_flags Binary combination of members of the FontFlags enum.
|
62
59
|
Bitmap layout_markup(const std::string& markup, const std::string& font_name,
|
63
60
|
double font_height, double line_spacing = 0,
|
64
61
|
int width = -1, Alignment align = AL_LEFT, unsigned font_flags = 0);
|
data/include/Gosu/TextInput.hpp
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
//! \file TextInput.hpp
|
2
|
-
//! Interface of the TextInput class.
|
3
|
-
|
4
1
|
#pragma once
|
5
2
|
|
6
3
|
#include <Gosu/Fwd.hpp>
|
@@ -10,67 +7,64 @@
|
|
10
7
|
|
11
8
|
namespace Gosu
|
12
9
|
{
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
/// TextInput instances are invisible objects that build a text string from input, using the
|
11
|
+
/// current operating system's keyboard layout or input method editor (IME).
|
12
|
+
/// To start processing keyboard text input, you need to create a new TextInput instance and
|
13
|
+
/// pass it to your window's Input object via set_text_input.
|
14
|
+
/// Until you call this function again with a nullptr value, the TextInput object will then
|
15
|
+
/// build a text that can be accessed via TextInput::text().
|
16
|
+
/// A TextInput object has no built-in UI. It is up to you to actually draw a text field.
|
17
|
+
/// TextInput only provides a portable base for your own GUI to build upon.
|
21
18
|
class TextInput
|
22
19
|
{
|
23
20
|
struct Impl;
|
24
21
|
// Non-movable (const) to avoid dangling references to TextInput instances.
|
25
|
-
const std::unique_ptr<Impl>
|
26
|
-
|
22
|
+
const std::unique_ptr<Impl> m_impl;
|
23
|
+
|
27
24
|
public:
|
28
25
|
TextInput();
|
29
26
|
virtual ~TextInput();
|
30
27
|
|
31
28
|
std::string text() const;
|
32
29
|
|
33
|
-
|
34
|
-
|
30
|
+
/// Replaces the current text by the given string and positions the cursor at the end of the
|
31
|
+
/// text, with an empty selection.
|
35
32
|
void set_text(const std::string& text);
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
/// Index of the character that comes after the caret. When the text is empty, this is
|
35
|
+
/// always 0. For ease of use in C++, this counts bytes, not codepoints, in the UTF-8
|
36
|
+
/// encoded string.
|
40
37
|
unsigned caret_pos() const;
|
41
|
-
|
42
|
-
|
38
|
+
/// Sets the caret position as returned by caret_pos.
|
39
|
+
/// You usually also want to use set_selection_start.
|
43
40
|
void set_caret_pos(unsigned pos);
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
/// If there is a selection, the selection_start() member yields its beginning, using the
|
43
|
+
/// same indexing scheme as caret_pos. If there is no selection, selection_start() is equal
|
44
|
+
/// to caret_pos().
|
48
45
|
unsigned selection_start() const;
|
49
|
-
|
46
|
+
/// Sets the start of the selection as returned by selection_start.
|
50
47
|
void set_selection_start(unsigned pos);
|
51
|
-
|
48
|
+
|
52
49
|
#ifndef GOSU_IS_IPHONE
|
53
50
|
// Platform-specific communication with Gosu::Input.
|
54
51
|
bool feed_sdl_event(void* event);
|
55
52
|
#endif
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
virtual std::string filter(std::string text) const
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
//! Replaces the current selection (if any) and inserts the given string at the current
|
66
|
-
//! caret position.
|
67
|
-
//! The filter method will not be applied before appending the string.
|
54
|
+
/// Overridable filter that is applied to all new text that is entered.
|
55
|
+
/// Allows for context-sensitive filtering/extending/... of new characters.
|
56
|
+
/// The return value will be inserted at caret_pos.
|
57
|
+
virtual std::string filter(std::string text) const { return text; }
|
58
|
+
|
59
|
+
/// Replaces the current selection (if any) and inserts the given string at the current
|
60
|
+
/// caret position.
|
61
|
+
/// The filter method will not be applied before appending the string.
|
68
62
|
void insert_text(std::string text);
|
69
|
-
|
70
|
-
|
63
|
+
|
64
|
+
/// Deletes the current selection, if any, or the next character.
|
71
65
|
void delete_forward();
|
72
|
-
|
73
|
-
|
66
|
+
|
67
|
+
/// Deletes the current selection, if any, or the previous character.
|
74
68
|
void delete_backward();
|
75
69
|
};
|
76
70
|
}
|
data/include/Gosu/Utility.hpp
CHANGED
@@ -1,19 +1,21 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
3
|
#include <string>
|
4
|
+
#include <vector>
|
4
5
|
|
5
6
|
namespace Gosu
|
6
7
|
{
|
7
8
|
std::u32string utf8_to_composed_utc4(const std::string& utf8);
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
/// Returns true if the filename has the given extension.
|
11
|
+
/// The comparison is case-insensitive, but you must pass the extension in lower case.
|
11
12
|
bool has_extension(std::string_view filename, std::string_view extension);
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
|
14
|
+
/// Returns the user's preferred user_languages/locales, e.g. {"en_US", "de_DE", "ja"}.
|
15
|
+
/// The first two letters of each element will always be a language code.
|
16
|
+
/// This value is not cached. Please memorize the specific value that you are interested in,
|
17
|
+
/// typically the first language in the returned array that your game supports.
|
18
|
+
std::vector<std::string> user_languages();
|
17
19
|
|
18
20
|
class Noncopyable
|
19
21
|
{
|
data/include/Gosu/Version.hpp
CHANGED
data/include/Gosu/Window.hpp
CHANGED
@@ -12,26 +12,26 @@ namespace Gosu
|
|
12
12
|
{
|
13
13
|
WF_WINDOWED,
|
14
14
|
WF_FULLSCREEN = 1,
|
15
|
-
WF_RESIZABLE
|
15
|
+
WF_RESIZABLE = 2,
|
16
16
|
WF_BORDERLESS = 4
|
17
17
|
};
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
/// Convenient all-in-one class that serves as the foundation of a standard Gosu application.
|
20
|
+
/// Manages initialization of all of Gosu's core components and provides timing functionality.
|
21
|
+
/// Note that you can only use one instance of this class at the same time.
|
22
22
|
class Window
|
23
23
|
{
|
24
24
|
struct Impl;
|
25
|
-
const std::unique_ptr<Impl>
|
25
|
+
const std::unique_ptr<Impl> m_impl;
|
26
26
|
|
27
27
|
public:
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
/// Constructs a Window.
|
29
|
+
/// @param width Width of the window in points; that is, pixels on a normal display, and
|
30
|
+
/// 'points' on a high-resolution display.
|
31
|
+
/// @param height Same as width, just for the other dimension.
|
32
|
+
/// @param window_flags A bitmask of values from Gosu::WindowFlags.
|
33
|
+
/// @param update_interval Interval in milliseconds between two calls to the update member
|
34
|
+
/// function.
|
35
35
|
Window(int width, int height, unsigned window_flags = WF_WINDOWED,
|
36
36
|
double update_interval = 16.666666);
|
37
37
|
virtual ~Window();
|
@@ -53,75 +53,78 @@ namespace Gosu
|
|
53
53
|
std::string caption() const;
|
54
54
|
void set_caption(const std::string& caption);
|
55
55
|
|
56
|
-
|
57
|
-
|
56
|
+
/// Enters a modal loop where the Window is visible on screen and receives calls to draw,
|
57
|
+
/// update etc.
|
58
|
+
/// The loop exits when the window is closed.
|
58
59
|
virtual void show();
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
61
|
+
/// EXPERIMENTAL - MAY DISAPPEAR WITHOUT WARNING.
|
62
|
+
/// Performs a single main loop step.
|
63
|
+
/// This method is only useful if you want to integrate Gosu with another library that has
|
64
|
+
/// its own main loop.
|
65
|
+
/// This method implicitly shows the window if it was hidden before, and returns false when
|
66
|
+
/// the window has been closed.
|
67
|
+
/// If you discard the return value and keep calling tick(), the window will be shown again,
|
68
|
+
/// or keep being shown.
|
68
69
|
virtual bool tick();
|
69
70
|
|
70
|
-
|
71
|
-
|
72
|
-
|
71
|
+
/// Closes the window if it is currently shown.
|
72
|
+
/// If you do not want the window to close immediately, you should override this method and
|
73
|
+
/// only call the base implementation (Window::close) when needed.
|
73
74
|
virtual void close();
|
74
75
|
|
75
|
-
|
76
|
-
|
76
|
+
/// Called every update_interval milliseconds while the window is being shown.
|
77
|
+
/// Your application's main game logic goes here.
|
77
78
|
virtual void update() {}
|
78
79
|
|
79
|
-
|
80
|
-
|
80
|
+
/// Called after every update and when the OS wants the window to repaint itself.
|
81
|
+
/// Your application's rendering code goes here.
|
81
82
|
virtual void draw() {}
|
82
83
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
/// Gives the game a chance to say no to being redrawn.
|
85
|
+
/// This is not a definitive answer. The operating system can still force the window to
|
86
|
+
/// redraw itself.
|
87
|
+
/// By default, the window is redrawn all the time.
|
87
88
|
virtual bool needs_redraw() const { return true; }
|
88
89
|
|
89
|
-
|
90
|
+
/// If this function returns true, the system cursor will be visible while over the window.
|
90
91
|
virtual bool needs_cursor() const { return true; }
|
91
92
|
|
92
|
-
|
93
|
-
|
93
|
+
virtual void gain_focus() {}
|
94
|
+
|
95
|
+
/// This function is called when the window loses focus on some platforms.
|
96
|
+
/// Most importantly, it is called on the iPhone or iPad when the user locks the screen.
|
94
97
|
virtual void lose_focus() {}
|
95
98
|
|
96
|
-
|
97
|
-
|
99
|
+
/// This function is called when the operating system's memory is low.
|
100
|
+
/// So far, it is only called in iOS applications.
|
98
101
|
virtual void release_memory() {}
|
99
102
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
103
|
+
/// Called before update when the user presses a button while the window has the focus.
|
104
|
+
/// By default, this will toggle fullscreen mode if the user presses Alt+Enter (Windows,
|
105
|
+
/// Linux), cmd+F (macOS), or F11 (on all operating systems).
|
106
|
+
/// To support these shortcuts in your application, make sure to call Window::button_down
|
107
|
+
/// in your implementation.
|
105
108
|
virtual void button_down(Gosu::Button);
|
106
109
|
|
107
|
-
|
110
|
+
/// Same as button_down. Called when the user releases a button.
|
108
111
|
virtual void button_up(Gosu::Button) {}
|
109
112
|
|
110
|
-
|
111
|
-
|
113
|
+
/// Called when a gamepad is connected.
|
114
|
+
/// @param index the index of the gamepad slot that the gamepad is in.
|
112
115
|
virtual void gamepad_connected(int index) {}
|
113
116
|
|
114
|
-
|
115
|
-
|
117
|
+
/// Called when a gamepad is disconnected.
|
118
|
+
/// @param index the index of the gamepad slot that the gamepad is in. The slot will be freed immediately after this callback.
|
116
119
|
virtual void gamepad_disconnected(int index) {}
|
117
120
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
+
/// Called when a file is dropped onto the window.
|
122
|
+
/// @param filename The filename of the dropped file. When multiple files are dropped, this
|
123
|
+
/// method will be called several times.
|
121
124
|
virtual void drop(const std::string& filename) {}
|
122
125
|
|
123
|
-
|
124
|
-
|
126
|
+
// Ignore when SWIG is wrapping this class for Ruby/Gosu.
|
127
|
+
#ifndef SWIG
|
125
128
|
// Callbacks for touch events. So far these are only used on iOS.
|
126
129
|
virtual void touch_began(Touch touch) {}
|
127
130
|
virtual void touch_moved(Touch touch) {}
|
@@ -133,32 +136,32 @@ namespace Gosu
|
|
133
136
|
|
134
137
|
const Input& input() const;
|
135
138
|
Input& input();
|
136
|
-
|
139
|
+
#endif
|
137
140
|
|
138
|
-
|
141
|
+
#ifdef GOSU_IS_IPHONE
|
139
142
|
void* uikit_window() const;
|
140
|
-
|
143
|
+
#endif
|
141
144
|
};
|
142
145
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
+
/// Returns the width (in pixels) of a screen.
|
147
|
+
/// @param window The result describes the screen on which the window is shown, or the
|
148
|
+
/// primary screen if no window is given.
|
146
149
|
int screen_width(Window* window = nullptr);
|
147
150
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
+
/// Returns the height (in pixels) of the user's primary screen.
|
152
|
+
/// @param window The result describes the screen on which the window is shown, or the
|
153
|
+
/// primary screen if no window is given.
|
151
154
|
int screen_height(Window* window = nullptr);
|
152
155
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
156
|
+
/// Returns the maximum width (in 'points') that is available for a non-fullscreen Window.
|
157
|
+
/// All windows larger than this size will automatically be shrunk to fit.
|
158
|
+
/// @param window The result describes the screen on which the window is shown, or the
|
159
|
+
/// primary screen if no window is given.
|
157
160
|
int available_width(Window* window = nullptr);
|
158
161
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
162
|
+
/// Returns the maximum height (in 'points') that is available for a non-fullscreen Window.
|
163
|
+
/// All windows larger than this size will automatically be shrunk to fit.
|
164
|
+
/// @param window The result describes the screen on which the window is shown, or the
|
165
|
+
/// primary screen if no window is given.
|
163
166
|
int available_height(Window* window = nullptr);
|
164
167
|
}
|
data/lib/SDL2.dll
CHANGED
Binary file
|