赞 | 5 |
VIP | 0 |
好人卡 | 2 |
积分 | 36 |
经验 | 24079 |
最后登录 | 2024-11-5 |
在线时间 | 1890 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 3596
- 在线时间
- 1890 小时
- 注册时间
- 2010-6-19
- 帖子
- 1211
|
10星屑
本帖最后由 黑米馒头 于 2022-10-27 13:21 编辑
来个大佬看看,下面这个draw_text必备扩展功能脚本如何整合到文本里面,
脚本调用: $game_party.update_message("养成存档习惯,避免从头再来!","_系统"),可以输出文本,
如何把下面dl_draw_text脚本里面的功能添加进去,比如修改颜色,显示武器装备物品图标这些。
viewport = Viewport.new(0,0,640,480) viewport.z = 200 $message_sprite = Sprite.new(viewport) $message_sprite.bitmap = Bitmap.new(640,480) $message_sprite.x = 6 $message_sprite.y = 5 $message_sprite.z = 99999 $message_sprite.visible = true $message_sprite.bitmap.font.size = 15 $message_sprite.bitmap.font.color.set(255,255,255,255) class Window_Goods < Window_Base def initialize super(0, 0, 42, 42) self.opacity = 120 self.visible = true $game_party.update_message("养成存档习惯,避免从头再来!","_系统") end end def update_message(txt,a="_系统") bitmap = RPG::Cache.picture(a) rect = Rect.new(0,0,bitmap.width,bitmap.height) if $message_index < 19 $message_sprite.bitmap.blt(1,4 + $message_index * 25, bitmap,rect) $message_sprite.bitmap.draw_text(5+bitmap.width, 4 + $message_index * 25, 300,bitmap.height, txt) $message_index += 1 else $message_sprite.bitmap.clear $message_sprite.bitmap.blt(1,4,bitmap,rect) $message_sprite.bitmap.draw_text(5+bitmap.width, 4, 300,bitmap.height, txt) $message_index = 1 end end
viewport = Viewport.new(0,0,640,480)
viewport.z = 200
$message_sprite = Sprite.new(viewport)
$message_sprite.bitmap = Bitmap.new(640,480)
$message_sprite.x = 6
$message_sprite.y = 5
$message_sprite.z = 99999
$message_sprite.visible = true
$message_sprite.bitmap.font.size = 15
$message_sprite.bitmap.font.color.set(255,255,255,255)
class Window_Goods < Window_Base
def initialize
super(0, 0, 42, 42)
self.opacity = 120
self.visible = true
$game_party.update_message("养成存档习惯,避免从头再来!","_系统")
end
end
def update_message(txt,a="_系统")
bitmap = RPG::Cache.picture(a)
rect = Rect.new(0,0,bitmap.width,bitmap.height)
if $message_index < 19
$message_sprite.bitmap.blt(1,4 + $message_index * 25, bitmap,rect)
$message_sprite.bitmap.draw_text(5+bitmap.width, 4 + $message_index * 25, 300,bitmap.height, txt)
$message_index += 1
else
$message_sprite.bitmap.clear
$message_sprite.bitmap.blt(1,4,bitmap,rect)
$message_sprite.bitmap.draw_text(5+bitmap.width, 4, 300,bitmap.height, txt)
$message_index = 1
end
end
#=========================================================================== # * draw_text必备扩展 #=========================================================================== =begin !c[n] #改用n号颜色 *注 颜色在color处自定 !s[n] #改用n号大小 !n[name] #改用名称为name的字体 !b0 #关闭粗体 !b1 #开启粗体 !i0 #关闭斜体 !i1 #开启斜体 i[n] #描绘id为n的物品的图标 s[n] #描绘id为n的特技的图标 w[n] #描绘id为n的武器的图标 a[n] #描绘id为n的防具的图标 l[filename] #描绘文件名为filename的图标 \\n #手动换行 其他功能—— *投影 *自动换行 =end class Bitmap def dl_draw_text(x, y, text) #记录bitmap数据 name_copy = self.font.name size_copy = self.font.size bold_copy = self.font.bold italic_copy = self.font.italic color_copy = self.font.color.clone #初始数据 text_copy = text tx,ty = x,y rect = Rect.new(0, 0, 24, 24) #字体 text_copy.gsub!(/!c\[([0-9]+)\]/) { "\001[#{$1}]" } text_copy.gsub!(/!s\[([0-9]+)\]/) { "\002[#{$1}]" } text_copy.gsub!(/!n\[(.+)\]/) { "\003[#{$1}]" } text_copy.gsub!(/!b0/) { "\004" } text_copy.gsub!(/!b1/) { "\005" } text_copy.gsub!(/!i0/) { "\006" } text_copy.gsub!(/!i1/) { "\007" } #图标 text_copy.gsub!(/i\[([0-9]+)\]/) { "\020[#{$1}]" } text_copy.gsub!(/s\[([0-9]+)\]/) { "\021[#{$1}]" } text_copy.gsub!(/w\[([0-9]+)\]/) { "\022[#{$1}]" } text_copy.gsub!(/a\[([0-9]+)\]/) { "\023[#{$1}]" } text_copy.gsub!(/l\[(.+)\]/) { "\025[#{$1}]" } #其他 text_copy.gsub!(/v\[([0-9]+)\]/) { $game_variables[$1.to_i] } text_copy.gsub!(/\\n/) { "\030" } #颜色 color = [] color[0] = Color.new(255, 255, 255, 255)#白 color[1] = Color.new(128, 128, 255, 255)#蓝 color[2] = Color.new(255, 0, 0, 255)#(255, 0, 80, 255) #红 color[3] = Color.new(128, 255, 128, 255)#绿 color[4] = Color.new(128, 255, 255, 255)#青 color[5] = Color.new(255, 128, 255, 255)#粉红 color[6] = Color.new(255, 255, 128, 255)#黄 color[7] = Color.new(192, 192, 192, 255)#灰 color[8] = Color.new(255, 195, 105, 255)#桔色 color[9] = Color.new(207, 212, 241, 255)#紫色 while ((c = text_copy.slice!(/./m)) != nil) #==================================== #设置字体 #==================================== #颜色 if c == "\001" text_copy.sub!(/\[([0-9]+)\]/, "") next if color[$1.to_i].nil? self.font.color = color[$1.to_i] next end #大小 if c == "\002" text_copy.sub!(/\[([0-9]+)\]/, "") self.font.size = $1.to_i next end #名称 if c == "\003" text_copy.sub!(/\[(.+)\]/, "") self.font.name = $1 if Font.exist?($1) next end #粗体关 if c == "\004" self.font.bold = false next end #粗体开 if c == "\005" self.font.bold = true next end #斜体关 if c == "\006" self.font.italic = false next end #斜体开 if c == "\007" self.font.italic = true next end #==================================== #描绘图标 #==================================== #物品 if c == "\020" text_copy.sub!(/\[([0-9]+)\]/, "") if !$data_items[$1.to_i].nil? and $data_items[$1.to_i].icon_name != "" next if tx + 24 > self.width - 32 bitmap = RPG::Cache.icon($data_items[$1.to_i].icon_name) self.blt(tx, ty, bitmap, rect) tx += 24 end next end #特技 if c == "\021" text_copy.sub!(/\[([0-9]+)\]/, "") if !$data_skills[$1.to_i].nil? and $data_skills[$1.to_i].icon_name != "" next if tx + 24 > self.width - 32 bitmap = RPG::Cache.icon($data_skills[$1.to_i].icon_name) self.blt(tx, ty, bitmap, rect) tx += 24 end next end #武器 if c == "\022" text_copy.sub!(/\[([0-9]+)\]/, "") if !$data_weapons[$1.to_i].nil? and $data_weapons[$1.to_i].icon_name != "" next if tx + 24 > self.width - 32 bitmap = RPG::Cache.icon($data_weapons[$1.to_i].icon_name) self.blt(tx, ty, bitmap, rect) tx += 24 end next end #防具 if c == "\023" text_copy.sub!(/\[([0-9]+)\]/, "") if !$data_armors[$1.to_i].nil? and $data_armors[$1.to_i].icon_name != "" next if tx + 24 > self.width - 32 bitmap = RPG::Cache.icon($data_armors[$1.to_i].icon_name) self.blt(tx, ty, bitmap, rect) tx += 24 end next end #自定 if c == "\025" text_copy.sub!(/\[(.+)\]/, "") if $1 != "" next if tx + 24 > self.width - 32 bitmap = RPG::Cache.icon($1) self.blt(tx, ty, bitmap, rect) tx += 24 end next end #==================================== #其他 #==================================== #换行 if c == "\030" ty += self.font.size next end cx = self.text_size(c).width #投影 #dl_color_copy = self.font.color.clone #self.font.color.set(0, 0, 0) #self.draw_text(tx+1, ty+1, cx, self.font.size, c) #self.draw_text(tx-1, ty+1, cx, self.font.size, c) #self.draw_text(tx+1, ty-1, cx, self.font.size, c) #self.draw_text(tx-1, ty-1, cx, self.font.size, c) #self.font.color = dl_color_copy self.draw_text(tx, ty, cx, self.font.size, c) tx += cx #自动换行 if tx >= self.width tx = 0 ty += self.font.size end end #恢复调整 self.font.name = name_copy self.font.size = size_copy self.font.bold = bold_copy self.font.italic = italic_copy self.font.color = color_copy end end
#===========================================================================
# * draw_text必备扩展
#===========================================================================
=begin
!c[n] #改用n号颜色 *注 颜色在color处自定
!s[n] #改用n号大小
!n[name] #改用名称为name的字体
!b0 #关闭粗体
!b1 #开启粗体
!i0 #关闭斜体
!i1 #开启斜体
i[n] #描绘id为n的物品的图标
s[n] #描绘id为n的特技的图标
w[n] #描绘id为n的武器的图标
a[n] #描绘id为n的防具的图标
l[filename] #描绘文件名为filename的图标
\\n #手动换行
其他功能——
*投影
*自动换行
=end
class Bitmap
def dl_draw_text(x, y, text)
#记录bitmap数据
name_copy = self.font.name
size_copy = self.font.size
bold_copy = self.font.bold
italic_copy = self.font.italic
color_copy = self.font.color.clone
#初始数据
text_copy = text
tx,ty = x,y
rect = Rect.new(0, 0, 24, 24)
#字体
text_copy.gsub!(/!c\[([0-9]+)\]/) { "\001[#{$1}]" }
text_copy.gsub!(/!s\[([0-9]+)\]/) { "\002[#{$1}]" }
text_copy.gsub!(/!n\[(.+)\]/) { "\003[#{$1}]" }
text_copy.gsub!(/!b0/) { "\004" }
text_copy.gsub!(/!b1/) { "\005" }
text_copy.gsub!(/!i0/) { "\006" }
text_copy.gsub!(/!i1/) { "\007" }
#图标
text_copy.gsub!(/i\[([0-9]+)\]/) { "\020[#{$1}]" }
text_copy.gsub!(/s\[([0-9]+)\]/) { "\021[#{$1}]" }
text_copy.gsub!(/w\[([0-9]+)\]/) { "\022[#{$1}]" }
text_copy.gsub!(/a\[([0-9]+)\]/) { "\023[#{$1}]" }
text_copy.gsub!(/l\[(.+)\]/) { "\025[#{$1}]" }
#其他
text_copy.gsub!(/v\[([0-9]+)\]/) { $game_variables[$1.to_i] }
text_copy.gsub!(/\\n/) { "\030" }
#颜色
color = []
color[0] = Color.new(255, 255, 255, 255)#白
color[1] = Color.new(128, 128, 255, 255)#蓝
color[2] = Color.new(255, 0, 0, 255)#(255, 0, 80, 255) #红
color[3] = Color.new(128, 255, 128, 255)#绿
color[4] = Color.new(128, 255, 255, 255)#青
color[5] = Color.new(255, 128, 255, 255)#粉红
color[6] = Color.new(255, 255, 128, 255)#黄
color[7] = Color.new(192, 192, 192, 255)#灰
color[8] = Color.new(255, 195, 105, 255)#桔色
color[9] = Color.new(207, 212, 241, 255)#紫色
while ((c = text_copy.slice!(/./m)) != nil)
#====================================
#设置字体
#====================================
#颜色
if c == "\001"
text_copy.sub!(/\[([0-9]+)\]/, "")
next if color[$1.to_i].nil?
self.font.color = color[$1.to_i]
next
end
#大小
if c == "\002"
text_copy.sub!(/\[([0-9]+)\]/, "")
self.font.size = $1.to_i
next
end
#名称
if c == "\003"
text_copy.sub!(/\[(.+)\]/, "")
self.font.name = $1 if Font.exist?($1)
next
end
#粗体关
if c == "\004"
self.font.bold = false
next
end
#粗体开
if c == "\005"
self.font.bold = true
next
end
#斜体关
if c == "\006"
self.font.italic = false
next
end
#斜体开
if c == "\007"
self.font.italic = true
next
end
#====================================
#描绘图标
#====================================
#物品
if c == "\020"
text_copy.sub!(/\[([0-9]+)\]/, "")
if !$data_items[$1.to_i].nil? and $data_items[$1.to_i].icon_name != ""
next if tx + 24 > self.width - 32
bitmap = RPG::Cache.icon($data_items[$1.to_i].icon_name)
self.blt(tx, ty, bitmap, rect)
tx += 24
end
next
end
#特技
if c == "\021"
text_copy.sub!(/\[([0-9]+)\]/, "")
if !$data_skills[$1.to_i].nil? and $data_skills[$1.to_i].icon_name != ""
next if tx + 24 > self.width - 32
bitmap = RPG::Cache.icon($data_skills[$1.to_i].icon_name)
self.blt(tx, ty, bitmap, rect)
tx += 24
end
next
end
#武器
if c == "\022"
text_copy.sub!(/\[([0-9]+)\]/, "")
if !$data_weapons[$1.to_i].nil? and $data_weapons[$1.to_i].icon_name != ""
next if tx + 24 > self.width - 32
bitmap = RPG::Cache.icon($data_weapons[$1.to_i].icon_name)
self.blt(tx, ty, bitmap, rect)
tx += 24
end
next
end
#防具
if c == "\023"
text_copy.sub!(/\[([0-9]+)\]/, "")
if !$data_armors[$1.to_i].nil? and $data_armors[$1.to_i].icon_name != ""
next if tx + 24 > self.width - 32
bitmap = RPG::Cache.icon($data_armors[$1.to_i].icon_name)
self.blt(tx, ty, bitmap, rect)
tx += 24
end
next
end
#自定
if c == "\025"
text_copy.sub!(/\[(.+)\]/, "")
if $1 != ""
next if tx + 24 > self.width - 32
bitmap = RPG::Cache.icon($1)
self.blt(tx, ty, bitmap, rect)
tx += 24
end
next
end
#====================================
#其他
#====================================
#换行
if c == "\030"
ty += self.font.size
next
end
cx = self.text_size(c).width
#投影
#dl_color_copy = self.font.color.clone
#self.font.color.set(0, 0, 0)
#self.draw_text(tx+1, ty+1, cx, self.font.size, c)
#self.draw_text(tx-1, ty+1, cx, self.font.size, c)
#self.draw_text(tx+1, ty-1, cx, self.font.size, c)
#self.draw_text(tx-1, ty-1, cx, self.font.size, c)
#self.font.color = dl_color_copy
self.draw_text(tx, ty, cx, self.font.size, c)
tx += cx
#自动换行
if tx >= self.width
tx = 0
ty += self.font.size
end
end
#恢复调整
self.font.name = name_copy
self.font.size = size_copy
self.font.bold = bold_copy
self.font.italic = italic_copy
self.font.color = color_copy
end
end
|
|