gosu 1.4.1 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/dependencies/SDL_sound/SDL_sound.c +21 -63
  3. data/dependencies/SDL_sound/SDL_sound.h +2 -2
  4. data/dependencies/SDL_sound/SDL_sound_aiff.c +26 -23
  5. data/dependencies/SDL_sound/SDL_sound_au.c +8 -8
  6. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +4 -5
  7. data/dependencies/SDL_sound/SDL_sound_flac.c +28 -30
  8. data/dependencies/SDL_sound/SDL_sound_internal.h +4 -4
  9. data/dependencies/SDL_sound/SDL_sound_modplug.c +1 -1
  10. data/dependencies/SDL_sound/SDL_sound_mp3.c +19 -23
  11. data/dependencies/SDL_sound/SDL_sound_raw.c +5 -6
  12. data/dependencies/SDL_sound/SDL_sound_shn.c +4 -4
  13. data/dependencies/SDL_sound/SDL_sound_voc.c +15 -15
  14. data/dependencies/SDL_sound/SDL_sound_vorbis.c +14 -7
  15. data/dependencies/SDL_sound/SDL_sound_wav.c +17 -17
  16. data/dependencies/SDL_sound/dr_flac.h +10840 -4779
  17. data/dependencies/SDL_sound/dr_mp3.h +2793 -1004
  18. data/dependencies/SDL_sound/libmodplug/fastmix.c +5 -0
  19. data/dependencies/SDL_sound/libmodplug/load_669.c +1 -1
  20. data/dependencies/SDL_sound/libmodplug/load_amf.c +1 -0
  21. data/dependencies/SDL_sound/libmodplug/load_ams.c +38 -22
  22. data/dependencies/SDL_sound/libmodplug/load_it.c +18 -14
  23. data/dependencies/SDL_sound/libmodplug/load_mdl.c +18 -9
  24. data/dependencies/SDL_sound/libmodplug/load_med.c +7 -6
  25. data/dependencies/SDL_sound/libmodplug/load_mt2.c +36 -17
  26. data/dependencies/SDL_sound/libmodplug/load_okt.c +51 -24
  27. data/dependencies/SDL_sound/libmodplug/load_psm.c +4 -2
  28. data/dependencies/SDL_sound/libmodplug/load_s3m.c +4 -4
  29. data/dependencies/SDL_sound/libmodplug/load_ult.c +4 -3
  30. data/dependencies/SDL_sound/libmodplug/load_xm.c +5 -5
  31. data/dependencies/SDL_sound/libmodplug/snd_fx.c +8 -1
  32. data/dependencies/SDL_sound/libmodplug/sndfile.c +21 -4
  33. data/dependencies/SDL_sound/stb_vorbis.h +10 -18
  34. data/dependencies/mojoAL/mojoal.c +260 -6
  35. data/dependencies/stb/stb_image.h +208 -73
  36. data/dependencies/stb/stb_image_write.h +57 -23
  37. data/dependencies/stb/stb_truetype.h +345 -279
  38. data/dependencies/utf8proc/utf8proc.c +37 -18
  39. data/dependencies/utf8proc/utf8proc.h +17 -5
  40. data/dependencies/utf8proc/utf8proc_data.h +12012 -10089
  41. data/ext/gosu/extconf.rb +6 -3
  42. data/include/Gosu/Buttons.hpp +103 -103
  43. data/include/Gosu/Directories.hpp +31 -24
  44. data/include/Gosu/Font.hpp +4 -2
  45. data/include/Gosu/Gosu.hpp +5 -8
  46. data/include/Gosu/IO.hpp +0 -3
  47. data/include/Gosu/Input.hpp +7 -1
  48. data/include/Gosu/Math.hpp +0 -3
  49. data/include/Gosu/TextInput.hpp +3 -3
  50. data/include/Gosu/Timing.hpp +3 -6
  51. data/include/Gosu/Version.hpp +1 -1
  52. data/include/Gosu/Window.hpp +3 -2
  53. data/rdoc/gosu.rb +16 -2
  54. data/src/Audio.cpp +2 -2
  55. data/src/AudioFileAudioToolbox.cpp +1 -1
  56. data/src/AudioFileSDLSound.cpp +1 -1
  57. data/src/AudioImpl.cpp +0 -7
  58. data/src/AudioImpl.hpp +1 -3
  59. data/src/BitmapIO.cpp +23 -2
  60. data/src/BlockAllocator.cpp +1 -1
  61. data/src/DirectoriesApple.cpp +25 -24
  62. data/src/DirectoriesUnix.cpp +14 -12
  63. data/src/DirectoriesWin.cpp +26 -30
  64. data/src/FileUnix.cpp +1 -1
  65. data/src/FileWin.cpp +1 -1
  66. data/src/Font.cpp +13 -3
  67. data/src/Graphics.cpp +1 -1
  68. data/src/Image.cpp +10 -15
  69. data/src/Input.cpp +16 -1
  70. data/src/InputUIKit.cpp +1 -1
  71. data/src/Macro.cpp +1 -1
  72. data/src/RubyGosu.cxx +76 -34
  73. data/src/TextInput.cpp +1 -1
  74. data/src/TimingApple.cpp +2 -2
  75. data/src/TimingUnix.cpp +3 -7
  76. data/src/TimingWin.cpp +1 -2
  77. data/src/TrueTypeFont.cpp +1 -1
  78. data/src/Window.cpp +5 -4
  79. data/src/WindowUIKit.cpp +1 -1
  80. metadata +3 -3
