Skip to content

Commit

Permalink
Fixed missing font problem. In case of missing font, will now fall ba…
Browse files Browse the repository at this point in the history
…ck to default font determined by Gosu
  • Loading branch information
prototype committed May 11, 2009
1 parent 18868ad commit bd2406b
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions wolf3d.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ def fade_out(&when_done)
end

def present_boss(name, avatar_filename, title = "Boss", duration = 1, &block)
begin
title_image = Gosu::Image.from_text(self, title,
BOSS_PRESENTATION_TITLE_FONT,
BOSS_PRESENTATION_TITLE_FONT_SIZE)
rescue
title_image = Gosu::Image.from_text(self, title,
Gosu::default_font_name,
BOSS_PRESENTATION_TITLE_FONT_SIZE)
end

begin
name_width = Gosu::Image.from_text(self, name, BOSS_PRESENTATION_FONT,
BOSS_PRESENTATION_FONT_SIZE).width
rescue
name_width = Gosu::Image.from_text(self, name, Gosu::default_font_name,
BOSS_PRESENTATION_FONT_SIZE).width
end

fade_out do
@bg_song.stop
@mode = :presenting_boss
Expand All @@ -169,11 +187,8 @@ def present_boss(name, avatar_filename, title = "Boss", duration = 1, &block)
:duration => duration,
:sound => SoundPool.get(self, 'megaman_game_start.ogg').play,
:avatar => Gosu::Image.new(self, avatar_filename, false),
:title_image => Gosu::Image.from_text(self, title,
BOSS_PRESENTATION_TITLE_FONT,
BOSS_PRESENTATION_TITLE_FONT_SIZE),
:name_width => Gosu::Image.from_text(self, name, BOSS_PRESENTATION_FONT,
BOSS_PRESENTATION_FONT_SIZE).width,
:title_image => title_image,
:name_width => name_width,
:stars => Gosu::Image.new(self, 'stars.png', false),
:state => :opening,
:start_time => Time.now,
Expand Down Expand Up @@ -651,8 +666,14 @@ def draw_boss_presentation
args[:title_image].draw((RIGHT - LEFT) / 2 - args[:title_image].width / 2,
top - args[:title_image].height - 80, 3)

image = Gosu::Image.from_text(self, args[:name][0 .. args[:chars]],
BOSS_PRESENTATION_FONT, BOSS_PRESENTATION_FONT_SIZE)
begin
image = Gosu::Image.from_text(self, args[:name][0 .. args[:chars]],
BOSS_PRESENTATION_FONT, BOSS_PRESENTATION_FONT_SIZE)
rescue
image = Gosu::Image.from_text(self, args[:name][0 .. args[:chars]],
Gosu::default_font_name, BOSS_PRESENTATION_FONT_SIZE)
end

image.draw((RIGHT - LEFT) / 2 - args[:name_width] / 2, bottom + 80, 3)
end
if args[:state] == :waiting_until_done || args[:state] == :done
Expand Down

0 comments on commit bd2406b

Please sign in to comment.