Skip to content

Commit

Permalink
fixed growl stacking
Browse files Browse the repository at this point in the history
  • Loading branch information
bgoodspeed committed Oct 18, 2010
1 parent 0edc7b1 commit 17d4029
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions spike.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1314,25 +1314,36 @@ class NotificationsLayer < AbstractLayer
def initialize(screen, game)
super(screen, @@NOTIFICATION_LAYER_WIDTH, @@NOTIFICATION_LAYER_HEIGHT)
@notifications = []
@config = TextRenderingConfig.new(@@NOTIFICATION_TEXT_INSET, 0, @@NOTIFICATION_TEXT_INSET, @@NOTIFICATION_LINE_SPACING)
@config = TextRenderingConfig.new(@@NOTIFICATION_TEXT_INSET, 0, @@NOTIFICATION_TEXT_INSET, @@NOTIFICATION_LINE_SPACING )
end

def add_notification(notification)
@notifications << notification
@active = true
end

def config_for(idx)
TextRenderingConfig.new(@@NOTIFICATION_TEXT_INSET, 0, @@NOTIFICATION_TEXT_INSET, @@NOTIFICATION_LINE_SPACING * idx)
end

def draw
@layer.fill(:black)
@notifications.each do |notif|
@text_rendering_helper.render_lines_to_layer( notif.message, @config) #TODO this is where the ugly pop text is formatted
notif.displayed
end


@notifications.delete_if do |notif|
notif.dead?
end

puts "drawing #{@notifications.size} notifs"
msgs = @notifications.collect {|n| n.message}
@text_rendering_helper.render_lines_to_layer(msgs, @config)
@notifications.each {|n| n.displayed}
# @notifications.each_with_index do |notif, idx|
# conf = config_for(idx)
# puts "for #{idx} offset is #{conf.yf}"
# @text_rendering_helper.render_lines_to_layer( notif.message, conf) #TODO this is where the ugly pop text is formatted
# notif.displayed
# end

unless @notifications.empty?
@layer.blit(@screen, @notifications[0].location)
end
Expand Down

0 comments on commit 17d4029

Please sign in to comment.