gosu 0.7.18 → 0.7.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/COPYING.txt +1 -1
  2. data/Gosu/GraphicsBase.hpp +4 -2
  3. data/Gosu/IO.hpp +2 -9
  4. data/Gosu/Math.hpp +8 -6
  5. data/Gosu/Version.hpp +2 -2
  6. data/GosuImpl/Graphics/Common.hpp +4 -3
  7. data/GosuImpl/Graphics/DrawOp.hpp +4 -0
  8. data/GosuImpl/Graphics/Graphics.cpp +1 -1
  9. data/GosuImpl/Graphics/Image.cpp +1 -1
  10. data/GosuImpl/Graphics/LargeImageData.cpp +1 -1
  11. data/GosuImpl/Graphics/TexChunk.cpp +1 -1
  12. data/GosuImpl/Graphics/TextTouch.mm +79 -8
  13. data/GosuImpl/Graphics/Texture.cpp +15 -1
  14. data/GosuImpl/IO.cpp +10 -0
  15. data/GosuImpl/InputTouch.mm +10 -1
  16. data/GosuImpl/RubyGosu.swg +7 -13
  17. data/GosuImpl/RubyGosu_wrap.cxx +52 -22
  18. data/GosuImpl/Sockets/CommSocket.cpp +4 -3
  19. data/GosuImpl/Sockets/ListenerSocket.cpp +0 -1
  20. data/GosuImpl/Sockets/MessageSocket.cpp +8 -16
  21. data/GosuImpl/Sockets/Sockets.hpp +0 -1
  22. data/GosuImpl/WindowTouch.mm +2 -1
  23. data/Rakefile +3 -2
  24. data/lib/gosu.rb +3 -0
  25. data/lib/gosu/patches.rb +13 -2
  26. data/lib/gosu/swig_patches.rb +21 -0
  27. data/linux/extconf.rb +1 -1
  28. data/reference/cpp/_graphics_base_8hpp.html +3 -2
  29. data/reference/cpp/_graphics_base_8hpp_source.html +31 -30
  30. data/reference/cpp/_i_o_8hpp_source.html +49 -56
  31. data/reference/cpp/_math_8hpp.html +6 -6
  32. data/reference/cpp/_math_8hpp_source.html +63 -63
  33. data/reference/cpp/_version_8hpp.html +4 -4
  34. data/reference/cpp/_version_8hpp_source.html +2 -2
  35. data/reference/cpp/class_gosu_1_1_buffer.html +2 -6
  36. data/reference/cpp/class_gosu_1_1_file.html +1 -1
  37. data/reference/cpp/namespace_gosu.html +60 -57
  38. data/reference/cpp/namespacemembers.html +2 -0
  39. data/reference/cpp/namespacemembers_0x62.html +2 -2
  40. data/reference/cpp/namespacemembers_0x64.html +2 -0
  41. data/reference/cpp/namespacemembers_0x67.html +0 -2
  42. data/reference/cpp/namespacemembers_0x72.html +2 -2
  43. data/reference/cpp/namespacemembers_eval.html +4 -2
  44. data/reference/cpp/namespacemembers_func.html +4 -4
  45. data/reference/rdoc/classes/Gosu.html +1546 -0
  46. data/reference/rdoc/classes/Gosu/Color.html +660 -0
  47. data/reference/rdoc/classes/Gosu/Font.html +545 -0
  48. data/reference/rdoc/classes/Gosu/GLTexInfo.html +412 -0
  49. data/reference/rdoc/classes/Gosu/Image.html +706 -0
  50. data/reference/rdoc/classes/Gosu/Sample.html +476 -0
  51. data/reference/rdoc/classes/Gosu/SampleInstance.html +523 -0
  52. data/reference/rdoc/classes/Gosu/Song.html +568 -0
  53. data/reference/rdoc/classes/Gosu/TextInput.html +444 -0
  54. data/reference/rdoc/classes/Gosu/Window.html +911 -0
  55. data/reference/rdoc/classes/Numeric.html +479 -0
  56. data/reference/rdoc/created.rid +1 -0
  57. data/reference/rdoc/files/COPYING_txt.html +391 -0
  58. data/reference/rdoc/files/README_txt.html +387 -0
  59. data/reference/rdoc/files/reference/Deployment on OS X_rdoc.html +381 -0
  60. data/reference/rdoc/files/reference/Deployment on Windows_rdoc.html +385 -0
  61. data/reference/rdoc/files/reference/Drawing with Colors_rdoc.html +363 -0
  62. data/reference/rdoc/files/reference/Order of Corners_rdoc.html +358 -0
  63. data/reference/rdoc/files/reference/Tileability_rdoc.html +374 -0
  64. data/reference/rdoc/files/reference/Z Ordering_rdoc.html +361 -0
  65. data/reference/rdoc/files/reference/gosu_rb.html +348 -0
  66. data/reference/rdoc/fr_class_index.html +12 -0
  67. data/reference/rdoc/fr_file_index.html +10 -0
  68. data/reference/rdoc/fr_method_index.html +66 -0
  69. data/reference/rdoc/index.html +1 -0
  70. data/reference/rdoc/rdoc-style.css +320 -0
  71. metadata +29 -11
  72. data/GosuImpl/ObjGosu/ObjGosu.mm +0 -36
  73. data/GosuImpl/ObjGosu/ObjGosuColor.mm +0 -84
  74. data/GosuImpl/ObjGosu/ObjGosuFont.mm +0 -42
  75. data/GosuImpl/ObjGosu/ObjGosuImage.h +0 -7
  76. data/GosuImpl/ObjGosu/ObjGosuImage.mm +0 -65
  77. data/GosuImpl/ObjGosu/ObjGosuSample.mm +0 -32
  78. data/GosuImpl/ObjGosu/ObjGosuSong.mm +0 -43
  79. data/GosuImpl/ObjGosu/ObjGosuWindow.h +0 -32
  80. data/GosuImpl/ObjGosu/ObjGosuWindow.mm +0 -155
