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.
Files changed (219) hide show
  1. checksums.yaml +4 -4
  2. data/dependencies/SDL/include/SDL.h +108 -14
  3. data/dependencies/SDL/include/SDL_assert.h +81 -50
  4. data/dependencies/SDL/include/SDL_atomic.h +135 -35
  5. data/dependencies/SDL/include/SDL_audio.h +960 -355
  6. data/dependencies/SDL/include/SDL_bits.h +11 -6
  7. data/dependencies/SDL/include/SDL_blendmode.h +91 -14
  8. data/dependencies/SDL/include/SDL_clipboard.h +30 -7
  9. data/dependencies/SDL/include/SDL_config.h +277 -27
  10. data/dependencies/SDL/include/SDL_config_android.h +13 -38
  11. data/dependencies/SDL/include/SDL_config_iphoneos.h +21 -62
  12. data/dependencies/SDL/include/SDL_config_macosx.h +23 -92
  13. data/dependencies/SDL/include/SDL_config_minimal.h +1 -4
  14. data/dependencies/SDL/include/SDL_config_pandora.h +15 -22
  15. data/dependencies/SDL/include/SDL_config_psp.h +16 -37
  16. data/dependencies/SDL/include/SDL_config_windows.h +28 -91
  17. data/dependencies/SDL/include/SDL_config_winrt.h +33 -61
  18. data/dependencies/SDL/include/SDL_config_wiz.h +28 -56
  19. data/dependencies/SDL/include/SDL_copying.h +1 -1
  20. data/dependencies/SDL/include/SDL_cpuinfo.h +331 -71
  21. data/dependencies/SDL/include/SDL_egl.h +906 -280
  22. data/dependencies/SDL/include/SDL_endian.h +101 -47
  23. data/dependencies/SDL/include/SDL_error.h +70 -19
  24. data/dependencies/SDL/include/SDL_events.h +387 -79
  25. data/dependencies/SDL/include/SDL_filesystem.h +73 -64
  26. data/dependencies/SDL/include/SDL_gamecontroller.h +585 -125
  27. data/dependencies/SDL/include/SDL_gesture.h +36 -6
  28. data/dependencies/SDL/include/SDL_haptic.h +304 -210
  29. data/dependencies/SDL/include/SDL_hidapi.h +451 -0
  30. data/dependencies/SDL/include/SDL_hints.h +1286 -897
  31. data/dependencies/SDL/include/SDL_joystick.h +577 -130
  32. data/dependencies/SDL/include/SDL_keyboard.h +162 -63
  33. data/dependencies/SDL/include/SDL_keycode.h +7 -5
  34. data/dependencies/SDL/include/SDL_loadso.h +42 -8
  35. data/dependencies/SDL/include/SDL_locale.h +34 -32
  36. data/dependencies/SDL/include/SDL_log.h +212 -19
  37. data/dependencies/SDL/include/SDL_main.h +72 -17
  38. data/dependencies/SDL/include/SDL_messagebox.h +70 -23
  39. data/dependencies/SDL/include/SDL_metal.h +27 -32
  40. data/dependencies/SDL/include/SDL_misc.h +19 -15
  41. data/dependencies/SDL/include/SDL_mouse.h +262 -110
  42. data/dependencies/SDL/include/SDL_mutex.h +286 -66
  43. data/dependencies/SDL/include/SDL_name.h +1 -1
  44. data/dependencies/SDL/include/SDL_opengl.h +1 -1
  45. data/dependencies/SDL/include/SDL_opengles.h +1 -1
  46. data/dependencies/SDL/include/SDL_opengles2.h +2 -2
  47. data/dependencies/SDL/include/SDL_pixels.h +199 -34
  48. data/dependencies/SDL/include/SDL_platform.h +39 -2
  49. data/dependencies/SDL/include/SDL_power.h +23 -10
  50. data/dependencies/SDL/include/SDL_quit.h +1 -1
  51. data/dependencies/SDL/include/SDL_rect.h +78 -28
  52. data/dependencies/SDL/include/SDL_render.h +1204 -472
  53. data/dependencies/SDL/include/SDL_revision.h +2 -2
  54. data/dependencies/SDL/include/SDL_rwops.h +605 -33
  55. data/dependencies/SDL/include/SDL_scancode.h +1 -1
  56. data/dependencies/SDL/include/SDL_sensor.h +76 -42
  57. data/dependencies/SDL/include/SDL_shape.h +38 -27
  58. data/dependencies/SDL/include/SDL_stdinc.h +96 -24
  59. data/dependencies/SDL/include/SDL_surface.h +571 -139
  60. data/dependencies/SDL/include/SDL_system.h +339 -101
  61. data/dependencies/SDL/include/SDL_syswm.h +50 -20
  62. data/dependencies/SDL/include/SDL_test.h +1 -1
  63. data/dependencies/SDL/include/SDL_test_assert.h +2 -2
  64. data/dependencies/SDL/include/SDL_test_common.h +23 -6
  65. data/dependencies/SDL/include/SDL_test_compare.h +1 -1
  66. data/dependencies/SDL/include/SDL_test_crc32.h +1 -1
  67. data/dependencies/SDL/include/SDL_test_font.h +3 -3
  68. data/dependencies/SDL/include/SDL_test_fuzzer.h +28 -26
  69. data/dependencies/SDL/include/SDL_test_harness.h +6 -6
  70. data/dependencies/SDL/include/SDL_test_images.h +1 -1
  71. data/dependencies/SDL/include/SDL_test_log.h +1 -1
  72. data/dependencies/SDL/include/SDL_test_md5.h +1 -1
  73. data/dependencies/SDL/include/SDL_test_memory.h +1 -1
  74. data/dependencies/SDL/include/SDL_test_random.h +2 -2
  75. data/dependencies/SDL/include/SDL_thread.h +226 -128
  76. data/dependencies/SDL/include/SDL_timer.h +129 -22
  77. data/dependencies/SDL/include/SDL_touch.h +48 -8
  78. data/dependencies/SDL/include/SDL_types.h +1 -1
  79. data/dependencies/SDL/include/SDL_version.h +72 -46
  80. data/dependencies/SDL/include/SDL_video.h +1266 -460
  81. data/dependencies/SDL/include/SDL_vulkan.h +100 -161
  82. data/dependencies/SDL/include/begin_code.h +22 -1
  83. data/dependencies/SDL/include/close_code.h +1 -1
  84. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  85. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  86. data/dependencies/SDL_sound/SDL_sound.c +83 -7
  87. data/dependencies/SDL_sound/SDL_sound.h +4 -4
  88. data/dependencies/SDL_sound/SDL_sound_aiff.c +9 -12
  89. data/dependencies/SDL_sound/SDL_sound_au.c +7 -7
  90. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +3 -3
  91. data/dependencies/SDL_sound/SDL_sound_flac.c +1 -1
  92. data/dependencies/SDL_sound/SDL_sound_internal.h +17 -10
  93. data/dependencies/SDL_sound/SDL_sound_modplug.c +25 -27
  94. data/dependencies/SDL_sound/SDL_sound_mp3.c +5 -17
  95. data/dependencies/SDL_sound/SDL_sound_raw.c +11 -11
  96. data/dependencies/SDL_sound/SDL_sound_shn.c +8 -7
  97. data/dependencies/SDL_sound/SDL_sound_voc.c +6 -4
  98. data/dependencies/SDL_sound/SDL_sound_vorbis.c +6 -11
  99. data/dependencies/SDL_sound/SDL_sound_wav.c +35 -29
  100. data/dependencies/SDL_sound/dr_flac.h +618 -220
  101. data/dependencies/SDL_sound/dr_mp3.h +263 -94
  102. data/dependencies/SDL_sound/libmodplug/fastmix.c +58 -64
  103. data/dependencies/SDL_sound/libmodplug/libmodplug.h +25 -103
  104. data/dependencies/SDL_sound/libmodplug/load_669.c +14 -17
  105. data/dependencies/SDL_sound/libmodplug/load_amf.c +11 -7
  106. data/dependencies/SDL_sound/libmodplug/load_ams.c +65 -22
  107. data/dependencies/SDL_sound/libmodplug/load_dbm.c +8 -4
  108. data/dependencies/SDL_sound/libmodplug/load_dmf.c +55 -25
  109. data/dependencies/SDL_sound/libmodplug/load_far.c +9 -13
  110. data/dependencies/SDL_sound/libmodplug/load_gdm.c +448 -0
  111. data/dependencies/SDL_sound/libmodplug/load_it.c +45 -49
  112. data/dependencies/SDL_sound/libmodplug/load_mdl.c +80 -53
  113. data/dependencies/SDL_sound/libmodplug/load_med.c +20 -12
  114. data/dependencies/SDL_sound/libmodplug/load_mod.c +40 -15
  115. data/dependencies/SDL_sound/libmodplug/load_mt2.c +29 -17
  116. data/dependencies/SDL_sound/libmodplug/load_okt.c +12 -8
  117. data/dependencies/SDL_sound/libmodplug/load_psm.c +101 -78
  118. data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -17
  119. data/dependencies/SDL_sound/libmodplug/load_s3m.c +9 -7
  120. data/dependencies/SDL_sound/libmodplug/load_stm.c +3 -2
  121. data/dependencies/SDL_sound/libmodplug/load_ult.c +2 -2
  122. data/dependencies/SDL_sound/libmodplug/load_umx.c +315 -35
  123. data/dependencies/SDL_sound/libmodplug/load_xm.c +25 -21
  124. data/dependencies/SDL_sound/libmodplug/mmcmp.c +295 -149
  125. data/dependencies/SDL_sound/libmodplug/modplug.c +7 -123
  126. data/dependencies/SDL_sound/libmodplug/modplug.h +32 -29
  127. data/dependencies/SDL_sound/libmodplug/snd_dsp.c +0 -1
  128. data/dependencies/SDL_sound/libmodplug/snd_flt.c +2 -2
  129. data/dependencies/SDL_sound/libmodplug/snd_fx.c +24 -18
  130. data/dependencies/SDL_sound/libmodplug/sndfile.c +55 -156
  131. data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -12
  132. data/dependencies/SDL_sound/libmodplug/tables.h +10 -15
  133. data/dependencies/SDL_sound/stb_vorbis.h +508 -325
  134. data/dependencies/{al_soft → mojoAL}/AL/al.h +38 -30
  135. data/dependencies/{al_soft → mojoAL}/AL/alc.h +27 -56
  136. data/dependencies/mojoAL/mojoal.c +4594 -0
  137. data/ext/gosu/extconf.rb +29 -30
  138. data/include/Gosu/Audio.hpp +70 -85
  139. data/include/Gosu/Color.hpp +63 -107
  140. data/include/Gosu/Font.hpp +44 -48
  141. data/include/Gosu/Fwd.hpp +1 -1
  142. data/include/Gosu/Graphics.hpp +64 -75
  143. data/include/Gosu/GraphicsBase.hpp +32 -39
  144. data/include/Gosu/Image.hpp +56 -62
  145. data/include/Gosu/ImageData.hpp +23 -27
  146. data/include/Gosu/Inspection.hpp +1 -4
  147. data/include/Gosu/Math.hpp +4 -16
  148. data/include/Gosu/Platform.hpp +1 -51
  149. data/include/Gosu/Text.hpp +37 -40
  150. data/include/Gosu/TextInput.hpp +34 -40
  151. data/include/Gosu/Utility.hpp +10 -8
  152. data/include/Gosu/Version.hpp +1 -1
  153. data/include/Gosu/Window.hpp +73 -70
  154. data/lib/SDL2.dll +0 -0
  155. data/lib/gosu/compat.rb +28 -37
  156. data/lib/gosu/swig_patches.rb +31 -3
  157. data/lib/gosu.rb +2 -2
  158. data/lib64/SDL2.dll +0 -0
  159. data/rdoc/gosu.rb +9 -1
  160. data/src/Audio.cpp +88 -86
  161. data/src/AudioFile.hpp +6 -6
  162. data/src/AudioFileAudioToolbox.cpp +1 -1
  163. data/src/AudioFileSDLSound.cpp +1 -1
  164. data/src/AudioImpl.hpp +5 -5
  165. data/src/Bitmap.cpp +13 -13
  166. data/src/BitmapIO.cpp +0 -20
  167. data/src/BlockAllocator.cpp +2 -1
  168. data/src/Channel.cpp +22 -20
  169. data/src/Color.cpp +62 -55
  170. data/src/EmptyImageData.hpp +16 -18
  171. data/src/FileUnix.cpp +1 -1
  172. data/src/FileWin.cpp +1 -1
  173. data/src/Font.cpp +52 -57
  174. data/src/GosuViewController.cpp +2 -0
  175. data/src/Graphics.cpp +135 -143
  176. data/src/Image.cpp +42 -42
  177. data/src/Input.cpp +1 -1
  178. data/src/InputUIKit.cpp +1 -1
  179. data/src/LargeImageData.cpp +120 -113
  180. data/src/LargeImageData.hpp +18 -16
  181. data/src/Log.hpp +6 -6
  182. data/src/Macro.cpp +35 -37
  183. data/src/Macro.hpp +11 -11
  184. data/src/Math.cpp +8 -1
  185. data/src/RenderState.hpp +5 -5
  186. data/src/Resolution.cpp +12 -7
  187. data/src/RubyGosu.cxx +471 -502
  188. data/src/RubyGosu.h +3 -2
  189. data/src/TexChunk.cpp +50 -41
  190. data/src/TexChunk.hpp +22 -22
  191. data/src/Text.cpp +58 -59
  192. data/src/TextBuilder.cpp +60 -57
  193. data/src/TextBuilder.hpp +20 -20
  194. data/src/TextInput.cpp +127 -135
  195. data/src/TrueTypeFont.cpp +108 -108
  196. data/src/TrueTypeFont.hpp +39 -38
  197. data/src/TrueTypeFontApple.cpp +27 -23
  198. data/src/TrueTypeFontUnix.cpp +21 -26
  199. data/src/TrueTypeFontWin.cpp +30 -30
  200. data/src/Utility.cpp +82 -23
  201. data/src/WinUtility.hpp +2 -1
  202. data/src/Window.cpp +103 -86
  203. data/src/WindowUIKit.cpp +48 -51
  204. metadata +8 -20
  205. data/dependencies/SDL/include/SDL_config_os2.h +0 -188
  206. data/dependencies/SDL_sound/libmodplug/load_abc.c +0 -4725
  207. data/dependencies/SDL_sound/libmodplug/load_mid.c +0 -1405
  208. data/dependencies/SDL_sound/libmodplug/load_pat.c +0 -1143
  209. data/dependencies/SDL_sound/libmodplug/load_pat.h +0 -25
  210. data/dependencies/al_soft/AL/alext.h +0 -585
  211. data/dependencies/al_soft/AL/efx-creative.h +0 -3
  212. data/dependencies/al_soft/AL/efx-presets.h +0 -402
  213. data/dependencies/al_soft/AL/efx.h +0 -762
  214. data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
  215. data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
  216. data/lib/OpenAL32.dll +0 -0
  217. data/lib64/OpenAL32.dll +0 -0
  218. data/src/UtilityApple.cpp +0 -16
  219. data/src/UtilityWin.cpp +0 -17
