gosu 1.4.1 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/dependencies/SDL_sound/SDL_sound.c +21 -63
- data/dependencies/SDL_sound/SDL_sound.h +2 -2
- data/dependencies/SDL_sound/SDL_sound_aiff.c +26 -23
- data/dependencies/SDL_sound/SDL_sound_au.c +8 -8
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +4 -5
- data/dependencies/SDL_sound/SDL_sound_flac.c +28 -30
- data/dependencies/SDL_sound/SDL_sound_internal.h +4 -4
- data/dependencies/SDL_sound/SDL_sound_modplug.c +1 -1
- data/dependencies/SDL_sound/SDL_sound_mp3.c +19 -23
- data/dependencies/SDL_sound/SDL_sound_raw.c +5 -6
- data/dependencies/SDL_sound/SDL_sound_shn.c +4 -4
- data/dependencies/SDL_sound/SDL_sound_voc.c +15 -15
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +14 -7
- data/dependencies/SDL_sound/SDL_sound_wav.c +17 -17
- data/dependencies/SDL_sound/dr_flac.h +10840 -4779
- data/dependencies/SDL_sound/dr_mp3.h +2793 -1004
- data/dependencies/SDL_sound/libmodplug/fastmix.c +5 -0
- data/dependencies/SDL_sound/libmodplug/load_669.c +1 -1
- data/dependencies/SDL_sound/libmodplug/load_amf.c +1 -0
- data/dependencies/SDL_sound/libmodplug/load_ams.c +38 -22
- data/dependencies/SDL_sound/libmodplug/load_it.c +18 -14
- data/dependencies/SDL_sound/libmodplug/load_mdl.c +18 -9
- data/dependencies/SDL_sound/libmodplug/load_med.c +7 -6
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +36 -17
- data/dependencies/SDL_sound/libmodplug/load_okt.c +51 -24
- data/dependencies/SDL_sound/libmodplug/load_psm.c +4 -2
- data/dependencies/SDL_sound/libmodplug/load_s3m.c +4 -4
- data/dependencies/SDL_sound/libmodplug/load_ult.c +4 -3
- data/dependencies/SDL_sound/libmodplug/load_xm.c +5 -5
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +8 -1
- data/dependencies/SDL_sound/libmodplug/sndfile.c +21 -4
- data/dependencies/SDL_sound/stb_vorbis.h +10 -18
- data/dependencies/mojoAL/mojoal.c +260 -6
- data/dependencies/stb/stb_image.h +208 -73
- data/dependencies/stb/stb_image_write.h +57 -23
- data/dependencies/stb/stb_truetype.h +345 -279
- data/dependencies/utf8proc/utf8proc.c +37 -18
- data/dependencies/utf8proc/utf8proc.h +17 -5
- data/dependencies/utf8proc/utf8proc_data.h +12012 -10089
- data/ext/gosu/extconf.rb +6 -3
- data/include/Gosu/Buttons.hpp +103 -103
- data/include/Gosu/Directories.hpp +31 -24
- data/include/Gosu/Font.hpp +4 -2
- data/include/Gosu/Gosu.hpp +5 -8
- data/include/Gosu/IO.hpp +0 -3
- data/include/Gosu/Input.hpp +7 -1
- data/include/Gosu/Math.hpp +0 -3
- data/include/Gosu/TextInput.hpp +3 -3
- data/include/Gosu/Timing.hpp +3 -6
- data/include/Gosu/Version.hpp +1 -1
- data/include/Gosu/Window.hpp +3 -2
- data/rdoc/gosu.rb +16 -2
- data/src/Audio.cpp +2 -2
- data/src/AudioFileAudioToolbox.cpp +1 -1
- data/src/AudioFileSDLSound.cpp +1 -1
- data/src/AudioImpl.cpp +0 -7
- data/src/AudioImpl.hpp +1 -3
- data/src/BitmapIO.cpp +23 -2
- data/src/BlockAllocator.cpp +1 -1
- data/src/DirectoriesApple.cpp +25 -24
- data/src/DirectoriesUnix.cpp +14 -12
- data/src/DirectoriesWin.cpp +26 -30
- data/src/FileUnix.cpp +1 -1
- data/src/FileWin.cpp +1 -1
- data/src/Font.cpp +13 -3
- data/src/Graphics.cpp +1 -1
- data/src/Image.cpp +10 -15
- data/src/Input.cpp +16 -1
- data/src/InputUIKit.cpp +1 -1
- data/src/Macro.cpp +1 -1
- data/src/RubyGosu.cxx +76 -34
- data/src/TextInput.cpp +1 -1
- data/src/TimingApple.cpp +2 -2
- data/src/TimingUnix.cpp +3 -7
- data/src/TimingWin.cpp +1 -2
- data/src/TrueTypeFont.cpp +1 -1
- data/src/Window.cpp +5 -4
- data/src/WindowUIKit.cpp +1 -1
- metadata +3 -3
data/ext/gosu/extconf.rb
CHANGED
@@ -74,9 +74,12 @@ elsif macos
|
|
74
74
|
$LDFLAGS << " #{`sdl2-config --static-libs`.chomp} -framework OpenGL -framework Metal"
|
75
75
|
# And yet another hack: `sdl2-config --static-libs` uses `-lSDL2` instead of linking to the static library,
|
76
76
|
# even if it exists. -> Manually replace it. (Ugh!)
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
static_lib = if RbConfig::CONFIG["target_cpu"] == "arm64"
|
78
|
+
"/opt/homebrew/opt/sdl2/lib/libSDL2.a"
|
79
|
+
else
|
80
|
+
"/usr/local/lib/libSDL2.a"
|
81
|
+
end
|
82
|
+
$LDFLAGS.sub! " -lSDL2 ", " #{static_lib} " if File.exist? static_lib
|
80
83
|
|
81
84
|
# Disable building of 32-bit slices in Apple's Ruby.
|
82
85
|
# (RbConfig::CONFIG['CXXFLAGS'] on 10.11: -arch x86_64 -arch i386 -g -Os -pipe)
|
data/include/Gosu/Buttons.hpp
CHANGED
@@ -7,111 +7,111 @@ namespace Gosu
|
|
7
7
|
/// mouse buttons and mouse wheel (MS_*), as well as gamepad buttons (GP_*).
|
8
8
|
enum Button
|
9
9
|
{
|
10
|
-
KB_ESCAPE
|
11
|
-
KB_F1
|
12
|
-
KB_F2
|
13
|
-
KB_F3
|
14
|
-
KB_F4
|
15
|
-
KB_F5
|
16
|
-
KB_F6
|
17
|
-
KB_F7
|
18
|
-
KB_F8
|
19
|
-
KB_F9
|
20
|
-
KB_F10
|
21
|
-
KB_F11
|
22
|
-
KB_F12
|
23
|
-
KB_0
|
24
|
-
KB_1
|
25
|
-
KB_2
|
26
|
-
KB_3
|
27
|
-
KB_4
|
28
|
-
KB_5
|
29
|
-
KB_6
|
30
|
-
KB_7
|
31
|
-
KB_8
|
32
|
-
KB_9
|
33
|
-
KB_TAB
|
34
|
-
KB_RETURN
|
35
|
-
KB_SPACE
|
36
|
-
KB_LEFT_SHIFT
|
37
|
-
KB_RIGHT_SHIFT
|
38
|
-
KB_LEFT_CONTROL
|
39
|
-
KB_RIGHT_CONTROL
|
40
|
-
KB_LEFT_ALT
|
41
|
-
KB_RIGHT_ALT
|
42
|
-
KB_LEFT_META
|
43
|
-
KB_RIGHT_META
|
44
|
-
KB_BACKSPACE
|
45
|
-
KB_LEFT
|
46
|
-
KB_RIGHT
|
47
|
-
KB_UP
|
48
|
-
KB_DOWN
|
49
|
-
KB_HOME
|
50
|
-
KB_END
|
51
|
-
KB_PRINT_SCREEN
|
52
|
-
KB_SCROLL_LOCK
|
53
|
-
KB_PAUSE
|
54
|
-
KB_INSERT
|
55
|
-
KB_DELETE
|
56
|
-
KB_PAGE_UP
|
57
|
-
KB_PAGE_DOWN
|
58
|
-
KB_ENTER
|
59
|
-
KB_BACKTICK
|
60
|
-
KB_MINUS
|
61
|
-
KB_EQUALS
|
62
|
-
KB_LEFT_BRACKET
|
63
|
-
KB_RIGHT_BRACKET
|
64
|
-
KB_BACKSLASH
|
65
|
-
KB_SEMICOLON
|
66
|
-
KB_APOSTROPHE
|
67
|
-
KB_COMMA
|
68
|
-
KB_PERIOD
|
69
|
-
KB_SLASH
|
70
|
-
KB_CAPS_LOCK
|
71
|
-
KB_A
|
72
|
-
KB_B
|
73
|
-
KB_C
|
74
|
-
KB_D
|
75
|
-
KB_E
|
76
|
-
KB_F
|
77
|
-
KB_G
|
78
|
-
KB_H
|
79
|
-
KB_I
|
80
|
-
KB_J
|
81
|
-
KB_K
|
82
|
-
KB_L
|
83
|
-
KB_M
|
84
|
-
KB_N
|
85
|
-
KB_O
|
86
|
-
KB_P
|
87
|
-
KB_Q
|
88
|
-
KB_R
|
89
|
-
KB_S
|
90
|
-
KB_T
|
91
|
-
KB_U
|
92
|
-
KB_V
|
93
|
-
KB_W
|
94
|
-
KB_X
|
95
|
-
KB_Y
|
96
|
-
KB_Z
|
10
|
+
KB_ESCAPE = 41,
|
11
|
+
KB_F1 = 58,
|
12
|
+
KB_F2 = 59,
|
13
|
+
KB_F3 = 60,
|
14
|
+
KB_F4 = 61,
|
15
|
+
KB_F5 = 62,
|
16
|
+
KB_F6 = 63,
|
17
|
+
KB_F7 = 64,
|
18
|
+
KB_F8 = 65,
|
19
|
+
KB_F9 = 66,
|
20
|
+
KB_F10 = 67,
|
21
|
+
KB_F11 = 68,
|
22
|
+
KB_F12 = 69,
|
23
|
+
KB_0 = 39,
|
24
|
+
KB_1 = 30,
|
25
|
+
KB_2 = 31,
|
26
|
+
KB_3 = 32,
|
27
|
+
KB_4 = 33,
|
28
|
+
KB_5 = 34,
|
29
|
+
KB_6 = 35,
|
30
|
+
KB_7 = 36,
|
31
|
+
KB_8 = 37,
|
32
|
+
KB_9 = 38,
|
33
|
+
KB_TAB = 43,
|
34
|
+
KB_RETURN = 40,
|
35
|
+
KB_SPACE = 44,
|
36
|
+
KB_LEFT_SHIFT = 225,
|
37
|
+
KB_RIGHT_SHIFT = 229,
|
38
|
+
KB_LEFT_CONTROL = 224,
|
39
|
+
KB_RIGHT_CONTROL = 228,
|
40
|
+
KB_LEFT_ALT = 226,
|
41
|
+
KB_RIGHT_ALT = 230,
|
42
|
+
KB_LEFT_META = 227,
|
43
|
+
KB_RIGHT_META = 231,
|
44
|
+
KB_BACKSPACE = 42,
|
45
|
+
KB_LEFT = 80,
|
46
|
+
KB_RIGHT = 79,
|
47
|
+
KB_UP = 82,
|
48
|
+
KB_DOWN = 81,
|
49
|
+
KB_HOME = 74,
|
50
|
+
KB_END = 77,
|
51
|
+
KB_PRINT_SCREEN = 70,
|
52
|
+
KB_SCROLL_LOCK = 71,
|
53
|
+
KB_PAUSE = 72,
|
54
|
+
KB_INSERT = 73,
|
55
|
+
KB_DELETE = 76,
|
56
|
+
KB_PAGE_UP = 75,
|
57
|
+
KB_PAGE_DOWN = 78,
|
58
|
+
KB_ENTER = 88,
|
59
|
+
KB_BACKTICK = 53,
|
60
|
+
KB_MINUS = 45,
|
61
|
+
KB_EQUALS = 46,
|
62
|
+
KB_LEFT_BRACKET = 47,
|
63
|
+
KB_RIGHT_BRACKET = 48,
|
64
|
+
KB_BACKSLASH = 49,
|
65
|
+
KB_SEMICOLON = 51,
|
66
|
+
KB_APOSTROPHE = 52,
|
67
|
+
KB_COMMA = 54,
|
68
|
+
KB_PERIOD = 55,
|
69
|
+
KB_SLASH = 56,
|
70
|
+
KB_CAPS_LOCK = 57,
|
71
|
+
KB_A = 4,
|
72
|
+
KB_B = 5,
|
73
|
+
KB_C = 6,
|
74
|
+
KB_D = 7,
|
75
|
+
KB_E = 8,
|
76
|
+
KB_F = 9,
|
77
|
+
KB_G = 10,
|
78
|
+
KB_H = 11,
|
79
|
+
KB_I = 12,
|
80
|
+
KB_J = 13,
|
81
|
+
KB_K = 14,
|
82
|
+
KB_L = 15,
|
83
|
+
KB_M = 16,
|
84
|
+
KB_N = 17,
|
85
|
+
KB_O = 18,
|
86
|
+
KB_P = 19,
|
87
|
+
KB_Q = 20,
|
88
|
+
KB_R = 21,
|
89
|
+
KB_S = 22,
|
90
|
+
KB_T = 23,
|
91
|
+
KB_U = 24,
|
92
|
+
KB_V = 25,
|
93
|
+
KB_W = 26,
|
94
|
+
KB_X = 27,
|
95
|
+
KB_Y = 28,
|
96
|
+
KB_Z = 29,
|
97
97
|
/// ` on US/UK macOS, < on EU macOS, \ on US/UK Windows
|
98
|
-
KB_ISO
|
99
|
-
KB_NUMPAD_0
|
100
|
-
KB_NUMPAD_1
|
101
|
-
KB_NUMPAD_2
|
102
|
-
KB_NUMPAD_3
|
103
|
-
KB_NUMPAD_4
|
104
|
-
KB_NUMPAD_5
|
105
|
-
KB_NUMPAD_6
|
106
|
-
KB_NUMPAD_7
|
107
|
-
KB_NUMPAD_8
|
108
|
-
KB_NUMPAD_9
|
109
|
-
KB_NUMPAD_DELETE
|
110
|
-
KB_NUMPAD_PLUS
|
111
|
-
KB_NUMPAD_MINUS
|
98
|
+
KB_ISO = 100,
|
99
|
+
KB_NUMPAD_0 = 98,
|
100
|
+
KB_NUMPAD_1 = 89,
|
101
|
+
KB_NUMPAD_2 = 90,
|
102
|
+
KB_NUMPAD_3 = 91,
|
103
|
+
KB_NUMPAD_4 = 92,
|
104
|
+
KB_NUMPAD_5 = 93,
|
105
|
+
KB_NUMPAD_6 = 94,
|
106
|
+
KB_NUMPAD_7 = 95,
|
107
|
+
KB_NUMPAD_8 = 96,
|
108
|
+
KB_NUMPAD_9 = 97,
|
109
|
+
KB_NUMPAD_DELETE = 99,
|
110
|
+
KB_NUMPAD_PLUS = 87,
|
111
|
+
KB_NUMPAD_MINUS = 86,
|
112
112
|
KB_NUMPAD_MULTIPLY = 85,
|
113
|
-
KB_NUMPAD_DIVIDE
|
114
|
-
KB_RANGE_END
|
113
|
+
KB_NUMPAD_DIVIDE = 84,
|
114
|
+
KB_RANGE_END = 0xff,
|
115
115
|
|
116
116
|
MS_RANGE_BEGIN,
|
117
117
|
MS_LEFT = MS_RANGE_BEGIN,
|
@@ -1,36 +1,43 @@
|
|
1
|
-
//! \file Directories.hpp
|
2
|
-
//! Access to a small set of system paths.
|
3
|
-
|
4
1
|
#pragma once
|
5
2
|
|
6
3
|
#include <string>
|
7
4
|
|
8
5
|
namespace Gosu
|
9
6
|
{
|
10
|
-
|
7
|
+
/// Changes the current directory to the result of resource_prefix().
|
11
8
|
void use_resource_directory();
|
12
9
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
/// Prefix for a program's own resources.
|
11
|
+
/// <ul>
|
12
|
+
/// <li> Windows: The parent directory of the executable.
|
13
|
+
/// <li> macOS, iOS: The 'Resources' directory inside the .app bundle.
|
14
|
+
/// <li> Linux: The current directory (empty string).
|
15
|
+
/// </ul>
|
16
|
+
const std::string& resource_prefix();
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
/// Prefix for shared resources of a group of programs, e.g. the game and its level editor.
|
19
|
+
/// <ul>
|
20
|
+
/// <li> Windows: The parent directory of the executable.
|
21
|
+
/// <li> macOS: The parent directory of the .app bundle.
|
22
|
+
/// <li> Linux: The current directory (empty string).
|
23
|
+
/// </uil>
|
24
|
+
const std::string& shared_resource_prefix();
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
/// Prefix for user settings.
|
27
|
+
/// <ul>
|
28
|
+
/// <li> Windows: The same as %APPDATA%.
|
29
|
+
/// <li> macOS: The user's Library/Preferences folder.
|
30
|
+
/// <li> Linux: The home directory plus a trailing dot for hidden files.
|
31
|
+
/// </ul>
|
32
|
+
const std::string& user_settings_prefix();
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
/// Prefix for user documents, e.g. saved games.
|
35
|
+
/// <ul>
|
36
|
+
/// <li> Windows: The "My Documents" folder.
|
37
|
+
/// <li> macOS: The user's "Documents" folder.
|
38
|
+
/// <li> Linux: The home directory.
|
39
|
+
/// </ul>
|
40
|
+
const std::string& user_documents_prefix();
|
41
|
+
|
42
|
+
// TODO: Instead of re-inventing wheels here, we should wrap SDL_GetBasePath / SDL_GetPrefPath.
|
36
43
|
}
|
data/include/Gosu/Font.hpp
CHANGED
@@ -20,9 +20,10 @@ namespace Gosu
|
|
20
20
|
public:
|
21
21
|
/// @param name Name of a system font, or path to a TTF file (must contain '/').
|
22
22
|
/// @param height Height of the font, in pixels.
|
23
|
-
/// @param
|
23
|
+
/// @param font_flags Flags used to render individual characters of the font (FontFlags enum).
|
24
|
+
/// @param image_flags Flags used to render individual characters of the font (ImageFlags enum).
|
24
25
|
explicit Font(int height, const std::string& name = default_font_name(),
|
25
|
-
unsigned
|
26
|
+
unsigned font_flags = 0, unsigned image_flags = 0);
|
26
27
|
|
27
28
|
/// Returns the name of the font that was used to create it, i.e. the filename, nor the
|
28
29
|
/// internal TTF name. (TODO: Why not?)
|
@@ -33,6 +34,7 @@ namespace Gosu
|
|
33
34
|
|
34
35
|
/// Returns the flags used to render the characters of the font (FontFlags enum).
|
35
36
|
unsigned flags() const;
|
37
|
+
unsigned image_flags() const;
|
36
38
|
|
37
39
|
/// Returns the width, in pixels, that the given text would occupy if drawn.
|
38
40
|
double text_width(const std::string& text) const;
|
data/include/Gosu/Gosu.hpp
CHANGED
@@ -1,11 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
//! These pages serve as a reference on the C++ interface of Gosu. For a higher-level
|
7
|
-
//! discussion of concepts and ideas behind the library, see the Wiki entries linked
|
8
|
-
//! from the official website, https://www.libgosu.org/.
|
1
|
+
/// \mainpage Gosu C++ Documentation
|
2
|
+
///
|
3
|
+
/// These pages serve as a reference on the C++ interface of Gosu. For a higher-level
|
4
|
+
/// discussion of concepts and ideas behind the library, see the Wiki entries linked
|
5
|
+
/// from the official website, https://www.libgosu.org/.
|
9
6
|
|
10
7
|
#pragma once
|
11
8
|
|
data/include/Gosu/IO.hpp
CHANGED
data/include/Gosu/Input.hpp
CHANGED
@@ -24,7 +24,7 @@ namespace Gosu
|
|
24
24
|
|
25
25
|
/// Manages initialization and shutdown of the input system.
|
26
26
|
/// Only one Input instance can exist per application.
|
27
|
-
class Input : Noncopyable
|
27
|
+
class Input : private Noncopyable
|
28
28
|
{
|
29
29
|
struct Impl;
|
30
30
|
std::unique_ptr<Impl> pimpl;
|
@@ -107,5 +107,11 @@ namespace Gosu
|
|
107
107
|
TextInput* text_input() const;
|
108
108
|
//! Sets the currently active TextInput, or resets it to the nullptr.
|
109
109
|
void set_text_input(TextInput* input);
|
110
|
+
|
111
|
+
/// Returns the contents of the clipboard as plain text, or an empty string if none is available.
|
112
|
+
static std::string clipboard();
|
113
|
+
|
114
|
+
/// Replaces the contents of the clipboard with the given string.
|
115
|
+
static void set_clipboard(const std::string& text);
|
110
116
|
};
|
111
117
|
}
|
data/include/Gosu/Math.hpp
CHANGED
data/include/Gosu/TextInput.hpp
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
#include <Gosu/Fwd.hpp>
|
4
4
|
#include <Gosu/Platform.hpp>
|
5
|
+
#include <Gosu/Utility.hpp>
|
5
6
|
#include <memory>
|
6
7
|
#include <string>
|
7
8
|
|
@@ -15,11 +16,10 @@ namespace Gosu
|
|
15
16
|
/// build a text that can be accessed via TextInput::text().
|
16
17
|
/// A TextInput object has no built-in UI. It is up to you to actually draw a text field.
|
17
18
|
/// TextInput only provides a portable base for your own GUI to build upon.
|
18
|
-
class TextInput
|
19
|
+
class TextInput : private Noncopyable
|
19
20
|
{
|
20
21
|
struct Impl;
|
21
|
-
|
22
|
-
const std::unique_ptr<Impl> m_impl;
|
22
|
+
std::unique_ptr<Impl> m_impl;
|
23
23
|
|
24
24
|
public:
|
25
25
|
TextInput();
|
data/include/Gosu/Timing.hpp
CHANGED
@@ -1,14 +1,11 @@
|
|
1
|
-
//! \file Timing.hpp
|
2
|
-
//! Functions for timing.
|
3
|
-
|
4
1
|
#pragma once
|
5
2
|
|
6
3
|
namespace Gosu
|
7
4
|
{
|
8
|
-
|
5
|
+
/// Freezes the current thread for the given amount of milliseconds.
|
9
6
|
void sleep(unsigned milliseconds);
|
10
7
|
|
11
|
-
|
12
|
-
|
8
|
+
/// Returns the milliseconds since first calling this function.
|
9
|
+
/// Can wrap after running for a long time.
|
13
10
|
unsigned long milliseconds();
|
14
11
|
}
|
data/include/Gosu/Version.hpp
CHANGED
data/include/Gosu/Window.hpp
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
#include <Gosu/Fwd.hpp>
|
4
4
|
#include <Gosu/Input.hpp>
|
5
5
|
#include <Gosu/Platform.hpp>
|
6
|
+
#include <Gosu/Utility.hpp>
|
6
7
|
#include <memory>
|
7
8
|
#include <string>
|
8
9
|
|
@@ -19,10 +20,10 @@ namespace Gosu
|
|
19
20
|
/// Convenient all-in-one class that serves as the foundation of a standard Gosu application.
|
20
21
|
/// Manages initialization of all of Gosu's core components and provides timing functionality.
|
21
22
|
/// Note that you can only use one instance of this class at the same time.
|
22
|
-
class Window
|
23
|
+
class Window : private Noncopyable
|
23
24
|
{
|
24
25
|
struct Impl;
|
25
|
-
|
26
|
+
std::unique_ptr<Impl> m_impl;
|
26
27
|
|
27
28
|
public:
|
28
29
|
/// Constructs a Window.
|
data/rdoc/gosu.rb
CHANGED
@@ -272,6 +272,7 @@ module Gosu
|
|
272
272
|
# @option options [bool] :bold (false)
|
273
273
|
# @option options [bool] :italic (false)
|
274
274
|
# @option options [bool] :underline (false)
|
275
|
+
# @option options [bool] :retro (false) see Gosu::Image
|
275
276
|
#
|
276
277
|
# @overload initialize(height, options = {})
|
277
278
|
# @overload initialize(window, font_name, height)
|
@@ -1042,6 +1043,19 @@ module Gosu
|
|
1042
1043
|
#
|
1043
1044
|
def axis(id); end
|
1044
1045
|
|
1046
|
+
##
|
1047
|
+
# Returns the contents of the clipboard as plain text, or an empty string if none is available.
|
1048
|
+
#
|
1049
|
+
# @return [String]
|
1050
|
+
def clipboard(); end
|
1051
|
+
|
1052
|
+
##
|
1053
|
+
# Replaces the contents of the clipboard with the given string.
|
1054
|
+
#
|
1055
|
+
# @return [nil]
|
1056
|
+
def clipboard=(text); end
|
1057
|
+
|
1058
|
+
|
1045
1059
|
# @!group Drawing primitives
|
1046
1060
|
|
1047
1061
|
##
|
@@ -1295,7 +1309,7 @@ module Gosu
|
|
1295
1309
|
# @see char_to_button_id
|
1296
1310
|
# @see Window#text_input
|
1297
1311
|
# @see TextInput
|
1298
|
-
def
|
1312
|
+
def button_id_to_char(id); end
|
1299
1313
|
|
1300
1314
|
##
|
1301
1315
|
# Returns the button that usually produces a character, if any.
|
@@ -1306,7 +1320,7 @@ module Gosu
|
|
1306
1320
|
# @see button_id_to_char
|
1307
1321
|
# @see Window#text_input
|
1308
1322
|
# @see TextInput
|
1309
|
-
def
|
1323
|
+
def char_to_button_id(char); end
|
1310
1324
|
|
1311
1325
|
##
|
1312
1326
|
# @return [Float] a random number in the range [min; max).
|
data/src/Audio.cpp
CHANGED
@@ -13,7 +13,7 @@ static Gosu::Song* cur_song = nullptr;
|
|
13
13
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
14
14
|
static bool cur_song_looping;
|
15
15
|
|
16
|
-
struct Gosu::Sample::Impl : Gosu::Noncopyable
|
16
|
+
struct Gosu::Sample::Impl : private Gosu::Noncopyable
|
17
17
|
{
|
18
18
|
ALuint buffer;
|
19
19
|
|
@@ -76,7 +76,7 @@ Gosu::Channel Gosu::Sample::play_pan(double pan, double volume, double speed, bo
|
|
76
76
|
}
|
77
77
|
|
78
78
|
// AudioFile impl
|
79
|
-
struct Gosu::Song::Impl : Gosu::Noncopyable
|
79
|
+
struct Gosu::Song::Impl : private Gosu::Noncopyable
|
80
80
|
{
|
81
81
|
private:
|
82
82
|
double m_volume = 1.0;
|
@@ -35,7 +35,7 @@ static void throw_os_error(OSStatus status, unsigned line)
|
|
35
35
|
|
36
36
|
#define CHECK_OS(status) do { if (status) throw_os_error(status, __LINE__); } while (0)
|
37
37
|
|
38
|
-
struct Gosu::AudioFile::Impl : Gosu::Noncopyable
|
38
|
+
struct Gosu::AudioFile::Impl : private Gosu::Noncopyable
|
39
39
|
{
|
40
40
|
Buffer buffer;
|
41
41
|
AudioFileID file_id;
|
data/src/AudioFileSDLSound.cpp
CHANGED
data/src/AudioImpl.cpp
CHANGED
data/src/AudioImpl.hpp
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#include <Gosu/Audio.hpp>
|
4
4
|
#include <Gosu/Platform.hpp>
|
5
5
|
#ifdef GOSU_IS_IPHONE
|
6
|
-
// Ignore OpenAL deprecation warnings. If
|
6
|
+
// Ignore OpenAL deprecation warnings. If iOS stops shipping OpenAL, it's more likely that we bundle our own version
|
7
7
|
// of it than that we switch to another audio API.
|
8
8
|
#define OPENAL_DEPRECATED
|
9
9
|
#include <OpenAL/al.h>
|
@@ -18,8 +18,6 @@ namespace Gosu
|
|
18
18
|
void al_initialize();
|
19
19
|
bool al_initialized();
|
20
20
|
|
21
|
-
// Will initialize OpenAL if necessary.
|
22
|
-
ALCdevice* al_device();
|
23
21
|
// Will initialize OpenAL if necessary.
|
24
22
|
ALCcontext* al_context();
|
25
23
|
|
data/src/BitmapIO.cpp
CHANGED
@@ -39,6 +39,26 @@ static bool is_bmp(Gosu::Reader reader)
|
|
39
39
|
return magic_bytes[0] == 'B' && magic_bytes[1] == 'M';
|
40
40
|
}
|
41
41
|
|
42
|
+
/// Returns a copy of the given Gosu::Image with the alpha channel removed.
|
43
|
+
/// Every pixel with alpha==0 will be replaced by Gosu::Color::FUCHSIA.
|
44
|
+
static std::vector<Gosu::Color::Channel> bitmap_to_rgb(const Gosu::Bitmap& bmp)
|
45
|
+
{
|
46
|
+
std::vector<Gosu::Color::Channel> rgb(static_cast<std::size_t>(bmp.width() * bmp.height() * 3));
|
47
|
+
for (std::size_t offset = 0; offset < rgb.size(); offset += 3) {
|
48
|
+
const Gosu::Color& color = bmp.data()[offset / 3];
|
49
|
+
if (color.alpha == 0) {
|
50
|
+
rgb[offset + 0] = 0xff;
|
51
|
+
rgb[offset + 1] = 0x00;
|
52
|
+
rgb[offset + 2] = 0xff;
|
53
|
+
} else {
|
54
|
+
rgb[offset + 0] = color.red;
|
55
|
+
rgb[offset + 1] = color.green;
|
56
|
+
rgb[offset + 2] = color.blue;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
return rgb;
|
60
|
+
}
|
61
|
+
|
42
62
|
Gosu::Bitmap Gosu::load_image_file(const std::string& filename)
|
43
63
|
{
|
44
64
|
Buffer buffer;
|
@@ -80,7 +100,8 @@ void Gosu::save_image_file(const Gosu::Bitmap& bitmap, const std::string& filena
|
|
80
100
|
int ok;
|
81
101
|
|
82
102
|
if (has_extension(filename, "bmp")) {
|
83
|
-
ok = stbi_write_bmp(filename.c_str(), bitmap.width(), bitmap.height(),
|
103
|
+
ok = stbi_write_bmp(filename.c_str(), bitmap.width(), bitmap.height(), 3,
|
104
|
+
bitmap_to_rgb(bitmap).data());
|
84
105
|
}
|
85
106
|
else if (has_extension(filename, "tga")) {
|
86
107
|
ok = stbi_write_tga(filename.c_str(), bitmap.width(), bitmap.height(), 4, bitmap.data());
|
@@ -106,7 +127,7 @@ void Gosu::save_image_file(const Gosu::Bitmap& bitmap, Gosu::Writer writer,
|
|
106
127
|
|
107
128
|
if (has_extension(format_hint, "bmp")) {
|
108
129
|
ok = stbi_write_bmp_to_func(stbi_write_to_writer, &writer, bitmap.width(), bitmap.height(),
|
109
|
-
|
130
|
+
3, bitmap_to_rgb(bitmap).data());
|
110
131
|
}
|
111
132
|
else if (has_extension(format_hint, "tga")) {
|
112
133
|
stbi_write_tga_with_rle = 0;
|