gosu 0.10.9.pre1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/Gosu/Audio.hpp +35 -66
  3. data/Gosu/AutoLink.hpp +14 -16
  4. data/Gosu/Bitmap.hpp +50 -37
  5. data/Gosu/Buttons.hpp +246 -265
  6. data/Gosu/Color.hpp +32 -76
  7. data/Gosu/Directories.hpp +14 -17
  8. data/Gosu/Font.hpp +28 -34
  9. data/Gosu/Fwd.hpp +27 -31
  10. data/Gosu/Gosu.hpp +2 -5
  11. data/Gosu/Graphics.hpp +31 -48
  12. data/Gosu/GraphicsBase.hpp +27 -58
  13. data/Gosu/IO.hpp +44 -56
  14. data/Gosu/Image.hpp +29 -73
  15. data/Gosu/ImageData.hpp +13 -17
  16. data/Gosu/Input.hpp +42 -57
  17. data/Gosu/Inspection.hpp +2 -6
  18. data/Gosu/Math.hpp +32 -38
  19. data/Gosu/Platform.hpp +10 -29
  20. data/Gosu/Text.hpp +30 -39
  21. data/Gosu/TextInput.hpp +29 -36
  22. data/Gosu/Timing.hpp +14 -16
  23. data/Gosu/Utility.hpp +10 -15
  24. data/Gosu/Version.hpp +13 -14
  25. data/Gosu/Window.hpp +53 -68
  26. data/README.md +23 -11
  27. data/ext/gosu/extconf.rb +31 -81
  28. data/lib/gosu/patches.rb +35 -19
  29. data/lib/gosu/run.rb +13 -4
  30. data/rdoc/gosu.rb +24 -20
  31. data/src/ALChannelManagement.hpp +119 -0
  32. data/src/{Audio/Audio.cpp → Audio.cpp} +177 -211
  33. data/src/AudioFile.hpp +57 -0
  34. data/src/AudioToolboxFile.hpp +214 -0
  35. data/src/Bitmap.cpp +159 -0
  36. data/src/BitmapIO.cpp +141 -0
  37. data/src/BlockAllocator.cpp +133 -0
  38. data/src/{Graphics/BlockAllocator.hpp → BlockAllocator.hpp} +34 -35
  39. data/src/ClipRectStack.hpp +87 -0
  40. data/src/{Graphics/Color.cpp → Color.cpp} +30 -28
  41. data/src/DirectoriesApple.cpp +68 -0
  42. data/src/DirectoriesUnix.cpp +20 -18
  43. data/src/DirectoriesWin.cpp +40 -41
  44. data/src/DrawOp.hpp +168 -0
  45. data/src/DrawOpQueue.hpp +190 -0
  46. data/src/FileUnix.cpp +40 -46
  47. data/src/FileWin.cpp +42 -38
  48. data/src/Font.cpp +165 -0
  49. data/src/{Text/FormattedString.hpp → FormattedString.hpp} +114 -114
  50. data/src/GosuAppDelegate.cpp +30 -0
  51. data/src/{UIKit/GosuAppDelegate.h → GosuAppDelegate.h} +0 -0
  52. data/src/{UIKit/GosuGLView.mm → GosuGLView.cpp} +22 -17
  53. data/src/{UIKit/GosuGLView.h → GosuGLView.h} +0 -0
  54. data/src/GosuViewController.cpp +231 -0
  55. data/src/{UIKit/GosuViewController.h → GosuViewController.h} +0 -0
  56. data/src/Graphics.cpp +464 -0
  57. data/src/{Graphics/Common.hpp → GraphicsImpl.hpp} +29 -32
  58. data/src/IO.cpp +17 -16
  59. data/src/Iconv.hpp +13 -22
  60. data/src/Image.cpp +142 -0
  61. data/src/Input.cpp +459 -0
  62. data/src/InputUIKit.cpp +197 -0
  63. data/src/Inspection.cpp +4 -5
  64. data/src/LargeImageData.cpp +151 -0
  65. data/src/LargeImageData.hpp +43 -0
  66. data/src/{Graphics/Macro.cpp → Macro.cpp} +77 -78
  67. data/src/Macro.hpp +30 -0
  68. data/src/Math.cpp +17 -29
  69. data/src/{Audio/OggFile.hpp → OggFile.hpp} +19 -24
  70. data/src/RenderState.hpp +205 -0
  71. data/src/Resolution.cpp +86 -0
  72. data/src/ResolutionApple.cpp +25 -0
  73. data/{ext/gosu/gosu_wrap.cxx → src/RubyGosu.cxx} +2256 -1707
  74. data/{ext/gosu/gosu_wrap.h → src/RubyGosu.h} +9 -9
  75. data/src/{Audio/SndFile.hpp → SndFile.hpp} +54 -43
  76. data/src/TexChunk.cpp +117 -0
  77. data/src/{Graphics/TexChunk.hpp → TexChunk.hpp} +13 -18
  78. data/src/Text.cpp +371 -0
  79. data/src/TextApple.cpp +209 -0
  80. data/src/TextInput.cpp +278 -0
  81. data/src/TextTTFWin.cpp +251 -0
  82. data/src/{Text/TextUnix.cpp → TextUnix.cpp} +96 -92
  83. data/src/TextWin.cpp +194 -0
  84. data/src/{Graphics/Texture.cpp → Texture.cpp} +35 -38
  85. data/src/{Graphics/Texture.hpp → Texture.hpp} +9 -13
  86. data/src/TimingApple.cpp +11 -7
  87. data/src/TimingUnix.cpp +13 -7
  88. data/src/TimingWin.cpp +6 -1
  89. data/src/{Graphics/Transform.cpp → Transform.cpp} +17 -12
  90. data/src/{Graphics/TransformStack.hpp → TransformStack.hpp} +24 -25
  91. data/src/Utility.cpp +29 -70
  92. data/src/UtilityApple.cpp +52 -0
  93. data/src/UtilityWin.cpp +7 -4
  94. data/src/Version.cpp +22 -0
  95. data/src/WinMain.cpp +30 -33
  96. data/src/WinUtility.cpp +24 -22
  97. data/src/WinUtility.hpp +11 -20
  98. data/src/Window.cpp +142 -112
  99. data/src/WindowUIKit.cpp +155 -0
  100. data/src/stb_image.h +384 -173
  101. data/src/stb_vorbis.c +20 -18
  102. metadata +60 -62
  103. data/Gosu/TR1.hpp +0 -56
  104. data/src/AppleUtility.hpp +0 -66
  105. data/src/Audio/ALChannelManagement.hpp +0 -114
  106. data/src/Audio/Audio.mm +0 -1
  107. data/src/Audio/AudioFile.hpp +0 -53
  108. data/src/Audio/AudioToolboxFile.hpp +0 -207
  109. data/src/Bitmap/Bitmap.cpp +0 -183
  110. data/src/Bitmap/BitmapIO.cpp +0 -176
  111. data/src/DirectoriesApple.mm +0 -71
  112. data/src/Graphics/BlockAllocator.cpp +0 -142
  113. data/src/Graphics/ClipRectStack.hpp +0 -93
  114. data/src/Graphics/DrawOp.hpp +0 -175
  115. data/src/Graphics/DrawOpQueue.hpp +0 -188
  116. data/src/Graphics/Graphics.cpp +0 -478
  117. data/src/Graphics/Image.cpp +0 -193
  118. data/src/Graphics/LargeImageData.cpp +0 -133
  119. data/src/Graphics/LargeImageData.hpp +0 -46
  120. data/src/Graphics/Macro.hpp +0 -36
  121. data/src/Graphics/RenderState.hpp +0 -211
  122. data/src/Graphics/Resolution.cpp +0 -91
  123. data/src/Graphics/ResolutionApple.mm +0 -19
  124. data/src/Graphics/TexChunk.cpp +0 -112
  125. data/src/Input/Input.cpp +0 -463
  126. data/src/Input/InputUIKit.mm +0 -190
  127. data/src/Input/TextInput.cpp +0 -261
  128. data/src/Text/Font.cpp +0 -175
  129. data/src/Text/Text.cpp +0 -391
  130. data/src/Text/TextApple.mm +0 -227
  131. data/src/Text/TextTTFWin.cpp +0 -249
  132. data/src/Text/TextWin.cpp +0 -186
  133. data/src/UIKit/GosuAppDelegate.mm +0 -24
  134. data/src/UIKit/GosuViewController.mm +0 -211
  135. data/src/UtilityApple.mm +0 -63
  136. data/src/WindowUIKit.mm +0 -139
@@ -1,6 +1,9 @@
1
+ #include <Gosu/Platform.hpp>
2
+ #if defined(GOSU_IS_WIN)
3
+
1
4
  #include <Gosu/Timing.hpp>
2
- #include <windows.h>
3
5
  #include <cstdlib>
6
+ #include <windows.h>
4
7
 
5
8
  void Gosu::sleep(unsigned milliseconds)
6
9
  {
@@ -12,3 +15,5 @@ unsigned long Gosu::milliseconds()
12
15
  static unsigned long start = (timeBeginPeriod(1), timeGetTime());
13
16
  return timeGetTime() - start;
14
17
  }
18
+
19
+ #endif
@@ -1,24 +1,26 @@
1
1
  // Default matrices, adapted from original Transform support
2
2
  // contribution by erisdiscord. Thank you!
3
3
 
4
+ #include "GraphicsImpl.hpp"
4
5
  #include <Gosu/GraphicsBase.hpp>
5
6
  #include <Gosu/Math.hpp>
6
- #include "Common.hpp"
7
7
  #include <cmath>
8
8
 
9
9
  Gosu::Transform
10
- Gosu::rotate(double angle, double aroundX, double aroundY)
10
+ Gosu::rotate(double angle, double around_x, double around_y)
11
11
  {
12
- double c = std::cos(degreesToRadians(angle));
13
- double s = std::sin(degreesToRadians(angle));
12
+ double c = std::cos(degrees_to_radians(angle));
13
+ double s = std::sin(degrees_to_radians(angle));
14
14
  Gosu::Transform result = {
15
15
  +c, +s, 0, 0,
16
16
  -s, +c, 0, 0,
17
17
  0, 0, 1, 0,
18
18
  0, 0, 0, 1
19
19
  };
20
- if (aroundX != 0 || aroundY != 0)
21
- result = concat(concat(translate(-aroundX, -aroundY), result), translate(aroundX, aroundY));
20
+ if (around_x != 0 || around_y != 0) {
21
+ result = concat(concat(translate(-around_x, -around_y), result),
22
+ translate(around_x, around_y));
23
+ }
22
24
  return result;
23
25
  }
