查看: 12030|回复: 7

[已经解决] 关于Yami - Pop Message + Quack的问题

[复制链接]
梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
发表于 2020-9-17 16:24:57 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 alexncf125 于 2020-9-17 17:16 编辑

@RaidenInfinity
https://rpg.blue/thread-397856-1-1.html

同样是窗口宽度计算了转义符宽度的问题
如果刪了Quack的, 在Yami的改, 问题得到解決
但不刪Quack的, 我改Quack的成这样子后, 问题仍然存在
  1. def adjust_pop_message(text = " ")
  2.     #return unless SceneManager.scene_is?(Scene_Map)
  3.     unless @event_pop_id
  4.       if $imported["YEA-MessageSystem"]
  5.         adjust_message_window_size
  6.       end
  7.       return
  8.     end
  9.     n_line = cal_number_line(text)
  10.     text = text.split("\n").each{|s| s.gsub!(/\\\w*\[\w*\]/i,'')}.sort_by!{|s| s.length}.pop
  11.     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]
  12.     @real_lines = n_line
  13.     self.height = fitting_height(n_line)
  14.     self.height += @msg_size_y
  15.     self.width = cal_width_line(text) + 10
  16.     self.width += @msg_size_x
  17.     self.width += new_line_x
  18.     if self.width > YSE::POP_MESSAGE::LIMIT[:limit_width] && YSE::POP_MESSAGE::LIMIT[:limit_width] > 0
  19.       self.width = YSE::POP_MESSAGE::LIMIT[:limit_width]
  20.     end
  21.     if $game_message.choice? && !QUACK::MSG::POP_CHOICE_GROW
  22.       dy = fitting_height($game_message.choices.size) - 16
  23.       self.y -= dy - 16
  24.       self.height += dy - 16
  25.       @face_window.y -= dy - 16
  26.       @name_window.y -= dy - 16 if $imported["YEA-MessageSystem"]
  27.     end
  28.     # If a chatter message with face graphic, force height to be at least big enough to show the face.
  29.     if chatter? && !source.face_name.empty?
  30.       self.height = [self.height, 86].max
  31.     end
  32.    
  33.     create_contents
  34.     update_placement
  35.   end
复制代码