@@ -1,4 +1,4 @@
1
- Copyright (C) 2004-2007 Julian Raschke, Jan Lücker and all contributors.
1
+ Copyright (C) 2004-2010 Julian Raschke, Jan Lücker and all contributors.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a
4
4
  copy of this software and associated documentation files (the "Software"),
@@ -28,7 +28,9 @@ namespace Gosu
28
28
  //! The colors' channels will be added. The alpha channel specifies
29
29
  //! the percentage of the new color's channels that will be added
30
30
  //! to the old color's channels.
31
- amAdditive
31
+ amAdditive,
32
+ //! The color's channels will be multiplied with each other.
33
+ amMultiply
32
34
  };
33
35
 
34
36
  enum FontFlags
@@ -49,7 +51,7 @@ namespace Gosu
49
51
  //! Flags that affect the tileability of an image.
50
52
  enum BorderFlags
51
53
  {
52
- bfSoft = 0,
54
+ bfSmooth = 0,
53
55
  bfTileableLeft = 1,
54
56
  bfTileableTop = 2,
55
57
  bfTileableRight = 4,
@@ -192,15 +192,8 @@ namespace Gosu
192
192
  return *this;
193
193
  }
194
194
 
195
- std::size_t size() const
196
- {
197
- return buf.size();
198
- }
199
-
200
- void resize(std::size_t newSize)
201
- {
202
- buf.resize(newSize);
203
- }
195
+ std::size_t size() const;
196
+ void resize(std::size_t newSize);
204
197
 
205
198
  void read(std::size_t offset, std::size_t length,
206
199
  void* destBuffer) const;
@@ -29,26 +29,28 @@ namespace Gosu
29
29
  //! Uses std::rand, so you should call std::srand before using it.
30
30
  double random(double min, double max);
31
31
 
32
- //! Translates between Gosu's angle system and radians.
32
+ //! Translates between Gosu's angle system (where 0� is at the top)
33
+ //! and radians (where 0 is at the right).
33
34
  inline double gosuToRadians(double angle)
34
35
  {
35
36
  return (angle - 90) * pi / 180;
36
37
  }
37
- //! Translates between Gosu's angle system and radians.
38
+ //! Translates between Gosu's angle system (where 0� is at the top)
39
+ //! and radians (where 0 is at the right).
38
40
  inline double radiansToGosu(double angle)
39
41
  {
40
42
  return angle * 180 / pi + 90;
41
43
  }
42
44
 
43
- //! Translates between Gosu's angle scaling and radians, i.e. it
45
+ //! Translates between degrees (used by Gosu) and radians, i.e. it
44
46
  //! does not change the 'origin' of the angle system.
45
- inline double gosuToRadianScale(double angle)
47
+ inline double degreesToRadians(double angle)
46
48
  {
47
49
  return angle * pi / 180;
48
50
  }
49
- //! Translates between Gosu's angle scaling and radians, i.e. it
51
+ //! Translates between degrees (used by Gosu) and radians, i.e. it
50
52
  //! does not change the 'origin' of the angle system.
51
- inline double radiansScaleToGosu(double angle)
53
+ inline double radiansToDegrees(double angle)
52
54
  {
53
55
  return angle * 180 / pi;
54
56
  }
@@ -3,7 +3,7 @@
3
3
 
4
4
  #define GOSU_MAJOR_VERSION 0
5
5
  #define GOSU_MINOR_VERSION 7
6
- #define GOSU_POINT_VERSION 18
7
- #define GOSU_VERSION "0.7.18"
6
+ #define GOSU_POINT_VERSION 19
7
+ #define GOSU_VERSION "0.7.19"
8
8
 
9
9
  #endif
@@ -33,16 +33,17 @@ namespace Gosu
33
33
  {
34
34
  return (xb - xa) * (yp - ya) - (xp - xa) * (yb - ya) > 0;
35
35
  }
36
-
37
- template<typename T>
36
+
37
+ template<typename T, typename C>
38
38
  void reorderCoordinatesIfNecessary(T& x1, T& y1,
39
- T& x2, T& y2, T& x3, T& y3, T& x4, T& y4)
39
+ T& x2, T& y2, T& x3, T& y3, C& c3, T& x4, T& y4, C& c4)
40
40
  {
41
41
  if (isPToTheLeftOfAB(x1, y1, x2, y2, x3, y3) ==
42
42
  isPToTheLeftOfAB(x2, y2, x3, y3, x4, y4))
43
43
  {
44
44
  std::swap(x3, x4);
45
45
  std::swap(y3, y4);
46
+ std::swap(c3, c4);
46
47
  }
47
48
  }