24
26
 
@@ -47,16 +49,18 @@ Gosu::scale(double factor)
47
49
  }
48
50
 
49
51
  Gosu::Transform
50
- Gosu::scale(double factorX, double factorY, double aroundX, double aroundY)
52
+ Gosu::scale(double scale_x, double scale_y, double around_x, double around_y)
51
53
  {
52
54
  Gosu::Transform result = {
53
- factorX, 0, 0, 0,
54
- 0, factorY, 0, 0,
55
+ scale_x, 0, 0, 0,
56
+ 0, scale_y, 0, 0,
55
57
  0, 0, 1, 0,
56
58
  0, 0, 0, 1
57
59
  };
58
- if (aroundX != 0 || aroundY != 0)
59
- result = concat(concat(translate(-aroundX, -aroundY), result), translate(aroundX, aroundY));
60
+ if (around_x != 0 || around_y != 0) {
61
+ result = concat(concat(translate(-around_x, -around_y), result),
62
+ translate(around_x, around_y));
63
+ }
60
64
  return result;
61
65
  }
62
66
 
@@ -66,8 +70,9 @@ Gosu::concat(const Transform& left, const Transform& right)
66
70
  Gosu::Transform result;
67
71
  for (int i = 0; i < 16; ++i) {
68
72
  result[i] = 0;
69
- for (int j = 0; j < 4; ++j)
73
+ for (int j = 0; j < 4; ++j) {
70
74
  result[i] += left[i / 4 * 4 + j] * right[i % 4 + j * 4];
75
+ }
71
76
  }
72
77
  return result;
73
78
  }
@@ -1,7 +1,6 @@
1
- #ifndef GOSU_SRC_GRAPHICS_TRANSFORMSTACK_HPP
2
- #define GOSU_SRC_GRAPHICS_TRANSFORMSTACK_HPP
1
+ #pragma once
3
2
 
4
- #include "Common.hpp"
3
+ #include "GraphicsImpl.hpp"
5
4
  #include <cassert>
6
5
  #include <algorithm>
7
6
 
@@ -14,14 +13,14 @@ namespace Gosu
14
13
  // All the absolute matrices that have been created since last reset.
15
14
  Transforms absolute;
16
15
  // Points to one absolute transform.
17
- Transforms::const_iterator currentIterator;
16
+ Transforms::const_iterator current_iterator;
18
17
 