https://rpg.blue/thread-405406-1-1.html
工程里的兩个Quack脚本刪掉, 換成下方v1.4的
  1. =begin
  2. #==============================================================================
  3. * Chatter Messages (Yami's Pop Messages Addon) - v1.4
  4.   Author: Quack
  5. #==============================================================================
  6. What it does:
  7. 1-Allows you to use 'chatter' messageboxes. The difference from normal messages
  8.   is that they don't pause the game and don't close by pressing the action key.
  9.   Instead you provide the message with a timer and it will close automically
  10.   when the time is up. Another difference is that several chatter messages can
  11.   be active at once (though there is a limit (7 by default) which you can adjust
  12.   by chaning MAX_MSGS a bit lower down).
  13.   To make a message into 'chatter' use the '<cm:X>' tag in your message, where X
  14.   is the duration in seconds (IMPORTANT: THIS TAG HAS TO BE ON THE FIRST LINE
  15.   OF THE MESSAGE TO WORK).
  16.   Set X to a negative number and the message will last forever.
  17.   You can use this method in a script call to close all chatter messages:
  18.   clear_chatter
  19.   
  20. 2-By default Pop messages show a speech bubble tag of sorts so it's easier to
  21.   see which character the message belongs to.
  22.   I changed that code a bit and added option of showing a speech bubble tag or
  23.   thought bubble tag for the chose character.
  24.   Speech bubble tag is the same message tag as previous: \bm[x]
  25.   While thought bubble tag is: \bmt[x]
  26.   
  27. 3-By defauult Pop messages don't work during combat. Now they do.
  28.   It works mostly like normal. Use \bm[x] or \bmt[x] to show a pop message.
  29.   The difference is that to apply the pop message to an enemy, make x a positive
  30.   number. So enemy 1 \bm[1] and enemy 4 would be \bm[4]
  31.   Meanwhile actors use negative numbers. Like so: actor 1= \bm[-1]
  32.   HOWEVER, for pop messages to work for actors they needed to have a visual
  33.   battler. And I can't guarantee it will work with all actor battler scripts.
  34.   The only one I can guarantee works is Jet's sideview battlers since it's what
  35.   I use.
  36.   One problem with Pop messages in battler is that if a battle has a different
  37.   size than a normal character sprite the message box will get a bit missplaced.
  38.   To fix that I added to other messagebox tags to use to change the position.
  39.   \ox[X] - Offsets the messagebox position horizontally by X pixels.
  40.   \oy[X] - Offsets the messagebox position vertically by X pixels.

  41. Please note if you are using Yanfly's core script & Yanfly's Ace Message script
  42.   together. You need to set FONT_NAME in the core script to have the same value
  43.   as MESSAGE_WINDOW_FONT_NAME in the ace message script. Otherwise when these
  44.   two are combined it will sometimes cause the width of text to be
  45.   miss-measured. This wouldn't cause much of a problem normally, but when using
  46.   pop messages which measure the width of the text to set the width of the
  47.   message box it can cause big problems. (the other font settings on the two
  48.   scripts (that is bold, italic, shadow and outline) should preferably also be
  49.   the same on both)
  50.   
  51. VERSION 1.1 ADDITIONS:

  52. 1-Added text sound. You can add different text sounds in the TEXT_SOUNDS hash
  53.   in the config area (further instructions on adding sounds there). By default
  54.   messages won't have sound. To add it use this tag: <ts:x>   where x is a key
  55.   that exists in the TEXT_SOUNDS hash.
  56.   
  57. 2-Added Message box background tones. This allows you to specify different
  58.   background colors for your message boxes. You can add different tones in the
  59.   WINDOW_TONES has in the config area (further instructions on adding tones
  60.   there). By default it will use the normal window tone. To use one of the tones
  61.   in the WINDOW_TONES has use this tag: <bc:x>  where x is a key that exists in
  62.   the WINDOW_TONES hash.

  63. 3-Sometimes you might want to change font size in your message, multiple times,
  64.   or do other things that might affect the size required by your message and
  65.   therefore cause the size of the message window too be to big or too small. So
  66.   I added a tag to use to adjust the message window size: <pms:x,y> . It changes
  67.   Pop Message Size, adjusting the width by x and height by y. So if you put
  68.   <pms:20,-10> in your message it will increase the width of the window by 20
  69.   and decrease the height by 10.
  70.   
  71. 4-If you're like me you think it's annoying to have to remember which event has
  72.   what id when writing messages and it's further annoying to have to write so
  73.   many tags for each message. That is why I made it so now in my game using this
  74.   script I can position my pop message on the event I want and make it use the
  75.   background color and text sound that I want just by entering this tag:
  76.   <bt:x> (for speech bubble)  OR <btt:x> (for thought bubble)
  77.   How does that work you might ask?
  78.   Well lets say I have an event which is supposed to be one of my actors. Let's
  79.   call the actor Emil. In the name box of the event I put the tag: <emil>.
  80.   Now when I use the tags: <bt:emil> or <btt:emil>  the pop message will get
  81.   placed on that event. And if WINDOW_TONES has a value with the key 'emil',
  82.   that window tone will be used too. Same for TEXT_SOUNDS except if you are
  83.   using btt because thoughts shouldn't make sound now should they?
  84.   Doesn't that sound so much easier?
  85.   It will also make it easier to tell which event is saying a text when looking
  86.   at the event command in the editor since you know who 'emil' is but might not
  87.   be able to as easily tell which event '72' is.
  88.   
  89.   You can also specify the player with these tags by using 'pl', like so:
  90.   <bt:pl>
  91.   The reason I added this was to allow setting window tone and text sound for
  92.   player as well. This probably won't be all to useful in most cases since
  93.   the showing actor for the party might vary but I figured I should still add
  94.   the functionality.
  95.   
  96.   If you are wondering why all my new tags use different structure than the
  97.   previously existing ones then well.... because! Consistence is overrated
  98.   anyway, who needs it?
  99.   
  100.   Using these these two tags (<bt:x> & <btt:x>) does however require the
  101.   functionality of one of my other scripts, called Qonvenience (guess you could
  102.   kind of call it my 'core' script like how other scripters have (Yanfly,
  103.   Victor, Yami, etc).
  104.   You can find a link to it under the 'Requirements' section.
  105.   
  106. VERSION 1.2 ADDITIONS:

  107. -When showing choices it will appear differently depending on if the open
  108.   game_message is a pop message or not. If it is not it will display like normal.
  109.   But if it is a pop message the message window will be made bigger and the
  110.   choices will be displayed inside the message window.
  111.   
  112. VERSION 1.3:

  113. -Fixed some problems with faces graphics and nameboxes. It's still not perfect
  114.   but I wrote this script for a project of mine where I don't use nameboxes
  115.   or face graphics so I don't really want to put too much effort into features
  116.   I'm not personally interested in.
  117.   
  118. -Like with window tones and text sounds, you can now associate namebox names to
  119.   a tag.
  120.   
  121. -Position adjustments can also be be associated to a nametag now using POS_ADJUST.
  122.   
  123. ==============================================================================
  124. Instructions/Install notes:
  125. Requires Yami's Pop messages to work.
  126. Paste it below Yami's Pop messages script.

  127. ==============================================================================
  128. Requirements:
  129. Requires Yami's Pop messages to work. You can find it here:
  130. ​[url]https://github.com/suppayami/rmvxa-collection/blob/master/yami-script-ace/10%20-%20Pop%20Message.txt[/url]
  131. Also requires my script Qonvenience if you plan on using the message tags
  132. <bt:x> and <btt:x>
  133. Find it here:
  134. [url]http://pastebin.com/J6haUy5T[/url]

  135. ==============================================================================
  136. Credits:
  137. Yami for making Pop messages.

  138. ==============================================================================
  139. Terms of Use:
  140. Use it however you wish (yes, that does include commercial projects), as long
  141. as you do not claim it as your own code. I would also prefer you mention me in
  142. your credits if you do decide to use it.
  143. However do remember that this script relies on Yami's pop messages script which
  144. has it has it's own separate terms of use.

  145. ==============================================================================
  146. Bugs:
  147. dunno

  148. ==============================================================================
  149. History:
  150. 13/06/2018 - Fixed some things. Hopefully it isnt completely broken anymore.
  151. 11/10/2016 - Fixed some problems added some minor feature.
  152. 19/01/2016 - Fixed some bugs, changes to choices when a pop message is used.
  153. 14/01/2016 - Chatter messages now last forever if you set the duration to a
  154.              negative number. Also added method for clearing all chatter
  155.              to use in script calls. Also squashed some bugs.
  156. 13/01/2016 - Pretty big update. Added more functionality.
  157. 10/01/2016 - Proper release since Absurdiness found the original script so I
  158.              could separate the addon from the original.
  159. 08/01/2016 - Initial release

  160. =end

  161. $imported = {} if $imported.nil?
  162. $imported["Chatter_Messages"] = true

  163. #==============================================================================
  164. # * CONFIG
  165. #==============================================================================

  166. module YSE
  167.   module POP_MESSAGE
  168.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  169.     # - Visual Settings -
  170.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  171.    
  172.     EFFECT2 = { # Start.
  173.       :bubble_tag_name => "BubbleTag_Speech",
  174.       :thought_bubble_tag_name => "BubbleTag_Thought",
  175.     } # End.
  176.   end
  177. end

  178. module QUACK
  179.   module MSG
  180.    
  181.     # Max amount of chatter messages that can be exist at the same time.
  182.     # Too few might be limiting your options and too many will clutter up
  183.     # the screen and decrease performance.
  184.     MAX_MSGS = 7
  185.    
  186.     # Used for setting the background color of messages.
  187.     # To add a tone the syntax is:
  188.     # Key => Tone.new(Red,Green,Blue,Grey)
  189.     # Where key is a string, Red,Green and Blue are numerical value from -255 to
  190.     # 255. And Grey is a value from 0 to 255. The Grey value is optional so you
  191.     # don't have to add it.
  192.     # If you are unsure how to do it just copy one of the lines, paste it below
  193.     # and edit the values.
  194.     WINDOW_TONES = {
  195.       # Add tones below this line
  196.       'reddish1' => Tone.new(85,44,51),
  197.       'bluehair' => Tone.new(-34,85,102),
  198.       'geezer' => Tone.new(68,68,68,10),
  199.       'pl' => Tone.new(102,34,-34),
  200.       'alf' => Tone.new(102,34,51),
  201.       # And above this line
  202.     }
  203.    
  204.     # The name is kind of self explanatory
  205.     # If you want to add a sound the syntax is this:
  206.     #Key => [Sound, Volume, Pitch minimum, Pitch Maximum],
  207.     # where Key is a string. Sound is the name of your sound,
  208.     # Volume, Pitch minimum and Pitch Maximum are values from 0-100.
  209.     # Text sound automatically gets disabled for thought bubbles even if text
  210.     # sound is specified.
  211.     # Just a copy a line, paste it and edit it.
  212.     TEXT_SOUNDS = {
  213.       # Add sounds below this line
  214.       '0' => nil, # DEFAULT VALUE USED FOR NO SOUND!
  215.       '1' => ["Cursor1", 80, 70, 100],
  216.       '2' => ["Cursor1", 80, 90, 120],
  217.       '3' => ["Knock", 80, 50, 75],
  218.       'bluehair' => ["Cursor1", 80, 90, 120],
  219.       'geezer' => ["Cursor1", 80, 45, 70],
  220.       'pl' => ["Cursor1", 80, 70, 100],
  221.       'alf' => ["Cursor1", 70, 110, 140],
  222.       # And above this line
  223.     }
  224.    
  225.     NAMES = {
  226.       # Add names below this line
  227.       'bluehair' => "Riverhead",
  228.       'geezer' => "Geezer"
  229.     }
  230.    
  231.     POS_ADJUST = {
  232.       'test' => [20,10]
  233.     }
  234.    
  235.     # Play sound per X characters displayed.
  236.     SOUND_PLAY_FREQUENCY = 3
  237.    
  238.     # Whether the pop message should grow to make place for choices as the text
  239.     # finishes or just have the final size immediately.
  240.     POP_CHOICE_GROW = true
  241.    
  242.   end
  243. end

  244. #==============================================================================
  245. # * SCRIPT START
  246. #==============================================================================

  247. #==============================================================================
  248. # ?! DataManager
  249. #==============================================================================
  250. module DataManager
  251.   class << self
  252.     alias quack_msg_create_game_objects create_game_objects
  253.     def create_game_objects
  254.       quack_msg_create_game_objects
  255.       if !$imported["YSE-PopMessage"]
  256.         msgbox(sprintf("This script(Chatter Messages) requires Yami's Pop Messages to function", "ChatterMessages", 1))
  257.         exit
  258.       end
  259.       $game_message.quack_msg_make
  260.     end
  261.    
  262.     alias qmsg_sng setup_new_game
  263.     def setup_new_game
  264.       $game_message.clear_chatter
  265.       qmsg_sng
  266.     end
  267.   end
  268. end

  269. #==============================================================================
  270. # ?! BattleManager
  271. #==============================================================================
  272. module BattleManager
  273.   class << self
  274.     alias qmsg_proc_victory process_victory
  275.     def process_victory
  276.       $game_message.clear_chatter
  277.       qmsg_proc_victory
  278.     end
  279.    
  280.     alias qmsg_proc_abort process_abort
  281.     def process_abort
  282.       qmsg_proc_abort
  283.       $game_message.clear_chatter
  284.     end
  285.    
  286.     alias qmsg_proc_defeat process_defeat
  287.     def process_defeat
  288.       qmsg_proc_defeat
  289.       $game_message.clear_chatter
  290.     end
  291.   end
  292. end

  293. #==============================================================================
  294. # ?! Game_Message
  295. #==============================================================================
  296. class Game_Message
  297.   attr_accessor :quack_msgs
  298.   attr_accessor :ev_id
  299.   
  300.   # new
  301.   def quack_msg_make
  302.     @quack_msgs = []
  303.     QUACK::MSG::MAX_MSGS.times {@quack_msgs.push(Game_Message.new)}
  304.     @quack_msg_ttl = 0
  305.     @c_msg = 0
  306.    
  307.     @qmsg_windows = []
  308.     QUACK::MSG::MAX_MSGS.times do |i|
  309.         qm = Window_Quack_Message.new(@quack_msgs[i], 80-QUACK::MSG::MAX_MSGS+(i*2))
  310.       @qmsg_windows.push(qm)
  311.       ss = Sprite.new
  312.       ss.visible = false
  313.       ss.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT2[:bubble_tag_name])
  314.       ss.src_rect.set(0, 0, ss.width, ss.height / 2)
  315.       qm.speech_bubble_tag = ss
  316.       ts = Sprite.new
  317.       ts.visible = false
  318.       ts.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT2[:bubble_tag_name])
  319.       ts.src_rect.set(0, 0, ts.width, ts.height / 2)
  320.       qm.thought_bubble_tag = ts
  321.     end
  322.   end
  323.   # new
  324.   def set_ttl(ttl)
  325.     @quack_msg_ttl = ttl
  326.   end
  327.   # new
  328.   def ttl_sub
  329.     @quack_msg_ttl -= 1 if @quack_msg_ttl > 0
  330.   end
  331.   # new
  332.   def expire?
  333.     return false if @quack_msg_ttl < 0
  334.     @quack_msg_ttl == 0
  335.   end
  336.   # new
  337.   def prepare_msg(duration)
  338.     @quack_msg_ttl = (duration * 60).to_i
  339.   end
  340.   # new
  341.   def fin_msg
  342.     @quack_msg_ttl = 0
  343.     @c_msg = (@c_msg + 1) % QUACK::MSG::MAX_MSGS
  344.   end
  345.   # new
  346.   def add_chatter(text)
  347.     m = @quack_msgs[@c_msg]
  348.     m.add(text)
  349.     m.face_name = face_name
  350.     m.face_index = face_index
  351.     m.set_ttl(@quack_msg_ttl)
  352.   end
  353.   # new
  354.   def clear_chatter
  355.     @quack_msgs.each {|m| m.set_ttl(0) }
  356.     @qmsg_windows.each {|w| w.close }
  357.   end
  358.   
  359.   # new
  360.   def clear_chatter_event(e_id)
  361.     # Find any chatter attached to certain event id and close the chatter
  362.     @quack_msgs.each {|m| m.set_ttl(0) if m.ev_id == e_id }
  363.   end
  364.   
  365.   # new
  366.   def update_chatter
  367.     @qmsg_windows.each {|m|
  368.       m.update
  369.       if m.open?
  370.         m.update_placement
  371.       end
  372.     }
  373.   end
  374.   # new
  375.   def hide_chatter
  376.     @qmsg_windows.each {|m|
  377.       m.hide_me
  378.     }
  379.   end
  380.   # new
  381.   def show_chatter
  382.     @qmsg_windows.each {|m|
  383.       m.show_me
  384.     }
  385.   end
  386.   
  387. end

  388. #==============================================================================
  389. # ?! Window_Message
  390. #==============================================================================

  391. class Window_Message < Window_Base
  392.   
  393.   # new
  394.   def chatter?
  395.     false
  396.   end
  397.   # new
  398.   def source
  399.     $game_message
  400.   end
  401.   # overwrite
  402.   def standard_padding
  403.     return 8
  404.   end
  405.   # alias
  406.   alias quack_chatter_init initialize
  407.   def initialize
  408.     @msg_tone = $game_system.window_tone
  409.     @snd_f = 0
  410.     #@name_text = ""
  411.     quack_chatter_init
  412.   end
  413.   # new
  414.   def speech_bubble_tag=(sprite)
  415.     @speech_bubble_tag = sprite
  416.   end
  417.   # new
  418.   def thought_bubble_tag=(sprite)
  419.     @thought_bubble_tag = sprite
  420.   end
  421.   # new
  422.   def set_offset_x(x)
  423.     @ox = x
  424.     return ""
  425.   end
  426.   # new
  427.   def set_offset_y(y)
  428.     @oy = y
  429.     return ""
  430.   end
  431.   # overwrite
  432.   def cal_width_line(text)
  433.     result = 0
  434.     text.each_line { |line|
  435.       result = text_size(line).width if result < text_size(line).width
  436.     }
  437.     return result
  438.   end
  439.   # alias
  440.   alias quack_chatter_process_character process_character
  441.   def process_character(c, text, pos)
  442.     if @snd_f == 0 && !@show_fast && !@text_sound.nil?
  443.       Audio.se_play("Audio/SE/"+@text_sound[0],@text_sound[1],@text_sound[2]+rand(@text_sound[3]-@text_sound[2]))
  444.     end
  445.     @snd_f += 1
  446.     @snd_f = 0 if @snd_f == QUACK::MSG::SOUND_PLAY_FREQUENCY
  447.     quack_chatter_process_character(c,text,pos)
  448.   end
  449.   # overwrite
  450.   def update_tone
  451.     self.tone.set(@msg_tone)
  452.   end
  453.   # overwrite
  454.   def message_escape_characters_pop_message(result)
  455.     @msg_tone = $game_system.window_tone
  456.     @event_pop_id = nil
  457.     set_offset_x(0)
  458.     set_offset_y(0)
  459.     @text_sound = QUACK::MSG::TEXT_SOUNDS['0']
  460.     @msg_size_x = 0
  461.     @msg_size_y = 0
  462.     reset_font_settings
  463.    
  464.     result.gsub!(/<BT:([^<>]*)>/i) { event_pop_message_setup2($1, false) }
  465.     result.gsub!(/<BTT:([^<>]*)>/i) { event_pop_message_setup2($1, true) }
  466.     result.gsub!(/\eOX\[([-+]?\d+)\]/i) { set_offset_x($1.to_i) }
  467.     result.gsub!(/\eOY\[([-+]?\d+)\]/i) { set_offset_y($1.to_i) }
  468.     result.gsub!(/\eBM\[([-+]?\d+)\]/i) { event_pop_message_setup($1.to_i, false) }
  469.     result.gsub!(/\eBMT\[([-+]?\d+)\]/i) { event_pop_message_setup($1.to_i, true) }
  470.     result.gsub!(/\eBMF\[(\d+)\]/i) { event_pop_message_setup($1.to_i, false, true) }
  471.     result.gsub!(/\eCBM/i) { event_pop_message_setup(nil, false) }
  472.     result.gsub!(/<BC:([^<>]*)>/i) { @msg_tone = QUACK::MSG::WINDOW_TONES[$1] ;""}
  473.     result.gsub!(/<TS:([^<>]*)>/i) { @text_sound = QUACK::MSG::TEXT_SOUNDS[$1]; ""}
  474.     result.gsub!(/<PMS:([-+]?\d+),([-+]?\d+)>/i) { @msg_size_x = $1.to_i ;@msg_size_y = $2.to_i; ""}
  475.     result
  476.   end
  477.   # new
  478.   def event_pop_message_setup2(tag, thought = false)
  479.     msgbox(sprintf("Using this tag requires that you have Qonvenience installed.","Chatter Messages",1)) if !$imported["Qonvenience"]
  480.     if SceneManager.scene_is?(Scene_Battle)
  481.       ev_id = nil
  482.       $game_party.members.each{|m| ev_id = m if m.name == tag }
  483.       $game_troop.members.each{|m| ev_id = m if m.name == tag } if ev_id.nil?
  484.       if ev_id.nil?
  485.         msgbox(sprintf("No battler with name: '" + tag + "'.","Chatter Messages",1))
  486.         exit
  487.       end
  488.       @msg_tone = QUACK::MSG::WINDOW_TONES[tag] if QUACK::MSG::WINDOW_TONES.has_key?(tag)
  489.       @text_sound = QUACK::MSG::TEXT_SOUNDS[tag] if !thought && QUACK::MSG::TEXT_SOUNDS.has_key?(tag)
  490.       namewindow(QUACK::MSG::NAMES[tag], 1) if $imported["YEA-MessageSystem"] && QUACK::MSG::NAMES.has_key?(tag) && @name_text == ""
  491.       if QUACK::MSG::POS_ADJUST.has_key?(tag)
  492.         set_offset_x(QUACK::MSG::POS_ADJUST[tag][0])
  493.         set_offset_y(QUACK::MSG::POS_ADJUST[tag][1])
  494.       end
  495.       return event_pop_message_setup(ev_id, thought)
  496.     end
  497.     if tag == 'pl'
  498.       ev_id = 0
  499.     else
  500.       ev_id = $game_map.first_event_tag(tag).id
  501.       msgbox(sprintf("No event with tag: '" + tag + "'.","Chatter Messages",1)) if ev_id.nil?
  502.     end
  503.     @msg_tone = QUACK::MSG::WINDOW_TONES[tag] if QUACK::MSG::WINDOW_TONES.has_key?(tag)
  504.     @text_sound = QUACK::MSG::TEXT_SOUNDS[tag] if !thought && QUACK::MSG::TEXT_SOUNDS.has_key?(tag)
  505.     namewindow(QUACK::MSG::NAMES[tag], 1) if $imported["YEA-MessageSystem"] && QUACK::MSG::NAMES.has_key?(tag) && @name_text == ""
  506.     if QUACK::MSG::POS_ADJUST.has_key?(tag)
  507.       set_offset_x(QUACK::MSG::POS_ADJUST[tag][0])
  508.       set_offset_y(QUACK::MSG::POS_ADJUST[tag][1])
  509.     end
  510.     return event_pop_message_setup(ev_id, thought)
  511.   end
  512.   # overwrite
  513.   def event_pop_message_setup(event_id, thought = false, follower = false)
  514.     start_name_window if $imported["YEA-MessageSystem"]
  515.     if follower && $game_player.followers[event_id].nil?
  516.       @event_pop_id = nil
  517.       @event_pop_follower = false
  518.       return ""
  519.     end
  520.     if thought # THOUGHT
  521.       @speech_bubble_tag.visible = false
  522.       @bubble_tag = @thought_bubble_tag
  523.     else # SPEECH
  524.       @thought_bubble_tag.visible = false
  525.       @bubble_tag = @speech_bubble_tag
  526.     end
  527.     @event_pop_follower = follower
  528.     @event_pop_id = event_id
  529.     # close any chatter message currently attached to this event
  530.     $game_message.clear_chatter_event(event_id)
  531.     source.ev_id = event_id
  532.     return ""
  533.   end
  534.   # overwrite
  535.   def set_face_position
  536.     #return unless SceneManager.scene_is?(Scene_Map)
  537.     return unless @event_pop_id
  538.     return unless @face_window
  539.     contents.clear
  540.     @face_window.set_face
  541.     return unless $imported["YEA-MessageSystem"]
  542.     return if @face_window.close?
  543.     #@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)
  544.   end
  545.   # overwrite
  546.   def close
  547.     pop_message_close
  548.     #return unless SceneManager.scene_is?(Scene_Map)
  549.     return unless @event_pop_id
  550.     @event_pop_follower = false
  551.     @face_window.hide_face
  552.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  553.     @speech_bubble_tag.visible = false if @speech_bubble_tag
  554.     @thought_bubble_tag.visible = false if @thought_bubble_tag
  555.     source.ev_id = nil
  556.   end
  557.   # overwrite
  558.   def process_all_text
  559.     @event_pop_id = nil
  560.     @name_text = ""
  561.     txt = convert_escape_characters($game_message.all_text)
  562.     update_placement
  563.     adjust_pop_message(txt)#$game_message.all_text)
  564.     pop_message_process_all_text
  565.   end
  566.   # overwrite
  567.   def update_placement
  568.     if SceneManager.scene_is?(Scene_Map)
  569.       if @event_pop_id.nil?
  570.         fix_default_message
  571.         event_pop_message_update_placement
  572.       elsif @event_pop_id == 0
  573.         character = $game_player
  574.         self.y = character.screen_y + @oy - self.height + YSE::POP_MESSAGE::POSITION[:y_buffer]
  575.         self.x = character.screen_x + @ox - self.width / 2 + YSE::POP_MESSAGE::POSITION[:x_buffer]
  576.         fix_position_bubble(character)
  577.         set_bubble_tag(character)
  578.         @name_window.update_pos if $imported["YEA-MessageSystem"] && @name_window.open?
  579.         @face_window.set_position if !chatter? && @face_window.open?
  580.       elsif @event_pop_id > 0
  581.         hash = @event_pop_follower ? $game_player.followers : $game_map.events
  582.         character = hash[@event_pop_id]
  583.         return unless character##########
  584.         self.y = character.screen_y + @oy - self.height + YSE::POP_MESSAGE::POSITION[:y_buffer]
  585.         self.x = character.screen_x + @ox - self.width / 2 + YSE::POP_MESSAGE::POSITION[:x_buffer]
  586.         fix_position_bubble(character)
  587.         set_bubble_tag(character)
  588.         @name_window.update_pos if $imported["YEA-MessageSystem"] && @name_window.open?
  589.         @face_window.set_position if !chatter? && @face_window.open?
  590.       end
  591.     else
  592.       # IF IN BATTLE
  593.       #event_pop_message_update_placement
  594.       if @event_pop_id.nil?
  595.         fix_default_message
  596.         event_pop_message_update_placement
  597.       else
  598.         battler = @event_pop_id
  599.         self.y = battler.screen_y + @oy - self.height + YSE::POP_MESSAGE::POSITION[:y_buffer]
  600.         self.x = battler.screen_x + @ox - self.width / 2 + YSE::POP_MESSAGE::POSITION[:x_buffer]
  601.         fix_position_bubble(battler)
  602.         set_bubble_tag(battler)
  603.         @name_window.update_pos if $imported["YEA-MessageSystem"] && @name_window.open?
  604.         @face_window.set_position if !chatter? && @face_window.open?
  605.       end
  606.     end
  607.     if close?
  608.       self.x = -999
  609.       self.y = -999
  610.       @name_window.update_pos if $imported["YEA-MessageSystem"]
  611.       return unless @bubble_tag
  612.       @bubble_tag.x = -999
  613.       @bubble_tag.y = -999
  614.     end
  615.   end
  616.   # overwrite
  617.   def fix_default_message
  618.     self.width = window_width
  619.     self.height = window_height
  620.     self.x = 0
  621.     @face_window.hide_face if @face_window
  622.     #create_contents
  623.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  624.     @speech_bubble_tag.visible = false if @speech_bubble_tag
  625.     @thought_bubble_tag.visible = false if @thought_bubble_tag
  626.   end
  627.   # overwrite
  628.   def fix_position_bubble(character)
  629.     end_x = self.x + self.width
  630.     end_y = self.y + self.height
  631.     self.x = 0 if self.x < 0
  632.     self.y = character.screen_y + @oy if self.y < 0
  633.     self.y = -99 if self.y < 0
  634.     self.x = Graphics.width - self.width if end_x > Graphics.width
  635.     self.y = Graphics.height - self.height if end_y > Graphics.height
  636.   end
  637.   # overwrite
  638.   def set_bubble_tag(character)
  639.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  640.     return unless @bubble_tag
  641.     up = self.y == character.screen_y + @oy
  642.     if self.y == -99
  643.       self.y = 0
  644.       up = true
  645.     end
  646.     self.y += up ? @bubble_tag.height / 2 : -@bubble_tag.height / 2
  647.     @bubble_tag.x = character.screen_x + @ox - @bubble_tag.width / 2
  648.     if up
  649.       @bubble_tag.src_rect.set(0, @bubble_tag.height, @bubble_tag.width, @bubble_tag.height)
  650.       @bubble_tag.y = self.y - @bubble_tag.height - YSE::POP_MESSAGE::POSITION[:tag_y_buffer]
  651.     else
  652.       @bubble_tag.src_rect.set(0, 0, @bubble_tag.width, @bubble_tag.height)
  653.       @bubble_tag.y = self.y + self.height + YSE::POP_MESSAGE::POSITION[:tag_y_buffer]
  654.     end
  655.     @bubble_tag.z = self.z + 1
  656.   end
  657.   # overwrite
  658.   def adjust_pop_message(text = " ")
  659.     #return unless SceneManager.scene_is?(Scene_Map)
  660.     unless @event_pop_id
  661.       if $imported["YEA-MessageSystem"]
  662.         #adjust_message_window_size
  663.       end
  664.       return
  665.     end
  666.     n_line = cal_number_line(text)
  667.     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]
  668.     @real_lines = n_line
  669.     self.height = fitting_height(n_line)
  670.     self.height += @msg_size_y
  671.     self.width = cal_width_line(text) + 10
  672.     self.width += @msg_size_x
  673.     self.width += new_line_x
  674.     if self.width > YSE::POP_MESSAGE::LIMIT[:limit_width] && YSE::POP_MESSAGE::LIMIT[:limit_width] > 0
  675.       self.width = YSE::POP_MESSAGE::LIMIT[:limit_width]
  676.     end
  677.     if $game_message.choice? && !QUACK::MSG::POP_CHOICE_GROW
  678.       dy = fitting_height($game_message.choices.size) - 16
  679.       self.y -= dy - 16
  680.       self.height += dy - 16
  681.       @face_window.y -= dy - 16
  682.       @name_window.y -= dy - 16 if $imported["YEA-MessageSystem"]
  683.     end
  684.     # If a chatter message with face graphic, force height to be at least big enough to show the face.
  685.     if chatter? && !source.face_name.empty?
  686.       self.height = [self.height, 86].max
  687.     end
  688.    
  689.     create_contents
  690.     update_placement
  691.   end
  692.   # alias
  693.   alias yse_pop_dispose dispose
  694.   def dispose
  695.     @speech_bubble_tag.visible = false if @speech_bubble_tag
  696.     @thought_bubble_tag.visible = false if @thought_bubble_tag
  697.     yse_pop_dispose
  698.   end
  699.   # alias
  700.   alias chatter_msg_input_choice input_choice
  701.   def input_choice
  702.     if !close? && pop_message? && QUACK::MSG::POP_CHOICE_GROW
  703.       f = Fiber.new { add_room_for_choices }
  704.       @choice_window.visible = false
  705.       @choice_window.set_fiber(f)
  706.       f.resume
  707.     end
  708.     chatter_msg_input_choice
  709.   end
  710.   # new
  711.   def add_room_for_choices
  712.     q = fitting_height($game_message.choices.size) - 16
  713.     i = 0
  714.     while true
  715.       i += 4
  716.       self.y -= 4
  717.       self.height += 4
  718.       @face_window.y -= 4
  719.       @name_window.y -= 4 if $imported["YEA-MessageSystem"]
  720.       break if i >= q
  721.       Fiber.yield
  722.     end
  723.     @choice_window.visible = true
  724.     @choice_window.set_fiber(nil)
  725.   end
  726.   # new
  727.   def pop_message?
  728.     @event_pop_id
  729.   end
  730. end

  731. #==============================================================================
  732. # ?! Window_ChoiceList
  733. #==============================================================================
  734. class Window_ChoiceList < Window_Command
  735.   # alias
  736.   alias chatter_msg_init initialize
  737.   def initialize(message_window)
  738.     chatter_msg_init(message_window)
  739.     self.opacity = 0
  740.     self.z = 207
  741.   end
  742.   # new
  743.   def set_fiber(fiber)
  744.     @fiber = fiber
  745.   end
  746.   # alias
  747.   alias chatter_msg_update update
  748.   def update
  749.     chatter_msg_update
  750.     @fiber.resume if @fiber
  751.   end
  752.   # alias
  753.   alias chatter_msg_update_placement update_placement
  754.   def update_placement
  755.     if @message_window.pop_message?
  756.       self.opacity = 0
  757.       self.width = @message_window.width-26 + padding * 2
  758.       self.width = [width, Graphics.width].min
  759.       self.height = fitting_height($game_message.choices.size)
  760.       self.x = @message_window.x
  761.       self.y = @message_window.y+@message_window.height-self.height+6
  762.     else
  763.       self.opacity = 255
  764.       chatter_msg_update_placement
  765.     end
  766.   end
  767. end

  768. #==============================================================================
  769. # ■ Window_NameMessage
  770. #==============================================================================
  771. class Window_NameMessage < Window_Base
  772.   # alias
  773.   alias quack_msg_name_init initialize
  774.   def initialize(message_window)
  775.     quack_msg_name_init(message_window)
  776.     self.z += 1
  777.   end
  778.   # new
  779.   def update_pos
  780.     set_x_position(1)
  781.     #set_y_position
  782.     self.y = @message_window.y - self.height / 1.5
  783.     #self.y = 0 if self.y < 0
  784.   end
  785.   # overwrite
  786.       #  self.y = @message_window.height
  787.       #  self.y -= YEA::MESSAGE::NAME_WINDOW_Y_BUFFER
  788.       #else
  789.       #  self.y = @message_window.y - self.height / 1.25
  790.       #  self.y += YEA::MESSAGE::NAME_WINDOW_Y_BUFFER
  791.       #end
  792. end
  793.   
  794. #==============================================================================
  795. # ¡ Window_Message_Face
  796. #==============================================================================

  797. class Window_Message_Face < Window_Base
  798.   alias quack_msg_face_pos set_position
  799.   def set_position
  800.     quack_msg_face_pos
  801.     self.y -= 4
  802.   end
  803. end

  804. #==============================================================================
  805. # ?! Window_Quack_Message
  806. #==============================================================================
  807. class Window_Quack_Message < Window_Message
  808.   attr_accessor :active
  809.   
  810.   # overwrite
  811.   def initialize(msg_source, zz)
  812.     super()
  813.     self.z = zz
  814.     @quack_msg_source = msg_source
  815.     @active = false
  816.     @showing = true
  817.     @tag_showing = false
  818.     @background = 0
  819.     self.opacity = 255
  820.     self.visible = false
  821.     clear_name_window if $imported["YEA-MessageSystem"]
  822.   end
  823.   # overwrite
  824.   def chatter?
  825.     true
  826.   end
  827.   # overwrite
  828.   def source
  829.     @quack_msg_source
  830.   end
  831.   # overwrite
  832.   def update
  833.     if @quack_msg_source.busy?
  834.       if @quack_msg_source.expire?
  835.         close
  836.       else
  837.         self.visible = true if !self.visible && @showing
  838.         @quack_msg_source.ttl_sub
  839.       end
  840.     end
  841.     self.visible = false if self.visible && close?
  842.     super
  843.   end
  844.   # overwrite
  845.   def update_placement
  846.     return if @closing
  847.     super
  848.   end
  849.   # overwrite
  850.   def update_show_fast
  851.     return false
  852.   end
  853.   # overwrite
  854.   def process_all_text
  855.     @event_pop_id = nil
  856.     text = convert_escape_characters(@quack_msg_source.all_text)
  857.     update_placement
  858.     adjust_pop_message(text)
  859.     open_and_wait
  860.     #text = convert_escape_characters(@quack_msg_source.all_text)
  861.     pos = {}
  862.     new_page(text, pos)
  863.     process_character(text.slice!(0, 1), text, pos) until text.empty? || close?
  864.   end
  865.   # overwrite
  866.   def close
  867.     pop_message_close #super
  868.     return unless @event_pop_id
  869.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  870.     @speech_bubble_tag.visible = false if @speech_bubble_tag
  871.     @thought_bubble_tag.visible = false if @thought_bubble_tag
  872.     source.ev_id = nil
  873.     @name_text = ""
  874.     @showing = true
  875.   end
  876.   # overwrite
  877.   def input_pause
  878.     self.pause = true
  879.     wait(10)
  880.     Fiber.yield until close?
  881.     self.pause = false
  882.   end
  883.   # overwrite
  884.   def update_fiber
  885.     if @fiber
  886.       @fiber.resume
  887.     elsif @quack_msg_source.busy?
  888.       @fiber = Fiber.new { fiber_main }
  889.       @fiber.resume
  890.     else
  891.       @quack_msg_source.visible = false
  892.     end
  893.   end
  894.   def fiber_main
  895.     @quack_msg_source.visible = true
  896.     #update_background
  897.     update_placement
  898.     loop do
  899.       process_all_text if @quack_msg_source.has_text?
  900.       process_input
  901.       @quack_msg_source.clear
  902.       @name_window.start_close if $imported["YEA-MessageSystem"]
  903.       Fiber.yield
  904.       break unless text_continue?
  905.     end
  906.     close_and_wait
  907.     @quack_msg_source.visible = false
  908.     @fiber = nil
  909.   end
  910.   #def update_background
  911.   #  @background = @quack_msg_source.background
  912.   #  self.opacity = @background == 0 ? 255 : 0
  913.   #end
  914.   def process_input
  915.     input_pause unless @pause_skip
  916.   end
  917.   def text_continue?
  918.     @quack_msg_source.has_text?# && !settings_changed?
  919.   end
  920.   def settings_changed?
  921.     #@background != $game_message.background ||
  922.     #@position != @quack_msg_source.position
  923.     false
  924.   end
  925.   def new_page(text, pos)
  926.     contents.clear
  927.     draw_face(@quack_msg_source.face_name, @quack_msg_source.face_index, 0, 0)
  928.     reset_font_settings
  929.     pos[:x] = new_line_x
  930.     pos[:y] = 0
  931.     pos[:new_x] = new_line_x
  932.     pos[:height] = calc_line_height(text)
  933.     clear_flags
  934.   end
  935.   def new_line_x
  936.     @quack_msg_source.face_name.empty? ? 0 : 112
  937.   end
  938.   # overwrite
  939.   def input_pause
  940.     #self.pause = true
  941.     wait(10)
  942.     Fiber.yield until @quack_msg_source.expire? #Input.trigger?(:B) || Input.trigger?(:C)
  943.     #Input.update
  944.     #self.pause = false
  945.   end
  946.   
  947.   # overwrite
  948.   def create_all_windows
  949.     @name_window = Window_NameMessage.new(self) if $imported["YEA-MessageSystem"]
  950.   end
  951.   # overwrite
  952.   def dispose_all_windows
  953.     @name_window.dispose if $imported["YEA-MessageSystem"]
  954.   end
  955.   # overwrite
  956.   def update_all_windows
  957.     if $imported["YEA-MessageSystem"]
  958.       @name_window.update
  959.       @name_window.back_opacity = self.back_opacity
  960.       @name_window.opacity = self.opacity
  961.     end
  962.   end
  963.   # overwrite
  964.   def event_pop_message_update_placement
  965.   end
  966.   # overwrite
  967.   def all_close?
  968.     close? && (!$imported["YEA-MessageSystem"] || @name_window.close?)
  969.   end
  970.   
  971.   if $imported["YEA-MessageSystem"]
  972.     def close_and_wait
  973.       @name_window.force_close
  974.       window_message_close_and_wait_ams
  975.     end
  976.   end
  977.   # new
  978.   def hide_me
  979.     @showing = false
  980.     self.visible = false
  981.     if @bubble_tag
  982.       @tag_showing = @bubble_tag.visible
  983.       @bubble_tag.visible = false
  984.     end
  985.   end
  986.   # new
  987.   def show_me
  988.     @showing = true
  989.     @bubble_tag.visible = true if @bubble_tag && @tag_showing && !close?
  990.   end
  991. end

  992. #==============================================================================
  993. # ?! Scene_Map
  994. #==============================================================================

  995. class Scene_Map < Scene_Base
  996.   # alias
  997.   alias quack_msg_update update
  998.   def update
  999.     $game_message.update_chatter
  1000.     @message_window.update_placement if @message_window.open?
  1001.     quack_msg_update
  1002.   end
  1003.   # overwrite
  1004.   def create_message_window
  1005.     yse_pm_create_message_window
  1006.     @face_window = Window_Message_Face.new
  1007.     @face_window.message_window = @message_window
  1008.     if @bubble_tag_sprite || @thought_bubble_tag_sprite
  1009.     @bubble_tag_sprite.dispose
  1010.     @thought_bubble_tag_sprite.dispose
  1011.     end
  1012.     if YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  1013.       @bubble_tag_sprite = Sprite.new
  1014.       @bubble_tag_sprite.visible = false
  1015.       @bubble_tag_sprite.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT2[:bubble_tag_name])
  1016.       @bubble_tag_sprite.src_rect.set(0, 0, @bubble_tag_sprite.width, @bubble_tag_sprite.height / 2)
  1017.       @message_window.speech_bubble_tag = @bubble_tag_sprite
  1018.       
  1019.       @thought_bubble_tag_sprite = Sprite.new
  1020.       @thought_bubble_tag_sprite.visible = false
  1021.       @thought_bubble_tag_sprite.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT2[:thought_bubble_tag_name])
  1022.       @thought_bubble_tag_sprite.src_rect.set(0, 0, @thought_bubble_tag_sprite.width, @thought_bubble_tag_sprite.height / 2)
  1023.       @message_window.thought_bubble_tag = @thought_bubble_tag_sprite
  1024.     end
  1025.     @message_window.face_window = @face_window
  1026.    
  1027.     $game_message.show_chatter
  1028.   end
  1029.   # overwrite
  1030.   def dispose_spriteset
  1031.     pop_message_dispose_spriteset
  1032.     return unless @bubble_tag_sprite || @thought_bubble_tag_sprite
  1033.     @bubble_tag_sprite.dispose
  1034.     @thought_bubble_tag_sprite.dispose
  1035.   end
  1036.   # alias
  1037.   alias qmsg_disp_wind dispose_all_windows
  1038.   def dispose_all_windows
  1039.     qmsg_disp_wind
  1040.     $game_message.hide_chatter
  1041.   end
  1042.   # alias
  1043.   alias qmsg_upd_encounter update_encounter
  1044.   def update_encounter
  1045.     qmsg_upd_encounter
  1046.     $game_message.clear_chatter if $game_player.encounter
  1047.   end
  1048. end

  1049. #==============================================================================
  1050. # ?! Scene_Battle
  1051. #==============================================================================
  1052. class Scene_Battle
  1053.   # alias
  1054.   alias quack_update_basic update_basic
  1055.   def update_basic
  1056.     quack_update_basic
  1057.     $game_message.update_chatter
  1058.   end
  1059.   # alias
  1060.   alias yse_pop_create_message_window create_message_window
  1061.   def create_message_window
  1062.     yse_pop_create_message_window
  1063.     @face_window = Window_Message_Face.new
  1064.     @face_window.message_window = @message_window
  1065.     if YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  1066.       @bubble_tag_sprite = Sprite.new
  1067.       @bubble_tag_sprite.visible = false
  1068.       @bubble_tag_sprite.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT2[:bubble_tag_name])
  1069.       @bubble_tag_sprite.src_rect.set(0, 0, @bubble_tag_sprite.width, @bubble_tag_sprite.height / 2)
  1070.       @message_window.speech_bubble_tag = @bubble_tag_sprite
  1071.       
  1072.       @thought_bubble_tag_sprite = Sprite.new
  1073.       @thought_bubble_tag_sprite.visible = false
  1074.       @thought_bubble_tag_sprite.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT2[:thought_bubble_tag_name])
  1075.       @thought_bubble_tag_sprite.src_rect.set(0, 0, @thought_bubble_tag_sprite.width, @thought_bubble_tag_sprite.height / 2)
  1076.       @message_window.thought_bubble_tag = @thought_bubble_tag_sprite

  1077.     end
  1078.     @message_window.face_window = @face_window
  1079.    
  1080.     $game_message.show_chatter
  1081.   end
  1082.   # alias
  1083.   alias yse_pop_dispose_spriteset dispose_spriteset
  1084.   def dispose_spriteset
  1085.     yse_pop_dispose_spriteset
  1086.     return unless @bubble_tag_sprite || @thought_bubble_tag_sprite
  1087.     @bubble_tag_sprite.dispose
  1088.     @thought_bubble_tag_sprite.dispose
  1089.   end
  1090.   # alias
  1091.   alias qmsg_disp_wind dispose_all_windows
  1092.   def dispose_all_windows
  1093.     qmsg_disp_wind
  1094.     $game_message.hide_chatter
  1095.   end
  1096. end

  1097. #==============================================================================
  1098. # ?! Game_Interpreter
  1099. #==============================================================================
  1100. class Game_Interpreter
  1101.   # overwrite
  1102.   def command_101
  1103.     item = $data_items[20]
  1104.     if $imported["YEA-MessageSystem"]
  1105.       wait_for_message
  1106.       $game_message.face_name = @params[0]
  1107.       $game_message.face_index = @params[1]
  1108.       $game_message.background = @params[2]
  1109.       $game_message.position = @params[3]
  1110.       
  1111.       startindex = @index+1
  1112.       textline = @list[startindex].parameters[0].dup
  1113.       chatdur = 0
  1114.       textline.gsub!(/<cm:([^<>]*)>/i) { chatdur = $1.to_i;"" }
  1115.       $game_message.prepare_msg(chatdur) if chatdur != 0
  1116.       while continue_message_string?
  1117.         @index += 1
  1118.         if @list[@index].code == 401
  1119.           textline = @list[@index].parameters[0] unless @index == startindex
  1120.           if chatdur != 0; $game_message.add_chatter(textline)
  1121.           else; $game_message.add(textline)
  1122.           end
  1123.         end
  1124.         break if $game_message.texts.size >= Variable.message_rows
  1125.       end
  1126.       case next_event_code
  1127.       when 102
  1128.         @index += 1
  1129.         setup_choices(@list[@index].parameters)
  1130.       when 103
  1131.         @index += 1
  1132.         setup_num_input(@list[@index].parameters)
  1133.       when 104
  1134.         @index += 1
  1135.         setup_item_choice(@list[@index].parameters)
  1136.       end
  1137.       $game_message.fin_msg if chatdur != 0
  1138.       wait_for_message
  1139.     else
  1140.       wait_for_message
  1141.       $game_message.face_name = @params[0]
  1142.       $game_message.face_index = @params[1]
  1143.       $game_message.background = @params[2]
  1144.       $game_message.position = @params[3]
  1145.       
  1146.       startindex = @index+1
  1147.       textline = @list[startindex].parameters[0].dup
  1148.       chatdur = 0
  1149.       textline.gsub!(/<cm:([^<>]*)>/i) { chatdur = $1.to_i;"" }
  1150.       $game_message.prepare_msg(chatdur) if chatdur != 0
  1151.       
  1152.       while next_event_code == 401       # Text data
  1153.         @index += 1
  1154.         textline = @list[@index].parameters[0] unless @index == startindex
  1155.         if chatdur != 0; $game_message.add_chatter(textline)
  1156.         else; $game_message.add(textline)
  1157.         end
  1158.       end
  1159.       case next_event_code
  1160.       when 102  # Show Choices
  1161.         @index += 1
  1162.         setup_choices(@list[@index].parameters)
  1163.       when 103  # Input Number
  1164.         @index += 1
  1165.         setup_num_input(@list[@index].parameters)
  1166.       when 104  # Select Item
  1167.         @index += 1
  1168.         setup_item_choice(@list[@index].parameters)
  1169.       end
  1170.       $game_message.fin_msg if chatdur != 0
  1171.       wait_for_message
  1172.     end
  1173.   end
  1174.   # new
  1175.   def clear_chatter
  1176.     $game_message.clear_chatter
  1177.   end
  1178.   # alias
  1179.   alias qmsg_cmd301 command_301
  1180.   def command_301
  1181.     $game_message.clear_chatter
  1182.     qmsg_cmd301
  1183.   end
  1184.   # new
  1185.   def event_on_screen(evtag)
  1186.     e = $game_map.first_event_tag(evtag)
  1187.     return e.screen_x >= -32 && e.screen_x < 672 && e.screen_y >= 0 && e.screen_y < 512
  1188.   end
  1189.   # new
  1190.   def event_within_earshot(evtag)
  1191.     e = $game_map.first_event_tag(evtag)
  1192.     return e.screen_x >= -352 && e.screen_x < 992 && e.screen_y >= -240 && e.screen_y < 752
  1193.   end
  1194.   # new
  1195.   def make_chatter(evtag, dur, text, thought=false, mute=false)
  1196.     $game_message.prepare_message(dur)
  1197.     text = "<ts:0>" + text if mute
  1198.     if thought
  1199.       $game_message.create_chatter("<btt:"+evtag+">" + text)
  1200.     else
  1201.       $game_message.create_chatter("<bt:"+evtag+">" + text)
  1202.     end
  1203.     $game_message.fin_msg
  1204.   end
  1205. end

  1206. #==============================================================================
  1207. #
  1208. # ?\ End of File
  1209. #
  1210. #==============================================================================
复制代码

老鹰

梦石
40
星屑
38044
在线时间
7127 小时
注册时间
2012-5-26
回帖
3306

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

发表于 2020-9-17 16:58:43 | 显示全部楼层
啊这,pop也就算了,甚至还有一个比pop还长的addon()
缩进不是指宽度计算了转义符宽度吧?

点评

那你应该找 cal_width_line 方法,比如这个addon里就粗暴的覆盖然后用 text_size 当然不行,你把它的改成先替换掉转义符再用text_size  发表于 2020-9-17 17:50
是指宽度计算了转义符宽度  发表于 2020-9-17 17:02

评分

参与人数 1赞 +1 收起 理由
alexncf125 + 1 塞糖

查看全部评分

回复

使用道具 举报

梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
 楼主| 发表于 2020-9-17 20:11:40 | 显示全部楼层
本帖最后由 alexncf125 于 2020-9-17 20:12 编辑
百里_飞柳 发表于 2020-9-17 16:58
啊这,pop也就算了,甚至还有一个比pop还长的addon()
缩进不是指宽度计算了转义符宽度吧? ...
兩者的 def cal_width_line 是一样的

Yami的:
  1.   #--------------------------------------------------------------------------
  2.   # new method: cal_width_line
  3.   #--------------------------------------------------------------------------
  4.   def cal_width_line(text)
  5.     p text
  6.     result = 0
  7.     text.each_line { |line|
  8.       result = text_size(line).width if result < text_size(line).width
  9.     }
  10.     return result
  11.   end