@@ -1,10 +1,7 @@
1
- //! \file Inspection.hpp
2
- //! A special set of functions designed for tuning Gosu games.
3
-
4
1
  #pragma once
5
2
 
6
3
  namespace Gosu
7
4
  {
8
- //! Returns the current framerate.
5
+ /// Returns the current framerate.
9
6
  int fps();
10
7
  }
@@ -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
- //! Interpolates a value between a and b, weight being the bias towards the second value.
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 interpolate(T a, T b, double weight = 0.5)
95
+ T lerp(T a, T b, double t = 0.5)
108
96
  {
109
- return a * (1.0 - weight) + b * weight;
97
+ return a * (1.0 - t) + b * t;
110
98
  }
111
99
  }
@@ -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
- # if defined(GOSU_IS_WIN)
67
- # define GOSU_DEPRECATED __declspec(deprecated)
68
- # else
69
- # define GOSU_DEPRECATED __attribute__((__deprecated__))
70
- # endif
20
+ # define GOSU_DEPRECATED [[deprecated]]
71
21
  #endif
@@ -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
- //! Returns the name of a neutral font that is available on the current platform.
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
- //! Returns the width an unformatted line of text would span on a bitmap if it were drawn using
17
- //! draw_text with the same arguments.
18
- //! \param text A UCS-4 string, normalization: NFC.
19
- //! \param font_name Name of a system font, or filename of a TTF file (must contain '/' or '.').
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
- //! Draws a line of plain text on a bitmap. This is a low-level function that does not
24
- //! understand any of Gosu's HTML-like markup.
25
- //! \param text A UCS-4 string, normalization: NFC.
26
- //! \param font_name Name of a system font, or filename of a TTF file (must contain '/' or '.').
27
- //! \param font_height Height, in pixels, of the text.
28
- //! \param font_flags Binary combination of members of the FontFlags enum.
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
- //! Creates a bitmap that is filled with the plain text given to the function.
33
- //! The line can contain line breaks and HTML-like markup.
34
- //! \param text Plain text.
35
- //! \param font_name Name of a system font, or filename of a TTF file (must contain '/' or '.').
36
- //! \param font_height Height of the font in pixels.
37
- //! \param line_spacing Spacing between two lines of text in pixels. Can be negative to make
38
- //! text stick together more closely.
39
- //! \param width Width of the bitmap that will be returned.
40
- //! Text will be split into multiple lines to avoid drawing over the right border.
41
- //! When a single word is too long, it will be truncated.
42
- //! A width smaller than 0 indicates that lines should not be wrapped, and the resulting
43
- //! bitmap will be as wide as the widest line.
44
- //! \param font_flags Binary combination of members of the FontFlags enum.
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
- //! Creates a bitmap that is filled with the formatted text given to the function.
50
- //! The line can contain line breaks and HTML-like markup.
51
- //! \param markup Formatted text.
52
- //! \param font_name Name of a system font, or filename of a TTF file (must contain '/' or '.').
53
- //! \param font_height Height of the font in pixels.
54
- //! \param line_spacing Spacing between two lines of text in pixels. Can be negative to make
55
- //! text stick together more closely.
56
- //! \param width Width of the bitmap that will be returned.
57
- //! Text will be split into multiple lines to avoid drawing over the right border.
58
- //! When a single word is too long, it will be truncated.
59
- //! A width smaller than 0 indicates that lines should not be wrapped, and the resulting
60
- //! bitmap will be as wide as the widest line.
61
- //! \param font_flags Binary combination of members of the FontFlags enum.
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);
@@ -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
- //! TextInput instances are invisible objects that build a text string from input,
14
- //! using the current operating system's keyboard layout.
15
- //! At its most basic form, you only need to create a new TextInput instance and
16
- //! pass it to your window via set_text_input. Until you call this function again,
17
- //! passing nullptr, the TextInput object will build a text that can be accessed via
18
- //! TextInput::text().
19
- //! A TextInput object is purely abstract. It is up to you to actually draw a text field.
20
- //! TextInput only provides a portable base for your own GUI to build upon.
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> pimpl;
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
- //! Replaces the current text by the given string and positions the cursor
34
- //! at the end of the text, with an empty selection.
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
- //! Index of the character that comes after the caret. When the text is empty, this is
38
- //! always 0. For ease of use in C++, this counts bytes, not codepoints in the UTF-8 encoded
39
- //! string.
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
- //! Sets the caret position as returned by caret_pos.
42
- //! You usually also want to use set_selection_start.
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
- //! If there is a selection, the selection_start() member yields its beginning,
46
- //! using the same indexing scheme as caret_pos. If there is no selection,
47
- //! selection_start() is equal to caret_pos().
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
- //! Sets the start of the selection as returned by selection_start.
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
- //! Overridable filter that is applied to all new text that is entered.
58
- //! Allows for context-sensitive filtering/extending/... of new characters.
59
- //! The return value will be inserted at caret_pos.
60
- virtual std::string filter(std::string text) const
61
- {
62
- return text;
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
- //! Deletes the current selection, if any, or the next character.
63
+
64
+ /// Deletes the current selection, if any, or the next character.
71
65
  void delete_forward();
72
-
73
- //! Deletes the current selection, if any, or the previous character.
66
+
67
+ /// Deletes the current selection, if any, or the previous character.
74
68
  void delete_backward();
75
69
  };
