Sha256: b1a87f453e94f1398470255f2d19c0e4edc5ffdc4e8c0676f09b8635b6f5eded

Contents?: true

Size: 735 Bytes

Versions: 15

Compression:

Stored size: 735 Bytes

Contents

#
#
module UserInterface extend Trait
  
  def self.included base
    base.extend ClassMethods
  end
  
  # Call this to install an UI on all instances of
  # this class at the given position.
  #
  module ClassMethods
    attr_accessor :ui
    def ui x = 20, y = 10, color = Gosu::Color::BLACK, &display
      InitializerHooks.append self do
        ui x, y, color, &display
      end
    end
  end
  
  # Call this to dynamically add itself to the ui displaying.
  #
  def ui x = 20, y = 10, color = Gosu::Color::BLACK, &display
    metaclass.instance_eval do
      define_method :draw_ui do
        window.font.draw instance_eval(&display), x, y, Layer::UI, 1.0, 1.0, color
      end
    end
    window.register_ui self
  end
  
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
gosu_extensions-0.3.8 lib/traits/user_interface.rb
gosu_extensions-0.3.7 lib/traits/user_interface.rb
gosu_extensions-0.3.6 lib/traits/user_interface.rb
gosu_extensions-0.3.5 lib/traits/user_interface.rb
gosu_extensions-0.3.4 lib/traits/user_interface.rb
gosu_extensions-0.3.3 lib/traits/user_interface.rb
gosu_extensions-0.3.2 lib/traits/user_interface.rb
gosu_extensions-0.3.1 lib/traits/user_interface.rb
gosu_extensions-0.3.0 lib/traits/user_interface.rb
gosu_extensions-0.2.9 lib/traits/user_interface.rb
gosu_extensions-0.2.8 lib/traits/user_interface.rb
gosu_extensions-0.2.7 lib/traits/user_interface.rb
gosu_extensions-0.2.6 lib/traits/user_interface.rb
gosu_extensions-0.2.5 lib/traits/user_interface.rb
gosu_extensions-0.2.4 lib/traits/user_interface.rb