@@ -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 result = [] {
15
+ static const std::string user_settings_prefix = [] {
17
16
  @autoreleasepool {
18
17
  NSString* library =
19
- NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)[0];
18
+ NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)
19
+ .firstObject;
20
20
  NSString* preferences = [library stringByAppendingPathComponent:@"Preferences"];
21
-
22
- return string(preferences.UTF8String ?: ".") + "/";
21
+
22
+ return std::string{preferences.UTF8String ?: "."} + "/";
23
23
  }
24
24
  }();
25
- return result;
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 result = [] {
30
+ static const std::string user_documents_prefix = [] {
31
31
  @autoreleasepool {
32
32
  NSString* documents =
33
- NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
34
-
35
- return string(documents.UTF8String ?: ".") + "/";
33
+ NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)
34
+ .firstObject;
35
+
36
+ return std::string{documents.UTF8String ?: "."} + "/";
36
37
  }
37
38
  }();
38
- return result;
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 result = [] {
44
+ static const std::string resource_prefix = [] {
44
45
  @autoreleasepool {
45
46
  NSString* resources = [NSBundle mainBundle].resourcePath;
46
- return string(resources.UTF8String ?: ".") + "/";
47
+ return std::string{resources.UTF8String ?: "."} + "/";
47
48
  }
48
49
  }();
49
- return result;
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
- #ifdef GOSU_IS_IPHONE
55
+ #ifdef GOSU_IS_IPHONE
55
56
  return resource_prefix();
56
- #else
57
- static string result = [] {
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(containing_path.UTF8String ?: ".");
62
+ return std::string{containing_path.UTF8String ?: "."};
62
63
  }
63
64
  }();
64
- return result;
65
- #endif
65
+ return shared_resource_prefix;
66
+ #endif
66
67
  }
67
68
 
68
69
  #endif
@@ -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
- assert (pwd && pwd->pw_dir);
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
- return string();
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
- return string();
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
- return home_dir() + "/.";
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
- return home_dir() + "/";
42
+ static const std::string user_documents_prefix = home_dir() + "/";
43
+ return user_documents_prefix;
42
44
  }
43
45
 
44
46
  #endif
@@ -1,21 +1,19 @@
1
1
  #include <Gosu/Platform.hpp>
2
2
  #if defined(GOSU_IS_WIN)
3
3
 
4
- #include "WinUtility.hpp"
5
4
  #include <Gosu/Directories.hpp>
6
5
  #include <Gosu/Utility.hpp>
6
+ #include "WinUtility.hpp"
7
7
  #include <cwchar>
8
- #include <stdexcept>
9
8
  #include <shlobj.h>
10
- using namespace std;
9
+ #include <stdexcept>
11
10
 
