gosu 1.1.0.pre2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70dc24184a235da8dc66f4bac07da231b87ab9f4a7469d06331ba048da6bc5b6
4
- data.tar.gz: 0fab031220b2912e66d29e53e1c4dbee51823e042b75927e31415bca59056ac3
3
+ metadata.gz: 7d58f7d332c57be8c599f33a6c60df54d7143e6ef2980eacd1a84f5d51f7a26a
4
+ data.tar.gz: e22cf468c5392985d6429aac77b958d71c63c33ac40a4a06b1f01187837bb224
5
5
  SHA512:
6
- metadata.gz: 59567c7edd20676430b16a27f260fb64f6309d992215cf5f3e22cf8311d39a263945836b040ebd46cb9ee4e0e9a430a0cc1f84d35fc8b3ea8f1ca4b79b170bb6
7
- data.tar.gz: 31afdb7a4465c4c59002a2a044202b43803db915c9ae6940fb87606b51e9907707591db591d6baa60c1aadf89104a045a12bfdeb81e7c80bed76dfb9d8284709
6
+ metadata.gz: 69605aee52675d916c27e58ad596d294ea4268e24520b137a2afa184a38f92b4120646a1e0c3ada0e6293088db9f965adf907a99b164052ee741b81cfd2a779c
7
+ data.tar.gz: 55615664e9ababb8ee986af01191a296b364d53d42986fcd45a94436b33f4d59aa46643da62a14e0e0a960def6a699d782f03bf74876c70405e4f6ec4d8591df
data/COPYING CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2001-2020 Julian Raschke, Jan Lücker and all contributors.
1
+ Copyright (C) 2001-2021 Julian Raschke, Jan Lücker and all contributors.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a
4
4
  copy of this software and associated documentation files (the "Software"),
data/ext/gosu/extconf.rb CHANGED
@@ -51,7 +51,7 @@ if windows
51
51
  else
52
52
  $LDFLAGS << " -L../../dependencies/al_soft/x86 -L../../dependencies/SDL/lib/x86"
53
53
  end
54
- $LDFLAGS << " -lgdi32 -lwinmm -lOpenGL32 -lOpenAL32 -lSDL2"
54
+ $LDFLAGS << " -lgdi32 -lwinmm -ldwmapi -lOpenGL32 -lOpenAL32 -lSDL2"
55
55
  # Link libstdc++ statically to avoid having another DLL dependency when using Ocra.
56
56
  $LDFLAGS << " -static-libstdc++"
57
57
  elsif macos
@@ -62,6 +62,10 @@ elsif macos
62
62
  # rvm will sometimes try to override this:
63
63
  # https://github.com/shawn42/gamebox/issues/96
64
64
  $CXXFLAGS << " -stdlib=libc++"
65
+
66
+ # Disable an error that is disabled by default and prevents Gosu from building with universal Ruby:
67
+ # https://trac.macports.org/ticket/58255 / https://github.com/gosu/gosu/issues/424
68
+ $CXXFLAGS << " -Wno-reserved-user-defined-literal"
65
69
 
66
70
  # Dependencies.
67
71
  $CFLAGS << " #{`sdl2-config --cflags`.chomp}"
@@ -1,6 +1,3 @@
1
- //! \file Color.hpp
2
- //! Interface of the Color class.
3
-
4
1
  #pragma once
5
2
 
6
3
  #include <Gosu/Platform.hpp>
@@ -8,154 +5,105 @@
8
5
 
9
6
  namespace Gosu
