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

Project1

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

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

[复制链接]

Lv5.捕梦者

梦石
0
星屑
24292
在线时间
5047 小时
注册时间
2016-3-8
帖子
1618
跳转到指定楼层
1
发表于 2020-9-17 16:24:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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

同样是窗口宽度计算了转义符宽度的问题
如果刪了Quack的, 在Yami的改, 问题得到解決
但不刪Quack的, 我改Quack的成这样子后, 问题仍然存在
RUBY 代码复制
  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的
RUBY 代码复制
  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.  
  42. Please note if you are using Yanfly's core script & Yanfly's Ace Message script
  43.   together. You need to set FONT_NAME in the core script to have the same value
  44.   as MESSAGE_WINDOW_FONT_NAME in the ace message script. Otherwise when these
  45.   two are combined it will sometimes cause the width of text to be
  46.   miss-measured. This wouldn't cause much of a problem normally, but when using
  47.   pop messages which measure the width of the text to set the width of the
  48.   message box it can cause big problems. (the other font settings on the two
  49.   scripts (that is bold, italic, shadow and outline) should preferably also be
  50.   the same on both)
  51.  
  52. VERSION 1.1 ADDITIONS:
  53.  
  54. 1-Added text sound. You can add different text sounds in the TEXT_SOUNDS hash
  55.   in the config area (further instructions on adding sounds there). By default
  56.   messages won't have sound. To add it use this tag: <ts:x>   where x is a key
  57.   that exists in the TEXT_SOUNDS hash.
  58.  
  59. 2-Added Message box background tones. This allows you to specify different
  60.   background colors for your message boxes. You can add different tones in the
  61.   WINDOW_TONES has in the config area (further instructions on adding tones
  62.   there). By default it will use the normal window tone. To use one of the tones
  63.   in the WINDOW_TONES has use this tag: <bc:x>  where x is a key that exists in
  64.   the WINDOW_TONES hash.
  65.  
  66. 3-Sometimes you might want to change font size in your message, multiple times,
  67.   or do other things that might affect the size required by your message and
  68.   therefore cause the size of the message window too be to big or too small. So
  69.   I added a tag to use to adjust the message window size: <pms:x,y> . It changes
  70.   Pop Message Size, adjusting the width by x and height by y. So if you put
  71.   <pms:20,-10> in your message it will increase the width of the window by 20
  72.   and decrease the height by 10.
  73.  
  74. 4-If you're like me you think it's annoying to have to remember which event has
  75.   what id when writing messages and it's further annoying to have to write so
  76.   many tags for each message. That is why I made it so now in my game using this
  77.   script I can position my pop message on the event I want and make it use the
  78.   background color and text sound that I want just by entering this tag:
  79.   <bt:x> (for speech bubble)  OR <btt:x> (for thought bubble)
  80.   How does that work you might ask?
  81.   Well lets say I have an event which is supposed to be one of my actors. Let's
  82.   call the actor Emil. In the name box of the event I put the tag: <emil>.
  83.   Now when I use the tags: <bt:emil> or <btt:emil>  the pop message will get
  84.   placed on that event. And if WINDOW_TONES has a value with the key 'emil',
  85.   that window tone will be used too. Same for TEXT_SOUNDS except if you are
  86.   using btt because thoughts shouldn't make sound now should they?
  87.   Doesn't that sound so much easier?
  88.   It will also make it easier to tell which event is saying a text when looking
  89.   at the event command in the editor since you know who 'emil' is but might not
  90.   be able to as easily tell which event '72' is.
  91.  
  92.   You can also specify the player with these tags by using 'pl', like so:
  93.   <bt:pl>
  94.   The reason I added this was to allow setting window tone and text sound for
  95.   player as well. This probably won't be all to useful in most cases since
  96.   the showing actor for the party might vary but I figured I should still add
  97.   the functionality.
  98.  
  99.   If you are wondering why all my new tags use different structure than the
  100.   previously existing ones then well.... because! Consistence is overrated
  101.   anyway, who needs it?
  102.  
  103.   Using these these two tags (<bt:x> & <btt:x>) does however require the
  104.   functionality of one of my other scripts, called Qonvenience (guess you could
  105.   kind of call it my 'core' script like how other scripters have (Yanfly,
  106.   Victor, Yami, etc).
  107.   You can find a link to it under the 'Requirements' section.
  108.  
  109. VERSION 1.2 ADDITIONS:
  110.  
  111. -When showing choices it will appear differently depending on if the open
  112.   game_message is a pop message or not. If it is not it will display like normal.
  113.   But if it is a pop message the message window will be made bigger and the
  114.   choices will be displayed inside the message window.
  115.  
  116. VERSION 1.3:
  117.  
  118. -Fixed some problems with faces graphics and nameboxes. It's still not perfect
  119.   but I wrote this script for a project of mine where I don't use nameboxes
  120.   or face graphics so I don't really want to put too much effort into features
  121.   I'm not personally interested in.
  122.  
  123. -Like with window tones and text sounds, you can now associate namebox names to
  124.   a tag.
  125.  
  126. -Position adjustments can also be be associated to a nametag now using POS_ADJUST.
  127.  
  128. ==============================================================================
  129. Instructions/Install notes:
  130. Requires Yami's Pop messages to work.
  131. Paste it below Yami's Pop messages script.
  132.  
  133. ==============================================================================
  134. Requirements:
  135. Requires Yami's Pop messages to work. You can find it here:
  136. ​[url]https://github.com/suppayami/rmvxa-collection/blob/master/yami-script-ace/10%20-%20Pop%20Message.txt[/url]
  137. Also requires my script Qonvenience if you plan on using the message tags
  138. <bt:x> and <btt:x>
  139. Find it here:
  140. [url]http://pastebin.com/J6haUy5T[/url]
  141.  
  142. ==============================================================================
  143. Credits:
  144. Yami for making Pop messages.
  145.  
  146. ==============================================================================
  147. Terms of Use:
  148. Use it however you wish (yes, that does include commercial projects), as long
  149. as you do not claim it as your own code. I would also prefer you mention me in
  150. your credits if you do decide to use it.
  151. However do remember that this script relies on Yami's pop messages script which
  152. has it has it's own separate terms of use.
  153.  
  154. ==============================================================================
  155. Bugs:
  156. dunno
  157.  
  158. ==============================================================================
  159. History:
  160. 13/06/2018 - Fixed some things. Hopefully it isnt completely broken anymore.
  161. 11/10/2016 - Fixed some problems added some minor feature.
  162. 19/01/2016 - Fixed some bugs, changes to choices when a pop message is used.
  163. 14/01/2016 - Chatter messages now last forever if you set the duration to a
  164.              negative number. Also added method for clearing all chatter
  165.              to use in script calls. Also squashed some bugs.
  166. 13/01/2016 - Pretty big update. Added more functionality.
  167. 10/01/2016 - Proper release since Absurdiness found the original script so I
  168.              could separate the addon from the original.
  169. 08/01/2016 - Initial release
  170.  
  171. =end
  172.  
  173. $imported = {} if $imported.nil?
  174. $imported["Chatter_Messages"] = true
  175.  
  176. #==============================================================================
  177. # * CONFIG
  178. #==============================================================================
  179.  
  180. module YSE
  181.   module POP_MESSAGE
  182.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  183.     # - Visual Settings -
  184.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  185.  
  186.     EFFECT2 = { # Start.
  187.       :bubble_tag_name => "BubbleTag_Speech",
  188.       :thought_bubble_tag_name => "BubbleTag_Thought",
  189.     } # End.
  190.   end
  191. end
  192.  
  193. module QUACK
  194.   module MSG
  195.  
  196.     # Max amount of chatter messages that can be exist at the same time.
  197.     # Too few might be limiting your options and too many will clutter up
  198.     # the screen and decrease performance.
  199.     MAX_MSGS = 7
  200.  
  201.     # Used for setting the background color of messages.
  202.     # To add a tone the syntax is:
  203.     # Key => Tone.new(Red,Green,Blue,Grey)
  204.     # Where key is a string, Red,Green and Blue are numerical value from -255 to
  205.     # 255. And Grey is a value from 0 to 255. The Grey value is optional so you
  206.     # don't have to add it.
  207.     # If you are unsure how to do it just copy one of the lines, paste it below
  208.     # and edit the values.
  209.     WINDOW_TONES = {
  210.       # Add tones below this line
  211.       'reddish1' => Tone.new(85,44,51),
  212.       'bluehair' => Tone.new(-34,85,102),
  213.       'geezer' => Tone.new(68,68,68,10),
  214.       'pl' => Tone.new(102,34,-34),
  215.       'alf' => Tone.new(102,34,51),
  216.       # And above this line
  217.     }
  218.  
  219.     # The name is kind of self explanatory
  220.     # If you want to add a sound the syntax is this:
  221.     #Key => [Sound, Volume, Pitch minimum, Pitch Maximum],
  222.     # where Key is a string. Sound is the name of your sound,
  223.     # Volume, Pitch minimum and Pitch Maximum are values from 0-100.
  224.     # Text sound automatically gets disabled for thought bubbles even if text
  225.     # sound is specified.
  226.     # Just a copy a line, paste it and edit it.
  227.     TEXT_SOUNDS = {
  228.       # Add sounds below this line
  229.       '0' => nil, # DEFAULT VALUE USED FOR NO SOUND!
  230.       '1' => ["Cursor1", 80, 70, 100],
  231.       '2' => ["Cursor1", 80, 90, 120],
  232.       '3' => ["Knock", 80, 50, 75],
  233.       'bluehair' => ["Cursor1", 80, 90, 120],
  234.       'geezer' => ["Cursor1", 80, 45, 70],
  235.       'pl' => ["Cursor1", 80, 70, 100],
  236.       'alf' => ["Cursor1", 70, 110, 140],
  237.       # And above this line
  238.     }
  239.  
  240.     NAMES = {
  241.       # Add names below this line
  242.       'bluehair' => "Riverhead",
  243.       'geezer' => "Geezer"
  244.     }
  245.  
  246.     POS_ADJUST = {
  247.       'test' => [20,10]
  248.     }
  249.  
  250.     # Play sound per X characters displayed.
  251.     SOUND_PLAY_FREQUENCY = 3
  252.  
  253.     # Whether the pop message should grow to make place for choices as the text
  254.     # finishes or just have the final size immediately.
  255.     POP_CHOICE_GROW = true
  256.  
  257.   end
  258. end
  259.  
  260. #==============================================================================
  261. # * SCRIPT START
  262. #==============================================================================
  263.  
  264. #==============================================================================
  265. # ?! DataManager
  266. #==============================================================================
  267. module DataManager
  268.   class << self
  269.     alias quack_msg_create_game_objects create_game_objects
  270.     def create_game_objects
  271.       quack_msg_create_game_objects
  272.       if !$imported["YSE-PopMessage"]
  273.         msgbox(sprintf("This script(Chatter Messages) requires Yami's Pop Messages to function", "ChatterMessages", 1))
  274.         exit
  275.       end
  276.       $game_message.quack_msg_make
  277.     end
  278.  
  279.     alias qmsg_sng setup_new_game
  280.     def setup_new_game
  281.       $game_message.clear_chatter
  282.       qmsg_sng
  283.     end
  284.   end
  285. end
  286.  
  287. #==============================================================================
  288. # ?! BattleManager
  289. #==============================================================================
  290. module BattleManager
  291.   class << self
  292.     alias qmsg_proc_victory process_victory
  293.     def process_victory
  294.       $game_message.clear_chatter
  295.       qmsg_proc_victory
  296.     end
  297.  
  298.     alias qmsg_proc_abort process_abort
  299.     def process_abort
  300.       qmsg_proc_abort
  301.       $game_message.clear_chatter
  302.     end
  303.  
  304.     alias qmsg_proc_defeat process_defeat
  305.     def process_defeat
  306.       qmsg_proc_defeat
  307.       $game_message.clear_chatter
  308.     end
  309.   end
  310. end
  311.  
  312. #==============================================================================
  313. # ?! Game_Message
  314. #==============================================================================
  315. class Game_Message
  316.   attr_accessor :quack_msgs
  317.   attr_accessor :ev_id
  318.  
  319.   # new
  320.   def quack_msg_make
  321.     @quack_msgs = []
  322.     QUACK::MSG::MAX_MSGS.times {@quack_msgs.push(Game_Message.new)}
  323.     @quack_msg_ttl = 0
  324.     @c_msg = 0
  325.  
  326.     @qmsg_windows = []
  327.     QUACK::MSG::MAX_MSGS.times do |i|
  328.         qm = Window_Quack_Message.new(@quack_msgs[i], 80-QUACK::MSG::MAX_MSGS+(i*2))
  329.       @qmsg_windows.push(qm)
  330.       ss = Sprite.new
  331.       ss.visible = false
  332.       ss.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT2[:bubble_tag_name])
  333.       ss.src_rect.set(0, 0, ss.width, ss.height / 2)
  334.       qm.speech_bubble_tag = ss
  335.       ts = Sprite.new
  336.       ts.visible = false
  337.       ts.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT2[:bubble_tag_name])
  338.       ts.src_rect.set(0, 0, ts.width, ts.height / 2)
  339.       qm.thought_bubble_tag = ts
  340.     end
  341.   end
  342.   # new
  343.   def set_ttl(ttl)
  344.     @quack_msg_ttl = ttl
  345.   end
  346.   # new
  347.   def ttl_sub
  348.     @quack_msg_ttl -= 1 if @quack_msg_ttl > 0
  349.   end
  350.   # new
  351.   def expire?
  352.     return false if @quack_msg_ttl < 0
  353.     @quack_msg_ttl == 0
  354.   end
  355.   # new
  356.   def prepare_msg(duration)
  357.     @quack_msg_ttl = (duration * 60).to_i
  358.   end
  359.   # new
  360.   def fin_msg
  361.     @quack_msg_ttl = 0
  362.     @c_msg = (@c_msg + 1) % QUACK::MSG::MAX_MSGS
  363.   end
  364.   # new
  365.   def add_chatter(text)
  366.     m = @quack_msgs[@c_msg]
  367.     m.add(text)
  368.     m.face_name = face_name
  369.     m.face_index = face_index
  370.     m.set_ttl(@quack_msg_ttl)
  371.   end
  372.   # new
  373.   def clear_chatter
  374.     @quack_msgs.each {|m| m.set_ttl(0) }
  375.     @qmsg_windows.each {|w| w.close }
  376.   end
  377.  
  378.   # new
  379.   def clear_chatter_event(e_id)
  380.     # Find any chatter attached to certain event id and close the chatter
  381.     @quack_msgs.each {|m| m.set_ttl(0) if m.ev_id == e_id }
  382.   end
  383.  
  384.   # new
  385.   def update_chatter
  386.     @qmsg_windows.each {|m|
  387.       m.update
  388.       if m.open?
  389.         m.update_placement
  390.       end
  391.     }
  392.   end
  393.   # new
  394.   def hide_chatter
  395.     @qmsg_windows.each {|m|
  396.       m.hide_me
  397.     }
  398.   end
  399.   # new
  400.   def show_chatter
  401.     @qmsg_windows.each {|m|
  402.       m.show_me
  403.     }
  404.   end
  405.  
  406. end
  407.  
  408. #==============================================================================
  409. # ?! Window_Message
  410. #==============================================================================
  411.  
  412. class Window_Message < Window_Base
  413.  
  414.   # new
  415.   def chatter?
  416.     false
  417.   end
  418.   # new
  419.   def source
  420.     $game_message
  421.   end
  422.   # overwrite
  423.   def standard_padding
  424.     return 8
  425.   end
  426.   # alias
  427.   alias quack_chatter_init initialize
  428.   def initialize
  429.     @msg_tone = $game_system.window_tone
  430.     @snd_f = 0
  431.     #@name_text = ""
  432.     quack_chatter_init
  433.   end
  434.   # new
  435.   def speech_bubble_tag=(sprite)
  436.     @speech_bubble_tag = sprite
  437.   end
  438.   # new
  439.   def thought_bubble_tag=(sprite)
  440.     @thought_bubble_tag = sprite
  441.   end
  442.   # new
  443.   def set_offset_x(x)
  444.     @ox = x
  445.     return ""
  446.   end
  447.   # new
  448.   def set_offset_y(y)
  449.     @oy = y
  450.     return ""
  451.   end
  452.   # overwrite
  453.   def cal_width_line(text)
  454.     result = 0
  455.     text.each_line { |line|
  456.       result = text_size(line).width if result < text_size(line).width
  457.     }
  458.     return result
  459.   end
  460.   # alias
  461.   alias quack_chatter_process_character process_character
  462.   def process_character(c, text, pos)
  463.     if @snd_f == 0 && !@show_fast && !@text_sound.nil?
  464.       Audio.se_play("Audio/SE/"+@text_sound[0],@text_sound[1],@text_sound[2]+rand(@text_sound[3]-@text_sound[2]))
  465.     end
  466.     @snd_f += 1
  467.     @snd_f = 0 if @snd_f == QUACK::MSG::SOUND_PLAY_FREQUENCY
  468.     quack_chatter_process_character(c,text,pos)
  469.   end
  470.   # overwrite
  471.   def update_tone
  472.     self.tone.set(@msg_tone)
  473.   end
  474.   # overwrite
  475.   def message_escape_characters_pop_message(result)
  476.     @msg_tone = $game_system.window_tone
  477.     @event_pop_id = nil
  478.     set_offset_x(0)
  479.     set_offset_y(0)
  480.     @text_sound = QUACK::MSG::TEXT_SOUNDS['0']
  481.     @msg_size_x = 0
  482.     @msg_size_y = 0
  483.     reset_font_settings
  484.  
  485.     result.gsub!(/<BT:([^<>]*)>/i) { event_pop_message_setup2($1, false) }
  486.     result.gsub!(/<BTT:([^<>]*)>/i) { event_pop_message_setup2($1, true) }
  487.     result.gsub!(/\eOX\[([-+]?\d+)\]/i) { set_offset_x($1.to_i) }
  488.     result.gsub!(/\eOY\[([-+]?\d+)\]/i) { set_offset_y($1.to_i) }
  489.     result.gsub!(/\eBM\[([-+]?\d+)\]/i) { event_pop_message_setup($1.to_i, false) }
  490.     result.gsub!(/\eBMT\[([-+]?\d+)\]/i) { event_pop_message_setup($1.to_i, true) }
  491.     result.gsub!(/\eBMF\[(\d+)\]/i) { event_pop_message_setup($1.to_i, false, true) }
  492.     result.gsub!(/\eCBM/i) { event_pop_message_setup(nil, false) }
  493.     result.gsub!(/<BC:([^<>]*)>/i) { @msg_tone = QUACK::MSG::WINDOW_TONES[$1] ;""}
  494.     result.gsub!(/<TS:([^<>]*)>/i) { @text_sound = QUACK::MSG::TEXT_SOUNDS[$1]; ""}
  495.     result.gsub!(/<PMS:([-+]?\d+),([-+]?\d+)>/i) { @msg_size_x = $1.to_i ;@msg_size_y = $2.to_i; ""}
  496.     result
  497.   end
  498.   # new
  499.   def event_pop_message_setup2(tag, thought = false)
  500.     msgbox(sprintf("Using this tag requires that you have Qonvenience installed.","Chatter Messages",1)) if !$imported["Qonvenience"]
  501.     if SceneManager.scene_is?(Scene_Battle)
  502.       ev_id = nil
  503.       $game_party.members.each{|m| ev_id = m if m.name == tag }
  504.       $game_troop.members.each{|m| ev_id = m if m.name == tag } if ev_id.nil?
  505.       if ev_id.nil?
  506.         msgbox(sprintf("No battler with name: '" + tag + "'.","Chatter Messages",1))
  507.         exit
  508.       end
  509.       @msg_tone = QUACK::MSG::WINDOW_TONES[tag] if QUACK::MSG::WINDOW_TONES.has_key?(tag)
  510.       @text_sound = QUACK::MSG::TEXT_SOUNDS[tag] if !thought && QUACK::MSG::TEXT_SOUNDS.has_key?(tag)
  511.       namewindow(QUACK::MSG::NAMES[tag], 1) if $imported["YEA-MessageSystem"] && QUACK::MSG::NAMES.has_key?(tag) && @name_text == ""
  512.       if QUACK::MSG::POS_ADJUST.has_key?(tag)
  513.         set_offset_x(QUACK::MSG::POS_ADJUST[tag][0])
  514.         set_offset_y(QUACK::MSG::POS_ADJUST[tag][1])
  515.       end
  516.       return event_pop_message_setup(ev_id, thought)
  517.     end
  518.     if tag == 'pl'
  519.       ev_id = 0
  520.     else
  521.       ev_id = $game_map.first_event_tag(tag).id
  522.       msgbox(sprintf("No event with tag: '" + tag + "'.","Chatter Messages",1)) if ev_id.nil?
  523.     end
  524.     @msg_tone = QUACK::MSG::WINDOW_TONES[tag] if QUACK::MSG::WINDOW_TONES.has_key?(tag)
  525.     @text_sound = QUACK::MSG::TEXT_SOUNDS[tag] if !thought && QUACK::MSG::TEXT_SOUNDS.has_key?(tag)
  526.     namewindow(QUACK::MSG::NAMES[tag], 1) if $imported["YEA-MessageSystem"] && QUACK::MSG::NAMES.has_key?(tag) && @name_text == ""
  527.     if QUACK::MSG::POS_ADJUST.has_key?(tag)
  528.       set_offset_x(QUACK::MSG::POS_ADJUST[tag][0])
  529.       set_offset_y(QUACK::MSG::POS_ADJUST[tag][1])
  530.     end
  531.     return event_pop_message_setup(ev_id, thought)
  532.   end
  533.   # overwrite
  534.   def event_pop_message_setup(event_id, thought = false, follower = false)
  535.     start_name_window if $imported["YEA-MessageSystem"]
  536.     if follower && $game_player.followers[event_id].nil?
  537.       @event_pop_id = nil
  538.       @event_pop_follower = false
  539.       return ""
  540.     end
  541.     if thought # THOUGHT
  542.       @speech_bubble_tag.visible = false
  543.       @bubble_tag = @thought_bubble_tag
  544.     else # SPEECH
  545.       @thought_bubble_tag.visible = false
  546.       @bubble_tag = @speech_bubble_tag
  547.     end
  548.     @event_pop_follower = follower
  549.     @event_pop_id = event_id
  550.     # close any chatter message currently attached to this event
  551.     $game_message.clear_chatter_event(event_id)
  552.     source.ev_id = event_id
  553.     return ""
  554.   end
  555.   # overwrite
  556.   def set_face_position
  557.     #return unless SceneManager.scene_is?(Scene_Map)
  558.     return unless @event_pop_id
  559.     return unless @face_window
  560.     contents.clear
  561.     @face_window.set_face
  562.     return unless $imported["YEA-MessageSystem"]
  563.     return if @face_window.close?
  564.     #@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)
  565.   end
  566.   # overwrite
  567.   def close
  568.     pop_message_close
  569.     #return unless SceneManager.scene_is?(Scene_Map)
  570.     return unless @event_pop_id
  571.     @event_pop_follower = false
  572.     @face_window.hide_face
  573.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  574.     @speech_bubble_tag.visible = false if @speech_bubble_tag
  575.     @thought_bubble_tag.visible = false if @thought_bubble_tag
  576.     source.ev_id = nil
  577.   end
  578.   # overwrite
  579.   def process_all_text
  580.     @event_pop_id = nil
  581.     @name_text = ""
  582.     txt = convert_escape_characters($game_message.all_text)
  583.     update_placement
  584.     adjust_pop_message(txt)#$game_message.all_text)
  585.     pop_message_process_all_text
  586.   end
  587.   # overwrite
  588.   def update_placement
  589.     if SceneManager.scene_is?(Scene_Map)
  590.       if @event_pop_id.nil?
  591.         fix_default_message
  592.         event_pop_message_update_placement
  593.       elsif @event_pop_id == 0
  594.         character = $game_player
  595.         self.y = character.screen_y + @oy - self.height + YSE::POP_MESSAGE::POSITION[:y_buffer]
  596.         self.x = character.screen_x + @ox - self.width / 2 + YSE::POP_MESSAGE::POSITION[:x_buffer]
  597.         fix_position_bubble(character)
  598.         set_bubble_tag(character)
  599.         @name_window.update_pos if $imported["YEA-MessageSystem"] && @name_window.open?
  600.         @face_window.set_position if !chatter? && @face_window.open?
  601.       elsif @event_pop_id > 0
  602.         hash = @event_pop_follower ? $game_player.followers : $game_map.events
  603.         character = hash[@event_pop_id]
  604.         return unless character##########
  605.         self.y = character.screen_y + @oy - self.height + YSE::POP_MESSAGE::POSITION[:y_buffer]
  606.         self.x = character.screen_x + @ox - self.width / 2 + YSE::POP_MESSAGE::POSITION[:x_buffer]
  607.         fix_position_bubble(character)
  608.         set_bubble_tag(character)
  609.         @name_window.update_pos if $imported["YEA-MessageSystem"] && @name_window.open?
  610.         @face_window.set_position if !chatter? && @face_window.open?
  611.       end
  612.     else
  613.       # IF IN BATTLE
  614.       #event_pop_message_update_placement
  615.       if @event_pop_id.nil?
  616.         fix_default_message
  617.         event_pop_message_update_placement
  618.       else
  619.         battler = @event_pop_id
  620.         self.y = battler.screen_y + @oy - self.height + YSE::POP_MESSAGE::POSITION[:y_buffer]
  621.         self.x = battler.screen_x + @ox - self.width / 2 + YSE::POP_MESSAGE::POSITION[:x_buffer]
  622.         fix_position_bubble(battler)
  623.         set_bubble_tag(battler)
  624.         @name_window.update_pos if $imported["YEA-MessageSystem"] && @name_window.open?
  625.         @face_window.set_position if !chatter? && @face_window.open?
  626.       end
  627.     end
  628.     if close?
  629.       self.x = -999
  630.       self.y = -999
  631.       @name_window.update_pos if $imported["YEA-MessageSystem"]
  632.       return unless @bubble_tag
  633.       @bubble_tag.x = -999
  634.       @bubble_tag.y = -999
  635.     end
  636.   end
  637.   # overwrite
  638.   def fix_default_message
  639.     self.width = window_width
  640.     self.height = window_height
  641.     self.x = 0
  642.     @face_window.hide_face if @face_window
  643.     #create_contents
  644.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  645.     @speech_bubble_tag.visible = false if @speech_bubble_tag
  646.     @thought_bubble_tag.visible = false if @thought_bubble_tag
  647.   end
  648.   # overwrite
  649.   def fix_position_bubble(character)
  650.     end_x = self.x + self.width
  651.     end_y = self.y + self.height
  652.     self.x = 0 if self.x < 0
  653.     self.y = character.screen_y + @oy if self.y < 0
  654.     self.y = -99 if self.y < 0
  655.     self.x = Graphics.width - self.width if end_x > Graphics.width
  656.     self.y = Graphics.height - self.height if end_y > Graphics.height
  657.   end
  658.   # overwrite
  659.   def set_bubble_tag(character)
  660.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  661.     return unless @bubble_tag
  662.     up = self.y == character.screen_y + @oy
  663.     if self.y == -99
  664.       self.y = 0
  665.       up = true
  666.     end
  667.     self.y += up ? @bubble_tag.height / 2 : -@bubble_tag.height / 2
  668.     @bubble_tag.x = character.screen_x + @ox - @bubble_tag.width / 2
  669.     if up
  670.       @bubble_tag.src_rect.set(0, @bubble_tag.height, @bubble_tag.width, @bubble_tag.height)
  671.       @bubble_tag.y = self.y - @bubble_tag.height - YSE::POP_MESSAGE::POSITION[:tag_y_buffer]
  672.     else
  673.       @bubble_tag.src_rect.set(0, 0, @bubble_tag.width, @bubble_tag.height)
  674.       @bubble_tag.y = self.y + self.height + YSE::POP_MESSAGE::POSITION[:tag_y_buffer]
  675.     end
  676.     @bubble_tag.z = self.z + 1
  677.   end
  678.   # overwrite
  679.   def adjust_pop_message(text = " ")
  680.     #return unless SceneManager.scene_is?(Scene_Map)
  681.     unless @event_pop_id
  682.       if $imported["YEA-MessageSystem"]
  683.         #adjust_message_window_size
  684.       end
  685.       return
  686.     end
  687.     n_line = cal_number_line(text)
  688.     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]
  689.     @real_lines = n_line
  690.     self.height = fitting_height(n_line)
  691.     self.height += @msg_size_y
  692.     self.width = cal_width_line(text) + 10
  693.     self.width += @msg_size_x
  694.     self.width += new_line_x
  695.     if self.width > YSE::POP_MESSAGE::LIMIT[:limit_width] && YSE::POP_MESSAGE::LIMIT[:limit_width] > 0
  696.       self.width = YSE::POP_MESSAGE::LIMIT[:limit_width]
  697.     end
  698.     if $game_message.choice? && !QUACK::MSG::POP_CHOICE_GROW
  699.       dy = fitting_height($game_message.choices.size) - 16
  700.       self.y -= dy - 16
  701.       self.height += dy - 16
  702.       @face_window.y -= dy - 16
  703.       @name_window.y -= dy - 16 if $imported["YEA-MessageSystem"]
  704.     end
  705.     # If a chatter message with face graphic, force height to be at least big enough to show the face.
  706.     if chatter? && !source.face_name.empty?
  707.       self.height = [self.height, 86].max
  708.     end
  709.  
  710.     create_contents
  711.     update_placement
  712.   end
  713.   # alias
  714.   alias yse_pop_dispose dispose
  715.   def dispose
  716.     @speech_bubble_tag.visible = false if @speech_bubble_tag
  717.     @thought_bubble_tag.visible = false if @thought_bubble_tag
  718.     yse_pop_dispose
  719.   end
  720.   # alias
  721.   alias chatter_msg_input_choice input_choice
  722.   def input_choice
  723.     if !close? && pop_message? && QUACK::MSG::POP_CHOICE_GROW
  724.       f = Fiber.new { add_room_for_choices }
  725.       @choice_window.visible = false
  726.       @choice_window.set_fiber(f)
  727.       f.resume
  728.     end
  729.     chatter_msg_input_choice
  730.   end
  731.   # new
  732.   def add_room_for_choices
  733.     q = fitting_height($game_message.choices.size) - 16
  734.     i = 0
  735.     while true
  736.       i += 4
  737.       self.y -= 4
  738.       self.height += 4
  739.       @face_window.y -= 4
  740.       @name_window.y -= 4 if $imported["YEA-MessageSystem"]
  741.       break if i >= q
  742.       Fiber.yield
  743.     end
  744.     @choice_window.visible = true
  745.     @choice_window.set_fiber(nil)
  746.   end
  747.   # new
  748.   def pop_message?
  749.     @event_pop_id
  750.   end
  751. end
  752.  
  753. #==============================================================================
  754. # ?! Window_ChoiceList
  755. #==============================================================================
  756. class Window_ChoiceList < Window_Command
  757.   # alias
  758.   alias chatter_msg_init initialize
  759.   def initialize(message_window)
  760.     chatter_msg_init(message_window)
  761.     self.opacity = 0
  762.     self.z = 207
  763.   end
  764.   # new
  765.   def set_fiber(fiber)
  766.     @fiber = fiber
  767.   end
  768.   # alias
  769.   alias chatter_msg_update update
  770.   def update
  771.     chatter_msg_update
  772.     @fiber.resume if @fiber
  773.   end
  774.   # alias
  775.   alias chatter_msg_update_placement update_placement
  776.   def update_placement
  777.     if @message_window.pop_message?
  778.       self.opacity = 0
  779.       self.width = @message_window.width-26 + padding * 2
  780.       self.width = [width, Graphics.width].min
  781.       self.height = fitting_height($game_message.choices.size)
  782.       self.x = @message_window.x
  783.       self.y = @message_window.y+@message_window.height-self.height+6
  784.     else
  785.       self.opacity = 255
  786.       chatter_msg_update_placement
  787.     end
  788.   end
  789. end
  790.  
  791. #==============================================================================
  792. # ■ Window_NameMessage
  793. #==============================================================================
  794. class Window_NameMessage < Window_Base
  795.   # alias
  796.   alias quack_msg_name_init initialize
  797.   def initialize(message_window)
  798.     quack_msg_name_init(message_window)
  799.     self.z += 1
  800.   end
  801.   # new
  802.   def update_pos
  803.     set_x_position(1)
  804.     #set_y_position
  805.     self.y = @message_window.y - self.height / 1.5
  806.     #self.y = 0 if self.y < 0
  807.   end
  808.   # overwrite
  809.       #  self.y = @message_window.height
  810.       #  self.y -= YEA::MESSAGE::NAME_WINDOW_Y_BUFFER
  811.       #else
  812.       #  self.y = @message_window.y - self.height / 1.25
  813.       #  self.y += YEA::MESSAGE::NAME_WINDOW_Y_BUFFER
  814.       #end
  815. end
  816.  
  817. #==============================================================================
  818. # ¡ Window_Message_Face
  819. #==============================================================================
  820.  
  821. class Window_Message_Face < Window_Base
  822.   alias quack_msg_face_pos set_position
  823.   def set_position
  824.     quack_msg_face_pos
  825.     self.y -= 4
  826.   end
  827. end
  828.  
  829. #==============================================================================
  830. # ?! Window_Quack_Message
  831. #==============================================================================
  832. class Window_Quack_Message < Window_Message
  833.   attr_accessor :active
  834.  
  835.   # overwrite
  836.   def initialize(msg_source, zz)
  837.     super()
  838.     self.z = zz
  839.     @quack_msg_source = msg_source
  840.     @active = false
  841.     @showing = true
  842.     @tag_showing = false
  843.     @background = 0
  844.     self.opacity = 255
  845.     self.visible = false
  846.     clear_name_window if $imported["YEA-MessageSystem"]
  847.   end
  848.   # overwrite
  849.   def chatter?
  850.     true
  851.   end
  852.   # overwrite
  853.   def source
  854.     @quack_msg_source
  855.   end
  856.   # overwrite
  857.   def update
  858.     if @quack_msg_source.busy?
  859.       if @quack_msg_source.expire?
  860.         close
  861.       else
  862.         self.visible = true if !self.visible && @showing
  863.         @quack_msg_source.ttl_sub
  864.       end
  865.     end
  866.     self.visible = false if self.visible && close?
  867.     super
  868.   end
  869.   # overwrite
  870.   def update_placement
  871.     return if @closing
  872.     super
  873.   end
  874.   # overwrite
  875.   def update_show_fast
  876.     return false
  877.   end
  878.   # overwrite
  879.   def process_all_text
  880.     @event_pop_id = nil
  881.     text = convert_escape_characters(@quack_msg_source.all_text)
  882.     update_placement
  883.     adjust_pop_message(text)
  884.     open_and_wait
  885.     #text = convert_escape_characters(@quack_msg_source.all_text)
  886.     pos = {}
  887.     new_page(text, pos)
  888.     process_character(text.slice!(0, 1), text, pos) until text.empty? || close?
  889.   end
  890.   # overwrite
  891.   def close
  892.     pop_message_close #super
  893.     return unless @event_pop_id
  894.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  895.     @speech_bubble_tag.visible = false if @speech_bubble_tag
  896.     @thought_bubble_tag.visible = false if @thought_bubble_tag
  897.     source.ev_id = nil
  898.     @name_text = ""
  899.     @showing = true
  900.   end
  901.   # overwrite
  902.   def input_pause
  903.     self.pause = true
  904.     wait(10)
  905.     Fiber.yield until close?
  906.     self.pause = false
  907.   end
  908.   # overwrite
  909.   def update_fiber
  910.     if @fiber
  911.       @fiber.resume
  912.     elsif @quack_msg_source.busy?
  913.       @fiber = Fiber.new { fiber_main }
  914.       @fiber.resume
  915.     else
  916.       @quack_msg_source.visible = false
  917.     end
  918.   end
  919.   def fiber_main
  920.     @quack_msg_source.visible = true
  921.     #update_background
  922.     update_placement
  923.     loop do
  924.       process_all_text if @quack_msg_source.has_text?
  925.       process_input
  926.       @quack_msg_source.clear
  927.       @name_window.start_close if $imported["YEA-MessageSystem"]
  928.       Fiber.yield
  929.       break unless text_continue?
  930.     end
  931.     close_and_wait
  932.     @quack_msg_source.visible = false
  933.     @fiber = nil
  934.   end
  935.   #def update_background
  936.   #  @background = @quack_msg_source.background
  937.   #  self.opacity = @background == 0 ? 255 : 0
  938.   #end
  939.   def process_input
  940.     input_pause unless @pause_skip
  941.   end
  942.   def text_continue?
  943.     @quack_msg_source.has_text?# && !settings_changed?
  944.   end
  945.   def settings_changed?
  946.     #@background != $game_message.background ||
  947.     #@position != @quack_msg_source.position
  948.     false
  949.   end
  950.   def new_page(text, pos)
  951.     contents.clear
  952.     draw_face(@quack_msg_source.face_name, @quack_msg_source.face_index, 0, 0)
  953.     reset_font_settings
  954.     pos[:x] = new_line_x
  955.     pos[:y] = 0
  956.     pos[:new_x] = new_line_x
  957.     pos[:height] = calc_line_height(text)
  958.     clear_flags
  959.   end
  960.   def new_line_x
  961.     @quack_msg_source.face_name.empty? ? 0 : 112
  962.   end
  963.   # overwrite
  964.   def input_pause
  965.     #self.pause = true
  966.     wait(10)
  967.     Fiber.yield until @quack_msg_source.expire? #Input.trigger?(:B) || Input.trigger?(:C)
  968.     #Input.update
  969.     #self.pause = false
  970.   end
  971.  
  972.   # overwrite
  973.   def create_all_windows
  974.     @name_window = Window_NameMessage.new(self) if $imported["YEA-MessageSystem"]
  975.   end
  976.   # overwrite
  977.   def dispose_all_windows
  978.     @name_window.dispose if $imported["YEA-MessageSystem"]
  979.   end
  980.   # overwrite
  981.   def update_all_windows
  982.     if $imported["YEA-MessageSystem"]
  983.       @name_window.update
  984.       @name_window.back_opacity = self.back_opacity
  985.       @name_window.opacity = self.opacity
  986.     end
  987.   end
  988.   # overwrite
  989.   def event_pop_message_update_placement
  990.   end
  991.   # overwrite
  992.   def all_close?
  993.     close? && (!$imported["YEA-MessageSystem"] || @name_window.close?)
  994.   end
  995.  
  996.   if $imported["YEA-MessageSystem"]
  997.     def close_and_wait
  998.       @name_window.force_close
  999.       window_message_close_and_wait_ams
  1000.     end
  1001.   end
  1002.   # new
  1003.   def hide_me
  1004.     @showing = false
  1005.     self.visible = false
  1006.     if @bubble_tag
  1007.       @tag_showing = @bubble_tag.visible
  1008.       @bubble_tag.visible = false
  1009.     end
  1010.   end
  1011.   # new
  1012.   def show_me
  1013.     @showing = true
  1014.     @bubble_tag.visible = true if @bubble_tag && @tag_showing && !close?
  1015.   end
  1016. end
  1017.  
  1018. #==============================================================================
  1019. # ?! Scene_Map
  1020. #==============================================================================
  1021.  
  1022. class Scene_Map < Scene_Base
  1023.   # alias
  1024.   alias quack_msg_update update
  1025.   def update
  1026.     $game_message.update_chatter
  1027.     @message_window.update_placement if @message_window.open?
  1028.     quack_msg_update
  1029.   end
  1030.   # overwrite
  1031.   def create_message_window
  1032.     yse_pm_create_message_window
  1033.     @face_window = Window_Message_Face.new
  1034.     @face_window.message_window = @message_window
  1035.     if @bubble_tag_sprite || @thought_bubble_tag_sprite
  1036.     @bubble_tag_sprite.dispose
  1037.     @thought_bubble_tag_sprite.dispose
  1038.     end
  1039.     if YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  1040.       @bubble_tag_sprite = Sprite.new
  1041.       @bubble_tag_sprite.visible = false
  1042.       @bubble_tag_sprite.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT2[:bubble_tag_name])
  1043.       @bubble_tag_sprite.src_rect.set(0, 0, @bubble_tag_sprite.width, @bubble_tag_sprite.height / 2)
  1044.       @message_window.speech_bubble_tag = @bubble_tag_sprite
  1045.  
  1046.       @thought_bubble_tag_sprite = Sprite.new
  1047.       @thought_bubble_tag_sprite.visible = false
  1048.       @thought_bubble_tag_sprite.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT2[:thought_bubble_tag_name])
  1049.       @thought_bubble_tag_sprite.src_rect.set(0, 0, @thought_bubble_tag_sprite.width, @thought_bubble_tag_sprite.height / 2)
  1050.       @message_window.thought_bubble_tag = @thought_bubble_tag_sprite
  1051.     end
  1052.     @message_window.face_window = @face_window
  1053.  
  1054.     $game_message.show_chatter
  1055.   end
  1056.   # overwrite
  1057.   def dispose_spriteset
  1058.     pop_message_dispose_spriteset
  1059.     return unless @bubble_tag_sprite || @thought_bubble_tag_sprite
  1060.     @bubble_tag_sprite.dispose
  1061.     @thought_bubble_tag_sprite.dispose
  1062.   end
  1063.   # alias
  1064.   alias qmsg_disp_wind dispose_all_windows
  1065.   def dispose_all_windows
  1066.     qmsg_disp_wind
  1067.     $game_message.hide_chatter
  1068.   end
  1069.   # alias
  1070.   alias qmsg_upd_encounter update_encounter
  1071.   def update_encounter
  1072.     qmsg_upd_encounter
  1073.     $game_message.clear_chatter if $game_player.encounter
  1074.   end
  1075. end
  1076.  
  1077. #==============================================================================
  1078. # ?! Scene_Battle
  1079. #==============================================================================
  1080. class Scene_Battle
  1081.   # alias
  1082.   alias quack_update_basic update_basic
  1083.   def update_basic
  1084.     quack_update_basic
  1085.     $game_message.update_chatter
  1086.   end
  1087.   # alias
  1088.   alias yse_pop_create_message_window create_message_window
  1089.   def create_message_window
  1090.     yse_pop_create_message_window
  1091.     @face_window = Window_Message_Face.new
  1092.     @face_window.message_window = @message_window
  1093.     if YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  1094.       @bubble_tag_sprite = Sprite.new
  1095.       @bubble_tag_sprite.visible = false
  1096.       @bubble_tag_sprite.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT2[:bubble_tag_name])
  1097.       @bubble_tag_sprite.src_rect.set(0, 0, @bubble_tag_sprite.width, @bubble_tag_sprite.height / 2)
  1098.       @message_window.speech_bubble_tag = @bubble_tag_sprite
  1099.  
  1100.       @thought_bubble_tag_sprite = Sprite.new
  1101.       @thought_bubble_tag_sprite.visible = false
  1102.       @thought_bubble_tag_sprite.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT2[:thought_bubble_tag_name])
  1103.       @thought_bubble_tag_sprite.src_rect.set(0, 0, @thought_bubble_tag_sprite.width, @thought_bubble_tag_sprite.height / 2)
  1104.       @message_window.thought_bubble_tag = @thought_bubble_tag_sprite
  1105.  
  1106.     end
  1107.     @message_window.face_window = @face_window
  1108.  
  1109.     $game_message.show_chatter
  1110.   end
  1111.   # alias
  1112.   alias yse_pop_dispose_spriteset dispose_spriteset
  1113.   def dispose_spriteset
  1114.     yse_pop_dispose_spriteset
  1115.     return unless @bubble_tag_sprite || @thought_bubble_tag_sprite
  1116.     @bubble_tag_sprite.dispose
  1117.     @thought_bubble_tag_sprite.dispose
  1118.   end
  1119.   # alias
  1120.   alias qmsg_disp_wind dispose_all_windows
  1121.   def dispose_all_windows
  1122.     qmsg_disp_wind
  1123.     $game_message.hide_chatter
  1124.   end
  1125. end
  1126.  
  1127. #==============================================================================
  1128. # ?! Game_Interpreter
  1129. #==============================================================================
  1130. class Game_Interpreter
  1131.   # overwrite
  1132.   def command_101
  1133.     item = $data_items[20]
  1134.     if $imported["YEA-MessageSystem"]
  1135.       wait_for_message
  1136.       $game_message.face_name = @params[0]
  1137.       $game_message.face_index = @params[1]
  1138.       $game_message.background = @params[2]
  1139.       $game_message.position = @params[3]
  1140.  
  1141.       startindex = @index+1
  1142.       textline = @list[startindex].parameters[0].dup
  1143.       chatdur = 0
  1144.       textline.gsub!(/<cm:([^<>]*)>/i) { chatdur = $1.to_i;"" }
  1145.       $game_message.prepare_msg(chatdur) if chatdur != 0
  1146.       while continue_message_string?
  1147.         @index += 1
  1148.         if @list[@index].code == 401
  1149.           textline = @list[@index].parameters[0] unless @index == startindex
  1150.           if chatdur != 0; $game_message.add_chatter(textline)
  1151.           else; $game_message.add(textline)
  1152.           end
  1153.         end
  1154.         break if $game_message.texts.size >= Variable.message_rows
  1155.       end
  1156.       case next_event_code
  1157.       when 102
  1158.         @index += 1
  1159.         setup_choices(@list[@index].parameters)
  1160.       when 103
  1161.         @index += 1
  1162.         setup_num_input(@list[@index].parameters)
  1163.       when 104
  1164.         @index += 1
  1165.         setup_item_choice(@list[@index].parameters)
  1166.       end
  1167.       $game_message.fin_msg if chatdur != 0
  1168.       wait_for_message
  1169.     else
  1170.       wait_for_message
  1171.       $game_message.face_name = @params[0]
  1172.       $game_message.face_index = @params[1]
  1173.       $game_message.background = @params[2]
  1174.       $game_message.position = @params[3]
  1175.  
  1176.       startindex = @index+1
  1177.       textline = @list[startindex].parameters[0].dup
  1178.       chatdur = 0
  1179.       textline.gsub!(/<cm:([^<>]*)>/i) { chatdur = $1.to_i;"" }
  1180.       $game_message.prepare_msg(chatdur) if chatdur != 0
  1181.  
  1182.       while next_event_code == 401       # Text data
  1183.         @index += 1
  1184.         textline = @list[@index].parameters[0] unless @index == startindex
  1185.         if chatdur != 0; $game_message.add_chatter(textline)
  1186.         else; $game_message.add(textline)
  1187.         end
  1188.       end
  1189.       case next_event_code
  1190.       when 102  # Show Choices
  1191.         @index += 1
  1192.         setup_choices(@list[@index].parameters)
  1193.       when 103  # Input Number
  1194.         @index += 1
  1195.         setup_num_input(@list[@index].parameters)
  1196.       when 104  # Select Item
  1197.         @index += 1
  1198.         setup_item_choice(@list[@index].parameters)
  1199.       end
  1200.       $game_message.fin_msg if chatdur != 0
  1201.       wait_for_message
  1202.     end
  1203.   end
  1204.   # new
  1205.   def clear_chatter
  1206.     $game_message.clear_chatter
  1207.   end
  1208.   # alias
  1209.   alias qmsg_cmd301 command_301
  1210.   def command_301
  1211.     $game_message.clear_chatter
  1212.     qmsg_cmd301
  1213.   end
  1214.   # new
  1215.   def event_on_screen(evtag)
  1216.     e = $game_map.first_event_tag(evtag)
  1217.     return e.screen_x >= -32 && e.screen_x < 672 && e.screen_y >= 0 && e.screen_y < 512
  1218.   end
  1219.   # new
  1220.   def event_within_earshot(evtag)
  1221.     e = $game_map.first_event_tag(evtag)
  1222.     return e.screen_x >= -352 && e.screen_x < 992 && e.screen_y >= -240 && e.screen_y < 752
  1223.   end
  1224.   # new
  1225.   def make_chatter(evtag, dur, text, thought=false, mute=false)
  1226.     $game_message.prepare_message(dur)
  1227.     text = "<ts:0>" + text if mute
  1228.     if thought
  1229.       $game_message.create_chatter("<btt:"+evtag+">" + text)
  1230.     else
  1231.       $game_message.create_chatter("<bt:"+evtag+">" + text)
  1232.     end
  1233.     $game_message.fin_msg
  1234.   end
  1235. end
  1236.  
  1237. #==============================================================================
  1238. #
  1239. # ?\ End of File
  1240. #
  1241. #==============================================================================

Lv6.析梦学徒

老鹰

梦石
40
星屑
33412
在线时间
6552 小时
注册时间
2012-5-26
帖子
3178

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

2
发表于 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 塞糖

查看全部评分

回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
24292
在线时间
5047 小时
注册时间
2016-3-8
帖子
1618
3
 楼主| 发表于 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中无效
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
24292
在线时间
5047 小时
注册时间
2016-3-8
帖子
1618
4
 楼主| 发表于 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
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-27 01:46

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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