12
- static string special_folder_path(int csidl)
11
+ static std::string special_folder_path(int csidl)
13
12
  {
14
13
  WCHAR buf[MAX_PATH + 2];
15
- if (FAILED(SHGetFolderPathW(nullptr, csidl | CSIDL_FLAG_CREATE, nullptr, 0, buf))) {
16
- throw runtime_error("Error getting special folder path");
17
- }
18
- size_t len = wcslen(buf);
14
+ if (FAILED(SHGetFolderPathW(nullptr, csidl | CSIDL_FLAG_CREATE, nullptr, 0, buf)))
15
+ throw std::runtime_error{"Error getting special folder path"};
16
+ size_t len = std::wcslen(buf);
19
17
  if (buf[len - 1] != L'\\') {
20
18
  buf[len] = L'\\';
21
19
  buf[len + 1] = 0;
@@ -23,16 +21,12 @@ static string special_folder_path(int csidl)
23
21
  return Gosu::utf16_to_utf8(buf);
24
22
  }
25
23
 
26
- static string exe_filename()
24
+ std::string exe_filename()
27
25
  {
28
- static string result;
29
- if (result.empty()) {
30
- WCHAR buffer[MAX_PATH * 2];
31
- Gosu::winapi_check(GetModuleFileNameW(nullptr, buffer, MAX_PATH * 2),
32
- "getting the module filename");
33
- result = Gosu::utf16_to_utf8(buffer);
34
- }
35
- return result;
26
+ WCHAR buffer[MAX_PATH * 2];
27
+ Gosu::winapi_check(GetModuleFileNameW(nullptr, buffer, MAX_PATH * 2),
28
+ "getting the module filename");
29
+ return Gosu::utf16_to_utf8(buffer);
36
30
  }
37
31
 
38
32
  void Gosu::use_resource_directory()
@@ -40,30 +34,32 @@ void Gosu::use_resource_directory()
40
34
  SetCurrentDirectory(utf8_to_utf16(resource_prefix()).c_str());
41
35
  }
42
36
 
43
- string Gosu::resource_prefix()
37
+ const std::string& Gosu::resource_prefix()
44
38
  {
45
- static string result;
46
- if (result.empty()) {
47
- result = exe_filename();
48
- auto last_delim = result.find_last_of("\\/");
49
- result.resize(last_delim == string::npos ? 0 : last_delim + 1);
50
- }
51
- return result;
39
+ static const std::string resource_prefix = [] {
40
+ std::string result = exe_filename();
41
+ const auto last_delim = result.find_last_of("\\/");
42
+ result.resize(last_delim == std::string::npos ? 0 : last_delim + 1);
43
+ return result;
44
+ }();
45
+ return resource_prefix;
52
46
  }
53
47
 
54
- string Gosu::shared_resource_prefix()
48
+ const std::string& Gosu::shared_resource_prefix()
55
49
  {
56
50
  return resource_prefix();
57
51
  }
58
52
 
59
- string Gosu::user_settings_prefix()
53
+ const std::string& Gosu::user_settings_prefix()
60
54
  {
61
- return special_folder_path(CSIDL_APPDATA);
55
+ static const std::string user_settings_prefix = special_folder_path(CSIDL_APPDATA);
56
+ return user_settings_prefix;
62
57
  }
63
58
 
64
- string Gosu::user_documents_prefix()
59
+ const std::string& Gosu::user_documents_prefix()
65
60
  {
66
- return special_folder_path(CSIDL_PERSONAL);
61
+ static const std::string user_documents_prefix = special_folder_path(CSIDL_PERSONAL);
62
+ return user_documents_prefix;
67
63
  }
68
64
 
69
65
  #endif
data/src/FileUnix.cpp CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  using namespace std;
18
18
 
19
- struct Gosu::File::Impl : Gosu::Noncopyable
19
+ struct Gosu::File::Impl : private Gosu::Noncopyable
20
20
  {
21
21
  int fd = -1;
22
22
  void* mapping = MAP_FAILED;
data/src/FileWin.cpp CHANGED
@@ -9,7 +9,7 @@ using namespace std;
9
9
 
10
10
  // TODO: Error checking
11
11
 
12
- struct Gosu::File::Impl : Gosu::Noncopyable
12
+ struct Gosu::File::Impl : private Gosu::Noncopyable
13
13
  {
14
14
  HANDLE handle = INVALID_HANDLE_VALUE;
15
15
 
data/src/Font.cpp CHANGED
@@ -13,11 +13,12 @@
13
13
 
14
14
  static const int FONT_RENDER_SCALE = 2;
15
15
 
16
- struct Gosu::Font::Impl : Gosu::Noncopyable
16
+ struct Gosu::Font::Impl : private Gosu::Noncopyable
17
17
  {
18
18
  std::string name;
19
19
  int height;
20
20
  unsigned base_flags;
21
+ unsigned image_flags;
21
22
 
22
23
  // The most common characters are stored directly in an array for maximum performance.
23
24
  // (This is the start of the Basic Multilingual Plane, up until the part where right-to-left
@@ -39,6 +40,9 @@ struct Gosu::Font::Impl : Gosu::Noncopyable
39
40
  // If this codepoint has not been rendered before, do it now.
40
41
  if (image->width() == 0 && image->height() == 0) {
41
42
  auto scaled_height = height * FONT_RENDER_SCALE;
43
+ // Optimization: Don't render higher-resolution versions if we use
44
+ // next neighbor interpolation anyway.
45
+ if (image_flags & IF_RETRO) scaled_height = height;
42
46
 
43
47
  std::u32string string(1, codepoint);
44
48
  Bitmap bitmap(scaled_height, scaled_height);
@@ -51,19 +55,20 @@ struct Gosu::Font::Impl : Gosu::Noncopyable
51
55
  font_flags);
52
56
  }
53
57
 
54
- *image = Image(bitmap, 0, 0, required_width, scaled_height);
58
+ *image = Image(bitmap, 0, 0, required_width, scaled_height, image_flags);
55
59
  }
56
60
 
57
61
  return *image;
58
62
  }
59
63
  };
60
64
 
61
- Gosu::Font::Font(int font_height, const std::string& font_name, unsigned font_flags)
65
+ Gosu::Font::Font(int font_height, const std::string& font_name, unsigned font_flags, unsigned image_flags)
62
66
  : m_impl{new Impl}
63
67
  {
64
68
  m_impl->name = font_name;
65
69
  m_impl->height = font_height;
66
70
  m_impl->base_flags = font_flags;
71
+ m_impl->image_flags = image_flags;
67
72
  }
68
73
 
69
74
  const std::string& Gosu::Font::name() const
@@ -81,6 +86,11 @@ unsigned Gosu::Font::flags() const
81
86
  return m_impl->base_flags;
82
87
  }
83
88
 
89
+ unsigned Gosu::Font::image_flags() const
90
+ {
91
+ return m_impl->image_flags;
92
+ }
93
+
84
94
  double Gosu::Font::text_width(const std::string& text) const
85
95
  {
86
96
  return markup_width(escape_markup(text));
data/src/Graphics.cpp CHANGED
@@ -42,7 +42,7 @@ namespace Gosu
42
42
  }
43
43
  }
44
44
 
