rubygame 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS +23 -0
- data/Rakefile +31 -26
- data/ext/rubygame/rubygame_event.c +2 -2
- data/ext/rubygame/rubygame_gfx.c +2 -2
- data/ext/rubygame/rubygame_screen.c +3 -3
- data/ext/rubygame/rubygame_shared.c +3 -3
- data/ext/rubygame/rubygame_surface.c +2 -2
- data/lib/rubygame/event_handler.rb +9 -9
- data/lib/rubygame/event_triggers.rb +6 -6
- metadata +3 -3
data/NEWS
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
= NEWS
|
2
2
|
|
3
|
+
== Rubygame 2.4.1
|
4
|
+
|
5
|
+
Release focus: Bug fixes; Ruby 1.9 compatibility.
|
6
|
+
|
7
|
+
=== Fixes
|
8
|
+
|
9
|
+
- Fixed: Module scope problems with EventHandler and triggers.
|
10
|
+
They were trying to find the Events module, which only worked if
|
11
|
+
you had done 'include Rubygame' somewhere.
|
12
|
+
|
13
|
+
- Fixed: Compiler warning in unmake_symbol().
|
14
|
+
|
15
|
+
=== Other Stuff
|
16
|
+
|
17
|
+
- Rubygame is compatible with Ruby 1.9.
|
18
|
+
|
19
|
+
- Build system is compatible with Ruby 1.9.
|
20
|
+
|
21
|
+
- Minor cleanup to build system internals.
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
3
26
|
== Rubygame 2.4.0
|
4
27
|
|
5
28
|
Release focus: Events.
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
# The version number for Rubygame.
|
9
|
-
RUBYGAME_VERSION = [2,4,
|
9
|
+
RUBYGAME_VERSION = [2,4,1]
|
10
10
|
|
11
11
|
|
12
12
|
#
|
@@ -37,7 +37,6 @@ RUBYGAME_VERSION = [2,4,0]
|
|
37
37
|
|
38
38
|
|
39
39
|
require 'rubygems'
|
40
|
-
Gem::manage_gems
|
41
40
|
|
42
41
|
require 'rake'
|
43
42
|
require 'rake/gempackagetask'
|
@@ -51,10 +50,20 @@ require 'English'
|
|
51
50
|
class ShellCommandError < RuntimeError
|
52
51
|
end
|
53
52
|
|
54
|
-
# Execute the
|
55
|
-
#
|
56
|
-
|
57
|
-
|
53
|
+
# Execute the shell command and raise ShellCommandError if
|
54
|
+
# the command failed.
|
55
|
+
#
|
56
|
+
# If verbose is true, outputs the command string to the console.
|
57
|
+
# If it's false, it outputs the pretty string to the console instead.
|
58
|
+
#
|
59
|
+
def try_shell( command, pretty="", verbose=false )
|
60
|
+
if verbose
|
61
|
+
puts command
|
62
|
+
else
|
63
|
+
puts pretty unless pretty.empty?
|
64
|
+
end
|
65
|
+
|
66
|
+
result = `#{command}`
|
58
67
|
|
59
68
|
unless $CHILD_STATUS.exitstatus == 0
|
60
69
|
raise ShellCommandError, "Command failed. Aborting."
|
@@ -66,7 +75,7 @@ end
|
|
66
75
|
def try_sdl_config( flag )
|
67
76
|
begin
|
68
77
|
if $options[:"sdl-config"]
|
69
|
-
return try_shell
|
78
|
+
return try_shell("sdl-config #{flag}").chomp
|
70
79
|
else
|
71
80
|
return String.new
|
72
81
|
end
|
@@ -160,7 +169,7 @@ $options = {
|
|
160
169
|
# Default behavior for win32 is to skip sdl_config,
|
161
170
|
# since it's usually not available. It can still be
|
162
171
|
# enabled through the options, though.
|
163
|
-
if
|
172
|
+
if RUBY_PLATFORM =~ /win32/
|
164
173
|
$options[:"sdl-config"] = false
|
165
174
|
end
|
166
175
|
|
@@ -228,6 +237,10 @@ string_option :sitelibdir
|
|
228
237
|
CFLAGS = [from_env_or_config("CFLAGS"),
|
229
238
|
try_sdl_config("--cflags"),
|
230
239
|
"-I. -I#{CONFIG['topdir']}",
|
240
|
+
(if CONFIG['rubyhdrdir']
|
241
|
+
"-I#{CONFIG['rubyhdrdir']} " +\
|
242
|
+
"-I#{File.join(CONFIG['rubyhdrdir'], CONFIG['arch'])}"
|
243
|
+
end),
|
231
244
|
"-DRUBYGAME_MAJOR_VERSION=#{RUBYGAME_VERSION[0]}",
|
232
245
|
"-DRUBYGAME_MINOR_VERSION=#{RUBYGAME_VERSION[1]}",
|
233
246
|
"-DRUBYGAME_PATCHLEVEL=#{RUBYGAME_VERSION[2]}"
|
@@ -292,12 +305,9 @@ class ExtensionModule
|
|
292
305
|
link_command.gsub!("-arch ppc","")
|
293
306
|
end
|
294
307
|
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
puts "Linking compiled files to create #{File.basename(@directory)}/#{File.basename(dynlib_full)}"
|
299
|
-
try_shell { `#{link_command}` }
|
300
|
-
end
|
308
|
+
try_shell( link_command,
|
309
|
+
"Linking compiled files to create #{File.basename(@directory)}/#{File.basename(dynlib_full)}",
|
310
|
+
$options[:verbose] )
|
301
311
|
end
|
302
312
|
|
303
313
|
task :build => [dynlib_full] # Add this as a prereq of the build
|
@@ -326,12 +336,9 @@ class ExtensionModule
|
|
326
336
|
compile_command.gsub!("-arch ppc","")
|
327
337
|
end
|
328
338
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
puts "Compiling #{File.basename(@directory)}/#{File.basename(t.source)}"
|
333
|
-
try_shell { `#{compile_command}` }
|
334
|
-
end
|
339
|
+
try_shell( compile_command,
|
340
|
+
"Compiling #{File.basename(@directory)}/#{File.basename(t.source)}",
|
341
|
+
$options[:verbose] )
|
335
342
|
end
|
336
343
|
rescue
|
337
344
|
# Generate a .o rule for each .c file in the directory.
|
@@ -339,12 +346,10 @@ class ExtensionModule
|
|
339
346
|
object = source.sub(".c", ".#{OBJEXT}")
|
340
347
|
file object => ([source] + depends_headers( source )) do |t|
|
341
348
|
compile_command = "#{CONFIG['CC']} -c #{CFLAGS} #{"-g " if $options[:debug]} #{source} -o #{t.name}"
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
try_shell { `#{compile_command}` }
|
347
|
-
end
|
349
|
+
|
350
|
+
try_shell( compile_command,
|
351
|
+
"Compiling #{File.basename(@directory)}/#{File.basename(t.source)}",
|
352
|
+
$options[:verbose] )
|
348
353
|
end
|
349
354
|
end
|
350
355
|
end
|
@@ -325,7 +325,7 @@ int rg_get_keyrepeat_value( VALUE vvalue, int default_value, char *name )
|
|
325
325
|
else
|
326
326
|
{
|
327
327
|
rb_raise( rb_eArgError, "unsupported symbol '%s' for %s",
|
328
|
-
|
328
|
+
RSTRING_PTR(rb_inspect(vvalue)), name );
|
329
329
|
}
|
330
330
|
}
|
331
331
|
|
@@ -335,7 +335,7 @@ int rg_get_keyrepeat_value( VALUE vvalue, int default_value, char *name )
|
|
335
335
|
if( value < 1 )
|
336
336
|
{
|
337
337
|
rb_raise( rb_eArgError, "%s must be at least 0.001 seconds (got %s)",
|
338
|
-
name,
|
338
|
+
name, RSTRING_PTR(rb_inspect(vvalue)));
|
339
339
|
}
|
340
340
|
|
341
341
|
return value;
|
data/ext/rubygame/rubygame_gfx.c
CHANGED
@@ -62,7 +62,7 @@ VALUE rbgm_draw_fillpolygon(VALUE, VALUE, VALUE);
|
|
62
62
|
void extract_xy(VALUE point, Sint16* x, Sint16* y)
|
63
63
|
{
|
64
64
|
point = convert_to_array(point);
|
65
|
-
if(
|
65
|
+
if(RARRAY_LEN(point) < 2)
|
66
66
|
rb_raise(rb_eArgError,"expected argument as [x,y] form");
|
67
67
|
*x = NUM2INT(rb_ary_entry(point,0));
|
68
68
|
*y = NUM2INT(rb_ary_entry(point,1));
|
@@ -479,7 +479,7 @@ void draw_polygon(VALUE target, VALUE points, VALUE rgba, int aa, int fill)
|
|
479
479
|
|
480
480
|
/* separate points into arrays of x and y values */
|
481
481
|
points = convert_to_array(points);
|
482
|
-
length =
|
482
|
+
length = RARRAY_LEN(points);
|
483
483
|
x = alloca(sizeof (Sint16) * length);
|
484
484
|
y = alloca(sizeof (Sint16) * length);
|
485
485
|
|
@@ -247,10 +247,10 @@ VALUE rbgm_screen_update(int argc, VALUE *argv, VALUE self)
|
|
247
247
|
{
|
248
248
|
switch( TYPE(vx) ) {
|
249
249
|
case T_ARRAY: {
|
250
|
-
if(
|
250
|
+
if( RARRAY_LEN(vx) < 4 )
|
251
251
|
{
|
252
252
|
rb_raise(rb_eArgError,"Array is too short to be a Rect (%s for 4)",
|
253
|
-
|
253
|
+
RARRAY_LEN(vx));
|
254
254
|
}
|
255
255
|
x = NUM2INT(rb_ary_entry(vx,0));
|
256
256
|
y = NUM2INT(rb_ary_entry(vx,1));
|
@@ -311,7 +311,7 @@ VALUE rbgm_screen_updaterects(VALUE self, VALUE array_rects)
|
|
311
311
|
|
312
312
|
/* prepare an (uninitialized) array of Rects */
|
313
313
|
array_rects = convert_to_array(array_rects);
|
314
|
-
num_rects =
|
314
|
+
num_rects = RARRAY_LEN(array_rects);
|
315
315
|
rects = ALLOCA_N(SDL_Rect, num_rects);
|
316
316
|
|
317
317
|
/* initialize the array of Rects from array_rects */
|
@@ -54,7 +54,7 @@ VALUE make_symbol(char *string)
|
|
54
54
|
/* Returns a char* string from the given symbol */
|
55
55
|
char *unmake_symbol(VALUE symbol)
|
56
56
|
{
|
57
|
-
return rb_id2name( SYM2ID(symbol) );
|
57
|
+
return (char *)rb_id2name( SYM2ID(symbol) );
|
58
58
|
}
|
59
59
|
|
60
60
|
|
@@ -80,7 +80,7 @@ Uint32 collapse_flags(VALUE vflags)
|
|
80
80
|
{
|
81
81
|
switch( TYPE(vflags) ){
|
82
82
|
case T_ARRAY: {
|
83
|
-
int len =
|
83
|
+
int len = RARRAY_LEN(vflags);
|
84
84
|
for(i=0; i < len; i++)
|
85
85
|
{
|
86
86
|
flags |= NUM2UINT( rb_ary_entry( vflags,i ) );
|
@@ -161,7 +161,7 @@ void extract_rgba_u8_as_u8(VALUE color, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
|
|
161
161
|
*g = NUM2UINT(rb_ary_entry(color, 1));
|
162
162
|
*b = NUM2UINT(rb_ary_entry(color, 2));
|
163
163
|
|
164
|
-
if(
|
164
|
+
if( RARRAY_LEN(color) > 3 )
|
165
165
|
{
|
166
166
|
*a = NUM2UINT(rb_ary_entry(color, 3));
|
167
167
|
}
|
@@ -146,14 +146,14 @@ VALUE rbgm_surface_new(int argc, VALUE *argv, VALUE class)
|
|
146
146
|
/* Get width and height for new surface from vsize */
|
147
147
|
vsize = convert_to_array(vsize);
|
148
148
|
|
149
|
-
if(
|
149
|
+
if(RARRAY_LEN(vsize) >= 2)
|
150
150
|
{
|
151
151
|
w = NUM2INT(rb_ary_entry(vsize,0));
|
152
152
|
h = NUM2INT(rb_ary_entry(vsize,1));
|
153
153
|
}
|
154
154
|
else
|
155
155
|
rb_raise(rb_eArgError,"Array is too short for Surface size (%d for 2)",\
|
156
|
-
|
156
|
+
RARRAY_LEN(vsize));
|
157
157
|
|
158
158
|
flags = collapse_flags(vflags); /* in rubygame_shared */
|
159
159
|
|
@@ -89,7 +89,7 @@ class Rubygame::EventHandler
|
|
89
89
|
# the top of the stack.
|
90
90
|
#
|
91
91
|
def append_hook( hook )
|
92
|
-
hook = EventHook.new( hook ) if hook.kind_of?( Hash )
|
92
|
+
hook = Rubygame::EventHook.new( hook ) if hook.kind_of?( Hash )
|
93
93
|
@hooks = (@hooks - [hook]) | [hook]
|
94
94
|
return hook
|
95
95
|
end
|
@@ -103,7 +103,7 @@ class Rubygame::EventHandler
|
|
103
103
|
# If the EventHandler already has that hook, it is moved to the top.
|
104
104
|
#
|
105
105
|
def prepend_hook( hook )
|
106
|
-
hook = EventHook.new( hook ) if hook.kind_of?( Hash )
|
106
|
+
hook = Rubygame::EventHook.new( hook ) if hook.kind_of?( Hash )
|
107
107
|
@hooks = [hook] | @hooks
|
108
108
|
return hook
|
109
109
|
end
|
@@ -324,7 +324,7 @@ module Rubygame::EventHandler::HasEventHandler
|
|
324
324
|
|
325
325
|
# Sets @event_handler to a new EventHandler if needed.
|
326
326
|
def _make_event_handler
|
327
|
-
@event_handler = EventHandler.new() if @event_handler.nil?
|
327
|
+
@event_handler = Rubygame::EventHandler.new() if @event_handler.nil?
|
328
328
|
end
|
329
329
|
|
330
330
|
# This method is called by #make_magic_hooks to convert an
|
@@ -363,10 +363,10 @@ module Rubygame::EventHandler::HasEventHandler
|
|
363
363
|
case action
|
364
364
|
|
365
365
|
when Symbol
|
366
|
-
EventActions::MethodAction.new(action)
|
366
|
+
Rubygame::EventActions::MethodAction.new(action)
|
367
367
|
|
368
368
|
when Proc, Method
|
369
|
-
EventActions::BlockAction.new(&action)
|
369
|
+
Rubygame::EventActions::BlockAction.new(&action)
|
370
370
|
|
371
371
|
else
|
372
372
|
if action.respond_to? :perform
|
@@ -418,13 +418,13 @@ module Rubygame::EventHandler::HasEventHandler
|
|
418
418
|
when Symbol
|
419
419
|
case(trigger.to_s)
|
420
420
|
when /mouse/
|
421
|
-
EventTriggers::MousePressTrigger.new(trigger)
|
421
|
+
Rubygame::EventTriggers::MousePressTrigger.new(trigger)
|
422
422
|
else
|
423
|
-
EventTriggers::KeyPressTrigger.new(trigger)
|
423
|
+
Rubygame::EventTriggers::KeyPressTrigger.new(trigger)
|
424
424
|
end
|
425
425
|
|
426
426
|
when Class
|
427
|
-
EventTriggers::InstanceOfTrigger.new(trigger)
|
427
|
+
Rubygame::EventTriggers::InstanceOfTrigger.new(trigger)
|
428
428
|
|
429
429
|
else
|
430
430
|
if trigger.respond_to? :match?
|
@@ -441,7 +441,7 @@ module Rubygame::EventHandler::HasEventHandler
|
|
441
441
|
|
442
442
|
def _prepare_hook( hook )
|
443
443
|
if( hook.kind_of? Hash )
|
444
|
-
hook = EventHook.new( {:owner => self}.merge(hook) )
|
444
|
+
hook = Rubygame::EventHook.new( {:owner => self}.merge(hook) )
|
445
445
|
end
|
446
446
|
|
447
447
|
if( hook.owner == nil )
|
@@ -374,7 +374,7 @@ class KeyPressTrigger
|
|
374
374
|
# match either :left_alt or :right_alt.
|
375
375
|
#
|
376
376
|
def match?( event )
|
377
|
-
if event.kind_of?( Events::KeyPressed )
|
377
|
+
if event.kind_of?( Rubygame::Events::KeyPressed )
|
378
378
|
((@key == :any) or (event.key == @key)) and \
|
379
379
|
((@mods == :any) or (@mods == :none and event.modifiers == [])\
|
380
380
|
or (_mods_match?(event.modifiers)))
|
@@ -436,7 +436,7 @@ class KeyReleaseTrigger
|
|
436
436
|
# See KeyPressTrigger#match? for more information.
|
437
437
|
#
|
438
438
|
def match?( event )
|
439
|
-
if event.kind_of?( Events::KeyReleased )
|
439
|
+
if event.kind_of?( Rubygame::Events::KeyReleased )
|
440
440
|
((@key == :any) or (event.key == @key)) and \
|
441
441
|
((@mods == :any) or (@mods == :none and event.modifiers == [])\
|
442
442
|
or (_mods_match?(event.modifiers)))
|
@@ -529,7 +529,7 @@ class MousePressTrigger
|
|
529
529
|
# (or the trigger's button is :any).
|
530
530
|
#
|
531
531
|
def match?( event )
|
532
|
-
if event.kind_of?( Events::MousePressed )
|
532
|
+
if event.kind_of?( Rubygame::Events::MousePressed )
|
533
533
|
((@button == :any) or (event.button == @button))
|
534
534
|
else
|
535
535
|
false
|
@@ -598,7 +598,7 @@ class MouseMoveTrigger
|
|
598
598
|
# See #new for information about how events match.
|
599
599
|
#
|
600
600
|
def match?( event )
|
601
|
-
if event.kind_of?( Events::MouseMoved )
|
601
|
+
if event.kind_of?( Rubygame::Events::MouseMoved )
|
602
602
|
((@buttons == :any) or
|
603
603
|
(@buttons == :none and event.buttons == []) or
|
604
604
|
(_buttons_match?(event.buttons)) or
|
@@ -658,7 +658,7 @@ class MouseReleaseTrigger
|
|
658
658
|
# (or the trigger's button is :any).
|
659
659
|
#
|
660
660
|
def match?( event )
|
661
|
-
if event.kind_of?( Events::MouseReleased )
|
661
|
+
if event.kind_of?( Rubygame::Events::MouseReleased )
|
662
662
|
((@button == :any) or (event.button == @button))
|
663
663
|
else
|
664
664
|
false
|
@@ -670,7 +670,7 @@ end
|
|
670
670
|
|
671
671
|
# class TickTrigger
|
672
672
|
# def match?( event )
|
673
|
-
# event.kind_of?( Events::ClockTicked )
|
673
|
+
# event.kind_of?( Rubygame::Events::ClockTicked )
|
674
674
|
# end
|
675
675
|
# end
|
676
676
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubygame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Croisant
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-02-08 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
requirements: []
|
151
151
|
|
152
152
|
rubyforge_project:
|
153
|
-
rubygems_version: 1.
|
153
|
+
rubygems_version: 1.3.1
|
154
154
|
signing_key:
|
155
155
|
specification_version: 2
|
156
156
|
summary: Clean and powerful library for game programming
|