gosu 0.14.0.pre2 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gosu/Bitmap.hpp +4 -0
- data/Gosu/Font.hpp +29 -34
- data/Gosu/Text.hpp +19 -8
- data/Gosu/Utility.hpp +0 -5
- data/Gosu/Version.hpp +2 -2
- data/Gosu/Window.hpp +23 -16
- data/lib/gosu/compat.rb +17 -4
- data/lib/gosu/patches.rb +16 -0
- data/rdoc/gosu.rb +33 -9
- data/src/Bitmap.cpp +20 -0
- data/src/DirectoriesWin.cpp +3 -3
- data/src/DrawOpQueue.hpp +2 -1
- data/src/FileWin.cpp +87 -87
- data/src/Font.cpp +51 -31
- data/src/Graphics.cpp +1 -1
- data/src/GraphicsImpl.hpp +19 -0
- data/src/Input.cpp +30 -12
- data/src/MarkupParser.cpp +11 -8
- data/src/MarkupParser.hpp +2 -2
- data/src/Resolution.cpp +81 -50
- data/src/RubyGosu.cxx +285 -480
- data/src/Text.cpp +77 -50
- data/src/TextBuilder.cpp +1 -1
- data/src/TimingUnix.cpp +1 -1
- data/src/TrueTypeFont.cpp +26 -27
- data/src/TrueTypeFont.hpp +2 -1
- data/src/TrueTypeFontUnix.cpp +1 -1
- data/src/TrueTypeFontWin.cpp +4 -4
- data/src/Utility.cpp +0 -54
- data/src/UtilityApple.cpp +0 -35
- data/src/WinUtility.cpp +60 -41
- data/src/WinUtility.hpp +5 -0
- data/src/Window.cpp +19 -7
- data/src/WindowUIKit.cpp +26 -30
- metadata +4 -5
- data/src/ResolutionApple.cpp +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74fc901e66738f4992205611236f6a7e71e5e3db59f91cda307c54a7b4f1c1d5
|
4
|
+
data.tar.gz: '08b48f76d3a3d55f5d192551abd7c8c41c6b1a5c8fce354261195a179f7f45c9'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb408ee328e685dea6324d6bc8a954b180fd7b1bcb286df3897e7f3b734ba7225c7d05895d21cbfaa9cb168cd59e806a3a16599d9c770603727d9f9a20cb1a7d
|
7
|
+
data.tar.gz: d033a75590ece4317582ad74f6b2183e0ebe715df51d8993c5d2b3754499ca209bebe6bb31d5e3ec38d5a44fd8516e5bd09de50256cf11782243f353fef21871
|
data/Gosu/Bitmap.hpp
CHANGED
@@ -59,6 +59,10 @@ namespace Gosu
|
|
59
59
|
{
|
60
60
|
pixels[y * w + x] = c;
|
61
61
|
}
|
62
|
+
|
63
|
+
//! This updates a pixel using the "over" alpha compositing operator, see:
|
64
|
+
//! https://en.wikipedia.org/wiki/Alpha_compositing
|
65
|
+
void blend_pixel(unsigned x, unsigned y, Color c);
|
62
66
|
|
63
67
|
//! Inserts a bitmap at the given position. Parts of the inserted
|
64
68
|
//! bitmap that would be outside of the target bitmap will be
|
data/Gosu/Font.hpp
CHANGED
@@ -13,10 +13,8 @@
|
|
13
13
|
|
14
14
|
namespace Gosu
|
15
15
|
{
|
16
|
-
//!
|
17
|
-
//!
|
18
|
-
//! static texts you should use create_bitmap and turn the result into
|
19
|
-
//! an image.
|
16
|
+
//! Fonts are ideal for drawing short, dynamic strings.
|
17
|
+
//! For large, static texts you should use Gosu::layout_text and turn the result into an image.
|
20
18
|
class Font
|
21
19
|
{
|
22
20
|
struct Impl;
|
@@ -29,7 +27,7 @@ namespace Gosu
|
|
29
27
|
//! \param font_height Height of the font, in pixels.
|
30
28
|
//! \param font_flags Flags used to render individual characters of
|
31
29
|
//! the font.
|
32
|
-
Font(int height, const std::string& name = default_font_name(), unsigned flags =
|
30
|
+
Font(int height, const std::string& name = default_font_name(), unsigned flags = 0);
|
33
31
|
|
34
32
|
//! Returns the name of the font that was used to create it.
|
35
33
|
const std::string& name() const;
|
@@ -41,45 +39,42 @@ namespace Gosu
|
|
41
39
|
unsigned flags() const;
|
42
40
|
|
43
41
|
//! Returns the width, in pixels, the given text would occupy if drawn.
|
44
|
-
double text_width(const std::string& text
|
42
|
+
double text_width(const std::string& text) const;
|
43
|
+
//! Returns the width, in pixels, the given text would occupy if drawn.
|
44
|
+
double markup_width(const std::string& markup) const;
|
45
45
|
|
46
46
|
//! Draws text so the top left corner of the text is at (x; y).
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
void draw_text(const std::string& text, double x, double y, ZPos z,
|
48
|
+
double scale_x = 1, double scale_y = 1, Color c = Color::WHITE,
|
49
|
+
AlphaMode mode = AM_DEFAULT) const;
|
50
|
+
//! Draws markup so the top left corner of the text is at (x; y).
|
51
|
+
void draw_markup(const std::string& markup, double x, double y, ZPos z,
|
52
|
+
double scale_x = 1, double scale_y = 1, Color c = Color::WHITE,
|
53
|
+
AlphaMode mode = AM_DEFAULT) const;
|
51
54
|
|
52
55
|
//! Draws text at a position relative to (x; y).
|
53
56
|
//! \param rel_x Determines where the text is drawn horizontally. If
|
54
57
|
//! rel_x is 0.0, the text will be to the right of x, if it is 1.0,
|
55
58
|
//! the text will be to the left of x, if it is 0.5, it will be
|
56
|
-
//! centered on x.
|
59
|
+
//! centered on x. All real numbers are possible values.
|
57
60
|
//! \param rel_y See rel_x.
|
58
|
-
void
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
//!
|
63
|
-
//!
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
void
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
//! Maps a letter to a specific image instead of generating one using
|
72
|
-
//! Gosu's built-in text rendering.
|
73
|
-
//! character, and the character must not have been drawn before.
|
74
|
-
//! This ensures that Fonts are still (sort of) immutable.
|
75
|
-
#ifndef SWIG
|
76
|
-
GOSU_DEPRECATED
|
77
|
-
#endif
|
61
|
+
void draw_text_rel(const std::string& text, double x, double y, ZPos z,
|
62
|
+
double rel_x, double rel_y, double scale_x = 1, double scale_y = 1,
|
63
|
+
Color c = Color::WHITE, AlphaMode mode = AM_DEFAULT) const;
|
64
|
+
//! Draws text at a position relative to (x; y).
|
65
|
+
//! \param rel_x Determines where the text is drawn horizontally. If
|
66
|
+
//! rel_x is 0.0, the text will be to the right of x, if it is 1.0,
|
67
|
+
//! the text will be to the left of x, if it is 0.5, it will be
|
68
|
+
//! centered on x. All real numbers are possible values.
|
69
|
+
//! \param rel_y See rel_x.
|
70
|
+
void draw_markup_rel(const std::string& markup, double x, double y, ZPos z,
|
71
|
+
double rel_x, double rel_y, double scale_x = 1, double scale_y = 1,
|
72
|
+
Color c = Color::WHITE, AlphaMode mode = AM_DEFAULT) const;
|
73
|
+
|
74
|
+
//! Maps a letter to a specific image, instead of generating one using
|
75
|
+
//! Gosu's built-in text rendering.
|
78
76
|
void set_image(std::string codepoint, unsigned font_flags, const Gosu::Image& image);
|
79
77
|
//! A shortcut for mapping a character to an image regardless of font_flags.
|
80
|
-
#ifndef SWIG
|
81
|
-
GOSU_DEPRECATED
|
82
|
-
#endif
|
83
78
|
void set_image(std::string codepoint, const Gosu::Image& image);
|
84
79
|
};
|
85
80
|
}
|
data/Gosu/Text.hpp
CHANGED
@@ -20,8 +20,8 @@ namespace Gosu
|
|
20
20
|
double text_width(const std::u32string& text, const std::string& font_name, double font_height,
|
21
21
|
unsigned font_flags = 0);
|
22
22
|
|
23
|
-
//! Draws a line of unformatted text on a bitmap. This is a
|
24
|
-
//!
|
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
25
|
//! \param text A UCS-4 string, normalization: NFC.
|
26
26
|
//! \param font_name Name of a system font, or filename of a TTF file (must contain '/' or '.').
|
27
27
|
//! \param font_height Height, in pixels, of the text.
|
@@ -29,15 +29,23 @@ namespace Gosu
|
|
29
29
|
double draw_text(Bitmap& bitmap, double x, double y, Color c, const std::u32string& text,
|
30
30
|
const std::string& font_name, double font_height, unsigned font_flags = 0);
|
31
31
|
|
32
|
-
//! Creates a bitmap that is filled with
|
32
|
+
//! Creates a bitmap that is filled with the formatted text given to the function.
|
33
33
|
//! The line can contain line breaks and HTML-like markup.
|
34
34
|
//! \param text Formatted text.
|
35
35
|
//! \param font_name Name of a system font, or filename of a TTF file (must contain '/' or '.').
|
36
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.
|
37
44
|
//! \param font_flags Binary combination of members of the FontFlags enum.
|
38
|
-
Bitmap
|
39
|
-
|
40
|
-
|
45
|
+
Bitmap layout_text(const std::string& text, const std::string& font_name,
|
46
|
+
double font_height, double line_spacing = 0,
|
47
|
+
int width = -1, Alignment align = AL_LEFT, unsigned font_flags = 0);
|
48
|
+
|
41
49
|
//! Creates a bitmap that is filled with the formatted text given to the function.
|
42
50
|
//! The line can contain line breaks and HTML-like markup.
|
43
51
|
//! \param text Formatted text.
|
@@ -48,7 +56,10 @@ namespace Gosu
|
|
48
56
|
//! \param width Width of the bitmap that will be returned.
|
49
57
|
//! Text will be split into multiple lines to avoid drawing over the right border.
|
50
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.
|
51
61
|
//! \param font_flags Binary combination of members of the FontFlags enum.
|
52
|
-
Bitmap
|
53
|
-
|
62
|
+
Bitmap layout_markup(const std::string& markup, const std::string& font_name,
|
63
|
+
double font_height, double line_spacing = 0,
|
64
|
+
int width = -1, Alignment align = AL_LEFT, unsigned font_flags = 0);
|
54
65
|
}
|
data/Gosu/Utility.hpp
CHANGED
@@ -7,11 +7,6 @@
|
|
7
7
|
|
8
8
|
namespace Gosu
|
9
9
|
{
|
10
|
-
//! Converts an UTF-8 to UCS-4 or UTF-16, depending on the platform's interpretation of wstring.
|
11
|
-
std::wstring utf8_to_wstring(const std::string& utf8);
|
12
|
-
//! Converts an UCS-4 or UTF-16 to UTF-8, depending on the platform's interpretation of wstring.
|
13
|
-
std::string wstring_to_utf8(const std::wstring& ws);
|
14
|
-
|
15
10
|
std::u32string utf8_to_composed_utc4(const std::string& utf8);
|
16
11
|
|
17
12
|
//! Returns true if the filename has the given extension.
|
data/Gosu/Version.hpp
CHANGED
data/Gosu/Window.hpp
CHANGED
@@ -18,27 +18,12 @@
|
|
18
18
|
|
19
19
|
namespace Gosu
|
20
20
|
{
|
21
|
-
//! Returns the width (in pixels) of the user's primary screen.
|
22
|
-
unsigned screen_width();
|
23
|
-
|
24
|
-
//! Returns the height (in pixels) of the user's primary screen.
|
25
|
-
unsigned screen_height();
|
26
|
-
|
27
|
-
//! Returns the maximum width (in 'points') that is available for a non-fullscreen Window.
|
28
|
-
//! All windows larger than this size will automatically be shrunk to fit.
|
29
|
-
unsigned available_width();
|
30
|
-
|
31
|
-
//! Returns the maximum height (in 'points') that is available for a non-fullscreen Window.
|
32
|
-
//! All windows larger than this size will automatically be shrunk to fit.
|
33
|
-
unsigned available_height();
|
34
|
-
|
35
21
|
//! Convenient all-in-one class that serves as the foundation of a standard Gosu application.
|
36
22
|
//! Manages initialization of all of Gosu's core components and provides timing functionality.
|
37
23
|
//! Note that you should really only use one instance of this class at the same time.
|
38
24
|
class Window
|
39
25
|
{
|
40
26
|
struct Impl;
|
41
|
-
// Non-movable (const) to avoid dangling internal references.
|
42
27
|
const std::unique_ptr<Impl> pimpl;
|
43
28
|
|
44
29
|
public:
|
@@ -68,7 +53,7 @@ namespace Gosu
|
|
68
53
|
virtual void show();
|
69
54
|
|
70
55
|
//! EXPERIMENTAL - MAY DISAPPEAR WITHOUT WARNING.
|
71
|
-
//! Performs a single
|
56
|
+
//! Performs a single main loop step.
|
72
57
|
//! This method is only useful if you want to integrate Gosu with another library that has
|
73
58
|
//! its own main loop.
|
74
59
|
//! This method implicitly shows the window if it was hidden before, and returns false when
|
@@ -141,4 +126,26 @@ namespace Gosu
|
|
141
126
|
void* uikit_window() const;
|
142
127
|
#endif
|
143
128
|
};
|
129
|
+
|
130
|
+
//! Returns the width (in pixels) of a screen.
|
131
|
+
//! \param window The result describes the screen on which the window is shown, or the
|
132
|
+
//! primary screen if no window is given.
|
133
|
+
unsigned screen_width(Window* window = nullptr);
|
134
|
+
|
135
|
+
//! Returns the height (in pixels) of the user's primary screen.
|
136
|
+
//! \param window The result describes the screen on which the window is shown, or the
|
137
|
+
//! primary screen if no window is given.
|
138
|
+
unsigned screen_height(Window* window = nullptr);
|
139
|
+
|
140
|
+
//! Returns the maximum width (in 'points') that is available for a non-fullscreen Window.
|
141
|
+
//! All windows larger than this size will automatically be shrunk to fit.
|
142
|
+
//! \param window The result describes the screen on which the window is shown, or the
|
143
|
+
//! primary screen if no window is given.
|
144
|
+
unsigned available_width(Window* window = nullptr);
|
145
|
+
|
146
|
+
//! Returns the maximum height (in 'points') that is available for a non-fullscreen Window.
|
147
|
+
//! All windows larger than this size will automatically be shrunk to fit.
|
148
|
+
//! \param window The result describes the screen on which the window is shown, or the
|
149
|
+
//! primary screen if no window is given.
|
150
|
+
unsigned available_height(Window* window = nullptr);
|
144
151
|
}
|
data/lib/gosu/compat.rb
CHANGED
@@ -129,7 +129,21 @@ class Gosu::Song
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
|
132
|
+
class Gosu::Font
|
133
|
+
alias_method :draw, :draw_markup
|
134
|
+
Gosu.deprecate Gosu::Font, :draw, "Font#draw_text or Font#draw_markup"
|
135
|
+
|
136
|
+
alias_method :draw_rel, :draw_markup_rel
|
137
|
+
Gosu.deprecate Gosu::Font, :draw_rel, "Font#draw_text_rel or Font#draw_markup_rel"
|
138
|
+
|
139
|
+
def draw_rot(markup, x, y, z, angle, scale_x = 1, scale_y = 1, c = 0xff_ffffff, mode = :default)
|
140
|
+
Gosu.rotate(angle, x, y) { draw_markup(markup, x, y, z, scale_x, scale_y, c, mode) }
|
141
|
+
end
|
142
|
+
|
143
|
+
Gosu.deprecate Gosu::Font, :draw_rot, "Font#draw with Gosu.rotate"
|
144
|
+
end
|
145
|
+
|
146
|
+
# Moved some Window methods to the Gosu module.
|
133
147
|
class Gosu::Window
|
134
148
|
# Class methods that have been turned into module methods.
|
135
149
|
class << self
|
@@ -151,13 +165,12 @@ class Gosu::Window
|
|
151
165
|
Gosu.send method, *args, &block
|
152
166
|
end
|
153
167
|
end
|
168
|
+
|
169
|
+
Gosu.deprecate Gosu::Window, :set_mouse_position, "Window#mouse_x= and Window#mouse_y="
|
154
170
|
end
|
155
171
|
|
156
172
|
# Constants
|
157
173
|
module Gosu
|
158
|
-
Gosu.deprecate Window, :set_mouse_position, "Window#mouse_x= and Window#mouse_y="
|
159
|
-
Gosu.deprecate Font, :draw_rot, "Font#draw with Gosu.rotate"
|
160
|
-
|
161
174
|
# This was renamed because it's not actually a "copyright notice".
|
162
175
|
# (https://en.wikipedia.org/wiki/Copyright_notice)
|
163
176
|
deprecate_const :GOSU_COPYRIGHT_NOTICE, :LICENSES
|
data/lib/gosu/patches.rb
CHANGED
@@ -18,6 +18,22 @@ class ::Numeric
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
class Gosu::Font
|
22
|
+
# draw_text will stop parsing markup in Gosu 1.0.
|
23
|
+
alias_method :draw_text, :draw_markup
|
24
|
+
# draw_text_rel will stop parsing markup in Gosu 1.0.
|
25
|
+
alias_method :draw_text_rel, :draw_markup_rel
|
26
|
+
# text_width will stop parsing markup in Gosu 1.0.
|
27
|
+
alias_method :text_width, :markup_width
|
28
|
+
end
|
29
|
+
|
30
|
+
class Gosu::Image
|
31
|
+
# from_markup will stop parsing markup in Gosu 1.0.
|
32
|
+
def self.from_markup(*args)
|
33
|
+
self.from_text(*args)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
21
37
|
# Color constants.
|
22
38
|
# This is cleaner than having SWIG define them.
|
23
39
|
module Gosu
|
data/rdoc/gosu.rb
CHANGED
@@ -233,7 +233,10 @@ module Gosu
|
|
233
233
|
#
|
234
234
|
# @param height [Integer] the height of the font, in pixels.
|
235
235
|
# @param [Hash] options
|
236
|
-
# @option options [String] :name the name of a system font, or a path to a TrueType Font (TTF) file. A path must contain at least one '/' character to distinguish it from a system font.
|
236
|
+
# @option options [String] :name the name of a system font, or a path to a TrueType Font (TTF) file. A path must contain at least one '/' or '.' character to distinguish it from a system font.
|
237
|
+
# @option options [bool] :bold (false)
|
238
|
+
# @option options [bool] :italic (false)
|
239
|
+
# @option options [bool] :underline (false)
|
237
240
|
#
|
238
241
|
# @overload initialize(height, options = {})
|
239
242
|
# @overload initialize(window, font_name, height)
|
@@ -268,7 +271,11 @@ module Gosu
|
|
268
271
|
# @see Gosu::Image.from_text
|
269
272
|
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
270
273
|
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
|
271
|
-
def
|
274
|
+
def draw_text(text, x, y, z, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
|
275
|
+
|
276
|
+
##
|
277
|
+
# Like {#draw_text}, but supports the following markup tags: `<b>bold</b>`, `<i>italic</i>`, `<c=rrggbb>colors</c>`.
|
278
|
+
def draw_markup(markup, x, y, z, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
|
272
279
|
|
273
280
|
##
|
274
281
|
# Draws a single line of text relative to (x, y).
|
@@ -285,7 +292,11 @@ module Gosu
|
|
285
292
|
# @see #draw
|
286
293
|
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
287
294
|
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
|
288
|
-
def
|
295
|
+
def draw_text_rel(text, x, y, z, rel_x, rel_y, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
|
296
|
+
|
297
|
+
##
|
298
|
+
# Like {#draw_text_rel}, but supports the following markup tags: `<b>bold</b>`, `<i>italic</i>`, `<c=rrggbb>colors</c>`.
|
299
|
+
def draw_markup_rel(markup, x, y, z, rel_x, rel_y, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
|
289
300
|
|
290
301
|
# @!endgroup
|
291
302
|
|
@@ -295,6 +306,10 @@ module Gosu
|
|
295
306
|
# @return [Integer] the width of the text, in pixels.
|
296
307
|
# @param text [String]
|
297
308
|
def text_width(text, scale_x=1); end
|
309
|
+
|
310
|
+
##
|
311
|
+
# Like {#text_width}, but supports the following markup tags: `<b>bold</b>`, `<i>italic</i>`, `<c=rrggbb>colors</c>`.
|
312
|
+
def markup_width(markup, scale_x=1); end
|
298
313
|
end
|
299
314
|
|
300
315
|
##
|
@@ -348,6 +363,9 @@ module Gosu
|
|
348
363
|
# @param [Integer] line_height the line height, in pixels.
|
349
364
|
# @param [Hash] options
|
350
365
|
# @option options [String] :font (Gosu::default_font_name) the name of a system font, or a path to a TrueType Font (TTF) file. A path must contain at least one '/' character to distinguish it from a system font.
|
366
|
+
# @option options [bool] :bold (false)
|
367
|
+
# @option options [bool] :italic (false)
|
368
|
+
# @option options [bool] :underline (false)
|
351
369
|
# @option options [Integer] :width the width of the image, in pixels. Long lines will be automatically wrapped around to avoid overflow, but overlong words will be truncated. If this option is omitted, lines will not be wrapped, and :align and :spacing will be ignored as well.
|
352
370
|
# @option options [Integer] :spacing (0) the spacing between lines, in pixels.
|
353
371
|
# @option options [:left, :right, :center, :justify] :align (:left) the text alignment.
|
@@ -357,6 +375,10 @@ module Gosu
|
|
357
375
|
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
358
376
|
def self.from_text(text, line_height, options = {}); end
|
359
377
|
|
378
|
+
##
|
379
|
+
# Like {#from_text}, but supports the following markup tags: `<b>bold</b>`, `<i>italic</i>`, `<c=rrggbb>colors</c>`.
|
380
|
+
def self.from_markup(markup, line_height, options = {}); end
|
381
|
+
|
360
382
|
##
|
361
383
|
# Loads an image from a file or an RMagick image, then divides the image into an array of equal-sized tiles.
|
362
384
|
#
|
@@ -1223,20 +1245,22 @@ module Gosu
|
|
1223
1245
|
def default_font_name(); end
|
1224
1246
|
|
1225
1247
|
##
|
1226
|
-
# @return [Integer] the width (in pixels) of
|
1227
|
-
|
1248
|
+
# @return [Integer] the width (in pixels) of a screen.
|
1249
|
+
# @param window [Gosu::Window] The result describes the screen on which the window is shown, or the primary screen if no window is given.
|
1250
|
+
def screen_width(window = nil); end
|
1228
1251
|
|
1229
|
-
# @return [Integer] the height (in pixels) of
|
1230
|
-
|
1252
|
+
# @return [Integer] the height (in pixels) of a screen.
|
1253
|
+
# @param window [Gosu::Window] The result describes the screen on which the window is shown, or the primary screen if no window is given.
|
1254
|
+
def screen_height(window = nil); end
|
1231
1255
|
|
1232
1256
|
##
|
1233
1257
|
# @return [Integer] the maximum width (in 'points') that is available for a non-fullscreen Window.
|
1234
1258
|
# All windows larger than this size will automatically be shrunk to fit.
|
1235
|
-
def available_width(); end
|
1259
|
+
def available_width(window = nil); end
|
1236
1260
|
|
1237
1261
|
# @return [Integer] the maximum height (in 'points') that is available for a non-fullscreen Window.
|
1238
1262
|
# All windows larger than this size will automatically be shrunk to fit.
|
1239
|
-
def available_height(); end
|
1263
|
+
def available_height(window = nil); end
|
1240
1264
|
|
1241
1265
|
##
|
1242
1266
|
# Returns the language code for the user's preferred language.
|
data/src/Bitmap.cpp
CHANGED
@@ -19,6 +19,26 @@ void Gosu::Bitmap::resize(unsigned width, unsigned height, Color c)
|
|
19
19
|
temp.insert(*this, 0, 0);
|
20
20
|
swap(temp);
|
21
21
|
}
|
22
|
+
|
23
|
+
void Gosu::Bitmap::blend_pixel(unsigned x, unsigned y, Color c)
|
24
|
+
{
|
25
|
+
if (c.alpha() == 0) return;
|
26
|
+
|
27
|
+
Color out = get_pixel(x, y);
|
28
|
+
if (out.alpha() == 0) {
|
29
|
+
set_pixel(x, y, c);
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
|
33
|
+
int inv_alpha = out.alpha() * (255 - c.alpha()) / 255;
|
34
|
+
|
35
|
+
out.set_alpha(c.alpha() + inv_alpha);
|
36
|
+
out.set_red ((c.red() * c.alpha() + out.red() * inv_alpha) / out.alpha());
|
37
|
+
out.set_green((c.green() * c.alpha() + out.green() * inv_alpha) / out.alpha());
|
38
|
+
out.set_blue ((c.blue() * c.alpha() + out.blue() * inv_alpha) / out.alpha());
|
39
|
+
|
40
|
+
set_pixel(x, y, out);
|
41
|
+
}
|
22
42
|
|
23
43
|
void Gosu::Bitmap::insert(const Bitmap& source, int x, int y)
|
24
44
|
{
|
data/src/DirectoriesWin.cpp
CHANGED
@@ -20,7 +20,7 @@ static string special_folder_path(int csidl)
|
|
20
20
|
buf[len] = L'\\';
|
21
21
|
buf[len + 1] = 0;
|
22
22
|
}
|
23
|
-
return Gosu::
|
23
|
+
return Gosu::utf16_to_utf8(buf);
|
24
24
|
}
|
25
25
|
|
26
26
|
static string exe_filename()
|
@@ -30,14 +30,14 @@ static string exe_filename()
|
|
30
30
|
WCHAR buffer[MAX_PATH * 2];
|
31
31
|
Gosu::winapi_check(GetModuleFileNameW(nullptr, buffer, MAX_PATH * 2),
|
32
32
|
"getting the module filename");
|
33
|
-
result = Gosu::
|
33
|
+
result = Gosu::utf16_to_utf8(buffer);
|
34
34
|
}
|
35
35
|
return result;
|
36
36
|
}
|
37
37
|
|
38
38
|
void Gosu::use_resource_directory()
|
39
39
|
{
|
40
|
-
SetCurrentDirectory(
|
40
|
+
SetCurrentDirectory(utf8_to_utf16(resource_prefix()).c_str());
|
41
41
|
}
|
42
42
|
|
43
43
|
string Gosu::resource_prefix()
|