45
- struct Gosu::Graphics::Impl : Gosu::Noncopyable
45
+ struct Gosu::Graphics::Impl : private Gosu::Noncopyable
46
46
  {
47
47
  unsigned virt_width = 0, virt_height = 0;
48
48
  unsigned phys_width = 0, phys_height = 0;
data/src/Image.cpp CHANGED
@@ -8,39 +8,34 @@
8
8
  #include <stdexcept>
9
9
 
10
10
  Gosu::Image::Image()
11
- : m_data(EmptyImageData::instance_ptr())
11
+ : m_data{EmptyImageData::instance_ptr()}
12
12
  {
13
13
  }
14
14
 
15
15
  Gosu::Image::Image(const std::string& filename, unsigned image_flags)
16
+ : Image(load_image_file(filename), image_flags)
16
17
  {
17
- // Forward.
18
- Bitmap bitmap = load_image_file(filename);
19
- Image{bitmap, image_flags}.m_data.swap(m_data);
20
18
  }
21
19
 
22
20
  Gosu::Image::Image(const std::string& filename, int src_x, int src_y, int src_width, int src_height,
23
21
  unsigned image_flags)
22
+ : Image(load_image_file(filename), src_x, src_y, src_width, src_height, image_flags)
24
23
  {
25
- // Forward.
26
- Bitmap bitmap = load_image_file(filename);
27
- Image{bitmap, src_x, src_y, src_width, src_height, image_flags}.m_data.swap(m_data);
28
24
  }
29
25
 
30
26
  Gosu::Image::Image(const Bitmap& source, unsigned image_flags)
27
+ : Image(source, 0, 0, source.width(), source.height(), image_flags)
31
28
  {
32
- // Forward.
33
- Image{source, 0, 0, source.width(), source.height(), image_flags}.m_data.swap(m_data);
34
29
  }
35
30
 
36
31
  Gosu::Image::Image(const Bitmap& source, int src_x, int src_y, int src_width, int src_height,
37
32
  unsigned image_flags)
38
- : m_data(Graphics::create_image(source, src_x, src_y, src_width, src_height, image_flags))
33
+ : m_data{Graphics::create_image(source, src_x, src_y, src_width, src_height, image_flags)}
39
34
  {
40
35
  }
41
36
 
42
37
  Gosu::Image::Image(std::unique_ptr<ImageData>&& data)
43
- : m_data(data.release())
38
+ : m_data{data.release()}
44
39
  {
45
40
  if (!m_data) throw std::invalid_argument("Gosu::Image cannot be initialized with nullptr");
46
41
  }
@@ -104,8 +99,8 @@ Gosu::ImageData& Gosu::Image::data() const
104
99
  return *m_data;
105
100
  }
106
101
 