10
7
  {
11
- //! Represents an RGBA color value with 8 bits for each channel.
12
- //! Can be implicitly constructed from literals of the form 0xaarrggbb.
13
- //! Has fast value semantics.
14
- //! The four-byte layout in memory is RGBA. On Big-Endian machines the unsigned int will look
15
- //! like 0xrrggbbaa, on Little-Endian machines it is 0xaabbggrr.
16
- class Color
8
+ /// Represents an RGBA color value with 8 bit for each channel.
9
+ /// Can be implicitly constructed from literals of the form 0xaarrggbb.
10
+ struct Color
17
11
  {
18
- std::uint32_t rep;
19
- #ifdef GOSU_IS_LITTLE_ENDIAN
20
- enum { RED_OFFSET = 0, GREEN_OFFSET = 8, BLUE_OFFSET = 16, ALPHA_OFFSET = 24 };
21
- #else
22
- enum { RED_OFFSET = 24, GREEN_OFFSET = 16, BLUE_OFFSET = 8, ALPHA_OFFSET = 0 };
23
- #endif
24
-
25
- public:
26
- typedef std::uint8_t Channel;
27
12
  static const unsigned GL_FORMAT = 0x1908; // GL_RGBA
28
-
29
- //! The default constructor does not initialize the color to any value.
30
- Color()
31
- {
32
- }
33
-
34
- //! Conversion constructor for literals of the form 0xaarrggbb.
35
- Color(unsigned argb)
36
- : Color((argb >> 24) & 0xff, (argb >> 16) & 0xff, (argb >> 8) & 0xff, (argb >> 0) & 0xff)
37
- {
38
- }
39
-
40
- Color(Channel red, Channel green, Channel blue)
41
- : Color(0xff, red, green, blue)
42
- {
43
- }
44
-
45
- Color(Channel alpha, Channel red, Channel green, Channel blue)
46
- {
47
- rep = (alpha << ALPHA_OFFSET) | (red << RED_OFFSET) |
48
- (green << GREEN_OFFSET) | (blue << BLUE_OFFSET);
49
- }
50
-
51
- //! Constructs a color from the given hue/saturation/value triple.
52
- //! Ranges of these values are given as 0..360, 0..1, and 0..1, respectively.
53
- static Color from_hsv(double h, double s, double v);
54
-
55
- //! Constructs a color from the given hue/saturation/value triple.
56
- //! Ranges of these values are given as 0..360, 0..1, and 0..1, respectively.
57
- static Color from_ahsv(Channel alpha, double h, double s, double v);
58
13
 
59
- Channel red() const
60
- {
61
- return static_cast<Channel>(rep >> RED_OFFSET);
62
- }
63
-
64
- Channel green() const
65
- {
66
- return static_cast<Channel>(rep >> GREEN_OFFSET);
67
- }
14
+ typedef std::uint8_t Channel;
68
15
 
69
- Channel blue() const
70
- {
71
- return static_cast<Channel>(rep >> BLUE_OFFSET);
72
- }
16
+ Channel red, green, blue, alpha;
73
17
 
74
- Channel alpha() const
18
+ constexpr Color()
19
+ : red{0}, green{0}, blue{0}, alpha{0}
75
20
  {
76
- return static_cast<Channel>(rep >> ALPHA_OFFSET);
77
21
  }
78
22
 
79
- void set_red(Channel value)
23
+ /// Conversion constructor for literals of the form 0xaarrggbb.
24
+ // NOLINTNEXTLINE: We want to allow implicit conversions.
25
+ constexpr Color(std::uint32_t argb)
26
+ : red{static_cast<Channel>(argb >> 16)}, green{static_cast<Channel>(argb >> 8)},
27
+ blue{static_cast<Channel>(argb >> 0)}, alpha{static_cast<Channel>(argb >> 24)}
80
28
  {
81
- rep &= ~(0xff << RED_OFFSET);
82
- rep |= value << RED_OFFSET;
83
29
  }
84
30
 
85
- void set_green(Channel value)
31
+ constexpr Color(Channel red, Channel green, Channel blue)
32
+ : red{red}, green{green}, blue{blue}, alpha{255}
86
33
  {
87
- rep &= ~(0xff << GREEN_OFFSET);
88
- rep |= value << GREEN_OFFSET;
89
34
  }
90
35
 
91
- void set_blue(Channel value)
36
+ Color with_alpha(Channel new_alpha)
92
37
  {
93
- rep &= ~(0xff << BLUE_OFFSET);
94
- rep |= value << BLUE_OFFSET;
38
+ Color result = *this;
39
+ result.alpha = new_alpha;
40
+ return result;
95
41
  }
96
42
 
97
- void set_alpha(Channel value)
98
- {
99
- rep &= ~(0xff << ALPHA_OFFSET);
100
- rep |= value << ALPHA_OFFSET;
101
- }
43
+ /// Constructs a color from the given hue/saturation/value triple.
44
+ /// Ranges of these values are given as 0..360, 0..1, and 0..1, respectively.
45
+ static Color from_hsv(double h, double s, double v);
102
46
 
103
- //! Returns the hue of the color, in the usual range of 0..360.
47
+ /// Returns the hue of the color, in the usual range of 0..360.
104
48
  double hue() const;
105
49
 
106
- //! Changes the current color so hue() will return h.
50
+ /// Changes the current color so hue() will return h.
107
51
  void set_hue(double h);
108
52
 
109
- //! Returns the saturation of the color, in the range of 0..1.
53
+ /// Returns the saturation of the color, in the range of 0..1.
110
54
  double saturation() const;
111
55
 
112
- //! Changes the current color so saturation() will return s.
56
+ /// Changes the current color so saturation() will return s.
113
57
  void set_saturation(double s);
114
58
 
115
- //! Returns the value (brightness) of the color, in the range of 0..1.
59
+ /// Returns the value (brightness) of the color, in the range of 0..1.
116
60
  double value() const;
117
61
 
118
- //! Changes the current color so value() will return v.
62
+ /// Changes the current color so value() will return v.
119
63
  void set_value(double v);
120
64
 
121
- //! Returns the color in 0xaarrggbb representation.
122
- std::uint32_t argb() const { return alpha() << 24 | red() << 16 | green() << 8 | blue(); }
65
+ /// Returns the color in 0xaarrggbb representation.
66
+ std::uint32_t argb() const { return alpha << 24 | red << 16 | green << 8 | blue; }
123
67
 
124
- //! Returns the color in 0x00bbggrr representation. Useful for Win32 programming.
125
- std::uint32_t bgr() const { return blue() << 16 | green() << 8 | red(); }
68
+ /// Returns the color in 0x00bbggrr representation. Useful for Win32 programming.
69
+ std::uint32_t bgr() const { return blue << 16 | green << 8 | red; }
70
+
71
+ /// Returns the color in 0xaabbggrr representation.
72
+ std::uint32_t abgr() const { return alpha << 24 | blue << 16 | green << 8 | red; }
73
+
74
+ /// Returns the internal representation of the color (RGBA in memory).
75
+ std::uint32_t gl() const { return *reinterpret_cast<const std::uint32_t*>(this); }
126
76
 
127
- //! Returns the color in 0xaabbggrr representation.
128
- std::uint32_t abgr() const { return alpha() << 24 | blue() << 16 | green() << 8 | red(); }
129
-
130
- //! Returns the internal representation of the color (RGBA in memory).
131
- std::uint32_t gl() const { return rep; }
132
-
133
77
  static const Color NONE;
134
78
  static const Color BLACK;
135
79
  static const Color GRAY;
136
80
  static const Color WHITE;
137
-
81
+
82
+ /// Same as Color::CYAN.
138
83
  static const Color AQUA;
139
84
  static const Color RED;
140
85
  static const Color GREEN;
141
86
  static const Color BLUE;
142
87
  static const Color YELLOW;
143
88
  static const Color FUCHSIA;
89
+ /// Same as Color::AQUA.
144
90
  static const Color CYAN;
145
91
  };
92
+
93
+ // Ensure that we can pass vectors of Gosu::Color straight to OpenGL and back.
94
+ static_assert(sizeof(Color) == sizeof(std::uint32_t));
146
95
 
147
96
  #ifndef SWIG
148
97
  inline bool operator<(Color a, Color b) { return a.gl() < b.gl(); }
149
98
  inline bool operator==(Color a, Color b) { return a.gl() == b.gl(); }
150
99
  inline bool operator!=(Color a, Color b) { return a.gl() != b.gl(); }
151
100
 
152
- //! Interpolates linearly between two colors, with a given weight towards
153
- //! the second color.
154
- //! Specialization of the general function in Gosu/Math.hpp.
155
- Color interpolate(Color a, Color b, double weight = 0.5);
101
+ /// Interpolates linearly between two colors, with a given weight towards
102
+ /// the second color.
103
+ Color lerp(Color a, Color b, double t = 0.5);
156
104
 
157
- //! Combines two colors as if their channels were mapped to the 0..1 range
158
- //! and then multiplied with each other.
105
+ /// Combines two colors as if their channels were mapped to the 0..1 range
106
+ /// and then multiplied with each other.
159
107
  Color multiply(Color a, Color b);
160
108
  #endif
161
109
  }
