modern_algebra

[VXA] ATS: Message Options 1.0.7

Sep 8th, 2012
5,122
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. #    ATS: Message Options [VXA]
  3. #    Version: 1.0.7
  4. #    Author: modern algebra (rmrk.net)
  5. #    Date: 28 January 2013
  6. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. #  Description:
  8. #
  9. #    This script allows you to control a number of things about the message
  10. #   window, such as its size and position. It also provides for scrolling
  11. #   and review, and it includes the option to create a name window to identify
  12. #   the speaker (or for any other use).
  13. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  14. #  ATS Series:
  15. #
  16. #    This script is part of the Advanced Text System series of scripts. These
  17. #   scripts are based off the Advanced Text System for RMVX, but since RMVX Ace
  18. #   has a much more sensibly designed message system, it is no longer necessary
  19. #   that it be one large script. For that reason, and responding to feedback on
  20. #   the ATS, I have split the ATS into multiple different scripts so that you
  21. #   only need to pick up the components for the features that you want. It is
  22. #   therefore easier to customize and configure.
  23. #
  24. #    To find more scripts in the ATS Series, please visit:
  25. #      http://rmrk.net/index.php/topic,44525.0.html
  26. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  27. #  Instructions:
  28. #
  29. #    There are a lot of configuration options in this script, and I direct you
  30. #   to the Editable Region at line 125 for detailed comments on what each does
  31. #   Here, I will just list them:
  32. #
  33. #          :append_text                       :scrolling_on
  34. #          :scroll_speed                      :pause_before_scroll
  35. #          :scroll_by_page                    :scroll_review
  36. #          :letter_sound_on                   :letter_se
  37. #          :letters_per_se                    :random_pitch
  38. #          :start_sound_on                    :start_se
  39. #          :pause_sound_on                    :pause_se
  40. #          :terminate_sound_on                :terminate_se
  41. #          :finish_sound_on                   :finish_se
  42. #          :message_windowskin                :message_dim_bg
  43. #          :message_win_x                     :message_win_y
  44. #          :character_size_offset             :do_not_obscure
  45. #          :message_win_width                 :message_win_height
  46. #          :message_win_padding               :fit_window_to_message
  47. #          :fit_window_width_range            :fit_window_height_range
  48. #          :name_win_min_width                :name_win_padding
  49. #          :name_format                       :name_win_align
  50. #          :name_win_x                        :name_win_y
  51. #          :name_win_x_offset                 :name_win_y_offset
  52. #
  53. #    As with other ATS scripts, you can change the value of these options in
  54. #   game with the following codes in a script call:
  55. #
  56. #      ats_next(:message_option, x)
  57. #      ats_all(:message_option, x)
  58. #
  59. #   Where :message_option is the symbol you want and x is the value you want
  60. #   to change it to. ats_next will only change it for the very next message,
  61. #   while ats_all will change it for every message to follow.
  62. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  63. #  List of Special Message Codes:
  64. #
  65. #    The following is a complete list of the message codes at your disposal.
  66. #   Simply insert them into a Display Message command.
  67. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68. #  Name Box:
  69. #
  70. # \nb{text}   - Shows the namebox with text displayed.
  71. # \nbl{text}  - Shows the namebox left of the message with text displayed.
  72. # \nbr{text}  - Shows the namebox right of the message with text displayed.
  73. # \nbt{text}  - Shows the namebox above the message with text displayed.
  74. # \nbb{text}  - Shows the namebox below the message with text displayed.
  75. # \nblt{text} - Shows the namebox left and above with text displayed.
  76. # \nblb{text} - Shows the namebox left and below with text displayed.
  77. # \nbrt{text} - Shows the namebox right and above with text displayed.
  78. # \nbrb{text} - Shows the namebox right and below with text displayed.
  79. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  80. #  Message Size and Position:
  81. #
  82. # \fit   - Fits the window to this message (:paragraph_format must be false)
  83. # \e[n]  - Sets the text box in reference to character n(0 = Player; >0 = Event)
  84. # \et[n] - Sets the text box above character n (0 = Player; >0 = Event)
  85. # \eb[n] - Sets the text box below character n (0 = Player; >0 = Event)
  86. # \el[n] - Sets the text box to the left of character n(0 = Player; >0 = Event)
  87. # \er[n] - Sets the text box to the right of character n(0 = Player; >0 = Event)
  88. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  89. #  Sound Effects:
  90. #
  91. # \lse - Turns the letter by letter SE on.
  92. # /lse - Turns the letter by letter SE off.
  93. # \pse - Turns the pause SE on.
  94. # /pse - Turns the pause SE off.
  95. # \fse - Turns the finish SE on.
  96. # /fse - Turns the finish SE off.
  97. # \tse - Turns the terminate SE on.
  98. # /tse - Turns the terminate SE off.
  99. # \pSE[file,x,y] - Play the "file" SE at volume x and pitch y
  100. # \pME[file,x,y] - Play the "file" ME at volume x and pitch y
  101. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  102. #  Other Effects:
  103. #
  104. # \pANIM[x,n] - Play the animation with ID n over character x
  105. # \pBLN[x,n] - Play the balloon with ID n over character x
  106. #==============================================================================
  107.  
  108. $imported = {} unless $imported
  109. $imported[:ATS_MessageOptions] = true
  110.  
  111. #==============================================================================
  112. # ** Game_ATS
  113. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  114. #  Summary of Changes:
  115. #    new public instance variables - append_text; scrolling_on; scroll_speed;
  116. #      pause_before_scroll; scroll_by_page; scroll_review; letter_sound_on;
  117. #      letter_se; letters_per_se; random_pitch; start_sound_on; start_se;
  118. #      pause_sound_on; pause_se; terminate_sound_on; terminate_se;
  119. #      finish_sound_on; finish_se; message_windowskin; message_dim_bg;
  120. #      message_win_x; message_win_y; character_size_offset; do_not_obscure;
  121. #      message_win_width; message_win_height; message_win_padding;
  122. #      fit_window_to_message; fit_window_width_range; fit_window_height_range;
  123. #      name_win_min_width; name_win_padding; name_format; name_win_align;
  124. #      name_win_x; name_win_y; name_win_x_offset; name_win_y_offset
  125. #==============================================================================
  126.  
  127. class Game_ATS
  128.   CONFIG ||= {}
  129.   CONFIG[:ats_message_options] = {
  130.       ats_message_options: true,
  131.     #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  132.     #  EDITABLE REGION
  133.       #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  134.     #  :append_text - Set this value to either true or false. If true, then any
  135.     # immediately subsequent display text event commands with the same settings
  136.     # will be joined together and they will show in the same message window if
  137.     # there is space. This option is primarily useful for message scrolling and
  138.     # oversized windows. If you are using ATS: Formatting, the value set in
  139.     # this script applies and the one set in ATS: Formatting does not.
  140.     append_text:           true,
  141.       #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  142.     # Scrolling
  143.       #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  144.     #  If :scrolling_on is false, then whenever a message ends, it will pause
  145.     # and create a new page. If :scrolling_on is true, then it will smoothly
  146.     # scroll instead, and you can choose whether to scroll line by line or
  147.     # by page. Practically, :append_text needs to be true for this feature to
  148.     # be useful.
  149.     scrolling_on:          true,
  150.       #  :scroll_speed - the pixels scrolled per frame when scrolling. If this
  151.       # is 0, then it will be instant.
  152.       scroll_speed:        2,
  153.       #  :pause_before_scroll - when this is true, the message will pause
  154.       # before the page (or line) scrolls.
  155.       pause_before_scroll: false,
  156.       #  :scroll_by_page - If this is true, then the message will scroll one
  157.       # whole page at a time. If it is false, it will scroll after each line.
  158.       scroll_by_page:      false,
  159.       #  :scroll_review - When this is true, then at each time the message
  160.       # pauses, the player can use the Up and Down directional keys to review
  161.       # the entire message
  162.       scroll_review:       true,
  163.       #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  164.     # Sound Effects
  165.       #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  166.     # Letter By Letter SE
  167.     #  :letter_sound_on - when this is true, the sound specified below will
  168.     # be played as letters are drawn, according to a chosen frequency.
  169.     letter_sound_on:       true,
  170.       #  :letter_se - This determines what sound effect is played when
  171.       # :letter_sound_on is true. You set it as an array, with the first entry
  172.       # being the filename as a string, and the other entries being integers
  173.       # representing the volume. EX: ["Cursor2", 60],
  174.       letter_se:           ["Cursor2"],
  175.       #  :letters_per_se - This determines how frequently :letter_se is played
  176.       # when :letter_sound_on is true. Basically, the number you put in the
  177.       # amount of letters that are drawn between each sound effect. If, for
  178.       # instance, it is 5, then 5 letters are drawn between playing the SE.
  179.       letters_per_se:      4,
  180.       #  :random_pitch - This range determines the pitch the sound effect is
  181.       # played at. It is in the form x...y and if x is equal to y, then the SE
  182.       # is always played at that pitch. If they are different, x must be less
  183.       # than y and each SE will play at a pitch randomly selected between the
  184.       # x and y. It is used to simulate changes of pitch in speech.
  185.       random_pitch:        100...100,
  186.     # Start SE
  187.     #  :start_sound_on - when this is true, the sound specified at :start_se
  188.     # will play whenever a message first opens.
  189.     start_sound_on:        false,
  190.       #  :start_se - This determines what sound effect is played when
  191.       # :start_sound_on is true. You set it as an array, with the first entry
  192.       # being the filename as a string, and the other entries being integers
  193.       # representing the volume and the pitch. EX: ["Chime2", 80, 50],
  194.       start_se:            ["Chime2"],
  195.     # Pause SE
  196.     #  :pause_sound_on - when this is true, the sound specified at :pause_se is
  197.     # played whenever a message pauses and waits for player input.
  198.     pause_sound_on:        false,
  199.       #  :pause_se - This determines what sound effect is played when
  200.       # :pause_sound_on is true. You set it as an array, with the first entry
  201.       # being the filename as a string, and the other entries being integers
  202.       # representing the volume and the pitch. EX: ["Decision2"],
  203.       pause_se:            ["Decision2"],
  204.     # Finish SE
  205.     #  :finish_sound_on - when this is true, the sound specified at :finish_se
  206.     # is played whenever a message finishes.
  207.     finish_sound_on:       false,
  208.       #  :finish_se - This determines what sound effect is played when
  209.       # :finish_sound_on is true. You set it as an array, with the first entry
  210.       # being the filename as a string, and the other entries being integers
  211.       # representing the volume and the pitch. EX: ["Chime1", 120],
  212.       finish_se:           ["Chime1"],
  213.     # Terminate SE
  214.     #  :terminate_sound_on - when this is true, the sound specified at
  215.     # :terminate_se is played whenever a message finishes.
  216.     terminate_sound_on:    false,
  217.       #  :terminate_se - This determines what sound effect is played when
  218.       # :terminate_sound_on is true. You set it as an array, with the first
  219.       # entry being the filename as a string, and the other entries being
  220.       # integers representing the volume and the pitch. EX: ["Cancel2"],
  221.       terminate_se:        ["Cancel2"],
  222.       #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  223.     # Message Window Settings
  224.       #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  225.     # Message Graphics
  226.     #  :message_windowskin - This sets the windowskin of the message window
  227.     # and all its related windows. The graphic chosen must be in the System
  228.     # folder of Graphics.
  229.     message_windowskin:    "Window",
  230.     #  :message_dim_bg - This feature allows you to replace the default dim
  231.     # background with an image of your choosing. Just set it to a filename. The
  232.     # graphic chosen must be in the System folder of Graphics
  233.     message_dim_bg:        "",
  234.     # Message Position
  235.     #  :message_win_x - This determines the x-coordinate of the message window.
  236.     # When set to -1, it is centred. When set to any other integer, it is
  237.     # directly set to that x-coordinate on the screen. This is completely
  238.     # overridden when you use message codes to set the message window in
  239.     # reference to a character.
  240.     message_win_x:         -1, # -1 = centred
  241.     #  :message_win_y - This determines the y-coordinate of the message window.
  242.     # When set to -1, it defaults to the position setting in the normal message
  243.     # window. When set to any other integer, it is directly set to that
  244.     # y-coordinate on the screen. This is completely overridden when you
  245.     # use message codes to set the message window in reference to a character.
  246.     message_win_y:         -1, # -1 = default to position
  247.     #  :character_size_offset - This feature is used when setting the message
  248.     # window's position in reference to a character, and it should be set to
  249.     # the size of the character (in the direction the window is being set). In
  250.     # other words, if setting a window to above or below the character, this
  251.     # should be set to the height of that character. If setting it to the left
  252.     # or right of a character, this should be set to the width of the character
  253.     character_size_offset: 32,
  254.     #  :do_not_obscure - This feature is only useful if :message_win_y is set
  255.     # to -1 and you are using the default position setting. Basically, if you
  256.     # put the ID of any character (0 is the player; otherwise the ID of the
  257.     # event you don't want to obscure) in this array, then the message window
  258.     # will be repositioned so as not to obscure that character. In other words,
  259.     # if you set this value to [0, 5], then the message window will never
  260.     # obscure either the player or the event with ID 5. So, if a message window
  261.     # is set to bottom, but drawing it at the bottom would cover the player,
  262.     # then the message window will instead be positioned to Top.
  263.     do_not_obscure:        [],
  264.     # Message Window Size
  265.     #  :message_win_width - This sets the width, in pixels, of the message
  266.     # window. It is overridden if :fit_window_to_message is true.
  267.     message_win_width:     544,
  268.     #  :message_win_height - This sets the height, in pixels, of the message
  269.     # window. A normal line of text is 24 pixels high. This value is overridden
  270.     # if :fit_window_to_message is true.
  271.     message_win_height:    120,
  272.     #  :message_win_padding - This value determines the size, in pixels, of the
  273.     # border of the message window
  274.     message_win_padding:   12,
  275.     #  :fit_window_to_message - when this is true, the message window's width
  276.     # will be fitted to the longest line and the message window's height will
  277.     # be set to include as many lines as possible. The sizes in both respects
  278.     # are limited by :fit_window_width_range and :fit_window_height_range. If
  279.     # you are using ATS: Formatting, then this feature will only work if
  280.     # :paragraph_format is off.
  281.     fit_window_to_message: false,
  282.       #  :fit_window_width_range - This is a range in the form x...y, where
  283.       # x must be less than y. x is the minimum width the window to which the
  284.       # window can be set when using :fit_window_to_message, while y is the
  285.       # maximum.
  286.       fit_window_width_range: 160...544,
  287.       #  :fit_window_height_range - This is a range in the form x...y, where
  288.       # x must be less than y. x is the minimum height the window to which the
  289.       # window can be set when using :fit_window_to_message, while y is the
  290.       # maximum.
  291.       fit_window_height_range: 72...144,
  292.       #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  293.     # Name Window Settings
  294.       #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  295.     # Name Window Size
  296.     #  :name_win_min_width - normally, the name window will be sized to fit
  297.     # whatever name is input in it. This value determines the minimum width
  298.     # that the name window can be, such that if the name is shorter, the
  299.     # name window will be set to this size.
  300.     name_win_min_width:    32,
  301.     #  :name_win_padding - this determines the size of the border of the name
  302.     # window. The default for most other windows is 12.
  303.     name_win_padding:      8,
  304.     # Name Format
  305.     #  :name_format - This allows you to set some default formatting for names.
  306.     # Basically, it is a string ('%s'), and the %s will be replaced by whatever
  307.     # name you set for the message. This allows you to use some special message
  308.     # codes for every name, without having to put it in. For instance, if you
  309.     # set this value to '\c[16]%s', then every name would automatically be set
  310.     # to colour 16.
  311.     name_format:          '%s',
  312.     #  :name_win_align - This sets the alignment of the name in the window.
  313.     # Since the window is normally sized to fit the name, this will generally
  314.     # only matter if the name is short enough to engage the :name_win_min_width
  315.     # or if there is more than one line in the name window.
  316.     name_win_align:       1,
  317.     # Name Position
  318.     #  :name_win_x - This sets the x-position of the name window. It can be set
  319.     # to either :l, :r, or an integer. If :l, it will be set flush with the left
  320.     # corners of the message window, offset by + :name_win_x_offset. If :r, it
  321.     # will be set flush with the right corners of the message window, offset
  322.     # by - :name_win_x_offset. If an integer, it will be directly set to that
  323.     # x-coordinate on the screen.
  324.     name_win_x:           :l,
  325.     #  :name_win_y - This sets the y-position of the name window. It can be set
  326.     # to either :t, :b, or an integer. If :t, it will be set flush with the top
  327.     # corners of the message window, offset by + :name_win_y_offset. If :b, it
  328.     # will be set flush with the bottom corners of the message window, offset
  329.     # by - :name_win_y_offset. If an integer, it will be directly set to that
  330.     # y-coordinate on the screen.
  331.     name_win_y:           :t,
  332.     #  :name_win_x_offset - this is the number of pixels offset when
  333.     # :name_win_x is set to :l or :r. When :l, it is added. When :r, it is
  334.     # subtracted.
  335.     name_win_x_offset:    8,
  336.     #  :name_win_y_offset - this is the number of pixels offset when
  337.     # :name_win_y is set to :t or :b. When :t, it is added. When :b, it is
  338.     # subtracted.
  339.     name_win_y_offset:    8,
  340.       #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  341.     #  END EDITABLE REGION
  342.     #////////////////////////////////////////////////////////////////////////
  343.   }
  344.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  345.   # * Public Instance Variables
  346.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  347.   CONFIG[:ats_formatting].delete(:append_text) if $imported[:ATS_Formatting]
  348.   CONFIG[:ats_message_options].keys.each { |key| attr_accessor key }
  349.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  350.   # * Overwrite SE methods
  351.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  352.   [:letter_se, :start_se, :pause_se, :finish_se, :terminate_se].each { |method_name|
  353.     define_method(:"#{method_name}=") do |*args|
  354.       instance_variable_set(:"@#{method_name}", Game_ATS.set_sound_effect(*args))
  355.     end
  356.   }
  357.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  358.   # * Set Sound Effect
  359.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  360.   def self.set_sound_effect(settings)
  361.     return settings if settings.is_a?(RPG::SE)
  362.     settings = [settings] if settings.is_a?(String)
  363.     settings[1] = 80 if !settings[1]
  364.     RPG::SE.new(*settings)
  365.   end
  366.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  367.   # * Set Random Pitch
  368.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  369.   def random_pitch=(val)
  370.     @random_pitch = val.is_a?(Integer) ? letter_se.pitch..(letter_se.pitch + val) : val
  371.   end
  372. end
  373.  
  374. #==============================================================================
  375. #  Initialize Common ATS Data if no other ATS script interpreted first
  376. #==============================================================================
  377.  
  378. if !$imported[:AdvancedTextSystem]
  379.   #============================================================================
  380.   # *** DataManager
  381.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  382.   #  Summary of Changes:
  383.   #    aliased method - create_game_objects; make_save_contents;
  384.   #      extract_save_contents
  385.   #============================================================================
  386.   module DataManager
  387.     class << self
  388.       alias modb_ats_crtgmobj_6yh7 create_game_objects
  389.       alias mlba_ats_mksave_5tg9 make_save_contents
  390.       alias ma_ats_extrcsvcon_8uj2 extract_save_contents
  391.     end
  392.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  393.     # * Create Game Objects
  394.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  395.     def self.create_game_objects(*args, &block)
  396.       modb_ats_crtgmobj_6yh7(*args, &block)
  397.       $game_ats = Game_ATS.new
  398.       $game_ats.init_new_installs
  399.     end
  400.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  401.     # * Make Save Contents
  402.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  403.     def self.make_save_contents(*args, &block)
  404.       contents = mlba_ats_mksave_5tg9(*args, &block)
  405.       contents[:ats] = $game_ats
  406.       contents
  407.     end
  408.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  409.     # * Extract Save Contents
  410.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  411.     def self.extract_save_contents(contents, *args, &block)
  412.       ma_ats_extrcsvcon_8uj2(contents, *args, &block)
  413.       $game_ats = contents[:ats] ? contents[:ats] : Game_ATS.new
  414.       $game_ats.init_new_installs
  415.     end
  416.   end
  417.  
  418.   #============================================================================
  419.   # ** Game_ATS
  420.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  421.   #  This class holds the default data for all scripts in the ATS series
  422.   #============================================================================
  423.  
  424.   class Game_ATS
  425.     def initialize; reset; end
  426.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  427.     # * Reset any or all installed ATS scripts
  428.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  429.     def reset(script_name = nil)
  430.       if script_name.is_a? (Symbol) # If script to reset specified
  431.         CONFIG[script_name].each_pair { |key, value|
  432.           self.send("#{key}=".to_sym, value)
  433.           $game_message.send("#{key}=".to_sym, value)
  434.         }
  435.       else                          # Reset all ATS scripts
  436.         CONFIG.keys.each { |script| reset(script) }
  437.       end
  438.     end
  439.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  440.     # * Initialize any newly installed ATS scripts
  441.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  442.     def init_new_installs
  443.       CONFIG.keys.each { |script| reset(script) unless self.send(script) }
  444.     end
  445.   end
  446.  
  447.   #============================================================================
  448.   # ** Game_Message
  449.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  450.   #  Summary of Changes:
  451.   #    aliased method - clear
  452.   #============================================================================
  453.  
  454.   class Game_Message
  455.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  456.     # * Clear
  457.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  458.     alias mlb_ats_clrats_5tv1 clear
  459.     def clear(*args, &block)
  460.       mlb_ats_clrats_5tv1(*args, &block) # Run Original Method
  461.       return if !$game_ats
  462.       Game_ATS::CONFIG.values.each { |installed|
  463.         installed.keys.each { |key| self.send("#{key}=".to_sym, $game_ats.send(key)) }
  464.       }
  465.     end
  466.   end
  467.  
  468.   #============================================================================
  469.   # ** Game_Interpreter
  470.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  471.   #  Summary of Changes:
  472.   #    new methods - ats_all; ats_next
  473.   #============================================================================
  474.  
  475.   class Game_Interpreter
  476.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  477.     # * ATS All
  478.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  479.     def ats_all(sym, *args, &block)
  480.       $game_ats.send("#{sym}=".to_sym, *args, &block)
  481.       ats_next(sym, *args, &block)
  482.     end
  483.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  484.     # * ATS Next
  485.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  486.     def ats_next(sym, *args, &block)
  487.       $game_message.send("#{sym}=".to_sym, *args, &block)
  488.     end
  489.   end
  490. $imported[:AdvancedTextSystem] = true
  491. end
  492.  
  493. #==============================================================================
  494. # ** Game_Message
  495. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  496. #  Summary of Changes:
  497. #    new attr_reader methods - show_on_character_id; show_on_character_pos
  498. #    new attr_accessor methods - append_text; scrolling_on; scroll_speed;
  499. #      pause_before_scroll; scroll_by_page; scroll_review; letter_sound_on;
  500. #      letter_se; letters_per_se; random_pitch; start_sound_on; start_se;
  501. #      pause_sound_on; pause_se; terminate_sound_on; terminate_se;
  502. #      finish_sound_on; finish_se; message_windowskin; message_dim_bg;
  503. #      message_win_x; message_win_y; character_size_offset; do_not_obscure;
  504. #      message_win_width; message_win_height; message_win_padding;
  505. #      fit_window_to_message; fit_window_width_range; fit_window_height_range;
  506. #      name_win_min_width; name_win_padding; name_format; name_win_align;
  507. #      name_win_x; name_win_y; name_win_x_offset; name_win_y_offset;
  508. #      message_name
  509. #    aliased method - clear; all_text
  510. #    new methods - atsmo_play_sound?; atsmo_setup_name_window
  511. #==============================================================================
  512.  
  513. class Game_Message
  514.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  515.   # * Public Instance Variables
  516.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  517.   attr_reader :message_name
  518.   attr_reader :show_on_character_id
  519.   attr_reader :show_on_character_pos
  520.   Game_ATS::CONFIG[:ats_message_options].keys.each { |key| attr_accessor key }
  521.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  522.   # * Clear
  523.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  524.   alias maatsmo_cler_2yx7 clear
  525.   def clear(*args, &block)
  526.     @show_on_character_id = -1
  527.     @show_on_character_pos = :t
  528.     @message_name = nil
  529.     tso = @terminate_sound_on # Don't reset terminate sound
  530.     maatsmo_cler_2yx7(*args, &block) # Call Original Method
  531.     @terminate_sound_on = tso unless tso.nil?
  532.   end
  533.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  534.   # SE Definitions
  535.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  536.   [:letter, :start, :pause, :finish, :terminate].each { |method_name|
  537.     define_method(:"#{method_name}_se=") do |*args|
  538.       instance_variable_set(:"@#{method_name}_se", Game_ATS.set_sound_effect(*args))
  539.     end
  540.   }
  541.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  542.   # * Play Sound?
  543.   #    type : :letter, :start, :pause, :finish, or :terminate
  544.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  545.   def atsmo_play_sound?(type)
  546.     return instance_variable_get(:"@#{type}_sound_on") &&
  547.       !instance_variable_get(:"@#{type}_se").nil?
  548.   end
  549.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  550.   # * Set Random Pitch
  551.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  552.   def random_pitch=(val)
  553.     @random_pitch = val.is_a?(Integer) ? letter_se.pitch..(letter_se.pitch + val) : val
  554.   end
  555.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  556.   # * Set Name for Name Window
  557.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  558.   def message_name=(string)
  559.     @message_name = !@name_format.empty? ? sprintf(@name_format, string) : string
  560.   end
  561.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  562.   # * All Text
  563.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  564.   alias maatsmo_altx_7jv2 all_text
  565.   def all_text(*args, &block)
  566.     result = maatsmo_altx_7jv2(*args, &block) # Call Original Method
  567.     # Look for the Name Box Code
  568.     if result[/\\NB([LRTB]*)\{(.+?)\}/im]
  569.       atsmo_setup_name_window($2, $1)
  570.       result.gsub!(/\\NB([LRTB]*)\{(.+?)\}/im, "")
  571.     end
  572.     if result[/([\\\/])FIT/i]
  573.       @fit_window_to_message = $1 == "\\"
  574.       result.gsub!(/[\\\/]FIT/i, "")
  575.     end
  576.     if result[/\\E([LRTB]?)\[(\d+)\]/i]
  577.       @show_on_character_pos = $1.downcase.to_sym if !$1.empty?
  578.       @show_on_character_id = $2.to_i
  579.       # Don't show on character if the event referenced is nil
  580.       @show_on_character_id = -1 if show_on_character_id > 0 && !$game_map.events[show_on_character_id]
  581.       result.gsub!(/\\E[LRTB]?\[\d+\]/i, "")
  582.     end
  583.     result
  584.   end
  585.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  586.   # * Set Name
  587.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  588.   def atsmo_setup_name_window(name, pos)
  589.     self.message_name = name
  590.     pos.each_char {|letter|
  591.       val = letter.downcase.to_sym
  592.       case val
  593.       when :l, :r then self.name_win_x = val
  594.       when :t, :b then self.name_win_y = val
  595.       end
  596.     }
  597.   end
  598. end
  599.  
  600. #==============================================================================
  601. # ** Game_Interpreter
  602. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  603. #  Summary of Changes:
  604. #    aliased methods - command_101; next_event_code
  605. #    new method - maatsf_same_message_conditions?
  606. #==============================================================================
  607.  
  608. if !$imported[:ATS_Formatting]
  609.   class Game_Interpreter
  610.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  611.     # * Display Text Message
  612.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  613.     alias maatsf_disptext_3jf5 command_101
  614.     def command_101(*args, &block)
  615.       @ats_appending_text = $game_message.append_text
  616.       maatsf_disptext_3jf5(*args, &block) # Call Original Method
  617.       @ats_appending_text = false
  618.     end
  619.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  620.     # * Next Event Code
  621.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  622.     alias maatsf_nexcode_5rq9 next_event_code
  623.     def next_event_code(*args, &block)
  624.       result = maatsf_nexcode_5rq9(*args, &block) # Call Original Method
  625.       if @ats_appending_text && result == 101
  626.         if maats_same_message_conditions?(@index + 1)
  627.           @index += 1
  628.           result = next_event_code(*args, &block)
  629.         end
  630.       end
  631.       result
  632.     end
  633.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  634.     # * Same Message Conditions?
  635.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  636.     def maats_same_message_conditions?(list_index)
  637.       n_params = @list[list_index].parameters
  638.       if ($imported[:MA_CompositeGraphics] || $imported[:ATS_FaceOptions]) &&
  639.         @list[list_index + 1] && @list[list_index + 1].parameters[0][/^\\([AP])F\[(\d+)\]/i]
  640.         param = $2.to_i
  641.         actor = ($1 == 'A') ? $game_actors[param] : $game_party.members[param - 1]
  642.         return (actor.face_name == $game_message.face_name &&
  643.           actor.face_index == $game_message.face_index &&
  644.           n_params[2] == $game_message.background && n_params[3] == $game_message.position)
  645.       end
  646.       n_params[0] == $game_message.face_name && n_params[1] == $game_message.face_index &&
  647.         n_params[2] == $game_message.background && n_params[3] == $game_message.position
  648.     end
  649.   end
  650. end
  651.  
  652. unless $imported[:"MA_ParagraphFormat_1.0.1"] # Overwrite if earlier version
  653.   #============================================================================
  654.   # ** MA_Window_ParagraphFormat
  655.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  656.   #  This module inserts into Window_Base and provides a method to format the
  657.   # strings so as to go to the next line if it exceeds a set limit. This is
  658.   # designed to work with draw_text_ex, and a string formatted by this method
  659.   # should go through that, not draw_text.
  660.   #============================================================================
  661.  
  662.   module MA_Window_ParagraphFormat
  663.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  664.     # * Calc Line Width
  665.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  666.     def mapf_calc_line_width(line, tw = 0, contents_dummy = false)
  667.       return tw if line.nil?
  668.       line = line.clone
  669.       unless contents_dummy
  670.         real_contents = contents # Preserve Real Contents
  671.         # Create a dummy contents
  672.         self.contents = Bitmap.new(contents_width, 24)
  673.         reset_font_settings
  674.       end
  675.       pos = {x: 0, y: 0, new_x: 0, height: calc_line_height(line)}
  676.       test = @atsf_testing
  677.       @atsf_testing = true # This
  678.       while line[/^(.*?)\e(.*)/]
  679.         tw += text_size($1).width
  680.         line = $2
  681.         # Remove all ancillaries to the code, like parameters
  682.         code = obtain_escape_code(line)
  683.         # If direct setting of x, reset tw.
  684.         tw = 0 if ($imported[:ATS_SpecialMessageCodes] && code.upcase == 'X') ||
  685.           ($imported["YEA-MessageSystem"] && code.upcase == 'PX')
  686.         #  If I need to do something special on the basis that it is testing,
  687.         # alias process_escape_character and differentiate using @atsf_testing
  688.         process_escape_character(code, line, pos)
  689.       end
  690.       @atsf_testing = test
  691.       #  Add width of remaining text, as well as the value of pos[:x] under the
  692.       # assumption that any additions to it are because the special code is
  693.       # replaced by something which requires space (like icons)
  694.       tw += text_size(line).width + pos[:x]
  695.       unless contents_dummy
  696.         contents.dispose # Dispose dummy contents
  697.         self.contents = real_contents # Restore real contents
  698.       end
  699.       return tw
  700.     end
  701.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  702.     # * Format Paragraph
  703.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  704.     def mapf_format_paragraph(text, max_width = contents_width)
  705.       text = text.clone
  706.       #  Create a Dummy Contents - I wanted to boost compatibility by using the
  707.       # default process method for escape codes. It may have the opposite effect,
  708.       # for some :(
  709.       real_contents = contents # Preserve Real Contents
  710.       self.contents = Bitmap.new(contents_width, 24)
  711.       reset_font_settings
  712.       paragraph = ""
  713.       while !text.empty?
  714.         oline, nline, tw = mapf_format_by_line(text.clone, max_width)
  715.         # Replace old line with the new one
  716.         text.sub!(/#{Regexp.escape(oline)}/m, nline)
  717.         paragraph += text.slice!(/.*?(\n|$)/)
  718.         text.lstrip!
  719.       end
  720.       contents.dispose # Dispose dummy contents
  721.       self.contents = real_contents # Restore real contents
  722.       return paragraph
  723.     end
  724.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  725.     # * Format By Line
  726.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  727.     def mapf_format_by_line(text, max_width = contents_width)
  728.       oline, nline, tw = "", "", 0
  729.       loop do
  730.         #  Format each word until reach the width limit
  731.         oline, nline, tw, done = mapf_format_by_word(text, nline, tw, max_width)
  732.         return oline, nline, tw if done
  733.       end
  734.     end
  735.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  736.     # * Format By Word
  737.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  738.     def mapf_format_by_word(text, line, tw, max_width)
  739.       return line, line, tw, true if text.nil? || text.empty?
  740.       # Extract next word
  741.       if text.sub!(/([ \t\r\f]*)(\S*)([\n\f]?)/, "") != nil
  742.         prespace, word, line_end = $1, $2, $3
  743.         ntw = mapf_calc_line_width(word, tw, true)
  744.         pw = contents.text_size(prespace).width
  745.         if (pw + ntw >= max_width)
  746.           # Insert
  747.           if line.empty?
  748.             # If one word takes entire line
  749.             return prespace + word, word + "\n", ntw, true
  750.           else
  751.             return line + prespace + word, line + "\n" + word, tw, true
  752.           end
  753.         else
  754.           line += prespace + word
  755.           tw = pw + ntw
  756.           # If the line is force ended, then end
  757.           return line, line, tw, true if !line_end.empty?
  758.         end
  759.       else
  760.         return line, line, tw, true
  761.       end
  762.       return line, line, tw, false
  763.     end
  764.   end
  765.  
  766.   class Window_Base
  767.     include MA_Window_ParagraphFormat unless $imported[:"MA_ParagraphFormat_1.0"]
  768.   end
  769.  
  770.   $imported[:"MA_ParagraphFormat_1.0"] = true
  771.   $imported[:"MA_ParagraphFormat_1.0.1"] = true
  772. end
  773.  
  774. #==============================================================================
  775. # *** MA Window ATS Message Options
  776. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  777. #  This module mixes in with Window_Message and the Name window
  778. #==============================================================================
  779.  
  780. module MA_Window_ATS_MessageOptions
  781.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  782.   # * Resize
  783.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  784.   def resize(w, h)
  785.     if w != self.width || h != self.height
  786.       self.width = w
  787.       self.height = h
  788.       create_contents
  789.     end
  790.   end
  791. end
  792.  
  793. #==============================================================================
  794. # ** Window_ATS_Name
  795. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  796. #  This window shows a single message to identify the speaker of a message.
  797. #==============================================================================
  798.  
  799. class Window_ATS_Name < Window_Base
  800.   include MA_Window_ATS_MessageOptions
  801.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  802.   # * Object Initialization
  803.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  804.   def initialize(message_window)
  805.     @message_window = message_window
  806.     super(0, 0, $game_message.name_win_min_width, line_height + standard_padding*2)
  807.     @current_windowskin = windowskin
  808.     update_placement
  809.     self.visible = false
  810.     self.z = @message_window.z + 1
  811.   end
  812.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  813.   # * Frame Update
  814.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  815.   def update(*args, &block)
  816.     super(*args, &block)
  817.     if $game_message.message_name.nil?
  818.       self.visible = false
  819.     else
  820.       self.openness = @message_window.openness
  821.       self.visible = @message_window.visible
  822.       self.opacity = @message_window.opacity
  823.       self.back_opacity = @message_window.back_opacity
  824.       set_text($game_message.message_name)
  825.     end
  826.   end
  827.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  828.   # * Update Placement
  829.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  830.   def update_placement
  831.     set_x_position
  832.     set_y_position
  833.     update_padding
  834.   end
  835.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  836.   # * Set X Position
  837.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  838.   def set_x_position
  839.     self.x = case $game_message.name_win_x
  840.     when :l then @message_window.x + $game_message.name_win_x_offset
  841.     when :r then @message_window.x + @message_window.width - self.width - $game_message.name_win_x_offset
  842.     else $game_message.name_win_x
  843.     end
  844.   end
  845.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  846.   # * Set y Position
  847.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  848.   def set_y_position
  849.     case $game_message.name_win_y
  850.     when :t
  851.       self.y = @message_window.y - self.height + $game_message.name_win_y_offset
  852.       self.y = @message_window.y + @message_window.height - $game_message.name_win_y_offset if self.y < 0
  853.     when :b
  854.       self.y = @message_window.y + @message_window.height - $game_message.name_win_y_offset
  855.       self.y = @message_window.y - self.height + $game_message.name_win_y_offset if self.y + self.height > Graphics.height
  856.     else
  857.       self.y = $game_message.name_win_y
  858.     end
  859.   end
  860.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  861.   # * Refresh
  862.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  863.   def refresh
  864.     contents.clear
  865.     align = $game_message.name_win_align
  866.     if align > 0
  867.       y = 0
  868.       for line in convert_escape_characters(@text.clone).split(/\n/)
  869.         tw = mapf_calc_line_width(line)
  870.         x = align*((contents_width - tw) / 2)
  871.         draw_text_ex(x, y, line)
  872.         y += calc_line_height(line)
  873.       end
  874.     else
  875.       draw_text_ex(0, 0, @text)
  876.     end
  877.   end
  878.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  879.   # * Set Text
  880.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  881.   def set_text(text)
  882.     if text.is_a?(String) && (@text != text || $game_message.name_win_min_width > contents.width)
  883.       @text = text
  884.       resize(*calc_window_size_by_text(text)) unless text.empty?
  885.       update_placement
  886.       refresh
  887.     end
  888.   end
  889.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  890.   # * Calculate Width and Height
  891.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  892.   def calc_window_size_by_text(text)
  893.     text = convert_escape_characters(text.clone)
  894.     # Calculate width and height of window
  895.     fit_w = $game_message.name_win_min_width
  896.     h = standard_padding*2
  897.     text.split(/\n/).each { |line|
  898.       h += calc_line_height(line)
  899.       tw = mapf_calc_line_width(line)
  900.       fit_w = tw if tw > fit_w
  901.     }
  902.     w = [fit_w + (standard_padding*2), Graphics.width].min
  903.     return w, h
  904.   end
  905.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  906.   # * Standard Padding
  907.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  908.   def standard_padding
  909.     $game_message.name_win_padding
  910.   end
  911. end
  912.  
  913. #==============================================================================
  914. # ** Window_Message
  915. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  916. #  Summary of Changes:
  917. #    aliased methods - initialize; create_all_windows; update_all_windows;
  918. #      update_placement; convert_escape_characters
  919. #    new method - maatsmo_convert_escape_characters; atsmo_update_placement_x;
  920. #      atsmo_update_placement_y; atsmo_update_placement_w;
  921. #      atsmo_update_placement_h;
  922. #    overwritten method - process_new_line; standard padding;
  923. #==============================================================================
  924.  
  925. class Window_Message
  926.   include MA_Window_ATS_MessageOptions
  927.   IS_ATSF_ABOVE = $imported[:ATS_Formatting] # Check if Formatting installed
  928.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  929.   # * Object Initialization
  930.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  931.   alias maatsmo_initz_2uq7 initialize
  932.   def initialize(*args, &block)
  933.     @maatsmo_lblse_char_count = 0
  934.     @scroll_review_max_oy = 0
  935.     @atsmo_all_windows = []
  936.     maatsmo_initz_2uq7(*args, &block) # Call Original Method
  937.     @atsmo_old_windowskin = self.windowskin
  938.   end
  939.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  940.   # * Create All Windows
  941.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  942.   alias maatsmo_creatalwins_2jf4 create_all_windows
  943.   def create_all_windows(*args, &block)
  944.     @atsmo_all_windows.clear
  945.     maatsmo_creatalwins_2jf4(*args, &block) # Call Original Method
  946.     @atsmo_name_window = Window_ATS_Name.new(self)
  947.     @atsmo_all_windows.push(@gold_window, @choice_window, @number_window,
  948.       @item_window, @atsmo_name_window)
  949.   end
  950.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  951.   # * Create Back Bitmap
  952.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  953.   alias maatsmo_cretebbmp_3gl5 create_back_bitmap
  954.   def create_back_bitmap(*args, &block)
  955.     @back_bitmap.dispose if @back_bitmap && !@back_bitmap.disposed?
  956.     if $game_message.message_dim_bg.empty?
  957.       maatsmo_cretebbmp_3gl5(*args, &block)
  958.     else
  959.       @back_bitmap = Bitmap.new(width, height)
  960.       bbmp = Cache.system($game_message.message_dim_bg)
  961.       @back_bitmap.stretch_blt(@back_bitmap.rect, bbmp, bbmp.rect)
  962.     end
  963.     @back_sprite.bitmap = @back_bitmap if @back_sprite
  964.     @current_bbmp = $game_message.message_dim_bg
  965.   end
  966.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  967.   # * Standard Padding
  968.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  969.   def standard_padding
  970.     $game_message.message_win_padding # Get padding
  971.   end
  972.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  973.   # * Update All Windows
  974.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  975.   alias maatsmo_updtallwin_8ih4 update_all_windows
  976.   def update_all_windows(*args, &block)
  977.     maatsmo_updtallwin_8ih4(*args, &block) # Call Original Method
  978.     @atsmo_name_window.update
  979.   end
  980.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  981.   # * Free All Windows
  982.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  983.   alias maatsmo_dispallwins_4bx9 dispose_all_windows
  984.   def dispose_all_windows(*args, &block)
  985.     maatsmo_dispallwins_4bx9(*args, &block) # Call Original Method
  986.     @atsmo_name_window.dispose
  987.   end
  988.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  989.   # * Update Windowskins
  990.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  991.   def atsmo_update_windowskin
  992.     new_wskin = Cache.system($game_message.message_windowskin)
  993.     # If windowskin is new and exists
  994.     if new_wskin != self.windowskin && new_wskin.width > 32
  995.       ([self] + @atsmo_all_windows).each { |win| win.windowskin = new_wskin }
  996.       @atsmo_name_window.set_text("") # Clear to redraw in right colour
  997.     end
  998.   end
  999.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1000.   # * Update Placement
  1001.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1002.   alias maatsmo_updplacem_3yg5 update_placement
  1003.   def update_placement(*args, &block)
  1004.     # Resize window
  1005.     resize(atsmo_update_placement_w, atsmo_update_placement_h)
  1006.     # Set X Position
  1007.     self.x = atsmo_update_placement_x
  1008.     # Set Y Position
  1009.     self.y = atsmo_update_placement_y(*args, &block) # Original Method, essentially
  1010.     update_padding
  1011.     @atsmo_name_window.update_placement
  1012.     create_back_bitmap if @current_bbmp != $game_message.message_dim_bg
  1013.   end
  1014.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1015.   # * Update X Position
  1016.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1017.   def atsmo_update_placement_x
  1018.     # Show on Character
  1019.     return show_on_character_x if $game_message.show_on_character_id >= 0
  1020.     # If not showing on character
  1021.     return $game_message.message_win_x == -1 ? # Centre or else direct set
  1022.       (Graphics.width - self.width) / 2 : $game_message.message_win_x
  1023.   end
  1024.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1025.   # * Update X in reference to character
  1026.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1027.   def show_on_character_x
  1028.     character = atsmo_get_character($game_message.show_on_character_id)
  1029.     x = case $game_message.show_on_character_pos
  1030.     when :t, :b then character.screen_x - (self.width / 2)
  1031.     when :l then character.screen_x - self.width - ($game_message.character_size_offset / 2)
  1032.     when :r then character.screen_x + ($game_message.character_size_offset / 2)
  1033.     else character.screen_x
  1034.     end
  1035.     [[x, Graphics.width - self.width].min, 0].max
  1036.   end
  1037.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1038.   # * Update Y Position
  1039.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1040.   def atsmo_update_placement_y(*args, &block)
  1041.     # Show on Character
  1042.     return show_on_character_y if $game_message.show_on_character_id >= 0
  1043.     # If not showing on a character
  1044.     if $game_message.message_win_y == -1
  1045.       do_not_obscure_characters unless $game_message.do_not_obscure.empty?
  1046.       maatsmo_updplacem_3yg5(*args, &block) # Call Original Method
  1047.       return self.y
  1048.     else
  1049.       @gold_window.y = $game_message.message_win_y > @gold_window.height ? 0 :
  1050.         Graphics.height - @gold_window.height
  1051.       return $game_message.message_win_y
  1052.     end
  1053.   end
  1054.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1055.   # * Update Y in reference to character
  1056.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1057.   def show_on_character_y
  1058.     character = atsmo_get_character($game_message.show_on_character_id)
  1059.     y = case $game_message.show_on_character_pos
  1060.     when :l, :r then character.screen_y - (($game_message.character_size_offset + self.height) / 2)
  1061.     when :t then character.screen_y - $game_message.character_size_offset - self.height
  1062.     when :b then character.screen_y
  1063.     end
  1064.     [[y, Graphics.height - self.height].min, 0].max
  1065.   end
  1066.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1067.   # * Update Message Window Width
  1068.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1069.   def atsmo_update_placement_w
  1070.     $game_message.message_win_width == -1 ? Graphics.width : $game_message.message_win_width
  1071.   end
  1072.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1073.   # * Update Message Window Height
  1074.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1075.   def atsmo_update_placement_h
  1076.     $game_message.message_win_height
  1077.   end
  1078.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1079.   # * Do Not Obstruct Characters
  1080.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1081.   def do_not_obscure_characters
  1082.     obscured = [0, 0, 0]
  1083.     positions = [2, 0, 1]
  1084.     positions.unshift(positions.delete($game_message.position))
  1085.     chosen_pos = positions[0]
  1086.     positions.each { |pos|
  1087.       y = ((Graphics.height - self.height) / 2)*pos
  1088.       range1 = y..(y + self.height)
  1089.       $game_message.do_not_obscure.each { |id|
  1090.         char = atsmo_get_character(id)
  1091.         next if char.nil?
  1092.         range2 = (char.screen_y - $game_message.character_size_offset)..char.screen_y
  1093.         obscured[pos] += 1 if range1 === range2.first || range2 === range1.first
  1094.       }
  1095.       chosen_pos = pos if obscured[pos] < obscured[chosen_pos]
  1096.     }
  1097.     $game_message.position = chosen_pos
  1098.   end
  1099.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1100.   # * Get Character
  1101.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1102.   def atsmo_get_character(id)
  1103.     id == 0 ? $game_player : $game_map.events[id]
  1104.   end
  1105.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1106.   # * Process All Text
  1107.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1108.   alias maatsmo_procsalltx_6fw2 process_all_text
  1109.   def process_all_text(*args, &block)
  1110.     # Play Start SE
  1111.     $game_message.start_se.play if $game_message.atsmo_play_sound?(:start)
  1112.     fit_window_to_message(convert_escape_characters($game_message.all_text.dup))
  1113.     atsmo_update_windowskin
  1114.     update_placement
  1115.     maatsmo_procsalltx_6fw2(*args, &block) # Call Original Method
  1116.     # Play Finish SE
  1117.     $game_message.finish_se.play if $game_message.atsmo_play_sound?(:finish)
  1118.   end
  1119.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1120.   # * Input Processing
  1121.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1122.   alias maatsmo_proceinpt_3rf6 process_input
  1123.   def process_input(*args, &block)
  1124.     # Don't play Pause Sound if Finish Sound played
  1125.     $game_message.pause_sound_on = false if $game_message.atsmo_play_sound?(:finish)
  1126.     maatsmo_proceinpt_3rf6(*args, &block)
  1127.   end
  1128.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1129.   # * Close Window and Wait for It to Fully Close
  1130.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1131.   alias maatsmo_closewat_4dr9 close_and_wait
  1132.   def close_and_wait(*args, &block)
  1133.     # Play Terminate SE
  1134.     $game_message.terminate_se.play if $game_message.atsmo_play_sound?(:terminate)
  1135.     $game_message.terminate_sound_on = $game_ats.terminate_sound_on
  1136.     maatsmo_closewat_4dr9(*args, &block) # Call Original Method
  1137.   end
  1138.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1139.   # * New Page
  1140.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1141.   alias maatsmo_newpge_3rj8 new_page
  1142.   def new_page(*args, &block)
  1143.     # Reset Contents size
  1144.     create_contents if contents.height > contents_height
  1145.     self.oy = 0
  1146.     maatsmo_newpge_3rj8(*args, &block) # Call Original Method
  1147.   end
  1148.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1149.   # * Convert Escape Characters
  1150.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1151.   if instance_methods(false).include?(:convert_escape_characters)
  1152.     # If convert_escape_characters already defined in Window_Message, just alias
  1153.     alias maatsmo_cnvrscchrc_7yc3 convert_escape_characters
  1154.     def convert_escape_characters(*args, &block)
  1155.       maatsmo_convert_escape_characters(maatsmo_cnvrscchrc_7yc3(*args, &block))
  1156.     end
  1157.   else
  1158.     # If convert_escape_characters undefined in Window_Message, call super method
  1159.     def convert_escape_characters(*args, &block)
  1160.       maatsmo_convert_escape_characters(super(*args, &block))
  1161.     end
  1162.   end
  1163.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1164.   # * ATS MO Convert Escape Characters
  1165.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1166.   def maatsmo_convert_escape_characters(text)
  1167.     # Sound Effects
  1168.     text.gsub!(/\eP_?([MS]E)\[\s*\"?([^\",\]]+)\"?(.*?)\]/i) { "\ePLAYSOUND\[#{$1.upcase},\"#{$2}\"#{$3.gsub(/ /, "")}\]" }
  1169.     text.gsub!(/\eP_?(ANIM|BLN)\[\s*(\d+)[\s,:;]*(\d+)\s*\]/i) { "\eANIMATION\[#{$1.upcase == "ANIM" ? 0 : 1},#{$2},#{$3}\]" }
  1170.     letter_ary = ["L", "P", "F", "T"]
  1171.     # Turn Sound Effects on or off
  1172.     text.gsub!(/([\e\/])([LPFT])SE/i) {
  1173.       num = ($1 == "\e" ? 0 : 1) + (2*letter_ary.index($2.upcase))
  1174.       "\eATSMOSE\[#{num}\]" }
  1175.     return text
  1176.   end
  1177.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1178.   # * Process Escape Character
  1179.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1180.   alias maatasmo_procescchar_2ia4 process_escape_character
  1181.   def process_escape_character(code, text, *args, &block) # (code, text, pos)
  1182.     case code.upcase
  1183.     when 'ATSMOSE'
  1184.       param = obtain_escape_param(text)
  1185.       return if @atsf_testing
  1186.       case param / 2
  1187.       when 0 then $game_message.letter_sound_on = (param == 0)    # Letter Sound
  1188.       when 1 then $game_message.pause_sound_on = (param == 2)     # Pause Sound
  1189.       when 2 then $game_message.finish_sound_on = (param == 4)    # Finish Sound
  1190.       when 3 then $game_message.terminate_sound_on = (param == 6) # Terminate Sound
  1191.       end
  1192.     when 'PLAYSOUND'
  1193.       return unless text.slice!(/^\[([MS]E),\"(.+?)\",?(\d*),?(\d*)\]/i)
  1194.      return if @atsf_testing
  1195.      RPG.const_get($1.to_sym).new($2, $3.empty? ? 80 : $3.to_i, $4.empty? ? 100 : $4.to_i).play
  1196.    when 'ANIMATION'
  1197.      return unless text.slice!(/^\[(\d+),(\d+),(\d+)\]/)
  1198.      return if @atsf_testing
  1199.      character = atsmo_get_character($2.to_i)
  1200.      if character
  1201.        case $1.to_i
  1202.        when 0 then character.animation_id = $3.to_i
  1203.        when 1 then character.balloon_id = $3.to_i
  1204.        end
  1205.      end
  1206.    else
  1207.      maatasmo_procescchar_2ia4(code, text, *args, &block) # Run Original Method
  1208.    end
  1209.  end
  1210.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1211.  # * Process Normal Character
  1212.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1213.  alias maatsmo_prcssnrmlch_3kz8 process_normal_character
  1214.  def process_normal_character(c, pos, *args, &block)
  1215.    maatsmo_prcssnrmlch_3kz8(c, pos, *args, &block) # Call Original Method
  1216.    # Play SE if not showing fast and the letter sound is on
  1217.    maatsmo_play_letter_by_letter_se if $game_message.atsmo_play_sound?(:letter) &&
  1218.      !@show_fast && !@line_show_fast
  1219.  end
  1220.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1221.  # * New Line Character Processing
  1222.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1223.  alias maatsmo_procnewlin_3jd8 process_new_line
  1224.  def process_new_line(text, pos, *args)
  1225.    if $game_message.scrolling_on # If using scrolling
  1226.      @line_show_fast = false
  1227.      super
  1228.      if $imported[:ATS_Formatting] && IS_ATSF_ABOVE
  1229.        maatsf_paragraph_new_line(method(:maatsmo_process_new_line_scroll), text, pos)
  1230.      else
  1231.        maatsmo_process_new_line_scroll(text, pos)
  1232.      end
  1233.    else # Not using scrolling, so no need to interfere with this method
  1234.      maatsmo_procnewlin_3jd8(text, pos, *args) # Call Original Method
  1235.    end
  1236.  end
  1237.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1238.  # * New Line Character Processing when scrolling
  1239.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1240.  def maatsmo_process_new_line_scroll(text, pos)
  1241.    if need_new_page?(text, pos)
  1242.      # Only pause if demanded
  1243.      input_pause if $game_message.pause_before_scroll && !@pause_skip
  1244.      scroll_h = !$game_message.scroll_by_page ? pos[:y] + pos[:height] : # Line
  1245.        contents.height + (pos[:y] - self.oy) # Page
  1246.      atsmo_scroll_page(text, pos, scroll_h)
  1247.      @show_fast = false # Don't speed through entire message
  1248.    end
  1249.  end
  1250.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1251.  # * Wait / Wait for One Character / Process Input
  1252.  #``````````````````````````````````````````````````````````````````````````
  1253.  # Do not permit these to run when testing
  1254.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1255.  [:wait, :wait_for_one_character].each { |meth|
  1256.    alias_method(:"maatsmo_#{meth}_6hb1", meth)
  1257.     define_method(meth) do |*args|
  1258.       send(:"maatsmo_#{meth}_6hb1", *args) unless @atsf_testing
  1259.     end
  1260.   }
  1261.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1262.   # * Input Pause
  1263.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1264.   alias maatsmo_inppuse_3kx5 input_pause
  1265.   def input_pause(*args, &block)
  1266.     return if @atsf_testing
  1267.     # Play Pause SE
  1268.     $game_message.pause_se.play if $game_message.atsmo_play_sound?(:pause) # Play
  1269.     if $game_message.scroll_review && self.oy > 0
  1270.       # If scroll review, need to overwrite this method
  1271.       self.pause = true
  1272.       wait(10)
  1273.       @scroll_review_max_oy = contents.height - contents_height
  1274.       until Input.trigger?(:B) || Input.trigger?(:C)
  1275.         update_scroll_review
  1276.         Fiber.yield
  1277.       end
  1278.       self.oy = @scroll_review_max_oy
  1279.       Input.update
  1280.       self.pause = false
  1281.     else
  1282.       maatsmo_inppuse_3kx5(*args, &block) # Call Original Method
  1283.     end
  1284.   end
  1285.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1286.   # * Play Letter By Letter SE
  1287.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1288.   def maatsmo_play_letter_by_letter_se
  1289.     # If drawn enough letters to play the SE
  1290.     if @maatsmo_lblse_char_count >= $game_message.letters_per_se
  1291.       @maatsmo_lblse_char_count = 0
  1292.       $game_message.letter_se.pitch = $game_message.random_pitch.first
  1293.       unless $game_message.random_pitch.first >= $game_message.random_pitch.last
  1294.         # Randomize pitch
  1295.         $game_message.letter_se.pitch += rand($game_message.random_pitch.last - $game_message.random_pitch.first)
  1296.       end
  1297.       $game_message.letter_se.play # Play Letter by Letter SE
  1298.     else
  1299.       @maatsmo_lblse_char_count += 1 # Advance character count
  1300.     end
  1301.   end
  1302.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1303.   # * Resize Contents
  1304.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1305.   def resize_contents(w, h)
  1306.     bmp = contents # Save old contents
  1307.     self.contents = Bitmap.new(w, h)
  1308.     self.contents.font = bmp.font.dup
  1309.     self.contents.blt(0, 0, bmp, bmp.rect) # Draw old contents onto new
  1310.     bmp.dispose
  1311.   end
  1312.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1313.   # * Fit Window to Message
  1314.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1315.   def fit_window_to_message(text)
  1316.     # Fit window to message if longes
  1317.     if !($imported[:ATS_Formatting] && $game_message.paragraph_format) &&
  1318.       $game_message.fit_window_to_message
  1319.       w, h = 0, 0
  1320.       for line in text.split(/[\n\r]+/)
  1321.         lw = mapf_calc_line_width(line) + new_line_x
  1322.         w = lw if lw > w
  1323.         h += calc_line_height(line)
  1324.       end
  1325.       $game_message.message_win_width = [$game_message.fit_window_width_range.last,
  1326.         [w + (standard_padding*2), $game_message.fit_window_width_range.first].max].min
  1327.       $game_message.message_win_height = [$game_message.fit_window_height_range.last,
  1328.         [h + (standard_padding*2), $game_message.fit_window_height_range.first].max].min
  1329.     end
  1330.   end
  1331.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1332.   # * Scroll to Next Line
  1333.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1334.   def atsmo_scroll_page(text, pos, height)
  1335.     resize_contents(contents.width, height)
  1336.     goal_oy = contents.height - contents_height
  1337.     if $game_message.scroll_speed <= 0
  1338.       self.oy = goal_oy # Instant scroll
  1339.     else
  1340.       until self.oy == goal_oy # Scroll until goal reached
  1341.         self.oy += [$game_message.scroll_speed, goal_oy - self.oy].min
  1342.         Fiber.yield
  1343.       end
  1344.     end
  1345.   end
  1346.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1347.   # * Update Scroll Review
  1348.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1349.   def update_scroll_review
  1350.     if Input.press?(:UP)
  1351.       self.oy -= [4, self.oy].min
  1352.     elsif Input.press?(:DOWN) # self.oy = contents.height - contents_height
  1353.       self.oy += [4, @scroll_review_max_oy - self.oy].min
  1354.     end
  1355.   end
  1356. end
  1357.  
  1358. #==============================================================================
  1359. # ** Window_ChoiceList
  1360. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1361. #  Summary of Changes:
  1362. #    aliased method - update_placement
  1363. #==============================================================================
  1364.  
  1365. class Window_ChoiceList
  1366.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1367.   # * Update Window Position
  1368.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1369.   alias maatsmo_updplace_3ib6 update_placement
  1370.   def update_placement(*args, &block)
  1371.     maatsmo_updplace_3ib6(*args, &block) # Call original method
  1372.     if !$imported[:ATS_AdvancedChoices]
  1373.       self.x = @message_window.x
  1374.       self.x += @message_window.width - self.width unless $game_message.name_win_x == :r
  1375.     end
  1376.   end
  1377. end
RAW Paste Data