19
- void makeCurrent(const Transform& transform)
18
+ void make_current(const Transform& transform)
20
19
  {
21
- currentIterator =
22
- std::find(absolute.begin(), absolute.end(), transform);
23
- if (currentIterator == absolute.end())
24
- currentIterator = absolute.insert(absolute.end(), transform);
20
+ current_iterator = std::find(absolute.begin(), absolute.end(), transform);
21
+ if (current_iterator == absolute.end()) {
22
+ current_iterator = absolute.insert(absolute.end(), transform);
23
+ }
25
24
  }
26
25
 
27
26
  public:
@@ -30,7 +29,7 @@ namespace Gosu
30
29
  reset();
31
30
  individual.front() = absolute.front() = scale(1);
32
31
  }
33
-
32
+
34
33
  void reset()
35
34
  {
36
35
  // Every queue has a base transform that is always the current transform.
@@ -38,7 +37,7 @@ namespace Gosu
38
37
  // set a base transform in the main rendering queue.
39
38
  individual.resize(1);
40
39
  absolute.resize(1);
41
- currentIterator = absolute.begin();
40
+ current_iterator = absolute.begin();
42
41
  }
43
42
 
44
43
  TransformStack(const TransformStack& other)
@@ -46,41 +45,43 @@ namespace Gosu
46
45
  *this = other;
47
46
  }
48
47
 
49
- // Custom assignment to ensure valid currentIterator
50
- TransformStack& operator=(const TransformStack &other)
48
+ // Custom assignment to ensure valid current_iterator
49
+ TransformStack& operator=(const TransformStack& other)
51
50
  {
52
51
  individual = other.individual;
53
52
  absolute = other.absolute;
54
53
 
55
- // Reset our currentIterator to point to the respective element
54
+ // Reset our current_iterator to point to the respective element
56
55
  // in our own 'absolute' transforms by iterating both lists up to
57
56
  // the other lists' current iterator
58
- currentIterator = absolute.begin();
59
- Transforms::const_iterator otherIterator = other.absolute.begin();
60
- while (otherIterator != other.currentIterator)
61
- ++currentIterator, ++otherIterator;
57
+ current_iterator = absolute.begin();
58
+ Transforms::const_iterator other_iterator = other.absolute.begin();
59
+ while (other_iterator != other.current_iterator) {
60
+ ++current_iterator;
61
+ ++other_iterator;
62
+ }
62
63
 
63
64
  return *this;
64
65
  }
65
66
 
66
- void setBaseTransform(const Transform& baseTransform)
67
+ void set_base_transform(const Transform& base_transform)
67
68
  {
68
69
  assert (individual.size() == 1);
69
70
  assert (absolute.size() == 1);
70
71
 
71
- individual.front() = absolute.front() = baseTransform;
72
+ individual.front() = absolute.front() = base_transform;
72
73
  }
73
74
 
74
75
  const Transform& current()
75
76
  {
76
- return *currentIterator;
77
+ return *current_iterator;
77
78
  }
78
79
 
79
80
  void push(const Transform& transform)
80
81
  {
81
82
  individual.push_back(transform);
82
83
  Transform result = concat(transform, current());
83
- makeCurrent(result);
84
+ make_current(result);
84
85
  }
85
86
 
86
87
  void pop()
@@ -92,9 +93,7 @@ namespace Gosu
92
93
  for (Transforms::reverse_iterator it = individual.rbegin(),
93
94
  end = individual.rend(); it != end; ++it)
94
95
  result = concat(result, *it);
95
- makeCurrent(result);
96
+ make_current(result);
96
97
  }
97
98
  };
98
99
  }
99
-
100
- #endif
@@ -2,10 +2,11 @@
2
2
  #include <Gosu/Platform.hpp>
3
3
  #include <cstddef>
4
4
  #include <cstdlib>
5
- #include <cwctype>
5
+ #include <cstring>
6
6
  #include <cwchar>
7
- #include <stdexcept>
7
+ #include <cwctype>
8
8
  #include <algorithm>
9
+ #include <stdexcept>
9
10
  #include <vector>
10
11
 
11
12
  #ifndef GOSU_IS_IPHONE
@@ -16,7 +17,8 @@
16
17
  using namespace std;
17
18
 
18
19
  #ifndef GOSU_IS_WIN