复制代码

Quack的:
  1.   # overwrite
  2.   def cal_width_line(text)
  3.     p text
  4.     result = 0
  5.     text.each_line { |line|
  6.       result = text_size(line).width if result < text_size(line).width
  7.     }
  8.     return result
  9.   end
复制代码

然而不知道为什么, 我在事件"显示文章"是这样子的一句:
\bm[0]\i[1]test\i[10]test\i[11]test\i[100]test\i[101]test\i[110]test\i[111]test

在Yami p text会是:
"\\bm[0]\\i[1]test\\i[10]test\\i[11]test\\i[100]test\\i[101]test\\i[110]test\\i[111]test\n"
用主楼第十行替换转义符后:
"testtesttesttesttesttesttest"

但在Quack p text却会是:
"\ei[1]test\ei[10]test\ei[11]test\ei[100]test\ei[101]test\ei[110]test\ei[111]test\n"
用主楼第十行替换转义符后:
"\ei[1]test\ei[10]test\ei[11]test\ei[100]test\ei[101]test\ei[110]test\ei[111]test"

大大说的「把它的改成先替换掉转义符再用text_size」是这样子改么??
  1.   def cal_width_line(text)
  2.     text.each_line { |line|
  3.       text = text.split("\n").each{|s| s.gsub!(/\\\w*\[\w*\]/i,'')}.sort_by!{|s| s.length}.pop
  4.     }
  5.     result = 0
  6.     text.each_line { |line|
  7.       result = text_size(line).width if result < text_size(line).width
  8.     }
  9.     return result
  10.   end
