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

Project1

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

[已经过期] 弹出式对话框的控制符问题

[复制链接]

Lv4.逐梦者

梦石
10
星屑
5758
在线时间
1851 小时
注册时间
2013-2-14
帖子
395

开拓者

跳转到指定楼层
1
发表于 2014-12-31 20:44:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
使用弹出式对话框,在对话里加控制符会自动加长对话框位置,后面空出空位很不好看,请问有什么办法解决吗?

RUBY 代码复制
  1. #==============================================================================
  2. #
  3. # ¥ Yami Engine Ace - Pop Message
  4. # -- Last Updated: 2012.06.07
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YSE-PopMessage"] = true
  12.  
  13. #==============================================================================
  14. # ¥ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.06.07 - Fixed Compatible: YEA - Ace Message System.
  17. # 2012.05.11 - Fixed Message Position.
  18. #            - Remove Requirement: YSE - Fix Events Order.
  19. # 2012.05.07 - Fixed Face position.
  20. #            - Added Requirement: YSE - Fix Events Order.
  21. # 2012.04.06 - You can change Bubble Tag filename.
  22. # 2012.03.28 - Fixed Default Message Position and Sizes.
  23. # 2012.03.27 - Fixed Default Message.
  24. # 2012.03.27 - Added Bubble Tag.
  25. # 2012.03.25 - Fixed Escape Message.
  26. # 2012.03.24 - Fixed Battle Message.
  27. # 2012.03.24 - Rewrote script.
  28. #
  29. #==============================================================================
  30. # ¥ Instructions
  31. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  32. # To install this script, open up your script editor and copy/paste this script
  33. # to an open slot below ¥ Materials/‘fÞ but above ¥ Main. Remember to save.
  34. #
  35. # -----------------------------------------------------------------------------
  36. # Message Window text Codes - These go inside of your message window.
  37. # -----------------------------------------------------------------------------
  38. #  Position:   Effect:
  39. #    \bm[x]    - Sets Message Window position to event x. *Note
  40. #    \cbm      - Cancel bubble message.
  41. #
  42. #              *Note: Set to 0 to sets position to Game Player.
  43. #
  44. #==============================================================================
  45. # ¥ Compatibility
  46. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  47. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  48. # it will run with RPG Maker VX without adjusting.
  49. #
  50. #==============================================================================
  51.  
  52. module YSE
  53.   module POP_MESSAGE
  54.  
  55.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  56.     # - Visual Settings -
  57.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  58.     LIMIT = { # Start.
  59.       :limit_width    =>  0,  # Set to 0 to disable limit.
  60.       :limit_line     =>  6,  # Set to 0 to disable limit.
  61.     } # End.
  62.  
  63.     POSITION = { # Start.
  64.       :x_buffer       =>  0,
  65.       :y_buffer       =>  -36,
  66.       :face_x_buffer  =>  8,
  67.       :face_y_buffer  =>  24,
  68.       :tag_y_buffer   =>  -6,
  69.       :name_x_buffer  =>  112, # Require YEA - Message System.
  70.     } # End.
  71.  
  72.     EFFECT = { # Start.
  73.       :fade_face       =>  true,
  74.       :move_face       =>  true,
  75.       :use_bubble_tag  =>  true,
  76.       :bubble_tag_name => "BubbleTag",
  77.     } # End.
  78.  
  79.   end
  80. end
  81.  
  82. #==============================================================================
  83. # ¥ Editting anything past this point may potentially result in causing
  84. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  85. # halitosis so edit at your own risk.
  86. #==============================================================================
  87.  
  88. #==============================================================================
  89. # ¡ Spriteset_Map
  90. #==============================================================================
  91.  
  92. class Spriteset_Map
  93.  
  94.   #--------------------------------------------------------------------------
  95.   # public instance variables
  96.   #--------------------------------------------------------------------------
  97.   attr_accessor :character_sprites
  98.  
  99. end # Spriteset_Map
  100.  
  101. #==============================================================================
  102. # ¡ Window_Message_Face
  103. #==============================================================================
  104.  
  105. class Window_Message_Face < Window_Base
  106.  
  107.   #--------------------------------------------------------------------------
  108.   # initialize
  109.   #--------------------------------------------------------------------------
  110.   def initialize
  111.     super(0, 0, 120, 120)
  112.     self.opacity = 0
  113.     @face_name = ""
  114.     @face_index = 0
  115.     @move_x = 0
  116.     close
  117.   end
  118.  
  119.   #--------------------------------------------------------------------------
  120.   # message_window=
  121.   #--------------------------------------------------------------------------
  122.   def message_window=(window)
  123.     @message_window = window
  124.   end
  125.  
  126.   #--------------------------------------------------------------------------
  127.   # set_face
  128.   #--------------------------------------------------------------------------
  129.   def set_face
  130.     contents.clear
  131.     return unless @message_window
  132.     if !$game_message.face_name.empty?
  133.       draw_face($game_message.face_name, $game_message.face_index, 0, 0)
  134.       set_position
  135.       show_face
  136.     else
  137.       hide_face
  138.     end
  139.   end
  140.  
  141.   #--------------------------------------------------------------------------
  142.   # set_position
  143.   #--------------------------------------------------------------------------
  144.   def set_position
  145.     return unless @message_window
  146.     self.x = @message_window.x
  147.     self.y = @message_window.y - 96
  148.     self.x += YSE::POP_MESSAGE::POSITION[:face_x_buffer]
  149.     self.y += YSE::POP_MESSAGE::POSITION[:face_y_buffer]
  150.     self.y += (@message_window.real_lines - 1) * 24
  151.     self.z = @message_window.z + 1
  152.     if (@face_name != $game_message.face_name || @face_index != $game_message.face_index)
  153.       if YSE::POP_MESSAGE::EFFECT[:move_face]
  154.         @move_x = 30
  155.         self.x -= 30
  156.       end
  157.       @face_name = $game_message.face_name
  158.       @face_index = $game_message.face_index
  159.       self.contents_opacity = 0 if YSE::POP_MESSAGE::EFFECT[:fade_face]
  160.     end
  161.   end
  162.  
  163.   #--------------------------------------------------------------------------
  164.   # show_face
  165.   #--------------------------------------------------------------------------
  166.   def show_face
  167.     open
  168.   end
  169.  
  170.   #--------------------------------------------------------------------------
  171.   # hide_face
  172.   #--------------------------------------------------------------------------
  173.   def hide_face
  174.     contents.clear
  175.     close
  176.   end
  177.  
  178.   #--------------------------------------------------------------------------
  179.   # update
  180.   #--------------------------------------------------------------------------
  181.   def update
  182.     super
  183.     self.contents_opacity += 15 if self.contents_opacity < 255
  184.     unless @move_x <= 0
  185.       self.x += 2
  186.       @move_x -= 2
  187.     end
  188.   end
  189.  
  190. end # Sprite_Message_Face
  191.  
  192. #==============================================================================
  193. # ¡ Window_Message
  194. #==============================================================================
  195.  
  196. class Window_Message < Window_Base
  197.  
  198.   #--------------------------------------------------------------------------
  199.   # new method: face_window=
  200.   #--------------------------------------------------------------------------
  201.   def face_window=(window)
  202.     @face_window = window
  203.   end
  204.  
  205.   #--------------------------------------------------------------------------
  206.   # new method: bubble_tag=
  207.   #--------------------------------------------------------------------------
  208.   def bubble_tag=(sprite)
  209.     @bubble_tag = sprite
  210.   end
  211.  
  212.   #--------------------------------------------------------------------------
  213.   # new method: message_escape_characters_pop_message
  214.   #--------------------------------------------------------------------------
  215.   def message_escape_characters_pop_message(result)
  216.     result.gsub!(/\eBM\[(\d+)\]/i) { event_pop_message_setup($1.to_i, false) }
  217.     result.gsub!(/\eBMF\[(\d+)\]/i) { event_pop_message_setup($1.to_i, true) }
  218.     result.gsub!(/\eCBM/i) { event_pop_message_setup(nil, false) }
  219.     result
  220.   end
  221.  
  222.   #--------------------------------------------------------------------------
  223.   # alias method: convert_escape_characters
  224.   #--------------------------------------------------------------------------
  225.   alias yse_convert_escape_characters_pm convert_escape_characters
  226.   def convert_escape_characters(text)
  227.     result = yse_convert_escape_characters_pm(text)
  228.     result = message_escape_characters_pop_message(result)
  229.     result
  230.   end
  231.  
  232.   #--------------------------------------------------------------------------
  233.   # new method: event_pop_message_setup
  234.   #--------------------------------------------------------------------------
  235.   def event_pop_message_setup(event_id, follower = false)
  236.     if follower && $game_player.followers[event_id].nil?
  237.       @event_pop_id = nil
  238.       @event_pop_follower = false
  239.       return ""
  240.     end
  241.     @event_pop_follower = follower
  242.     @event_pop_id = event_id
  243.     return ""
  244.   end
  245.  
  246.   #--------------------------------------------------------------------------
  247.   # new method: set_face_position
  248.   #--------------------------------------------------------------------------
  249.   def set_face_position
  250.     return unless SceneManager.scene_is?(Scene_Map)
  251.     return unless @event_pop_id
  252.     return unless @face_window
  253.     contents.clear
  254.     @face_window.set_face
  255.     return unless $imported["YEA-MessageSystem"]
  256.     return if @face_window.close?
  257.     #@name_window.x = self.x + YSE::POP_MESSAGE::POSITION[:face_x_buffer] + YSE::POP_MESSAGE::POSITION[:name_x_buffer] if (@name_position == 1 || @name_position == 2)
  258.   end
  259.  
  260.   #--------------------------------------------------------------------------
  261.   # alias method: new_page
  262.   #--------------------------------------------------------------------------
  263.   alias window_message_new_page_pm_yse new_page
  264.   def new_page(text, pos)
  265.     window_message_new_page_pm_yse(text, pos)
  266.     set_face_position
  267.   end
  268.  
  269.   #--------------------------------------------------------------------------
  270.   # alias method: close
  271.   #--------------------------------------------------------------------------
  272.   alias pop_message_close close
  273.   def close
  274.     pop_message_close
  275.     return unless SceneManager.scene_is?(Scene_Map)
  276.     return unless @event_pop_id
  277.     @event_pop_id = nil
  278.     @event_pop_follower = false
  279.     @face_window.hide_face
  280.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  281.     @bubble_tag.visible = false if @bubble_tag
  282.   end
  283.  
  284.   #--------------------------------------------------------------------------
  285.   # alias method: open_and_wait
  286.   #--------------------------------------------------------------------------
  287.   alias pop_message_open_and_wait open_and_wait
  288.   def open_and_wait
  289.     pop_message_open_and_wait
  290.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  291.     @bubble_tag.visible = true if @event_pop_id && @bubble_tag
  292.   end
  293.  
  294.   #--------------------------------------------------------------------------
  295.   # alias method: process_all_text
  296.   #--------------------------------------------------------------------------
  297.   alias pop_message_process_all_text process_all_text
  298.   def process_all_text
  299.     @event_pop_id = nil
  300.     convert_escape_characters($game_message.all_text)
  301.     update_placement
  302.     adjust_pop_message($game_message.all_text)
  303.     pop_message_process_all_text
  304.   end
  305.  
  306.   #--------------------------------------------------------------------------
  307.   # alias method: update_placement
  308.   #--------------------------------------------------------------------------
  309.   alias event_pop_message_update_placement update_placement
  310.   def update_placement
  311.     if SceneManager.scene_is?(Scene_Map)
  312.       if @event_pop_id.nil?
  313.         fix_default_message
  314.         event_pop_message_update_placement
  315.       elsif @event_pop_id == 0
  316.         character = $game_player
  317.         self.y = character.screen_y - self.height + YSE::POP_MESSAGE::POSITION[:y_buffer]
  318.         self.x = character.screen_x - self.width / 2 + YSE::POP_MESSAGE::POSITION[:x_buffer]
  319.         fix_position_bubble(character)
  320.         set_bubble_tag(character)
  321.       elsif @event_pop_id > 0
  322.         hash = @event_pop_follower ? $game_player.followers : $game_map.events
  323.         character = hash[@event_pop_id]
  324.         self.y = character.screen_y - self.height + YSE::POP_MESSAGE::POSITION[:y_buffer]
  325.         self.x = character.screen_x - self.width / 2 + YSE::POP_MESSAGE::POSITION[:x_buffer]
  326.         fix_position_bubble(character)
  327.         set_bubble_tag(character)
  328.       end
  329.     else
  330.       event_pop_message_update_placement
  331.     end
  332.   end
  333.  
  334.   #--------------------------------------------------------------------------
  335.   # new method: fix_default_message
  336.   #--------------------------------------------------------------------------
  337.   def fix_default_message
  338.     self.width = window_width
  339.     self.height = window_height
  340.     self.x = 0
  341.     @face_window.hide_face if @face_window
  342.     create_contents
  343.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  344.     @bubble_tag.visible = false if @bubble_tag
  345.   end
  346.  
  347.   #--------------------------------------------------------------------------
  348.   # new method: fix_position_bubble
  349.   #--------------------------------------------------------------------------
  350.   def fix_position_bubble(character)
  351.     end_x = self.x + self.width
  352.     end_y = self.y + self.height
  353.     self.x = 0 if self.x < 0
  354.     self.y = character.screen_y if self.y < 0
  355.     self.x = Graphics.width - self.width if end_x > Graphics.width
  356.     self.y = Graphics.height - self.height if end_y > Graphics.height
  357.   end
  358.  
  359.   #--------------------------------------------------------------------------
  360.   # new method: set_bubble_tag
  361.   #--------------------------------------------------------------------------
  362.   def set_bubble_tag(character)
  363.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  364.     return unless @bubble_tag
  365.     up = self.y == character.screen_y
  366.     self.y += up ? @bubble_tag.height / 2 : [email]-@bubble_tag.height[/email] / 2
  367.     @bubble_tag.x = character.screen_x - @bubble_tag.width / 2
  368.     if up
  369.       @bubble_tag.src_rect.set(0, @bubble_tag.height, @bubble_tag.width, @bubble_tag.height)
  370.       @bubble_tag.y = self.y - @bubble_tag.height - YSE::POP_MESSAGE::POSITION[:tag_y_buffer]
  371.     else
  372.       @bubble_tag.src_rect.set(0, 0, @bubble_tag.width, @bubble_tag.height)
  373.       @bubble_tag.y = self.y + self.height + YSE::POP_MESSAGE::POSITION[:tag_y_buffer]
  374.     end
  375.   end
  376.  
  377.   #--------------------------------------------------------------------------
  378.   # new method: cal_number_line
  379.   #--------------------------------------------------------------------------
  380.   def cal_number_line(text)
  381.     result = 0
  382.     text.each_line { result += 1 }
  383.     return result
  384.   end
  385.  
  386.   #--------------------------------------------------------------------------
  387.   # new method: cal_width_line
  388.   #--------------------------------------------------------------------------
  389.   def cal_width_line(text)
  390.     result = 0
  391.     text.each_line { |line|
  392.       result = text_size(line).width if result < text_size(line).width
  393.     }
  394.     return result
  395.   end
  396.  
  397.   #--------------------------------------------------------------------------
  398.   # alias method: adjust_message_window_size
  399.   #--------------------------------------------------------------------------
  400.   if $imported["YEA-MessageSystem"]
  401.   alias yse_pop_message_adjust_message_window_size adjust_message_window_size
  402.   def adjust_message_window_size
  403.     start_name_window if @event_pop_id
  404.     return if @event_pop_id
  405.     yse_pop_message_adjust_message_window_size
  406.   end
  407.   end
  408.  
  409.   #--------------------------------------------------------------------------
  410.   # new method: adjust_pop_message
  411.   #--------------------------------------------------------------------------
  412.   def adjust_pop_message(text = " ")
  413.     return unless SceneManager.scene_is?(Scene_Map)
  414.     unless @event_pop_id
  415.       if $imported["YEA-MessageSystem"]
  416.         #adjust_message_window_size
  417.       end
  418.       return
  419.     end
  420.     n_line = cal_number_line(text)
  421.     n_line = YSE::POP_MESSAGE::LIMIT[:limit_line] if YSE::POP_MESSAGE::LIMIT[:limit_line] > 0 && cal_number_line(text) > YSE::POP_MESSAGE::LIMIT[:limit_line]
  422.     @real_lines = n_line
  423.     self.height = fitting_height(n_line)
  424.     self.width = cal_width_line(text) + 24
  425.     self.width += new_line_x
  426.     if self.width > YSE::POP_MESSAGE::LIMIT[:limit_width] && YSE::POP_MESSAGE::LIMIT[:limit_width] > 0
  427.       self.width = YSE::POP_MESSAGE::LIMIT[:limit_width]
  428.     end
  429.     create_contents
  430.     update_placement
  431.   end
  432.  
  433.   #--------------------------------------------------------------------------
  434.   # overwrite method: new_line_x
  435.   #--------------------------------------------------------------------------
  436.   def new_line_x
  437.     if $game_message.face_name.empty?
  438.       return 0
  439.     else
  440.       result = YSE::POP_MESSAGE::POSITION[:face_x_buffer]
  441.       p_x = $imported["YEA-MessageSystem"] ? YEA::MESSAGE::FACE_INDENT_X : 112
  442.       result += p_x
  443.       return result
  444.     end
  445.   end
  446.  
  447.   #--------------------------------------------------------------------------
  448.   # new method: real_lines
  449.   #--------------------------------------------------------------------------
  450.   def real_lines
  451.     @real_lines
  452.   end
  453.  
  454. end # Window_Message
  455.  
  456. #==============================================================================
  457. # ¡ Scene_Map
  458. #==============================================================================
  459.  
  460. class Scene_Map < Scene_Base
  461.  
  462.   #--------------------------------------------------------------------------
  463.   # alias method: create_message_window
  464.   #--------------------------------------------------------------------------
  465.   alias yse_pm_create_message_window create_message_window
  466.   def create_message_window
  467.     yse_pm_create_message_window
  468.     @face_window = Window_Message_Face.new
  469.     @face_window.message_window = @message_window
  470.     if YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  471.       @bubble_tag_sprite = Sprite.new
  472.       @bubble_tag_sprite.visible = false
  473.       @bubble_tag_sprite.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT[:bubble_tag_name])
  474.       @bubble_tag_sprite.src_rect.set(0, 0, @bubble_tag_sprite.width, @bubble_tag_sprite.height / 2)
  475.       @message_window.bubble_tag = @bubble_tag_sprite
  476.     end
  477.     @message_window.face_window = @face_window
  478.   end
  479.  
  480.   #--------------------------------------------------------------------------
  481.   # alias method: dispose_spriteset
  482.   #--------------------------------------------------------------------------
  483.   alias pop_message_dispose_spriteset dispose_spriteset
  484.   def dispose_spriteset
  485.     pop_message_dispose_spriteset
  486.     return unless @bubble_tag_sprite
  487.     @bubble_tag_sprite.dispose
  488.   end
  489.  
  490. end # Scene_Map
  491.  
  492. #==============================================================================
  493. #
  494. # ¥ End of File
  495. #
  496. #==============================================================================

Lv3.寻梦者 (版主)

…あたしは天使なんかじゃないわ

梦石
0
星屑
2208
在线时间
4033 小时
注册时间
2010-10-4
帖子
10779

开拓者贵宾

2
发表于 2014-12-31 20:47:41 | 只看该作者
仅供参考。不保证可以解决,但解决思路就是这个。

https://rpg.blue/thread-233548-1-1.html

点评

好吧,我研究下,谢谢。。  发表于 2015-1-1 17:40
看得懂的话,就不需要指点;看不懂这段脚本的话,指点也没用  发表于 2015-1-1 17:35
没有用,求指点。。  发表于 2015-1-1 17:34
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-15 15:15

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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