Sha256: cb674173e3c30c8f145629f261b37f5ddeeb6d4865a57b147b2391f50141c4eb

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

#
#
module Controllable extend Trait
  
  def self.included controllable
    controllable.extend ClassMethods
  end
  
  module ClassMethods
    
    # TODO alternate controls handling!
    #
    
    def controls mapping
      attr_accessor :controls_mapping
      hook = lambda do
        if self.controls_mapping
          # primary controls taken, use alternate controls
          self.controls_mapping = self.alternate_controls_mapping if self.respond_to? :alternate_controls_mapping
        else
          self.controls_mapping = mapping
        end
        self.window.add_controls_for self
      end
      InitializerHooks.register self, &hook
    end
    
    def alternate_controls mapping
      attr_accessor :alternate_controls_mapping
      hook = lambda do
        if self.controls_mapping
          # primary controls taken, use alternate controls
          self.controls_mapping = self.alternate_controls_mapping if self.respond_to? :alternate_controls_mapping
        else
          self.controls_mapping = mapping
        end
      end
      InitializerHooks.register self, &hook
    end
    
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gosu_extensions-0.1.21 lib/traits/controllable.rb
gosu_extensions-0.1.20 lib/traits/controllable.rb
gosu_extensions-0.1.19 lib/traits/controllable.rb
gosu_extensions-0.1.18 lib/traits/controllable.rb
gosu_extensions-0.1.17 lib/traits/controllable.rb
gosu_extensions-0.1.16 lib/traits/controllable.rb
gosu_extensions-0.1.15 lib/traits/controllable.rb