19
- namespace {
20
+ namespace
21
+ {
20
22
  extern const char UTF_8[] = "UTF-8";
21
23
  #ifdef __BIG_ENDIAN__
22
24
  extern const char UCS_4_INTERNAL[] = "UCS-4BE";
@@ -25,95 +27,52 @@ namespace {
25
27
  #endif
26
28
  }
27
29
 
28
- wstring Gosu::utf8ToWstring(const string& s)
30
+ wstring Gosu::utf8_to_wstring(const string& s)
29
31
  {
30
32
  return iconvert<wstring, UCS_4_INTERNAL, UTF_8>(s);
31
33
  }
32
- string Gosu::wstringToUTF8(const std::wstring& ws)
34
+ string Gosu::wstring_to_utf8(const std::wstring& ws)
33
35
  {
34
36
  return iconvert<string, UTF_8, UCS_4_INTERNAL>(ws);
35
37
  }
36
38
 
37
- #ifdef GOSU_IS_MAC
38
- // This is only necessary on OS X (for text output)
39
- // TODO: Move to respective files now that iconvert<> has been extracted
40
- // from this file.
41
-
42
- namespace {
43
- extern const char UCS_2_INTERNAL[] = "UCS-2-INTERNAL";
44
- }
45
-
46
- namespace Gosu {
47
- vector<unsigned short> wstringToUniChars(const wstring& ws)
48
- {
49
- return iconvert<vector<unsigned short>, UCS_2_INTERNAL, UCS_4_INTERNAL>(ws);
50
- }
51
- }
52
- #endif
53
39
  #else
54
40
  #ifndef NOMINMAX
55
41
  #define NOMINMAX
56
42
  #endif
57
43
  #include <windows.h>
58
- wstring Gosu::utf8ToWstring(const string& utf8)
44
+ wstring Gosu::utf8_to_wstring(const string& utf8)
59
45
  {
60
- vector<wchar_t> buffer(utf8.size() + 1);
61
- MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), utf8.size() + 1, &buffer[0], buffer.size());
62
- return &buffer[0];
63
- }
64
- string Gosu::wstringToUTF8(const wstring& ws)
46
+ vector<wchar_t> buffer(utf8.size() + 1);
47
+ MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), utf8.size() + 1, &buffer[0], buffer.size());
48
+ return &buffer[0];
49
+ }
50
+ string Gosu::wstring_to_utf8(const wstring& ws)
65
51
  {
66
- unsigned size = WideCharToMultiByte(CP_UTF8, 0, ws.c_str(), ws.size(), 0, 0, 0, 0);
67
- vector<char> buffer(size + 1);
68
- WideCharToMultiByte(CP_UTF8, 0, ws.c_str(), ws.size(), &buffer[0], buffer.size(), 0, 0);
69
- return &buffer[0];
52
+ unsigned size = WideCharToMultiByte(CP_UTF8, 0, ws.c_str(), ws.size(), 0, 0, 0, 0);
53
+ vector<char> buffer(size + 1);
54
+ WideCharToMultiByte(CP_UTF8, 0, ws.c_str(), ws.size(), &buffer[0], buffer.size(), 0, 0);
55
+ return &buffer[0];
70
56
  }
71
57
  #endif
72
-
73
- wstring Gosu::widen(const string& s)
74
- {
75
- #ifdef GOSU_IS_X
76
- setlocale(LC_ALL, "");
77
58
  #endif
78
59
 
79
- size_t wideLen = std::mbstowcs(0, s.c_str(), 0);
80
- if (wideLen == static_cast<size_t>(-1))
81
- throw std::runtime_error("Could not convert from string to wstring: " + s);
82
-
83
- vector<wchar_t> buf(wideLen + 1);
84
- mbstowcs(&buf.front(), s.c_str(), buf.size());
85
-
86
- return wstring(buf.begin(), buf.end() - 1);
87
- }
88
-
89
- string Gosu::narrow(const wstring& ws)
60
+ bool Gosu::has_extension(const std::string& filename, const char* extension)
90
61
  {
91
- size_t narrowLen = std::wcstombs(0, ws.c_str(), 0);
92
- if (narrowLen == static_cast<size_t>(-1))
93
- throw std::runtime_error("Could not convert from wstring to string: " + string(ws.begin(), ws.end()));
94
-
95
- vector<char> buf(narrowLen + 1);
96
- wcstombs(&buf.front(), ws.c_str(), buf.size());
97
-
98
- return string(buf.begin(), buf.end() - 1);
99
- }
100
-
101
- #endif
62
+ size_t ext_len = strlen(extension);
63
+ if (ext_len > filename.length()) {
64
+ return false;
65
+ }
102
66
 