复制代码
然而我这个改法也是在Yami的有效, 在Quack中无效
回复

使用道具 举报

梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
 楼主| 发表于 2020-9-17 20:20:28 | 显示全部楼层
本帖最后由 alexncf125 于 2020-9-17 20:45 编辑
alexncf125 发表于 2020-9-17 20:11
兩者的 def cal_width_line 是一样的

Yami的:


不到半句钟...发现解決方法了...
text = text.split("\n").each{|s| s.gsub!(/\\\w*\[\w*\]/i,'')}.sort_by!{|s| s.length}.pop
改成
text = text.split("\n").each{|s| s.gsub!(/\e\w*\[\w*\]/i,'')}.sort_by!{|s| s.length}.pop
就好了

然而不明白为什么p text
\\i会成了\ei

=======廿分钟后又发现有问题了...=========

多出来的宽度是没了, 但应有的宽度也没了

应有的宽度:
test的宽度x7+1号图标的宽度+10号图标的宽度+11号图标的宽度+100号图标的宽度+101号图标的宽度+110号图标的宽度+111号图标的宽度

现在用text = text.split("\n").each{|s| s.gsub!(/\e\w*\[\w*\]/i,'')}.sort_by!{|s| s.length}.pop改完后的宽度:
test的宽度x7

没了图标的宽度
看来版主大大没考虑到当转义符不是转义成文字时的情形

点评

加多句text = text.split("\n").each{|s| s.gsub!(/\eI\[(\d+)\]/i,' ')}.sort_by!{|s| s.length}.pop后, 解決了所有问题, 谢谢你~  发表于 2020-9-18 09:47
这个东西本来就是写起来很麻烦,推荐一行行计算时,遇到\i转义符就直接加24宽度  发表于 2020-9-18 09:21
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部