76
70
  }
@@ -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
- //! Returns true if the filename has the given extension.
10
- //! The comparison is case-insensitive, but you must pass the extension in lower case.
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
- //! Returns the user's preferred language, at the moment of calling the function. Expect return
14
- //! values such as 'en_US', 'de_DE.UTF-8', 'ja', 'zh-Hans'.
15
- //! The first two letters will always be a language code.
16
- std::string language();
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
  {
@@ -3,7 +3,7 @@
3
3
  #include <string>
4
4
 
5
5
  #define GOSU_MAJOR_VERSION 1
6
- #define GOSU_MINOR_VERSION 1
6
+ #define GOSU_MINOR_VERSION 4
7
7
  #define GOSU_POINT_VERSION 1
8
8
 
9
9
  namespace Gosu
@@ -12,26 +12,26 @@ namespace Gosu
12
12
  {
13
13
  WF_WINDOWED,
14
14
  WF_FULLSCREEN = 1,
15
- WF_RESIZABLE = 2,
15
+ WF_RESIZABLE = 2,
16
16
  WF_BORDERLESS = 4
17
17
  };
18
18
 
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 should really only use one instance of this class at the same time.
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> pimpl;
25
+ const std::unique_ptr<Impl> m_impl;
26
26
 
27
27
  public:
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 See width.
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.
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
- //! Enters a modal loop where the Window is visible on screen and
57
- //! receives calls to draw, update etc.
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
- //! EXPERIMENTAL - MAY DISAPPEAR WITHOUT WARNING.
61
- //! Performs a single main loop step.
62
- //! This method is only useful if you want to integrate Gosu with another library that has
63
- //! its own main loop.
64
- //! This method implicitly shows the window if it was hidden before, and returns false when
65
- //! the window has been closed.
66
- //! If you discard the return value and keep calling tick(), the window will be shown again,
67
- //! or keep being shown.
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
- //! Closes the window if it is currently shown.
71
- //! If you do not want the window to close immediately, you should override this method and
72
- //! only call the base implementation (Window::close) when needed.
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
- //! Called every update_interval milliseconds while the window is being shown.
76
- //! Your application's main game logic goes here.
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
- //! Called after every update and when the OS wants the window to repaint itself.
80
- //! Your application's rendering code goes here.
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
- //! Gives the game a chance to say no to being redrawn.
84
- //! This is not a definitive answer. The operating system can still force the window to
85
- //! redraw itself.
86
- //! By default, the window is redrawn all the time.
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
- //! If this function returns true, the system cursor will be visible while over the window.
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
- //! This function is called when the window loses focus on some platforms.
93
- //! Most importantly, it is called on the iPhone or iPad when the user locks the screen.
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
- //! This function is called when the operating system's memory is low.
97
- //! So far, it is only called in iOS applications.
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
- //! Called before update when the user presses a button while the window has the focus.
101
- //! By default, this will toggle fullscreen mode if the user presses Alt+Enter (Windows,
102
- //! Linux), cmd+F (macOS), or F11 (on all operating systems).
103
- //! To support these shortcuts in your application, make sure to call Window::button_down
104
- //! in your implementation.
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
- //! Same as button_down. Called when the user releases a button.
110
+ /// Same as button_down. Called when the user releases a button.
108
111
  virtual void button_up(Gosu::Button) {}
109
112
 
110
- //! Called when a gamepad is connected.
111
- //! \param index the index of the gamepad slot that the gamepad is in.
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
- //! Called when a gamepad is disconnected.
115
- //! \param index the index of the gamepad slot that the gamepad is in. The slot will be freed immediately after this callback.
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
- //! Called when a file is dropped onto the window.
119
- //! \param filename The filename of the dropped file. When multiple files are dropped, this
120
- //! method will be called several times.
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
- // Ignore when SWIG is wrapping this class for Ruby/Gosu.
124
- #ifndef SWIG
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
- #endif
139
+ #endif
137
140
 
138
- #ifdef GOSU_IS_IPHONE
141
+ #ifdef GOSU_IS_IPHONE
139
142
  void* uikit_window() const;
140
- #endif
143
+ #endif
141
144
  };
142
145
 
143
- //! Returns the width (in pixels) of a screen.
144
- //! \param window The result describes the screen on which the window is shown, or the
145
- //! primary screen if no window is given.
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
- //! Returns the height (in pixels) of the user's primary screen.
149
- //! \param window The result describes the screen on which the window is shown, or the
150
- //! primary screen if no window is given.
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
- //! Returns the maximum width (in 'points') that is available for a non-fullscreen Window.
154
- //! All windows larger than this size will automatically be shrunk to fit.
155
- //! \param window The result describes the screen on which the window is shown, or the
156
- //! primary screen if no window is given.
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
- //! Returns the maximum height (in 'points') that is available for a non-fullscreen Window.
160
- //! All windows larger than this size will automatically be shrunk to fit.
161
- //! \param window The result describes the screen on which the window is shown, or the
162
- //! primary screen if no window is given.
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