Project1
标题:
Window_Help多行显示
[打印本页]
作者:
zh99998
时间:
2008-7-17 21:36
标题:
Window_Help多行显示
我把Window_Help改成窄高型的,但是只能显示1行字,怎么解决 [LINE]1,#dddddd[/LINE]
版务信息:本贴由楼主自主结贴~
作者:
浪使者
时间:
2008-7-17 21:40
你要的脚本:
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ ◆ 文字分段◆ VX ◆
#_/ ◇ Last update : 2007/12/19 ◇
#_/----------------------------------------------------------------------------
#_/
#_/============================================================================
#_/ VX必须用≪書式指定文字描画[DrawFormatText]≫
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
# ★ カスタマイズ項目 ★
#==============================================================================
module KGC
module HelpExtension
# ◆最大行数
ROW_MAX = 4
# ◆画面状态時使用
SHOP_STATUS_SCROLL_BUTTON = Input::A
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
$imported = {} if $imported == nil
$imported["HelpExtension"] = true
#==============================================================================
# ■ Window_Help
#==============================================================================
class Window_Help < Window_Base
attr_reader :row_max
#--------------------------------------------------------------------------
# ● 初期化
#--------------------------------------------------------------------------
alias initialize_KGC_HelpExtension initialize
def initialize
@row_max = 1
initialize_KGC_HelpExtension
end
#--------------------------------------------------------------------------
# ● 行数設定
#--------------------------------------------------------------------------
def row_max=(value)
@row_max = [value, 1].max
self.height = WLH * @row_max + 32
create_contents
# 内容修復
text = @text
align = @align
@text = @align = nil
set_text(text, align)
end
#--------------------------------------------------------------------------
# ● 排版設定
# text : 表示文字列
# align : (0..左、1..中央、2..右)
#--------------------------------------------------------------------------
def set_text(text, align = 0)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
font_buf = self.contents.font.clone
# \N[x] 改行可见的变换
buf = text.gsub(/\\N(\[\d+\])/i) { "\\__#{$1}" }
lines = buf.split(/(?:[|]|\\n)/i)
lines.each_with_index { |l, i|
# 变换\N[x] 颜色
l.gsub!(/\\__(\[\d+\])/i) { "\\N#{$1}" }
self.contents.draw_format_text(4, i * WLH, self.width - 40, WLH, l, align)
}
self.contents.font = font_buf
@text = text
@align = align
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Item
#==============================================================================
class Scene_Item < Scene_Base
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
alias start_KGC_HelpExtension start
def start
start_KGC_HelpExtension
adjust_window_size
end
#--------------------------------------------------------------------------
# ● 調整
#--------------------------------------------------------------------------
def adjust_window_size
@help_window.row_max = KGC::HelpExtension::ROW_MAX
@item_window.y = @help_window.height
@item_window.height = Graphics.height - @help_window.height
@item_window.refresh
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Skill
#==============================================================================
class Scene_Skill < Scene_Base
#--------------------------------------------------------------------------
# ● 開始处理
#--------------------------------------------------------------------------
alias start_KGC_HelpExtension start
def start
start_KGC_HelpExtension
adjust_window_size
end
#--------------------------------------------------------------------------
# ● 調整
#--------------------------------------------------------------------------
def adjust_window_size
@help_window.row_max = KGC::HelpExtension::ROW_MAX
@status_window.y = @help_window.height
dy = @help_window.height + @status_window.height
@skill_window.y = dy
@skill_window.height = Graphics.height - dy
@skill_window.refresh
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Equip
#==============================================================================
class Scene_Equip < Scene_Base
#--------------------------------------------------------------------------
# ● 開始处理
#--------------------------------------------------------------------------
alias start_KGC_HelpExtension start
def start
start_KGC_HelpExtension
adjust_window_size
end
#--------------------------------------------------------------------------
# ●調整
#--------------------------------------------------------------------------
def adjust_window_size
@help_window.row_max = KGC::HelpExtension::ROW_MAX
@equip_window.y = @help_window.height
@status_window.y = @help_window.height
resize_item_windows
end
#--------------------------------------------------------------------------
# ● 変更
#--------------------------------------------------------------------------
def resize_item_windows
@item_windows.each { |w|
dy = @help_window.height + @equip_window.height
w.y = dy
w.height = Graphics.height - dy
w.refresh
}
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Shop
#==============================================================================
class Scene_Shop < Scene_Base
#--------------------------------------------------------------------------
# ● 開始处理
#--------------------------------------------------------------------------
alias start_KGC_HelpExtension start
def start
start_KGC_HelpExtension
adjust_window_size
end
#--------------------------------------------------------------------------
# ● 調整
#--------------------------------------------------------------------------
def adjust_window_size
@help_window.row_max = KGC::HelpExtension::ROW_MAX
@command_window.y = @help_window.height
@gold_window.y = @help_window.height
dy = @help_window.height + @command_window.height
@dummy_window.y = @buy_window.y = @sell_window.y =
@number_window.y = @status_window.y = dy
@dummy_window.height = @buy_window.height =
@sell_window.height = @number_window.height =
@status_window.height = Graphics.height - dy
@dummy_window.create_contents
@number_window.create_contents
end
#--------------------------------------------------------------------------
# ● 更新
#--------------------------------------------------------------------------
alias udpate_KGC_HelpExtension update
def update
if !@command_window.active &&
Input.press?(KGC::HelpExtension::SHOP_STATUS_SCROLL_BUTTON)
super
update_menu_background
update_scroll_status
return
else
@status_window.cursor_rect.empty
end
udpate_KGC_HelpExtension
end
#--------------------------------------------------------------------------
# ● 更新处理
#--------------------------------------------------------------------------
def update_scroll_status
@status_window.cursor_rect.width = @status_window.contents.width
@status_window.cursor_rect.height = @status_window.height - 32
@status_window.update
if Input.press?(Input::UP)
@status_window.oy = [@status_window.oy - 4, 0].max
elsif Input.press?(Input::DOWN)
max_pos = [@status_window.contents.height -
(@status_window.height - 32), 0].max
@status_window.oy = [@status_window.oy + 4, max_pos].min
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● 初始化開始
#--------------------------------------------------------------------------
alias start_skill_selection_KGC_HelpExtension start_skill_selection
def start_skill_selection
start_skill_selection_KGC_HelpExtension
adjust_skill_window_size
end
#--------------------------------------------------------------------------
# ● 調整
#--------------------------------------------------------------------------
def adjust_skill_window_size
@help_window.row_max = KGC::HelpExtension::ROW_MAX
@skill_window.y = @help_window.height
@skill_window.height = Graphics.height -
(@help_window.height + @status_window.height)
@skill_window.refresh
end
#--------------------------------------------------------------------------
# ● 開始
#--------------------------------------------------------------------------
alias start_item_selection_KGC_HelpExtension start_item_selection
def start_item_selection
start_item_selection_KGC_HelpExtension
adjust_item_window_size
end
#--------------------------------------------------------------------------
# ● 調整
#--------------------------------------------------------------------------
def adjust_item_window_size
@help_window.row_max = KGC::HelpExtension::ROW_MAX
@item_window.y = @help_window.height
@item_window.height = Graphics.height -
(@help_window.height + @status_window.height)
@item_window.refresh
end
end
复制代码
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ ◆ 書式指定文字描画 - 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
复制代码
注意 使用方法: 在物品等描述中 用 | 换行!! [LINE]1,#dddddd[/LINE]
系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1