Project1

标题: 请问怎么可以让这个脚本在对话中设置名字左侧右侧 [打印本页]

作者: AWY346TEWF    时间: 2014-8-13 03:36
标题: 请问怎么可以让这个脚本在对话中设置名字左侧右侧
本帖最后由 AWY346TEWF 于 2014-8-13 03:43 编辑

用的是这个脚本,按照说明改0、1、2只能全部改位置请问有没有可能在对话中分别改成左侧或右侧
RUBY 代码复制
  1. =begin
  2. ===============================================================================
  3.  对话显示姓名 By喵呜喵5
  4. ===============================================================================
  5.  
  6. 【说明】
  7.  
  8. 通过在对话中加入
  9.  
  10. \name[姓名]
  11.  
  12. 则可以在对话中显示姓名,通过修改设定部分的设定乃至修改脚本可以让这个姓名显示脚本看起
  13. 来更漂亮一些
  14. 实在不会修改的话,默认的样式应该也还过得去吧……
  15.  
  16.  
  17. =end
  18. module M5Name
  19. #==============================================================================
  20. #  设定部分
  21. #==============================================================================
  22.  
  23.   LINE = 4
  24.   #文章显示的行数,姓名框会占用一行
  25.  
  26.   FONT = ["黑体"]
  27.   #姓名所使用的字体
  28.  
  29.   SIZE = 20
  30.   #姓名字体的大小,不建议超过你默认的文字大小,不然会发生奇怪的换页……
  31.  
  32.   COLOR = Color.new(0,0,0, 210)
  33.   #姓名的颜色,四个数值分别是R、G、B以及透明度
  34.  
  35.   BOLD = false
  36.   #姓名是否加粗
  37.  
  38.   ITALIC = false
  39.   #姓名是否斜体
  40.  
  41.   SHADOW = false
  42.   #姓名是否有阴影
  43.  
  44.   OUT = true
  45.   #姓名是否加边框
  46.  
  47.   OUT_COLOR = Color.new(255, 255, 255, 100)
  48.   #姓名边框的颜色,四个数值分别是R、G、B以及透明度
  49.  
  50.   ALIGN =  0
  51.   #姓名的对齐方式,0,1,2分别是居左、居中、居右
  52.  
  53.   COLOR1 = Color.new(255, 255, 255, 128)
  54.   #姓名的背景框左边的颜色,四个数值分别是R、G、B以及透明度
  55.   #有能力建议直接修改下方的脚本调整成适合自己游戏的样式
  56.  
  57.   COLOR2 = Color.new(255, 255, 255, 0)
  58.   #姓名的背景框右边的颜色,四个数值分别是R、G、B以及透明度
  59.   #有能力建议直接修改下方的脚本调整成适合自己游戏的样式
  60.  
  61. #==============================================================================
  62. #  设定结束
  63. #==============================================================================
  64. end
  65. #==============================================================================
  66. #  脚本部分
  67. #==============================================================================
  68. class Window_Message < Window_Base   
  69.   def visible_line_number
  70.     return M5Name::LINE
  71.   end  
  72.   def process_all_text
  73.     open_and_wait
  74.     text = convert_escape_characters($game_message.all_text)
  75.     text.slice!(/\ename\[(.+?)\]/i)
  76.     @showname = $1
  77.     pos = {}
  78.     new_page(text, pos)
  79.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  80.   end  
  81.   def new_line_x
  82.     $game_message.face_name.empty? ? 0 : 112
  83.   end  
  84.   def new_page(text, pos)
  85.     contents.clear
  86.     draw_face($game_message.face_name, $game_message.face_index, 0,0)
  87.     contents.font.name = M5Name::FONT
  88.     contents.font.bold = M5Name::BOLD
  89.     contents.font.italic = M5Name::ITALIC
  90.     contents.font.outline = M5Name::OUT
  91.     contents.font.shadow = M5Name::SHADOW
  92.     contents.font.color = M5Name::COLOR
  93.     contents.font.out_color = M5Name::OUT_COLOR
  94.     contents.font.size = M5Name::SIZE
  95.     if @showname != nil
  96.       draw_namebackground(text_size(@showname))
  97.       draw_text($game_message.face_name.empty? ? 0 : 112,0,contents_width,
  98.       M5Name::SIZE, @showname,M5Name::ALIGN)
  99.       pos[:y] = M5Name::SIZE
  100.     else
  101.       pos[:y] = 0
  102.     end   
  103.     reset_font_settings
  104.     pos[:x] = new_line_x
  105.     pos[:new_x] = new_line_x
  106.     pos[:height] = calc_line_height(text)
  107.     @showname = ""
  108.     clear_flags   
  109.   end
  110.   def reset_font_settings
  111.     change_color(normal_color)
  112.     contents.font.bold = Font.default_bold
  113.     contents.font.italic = Font.default_italic
  114.     contents.font.name = Font.default_name
  115.     contents.font.outline = Font.default_outline
  116.     contents.font.shadow = Font.default_shadow
  117.     contents.font.size = Font.default_size
  118.     contents.font.out_color = Font.default_out_color
  119.   end
  120. #==============================================================================
  121. #  以下内容用来描绘姓名框的背景,有能力的建议自行对其修改成适合自己游戏的样式
  122. #==============================================================================  
  123.  
  124.   def draw_namebackground(rect)
  125.     temp_rect = rect.clone
  126.     temp_rect.x = $game_message.face_name.empty? ? 0 : 112
  127.     temp_rect.width = 460   
  128.     contents.gradient_fill_rect(temp_rect, name_color1, name_color2)
  129.   end
  130.  
  131.   def name_color1
  132.     M5Name::COLOR1
  133.   end
  134.  
  135.   def name_color2
  136.     M5Name::COLOR2
  137.   end
  138.  
  139. end
  140. #==============================================================================
  141. #  脚本结束
  142. #==============================================================================

作者: taroxd    时间: 2014-8-13 07:33
第 98 行 M5Name::ALIGN 改为 $game_variables[1], 然后用 1 号变量控制




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1