103
- // TODO: This function needs to go into some internal header.
104
- namespace Gosu
105
- {
106
- bool isExtension(const wchar_t* str, const wchar_t* ext)
107
- {
108
- size_t strLen = wcslen(str), extLen = wcslen(ext);
109
- if (extLen > strLen)
67
+ const char* str = filename.c_str() + filename.length();
68
+ const char* ext = extension + ext_len;
69
+ while (ext_len--) {
70
+ if (tolower((int) *--str) != *--ext) {
110
71
  return false;
111
- str += strLen, ext += extLen;
112
- while (extLen--)
113
- if (towlower((wint_t)*--str) != *--ext)
114
- return false;
115
- return true;
72
+ }
116
73
  }
74
+
75
+ return true;
117
76
  }
118
77
 
119
78
  #if defined(GOSU_IS_UNIX) && !defined(GOSU_IS_MAC)
@@ -0,0 +1,52 @@
1
+ #include <Gosu/Platform.hpp>
2
+ #if defined(GOSU_IS_MAC)
3
+
4
+ #import <Gosu/Utility.hpp>
5
+ #import <Foundation/Foundation.h>
6
+ #import <stdexcept>
7
+ #import <vector>
8
+
9
+ #ifdef GOSU_IS_IPHONE
10
+ std::wstring Gosu::utf8_to_wstring(const std::string& s)
11
+ {
12
+ if (s.empty()) {
13
+ return std::wstring();
14
+ }
15
+
16
+ NSString* string = [NSString stringWithUTF8String:s.c_str()];
17
+ std::vector<wchar_t> buffer(s.size());
18
+ NSUInteger buffer_size;
19
+ if (![string getBytes:&buffer[0]
20
+ maxLength:buffer.size() * sizeof(wchar_t)
21
+ usedLength:&buffer_size
22
+ encoding:NSUTF32LittleEndianStringEncoding
23
+ options:0
24
+ range:NSMakeRange(0, string.length)
25
+ remainingRange:nullptr]) {
26
+ throw std::runtime_error("String " + s + " could not be converted to UTF-32");
27
+ }
28
+ return std::wstring(&buffer[0], &buffer[0] + buffer_size / sizeof(wchar_t));
29
+ }
30
+
31
+ std::string Gosu::wstring_to_utf8(const std::wstring& ws)
32
+ {
33
+ if (ws.empty()) return std::string();
34
+
35
+ @autoreleasepool {
36
+ NSString* string = [[NSString alloc] initWithBytes:ws.data()
37
+ length:ws.size() * sizeof(wchar_t)
38
+ encoding:NSUTF32LittleEndianStringEncoding];
39
+ return string.UTF8String ?: std::string();
40
+ }
41
+ }
42
+ #endif
43
+
44
+ std::string Gosu::language()
45
+ {
46
+ @autoreleasepool {
47
+ NSString* language = [NSLocale preferredLanguages][0];
48
+ return language.UTF8String ?: "en";
49
+ }
50
+ }
51
+
52
+ #endif
@@ -1,13 +1,16 @@
1
+ #include <Gosu/Platform.hpp>
2
+ #if defined(GOSU_IS_WIN)
3
+
1
4
  #include <Gosu/Utility.hpp>
2
5
  #include "WinUtility.hpp"
3
6
  #include <windows.h>
4
- using namespace std;
5
7
 
6
- string Gosu::language()
8
+ std::string Gosu::language()
7
9
  {
8
10
  LCID lcid = GetUserDefaultLCID();
9
11
  char buffer[9];
10
- Win::check(
11
- GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME, buffer, sizeof buffer));
12
+ winapi_check(GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME, buffer, sizeof buffer));
12
13
  return buffer;
13
14
  }