107
- std::vector<Gosu::Image> Gosu::load_tiles(const Bitmap& bmp, int tile_width, int tile_height,
108
- unsigned flags)
102
+ std::vector<Gosu::Image> Gosu::load_tiles(const Bitmap& bmp, //
103
+ int tile_width, int tile_height, unsigned flags)
109
104
  {
110
105
  int tiles_x, tiles_y;
111
106
  std::vector<Image> images;
@@ -136,8 +131,8 @@ std::vector<Gosu::Image> Gosu::load_tiles(const Bitmap& bmp, int tile_width, int
136
131
  return images;
137
132
  }
138
133
 
139
- std::vector<Gosu::Image> Gosu::load_tiles(const std::string& filename, int tile_width,
140
- int tile_height, unsigned flags)
134
+ std::vector<Gosu::Image> Gosu::load_tiles(const std::string& filename, //
135
+ int tile_width, int tile_height, unsigned flags)
141
136
  {
142
137
  Bitmap bmp = load_image_file(filename);
143
138
  return load_tiles(bmp, tile_width, tile_height, flags);
data/src/Input.cpp CHANGED
@@ -36,7 +36,7 @@ static vector<shared_ptr<SDL_GameController>> open_game_controllers;
36
36
  // Stores joystick instance id or -1 if empty
37
37
  static array<int, Gosu::NUM_GAMEPADS> gamepad_slots = {-1, -1, -1, -1};
38
38
 
39
- struct Gosu::Input::Impl : Gosu::Noncopyable
39
+ struct Gosu::Input::Impl : private Gosu::Noncopyable
40
40
  {
41
41
  struct InputEvent
42
42
  {
@@ -678,4 +678,19 @@ void Gosu::Input::set_text_input(TextInput* text_input)
678
678
  pimpl->text_input = text_input;
679
679
  }
680
680
 
681
+ std::string Gosu::Input::clipboard()
682
+ {
683
+ require_sdl_video();
684
+
685
+ std::shared_ptr<char> clipboard{SDL_GetClipboardText(), SDL_free};
686
+ return std::string{clipboard.get()};
687
+ }
688
+
689
+ void Gosu::Input::set_clipboard(const std::string& text)
690
+ {
691
+ require_sdl_video();
692
+
693
+ SDL_SetClipboardText(text.c_str());
694
+ }
695
+
681
696
  #endif
data/src/InputUIKit.cpp CHANGED
@@ -7,7 +7,7 @@
7
7
  #import <UIKit/UIKit.h>
8
8
  using namespace std;
9
9
 
10
- struct Gosu::Input::Impl : Gosu::Noncopyable
10
+ struct Gosu::Input::Impl : private Gosu::Noncopyable
11
11
  {
12
12
  UIView* view = nil;
13
13
  TextInput* text_input = nullptr;
data/src/Macro.cpp CHANGED
@@ -4,7 +4,7 @@
4
4
  #include "DrawOpQueue.hpp"
5
5
  #include <stdexcept>
6
6
 
7
- struct Gosu::Macro::Impl : Gosu::Noncopyable
7
+ struct Gosu::Macro::Impl : private Gosu::Noncopyable
8
8
  {
9
9
  VertexArrays vertex_arrays;
10
10
  int width, height;
data/src/RubyGosu.cxx CHANGED
@@ -2345,6 +2345,16 @@ namespace Gosu
2345
2345
  {
2346
2346
  return Gosu::Input::axis(btn);
2347
2347
  }
2348
+
2349
+ std::string clipboard()
2350
+ {
2351
+ return Gosu::Input::clipboard();
2352
+ }
2353
+
2354
+ void set_clipboard(const std::string& text)
2355
+ {
2356
+ return Gosu::Input::set_clipboard(text);
2357
+ }
2348
2358
  }
2349
2359
 
2350
2360
  // Global graphics functions
@@ -2806,6 +2816,7 @@ SWIGINTERN Gosu::Font *new_Gosu_Font__SWIG_0(Gosu::Window &window,std::string co
2806
2816
  SWIGINTERN Gosu::Font *new_Gosu_Font__SWIG_1(int height,VALUE options=0){
2807
2817
  std::string font_name = Gosu::default_font_name();
2808
2818
  unsigned font_flags = 0;
2819
+ unsigned image_flags = 0;
2809
2820
 
2810
2821
  if (options) {
2811
2822
  Check_Type(options, T_HASH);
@@ -2831,6 +2842,9 @@ SWIGINTERN Gosu::Font *new_Gosu_Font__SWIG_1(int height,VALUE options=0){
2831
2842
  else if (!strcmp(key_string, "underline")) {
2832
2843
  if (RTEST(value)) font_flags |= Gosu::FF_UNDERLINE;
2833
2844
  }
2845
+ else if (!strcmp(key_string, "retro")) {
2846
+ if (RTEST(value)) image_flags |= Gosu::IF_RETRO;
2847
+ }
2834
2848
  else {
2835
2849
  static bool issued_warning = false;
2836
2850
  if (!issued_warning) {
@@ -2841,7 +2855,7 @@ SWIGINTERN Gosu::Font *new_Gosu_Font__SWIG_1(int height,VALUE options=0){
2841
2855
  }
2842
2856
  }
2843
2857
 
2844
- return new Gosu::Font(height, font_name, font_flags);
2858
+ return new Gosu::Font(height, font_name, font_flags, image_flags);
2845
2859
  }
2846
2860
  SWIGINTERN double Gosu_Font_text_width(Gosu::Font *self,std::string const &markup,double scale_x=1.0){
2847
2861
  static bool issued_warning = false;
@@ -5258,37 +5272,6 @@ fail:
5258
5272
  }
5259
5273
 
5260
5274
 
5261
- SWIGINTERN VALUE
5262
- _wrap_Font_flags(int argc, VALUE *argv, VALUE self) {
5263
- Gosu::Font *arg1 = (Gosu::Font *) 0 ;
5264
- void *argp1 = 0 ;
5265
- int res1 = 0 ;
5266
- unsigned int result;
5267
- VALUE vresult = Qnil;
5268
-
5269
- if ((argc < 0) || (argc > 0)) {
5270
- rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
5271
- }
5272
- res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Gosu__Font, 0 | 0 );
5273
- if (!SWIG_IsOK(res1)) {
5274
- SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "Gosu::Font const *","flags", 1, self ));
5275
- }
5276
- arg1 = reinterpret_cast< Gosu::Font * >(argp1);
5277
- {
5278
- try {
5279
- result = (unsigned int)((Gosu::Font const *)arg1)->flags();
5280
- }
5281
- catch (const std::exception& e) {
5282
- SWIG_exception(SWIG_RuntimeError, e.what());
5283
- }
5284
- }
5285
- vresult = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result));
5286
- return vresult;
5287
- fail:
5288
- return Qnil;
5289
- }
5290
-
5291
-
5292
5275
  SWIGINTERN VALUE
5293
5276
  _wrap_Font_draw_text(int argc, VALUE *argv, VALUE self) {
5294
5277
  Gosu::Font *arg1 = (Gosu::Font *) 0 ;
@@ -10945,6 +10928,64 @@ fail:
10945
10928
  }
10946
10929
 
10947
10930
 
10931
+ SWIGINTERN VALUE
10932
+ _wrap_clipboard(int argc, VALUE *argv, VALUE self) {
10933
+ std::string result;
10934
+ VALUE vresult = Qnil;
10935
+
10936
+ if ((argc < 0) || (argc > 0)) {
10937
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
10938
+ }
10939
+ {
10940
+ try {
10941
+ result = Gosu::clipboard();
10942
+ }
10943
+ catch (const std::exception& e) {
10944
+ SWIG_exception(SWIG_RuntimeError, e.what());
10945
+ }
10946
+ }
10947
+ vresult = SWIG_From_std_string(static_cast< std::string >(result));
10948
+ return vresult;
10949
+ fail:
10950
+ return Qnil;
10951
+ }
10952
+
10953
+
10954
+ SWIGINTERN VALUE
10955
+ _wrap_clipboarde___(int argc, VALUE *argv, VALUE self) {
10956
+ std::string *arg1 = 0 ;
10957
+ int res1 = SWIG_OLDOBJ ;
10958
+
10959
+ if ((argc < 1) || (argc > 1)) {
10960
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
10961
+ }
10962
+ {
10963
+ std::string *ptr = (std::string *)0;
10964
+ res1 = SWIG_AsPtr_std_string(argv[0], &ptr);
10965
+ if (!SWIG_IsOK(res1)) {
10966
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "std::string const &","Gosu::set_clipboard", 1, argv[0] ));
10967
+ }
10968
+ if (!ptr) {
10969
+ SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::string const &","Gosu::set_clipboard", 1, argv[0]));
10970
+ }
10971
+ arg1 = ptr;
10972
+ }
10973
+ {
10974
+ try {
10975
+ Gosu::set_clipboard((std::string const &)*arg1);
10976
+ }
10977
+ catch (const std::exception& e) {
10978
+ SWIG_exception(SWIG_RuntimeError, e.what());
10979
+ }
10980
+ }
10981
+ if (SWIG_IsNewObj(res1)) delete arg1;
10982
+ return Qnil;
10983
+ fail:
10984
+ if (SWIG_IsNewObj(res1)) delete arg1;
10985
+ return Qnil;
10986
+ }
10987
+
10988
+
10948
10989
  SWIGINTERN VALUE
10949
10990
  _wrap_draw_line(int argc, VALUE *argv, VALUE self) {
10950
10991
  double arg1 ;
@@ -12486,7 +12527,7 @@ SWIGEXPORT void Init_gosu(void) {
12486
12527
  rb_define_const(mGosu, "LICENSES", SWIG_From_std_string(static_cast< std::string >(Gosu::LICENSES)));
12487
12528
  rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(1)));
12488
12529
  rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(4)));
