设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1708|回复: 3
打印 上一主题 下一主题

[已经过期] 这个脚本如何修改间距

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
154 小时
注册时间
2013-12-20
帖子
66
跳转到指定楼层
1
发表于 2014-1-17 20:31:45 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 丽塔菌 于 2014-1-17 20:33 编辑

这个脚本是一个相当于选项独立显示的一个脚本
可是不太清楚改如何修改,因为我选项使用暗色背景,于是会出现文字与选项位置不同这样的事情
该如何解决·?
脚本如下:

RUBY 代码复制
  1. #------------------------------------------------------------------------------#
  2. #  Galv's Visual Novel Choices
  3. #------------------------------------------------------------------------------#
  4. #  For: RPGMAKER VX ACE
  5. #  Version 1.9
  6. #------------------------------------------------------------------------------#
  7. #  2013-01-16 - Version 1.9 - Added Y offset for choice window
  8. #  2012-11-28 - Version 1.8 - Z level setting added
  9. #  2012-11-28 - Version 1.7 - Added compatability for some cursor scripts
  10. #  2012-11-28 - Version 1.6 - Fixed a bug that could crash the game.
  11. #  2012-11-28 - Version 1.5 - Added offset to change postion of cursor x and y
  12. #  2012-11-28 - Version 1.4 - Fixed z levels and made cursor use an image
  13. #  2012-11-27 - Version 1.3 - Fixed a bug with cancel choice selection
  14. #  2012-11-27 - Version 1.2 - added a switch to disable script effects
  15. #  2012-11-27 - Version 1.1 - added ability to use different image per choice
  16. #                           - added a couple more options
  17. #  2012-11-27 - Version 1.0 - release
  18. #------------------------------------------------------------------------------#
  19. #  This script overwrites the default "Show Choices" list. The choices are
  20. #  changed so they display centered on the screen with a graphic behind each
  21. #  of them. Made with visual novel choice selection in mind.
  22. #------------------------------------------------------------------------------#
  23. #  INSTRUCTIONS:
  24. #  Copy the graphic from the demo /Graphics/System into your project.
  25. #  Copy the script into your script list, below Materials and above Main
  26. #
  27. #  Some setup options below, most only need to be changed if you use your own
  28. #  custom choice image.
  29. #------------------------------------------------------------------------------#
  30. #  Codes:
  31. #------------------------------------------------------------------------------#
  32. #  Most of the usual codes that work in messages should work in choices.
  33. #  (eg. \V[x], \N[x], \C[x], etc. Look at message tooltip to know more.)
  34. #
  35. #  A new one has been added so you can change the background image for separate
  36. #  choice options.
  37. #
  38. #  \B[x]
  39. #
  40. #  This works by adding the number x (as you put in the code above) to the end
  41. #  of the CHOICE IMAGE file name. For example, the default choice image is:
  42. #  "Choice.png" located in /Graphics/System/. If you put the code anywhere in
  43. #  a choice box:  \B[3]  it will look for "Choice3.png" image in the same
  44. #  location.
  45. #------------------------------------------------------------------------------#
  46.  
  47. ($imported ||= {})["Galvs_Image_Choices"] = true
  48. module Galv_Choice
  49.  
  50. #------------------------------------------------------------------------------#
  51. #  SCRIPT SETUP OPTIONS
  52. #------------------------------------------------------------------------------#
  53.  
  54.   CURSOR_IMAGE = "Cursor"  # Images used to determine which option you select
  55.   CURSOR_OPACITY = 255      # Opacity of the cursor
  56.   CURSOR_Y_OFFSET = 0       # Nudge cursor position vertically
  57.   CURSOR_X_OFFSET = 0       # Nudge cursor position horizontally
  58.  
  59.   CHOICE_IMAGE = "Choice"   # Image for each choice located in /Graphics/System
  60.   IMAGE_Y_OFFSET = 3        # Nudge your choice image vertically if needed
  61.   IMAGE_OPACITY = 215       # The opacity of the image
  62.  
  63.   CHOICE_HEIGHT = 45        # How tall each choice.
  64.   CHOICE_ITEM_Y = 2       # Offset for choice item text
  65.  
  66.   CENTER_TEXT = true        # left aligned if false, centered if true
  67.  
  68.   DISABLE_SWITCH = 1        # Turn this switch ON to disable this script
  69.  
  70.   CHOICES_Y = 0             # Y offset to move choice window up or down.
  71.                             # useful if you use a script that creates a namebox
  72.   CHOICES_Z = 100            # The z value of the choices window. Try changing it
  73.                             # if pictures or other scripts appear over or under
  74.                             # the choices window to how you like.
  75.  
  76. #------------------------------------------------------------------------------#
  77.   OTHER_Y_OFFSET = 12       # May fix other cursor scripts positioning
  78. #------------------------------------------------------------------------------#
  79. #  SCRIPT SETUP OPTIONS
  80. #------------------------------------------------------------------------------#
  81.  
  82. end
  83.  
  84. class Window_ChoiceList < Window_Command
  85.  
  86.   alias galv_choice_initialize initialize
  87.   def initialize(message_window)
  88.     galv_choice_initialize(message_window)
  89.     self.z = Galv_Choice::CHOICES_Z
  90.   end
  91.  
  92.   def start
  93.     [url=home.php?mod=space&uid=370741]@Index[/url] = 0
  94.     setup_choices
  95.     make_cursor
  96.     refresh
  97.     open
  98.     activate
  99.     update_placement
  100.     update_bgs
  101.     refresh
  102.     select(0)
  103.   end
  104.  
  105.   def make_cursor
  106.     return if $game_switches[Galv_Choice::DISABLE_SWITCH]
  107.     @cursor_sprite = Sprite.new
  108.     @cursor_sprite.bitmap = Cache.system(Galv_Choice::CURSOR_IMAGE)
  109.   end
  110.  
  111.   def setup_choices
  112.     @choice_sprite = []
  113.     if !$game_switches[Galv_Choice::DISABLE_SWITCH]
  114.       self.opacity = 0
  115.       get_widths
  116.     else
  117.       self.opacity = 255
  118.     end
  119.   end
  120.  
  121.   alias galv_choice_update_placement update_placement
  122.   def update_placement
  123.     if $game_switches[Galv_Choice::DISABLE_SWITCH]
  124.       galv_choice_update_placement
  125.     else
  126.       self.width = [max_choice_width + 12, 96].max + padding * 4
  127.       self.width = [width, Graphics.width].min
  128.       self.height = contents_height + Galv_Choice::CHOICE_HEIGHT - 10
  129.       self.x = (Graphics.width - width) / 2
  130.  
  131.       if @message_window.openness < 100
  132.         self.y = Graphics.height - contents_height + item_height / 2
  133.       elsif @message_window.y >= Graphics.height / 2
  134.         self.y = @message_window.y - contents_height + item_height / 2 - Galv_Choice::CHOICES_Y
  135.       else
  136.         self.y = @message_window.y + @message_window.height + item_height / 2 + Galv_Choice::CHOICES_Y
  137.       end
  138.     end
  139.   end
  140.  
  141.   alias galv_choice_contents_height contents_height
  142.   def contents_height
  143.     if $game_switches[Galv_Choice::DISABLE_SWITCH]
  144.       galv_choice_contents_height
  145.     else
  146.       (item_max + 1) * item_height
  147.     end
  148.   end
  149.  
  150.   def draw_item(index)
  151.     rect = item_rect_for_text(index)
  152.     draw_text_ex(rect.x, rect.y, command_name(index))
  153.     if !$game_switches[Galv_Choice::DISABLE_SWITCH]
  154.       draw_bgs(index)
  155.     end
  156.   end
  157.  
  158.   def item_rect_for_text(index)
  159.     rect = item_rect(index)
  160.  
  161.     if $game_switches[Galv_Choice::DISABLE_SWITCH]
  162.       rect.x += 4
  163.       rect.width -= 8
  164.       rect
  165.     else
  166.       if Galv_Choice::CENTER_TEXT
  167.         rect.x = (max_choice_width - @text_sizes.collect {|s| text_size(s).width }[index] + (padding * 3)) / 2
  168.       else
  169.         rect.x += 4
  170.       end
  171.       rect.width -= 8
  172.       rect.y += Galv_Choice::CHOICE_ITEM_Y
  173.       rect
  174.     end
  175.   end
  176.  
  177.   def get_widths
  178.     @text_sizes = []
  179.     @choice_background = []
  180.     $game_message.choices.each_with_index do |c,i|
  181.       @text_sizes[i] = esc_characters(c,i)
  182.     end
  183.   end
  184.  
  185.   def esc_characters(text,index)
  186.     result = text.to_s.clone
  187.     result.gsub!(/\\/)            { "\e" }
  188.     result.gsub!(/\e\e/)          { "\\" }
  189.     result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
  190.     result.gsub!(/\eN\[(\d+)\]/i) { $game_actors[$1.to_i].name}
  191.     result.gsub!(/\eP\[(\d+)\]/i) {
  192.       if $game_party.members[$1.to_i].nil?
  193.         ""
  194.       else
  195.         $game_party.members[$1.to_i].name
  196.       end
  197.     }
  198.     result.gsub!(/\eG/i)          { Vocab::currency_unit }
  199.     result.gsub!(/\eC\[(\d+)\]/i)  { "" }
  200.     result.gsub!(/\eI\[(\d+)\]/i)  { "   " }
  201.     result.gsub!(/\eB\[(\d+)\]/i)  { @choice_background[index] = $1.to_i }
  202.     result.gsub!(/\eB\[(\d+)\]/i)  { "" }
  203.     result
  204.   end
  205.  
  206.   def convert_escape_characters(text)
  207.     result = text.to_s.clone
  208.     result.gsub!(/\\/)            { "\e" }
  209.     result.gsub!(/\e\e/)          { "\\" }
  210.     result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
  211.     result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
  212.     result.gsub!(/\eN\[(\d+)\]/i) { actor_name($1.to_i) }
  213.     result.gsub!(/\eP\[(\d+)\]/i) { party_member_name($1.to_i) }
  214.     result.gsub!(/\eG/i)          { Vocab::currency_unit }
  215.     result.gsub!(/\eB\[(\d+)\]/i)  { "" }
  216.     result
  217.   end
  218.  
  219.   def item_height
  220.     return line_height if $game_switches[Galv_Choice::DISABLE_SWITCH]
  221.     return Galv_Choice::CHOICE_HEIGHT
  222.   end
  223.  
  224.   def item_rect(index)
  225.     rect = Rect.new
  226.     rect.width = item_width
  227.     rect.height = item_height - 15
  228.     rect.height += 15 if $game_switches[Galv_Choice::DISABLE_SWITCH]
  229.     rect.x = index % col_max * (item_width + spacing)
  230.     rect.y = index / col_max * item_height
  231.     rect
  232.   end
  233.  
  234.   def draw_bgs(index)
  235.     return if @choice_sprite[index] != nil
  236.  
  237.     if @choice_background[index].nil?
  238.       b = ""
  239.     else
  240.       b = @choice_background[index]
  241.     end
  242.     @choice_sprite[index] = Sprite.new
  243.     @choice_sprite[index].bitmap = Cache.system(Galv_Choice::CHOICE_IMAGE + b.to_s)
  244.     @choice_sprite[index].x = index % col_max * (item_width + spacing)
  245.     @choice_sprite[index].y = index / col_max * item_height
  246.     @choice_sprite[index].z = self.z - 2
  247.   end
  248.  
  249.   def update_bgs
  250.     @choice_sprite.each_with_index do |s,i|
  251.       s.y = self.y + i * Galv_Choice::CHOICE_HEIGHT + Galv_Choice::IMAGE_Y_OFFSET
  252.       s.x = (Graphics.width - s.width) / 2
  253.       s.opacity = Galv_Choice::IMAGE_OPACITY
  254.     end
  255.   end
  256.  
  257.   def dispose_bgs
  258.     @choice_sprite.each_with_index do |s,i|
  259.       s.dispose
  260.       s.bitmap.dispose
  261.     end
  262.     if !$game_switches[Galv_Choice::DISABLE_SWITCH]
  263.       @cursor_sprite.dispose
  264.       @cursor_sprite.bitmap.dispose
  265.       @choice_sprite = []
  266.     end
  267.   end
  268.  
  269.   alias galv_choice_call_ok_handler call_ok_handler
  270.   def call_ok_handler
  271.     galv_choice_call_ok_handler
  272.     dispose_bgs
  273.   end
  274.   alias galv_choice_call_cancel_handler call_cancel_handler
  275.   def call_cancel_handler
  276.     galv_choice_call_cancel_handler
  277.     dispose_bgs
  278.   end
  279.  
  280.   def update_cursor
  281.     if $game_switches[Galv_Choice::DISABLE_SWITCH]
  282.       super
  283.     else
  284.       cursor_rect.empty
  285.       return if @cursor_sprite.nil? || @choice_sprite.nil?
  286.       if @index < 0
  287.         @cursor_sprite.opacity = 0
  288.       else
  289.         @cursor_sprite.opacity = Galv_Choice::CURSOR_OPACITY
  290.         @cursor_sprite.x = @choice_sprite[@index].x + Galv_Choice::CURSOR_X_OFFSET
  291.         @cursor_sprite.y = @choice_sprite[@index].y + Galv_Choice::CURSOR_Y_OFFSET
  292.         @cursor_sprite.z = self.z - 1
  293.         cursor_rect.y = (item_height * @index) + Galv_Choice::OTHER_Y_OFFSET
  294.       end
  295.     end
  296.   end
  297.  
  298. end # Window_ChoiceList < Window_Command