@@ -22,11 +22,9 @@ namespace Gosu
22
22
 
23
23
  public:
24
24
  //! Constructs a font that can be drawn onto the graphics object.
25
- //! \param font_name Name of a system font, or a filename to a TTF
26
- //! file (must contain '/', does not work on Linux).
27
- //! \param font_height Height of the font, in pixels.
28
- //! \param font_flags Flags used to render individual characters of
29
- //! the font.
25
+ //! \param name Name of a system font, or a filename to a TTF file.
26
+ //! \param height Height of the font, in pixels.
27
+ //! \param flags Flags used to render individual characters of the font.
30
28
  Font(int height, const std::string& name = default_font_name(), unsigned flags = 0);
31
29
 
32
30
  //! Returns the name of the font that was used to create it.
@@ -46,11 +44,11 @@ namespace Gosu
46
44
  //! Draws text so the top left corner of the text is at (x; y).
47
45
  void draw_text(const std::string& text, double x, double y, ZPos z,
48
46
  double scale_x = 1, double scale_y = 1, Color c = Color::WHITE,
49
- AlphaMode mode = AM_DEFAULT) const;
47
+ BlendMode mode = BM_DEFAULT) const;
50
48
  //! Draws markup so the top left corner of the text is at (x; y).
51
49
  void draw_markup(const std::string& markup, double x, double y, ZPos z,
52
50
  double scale_x = 1, double scale_y = 1, Color c = Color::WHITE,
53
- AlphaMode mode = AM_DEFAULT) const;
51
+ BlendMode mode = BM_DEFAULT) const;
54
52
 