12489
- rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(1)));
12530
+ rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(4)));
12490
12531
  rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
12491
12532
  rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
12492
12533
  rb_define_module_function(mGosu, "degrees_to_radians", VALUEFUNC(_wrap_degrees_to_radians), -1);
@@ -12544,7 +12585,6 @@ SWIGEXPORT void Init_gosu(void) {
12544
12585
  rb_define_method(SwigClassFont.klass, "initialize", VALUEFUNC(_wrap_new_Font), -1);
12545
12586
  rb_define_method(SwigClassFont.klass, "name", VALUEFUNC(_wrap_Font_name), -1);
12546
12587
  rb_define_method(SwigClassFont.klass, "height", VALUEFUNC(_wrap_Font_height), -1);
12547
- rb_define_method(SwigClassFont.klass, "flags", VALUEFUNC(_wrap_Font_flags), -1);
12548
12588
  rb_define_method(SwigClassFont.klass, "draw_text", VALUEFUNC(_wrap_Font_draw_text), -1);
12549
12589
  rb_define_method(SwigClassFont.klass, "draw_markup", VALUEFUNC(_wrap_Font_draw_markup), -1);
12550
12590
  rb_define_method(SwigClassFont.klass, "draw_text_rel", VALUEFUNC(_wrap_Font_draw_text_rel), -1);
@@ -12988,6 +13028,8 @@ SWIGEXPORT void Init_gosu(void) {
12988
13028
  rb_define_module_function(mGosu, "button_name", VALUEFUNC(_wrap_button_name), -1);
12989
13029
  rb_define_module_function(mGosu, "gamepad_name", VALUEFUNC(_wrap_gamepad_name), -1);
12990
13030
  rb_define_module_function(mGosu, "axis", VALUEFUNC(_wrap_axis), -1);
13031
+ rb_define_module_function(mGosu, "clipboard", VALUEFUNC(_wrap_clipboard), -1);
13032
+ rb_define_module_function(mGosu, "clipboard=", VALUEFUNC(_wrap_clipboarde___), -1);
12991
13033
  rb_define_module_function(mGosu, "draw_line", VALUEFUNC(_wrap_draw_line), -1);
12992
13034
  rb_define_module_function(mGosu, "draw_triangle", VALUEFUNC(_wrap_draw_triangle), -1);
12993
13035
  rb_define_module_function(mGosu, "draw_quad", VALUEFUNC(_wrap_draw_quad), -1);
data/src/TextInput.cpp CHANGED
@@ -7,7 +7,7 @@
7
7
  #include <SDL.h>
8
8
  #endif
9
9
 
10
- struct Gosu::TextInput::Impl : Gosu::Noncopyable
10
+ struct Gosu::TextInput::Impl : private Gosu::Noncopyable
11
11
  {
12
12
  std::string text;
13
13
 
data/src/TimingApple.cpp CHANGED
@@ -17,11 +17,11 @@ void Gosu::sleep(unsigned milliseconds)
17
17
  unsigned long Gosu::milliseconds()
18
18
  {
19
19
  static mach_timebase_info_data_t info;
20
- static uint64_t first_tick = [] {
20
+ static const uint64_t first_tick = [] {
21
21
  mach_timebase_info(&info);
22
22
  return mach_absolute_time();
23
23
  }();
24
-
24
+
25
25
  uint64_t runtime = mach_absolute_time() - first_tick;
26
26
  return runtime * info.numer / info.denom / 1000000;
27
27
  }
data/src/TimingUnix.cpp CHANGED
@@ -12,16 +12,12 @@ void Gosu::sleep(unsigned milliseconds)
12
12
 
13
13
  unsigned long Gosu::milliseconds()
14
14
  {
15
- static unsigned long start = 0;
16
-
17
15
  timeval tp;
18
16
  gettimeofday(&tp, nullptr);
17
+ unsigned long ms = tp.tv_usec / 1000UL + tp.tv_sec * 1000UL;
19
18
 
20
- if (start == 0) {
21
- start = tp.tv_usec / 1000UL + tp.tv_sec * 1000UL;
22
- }
23
-
24
- return tp.tv_usec / 1000UL + tp.tv_sec * 1000UL - start;
19
+ static unsigned long start = ms;
20
+ return ms - start;
25
21
  }
26
22
 
27
23
  #endif
data/src/TimingWin.cpp CHANGED
@@ -2,7 +2,6 @@
2
2
  #if defined(GOSU_IS_WIN)
3
3
 
4
4
  #include <Gosu/Timing.hpp>
5
- #include <cstdlib>
6
5
  #include <windows.h>
7
6
 
8
7
  void Gosu::sleep(unsigned milliseconds)
@@ -12,7 +11,7 @@ void Gosu::sleep(unsigned milliseconds)
12
11
 
13
12
  unsigned long Gosu::milliseconds()
14
13
  {
15
- static unsigned long start = [] {
14
+ static const unsigned long start = [] {
16
15
  timeBeginPeriod(1);
17
16
  return timeGetTime();
18
17
  }();