| 赞 | 0  | 
 
| VIP | 0 | 
 
| 好人卡 | 0 | 
 
| 积分 | 1 | 
 
| 经验 | 23330 | 
 
| 最后登录 | 2021-2-21 | 
 
| 在线时间 | 13 小时 | 
 
 
 
 
 
Lv1.梦旅人 
	- 梦石
 - 0 
 
        - 星屑
 - 65 
 
        - 在线时间
 - 13 小时
 
        - 注册时间
 - 2008-1-11
 
        - 帖子
 - 330
 
 
 
 | 
	
5楼
 
 
 楼主 |
发表于 2008-6-8 09:22:38
|
只看该作者
 
 
 
以下引用snstar2006于2008-6-8 1:22:09的发言: 
 
置頂帖: 
書式描繪文字 
說明窗口擴充   
 
初步理解和测试。。MS没生效。。估计是没完全了解使用方法,请指教。帮我看看使用方法,日文看不太懂,google翻译的效果也不太理想。。 
 
 
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ 
#_/    ◆ 書式指定文字描画 - KGC_DrawFormatText ◆ VX ◆ 
#_/    ◇ Last update : 2007/12/19 ◇ 
#_/---------------------------------------------------------------------------- 
#_/  書式指定文字描画機能を追加します。 
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ 
 
$imported = {} if $imported == nil 
$imported["DrawFormatText"] = true 
 
class Bitmap 
  @@__dummy_window = Window_Base.new(-64, -64, 64, 64) 
  @@__dummy_window.visible = false 
  #-------------------------------------------------------------------------- 
  # ● 書式指定文字描画 
  #-------------------------------------------------------------------------- 
  def draw_format_text(x, y, width, height, text, align = 0) 
    str = convert_special_characters(text) 
    dx = 0 
    buf = Bitmap.new(Graphics.width * 2, Window_Base::WLH) 
    buf.font = self.font.clone 
    loop { 
      c = str.slice!(/./m)              # 次の文字を取得 
      case c 
      when nil                          # 描画すべき文字がない 
        break 
      when "\x01"                       # \C[n]  (文字色変更) 
        str.sub!(/\[([0-9]+)\]/, "") 
        buf.font.color = @@__dummy_window.text_color($1.to_i) 
        next 
      else                              # 普通の文字 
        buf.draw_text(dx, 0, 40, Window_Base::WLH, c) 
        c_width = buf.text_size(c).width 
        dx += c_width 
      end 
    } 
    self.font = buf.font.clone 
    # バッファをウィンドウ内に転送 
    dest = Rect.new(x, y, [width, dx].min, height) 
    src = Rect.new(0, 0, dx, Window_Base::WLH) 
    offset = width - dx 
    case align 
    when 1  # 中央揃え 
      dest.x += offset / 2 
    when 2  # 右揃え 
      dest.x += offset 
    end 
    stretch_blt(dest, buf, src) 
    buf.dispose 
  end 
  #-------------------------------------------------------------------------- 
  # ● 特殊文字の変換 
  #-------------------------------------------------------------------------- 
  def convert_special_characters(str) 
    text = str.dup 
    text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] } 
    text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name } 
    text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" } 
    text.gsub!(/\\G/)              { $game_party.gold } 
    text.gsub!(/\\\\/)             { "\\" } 
    return text 
  end 
end 
 |   
 
 
 
 |