48
49
  }
@@ -54,6 +54,8 @@ namespace Gosu
54
54
 
55
55
  if (mode == amAdditive)
56
56
  glBlendFunc(GL_SRC_ALPHA, GL_ONE);
57
+ else if (mode == amMultiply)
58
+ glBlendFunc(GL_DST_COLOR, GL_ZERO);
57
59
  else
58
60
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
59
61
 
@@ -146,6 +148,8 @@ namespace Gosu
146
148
 
147
149
  if (mode == amAdditive)
148
150
  glBlendFunc(GL_SRC_ALPHA, GL_ONE);
151
+ else if (mode == amMultiply)
152
+ glBlendFunc(GL_DST_COLOR, GL_ZERO);
149
153
  else
150
154
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
151
155
 
@@ -281,7 +281,7 @@ void Gosu::Graphics::drawQuad(double x1, double y1, Color c1,
281
281
  double x4, double y4, Color c4,
282
282
  ZPos z, AlphaMode mode)
283
283
  {
284
- reorderCoordinatesIfNecessary(x1, y1, x2, y2, x3, y3, x4, y4);
284
+ reorderCoordinatesIfNecessary(x1, y1, x2, y2, x3, y3, c3, x4, y4, c4);
285
285
 
286
286
  DrawOp op;
287
287
 
@@ -29,7 +29,7 @@ Gosu::Image::Image(Graphics& graphics, const Bitmap& source,
29
29
  unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
30
30
  bool tileable)
31
31
  : data(graphics.createImage(source, srcX, srcY, srcWidth, srcHeight,
32
- tileable ? Gosu::bfTileable : Gosu::bfSoft))
32
+ tileable ? Gosu::bfTileable : Gosu::bfSmooth))
33
33
  {
34
34
  }
35
35
 
@@ -85,7 +85,7 @@ void Gosu::LargeImageData::draw(double x1, double y1, Color c1,
85
85
  if (parts.empty())
86
86
  return;
87
87
 
88
- reorderCoordinatesIfNecessary(x1, y1, x2, y2, x3, y3, x4, y4);
88
+ reorderCoordinatesIfNecessary(x1, y1, x2, y2, x3, y3, c3, x4, y4, c4);
89
89
 
90
90
  for (unsigned py = 0; py < partsY; ++py)
91
91
  for (unsigned px = 0; px < partsX; ++px)
@@ -47,7 +47,7 @@ void Gosu::TexChunk::draw(double x1, double y1, Color c1,
47
47
  {
48
48
  DrawOp newDrawOp;
49
49
 
50
- reorderCoordinatesIfNecessary(x1, y1, x2, y2, x3, y3, x4, y4);
50
+ reorderCoordinatesIfNecessary(x1, y1, x2, y2, x3, y3, c3, x4, y4, c4);
51
51
 
52
52
  x1 *= graphics->factorX();
53
53
  y1 *= graphics->factorY();
@@ -21,14 +21,83 @@ typedef NSFont OSXFont;
21
21
 
22
22
  namespace
23
23
  {
24
- map<pair<wstring, double>, OSXFont*> usedFonts;
25
- OSXFont* getFont(const wstring& name, double height)
24
+ // TODO: Merge with InputMac.mm
25
+ template<typename CFTypeRef>
26
+ class CFScope : boost::noncopyable
26
27
  {
27
- OSXFont* result = usedFonts[make_pair(name, height)];
28
+ CFTypeRef ref;
29
+ public:
30
+ explicit CFScope(CFTypeRef ref) : ref(ref) {}
31
+ ~CFScope() { CFRelease(ref); }
32
+ CFTypeRef get() { return ref; }
33
+ };
34
+
35
+ // If a font is a filename, loads the font and returns its family name that can be used
36
+ // like any system font. Otherwise, just returns the family name.
37
+ std::wstring normalizeFont(const std::wstring& fontName)
38
+ {
39
+ #ifdef GOSU_IS_IPHONE
40
+ return fontName;
41
+ #else
42
+ static map<wstring, wstring> familyOfFiles;
43
+
44
+ // Not a path name: It is already a family name
45
+ if (fontName.find(L"/") == std::wstring::npos)
46
+ return fontName;
47
+
48
+ // Already activated font & extracted family name
49
+ if (familyOfFiles.count(fontName) > 0)
50
+ return familyOfFiles[fontName];
51
+
52
+ CFScope<CFStringRef> urlString(
53
+ CFStringCreateWithBytes(NULL,
54
+ reinterpret_cast<const UInt8*>(fontName.c_str()),
55
+ fontName.length() * sizeof(wchar_t),
56
+ kCFStringEncodingUTF32LE, NO));
57
+ CFScope<CFURLRef> url(
58
+ CFURLCreateWithFileSystemPath(NULL, urlString.get(),
59
+ kCFURLPOSIXPathStyle, YES));
60
+ if (!url.get())
61
+ return familyOfFiles[fontName] = Gosu::defaultFontName();
62
+
63
+ CFScope<CFArrayRef> array(
64
+ CTFontManagerCreateFontDescriptorsFromURL(url.get()));
65
+
66
+ if (array.get() == NULL || CFArrayGetCount(array.get()) < 1 ||
67
+ !CTFontManagerRegisterFontsForURL(url.get(),
68
+ kCTFontManagerScopeProcess, NULL))
69
+ return familyOfFiles[fontName] = Gosu::defaultFontName();
70
+
71
+ CTFontDescriptorRef ref =
72
+ (CTFontDescriptorRef)CFArrayGetValueAtIndex(array.get(), 0);
73
+ CFScope<CFStringRef> fontNameStr(
74
+ (CFStringRef)CTFontDescriptorCopyAttribute(ref, kCTFontFamilyNameAttribute));
75
+
76
+ const char* utf8FontName =
77
+ [(NSString*)fontNameStr.get() cStringUsingEncoding: NSUTF8StringEncoding];
78
+ return familyOfFiles[fontName] = Gosu::utf8ToWstring(utf8FontName);
79
+ #endif
80
+ }
81
+
82
+ OSXFont* getFont(wstring fontName, double height)
83
+ {
84
+ fontName = normalizeFont(fontName);
85
+
86
+ static map<pair<wstring, double>, OSXFont*> usedFonts;
87
+
88
+ OSXFont* result = usedFonts[make_pair(fontName, height)];
28
89
  if (!result)
29
90
  {
30
- Gosu::ObjRef<NSString> fontName([[NSString alloc] initWithUTF8String: Gosu::wstringToUTF8(name).c_str()]);
31
- result = [[OSXFont fontWithName: fontName.obj() size: height] retain];
91
+ Gosu::ObjRef<NSString> name([[NSString alloc] initWithUTF8String: Gosu::wstringToUTF8(fontName).c_str()]);
92
+ #ifdef GOSU_IS_IPHONE
93
+ result = [[OSXFont fontWithName: name.obj() size: height] retain];
94
+ #else
95
+ NSFontDescriptor* desc = [[[NSFontDescriptor alloc] initWithFontAttributes:nil] fontDescriptorWithFamily:name.obj()];
96
+ result = [[NSFont fontWithDescriptor:desc size:height] retain];
97
+ #endif
98
+ if (!result && fontName != Gosu::defaultFontName())
99
+ result = getFont(Gosu::defaultFontName(), height);
100
+ usedFonts[make_pair(fontName, height)] = result;
32
101
  }
33
102
  return result;
34
103
  }
@@ -46,7 +115,8 @@ unsigned Gosu::textWidth(const wstring& text,
46
115
  {
47
116
  OSXFont* font = getFont(fontName, fontHeight);
48
117
 
49
- // This will, of course, compute a too large size; fontHeight is in pixels, the method expects point.
118
+ // This will, of course, compute a too large size; fontHeight is in pixels,
119
+ // the method expects point.
50
120
  ObjRef<NSString> string([[NSString alloc] initWithUTF8String: wstringToUTF8(text).c_str()]);
51
121
  #ifndef GOSU_IS_IPHONE
52
122
  ObjRef<NSDictionary> attributes([[NSDictionary alloc] initWithObjectsAndKeys:
@@ -111,8 +181,9 @@ void Gosu::drawText(Bitmap& bitmap, const wstring& text, int x, int y,
111
181
  font, NSFontAttributeName, [NSColor whiteColor], NSForegroundColorAttributeName, nil]);
112
182
 
113
183
  [NSGraphicsContext saveGraphicsState];
114
- [NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithGraphicsPort:(void *)context flipped:false]];
115
- [string.obj() drawAtPoint: NSPointZero withAttributes: attributes.get()];
184
+ [NSGraphicsContext setCurrentContext:
185
+ [NSGraphicsContext graphicsContextWithGraphicsPort:(void *)context flipped:false]];
186
+ [string.obj() drawAtPoint: NSPointZero withAttributes: attributes.get()];
116
187
  [NSGraphicsContext restoreGraphicsState];
117
188
  #endif
118
189
  CGContextRelease(context);
@@ -37,6 +37,11 @@ unsigned Gosu::Texture::maxTextureSize()
37
37
 
38
38
  //const unsigned Gosu::MAX_TEXTURE_SIZE = Gosu::Texture::maxTextureSize();
39
39
 
40
+ namespace Gosu
41
+ {
42
+ bool undocumentedRetrofication = false;
43
+ }
44
+
40
45
  Gosu::Texture::Texture(unsigned size)
41
46
  : allocator(size, size), num(0)
42
47
  {
@@ -54,7 +59,15 @@ Gosu::Texture::Texture(unsigned size)
54
59
  glTexImage2D(GL_TEXTURE_2D, 0, 4, allocator.width(), allocator.height(), 0,
55
60
  GL_RGBA, GL_UNSIGNED_BYTE, 0);
56
61
  #endif
57
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
62
+
63
+ if (undocumentedRetrofication)
64
+ {
65
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
66
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
67
+ }
68
+ else
69
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
70
+
58
71
  #ifdef GOSU_IS_WIN
59
72
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
60
73
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
@@ -121,6 +134,7 @@ std::auto_ptr<Gosu::TexChunk>
121
134
  glBindTexture(GL_TEXTURE_2D, name);
122
135
  glTexSubImage2D(GL_TEXTURE_2D, 0, block->left, block->top, block->width, block->height,
123
136
  format, GL_UNSIGNED_BYTE, texData);
137
+
124
138
  num += 1;
125
139
  return result;
126
140
  }
@@ -18,6 +18,16 @@ void Gosu::Writer::write(const void* source, std::size_t length)
18
18
  seek(length);
19
19
  }
20
20
 
21
+ std::size_t Gosu::Buffer::size() const
22
+ {
23
+ return buf.size();
24
+ }
25
+
26
+ void Gosu::Buffer::resize(std::size_t newSize)
27
+ {
28
+ buf.resize(newSize);
29
+ }
30
+
21
31
  void Gosu::Buffer::read(std::size_t offset, std::size_t length,
22
32
  void* destBuffer) const
23
33
  {
@@ -1,4 +1,13 @@
1
- #include <Gosu/input.hpp>
1
+ #include <Gosu/Input.hpp>
2
+ #include <Gosu/TextInput.hpp>
3
+
4
+ struct Gosu::TextInput::Impl {};
5
+ Gosu::TextInput::TextInput() {}
6
+ Gosu::TextInput::~TextInput() {}
7
+ std::wstring Gosu::TextInput::text() const { return L""; }
8
+ void Gosu::TextInput::setText(const std::wstring& text) {}
9
+ unsigned Gosu::TextInput::caretPos() const { return 0; }
10
+ unsigned Gosu::TextInput::selectionStart() const { return 0; }
2
11
 
3
12
  struct Gosu::Input::Impl {
4
13
  };
@@ -78,6 +78,8 @@
78
78
  $1 = Gosu::amDefault;
79
79
  else if (!strcmp(StringValueCStr(localTemporary), "additive"))
80
80
  $1 = Gosu::amAdditive;
81
+ else if (!strcmp(StringValueCStr(localTemporary), "multiply"))
82
+ $1 = Gosu::amMultiply;
81
83
  else
82
84
  SWIG_exception_fail(SWIG_ValueError, "invalid alpha mode");
83
85
  }
@@ -159,6 +161,7 @@
159
161
  // For Ruby-only MAX_TEXTURE_SIZE
160
162
  #include <Gosu/../GosuImpl/Graphics/Texture.hpp>
161
163
  namespace Gosu {
164
+ void enableUndocumentedRetrofication() { extern bool undocumentedRetrofication; undocumentedRetrofication = true; }
162
165
  unsigned __maxTextureSize() { return Gosu::Texture::maxTextureSize(); }
163
166
  }
164
167
 
@@ -283,6 +286,7 @@ namespace Gosu
283
286
  //%constant unsigned MAX_TEXTURE_SIZE = Gosu::Texture::maxTextureSize();
284
287
 
285
288
  namespace Gosu {
289
+ void enableUndocumentedRetrofication() { extern bool undocumentedRetrofication; undocumentedRetrofication = true; }
286
290
  unsigned __maxTextureSize() { return Gosu::Texture::maxTextureSize(); }
287
291
  }
288
292
 
@@ -357,7 +361,7 @@ namespace Gosu {
357
361
  %include "../Gosu/ImageData.hpp"
358
362
 
359
363
  // Image
360
- // Hackishly allow the user to pass Window& instead of Graphics&.
364
+ // Allow the user to pass Window& instead of Graphics&.
361
365
  // Also, provide convenience functions.
362
366
 
363
367
  // Typemap to return an array of images (for loadTiles)
@@ -377,7 +381,8 @@ namespace Gosu {
377
381
  %include "../Gosu/Image.hpp"
378
382
  %extend Gosu::Image {
379
383
  Image(Gosu::Window& window, VALUE source, bool tileable = false) {
380
- return new Gosu::Image(window.graphics(), Gosu::loadBitmap(source), tileable);
384
+ return new Gosu::Image(window.graphics(),
385
+ Gosu::loadBitmap(source), tileable);
381
386
  }
382
387
  Image(Gosu::Window& window, VALUE source, bool tileable,
383
388
  unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight) {
@@ -451,17 +456,6 @@ namespace Gosu {
451
456
  // Does not matter that it's the Mac file, %include only analyses symbols to export, not their values.
452
457
  %include "../Gosu/ButtonsMac.hpp"
453
458
  %init %{
454
- // ARGH, SWIG workaround...
455
- // It doesn't understand the C++ overloading otherwise.
456
- rb_eval_string("class Gosu::Image; def self.from_text(*args); args.size == 4 ? from_text4(*args) : from_text7(*args); end; end");
457
-
458
- // ARGH, SWIG workaround 2..
459
- // It won't let me have a class method and method with the same name.
460
- rb_eval_string("class Gosu::Window; def button_id_to_char(id); self.class.button_id_to_char(id); end; def char_to_button_id(ch); self.class.char_to_button_id(ch); end; end");
461
-
462
- // ARGH, Linux workaround: instead of declaring a constant, we declare a hidden function and call it when we need to define the constant.
463
- rb_eval_string("module Gosu;def self.const_missing sym;if sym == :MAX_TEXTURE_SIZE then;const_set sym, __max_texture_size;else;super;end;end;end");
464
-
465
459
  GosusDarkSide::oncePerTick = GosusDarkSide::yieldToOtherRubyThreads;
466
460
  %}
467
461
 
@@ -2232,6 +2232,7 @@ static VALUE mGosu;
2232
2232
  // For Ruby-only MAX_TEXTURE_SIZE
2233
2233
  #include <Gosu/../GosuImpl/Graphics/Texture.hpp>
2234
2234
  namespace Gosu {
2235
+ void enableUndocumentedRetrofication() { extern bool undocumentedRetrofication; undocumentedRetrofication = true; }
2235
2236
  unsigned __maxTextureSize() { return Gosu::Texture::maxTextureSize(); }
2236
2237
  }
2237
2238
 
@@ -2573,7 +2574,8 @@ SWIG_AsVal_bool (VALUE obj, bool *val)
2573
2574
  }
2574
2575
 
2575
2576
  SWIGINTERN Gosu::Image *new_Gosu_Image__SWIG_0(Gosu::Window &window,VALUE source,bool tileable=false){
2576
- return new Gosu::Image(window.graphics(), Gosu::loadBitmap(source), tileable);
2577
+ return new Gosu::Image(window.graphics(),
2578
+ Gosu::loadBitmap(source), tileable);
2577
2579
  }
2578
2580
  SWIGINTERN Gosu::Image *new_Gosu_Image__SWIG_1(Gosu::Window &window,VALUE source,bool tileable,unsigned int srcX,unsigned int srcY,unsigned int srcWidth,unsigned int srcHeight){
2579
2581
  return new Gosu::Image(window.graphics(), Gosu::loadBitmap(source),
@@ -2851,7 +2853,7 @@ fail:
2851
2853
 
2852
2854
 
2853
2855
  SWIGINTERN VALUE
2854
- _wrap_gosu_to_radian_scale(int argc, VALUE *argv, VALUE self) {
2856
+ _wrap_degrees_to_radians(int argc, VALUE *argv, VALUE self) {
2855
2857
  double arg1 ;
2856
2858
  double val1 ;
2857
2859
  int ecode1 = 0 ;
@@ -2863,12 +2865,12 @@ _wrap_gosu_to_radian_scale(int argc, VALUE *argv, VALUE self) {
2863
2865
  }
2864
2866
  ecode1 = SWIG_AsVal_double(argv[0], &val1);
2865
2867
  if (!SWIG_IsOK(ecode1)) {
2866
- SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "double","Gosu::gosuToRadianScale", 1, argv[0] ));
2868
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "double","Gosu::degreesToRadians", 1, argv[0] ));
2867
2869
  }
2868
2870
  arg1 = static_cast< double >(val1);
2869
2871
  {
2870
2872
  try {
2871
- result = (double)Gosu::gosuToRadianScale(arg1);
2873
+ result = (double)Gosu::degreesToRadians(arg1);
2872
2874
  } catch(const std::runtime_error& e) {
2873
2875
  SWIG_exception(SWIG_RuntimeError, e.what());
2874
2876
  }
@@ -2881,7 +2883,7 @@ fail:
2881
2883
 
2882
2884
 
2883
2885
  SWIGINTERN VALUE
2884
- _wrap_radians_scale_to_gosu(int argc, VALUE *argv, VALUE self) {
2886
+ _wrap_radians_to_degrees(int argc, VALUE *argv, VALUE self) {
2885
2887
  double arg1 ;
2886
2888
  double val1 ;
2887
2889
  int ecode1 = 0 ;
@@ -2893,12 +2895,12 @@ _wrap_radians_scale_to_gosu(int argc, VALUE *argv, VALUE self) {
2893
2895
  }
2894
2896
  ecode1 = SWIG_AsVal_double(argv[0], &val1);
2895
2897
  if (!SWIG_IsOK(ecode1)) {
2896
- SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "double","Gosu::radiansScaleToGosu", 1, argv[0] ));
2898
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "double","Gosu::radiansToDegrees", 1, argv[0] ));
2897
2899
  }
2898
2900
  arg1 = static_cast< double >(val1);
2899
2901
  {
2900
2902
  try {
2901
- result = (double)Gosu::radiansScaleToGosu(arg1);
2903
+ result = (double)Gosu::radiansToDegrees(arg1);
2902
2904
  } catch(const std::runtime_error& e) {
2903
2905
  SWIG_exception(SWIG_RuntimeError, e.what());
2904
2906
  }
@@ -3240,6 +3242,24 @@ fail:
3240
3242
  }
3241
3243
 
3242
3244
 
3245
+ SWIGINTERN VALUE
3246
+ _wrap_enable_undocumented_retrofication(int argc, VALUE *argv, VALUE self) {
3247
+ if ((argc < 0) || (argc > 0)) {
3248
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
3249
+ }
3250
+ {
3251
+ try {
3252
+ Gosu::enableUndocumentedRetrofication();
3253
+ } catch(const std::runtime_error& e) {
3254
+ SWIG_exception(SWIG_RuntimeError, e.what());
3255
+ }
3256
+ }
3257
+ return Qnil;
3258
+ fail:
3259
+ return Qnil;
3260
+ }
3261
+
3262
+
3243
3263
  SWIGINTERN VALUE
3244
3264
  _wrap___max_texture_size(int argc, VALUE *argv, VALUE self) {
3245
3265
  unsigned int result;
@@ -4677,6 +4697,8 @@ _wrap_Font_draw(int argc, VALUE *argv, VALUE self) {
4677
4697
  arg9 = Gosu::amDefault;
4678
4698
  else if (!strcmp(StringValueCStr(localTemporary), "additive"))
4679
4699
  arg9 = Gosu::amAdditive;
4700
+ else if (!strcmp(StringValueCStr(localTemporary), "multiply"))
4701
+ arg9 = Gosu::amMultiply;
4680
4702
  else
4681
4703
  SWIG_exception_fail(SWIG_ValueError, "invalid alpha mode");
4682
4704
  }
@@ -4797,6 +4819,8 @@ _wrap_Font_draw_rel(int argc, VALUE *argv, VALUE self) {
4797
4819
  arg11 = Gosu::amDefault;
4798
4820
  else if (!strcmp(StringValueCStr(localTemporary), "additive"))
4799
4821
  arg11 = Gosu::amAdditive;
4822
+ else if (!strcmp(StringValueCStr(localTemporary), "multiply"))
4823
+ arg11 = Gosu::amMultiply;
4800
4824
  else
4801
4825
  SWIG_exception_fail(SWIG_ValueError, "invalid alpha mode");
4802
4826
  }
@@ -4909,6 +4933,8 @@ _wrap_Font_draw_rot(int argc, VALUE *argv, VALUE self) {
4909
4933
  arg10 = Gosu::amDefault;
4910
4934
  else if (!strcmp(StringValueCStr(localTemporary), "additive"))
4911
4935
  arg10 = Gosu::amAdditive;
4936
+ else if (!strcmp(StringValueCStr(localTemporary), "multiply"))
4937
+ arg10 = Gosu::amMultiply;
4912
4938
  else
4913
4939
  SWIG_exception_fail(SWIG_ValueError, "invalid alpha mode");
4914
4940
  }
@@ -5453,6 +5479,8 @@ _wrap_Image_draw(int argc, VALUE *argv, VALUE self) {
5453
5479
  arg8 = Gosu::amDefault;
5454
5480
  else if (!strcmp(StringValueCStr(localTemporary), "additive"))
5455
5481
  arg8 = Gosu::amAdditive;
5482
+ else if (!strcmp(StringValueCStr(localTemporary), "multiply"))
5483
+ arg8 = Gosu::amMultiply;
5456
5484
  else
5457
5485
  SWIG_exception_fail(SWIG_ValueError, "invalid alpha mode");
5458
5486
  }
@@ -5580,6 +5608,8 @@ _wrap_Image_draw_mod(int argc, VALUE *argv, VALUE self) {
5580
5608
  arg11 = Gosu::amDefault;
5581
5609
  else if (!strcmp(StringValueCStr(localTemporary), "additive"))
5582
5610
  arg11 = Gosu::amAdditive;
5611
+ else if (!strcmp(StringValueCStr(localTemporary), "multiply"))
5612
+ arg11 = Gosu::amMultiply;
5583
5613
  else
5584
5614
  SWIG_exception_fail(SWIG_ValueError, "invalid alpha mode");
5585
5615
  }
@@ -5705,6 +5735,8 @@ _wrap_Image_draw_rot(int argc, VALUE *argv, VALUE self) {
5705
5735
  arg11 = Gosu::amDefault;
5706
5736
  else if (!strcmp(StringValueCStr(localTemporary), "additive"))
5707
5737
  arg11 = Gosu::amAdditive;
5738
+ else if (!strcmp(StringValueCStr(localTemporary), "multiply"))
5739
+ arg11 = Gosu::amMultiply;
5708
5740
  else
5709
5741
  SWIG_exception_fail(SWIG_ValueError, "invalid alpha mode");
5710
5742
  }
@@ -6086,6 +6118,8 @@ _wrap_Image_draw_as_quad(int argc, VALUE *argv, VALUE self) {
6086
6118
  arg15 = Gosu::amDefault;
6087
6119
  else if (!strcmp(StringValueCStr(localTemporary), "additive"))
6088
6120
  arg15 = Gosu::amAdditive;
6121
+ else if (!strcmp(StringValueCStr(localTemporary), "multiply"))
6122
+ arg15 = Gosu::amMultiply;
6089
6123
  else
6090
6124
  SWIG_exception_fail(SWIG_ValueError, "invalid alpha mode");
6091
6125
  }
@@ -8045,6 +8079,8 @@ _wrap_Window_draw_line(int argc, VALUE *argv, VALUE self) {
8045
8079
  arg9 = Gosu::amDefault;
8046
8080
  else if (!strcmp(StringValueCStr(localTemporary), "additive"))
8047
8081
  arg9 = Gosu::amAdditive;
8082
+ else if (!strcmp(StringValueCStr(localTemporary), "multiply"))
8083
+ arg9 = Gosu::amMultiply;
8048
8084
  else
8049
8085
  SWIG_exception_fail(SWIG_ValueError, "invalid alpha mode");
8050
8086
  }
@@ -8178,6 +8214,8 @@ _wrap_Window_draw_triangle(int argc, VALUE *argv, VALUE self) {
8178
8214
  arg12 = Gosu::amDefault;
8179
8215
  else if (!strcmp(StringValueCStr(localTemporary), "additive"))
8180
8216
  arg12 = Gosu::amAdditive;
8217
+ else if (!strcmp(StringValueCStr(localTemporary), "multiply"))
8218
+ arg12 = Gosu::amMultiply;
8181
8219
  else
8182
8220
  SWIG_exception_fail(SWIG_ValueError, "invalid alpha mode");
8183
8221
  }
@@ -8339,6 +8377,8 @@ _wrap_Window_draw_quad(int argc, VALUE *argv, VALUE self) {
8339
8377
  arg15 = Gosu::amDefault;
8340
8378
  else if (!strcmp(StringValueCStr(localTemporary), "additive"))
8341
8379
  arg15 = Gosu::amAdditive;
8380
+ else if (!strcmp(StringValueCStr(localTemporary), "multiply"))
8381
+ arg15 = Gosu::amMultiply;
8342
8382
  else
8343
8383
  SWIG_exception_fail(SWIG_ValueError, "invalid alpha mode");
8344
8384
  }
@@ -9235,12 +9275,12 @@ SWIGEXPORT void Init_gosu(void) {
9235
9275
  SWIG_RubyInitializeTrackings();
9236
9276
  rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(0)));
9237
9277
  rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(7)));
9238
- rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(18)));
9239
- rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.7.18"));
9278
+ rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(19)));
9279
+ rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.7.19"));
9240
9280
  rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
9241
9281
  rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
9242
- rb_define_module_function(mGosu, "gosu_to_radian_scale", VALUEFUNC(_wrap_gosu_to_radian_scale), -1);
9243
- rb_define_module_function(mGosu, "radians_scale_to_gosu", VALUEFUNC(_wrap_radians_scale_to_gosu), -1);
9282
+ rb_define_module_function(mGosu, "degrees_to_radians", VALUEFUNC(_wrap_degrees_to_radians), -1);
9283
+ rb_define_module_function(mGosu, "radians_to_degrees", VALUEFUNC(_wrap_radians_to_degrees), -1);
9244
9284
  rb_define_module_function(mGosu, "offset_x", VALUEFUNC(_wrap_offset_x), -1);
9245
9285
  rb_define_module_function(mGosu, "offset_y", VALUEFUNC(_wrap_offset_y), -1);
9246
9286
  rb_define_module_function(mGosu, "angle", VALUEFUNC(_wrap_angle), -1);
@@ -9250,6 +9290,7 @@ SWIGEXPORT void Init_gosu(void) {
9250
9290
  rb_define_module_function(mGosu, "default_font_name", VALUEFUNC(_wrap_default_font_name), -1);
9251
9291
  rb_define_module_function(mGosu, "screen_width", VALUEFUNC(_wrap_screen_width), -1);
9252
9292
  rb_define_module_function(mGosu, "screen_height", VALUEFUNC(_wrap_screen_height), -1);
9293
+ rb_define_module_function(mGosu, "enable_undocumented_retrofication", VALUEFUNC(_wrap_enable_undocumented_retrofication), -1);
9253
9294
  rb_define_module_function(mGosu, "__max_texture_size", VALUEFUNC(_wrap___max_texture_size), -1);
9254
9295
 
9255
9296
  SwigClassColor.klass = rb_define_class_under(mGosu, "Color", rb_cObject);
@@ -9512,17 +9553,6 @@ SWIGEXPORT void Init_gosu(void) {
9512
9553
  rb_define_const(mGosu, "NumButtons", SWIG_From_int(static_cast< int >(Gosu::numButtons)));
9513
9554
  rb_define_const(mGosu, "NoButton", SWIG_From_int(static_cast< int >(Gosu::noButton)));
9514
9555
 
9515
- // ARGH, SWIG workaround...
9516
- // It doesn't understand the C++ overloading otherwise.
9517
- rb_eval_string("class Gosu::Image; def self.from_text(*args); args.size == 4 ? from_text4(*args) : from_text7(*args); end; end");
9518
-
9519
- // ARGH, SWIG workaround 2..
9520
- // It won't let me have a class method and method with the same name.
9521
- rb_eval_string("class Gosu::Window; def button_id_to_char(id); self.class.button_id_to_char(id); end; def char_to_button_id(ch); self.class.char_to_button_id(ch); end; end");
9522
-
9523
- // ARGH, Linux workaround: instead of declaring a constant, we declare a hidden function and call it when we need to define the constant.
9524
- rb_eval_string("module Gosu;def self.const_missing sym;if sym == :MAX_TEXTURE_SIZE then;const_set sym, __max_texture_size;else;super;end;end;end");
9525
-
9526
9556
  GosusDarkSide::oncePerTick = GosusDarkSide::yieldToOtherRubyThreads;
9527
9557
 
9528
9558
  rb_define_module_function(mGosu, "disown_TextInput", VALUEFUNC(_wrap_disown_TextInput), -1);