gosu 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29ea42b991f0cdb7184583f5a435defec4f07942
4
- data.tar.gz: 44b69037fa96ae7d5cacc38d5c1919b23a87461c
3
+ metadata.gz: 7aedd1fe70ab438f78ea2412e96323a9713f5d58
4
+ data.tar.gz: 34533d20906d49c8b6928be119c43494d4253146
5
5
  SHA512:
6
- metadata.gz: 3bf4f2486302c435a0b46a420649db290ffb951133a5bbed48e98e0cd9d58738250cf549fc397a632de224e837bc7b58640367db69703c93262780b61539eab2
7
- data.tar.gz: 0f0b3b81cb18107cf9253a1757237cbfdd46897bc55bcd108453c748689b36a0bcbe482a2eef5f20d1fa4b3149349433d5851421c18c9e04fa0cdd812d8802c7
6
+ metadata.gz: 4bd7363b574bfa87aa0a777f90badb769f2c7391a6d9cee1dfd8edbefe706b3e9c4737b81aa189a30a56430e1216da4fa449f57f41ec8a1f9cd0676e5217f44f
7
+ data.tar.gz: b7e43cb2de077d7f8ce07556f8eb1e14b523ca7a599bb0342c62fdf76913c097b7342ec141d87ef56b63f6af4d60d1dc49282cf78449083af26c16e6b72c07ad
@@ -3,8 +3,8 @@
3
3
 
4
4
  #define GOSU_MAJOR_VERSION 0
5
5
  #define GOSU_MINOR_VERSION 10
6
- #define GOSU_POINT_VERSION 0
7
- #define GOSU_VERSION "0.10.0"
6
+ #define GOSU_POINT_VERSION 1
7
+ #define GOSU_VERSION "0.10.1"
8
8
 
9
9
  #define GOSU_COPYRIGHT_NOTICE \
10
10
  "This software uses the following third-party libraries:\n" \
@@ -8,10 +8,6 @@
8
8
  * interface file instead.
9
9
  * ----------------------------------------------------------------------------- */
10
10
 
11
- // This file was afterwards patched using the following instructions:
12
- // http://sourceforge.net/tracker/index.php?func=detail&aid=2034216&group_id=1645&atid=101645
13
- // (Many thanks to Kevin Burge for that.)
14
-
15
11
  #define SWIGRUBY
16
12
  #define SWIG_DIRECTORS
17
13
 
@@ -874,7 +870,6 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
874
870
 
875
871
 
876
872
  #include <ruby.h>
877
- #include <map>
878
873
 
879
874
  /* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which
880
875
  * breaks using rb_intern as an lvalue, as SWIG does. We work around this
@@ -1215,7 +1210,7 @@ extern "C" {
1215
1210
  /* Global Ruby hash table to store Trackings from C/C++
1216
1211
  structs to Ruby Objects.
1217
1212
  */
1218
- static std::map<void*, VALUE> swig_ruby_trackings;
1213
+ static VALUE swig_ruby_trackings = Qnil;
1219
1214
 
1220
1215
  /* Global variable that stores a reference to the ruby
1221
1216
  hash table delete function. */
@@ -1232,18 +1227,34 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
1232
1227
  This is done to allow multiple DSOs to share the same
1233
1228
  tracking table.
1234
1229
  */
1230
+ ID trackings_id = rb_intern( "@__trackings__" );
1235
1231
  VALUE verbose = rb_gv_get("VERBOSE");
1236
1232
  rb_gv_set("VERBOSE", Qfalse);
1233
+ swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id );
1237
1234
  rb_gv_set("VERBOSE", verbose);
1238
1235
 
1239
1236
  /* No, it hasn't. Create one ourselves */
1240
- swig_ruby_trackings.clear();
1237
+ if ( swig_ruby_trackings == Qnil )
1238
+ {
1239
+ swig_ruby_trackings = rb_hash_new();
1240
+ rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings );
1241
+ }
1241
1242
 
1242
1243
  /* Now store a reference to the hash table delete function
1243
1244
  so that we only have to look it up once.*/
1244
1245
  swig_ruby_hash_delete = rb_intern("delete");
1245
1246
  }
1246
1247
 
1248
+ /* Get a Ruby number to reference a pointer */
1249
+ SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) {
1250
+ /* We cast the pointer to an unsigned long
1251
+ and then store a reference to it using
1252
+ a Ruby number object. */
1253
+
1254
+ /* Convert the pointer to a Ruby number */
1255
+ return SWIG2NUM(ptr);
1256
+ }
1257
+
1247
1258
  /* Get a Ruby number to reference an object */