15
+
16
+ #endif
@@ -0,0 +1,22 @@
1
+ #include <Gosu/Version.hpp>
2
+ #include <Gosu/Platform.hpp>
3
+ #include <string>
4
+
5
+ const std::string Gosu::VERSION = std::to_string(GOSU_MAJOR_VERSION) + '.' +
6
+ std::to_string(GOSU_MINOR_VERSION) + '.' +
7
+ std::to_string(GOSU_POINT_VERSION);
8
+
9
+ const std::string Gosu::LICENSES =
10
+ "This software may utilize code from the following third-party libraries:\n"
11
+ "\n"
12
+ "Gosu, https://www.libgosu.org, MIT License, http://opensource.org/licenses/MIT\n"
13
+ "SDL 2, http://www.libsdl.org, MIT License, http://opensource.org/licenses/MIT\n"
14
+ #if defined(GOSU_IS_WIN) || defined(GOSU_IS_X)
15
+ "libsndfile, http://www.mega-nerd.com/libsndfile, GNU LGPL 3, "
16
+ "http://www.gnu.org/copyleft/lesser.html\n"
17
+ #endif
18
+ #if defined(GOSU_IS_WIN)
19
+ "OpenAL Soft, http://kcat.strangesoft.net/openal.html, GNU LGPL 2, "
20
+ "http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html\n"
21
+ #endif
22
+ ;
@@ -1,48 +1,45 @@
1
- #include <windows.h>
1
+ #include <Gosu/Platform.hpp>
2
+ #if defined(GOSU_IS_WIN)
3
+
2
4
  #include <exception>
3
5
  #include <string>
4
6
  #include <vector>
7
+ #include <windows.h>
5
8
  using namespace std;
6
9
 
7
- vector<string> splitCmdLine()
10
+ vector<string> split_cmd_line()
8
11
  {
9
12
  vector<string> result;
10
13
 
11
- const char* cmdLine = ::GetCommandLineA();
14
+ const char* cmd_line = ::GetCommandLineA();
12
15
 
13
- const char* argBegin = 0;
14
- bool isQuotedArg = false;
16
+ const char* arg_begin = nullptr;
17
+ bool is_quoted_arg = false;
15
18
 
16
- while (*cmdLine)
17
- {
18
- if (*cmdLine == '"')
19
- {
20
- if (argBegin == 0)
21
- {
22
- argBegin = cmdLine + 1;
23
- isQuotedArg = true;
19
+ while (*cmd_line) {
20
+ if (*cmd_line == '"') {
21
+ if (arg_begin == nullptr) {
22
+ arg_begin = cmd_line + 1;
23
+ is_quoted_arg = true;
24
24
  }
25
- else if (isQuotedArg)
26
- {
27
- result.push_back(std::string(argBegin, cmdLine));
28
- argBegin = 0;
25
+ else if (is_quoted_arg) {
26
+ result.push_back(std::string(arg_begin, cmd_line));
27
+ arg_begin = nullptr;
29
28
  }
30
29
  }
31
- else if (!isspace((unsigned char)*cmdLine) && argBegin == 0)
32
- {
33
- argBegin = cmdLine;
34
- isQuotedArg = false;
30
+ else if (!isspace((unsigned char)*cmd_line) && arg_begin == nullptr) {
31
+ arg_begin = cmd_line;
32
+ is_quoted_arg = false;
35
33
  }
36
- else if (isspace((unsigned char)*cmdLine) && argBegin != 0 && !isQuotedArg)
37
- {
38
- result.push_back(std::string(argBegin, cmdLine + 1));
39
- argBegin = 0;
34
+ else if (isspace((unsigned char)*cmd_line) && arg_begin != nullptr && !is_quoted_arg) {
35
+ result.push_back(std::string(arg_begin, cmd_line + 1));
36
+ arg_begin = nullptr;
40
37
  }
41
- ++cmdLine;
38
+ ++cmd_line;
42
39
  }
43
40
 
44
- if (argBegin != 0)
45
- result.push_back(argBegin);
41
+ if (arg_begin != 0)
42
+ result.push_back(arg_begin);
46
43
 
47
44
  return result;
48
45
  }
@@ -51,17 +48,17 @@ int main(int argc, char* argv[]);
51
48
 
52
49
  int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
53
50
  {
54
- try
55
- {
56
- vector<string> arguments = splitCmdLine();
51
+ try {
52
+ vector<string> arguments = split_cmd_line();
57
53
  vector<char*> argv(arguments.size());
58
54
  for (unsigned i = 0; i < argv.size(); ++i)
59
55
  argv[i] = const_cast<char*>(arguments[i].c_str());
60
56
  return main(argv.size(), &argv[0]);
61
57
  }
62
- catch (const std::exception& e)
63
- {
58
+ catch (const std::exception& e) {
64
59
  ::MessageBoxA(0, e.what(), "Uncaught Exception", MB_OK | MB_ICONERROR);
65
60
  return EXIT_FAILURE;
66
61
  }
67
62
  }
63
+
64
+ #endif