55
53
  //! Draws text at a position relative to (x; y).
56
54
  //! \param rel_x Determines where the text is drawn horizontally. If
@@ -60,7 +58,7 @@ namespace Gosu
60
58
  //! \param rel_y See rel_x.
61
59
  void draw_text_rel(const std::string& text, double x, double y, ZPos z,
62
60
  double rel_x, double rel_y, double scale_x = 1, double scale_y = 1,
63
- Color c = Color::WHITE, AlphaMode mode = AM_DEFAULT) const;
61
+ Color c = Color::WHITE, BlendMode mode = BM_DEFAULT) const;
64
62
  //! Draws text at a position relative to (x; y).
65
63
  //! \param rel_x Determines where the text is drawn horizontally. If
66
64
  //! rel_x is 0.0, the text will be to the right of x, if it is 1.0,
@@ -69,7 +67,7 @@ namespace Gosu
69
67
  //! \param rel_y See rel_x.
70
68
  void draw_markup_rel(const std::string& markup, double x, double y, ZPos z,
71
69
  double rel_x, double rel_y, double scale_x = 1, double scale_y = 1,
72
- Color c = Color::WHITE, AlphaMode mode = AM_DEFAULT) const;
70
+ Color c = Color::WHITE, BlendMode mode = BM_DEFAULT) const;
73
71
 
74
72
  //! Maps a letter to a specific image, instead of generating one using
75
73
  //! Gosu's built-in text rendering.
data/include/Gosu/Fwd.hpp CHANGED
@@ -5,7 +5,7 @@ namespace Gosu
5
5
  class Bitmap;
6
6
  class Buffer;
7
7
  class Channel;
8
- class Color;
8
+ struct Color;
9
9
  class File;
10
10
  class Font;
11
11
  class Graphics;
@@ -78,21 +78,23 @@ namespace Gosu
78
78
  //! image to simulate lines, or contribute a better draw_line to Gosu.
79
79
  static void draw_line(double x1, double y1, Color c1,
80
80
  double x2, double y2, Color c2,
81
- ZPos z, AlphaMode mode = AM_DEFAULT);
81
+ ZPos z, BlendMode mode = BM_DEFAULT);
82
82
 
83
83
  static void draw_triangle(double x1, double y1, Color c1,
84
84
  double x2, double y2, Color c2,
85
85
  double x3, double y3, Color c3,
86
- ZPos z, AlphaMode mode = AM_DEFAULT);
86
+ ZPos z,
87
+ BlendMode mode = BM_DEFAULT);
87
88
 
88
89
  static void draw_quad(double x1, double y1, Color c1,
89
90
  double x2, double y2, Color c2,
90
91
  double x3, double y3, Color c3,
91
92
  double x4, double y4, Color c4,
92
- ZPos z, AlphaMode mode = AM_DEFAULT);
93
+ ZPos z, BlendMode mode = BM_DEFAULT);
93
94
 