1248
1259
  SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) {
1249
1260
  /* We cast the object to an unsigned long
@@ -1265,16 +1276,39 @@ SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) {
1265
1276
 
1266
1277
  /* Add a Tracking from a C/C++ struct to a Ruby object */
1267
1278
  SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) {
1279
+ /* In a Ruby hash table we store the pointer and
1280
+ the associated Ruby object. The trick here is
1281
+ that we cannot store the Ruby object directly - if
1282
+ we do then it cannot be garbage collected. So
1283
+ instead we typecast it as a unsigned long and
1284
+ convert it to a Ruby number object.*/
1285
+
1286
+ /* Get a reference to the pointer as a Ruby number */
1287
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1288
+
1289
+ /* Get a reference to the Ruby object as a Ruby number */
1290
+ VALUE value = SWIG_RubyObjectToReference(object);
1291
+
1268
1292
  /* Store the mapping to the global hash table. */
1269
- swig_ruby_trackings[ptr] = object;
1293
+ rb_hash_aset(swig_ruby_trackings, key, value);
1270
1294
  }
1271
1295
 
1272
1296
  /* Get the Ruby object that owns the specified C/C++ struct */
1273
1297
  SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
1274
- if (swig_ruby_trackings.count(ptr) == 0)
1298
+ /* Get a reference to the pointer as a Ruby number */
1299
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1300
+
1301
+ /* Now lookup the value stored in the global hash table */
1302
+ VALUE value = rb_hash_aref(swig_ruby_trackings, key);
1303
+
1304
+ if (value == Qnil) {
1305
+ /* No object exists - return nil. */
1275
1306
  return Qnil;
1276
- else
1277
- return swig_ruby_trackings[ptr];
1307
+ }
1308
+ else {
1309
+ /* Convert this value to Ruby object */
1310
+ return SWIG_RubyReferenceToObject(value);
1311
+ }
1278
1312
  }
1279
1313
 
1280
1314
  /* Remove a Tracking from a C/C++ struct to a Ruby object. It
@@ -1282,7 +1316,12 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
1282
1316
  since the same memory address may be reused later to create
1283
1317
  a new object. */
1284
1318
  SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) {
1285
- swig_ruby_trackings.erase(ptr);
1319
+ /* Get a reference to the pointer as a Ruby number */
1320
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1321
+
1322
+ /* Delete the object from the hash table by calling Ruby's
1323
+ do this we need to call the Hash.delete method.*/
1324
+ rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key);
1286
1325
  }
1287
1326
 
