gamebox 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -26,3 +26,8 @@
26
26
 
27
27
  * Bug fix release for RubyWeekend #3
28
28
  * updatable behavior was not in the manifest
29
+
30
+ === 0.0.4 / 2009-06-27
31
+
32
+ * Bug fix release for RubyWeekend #3
33
+ * added registering for events with input_manager that have no ids (ie i.reg KeyDownEvent do |e| ... will get all keys pressed)
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ gem 'hoe', '>= 2.3.0'
3
3
  require 'hoe'
4
4
 
5
5
  module Gamebox
6
- VERSION = '0.0.3'
6
+ VERSION = '0.0.4'
7
7
  end
8
8
  Hoe.new 'gamebox' do |spec|
9
9
  spec.developer('Shawn Anderson', 'shawn42@gmail.com')
@@ -13,7 +13,7 @@ Hoe.new 'gamebox' do |spec|
13
13
  spec.summary = "Framework for building and distributing games using Rubygame"
14
14
  spec.url = "http://shawn42.github.com/gamebox"
15
15
  spec.version = Gamebox::VERSION
16
- spec.changes = spec.paragraphs_of('History.txt', 4..5).join("\n\n")
16
+ spec.changes = spec.paragraphs_of('History.txt', 6..7).join("\n\n")
17
17
  spec.extra_deps << ['constructor']
18
18
  spec.extra_deps << ['publisher']
19
19
  spec.extra_deps << ['bacon']
@@ -32,6 +32,7 @@ class InputManager
32
32
  end
33
33
 
34
34
  @hooks = {}
35
+ @non_id_hooks = {}
35
36
  end
36
37
 
37
38
  def framerate=(frame_rate)
@@ -71,6 +72,13 @@ class InputManager
71
72
  end
72
73
  end
73
74
  end
75
+
76
+ non_id_event_hooks = @non_id_hooks[event.class]
77
+ if non_id_event_hooks
78
+ for callback in non_id_event_hooks
79
+ callback.call event
80
+ end
81
+ end
74
82
  end
75
83
 
76
84
  game.update @clock.tick
@@ -85,6 +93,10 @@ class InputManager
85
93
  @hooks[event_class][event_id] ||= []
86
94
  @hooks[event_class][event_id] << block
87
95
  end
96
+ @non_id_hooks[event_class] ||= []
97
+ if event_ids.empty?
98
+ @non_id_hooks[event_class] << block
99
+ end
88
100
  listener = eval("self", block.binding)
89
101
  listener.when :remove_me do
90
102
  unregister_hook event_class, *event_ids, &block
@@ -98,10 +110,15 @@ class InputManager
98
110
  @hooks[event_class][event_id] ||= []
99
111
  @hooks[event_class][event_id].delete block if block_given?
100
112
  end
113
+ if event_ids.empty?
114
+ @hooks[event_class] ||= []
115
+ @hooks[event_class].delete block if block_given?
116
+ end
101
117
  end
102
118
  alias unreg unregister_hook
103
119
 
104
120
  def clear_hooks
105
121
  @hooks = {}
122
+ @non_id_hooks = {}
106
123
  end
107
124
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shawn Anderson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-26 00:00:00 -07:00
12
+ date: 2009-06-27 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency