#============================================================================== # ★RGSS2 # STR27_文字ピクチャ生成 v1.1 08/09/05 # サポート:http://strcatyou.u-abel.net/ # # ・指定した文字列をピクチャ表示させます。 # # ■使用方法 # 以下のスクリプトをイベントコマンドで実行した後、 # ピクチャの表示"コマンドで文字ピクチャを表示させます。 =begin ここから # テキスト t = "hogehoge" s = 20 # 文字サイズ p = 0 # フォントパターン text_picture(t, p, s) ここまで =end # # ※フォントパターンは下の設定箇所で定義します。 # ※フォントサイズが小さすぎたり大きすぎたりすると #  エラーがでます。注意してください。 # #------------------------------------------------------------------------------ # # 更新履歴 # ◇1.0→1.1 # ""内の改行箇所などで・が表示されるバグを修正 # #============================================================================== # ★ フォントパターン定義(設定箇所) #============================================================================== module STRRGSS2 # ↓対応する値 # 通常の文字 STR27_FLIST = {0 => ["UmePlus Gothic", # フォント名 false, # 太字 false, # 斜体 true, # 影文字 false, # 縁取り Color.new(255,255,255),# 文字色 Color.new( 64, 32,128) # 縁取り色 ], # 斜め・縁取り 1 => ["UmePlus Gothic", # フォント名 false, # 太字 true, # 斜体 true, # 影文字 true, # 縁取り Color.new(255,255,255),# 文字色 Color.new( 64, 32,128) # 縁取り色 ], } # end #============================================================================== # ■ Game_Interpreter #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ● 文字ピクチャ指定 #-------------------------------------------------------------------------- def text_picture(text, p = 0, size = 20) strfp = STRRGSS2::STR27_FLIST[p] font = Font.new(strfp[0], size) font.bold = strfp[1] ; font.italic = strfp[2] font.shadow = strfp[3] ; font.color = strfp[5] text.gsub!(/[\t\n\r\f]*/,"") @strtxpic = [text, STR_DumpFont.new(font, strfp[4], strfp[6])] end #-------------------------------------------------------------------------- # ● ピクチャの表示(エイリアス) #-------------------------------------------------------------------------- alias command_231_str27 command_231 def command_231 @params[1] = @strtxpic if @strtxpic != nil ; @strtxpic = nil command_231_str27 end end #============================================================================== # ■ Sprite_Picture #============================================================================== class Sprite_Picture < Sprite #-------------------------------------------------------------------------- # ● フレーム更新(エイリアス) #-------------------------------------------------------------------------- alias update_str27 update def update if @picture.name.is_a?(Array) and @picture_name != @picture.name # 文字ピクチャ @picture_name = @picture.name if @picture_name != "" self.bitmap.dispose if self.bitmap != nil and not @picture_name.is_a?(String) f = @picture_name[1].undump # 文字サイズ取得 self.bitmap =Bitmap.new(1, 1) ; self.bitmap.font = f[0] size = self.bitmap.text_size(@picture_name[0]) size.width += f[0].size / 4 if f[0].italic size.width += 4 ; self.bitmap.dispose # イメージ作成 self.bitmap = Bitmap.new(size.width + 2, size.height + 2) ; self.bitmap.font = f[0] unless f[1] self.bitmap.draw_text(1, 1, size.width, size.height, @picture_name[0]) else self.bitmap.draw_text_f(1, 1, size.width, size.height, @picture_name[0], 0, f[2]) end end elsif @picture_name != @picture.name # 通常ピクチャ @picture_name = @picture.name if @picture_name != "" self.bitmap.dispose unless @picture_name.is_a?(String) self.bitmap = Cache.picture(@picture_name) end end # 呼び戻し update_str27 end end #============================================================================== # ■ Bitmap #============================================================================== class Bitmap #-------------------------------------------------------------------------- # ● 文字縁取り描画 #-------------------------------------------------------------------------- def draw_text_f(x, y, width, height, str, align = 0, color = Color.new(64,32,128)) shadow = self.font.shadow b_color = self.font.color.dup font.shadow = false font.color = color draw_text(x + 1, y, width, height, str, align) draw_text(x - 1, y, width, height, str, align) draw_text(x, y + 1, width, height, str, align) draw_text(x, y - 1, width, height, str, align) font.color = b_color draw_text(x, y, width, height, str, align) font.shadow = shadow end def draw_text_f_rect(r, str, align = 0, color = Color.new(64,32,128)) draw_text_f(r.x, r.y, r.width, r.height, str, align = 0, color) end end #============================================================================== # ■ STR_DumpFont #============================================================================== class STR_DumpFont #-------------------------------------------------------------------------- # ● 初期化 #-------------------------------------------------------------------------- def initialize(font, edge, ed_color) @name = font.name ; @size = font.size @bold = font.bold ; @italic = font.italic @shadow = font.shadow ; @edge = edge ; @ed_color = ed_color.clone @color = Color.new(font.color.red,font.color.green,font.color.blue,font.color.alpha) end #-------------------------------------------------------------------------- # ● 変換 #-------------------------------------------------------------------------- def undump font = Font.new(@name, @size) font.bold = @bold ; font.italic = @italic font.shadow = @shadow ; font.color = @color return [font, @edge, @ed_color] end end