1288
1327
  /* This is a helper method that unlinks a Ruby object from its
@@ -2856,6 +2895,7 @@ SWIGINTERN Gosu::Image *Gosu_Image_fromText(std::wstring const &text,unsigned in
2856
2895
  unsigned width = 0xfefefefe;
2857
2896
  unsigned spacing = 0;
2858
2897
  Gosu::TextAlign align = Gosu::taLeft;
2898
+ unsigned flags = 0;
2859
2899
 
2860
2900
  if (options) {
2861
2901
  Check_Type(options, T_HASH);
@@ -2892,6 +2932,10 @@ SWIGINTERN Gosu::Image *Gosu_Image_fromText(std::wstring const &text,unsigned in
2892
2932
  else if (!strcmp(keyString, "spacing")) {
2893
2933
  spacing = NUM2INT(value);
2894
2934
  }
2935
+ else if (!strcmp(keyString, "retro")) {
2936
+ if (RTEST(value))
2937
+ flags |= Gosu::ifRetro;
2938
+ }
2895
2939
  else {
2896
2940
  static bool issuedWarning = false;
2897
2941
  if (!issuedWarning) {
@@ -2903,9 +2947,9 @@ SWIGINTERN Gosu::Image *Gosu_Image_fromText(std::wstring const &text,unsigned in
2903
2947
  }
2904
2948
 
2905
2949
  if (width == 0xfefefefe)
2906
- return new Gosu::Image(Gosu::createText(text, font, fontHeight));
2950
+ return new Gosu::Image(Gosu::createText(text, font, fontHeight), flags);
2907
2951
  else
2908
- return new Gosu::Image(Gosu::createText(text, font, fontHeight, spacing, width, align));
2952
+ return new Gosu::Image(Gosu::createText(text, font, fontHeight, spacing, width, align), flags);
2909
2953
  }
2910
2954
  SWIGINTERN std::vector< Gosu::Image > Gosu_Image_loadTiles__SWIG_0(VALUE source,int tileWidth,int tileHeight,VALUE options=0){
2911
2955
  Gosu::Bitmap bmp;
@@ -2928,6 +2972,10 @@ SWIGINTERN std::vector< Gosu::Image > Gosu_Image_loadTiles__SWIG_0(VALUE source,
2928
2972
  if (RTEST(value))
2929
2973
  flags |= Gosu::ifTileable;
2930
2974
  }
2975
+ else if (!strcmp(keyString, "retro")) {
2976
+ if (RTEST(value))
2977
+ flags |= Gosu::ifRetro;
2978
+ }
2931
2979
  else {
2932
2980
  static bool issuedWarning = false;
2933
2981
  if (!issuedWarning) {
@@ -3063,14 +3111,14 @@ SwigDirector_Window::~SwigDirector_Window() {
3063
3111
  void SwigDirector_Window::update() {
3064
3112
  VALUE result;
3065
3113
 
3066
- result = rb_funcall(swig_get_self(), rb_intern("protected_update"), 0, NULL);
3114
+ result = rb_funcall(swig_get_self(), rb_intern("update"), 0, NULL);
3067
3115
  }
3068
3116
 
3069
3117
 
3070
3118
  void SwigDirector_Window::draw() {
3071
3119
  VALUE result;
3072
3120
 
3073
- result = rb_funcall(swig_get_self(), rb_intern("protected_draw_2"), 0, NULL);
3121
+ result = rb_funcall(swig_get_self(), rb_intern("draw"), 0, NULL);
3074
3122
  }
3075
3123
 
3076
3124
 
@@ -3078,7 +3126,7 @@ bool SwigDirector_Window::needsRedraw() const {
3078
3126
  bool c_result ;
3079
3127
  VALUE result;
3080
3128
 
3081
- result = rb_funcall(swig_get_self(), rb_intern("protected_needs_redraw?"), 0, NULL);
3129
+ result = rb_funcall(swig_get_self(), rb_intern("needs_redraw?"), 0, NULL);
3082
3130
  bool swig_val;
3083
3131
  int swig_res = SWIG_AsVal_bool(result, &swig_val);
3084
3132
  if (!SWIG_IsOK(swig_res)) {
@@ -3093,7 +3141,7 @@ bool SwigDirector_Window::needsCursor() const {
3093
3141
  bool c_result ;
3094
3142
  VALUE result;
3095
3143
 
3096
- result = rb_funcall(swig_get_self(), rb_intern("protected_needs_cursor?"), 0, NULL);
3144
+ result = rb_funcall(swig_get_self(), rb_intern("needs_cursor?"), 0, NULL);
3097
3145
  bool swig_val;
3098
3146
  int swig_res = SWIG_AsVal_bool(result, &swig_val);
3099
3147
  if (!SWIG_IsOK(swig_res)) {
@@ -3107,7 +3155,7 @@ bool SwigDirector_Window::needsCursor() const {
3107
3155
  void SwigDirector_Window::loseFocus() {
3108
3156
  VALUE result;
3109
3157
 
3110
- result = rb_funcall(swig_get_self(), rb_intern("protected_lose_focus"), 0, NULL);
3158
+ result = rb_funcall(swig_get_self(), rb_intern("lose_focus"), 0, NULL);
3111
3159
  }
3112
3160
 
3113
3161
 
@@ -3128,7 +3176,7 @@ void SwigDirector_Window::buttonDown(Gosu::Button arg0) {
3128
3176
  else
3129
3177
  obj0 = LONG2NUM((&arg0)->id());
3130
3178
  }
3131
- result = rb_funcall(swig_get_self(), rb_intern("protected_button_down"), 1,obj0);
3179
+ result = rb_funcall(swig_get_self(), rb_intern("button_down"), 1,obj0);
3132
3180
  }
3133
3181
 
3134
3182
 
@@ -3142,7 +3190,7 @@ void SwigDirector_Window::buttonUp(Gosu::Button arg0) {
3142
3190
  else
3143
3191
  obj0 = LONG2NUM((&arg0)->id());
3144
3192
  }
3145
- result = rb_funcall(swig_get_self(), rb_intern("protected_button_up"), 1,obj0);
3193
+ result = rb_funcall(swig_get_self(), rb_intern("button_up"), 1,obj0);
3146
3194
  }
3147
3195
 
3148
3196
 
@@ -1,19 +1,19 @@
1
- require 'rbconfig'
2
-
3
- if RUBY_PLATFORM =~ /mswin$|mingw32|mingw64|win32\-|\-win32/ then
4
- binary_path = File.dirname(__FILE__)
5
- # 64-bit builds of Windows use "x64-mingw32" as RUBY_PLATFORM
6
- binary_path += '64' if RUBY_PLATFORM =~ /^x64-/
7
-
8
- # Add this gem to the PATH on Windows so that bundled DLLs can be found.
9
- ENV['PATH'] = "#{binary_path};#{ENV['PATH']}"
10
-
11
- # Add the correct directory
12
- RUBY_VERSION =~ /(\d+.\d+)/
13
- $LOAD_PATH.unshift "#{binary_path}/#{$1}"
14
- end
15
-
16
- require "gosu.#{RbConfig::CONFIG['DLEXT']}"
17
-
18
- require "gosu/swig_patches"
19
- require "gosu/patches"
1
+ require 'rbconfig'
2
+
3
+ if RUBY_PLATFORM =~ /mswin$|mingw32|mingw64|win32\-|\-win32/ then
4
+ binary_path = File.dirname(__FILE__)
5
+ # 64-bit builds of Windows use "x64-mingw32" as RUBY_PLATFORM
6
+ binary_path += '64' if RUBY_PLATFORM =~ /^x64-/
7
+
8
+ # Add this gem to the PATH on Windows so that bundled DLLs can be found.
9
+ ENV['PATH'] = "#{binary_path};#{ENV['PATH']}"
10
+
11
+ # Add the correct directory
12
+ RUBY_VERSION =~ /(\d+.\d+)/
13
+ $LOAD_PATH.unshift "#{binary_path}/#{$1}"
14
+ end
15
+
16
+ require "gosu.#{RbConfig::CONFIG['DLEXT']}"
17
+
18
+ require "gosu/swig_patches"
19
+ require "gosu/patches"
@@ -1,117 +1,117 @@
1
- # Extend Numeric with simple angle conversion methods,
2
- # for easier integration with Chipmunk.
3
- class ::Numeric
4
- def degrees_to_radians
5
- self * Math::PI / 180.0
6
- end
7
-
8
- def radians_to_degrees
9
- self * 180.0 / Math::PI
10
- end
11
-
12
- def gosu_to_radians
13
- (self - 90) * Math::PI / 180.0
14
- end
15
-
16
- def radians_to_gosu
17
- self * 180.0 / Math::PI + 90
18
- end
19
- end
20
-
21
- # Backwards compatibility:
22
- # Import constants into Gosu::Button.
23
- module Gosu::Button
24
- Gosu.constants.each { |c| const_set(c, Gosu.const_get(c)) }
25
- end
26
-
27
- # Backwards compatibility:
28
- # The old version of from_text has been deprecated in Gosu 0.9.
29
- class Gosu::Image
30
- class << self
31
- alias from_text_without_window from_text
32
- end
33
-
34
- def self.from_text(*args)
35
- if args.size == 4
36
- from_text_without_window(args[1], args[3], :font => args[2])
37
- elsif args.size == 7
38
- from_text_without_window(args[1], args[3], :font => args[2],
39
- :spacing => args[4], :width => args[5], :align => args[6])
40
- else
41
- from_text_without_window(*args)
42
- end
43
- end
44
- end
45
-
46
- # Backwards compatibility:
47
- # Passing a Window Sample#initialize has been deprecated in Gosu 0.7.17.
48
- class Gosu::Sample
49
- alias initialize_without_window initialize
50
-
51
- def initialize(*args)
52
- args.shift if args.first.is_a? Gosu::Window
53
- initialize_without_window(*args)
54
- end
55
- end
56
-
57
- # Backwards compatibility:
58
- # Passing a Window to Song#initialize has been deprecated in Gosu 0.7.17.
59
- class Gosu::Song
60
- alias initialize_without_window initialize
61
-
62
- def initialize(*args)
63
- args.shift if args.first.is_a? Gosu::Window
64
- initialize_without_window(*args)
65
- end
66
- end
67
-
68
- # Color constants.
69
- # This is cleaner than having SWIG define them.
70
- module Gosu
71
- class ImmutableColor < Color
72
- private :alpha=, :red=, :green=, :blue=, :hue=, :saturation=, :value=
73
- end
74
-
75
- class Color
76
- NONE = Gosu::ImmutableColor.new(0x00_000000)
77
- BLACK = Gosu::ImmutableColor.new(0xff_000000)
78
- GRAY = Gosu::ImmutableColor.new(0xff_808080)
79
- WHITE = Gosu::ImmutableColor.new(0xff_ffffff)
80
- AQUA = Gosu::ImmutableColor.new(0xff_00ffff)
81
- RED = Gosu::ImmutableColor.new(0xff_ff0000)
82
- GREEN = Gosu::ImmutableColor.new(0xff_00ff00)
83
- BLUE = Gosu::ImmutableColor.new(0xff_0000ff)
84
- YELLOW = Gosu::ImmutableColor.new(0xff_ffff00)
85
- FUCHSIA = Gosu::ImmutableColor.new(0xff_ff00ff)
86
- CYAN = Gosu::ImmutableColor.new(0xff_00ffff)
87
- end
88
- end
89
-
90
- class Gosu::Window
91
- # Backwards compatibility:
92
- # Class methods that have been turned into module methods.
93
- def self.button_id_to_char(id)
94
- Gosu.button_id_to_char(id)
95
- end
96
-
97
- def self.char_to_button_id(ch)
98
- Gosu.char_to_button_id(ch)
99
- end
100
-
101
- # Backwards compatibility:
102
- # Instance methods taht have been turned into module methods.
103
- %w(draw_line draw_triangle draw_quad
104
- flush gl clip_to record
105
- transform translate rotate scale
106
- button_id_to_char char_to_button_id button_down?).each do |method|
107
- define_method method.to_sym do |*args, &block|
108
- Gosu.send method, *args, &block
109
- end
110
- end
111
- end
112
-
113
- # Release OpenAL resources during Ruby's shutdown, not Gosu's.
114
- at_exit do
115
- Gosu::Song.current_song.stop if Gosu::Song.current_song
116
- Gosu::_release_all_openal_resources
117
- end
1
+ # Extend Numeric with simple angle conversion methods,
2
+ # for easier integration with Chipmunk.
3
+ class ::Numeric
4
+ def degrees_to_radians
5
+ self * Math::PI / 180.0
6
+ end
7
+
8
+ def radians_to_degrees
9
+ self * 180.0 / Math::PI
10
+ end
11
+
12
+ def gosu_to_radians
13
+ (self - 90) * Math::PI / 180.0
14
+ end
15
+
16
+ def radians_to_gosu
17
+ self * 180.0 / Math::PI + 90
18
+ end
19
+ end
20
+
21
+ # Backwards compatibility:
22
+ # Import constants into Gosu::Button.
23
+ module Gosu::Button
24
+ Gosu.constants.each { |c| const_set(c, Gosu.const_get(c)) }
25
+ end
26
+
27
+ # Backwards compatibility:
28
+ # The old version of from_text has been deprecated in Gosu 0.9.
29
+ class Gosu::Image
30
+ class << self
31
+ alias from_text_without_window from_text
32
+ end
33
+
34
+ def self.from_text(*args)
35
+ if args.size == 4
36
+ from_text_without_window(args[1], args[3], :font => args[2])
37
+ elsif args.size == 7
38
+ from_text_without_window(args[1], args[3], :font => args[2],
39
+ :spacing => args[4], :width => args[5], :align => args[6])
40
+ else
41
+ from_text_without_window(*args)
42
+ end
43
+ end
44
+ end
45
+
46
+ # Backwards compatibility:
47
+ # Passing a Window Sample#initialize has been deprecated in Gosu 0.7.17.
48
+ class Gosu::Sample
49
+ alias initialize_without_window initialize
50
+
51
+ def initialize(*args)
52
+ args.shift if args.first.is_a? Gosu::Window
53
+ initialize_without_window(*args)
54
+ end
55
+ end
56
+
57
+ # Backwards compatibility:
58
+ # Passing a Window to Song#initialize has been deprecated in Gosu 0.7.17.
59
+ class Gosu::Song
60
+ alias initialize_without_window initialize
61
+
62
+ def initialize(*args)
63
+ args.shift if args.first.is_a? Gosu::Window
64
+ initialize_without_window(*args)
65
+ end
66
+ end
67
+
68
+ # Color constants.
69
+ # This is cleaner than having SWIG define them.
70
+ module Gosu
71
+ class ImmutableColor < Color
72
+ private :alpha=, :red=, :green=, :blue=, :hue=, :saturation=, :value=
73
+ end
74
+
75
+ class Color
76
+ NONE = Gosu::ImmutableColor.new(0x00_000000)
77
+ BLACK = Gosu::ImmutableColor.new(0xff_000000)
78
+ GRAY = Gosu::ImmutableColor.new(0xff_808080)
79
+ WHITE = Gosu::ImmutableColor.new(0xff_ffffff)
80
+ AQUA = Gosu::ImmutableColor.new(0xff_00ffff)
81
+ RED = Gosu::ImmutableColor.new(0xff_ff0000)
82
+ GREEN = Gosu::ImmutableColor.new(0xff_00ff00)
83
+ BLUE = Gosu::ImmutableColor.new(0xff_0000ff)
84
+ YELLOW = Gosu::ImmutableColor.new(0xff_ffff00)
85
+ FUCHSIA = Gosu::ImmutableColor.new(0xff_ff00ff)
86
+ CYAN = Gosu::ImmutableColor.new(0xff_00ffff)
87
+ end
88
+ end
89
+
90
+ class Gosu::Window
91
+ # Backwards compatibility:
92
+ # Class methods that have been turned into module methods.
93
+ def self.button_id_to_char(id)
94
+ Gosu.button_id_to_char(id)
95
+ end
96
+
97
+ def self.char_to_button_id(ch)
98
+ Gosu.char_to_button_id(ch)
99
+ end
100
+
101
+ # Backwards compatibility:
102
+ # Instance methods taht have been turned into module methods.
103
+ %w(draw_line draw_triangle draw_quad
104
+ flush gl clip_to record
105
+ transform translate rotate scale
106
+ button_id_to_char char_to_button_id button_down?).each do |method|
107
+ define_method method.to_sym do |*args, &block|
108
+ Gosu.send method, *args, &block
109
+ end
110
+ end
111
+ end
112
+
113
+ # Release OpenAL resources during Ruby's shutdown, not Gosu's.
114
+ at_exit do
115
+ Gosu::Song.current_song.stop if Gosu::Song.current_song
116
+ Gosu::_release_all_openal_resources
117
+ end
@@ -1,10 +1,10 @@
1
- warn "gosu/preview.rb has been removed in Gosu 0.9.0, and Gosu itself \n" +
2
- "provides a similar interface to what preview.rb used to offer.\n" +
3
- "Notable differences:\n" +
4
- "• no global $window variable\n" +
5
- "• no global Gosu.mouse_x and Gosu.mouse_y functions\n" +
6
- "• Image#initialize et.al. use an options hash now\n" +
7
- "If you cannot update your code base right now, you should require \n" +
8
- "Gosu 0.8.x in your Gemfile: gem 'gosu', '~> 0.8.0'";
9
-
10
- require 'gosu'
1
+ warn "gosu/preview.rb has been removed in Gosu 0.9.0, and Gosu itself \n" +
2
+ "provides a similar interface to what preview.rb used to offer.\n" +
3
+ "Notable differences:\n" +
4
+ "• no global $window variable\n" +
5
+ "• no global Gosu.mouse_x and Gosu.mouse_y functions\n" +
6
+ "• Image#initialize et.al. use an options hash now\n" +
7
+ "If you cannot update your code base right now, you should require \n" +
8
+ "Gosu 0.8.x in your Gemfile: gem 'gosu', '~> 0.8.0'";
9
+
10
+ require 'gosu'
@@ -1,11 +1,11 @@
1
- # Replace the load path
2
- $LOAD_PATH.clear
3
- $LOAD_PATH << File.dirname(__FILE__)[0..-6]
4
- $LOAD_PATH << $LOAD_PATH[0] + '/lib'
5
- # Ruby portions of Gosu
6
- require 'gosu/patches'
7
- require 'gosu/swig_patches'
8
- # Let the application know it is being run from the Mac app wrapper.
9
- OSX_EXECUTABLE = true
10
- # Main application
11
- require 'Main'
1
+ # Replace the load path
2
+ $LOAD_PATH.clear
3
+ $LOAD_PATH << File.dirname(__FILE__)[0..-6]
4
+ $LOAD_PATH << $LOAD_PATH[0] + '/lib'
5
+ # Ruby portions of Gosu
6
+ require 'gosu/patches'
7
+ require 'gosu/swig_patches'
8
+ # Let the application know it is being run from the Mac app wrapper.
9
+ OSX_EXECUTABLE = true
10
+ # Main application
11
+ require 'Main'
@@ -1,70 +1,70 @@
1
- # SWIG workarounds
2
- # These are offloaded into a separate file because rb_eval_string() is weird on Ruby 1.8.
3
-
4
- # Exceptions in Window callbacks often get lost, this is especially annoying in draw/update.
5
- # It is not clear whether this is a SWIG issue or if some stack frame is not exception
6
- # compatible, but I just call protected_update etc. in the Ruby wrapper so I can add this
7
- # custom debugging help:
8
- class Gosu::Window
9
- alias initialize_without_hash initialize
10
-
11
- def initialize width, height, *args
12
- if args.empty? or args.first.is_a? Hash then
13
- options = args.first || {}
14
- fullscreen = options[:fullscreen]
15
- update_interval = options[:update_interval]
16
- else
17
- fullscreen, update_interval = *args
18
- end
19
- initialize_without_hash width, height, !!fullscreen, update_interval || 16.666666
20
- end
21
-
22
- %w(update draw needs_redraw? needs_cursor?
23
- lose_focus button_down button_up).each do |callback|
24
- define_method "protected_#{callback}" do |*args|
25
- begin
26
- # If there has been an exception, don't do anything as to not make matters worse.
27
- # Conveniently turn the return value into a boolean result (for needs_cursor? etc).
28
- defined?(@_exception) ? false : !!send(callback, *args)
29
- rescue Exception => e
30
- # Exit the message loop naturally, then re-throw
31
- @_exception = e
32
- close
33
- end
34
- end
35
- end
36
-
37
- def protected_draw_2
38
- protected_draw
39
- $gosu_gl_blocks_2 = $gosu_gl_blocks
40
- $gosu_gl_blocks = nil
41
- end
42
-
43
- alias show_internal show
44
- def show
45
- show_internal
46
- # Try to format the message nicely, without any useless patching that we are
47
- # doing here.
48
- if defined? @_exception then
49
- if @_exception.backtrace.is_a? Array and not @_exception.backtrace.frozen? then
50
- @_exception.backtrace.reject! { |line| line.include? 'lib/gosu/swig_patches.rb' }
51
- end
52
- raise @_exception
53
- end
54
- end
55
- end
56
-
57
- module Gosu
58
- # Keep a reference to these blocks that is only cleared after Window#draw.
59
- # Otherwise, the GC might free these blocks while Gosu is still rendering.
60
- def self.gl(*args, &block)
61
- $gosu_gl_blocks ||= []
62
- $gosu_gl_blocks << block
63
- unsafe_gl(*args, &block)
64
- end
65
- end
66
-
67
- # SWIG won't let me rename my method to '[]='.
68
- class Gosu::Font
69
- alias []= set_image
70
- end
1
+ # SWIG workarounds
2
+ # These are offloaded into a separate file because rb_eval_string() is weird on Ruby 1.8.
3
+
4
+ # Exceptions in Window callbacks often get lost, this is especially annoying in draw/update.
5
+ # It is not clear whether this is a SWIG issue or if some stack frame is not exception
6
+ # compatible, but I just call protected_update etc. in the Ruby wrapper so I can add this
7
+ # custom debugging help:
8
+ class Gosu::Window
9
+ alias initialize_without_hash initialize
10
+
11
+ def initialize width, height, *args
12
+ if args.empty? or args.first.is_a? Hash then
13
+ options = args.first || {}
14
+ fullscreen = options[:fullscreen]
15
+ update_interval = options[:update_interval]
16
+ else
17
+ fullscreen, update_interval = *args
18
+ end
19
+ initialize_without_hash width, height, !!fullscreen, update_interval || 16.666666
20
+ end
21
+
22
+ %w(update draw needs_redraw? needs_cursor?
23
+ lose_focus button_down button_up).each do |callback|
24
+ define_method "protected_#{callback}" do |*args|
25
+ begin
26
+ # If there has been an exception, don't do anything as to not make matters worse.
27
+ # Conveniently turn the return value into a boolean result (for needs_cursor? etc).
28
+ defined?(@_exception) ? false : !!send(callback, *args)
29
+ rescue Exception => e
30
+ # Exit the message loop naturally, then re-throw
31
+ @_exception = e
32
+ close
33
+ end
34
+ end
35
+ end
36
+
37
+ def protected_draw_2
38
+ protected_draw
39
+ $gosu_gl_blocks_2 = $gosu_gl_blocks
40
+ $gosu_gl_blocks = nil
41
+ end
42
+
43
+ alias show_internal show
44
+ def show
45
+ show_internal
46
+ # Try to format the message nicely, without any useless patching that we are
47
+ # doing here.
48
+ if defined? @_exception then
49
+ if @_exception.backtrace.is_a? Array and not @_exception.backtrace.frozen? then
50
+ @_exception.backtrace.reject! { |line| line.include? 'lib/gosu/swig_patches.rb' }
51
+ end
52
+ raise @_exception
53
+ end
54
+ end
55
+ end
56
+
57
+ module Gosu
58
+ # Keep a reference to these blocks that is only cleared after Window#draw.
59
+ # Otherwise, the GC might free these blocks while Gosu is still rendering.
60
+ def self.gl(*args, &block)
61
+ $gosu_gl_blocks ||= []
62
+ $gosu_gl_blocks << block
63
+ unsafe_gl(*args, &block)
64
+ end
65
+ end
66
+
67
+ # SWIG won't let me rename my method to '[]='.
68
+ class Gosu::Font
69
+ alias []= set_image
70
+ end
@@ -1,89 +1,89 @@
1
- require 'gosu/preview'
2
-
3
- module Gosu
4
- module Zen
5
-
6
- @@window_args = [800, 600, {}]
7
- @@options = {}
8
-
9
- def window width, height, options = nil
10
- if $window.nil?
11
- @@window_args[0] = width
12
- @@window_args[1] = height
13
- @@window_args[2].merge! options if options
14
- else
15
- raise "window size can only be set before the window is created"
16
- end
17
- end
18
-
19
- def set what, value
20
- if $window.nil?
21
- @@options[what.to_sym] = value
22
- else
23
- $window.send "#{what}=", value
24
- end
25
- end
26
-
27
- def init &body
28
- ZenWindow.send :define_method, :init, &body
29
- end
30
-
31
- def button_down id = nil, &body
32
- m = id ? "button_down_#{id}" : :button_down_other
33
- ZenWindow.send :define_method, m, &body
34
- end
35
-
36
- def button_up id = nil, &body
37
- m = id ? "button_up_#{id}" : :button_up_other
38
- ZenWindow.send :define_method, m, &body
39
- end
40
-
41
- def update &body
42
- ZenWindow.send :define_method, :update, &body
43
- end
44
-
45
- def draw &body
46
- ZenWindow.send :define_method, :draw, &body
47
- end
48
-
49
- def run!
50
- window = ZenWindow.new *@@window_args
51
- @@options.each do |opt, value|
52
- window.send "#{opt}=", value
53
- end
54
- window.show
55
- end
56
-
57
- def Zen.included mod
58
- at_exit { run! unless $! }
59
- end
60
-
61
- end
62
-
63
- class ZenWindow < Window
64
- def initialize *args
65
- super
66
- init
67
- end
68
-
69
- def init
70
- end
71
-
72
- def button_down id
73
- m = :"button_down_#{id}"
74
- respond_to?(m) ? send(m) : button_down_other(id)
75
- end
76
-
77
- def button_up id
78
- m = :"button_up_#{id}"
79
- respond_to?(m) ? send(m) : button_up_other(id)
80
- end
81
-
82
- def button_down_other id
83
- end
84
-
85
- def button_up_other id
86
- end
87
-
88
- end
89
- end
1
+ require 'gosu/preview'
2
+
3
+ module Gosu
4
+ module Zen
5
+
6
+ @@window_args = [800, 600, {}]
7
+ @@options = {}
8
+
9
+ def window width, height, options = nil
10
+ if $window.nil?
11
+ @@window_args[0] = width
12
+ @@window_args[1] = height
13
+ @@window_args[2].merge! options if options
14
+ else
15
+ raise "window size can only be set before the window is created"
16
+ end
17
+ end
18
+
19
+ def set what, value
20
+ if $window.nil?
21
+ @@options[what.to_sym] = value
22
+ else
23
+ $window.send "#{what}=", value
24
+ end
25
+ end
26
+
27
+ def init &body
28
+ ZenWindow.send :define_method, :init, &body
29
+ end
30
+
31
+ def button_down id = nil, &body
32
+ m = id ? "button_down_#{id}" : :button_down_other
33
+ ZenWindow.send :define_method, m, &body
34
+ end
35
+
36
+ def button_up id = nil, &body
37
+ m = id ? "button_up_#{id}" : :button_up_other
38
+ ZenWindow.send :define_method, m, &body
39
+ end
40
+
41
+ def update &body
42
+ ZenWindow.send :define_method, :update, &body
43
+ end
44
+
45
+ def draw &body
46
+ ZenWindow.send :define_method, :draw, &body
47
+ end
48
+
49
+ def run!
50
+ window = ZenWindow.new *@@window_args
51
+ @@options.each do |opt, value|
52
+ window.send "#{opt}=", value
53
+ end
54
+ window.show
55
+ end
56
+
57
+ def Zen.included mod
58
+ at_exit { run! unless $! }
59
+ end
60
+
61
+ end
62
+
63
+ class ZenWindow < Window
64
+ def initialize *args
65
+ super
66
+ init
67
+ end
68
+
69
+ def init
70
+ end
71
+
72
+ def button_down id
73
+ m = :"button_down_#{id}"
74
+ respond_to?(m) ? send(m) : button_down_other(id)
75
+ end
76
+
77
+ def button_up id
78
+ m = :"button_up_#{id}"
79
+ respond_to?(m) ? send(m) : button_up_other(id)
80
+ end
81
+
82
+ def button_down_other id
83
+ end
84
+
85
+ def button_up_other id
86
+ end
87
+
88
+ end
89
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Raschke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-20 00:00:00.000000000 Z
11
+ date: 2015-08-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  2D game development library.