gosu 1.4.1 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- 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/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/Math.hpp +0 -3
- data/include/Gosu/Timing.hpp +2 -8
- data/include/Gosu/Version.hpp +1 -1
- data/src/AudioImpl.cpp +0 -7
- data/src/AudioImpl.hpp +1 -3
- data/src/BitmapIO.cpp +23 -2
- data/src/DirectoriesApple.cpp +25 -24
- data/src/DirectoriesUnix.cpp +14 -12
- data/src/DirectoriesWin.cpp +26 -30
- data/src/Font.cpp +12 -2
- data/src/Image.cpp +10 -15
- data/src/RubyGosu.cxx +6 -34
- data/src/TimingApple.cpp +1 -7
- data/src/TimingUnix.cpp +0 -6
- data/src/TimingWin.cpp +0 -6
- data/src/Window.cpp +4 -3
- metadata +2 -2
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/Math.hpp
CHANGED
data/include/Gosu/Timing.hpp
CHANGED
@@ -1,14 +1,8 @@
|
|
1
|
-
//! \file Timing.hpp
|
2
|
-
//! Functions for timing.
|
3
|
-
|
4
1
|
#pragma once
|
5
2
|
|
6
3
|
namespace Gosu
|
7
4
|
{
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
//! Returns the milliseconds since first calling this function.
|
12
|
-
//! Can wrap after running for a long time.
|
5
|
+
/// Returns the milliseconds since first calling this function.
|
6
|
+
/// Can wrap after running for a long time.
|
13
7
|
unsigned long milliseconds();
|
14
8
|
}
|
data/include/Gosu/Version.hpp
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;
|
data/src/DirectoriesApple.cpp
CHANGED
@@ -4,65 +4,66 @@
|
|
4
4
|
#import <Gosu/Directories.hpp>
|
5
5
|
#import <Foundation/Foundation.h>
|
6
6
|
#import <unistd.h>
|
7
|
-
using namespace std;
|
8
7
|
|
9
8
|
void Gosu::use_resource_directory()
|
10
9
|
{
|
11
10
|
chdir(resource_prefix().c_str());
|
12
11
|
}
|
13
12
|
|
14
|
-
string Gosu::user_settings_prefix()
|
13
|
+
const std::string& Gosu::user_settings_prefix()
|
15
14
|
{
|
16
|
-
static string
|
15
|
+
static const std::string user_settings_prefix = [] {
|
17
16
|
@autoreleasepool {
|
18
17
|
NSString* library =
|
19
|
-
|
18
|
+
NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)
|
19
|
+
.firstObject;
|
20
20
|
NSString* preferences = [library stringByAppendingPathComponent:@"Preferences"];
|
21
|
-
|
22
|
-
return string
|
21
|
+
|
22
|
+
return std::string{preferences.UTF8String ?: "."} + "/";
|
23
23
|
}
|
24
24
|
}();
|
25
|
-
return
|
25
|
+
return user_settings_prefix;
|
26
26
|
}
|
27
27
|
|
28
|
-
string Gosu::user_documents_prefix()
|
28
|
+
const std::string& Gosu::user_documents_prefix()
|
29
29
|
{
|
30
|
-
static string
|
30
|
+
static const std::string user_documents_prefix = [] {
|
31
31
|
@autoreleasepool {
|
32
32
|
NSString* documents =
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)
|
34
|
+
.firstObject;
|
35
|
+
|
36
|
+
return std::string{documents.UTF8String ?: "."} + "/";
|
36
37
|
}
|
37
38
|
}();
|
38
|
-
return
|
39
|
+
return user_documents_prefix;
|
39
40
|
}
|
40
41
|
|
41
|
-
string Gosu::resource_prefix()
|
42
|
+
const std::string& Gosu::resource_prefix()
|
42
43
|
{
|
43
|
-
static string
|
44
|
+
static const std::string resource_prefix = [] {
|
44
45
|
@autoreleasepool {
|
45
46
|
NSString* resources = [NSBundle mainBundle].resourcePath;
|
46
|
-
return string
|
47
|
+
return std::string{resources.UTF8String ?: "."} + "/";
|
47
48
|
}
|
48
49
|
}();
|
49
|
-
return
|
50
|
+
return resource_prefix;
|
50
51
|
}
|
51
52
|
|
52
|
-
string Gosu::shared_resource_prefix()
|
53
|
+
const std::string& Gosu::shared_resource_prefix()
|
53
54
|
{
|
54
|
-
|
55
|
+
#ifdef GOSU_IS_IPHONE
|
55
56
|
return resource_prefix();
|
56
|
-
|
57
|
-
static string
|
57
|
+
#else
|
58
|
+
static const std::string shared_resource_prefix = [] {
|
58
59
|
@autoreleasepool {
|
59
60
|
NSString* bundle_path = [NSBundle mainBundle].bundlePath;
|
60
61
|
NSString* containing_path = [bundle_path stringByDeletingLastPathComponent];
|
61
|
-
return string
|
62
|
+
return std::string{containing_path.UTF8String ?: "."};
|
62
63
|
}
|
63
64
|
}();
|
64
|
-
return
|
65
|
-
|
65
|
+
return shared_resource_prefix;
|
66
|
+
#endif
|
66
67
|
}
|
67
68
|
|
68
69
|
#endif
|
data/src/DirectoriesUnix.cpp
CHANGED
@@ -7,13 +7,11 @@
|
|
7
7
|
#include <pwd.h>
|
8
8
|
#include <sys/types.h>
|
9
9
|
#include <unistd.h>
|
10
|
-
using namespace std;
|
11
10
|
|
12
|
-
static string home_dir()
|
11
|
+
static std::string home_dir()
|
13
12
|
{
|
14
13
|
passwd* pwd = getpwuid(geteuid());
|
15
|
-
|
16
|
-
return pwd->pw_dir;
|
14
|
+
return pwd && pwd->pw_dir ? pwd->pw_dir : ".";
|
17
15
|
}
|
18
16
|
|
19
17
|
void Gosu::use_resource_directory()
|
@@ -21,24 +19,28 @@ void Gosu::use_resource_directory()
|
|
21
19
|
// Do nothing, we expect the user to have the correct cwd on Linux.
|
22
20
|
}
|
23
21
|
|
24
|
-
string Gosu::resource_prefix()
|
22
|
+
const std::string& Gosu::resource_prefix()
|
25
23
|
{
|
26
|
-
|
24
|
+
static const std::string empty;
|
25
|
+
return empty;
|
27
26
|
}
|
28
27
|
|
29
|
-
string Gosu::shared_resource_prefix()
|
28
|
+
const std::string& Gosu::shared_resource_prefix()
|
30
29
|
{
|
31
|
-
|
30
|
+
static const std::string empty;
|
31
|
+
return empty;
|
32
32
|
}
|
33
33
|
|
34
|
-
string Gosu::user_settings_prefix()
|
34
|
+
const std::string& Gosu::user_settings_prefix()
|
35
35
|
{
|
36
|
-
|
36
|
+
static const std::string user_settings_prefix = home_dir() + "/.";
|
37
|
+
return user_settings_prefix;
|
37
38
|
}
|
38
39
|
|
39
|
-
string Gosu::user_documents_prefix()
|
40
|
+
const std::string& Gosu::user_documents_prefix()
|
40
41
|
{
|
41
|
-
|
42
|
+
static const std::string user_documents_prefix = home_dir() + "/";
|
43
|
+
return user_documents_prefix;
|
42
44
|
}
|
43
45
|
|
44
46
|
#endif
|