94
95
  static void draw_rect(double x, double y, double width, double height,
95
- Color c, ZPos z, AlphaMode mode = AM_DEFAULT);
96
+ Color c, ZPos z,
97
+ BlendMode mode = BM_DEFAULT);
96
98
 
97
99
  //! For internal use only.
98
100
  void set_physical_resolution(unsigned physical_width, unsigned physical_height);
@@ -15,18 +15,18 @@ namespace Gosu
15
15
 
16
16
  //! Determines the way colors are combined when one is drawn onto
17
17
  //! another.
18
- enum AlphaMode
18
+ enum BlendMode
19
19
  {
20
- AM_DEFAULT,
20
+ BM_DEFAULT,
21
21
  //! The color's channels will be interpolated. The alpha channel
22
22
  //! specifies the opacity of the new color, 255 is full opacity.
23
- AM_INTERPOLATE = AM_DEFAULT,
23
+ BM_INTERPOLATE = BM_DEFAULT,
24
24
  //! The colors' channels will be added. The alpha channel specifies
25
25
  //! the percentage of the new color's channels that will be added
26
26
  //! to the old color's channels.
27
- AM_ADD,
27
+ BM_ADD,
28
28
  //! The color's channels will be multiplied with each other.
29
- AM_MULTIPLY
29
+ BM_MULTIPLY
30
30
  };
31
31
 
32
32
  enum FontFlags
@@ -50,7 +50,7 @@ namespace Gosu
50
50
  {
51
51
  IF_SMOOTH = 0,
52
52
 
53
- // Note: No constant for '1', but Gosu treats '1' as if_tileable for
53
+ // Note: No constant for '1', but Gosu treats '1' as IF_TILEABLE for
54
54
  // backward compatibility reasons (this parameter used to be a bool).
55
55
 
56
56
  IF_TILEABLE_LEFT = 1 << 1,
@@ -49,10 +49,10 @@ namespace Gosu
49
49
 
50
50
  //! Draws the image so its upper left corner is at (x; y).
51
51
  void draw(double x, double y, ZPos z = 0, double scale_x = 1, double scale_y = 1,
52
- Color c = Color::WHITE, AlphaMode mode = AM_DEFAULT) const;
52
+ Color c = Color::WHITE, BlendMode mode = BM_DEFAULT) const;
53
53
  //! Like draw(), but with modulation colors for all four corners.
54
54
  void draw_mod(double x, double y, ZPos z, double scale_x, double scale_y,
55
- Color c1, Color c2, Color c3, Color c4, AlphaMode mode = AM_DEFAULT) const;
55
+ Color c1, Color c2, Color c3, Color c4, BlendMode mode = BM_DEFAULT) const;
56
56
 
57
57
  //! Draws the image rotated by the given angle so that its rotation
58
58
  //! center is at (x; y). Note that this is different from how all the
@@ -65,7 +65,7 @@ namespace Gosu
65
65
  //! \param center_y See center_x.
66
66
  void draw_rot(double x, double y, ZPos z = 0, double angle = 0,
67
67
  double center_x = 0.5, double center_y = 0.5, double scale_x = 1, double scale_y = 1,
68
- Color c = Color::WHITE, AlphaMode mode = AM_DEFAULT) const;
68
+ Color c = Color::WHITE, BlendMode mode = BM_DEFAULT) const;
69
69
 
70
70
  #ifndef SWIG
71
71
  //! Provides access to the underlying image data object.
@@ -44,7 +44,7 @@ namespace Gosu
44
44
  double x2, double y2, Color c2,
45
45
  double x3, double y3, Color c3,
46
46
  double x4, double y4, Color c4,
47
- ZPos z, AlphaMode mode) const = 0;
47
+ ZPos z, BlendMode mode) const = 0;
48
48
 
49
49
  virtual const GLTexInfo* gl_tex_info() const = 0;
50
50
 
@@ -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 unformatted 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 formatted text given to the function.
33
- //! The line can contain line breaks and HTML-like markup.
34
- //! \param text Formatted 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 text 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,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 3
7
7
  #define GOSU_POINT_VERSION 0
8
8
 
9
9
  namespace Gosu