Lv5.捕梦者 (暗夜天使)

只有笨蛋才会看到

梦石
1
星屑
21631
在线时间
9415 小时
注册时间
2012-6-19
帖子
7118

开拓者短篇九导演组冠军

2
发表于 2014-1-17 22:23:31 | 只看该作者
文字与选项位置不同是什么意思?
能截下图么?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
154 小时
注册时间
2013-12-20
帖子
66
3
 楼主| 发表于 2014-1-18 09:19:01 | 只看该作者
喵呜喵5 发表于 2014-1-17 22:23
文字与选项位置不同是什么意思?
能截下图么?

因为我使用的边框是暗色背景
于是会出现这样的情况:
文字出现在边框的边缘,
如果把边框调高,
两个选项就会重合,感觉不太美观

QQ图片20131209203323.jpg (16.65 KB, 下载次数: 17)

QQ图片20131209203323.jpg

点评

修改等号后面的数字……  发表于 2014-1-18 20:16
回复 支持 反对

使用道具 举报

Lv5.捕梦者 (暗夜天使)

只有笨蛋才会看到

梦石
1
星屑
21631
在线时间
9415 小时
注册时间
2012-6-19
帖子
7118

开拓者短篇九导演组冠军

4
发表于 2014-1-18 14:21:04 | 只看该作者
丽塔菌 发表于 2014-1-18 09:19
因为我使用的边框是暗色背景
于是会出现这样的情况:
文字出现在边框的边缘,

尝试修改脚本60、63、64行

点评

请问这几行分别是修改什么呢?  发表于 2014-1-18 20:12

评分

参与人数 1星屑 +150 收起 理由
Sion + 150 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-16 13:50

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表