Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module HUDWidgets
- #----------
- class WidgetBase < Sprite
- def initialize(name, x, y, z)
- super()
- @name = name
- self.x, self.y, self.z = x, y, z
- end
- def z=(v)
- super(v + 60)
- end
- def z
- return super() - 60
- end
- end
- #----------
- class TextWidget < WidgetBase
- def initialize(name, x, y, z, param, text, id, fname, fsize, fbold, fitalic, fshadow, fcolor, foutline, foutline_color, tw, th, fix_from)
- super(name, x, y, z)
- #-----
- @fsize = fsize
- @fix_from = fix_from
- @initial_width = nil
- #-----
- @font = Font.new(fname, fsize)
- @font.bold = fbold
- @font.italic = fitalic
- @font.shadow = fshadow
- @font.outline = foutline
- @font.out_color = foutline_color
- @fbmp = Bitmap.new(1, 1)
- @fbmp.font = @font
- #-----
- @param, @text, @id = param, text, id
- @tw, @th = tw, th
- #-----
- r = @fbmp.text_size('Text')
- @font.size *= (@tw.to_f / r.width)
- #-----
- @fbmp.font = @font
- #-----
- self.oy = (((r.height * (@tw.to_f / r.width)) * (1.0 - (r.width / @tw.to_f))) * 0.5).ceil
- #-----
- update
- end
- def update
- actor = $game_party.leader
- case @param
- when 0 # Text
- str = @text
- else
- return
- end
- #-----
- self.bitmap.dispose if self.bitmap and not self.bitmap.disposed?
- return if str.empty?
- #-----
- r = @fbmp.text_size(str)
- bmp = self.bitmap = Bitmap.new(r.width + 32, r.height)
- bmp.font = @font
- bmp.draw_text(bmp.rect, str, 0)
- #-----
- @initial_width ||= self.width
- #-----
- case @fix_from
- when 0
- self.ox = 0
- when 1
- self.ox = (self.width - @initial_width) / 2
- when 2
- self.ox = self.width - @initial_width
- end
- end
- end
- end
- class Scene_Map < Scene_Base
- #----------
- alias :hud_alias_start :start
- alias :hud_alias_update :update
- alias :hud_alias_p_term :terminate
- #----------
- def start
- hud_alias_start
- start_hud
- end
- #-----
- def start_hud
- @actor_info_cache, @var_info_cache, @hud_widgets = {}, {}, {}
- @hud_widgets[1] = HUDWidgets::TextWidget.new('Text', 14, 382, 0, 0, 'Put your text here', 0, 'Arial', 24, false, false, false, Color.new(255, 255, 255, 255), false, Color.new(0, 0, 0, 255), 59, 24,0)
- update_hud
- end
- #----------
- def update
- hud_alias_update
- update_hud
- end
- #-----
- def update_hud
- actor = $game_party.leader
- end
- #----------
- def terminate
- hud_alias_p_term
- hud_dispose
- end
- #-----
- def hud_dispose
- @hud_widgets.each_value {|hw| hw.dispose }
- end
- #----------
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement