#============================================================================== # ★ バトラー&アイコン&文字のピクチャ表示 ver1.0 by USK #------------------------------------------------------------------------------ # ・Graphics/Battlersにある画像やアイコン、文章をピクチャとして表示します。 #============================================================================== =begin イベントコマンドのスクリプトでshow_battler(ピクチャ番号, ファイル名)と記述すると Graphics/Battlers内の指定した画像が指定した番号のピクチャとして表示されます。 例 show_battler(1, "Angel") イベントコマンドのスクリプトでshow_icon(ピクチャ番号, アイコン番号)と記述すると 指定した番号のアイコンが指定した番号のピクチャとして表示されます。 例 show_icon(2, 10) イベントコマンドのスクリプトでshow_text(ピクチャ番号, テキスト, フォント)と記述 すると指定したテキストが指定した番号のピクチャとして表示されます。フォントの設定 は、Font.new(フォント名, フォントサイズ)と記述します。フォントは省略可能です。 例 show_text(2, "ツクール") show_text(3, "ツクール", Font.new("MS ゴシック", 40)) ピクチャの座標等の設定は「ピクチャの移動」のイベントコマンドで行ってください。 =end #============================================================================== # ■ Game_Interpreter #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def show_battler(id, name) screen.pictures[id].show_battler(name) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def show_icon(id, index) screen.pictures[id].show_icon(index) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def show_text(id, text, font = Font.new(Font.default_name)) screen.pictures[id].show_text(text, font) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def font(name = Font.default_name, size = 24) ret = Font.new(name, size) ret.bold = false ret end end #============================================================================== # ■ Game_Picture #============================================================================== class Game_Picture attr_reader :mode, :font #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- alias :show_picture :show def show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type) @mode = :picture show_picture(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def show_battler(name) @mode = :battler show_picture(name, 0, 0, 0, 100, 100, 255, 0) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def show_icon(index) @mode = :icon show_picture(index, 0, 0, 0, 100, 100, 255, 0) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def show_text(text, font) @mode = :text @font = font show_picture(text, 0, 0, 0, 100, 100, 255, 0) end end #============================================================================== # ■ Sprite_Picture #============================================================================== class Sprite_Picture #-------------------------------------------------------------------------- # ● 転送元ビットマップの更新 #-------------------------------------------------------------------------- alias :usk_bp_update_bitmap :update_bitmap def update_bitmap case @picture.mode when :battler self.bitmap = Cache.battler(@picture.name, 0) when :icon self.bitmap = Cache.system("IconSet") x = 24 * (@picture.name % 16) y = 24 * (@picture.name / 16) self.src_rect = Rect.new(x, y, 24, 24) when :text self.bitmap = Cache.text(@picture.name, @picture.font) else usk_bp_update_bitmap end end end #============================================================================== # ■ Cache #============================================================================== module Cache #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def self.text(text, font) return @cache[text] if @cache[text] w = font.size * text.size h = font.size bmp = Bitmap.new(w, h) bmp.font = font bmp.draw_text(bmp.rect, text) @cache[text] = bmp end end