CyberForte

DoW Advanced Text

Oct 10th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 173.70 KB | None | 0 0
  1. #==============================================================================
  2. #    Advanced Text System
  3. #    Version: 3.0c
  4. #    Author: modern algebra (rmrk.net)
  5. #    Date: September 7, 2010
  6. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. #  Thanks:
  8. #    *Zeriab* for his tutorial on RegExp, but most of all for being my mentor
  9. #      and friend. Without him, this script, and all my other scripts, will
  10. #      never have been made.
  11. #  For ideas on improving this script through bug reports or suggestions:
  12. #    Arrow-1, Irock, Stonewall, PhantomH, Seasons in the Abyss, Aindra, Arion,
  13. #    Okogawa, Megatronx, Charbel, Adrien., dricc, Raukue, EricDahRed, redyugi,
  14. #    HeartofShadow, Woratana, tsy0302, Kayo, deadnub.
  15. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  16. #  Description:
  17. #
  18. #    This scripts adds a whole bunch of features to message boxes, making them
  19. #   much prettier and with a lot more functionality than the default. What and
  20. #   how to use each feature will be exhaustively detailed in the instructions,
  21. #   but for now I will just give a list of a few of the staple features:
  22. #
  23. #      ~Appended Text~
  24. #    A staple feature of ATS, this will combine the messages of subsequent text
  25. #   events (that share properties). It is useful particularly when combined
  26. #   with text scrolling.
  27. #
  28. #      ~Text Scrolling~
  29. #    This feature allows longer text messages to scroll upwards, so that for
  30. #   longer messages, the contents of the window will scroll upwards when it
  31. #   reaches the bottom, allowing the player to read what has come before and
  32. #   ignore the annoying new page requirements. This feature has been beefed up
  33. #   in ATS 3.0, with the scroll now being much smoother and the speed user-
  34. #   definable, in addition to the new feature of Scroll Review, which, once the
  35. #   message is finished, allows the player to scroll upwards to see any text he
  36. #   or she might have missed. Moreover, you can also scroll by page instead.
  37. #
  38. #      ~Paragraph Format~
  39. #    Always a staple feature in the ATS, turning this feature on allows you to
  40. #   avoid the hassle that comes with making the text fit within the window by
  41. #   analyzing the exact length with reference to the grey arrows. Now you can
  42. #   type freely and know that nothing will get cut off. This feature takes on
  43. #   additional importance in ATS 3.0 with the addition of a special message
  44. #   codes like \S[] and \S![], more on which will be discussed later. As
  45. #   always, you can still manually define line breaks with the \LB code. As in
  46. #   previous versions, you can also justify text, meaning that the letters will
  47. #   be spaced out so as to exactly cover the width of the message box. Unlike
  48. #   previous versions, this paragraph formatter is integrated with the ATS in
  49. #   order to better accomodate text features and therefore does not require a
  50. #   separate Paragraph Formatter script to work.
  51. #
  52. #      ~Advanced Choices~
  53. #    Another staple feature of the ATS, you have been able to append choices
  54. #   from subsequent choice branches and show them all in a separate window.
  55. #   This feature has been vastly expanded on in ATS 3.0. In earlier versions,
  56. #   many of the features respecting advanced choices, such as appending them
  57. #   and tying choices to switches, were available only if using the choice
  58. #   window. In ATS 3.0, these features have been included in the traditional
  59. #   in-message window. Don't want to use the choice window but do want to
  60. #   exclude some choices unless a particular switch is ON? You can do that now.
  61. #   In addition to all of the old features, there are quite a few new ones that
  62. #   will make your choices more dynamic. One is the ability to make an the
  63. #   cursor pass over an option. This means it is a perfect way to include  
  64. #   headings or blank spaces in your choice box. Another new feature are the
  65. #   disable codes which allow you to make a choice unselectable, so when the
  66. #   player tries to select it the buzzer sound is played and nothing happens.
  67. #   Further, there is an external message property that can be set which you
  68. #   can use to automatically add certain properties to modify the choice text
  69. #   if it is disabled, such as a command to reduce the opacity of it. In
  70. #   addition, you can automatically modify all choice texts at once - want to
  71. #   add a larger indent or make all choices blue - you can do that. Finally,
  72. #   another unique feature of ATS choices is the \+{} code. Placed in a comment
  73. #   directly below a when branch of a choice branch, this allows you to add
  74. #   whatever text you want to that choice, effectively ignoring the limitations
  75. #   on choice message size. This means you can make your choices sentences
  76. #   instead of simple yes or nos. In addition to this, another new feature of
  77. #   ATS 3.0 choices is that choice messages can be longer than one line and
  78. #   that is recognized both in the choicebox and the new and improved default
  79. #   choice scheme. The last new feature added to choices in ATS 3.0 is the
  80. #   ability to set a help window for it. This means it will set a window whose
  81. #   contents will change depending on which choice the player is hovering over.
  82. #
  83. #      ~Advanced Faces~
  84. #    From the very start, animated faces have been a part of the ATS. This
  85. #   feature allows you to have the faces animate for every few letters drawn -
  86. #   perfect to make it look like the face is talking. However, this is not all
  87. #   the special features you gain with faces. As always, you can also use much
  88. #   larger or smaller faces, mirror them, set them to the right side of the
  89. #   text box, or move them anywhere you like, change the opacity, or surround
  90. #   it with a window. New in ATS 3.0, you can now define the exact size of the
  91. #   border of the window if using it, or you can use another sprite for it
  92. #   (just like the dim background of the Message Window). Also new in ATS 3.0,
  93. #   you can scroll the face in when it first appears either horizontally or
  94. #   vertically, or fade it in. You can also choose to make the face appear over
  95. #   or under the message window, and change the blend type.
  96. #
  97. #      ~Letter Control~
  98. #    This has always been a feature of the ATS and it allows you to control the
  99. #   speed that text is drawn, as well as putting in pauses at will. It also
  100. #   allows you to specify a sound, and you can even have it vary the pitch with
  101. #   every letter so that it mimics the sound of a voice. New in ATS 3.0, you
  102. #   can control the speed text is drawn not only through the \> and \< codes,
  103. #   but more directly via the \S[] command, where you can either set it to add
  104. #   or subtract a number from the current speed, or you can set it directly.
  105. #   See the section on this code in Special Message Codes for details.
  106. #
  107. #      ~Advanced Message Window~
  108. #    There are also a number of special features related to the appearance and
  109. #   position of the message window. Most of these should be familiar to users
  110. #   of ATS 2.0. You can manually control the size and exact position of the
  111. #   text box, or you can set it to automatic. Further, you can use the
  112. #   :fit_window_to_text property to set the width of the window to be only as
  113. #   long as it needs to be to accomodate the longest line. As always, you can
  114. #   set what windowskin to use, the font, how much space for each line, and the
  115. #   dim background. New features include the :do_not_obscure property, which,
  116. #   when using default positioning, will ensure that the characters specified
  117. #   in the :obscure_characters array. This feature will be ignored if manually
  118. #   setting position however. The only thing it does is, if you have the
  119. #   position set to bottom, but that would cover the player and you include the
  120. #   player in your obscure_characters array, then it would move the message box
  121. #   to the top instead. As always, you can use \OC[], \UC[], \LC[], and \RC[]
  122. #   to position the window in reference to a character. Something new is the
  123. #   \E[] command, which will set it above the character, unless there is not
  124. #   enough room, in which case it sets it below the character. Another new
  125. #   feature is speech tags, which, when using \OC[], \UC[], or \E[] codes will
  126. #   place a tag from the character speaking to the message window if this
  127. #   feature is enabled.
  128. #
  129. #      ~Word Boxes~
  130. #    New to ATS 3.0, this is a very simple feature that works akin to the Gold
  131. #   or Name window. Basically, it allows you to set a one line message to
  132. #   appear instantly. It can be used, for instance, if you want to show the
  133. #   value of a variable in the corner while showing this message or choice.
  134. #   Naturally, name boxes have also been retained from ATS 2.0
  135. #
  136. #      ~Graphic Novel Support~
  137. #    New to ATS 3.0, this feature, when activated, allows the player to
  138. #   completely hide and prevent from updating every message related window for
  139. #   as long as the player holds a button you choose or, if you wish, it can be
  140. #   a toggle rather than a press. It is useful if you have a game that relies
  141. #   heavily on graphics and you want to give the player the opportunity to just
  142. #   look at the background, like in many graphic novel games.
  143. #
  144. #      ~Move While Showing~
  145. #    Also new to ATS 3.0, this is a feature that, when activated, allows the
  146. #   player to move around while a message is showing. However, when a choice
  147. #   selection is active, this feature will be disabled.
  148. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  149. #  Instructions:
  150. #
  151. #    Place this script in its own slot in the Script Editor (F11) above Main
  152. #   and below Materials. This script is not compatible with most other message
  153. #   systems, so you may need to remove any other message systems. If you are
  154. #   upgrading to this from ATS 2.0, you will need to also install the
  155. #   conversion patch, located in this script's thread at RMRK.
  156. #
  157. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  158. #      ~Special Message Codes~
  159. #         These codes work in all ATS windows.
  160. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  161. #     You will recognize many of these from previous versions of the ATS. A lot
  162. #    are new though.
  163. # \lb    - Line break. Go to next line.
  164. # \v[x]  - Draw the value of the variable with ID x.
  165. # \n[x]  - Draw the name of the actor with ID x.
  166. # \c[x]  - Set the colour of the text being drawn to the xth colour of the
  167. #         Windowskin palette. 0 is the normal color and 16 is the system color.
  168. # \c[#RRGGBB] - Set the colour of the text being drawn to any colour, using
  169. #         hexadecimal. You can set each colour (red, green, blue) to anything
  170. #         from 0-255 (00-FF). You must use hexadecimal values.
  171. # \p[x] OR \pid[x] - Draw the ID of the actor in the xth position in the party.
  172. # \ni[x] - Draw the name of the item with ID x.
  173. # \nw[x] - Draw the name of the weapon with ID x.
  174. # \na[x] - Draw the name of the armor with ID x.
  175. # \ns[x] - Draw the name of the skill with ID x.
  176. # \nt[x] - Draw the name of the state with ID x.
  177. # \nc[x] - Draw the name of the class with ID x.
  178. # \ne[x] - Draw the name of the event with ID x on the current map.
  179. # \nm[x] - Draw the name of the enemy with ID x.
  180. # \nl[x] - Draw the name of the element with ID x.
  181. # \nv[x] - Draw the name of the variable with ID x.
  182. # \nsw[x] - Draw the name of the switch with ID x.
  183. # \np[x] - Draw the name of the actor in the nth position in the party.
  184. # \map   - Draw the name of the map the player is currently on.
  185. # \map[x] - Draw the name of the map with ID x.
  186. # \di[x] - Draw the description of the item with ID x.
  187. # \dw[x] - Draw the description of the weapon with ID x.
  188. # \da[x] - Draw the description of the armor with ID x.
  189. # \ds[x] - Draw the description of the skill with ID x.
  190. # \pi[x] - Draw the price of the item with ID x.
  191. # \pw[x] - Draw the price of the weapon with ID x.
  192. # \pa[x] - Draw the price of the armor with ID x.
  193. # \i#[x] - Draw the number of the item with ID x that the party posesses.
  194. # \w#[x] - Draw the number of the weapon with ID x that the party posesses.
  195. # \a#[x] - Draw the number of the armor with ID x that the party posesses.
  196. # \ac[x] - Draw the class of the actor with ID x.
  197. # \i[x]  - Draw the icon with index x.
  198. # \ii[x] - Draw the icon of the item with ID x.
  199. # \wi[x] - Draw the icon of the weapon with ID x.
  200. # \ai[x] - Draw the icon of the armor with ID x.
  201. # \si[x] - Draw the icon of the skill with ID x.
  202. # \ti[x] - Draw the icon of the state with ID x.
  203. # \fn[fontname] - Change the font to fontname
  204. # \fs[x] - Change the fontsize to x.
  205. # \fa[x] - Change the alpha value (opacity) of the font to x.
  206. # \b     - Turn bold on. Text drawn after this code will be bolded.
  207. # /b     - Turn bold off.
  208. # \i     - Turn italic on. Text drawn after this code will be italicized.
  209. # /i     - Turn italic off.
  210. # \s     - Turn shadow on. Text drawn after this code will have a shadow.
  211. # /s     - Turn shadow off.
  212. # \u     - Turn underline on. Text drawn after this code will be underlined.
  213. # /u     - Turn underline off.
  214. # \hl[x] - Turn highlight on. Text drawn after this code will be highlighted
  215. #         with colour x from the windowskin palette
  216. # /hl OR \hl[-1] - Turn highlight off.
  217. # \l     - align the text to the left
  218. # \r     - align the text to the right
  219. # \c     - align the text to the centre.
  220. # \t     - Tab. Draws the next character at the nearest pixel that is a
  221. #         multiple of 32. Doesn't work well with the :justified_text property.
  222. # \x[n]  - Sets the x position for drawing directly to n.
  223. # \f[key] - Draw the value corresponding to that key in the FILTERS array. If
  224. #          the key has quotation marks around it, you need to put "key"
  225. # \s[x,text] - Will only draw text if the switch with ID x is ON.
  226. # \s![x,text] - Will only draw text if the switch with ID x is OFF.
  227. # \vocab[method] - Will draw whatever Vocab.method returns, if it is a valid
  228. #          method call. Suitable values for method are: level, level_a, hp,
  229. #          hp_a, mp, mp_a, atk, def, spi, agi, weapon, armor1, armor2, armor3,
  230. #          armor4, weapon1, weapon2, attack, skill, guard, item, equip, status,
  231. #          save, game_end, fight, escape, new_game, shutdown, to_title, gold,
  232. #          continue, cancel
  233. # \actor_method[x] - This will draw whatever actor.method returns for whoever
  234. #          actor x. Some suitable values for method are: atk, def, spi, agi,
  235. #          level, exp, name, hp, maxhp, mp, maxmp, & any other methods that
  236. #          return values from Game_Actor.
  237. # \i_method[x] - This will draw whatever item.method returns for the item with
  238. #          ID x. Some suitable values for method are: name, description,
  239. #          base_damage, variance, atk_f, spi_f, price, hp_recovery_rate,
  240. #          hp_recovery, mp_recovery_rate, mp_recovery, parameter_points, note,
  241. #          n, & any other methods that return values from RPG::Item. Also, note
  242. #          will return all of the contents of the note field, whereas n will
  243. #          only return notefield text located between a \msg[text]msg/ code.
  244. # \w_method[x] - This will draw whatever weapon.method returns for the weapon
  245. #          with ID x. Some suitable values for method are: name, description,
  246. #          price, hit, atk, def, spi, agi, note, n, & any other methods that
  247. #          return values from RPG::Weapon. Also, note will return all
  248. #          of the contents of the note field, whereas n will only return  
  249. #          notefield text located between a \msg[text]msg/ code.
  250. # \a_method[x] - This will draw whatever armor.method returns for the armor
  251. #          with ID x. Some suitable values for method are: name, description,
  252. #          price, eva, atk, def, spi, agi, note, n, & any other methods that
  253. #          return values from RPG::Armor. Also, note will return all
  254. #          of the contents of the note field, whereas n will only return  
  255. #          notefield text located between a \msg[text]msg/ code.
  256. # \s_method[x] - This will draw whatever skill.method returns for the skill
  257. #          with ID x. Some suitable values for method are: name, description,
  258. #          base_damage, variance, atk_f, spi_f, hit, mp_cost, note, n, & any
  259. #          other methods that return values from RPG::Weapon. Also, note will
  260. #          return all of the contents of the note field, whereas n will only
  261. #          return notefield text located between a \msg[text]msg/ code.
  262. # \t_method[x] - This will draw whatever state.method returns for the state
  263. #          with ID x. Some suitable values for method are: name, atk_rate,
  264. #          def_rate, spi_rate, agi_rate, message1, message2, message3,
  265. #          message4, note, n, & any other methods that return values from
  266. #          RPG::State. Also, note will return all of the contents of the note
  267. #          field, whereas n will only return notefield text located between a
  268. #          \msg[text]msg/ code.
  269. # \enemy_method[x] - This will draw whatever enemy.method returns for whoever
  270. #          the enemy with ID x is. Some suitable values for method are: name,
  271. #          atk, def, spi, agi, hit, eva, exp, gold, note, n, & any other
  272. #          methods that return values from RPG::Enemy. Also, note will return
  273. #          all of the contents of the note field, whereas n will only return
  274. #          text located between a \msg[text]msg/ code.
  275. # \#{code}# - This will evaluate code. So, if you know scipting, you can place
  276. #          any code there and it will draw whatever is returned by it. For
  277. #          instance: \#{$game_system.save_count}# would draw the number of
  278. #          times the player has saved the current game.
  279. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  280. #       ~Message Box specific codes~
  281. #          These codes will only work in the Message Window.
  282. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  283. # \g     - Shows a window with the party's gold. Closes if already open
  284. # \nb[name] - Shows a name box with name displayed in the box
  285. # /nb    - Closes the namebox
  286. # \wb[word] - shows the word in its own window, similar to the gold window.
  287. # /wb    - Closes a wordbox
  288. # \.     - Wait 15 frames (1/4 second) before drawing the next letter.
  289. # \|     - Wait 60 frames (1 second) before drawing the next letter.
  290. # \w[x]  - Wait x frames before drawing the next letter.
  291. # \!     - Pause. Make the message wait for player input before continuing.
  292. # \^     - Skip the next pause without waiting for player input.
  293. # \>     - Speed up the text drawing by reducing wait time between letters by
  294. #         one frame.
  295. # \<     - Slow down the text drawing by increasing wait time between letters by
  296. #         one frame.
  297. # \S[x]  - Change the speed the text draws by adding x to the current time
  298. #         between drawing letters. Thus, \s[2] is the equivalent of \<\< and
  299. #         \s[-3] is the equivalent of \>\>\>. You can also directly set the
  300. #         speed by putting an equal sign, so \s[=0] would set the time to one
  301. #         frame between drawing letters, and \s[=-1] would set it to instant.
  302. # \@     - Turn on Show line fast - the line up to /@ will be shown instantly
  303. # /@     - Turn off Show line fast.
  304. # \@@    - Turn on Show message fast. This will show the entire message
  305. #         instantly, at least until the next scroll or it hits a /@@
  306. # /@@    - Turn off Show message fast.
  307. # \%     - Disable Text Skip through user input
  308. # \se[sound effect name] - Plays a sound effect
  309. # \me[music effect name] - Plays a musical effect
  310. # \ani[target_id,animation_id] - Shows animation_id on target_id. 0 => player,
  311. #         other numbers indicate the ID of the event
  312. # \bln[target_id,balloon_id] - Same as ani, but shows a balloon
  313. # \af[x] - Show the face of the actor with ID x.
  314. # \pb    - Page Break. Clear the contents and start drawing from the first line
  315. # \oc[x] - positions the message box over a character. 0 => player; when >1, it
  316. #         will show over the event with that ID on the map.
  317. # \uc[x] - same as \oc, but places box under character
  318. # \lc[x] - same as \oc, but places box to left of character
  319. # \rc[x] - same as \oc, but places box to right of character
  320. # \e[x]  - same as \oc, but if the box is too tall to comfortably fit, is moved
  321. #         below the character instead.
  322. # \mxy[x, y] - Set the position of the message window to x, y.
  323. # \fxy[x, y] - Set the position of the face window to x, y.
  324. # \nxy[x, y] - Set the position of the name window to x, y.
  325. # \#!{code}# - This will evaluate code at the time the window reaches this code
  326. #         when drawing. It does not put the result of the code into the message
  327. #         but is instead intended to be evaluated. For instance: \#!{new_page}#
  328. #         would perform the same function as \pb. You need to know syntax!
  329. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  330. #      ~Choice Branch Specific Codes~
  331. #         These codes only work in choice branches.
  332. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  333. # \skip  - Placing this in a choice text means that the player will not be able
  334. #         to hover over or select this option, but will skip to the next one.
  335. #         Perfect for making subheadings for your choices, or blank spaces.
  336. # \soff[x] - A choice with this in it will only appear in the branch if the
  337. #         switch with ID x is OFF.
  338. # \son[x] - Same as soff[x], but it will only appear if switch x is ON.
  339. # \d[x]  - A choice with this in it will be disabled (unselectable) if the
  340. #         switch with ID x is OFF. It will still show up, and the player can
  341. #         hover over it, but he or she will be prevented from selecting it.
  342. # \d![x] - Same as \d[x], except it will be disabled if switch x is ON.
  343. # \wb[text] - This code will create a help window. When the player hovers over
  344. #         that choice, it will show text in the help window. This allows you to
  345. #         explain the choice or make any content in the help window dependent
  346. #         on which choice the player is on.
  347. # \+{text} - This is actually a code you can put in a comment that is directly
  348. #         below the when branch of a choice, and it will add text to the
  349. #         choice. This effectively ignores the normal limitations on the size
  350. #         of a message in a choice, allowing you to make longer texts for
  351. #         choices.
  352. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  353. #      ~Message Properties~
  354. #    The following are properties of the message window that are set prior to
  355. #   calling the message and govern many properties. You set the default values
  356. #   to the constants of the same name in Game_ATS, starting at line 766. Those
  357. #   will be the values that each game starts out with. You can then change them
  358. #   on a message to message basis through either of the codes:
  359. #      ats_next (:property, new_value)
  360. #   or:
  361. #      $game_message.property = new_value
  362. #   However, it will reset to the default after the next message is processed.
  363. #   If you want to change it on a permanent basis, you have to use either:
  364. #      ats_all (:property, new_value)
  365. #   or:
  366. #      $game_ats.property = new_value
  367. #      $game_message.property = new_value
  368. #
  369. #    All of the properties and what types of values are expected for each are
  370. #   listed below. Note that if you use the ats_next or ats_all commands, you
  371. #   have to retain the : in front of the name. If you use the $game_ats or
  372. #   $game_message route then you don't use the :
  373. #
  374. #    You can reset $game_ats to the constants with: $game_ats.reset
  375. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  376. # :max_lines - This is the maximum number of lines to show at a time before
  377. #       either going to a new page or scrolling. Default: 4
  378. # :message_speed - This is the number of frames to wait in between drawing
  379. #       letters. -1 is instant. 0 is 1 frame. Default: 0
  380. # :skip_disabled - Whether the player can speed text up by pressing ENTER.
  381. # :append_text - Whether to include all text from subsequent text commands in
  382. #       the next message. true => append; false => do not append. Default: true
  383. # :append_choice - Whether to include all choices from subsequent choice
  384. #       choice branches in the next choice selection. The cancel branch is
  385. #       inherited from the last branch to not have cancel disabled.
  386. #       true => append; false => do not append. Default: true
  387. # :scrolling - Whether to scroll once :max_lines is exceeded or to pause and
  388. #       start a new page. true => scroll; false => new page. Default: true
  389. # :scroll_speed - If :scrolling is true, this is how many pixels it moves per
  390. #       frame when scrolling text. Default: 2
  391. # :scroll_show_arrows - If :scrolling is true, this determines whether or not
  392. #       to show the arrows when the contents grow. true => show; false => do
  393. #       not show. Default: true
  394. # :scroll_autopause - If :scrolling is true, this determines whether or not to
  395. #       insert a pause before it scrolls to the next line. Default: false
  396. # :scroll_review - If :scrolling is true, this option is whether or not the
  397. #       player has the option to review the message that has just finished by
  398. #       pressing up and down. true => yes; false => no. Default: true
  399. # :scroll_by_page - Whether to scroll by whole page or by line. Default: false
  400. # :paragraph_format - When this is true, the manual line breaks are ignored and
  401. #       it will draw as many characters as will fit on each line. You can still
  402. #       force a line break with the \lb code though. Default: false
  403. # :justified_text - If :paragraph_format is true, then this option will make
  404. #       the spacing of a line exactly such that it takes up the entire width of
  405. #       the message window. Default: false
  406. # :letter_sound - When this is true, a sound will be played upon drawing
  407. #       letters. Default: false
  408. # :letter_se - If :letter_sound is true, this is the SE that is played. It is
  409. #       set in the format ["filename", volume, pitch]. Default: ["Open1", 40]
  410. # :letters_per_se - If :letter_sound is true, this is the frequency that the
  411. #       SE is played. The SE will play every time this number of letters is
  412. #       drawn. Default: 3
  413. # :random_pitch - If :letter_sound is true, this is the range the pitch of the
  414. #       SE will vary within. It can be used to mimic the pitch variations of
  415. #       a human voice. It is a range in the format x..y. If x is equal to y,
  416. #       then the pitch won't vary. If set to an integer, it will take that as
  417. #       the variance from the regular pitch of the SE. Default: 100..100
  418. # :speech_tag_index - This refers to which speech tag to use when showing a
  419. #       message window above or below an event or player. -1 => no tag, while
  420. #       anything greater refers to the graphic of the corresponding index in
  421. #       :speech_tag_graphics. Default: -1
  422. # :speech_tag_graphics - This is an array containing the names of all speech
  423. #       tag graphics in the System folder of Graphics. Which one is used when
  424. #       showing a message depends on the value of :speech_tag_index.
  425. #       Default: ["Speech Tag 1", "Speech Tag 2", "Thought Tag 1"]
  426. # :start_sound - If true, a sound will be played when a message starts.
  427. #       Default: false
  428. # :start_se - If :start_sound is true, this is the SE that is played. It is
  429. #       set in the format ["filename", volume, pitch]. Default: ["Chime2"]
  430. # :finish_sound - If true, a sound will be played when a message finishes.
  431. #       Default: false
  432. # :finish_se - If :finish_sound is true, this is the SE that is played. It is
  433. #       set in the format ["filename", volume, pitch]. Default: ["Chime1"]
  434. # :pause_sound - If true, a sound will be played when a message pauses.
  435. #       Default: false
  436. # :pause_se - If :pause_sound is true, this is the SE that is played. It is
  437. #       set in the format ["filename", volume, pitch]. Default: ["Decision2"]
  438. # :terminate_sound - If true, a sound will be played when a message closes.
  439. #       Default: false
  440. # :terminate_se - If :terminate_sound is true, this is the SE that is played. It is
  441. #       set in the format ["filename", volume, pitch]. Default: ["Cancel"]
  442. # :move_when_visible - When this is true, the player will still be able to move
  443. #       when the message window is displaying text. It is recommended that you
  444. #       turn scroll review off when using this feature though, as it looks
  445. #       dumb. Also, whenever a choice starts, it takes precedence and the
  446. #       player will not be able to move even if this is true. Default: false
  447. # :graphic_novel - When this is true, it means the player can press the
  448. #       :hide_button and everything relating to the message window becomes
  449. #       invisible and stops updating until the player releases the button. It
  450. #       is intended for use where a player might want to see the whole screen
  451. #       and not have things hidden by the ATS windows. Default: false
  452. # :hide_button - If :graphic_novel is true, this is the button that hides the
  453. #       ATS windows when pressed. Default: Input::F5
  454. # :gn_press_or_toggle - If :graphic_novel is true, this determines whether the
  455. #       player has to hold down the :hide_button or whether it acts as a toggle.
  456. #       true => press; false => toggle. Default: true
  457. # :filters - This is a hash holding user-defined replacements for special
  458. #       codes. This is the hash that is accessed when using the \f[x] message
  459. #       code and is useful, for instance, if you have a character choose their
  460. #       sex at the start of the game. Then you can set the filters to the
  461. #       appropriate pronoun and use that and not have to have separate text
  462. #       boxes just to differentiate between when people say he or her.
  463. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  464. # :message_x - This is the x coordinate of the message window. If it is set to
  465. #       -1, then it will be centred. If not, it will be directly set to that
  466. #       coordinate of the screen. Default: -1
  467. # :message_y - This is the y coordinate of the message window. If it is set to
  468. #       -1, then it will abide by the normal way of setting position through
  469. #       the top, middle, bottom option in the text window. If it is not -1,
  470. #       then it will be directly set to that coordinate. Default: -1
  471. # :wlh - the line height of lines in the message window. Default: 24
  472. # :battle_wlh - the line height of lines in the message window during battle.
  473. #       This should always be 24 unless you have a good reason. Default: 24
  474. # :do_not_obscure - When using default positioning, this will choose a
  475. #       different position setting if the current one is over any of the
  476. #       characters included in :obscure_characters
  477. # :obscure_characters - If :do_not_obscure is true and the message is being set
  478. #       using default positioning, then the message box will be choose override
  479. #       the chosen position if the chosen position obscures one or more of the
  480. #       characters in this array and another position would obscure less. The
  481. #       player is identified by 0 and any number greater than that refers to
  482. #       the event with that ID. When setting up the default, it is recommended
  483. #       that you only include the player and set others only on a map by map
  484. #       basis. Default: [0]
  485. # :obscure_buffer - this is how much space from the bottom of the character you
  486. #       want to avoid obscuring. It should be set to the height of the tallest
  487. #       character you want to avoid obscuring. Default: 32
  488. # :fit_window_to_text - If this is true, then the window will be made to be
  489. #       just wide enough to contain the longest line and just tall enough to
  490. #       contain either all the lines up to :max_lines. Default: false
  491. # :message_width - This is how many pixels wide the message window is.
  492. #       Default: 544
  493. # :message_height - This is how many pixels tall the message window is.
  494. #       Default: 128
  495. # :message_opacity - This is the opacity of the window. Default: 255
  496. # :message_backopacity - This is the opacity of the background of the
  497. #       windowskin. Default: 200
  498. # :message_windowskin - This is the windowskin that this window uses. It must
  499. #       be a graphic located in the System folder. Default: "Window"
  500. # :message_fontcolour - This is the default colour of the font that is used
  501. #       everytime a new page is made. It can either refer to the windowskin
  502. #       palette (0-31) or be [red, green, blue] array. Default: 0
  503. # :message_fontname - This is the default font of the window. It can either
  504. #       refer to a single font or to a prioritized array of fonts, where the
  505. #       first one is used unless that font is not installed, and so on.
  506. #       Default: ["Verdana", "Arial", "Courier New"]
  507. # :message_fontsize - This is the default size of the font. Default: 20
  508. # :message_fontalpha - This is the default opacity of the text. Default: 255
  509. # :message_dim - The graphic to use when selecting the "Dim" option.
  510. #       Default: "MessageBack"
  511. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  512. # :face_x - The x coordinate of the face box. If set to -1, the x-coordinate
  513. #       will be automatically positioned. If not, it will be directly set to
  514. #       this value. Default: -1
  515. # :face_y - The y coordinate of the face box. If set to -1, the y-coordinate
  516. #       will be automatically positioned. If not, it will be directly set to
  517. #       this value. Default: -1
  518. # :face_z - If this is >0, it will show up above the message window. If less
  519. #       than 0, it will show up below the message window. Default: 10
  520. # :face_side - When :face_x is -1, this determines which side of the message
  521. #       box the face shows up on. true => Left; false => Right. Default: true
  522. # :face_offset_x - When :choice_x is -1, this is added to the x position.
  523. #       Default: 0
  524. # :face_offset_y - When :choice_y is -1, this is added to the y position.
  525. #       Default: 0
  526. # :face_width - This determines the width of the face. When 0, it will show the
  527. #       whole width of the face, even if using single face graphics. If you want
  528. #       to show only a portion of the face, then set it directly. Default: 0
  529. # :face_height - This determines the height of the face. When 0, it will show
  530. #       the whole height of the face, even if using single face graphics. If
  531. #       you want to show only part of the face, then set it directly. Default: 0
  532. # :face_mirror - When true, the face will be drawn mirrored. Default: false
  533. # :face_opacity - This is the opacity of the face. Default: 255
  534. # :face_blend_type - This is the blend type of the face sprites. 0 => normal;
  535. #       1 => addition; 2 => subtraction. Default: 0
  536. # :face_fadein - When this is true, the face will fadein when starting a
  537. #       message instead of just automatically appearing. Default: false
  538. # :face_fade_speed - If :face_fadein is true, this is how much the opacity will
  539. #       change every frame. Default: 10
  540. # :face_scroll_x - Option to scroll the face in horizontally. Default: false
  541. # :face_scroll_y - Option to scroll the face in vertically. Default: false
  542. # :face_scroll_speed - If either :face_scroll_x or :face_scroll_y are true,
  543. #       this is the number of pixels per frame it scrolls in at.
  544. # :animate_faces - When this is true, specially labelled face files will
  545. #       animate. Face files that have ![x] in the name will take the first x
  546. #       faces in the file and animate between them. Alternatively, it can take
  547. #       the face of the same index from separate face files that are sequenced
  548. #       by suffixes _1, _2, etc... Default: true
  549. # :letters_per_face - when :animate_faces is true, this is how many letters to
  550. #       draw between rotating the faces.
  551. # :face_window - If true, the face will be framed by a window. Default: false
  552. # :face_window_opacity - If :face_window is true, this is the opacity of that
  553. #       window. Default: 255
  554. # :face_windowskin - If :face_window is true, this is the windowskin it uses.
  555. #       Default: "Window"
  556. # :face_border_size - If :face_window is true, this is the size of the border.
  557. #       Default: 6
  558. # :face_dim - If using :face_window and dim, the sprite to stretch as a
  559. #       background for the face. Default: "MessageBack"
  560. # :face_use_dim - The setting for using dim. If 0, it will never use dim. If 1,
  561. #       it will use the dim sprite if :face_window is true. If 2, it will use
  562. #       dim only when the message window is also using dim. Default: 0
  563. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  564. # :choice_text - This is a bracket for any choice text. It is useful if, for
  565. #       instance, you want particular codes to apply to every choice in a
  566. #       branch. You must include %s in the string, and that is where the actual
  567. #       choice text will show up, bracketed by whatever other codes you put in
  568. #       Default: "    %s" (meaning every choice will be indented by four spaces)
  569. # :disabled_choice_text - Same as above, except it only applies to choices that
  570. #       are disabled and is applied after :choice_text is. It is useful if you
  571. #       want to differentiate between disabled choices and non-disabled ones.
  572. #       Unlike :choice_text, %s doesn't have to be included and in that case all
  573. #       disabled choices would simply be replaced by this text.
  574. #       Default: "\\FA[128]%s\\FA[255]" (meaning disabled choices will be drawn
  575. #       at 128 opacity).
  576. # :choicebox_text - The same as :choice_text, but this is what is applied when
  577. #       using a choicebox instead of :choice_text. Default: "%s" (no change)
  578. # :choice_window - Whether or not choices will show up in a separate window.
  579. #       Default: false
  580. # :choice_x - The x coordinate of the choice window. When this is -1, the x
  581. #       position will be set automatically in reference to the position of the
  582. #       message window (end of the side opposite the face). When anything else,
  583. #       the x position is directly set to that coordinate. Default: -1
  584. # :choice_y - The y coordinate of the choice window. Whwn this is -1, the y
  585. #       position is set automatically directly above the message window or
  586. #       below, if it goes off screen when placed above. Default: -1
  587. # :choice_offset_x - When :choice_x is -1, this is added to the auto x position.
  588. #       Default: -16
  589. # :choice_offset_y - When :choice_y is -1, this is added to the auto y position.
  590. #       Default: 16
  591. # :choice_width - This is the width of the choice window. When -1, it will set
  592. #       it to as wide as necessary to accomodate the longest line, up to a
  593. #       maximum of the screen width. Default: 192
  594. # :choice_height - This is the height of the choice window. When -1, it is set
  595. #       to the number of rows necessary to draw all choices, up to :max_lines.
  596. # :column_max - When using :choice_window, the number of columns. Default: 1
  597. # :row_max - When :choice_height is -1, the max number of rows. Default: 4
  598. # :choice_spacing - When :column_max > 1, this is how much empty space is left
  599. #       between options on the same row. Default: 20
  600. # :choice_opacity - This is the opacity of the choice window. Default: 255
  601. # :choice_backopacity - This is the opacity of the background of the choice
  602. #       window. Default: 200
  603. # :choice_windowskin - This is the name of the System file to use as the
  604. #       windowskin for the choice window. Default: "Window"
  605. # :choice_fontcolour - The default colour of text in the choice window. It can
  606. #       be from the windowskin palette or a [red, green, blue] array. Default: 0
  607. # :choice_fontname - The font for the choice window. If an array, it will take
  608. #       the first font in the array that the player has installed.
  609. #       Default: ["Verdana", "Arial", "Courier New"]
  610. # :choice_fontsize - Default size of the font in the choice window. Default: 20
  611. # :choice_wlh - The vertical space of each row of the choice window. Default: 24
  612. # :choice_dim - If using :choice_window and dim, the sprite to stretch as a
  613. #       background for the choice branch. Default: "MessageBack"
  614. # :choice_use_dim - The setting for using dim. If 0, it will never use dim. If
  615. #       1, it will use the dim sprite if :choice_window is true. If 2, it will
  616. #       use dim only when the message window is also using dim. Default: 2
  617. # :choice_on_line - Whether to show the choice box adjacent to the message
  618. #       window or not. Doesn't apply if :choice_width is not directly set or if
  619. #       :fit_window_to_text is on and larger than :choice_width. Default: false
  620. # :choice_opposite_face - When true, the side the choice is shown on is the
  621. #       opposite side the face is on. And vice versa. Default: true
  622. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  623. # :choicehelp_x - The x coordinate of the choicehelp window. When this is -1,
  624. #       the x position is centred. Default: -1
  625. # :choicehelp_y - The y coordinate of the choicehelp window. Whwn this is -1,
  626. #       the y position is at the top of the screen unless it overlaps with the
  627. #       message window, in which case it goes to the bottom. Default: -1
  628. # :choicehelp_width - This is the width of the choicehelp window. When -1, it
  629. #       will set it to the width of the longest line, up to a maximum of the
  630. #       screen width. Default: -1
  631. # :choicehelp_height - This is the height of the choicehelp window. When -1, it
  632. #       is set to accomodate the greatest number of lines that any choice option
  633. #       requires: Default: -1
  634. # :choicehelp_center - Whether or not to centre the text vertically when the
  635. #       number of lines is smaller than the height of the window. Default: true
  636. # :choicehelp_opacity - This is the opacity of the choicehelp window.
  637. #       Default: 255
  638. # :choicehelp_backopacity - This is the opacity of the background of the
  639. #       choicehelp window. Default: 200
  640. # :choicehelp_windowskin - This is the name of the System file to use as the
  641. #       windowskin for the choicehelp window. Default: "Window"
  642. # :choicehelp_fontcolour - This is the default colour of text in the choicehelp
  643. #       window. It can either be from the windowskin palette or a
  644. #       [red, green, blue, alpha] array. Default: 0
  645. # :choicehelp_fontname - This is either a string or array containing the name
  646. #       of the font used in the choicehelp window. If an array, it will take
  647. #       the first font in the array that the player has installed.
  648. #       Default: ["Verdana", "Arial", "Courier New"]
  649. # :choicehelp_fontsize - This is the default size of the font in the choicehelp
  650. #       window. Default: 20
  651. # :choicehelp_wlh - This is the vertical space required for each line of the
  652. #       choicehelp window. Default: 24
  653. # :choicehelp_dim - If using :choicehelp_window and dim, the sprite to stretch
  654. #       as a background for the choicehelp branch. Default: "MessageBack"
  655. # :choicehelp_use_dim - The setting for using dim. If 0, it will never use dim.
  656. #       If 1, it will use the dim sprite if :choicehelp_window is true. If 2,
  657. #       it will use dim only when the message window is also using dim.
  658. #       Default: 2
  659. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  660. # :name_x - The x coordinate of the name window. When this is -1, the x
  661. #       coordinate is automatically placed on the same side the face would be
  662. #       if automatically positioned. Default: -1
  663. # :name_y - The y coordinate of the name window. When this is -1, the y
  664. #       coordinate is just above the message window, unless it goes off the
  665. #       screen, in which case it is placed just below. Default: -1
  666. # :name_offset_x - When :name_x is -1, this is added to the x position.
  667. #       Default: 16
  668. # :name_offset_y - When :name_y is -1, this is added to the y position.
  669. #       Default: 16
  670. # :name_opacity - This is the opacity of the name window. Default: 255
  671. # :name_backopacity - This is the opacity of the background of the name window.
  672. #       Default: 200
  673. # :name_windowskin - This is the name of the System file to use as the
  674. #       windowskin for the name window. Default: "Window"
  675. # :name_border_size - The size of the windowskin border around the name.
  676. #       Default: 8
  677. # :name_wlh - This is the vertical space required for each line of the name
  678. #       window. Default: 24
  679. # :name_fontcolour - This is the default colour of text in the name window. It
  680. #       can either be from the windowskin palette or a  [red, green, blue]
  681. #       array. Default: 0
  682. # :name_fontname - This is either a string or array containing the name of the
  683. #       font used in the name window. If an array, it will take the first font
  684. #       in the array that the player has installed.
  685. #       Default: ["Verdana", "Arial", "Courier New"]
  686. # :name_fontsize - This is the default size of the font in the name window.
  687. #       Default: 20
  688. # :name_dim - If using dim, the sprite to stretch as a background for the name
  689. #       box. Default: "MessageBack"
  690. # :name_use_dim - The setting for using dim. If 0, it will never use dim.
  691. #       If 1, it will use the dim sprite. If 2, it will use dim only when the
  692. #       message window is also using dim. Default: 2
  693. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  694. # :word_x - The x coordinate of the word window. When this is -1, the word
  695. #       window is centred, or to the left of the gold window if the gold window
  696. #       is visible and :word_y is -1. If not -1, it is directly set to that
  697. #       coordinate. Default: -1
  698. # :word_y - The y coordinate of the word window. When this is -1, the y
  699. #       coordinate is at the same position as the gold window, unless the gold
  700. #       window is visible and the word window is too wide to fit to the left of
  701. #       it, in which case it is directly above or below the gold window,
  702. #       depending on where it fits. If not -1, it is directly set to that
  703. #       coordinate. Default: -1
  704. # :word_width - The width of the word window. When -1, it is set to accomodate
  705. #       the longest line. Default: 160
  706. # :word_height - The height of the word window. When -1, it will be set to
  707. #       accomodate the number of lines. Default: -1
  708. # :word_opacity - This is the opacity of the word window. Default: 255
  709. # :word_backopacity - This is the opacity of the background of the word window.
  710. #       Default: 200
  711. # :word_windowskin - This is the word of the System file to use as the
  712. #       windowskin for the word window. Default: "Window"
  713. # :word_wlh - This is the vertical space required for each line of the word
  714. #       window. Default: 24
  715. # :word_fontcolour - This is the default colour of text in the word window. It
  716. #       can either be from the windowskin palette or a  [red, green, blue]
  717. #       array. Default: 0
  718. # :word_fontname - This is either a string or array containing the name of the
  719. #       font used in the word window. If an array, it will take the first font
  720. #       in the array that the player has installed.
  721. #       Default: ["Verdana", "Arial", "Courier New"]
  722. # :word_fontsize - This is the default size of the font in the word window.
  723. #       Default: 20
  724. # :word_dim - If using dim, the sprite to stretch as a background for the word
  725. #       box. Default: "MessageBack"
  726. # :word_use_dim - The setting for using dim. If 0, it will never use dim.
  727. #       If 1, it will use the dim sprite. If 2, it will use dim only when the
  728. #       message window is also using dim. Default: 2
  729. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  730. #      ~ats_next only codes~
  731. #  The following codes can only be set on a message by message basis with
  732. # ats_next or $game_message. ats_all and $game_ats does not work for these.
  733. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  734. # :do_not_refresh - When this is set to true, the contents of the message
  735. #       window will not refresh until it is turned off. This means that text
  736. #       messages will be appended to all the previous messages even if there
  737. #       are other events in between, such as a Show Picture or Control
  738. #       Variables switch and so on... Note that you will not be able to change
  739. #       the face either without forcibly setting a new page. To turn it off,
  740. #       you need to use a ats_next (:do_not_refresh, false) right before the
  741. #       last message that you want appended. I do not recommend doing anything
  742. #       too fancy with this; the idea is to permit you to do small things, like
  743. #       Showing a picture, turning a switch on or off or doing some stuff with
  744. #       conditional branches in between drawing letters. It's not designed or
  745. #       tested for much of anything else.
  746. # :character - This is the same idea as the \oc, \uc, etc... character
  747. #       positioning codes. This allows you to place it prior to opening the
  748. #       window however. Set this value to the ID of the character you want to
  749. #       position it in reference to (0 => Player, >1 => Event with that ID.
  750. # :char_ref - This is how you want to place it. 0 => Over; 1 => Left;
  751. #       2 => Under; 3 => Right; 4 => Over if fits, otherwise under.
  752. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  753. # You can set default values for all properties starting at line 766.
  754. #==============================================================================
  755.  
  756. #==============================================================================
  757. # ** Game_ATS
  758. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  759. #  This class holds all of the default data for the ATS
  760. #==============================================================================
  761.  
  762. class Game_ATS
  763.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  764.   #      EDITABLE REGION
  765.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  766.   MAX_LINES = 4                 # See line 376.
  767.   MESSAGE_SPEED = 0             # See line 378.
  768.   SKIP_DISABLED = false         # See line 380.
  769.   APPEND_TEXT = false            # See line 381.
  770.   APPEND_CHOICE = true          # See line 383.
  771.   SCROLLING = true              # See line 387.
  772.     SCROLL_SPEED = 2            # See line 389.
  773.     SCROLL_SHOW_ARROWS = true   # See line 391.
  774.     SCROLL_AUTOPAUSE = false    # See line 394.
  775.     SCROLL_REVIEW = true        # See line 396.
  776.     SCROLL_BY_PAGE = false      # See line 399.
  777.   PARAGRAPH_FORMAT = true      # See line 400.
  778.     JUSTIFIED_TEXT = false      # See line 403.
  779.   LETTER_SOUND = false          # See line 406.
  780.     LETTER_SE = "Open1", 40     # See line 408.
  781.     LETTERS_PER_SE = 3          # See line 410.
  782.     RANDOM_PITCH = 100..100     # See line 413.
  783.   SPEECH_TAG_INDEX = -1         # See line 418.
  784.   # SPEECH_TAG_GRAPHICS         # See line 422.
  785.     SPEECH_TAG_GRAPHICS = ["Speech Tag 1", "Speech Tag 2", "Thought Tag 1"]
  786.   START_SOUND = false           # See line 426.
  787.     START_SE = "Chime2"         # See line 428.
  788.   FINISH_SOUND = false          # See line 430.
  789.     FINISH_SE = "Chime1"        # See line 432.
  790.   PAUSE_SOUND = false           # See line 434.
  791.     PAUSE_SE = "Decision2"      # See line 436.
  792.   TERMINATE_SOUND = false       # See line 438.
  793.     TERMINATE_SE = "Cancel"     # See line 440.
  794.   MOVE_WHEN_VISIBLE = false     # See line 442.
  795.   GRAPHIC_NOVEL = false         # See line 447.
  796.     HIDE_BUTTON = Input::F5     # See line 452.
  797.     GN_PRESS_OR_TOGGLE = true   # See line 454.
  798.   FILTERS = {                   # See line 457.
  799.     'ATS' => '\c[1]Advanced Text System\c[0], Version 3.0',
  800.     0     => 'Numbered filters work too',
  801.   }
  802.   FILTERS.default = "" # <- Do not touch
  803.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  804.   MESSAGE_X = -1                # See line 464.
  805.   MESSAGE_Y = -1                # See line 467.
  806.   WLH = 24                      # See line 471.
  807.   BATTLE_WLH = 24               # See line 472.
  808.   DO_NOT_OBSCURE = false        # See line 474.
  809.     OBSCURE_CHARACTERS = [0]    # See line 477.
  810.     OBSCURE_BUFFER = 32         # See line 485.
  811.   FIT_WINDOW_TO_TEXT = false    # See line 488.
  812.   MESSAGE_WIDTH = 544           # See line 491.
  813.   MESSAGE_HEIGHT = 128          # See line 493.
  814.   MESSAGE_OPACITY = 255         # See line 495.
  815.   MESSAGE_BACKOPACITY = 200     # See line 496.
  816.   MESSAGE_WINDOWSKIN = "Window" # See line 498.
  817.   MESSAGE_FONTCOLOUR = 0        # See line 500.
  818.   MESSAGE_FONTNAME = ["Verdana", "Arial", "Courier New"] # See line 503.
  819.   MESSAGE_FONTSIZE = 20         # See line 507.
  820.   MESSAGE_FONTALPHA = 255       # See line 508.
  821.   MESSAGE_DIM = "MessageBack"   # See line 509.
  822.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  823.   FACE_X = -1                   # See line 512.
  824.   FACE_Y = -1                   # See line 515.
  825.   FACE_Z = 10                   # See line 518.
  826.   FACE_SIDE = true              # See line 520.
  827.   FACE_OFFSET_X = 0             # See line 522.
  828.   FACE_OFFSET_Y = 0             # See line 524.
  829.   FACE_WIDTH = 0                # See line 526.
  830.   FACE_HEIGHT = 0               # See line 529.
  831.   FACE_MIRROR = false           # See line 532.
  832.   FACE_OPACITY = 255            # See line 533.
  833.   FACE_BLEND_TYPE = 0           # See line 534.
  834.   FACE_FADEIN = false           # See line 536.
  835.     FACE_FADE_SPEED = 10        # See line 538.
  836.   FACE_SCROLL_X = false         # See line 540.
  837.   FACE_SCROLL_Y = false         # See line 541.
  838.     FACE_SCROLL_SPEED = 12      # See line 542.
  839.   ANIMATE_FACES = true          # See line 544.
  840.     LETTERS_PER_FACE = 6        # See line 545.
  841.   FACE_WINDOW = false           # See line 551.
  842.     FACE_WINDOW_OPACITY = 255   # See line 552.
  843.     FACE_WINDOWSKIN = "Window"  # See line 554.
  844.     FACE_BORDER_SIZE = 6        # See line 556.
  845.     FACE_DIM = "MessageBack"    # See line 558.
  846.     FACE_USE_DIM = 0            # See line 560.
  847.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  848.   CHOICE_TEXT = "    %s"        # See line 564.
  849.   DISABLED_CHOICE_TEXT = "\\FA[128]%s\\FA[255]" # See line 569.
  850.   CHOICEBOX_TEXT = "%s"         # See line 576.
  851.   CHOICE_WINDOW = false         # See line 578.
  852.   CHOICE_X = -1                 # See line 580.
  853.   CHOICE_Y = -1                 # See line 584.
  854.   CHOICE_OFFSET_X = -16         # See line 587.
  855.   CHOICE_OFFSET_Y = 16          # See line 589.
  856.   CHOICE_WIDTH = 192            # See line 591.
  857.   CHOICE_HEIGHT = -1            # See line 594.
  858.   COLUMN_MAX = 1                # See line 596.
  859.   ROW_MAX = 4                   # See line 597.
  860.   CHOICE_SPACING = 20           # See line 598.
  861.   CHOICE_OPACITY = 255          # See line 600.
  862.   CHOICE_BACKOPACITY = 200      # See line 601.
  863.   CHOICE_WINDOWSKIN = "Window"  # See line 603.
  864.   CHOICE_FONTCOLOUR = 0         # See line 605.
  865.   CHOICE_FONTNAME = ["Verdana", "Arial", "Courier New"] # See line 607.
  866.   CHOICE_FONTSIZE = 20          # See line 610.
  867.   CHOICE_WLH = -1               # See line 611.
  868.   CHOICE_DIM = "MessageBack"    # See line 612.
  869.   CHOICE_USE_DIM = 2            # See line 614.
  870.   CHOICE_ON_LINE = false        # See line 617.
  871.   CHOICE_OPPOSITE_FACE = true   # See line 620.
  872.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  873.   CHOICEHELP_X = -1             # See line 623.
  874.   CHOICEHELP_Y = -1             # See line 625.
  875.   CHOICEHELP_WIDTH = 544        # See line 628.
  876.   CHOICEHELP_HEIGHT = -1        # See line 631.
  877.   CHOICEHELP_CENTER = true      # See line 634.
  878.   CHOICEHELP_OPACITY = 255      # See line 636.
  879.   CHOICEHELP_BACKOPACITY = 200  # See line 638.
  880.   CHOICEHELP_WLH = -1           # See line 640.
  881.   CHOICEHELP_WINDOWSKIN = "Window" # See line 642.
  882.   CHOICEHELP_FONTCOLOUR = 0     # See line 645.
  883.   CHOICEHELP_FONTNAME = ["Verdana", "Arial", "Courier New"] # See line 649.
  884.   CHOICEHELP_FONTSIZE = 20      # See line 651.
  885.   CHOICEHELP_DIM = "MessageBack"# See line 653.
  886.   CHOICEHELP_USE_DIM = 2        # See line 655.
  887.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  888.   NAME_X = -1                   # See line 660.
  889.   NAME_Y = -1                   # See line 663.
  890.   NAME_OFFSET_X = 16            # See line 666.
  891.   NAME_OFFSET_Y = 16            # See line 668.
  892.   NAME_OPACITY = 255            # See line 670.
  893.   NAME_BACKOPACITY = 200        # See line 671.
  894.   NAME_WINDOWSKIN = "Window"    # See line 673.
  895.   NAME_BORDER_SIZE = 8          # See line 675.
  896.   NAME_WLH = -1                 # See line 677.
  897.   NAME_FONTCOLOUR = 0           # See line 679.
  898.   NAME_FONTNAME = ["Verdana", "Arial", "Courier New"] # See line 682.
  899.   NAME_FONTSIZE = 20            # See line 686.
  900.   NAME_DIM = "MessageBack"      # See line 688.
  901.   NAME_USE_DIM = 2              # See line 690.
  902.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  903.   WORD_X = -1                   # See line 694.
  904.   WORD_Y = -1                   # See line 698.
  905.   WORD_WIDTH = 160              # See line 704.
  906.   WORD_HEIGHT = -1              # See line 706.
  907.   WORD_OPACITY = 255            # See line 708.
  908.   WORD_BACKOPACITY = 200        # See line 709.
  909.   WORD_WINDOWSKIN = "Window"    # See line 711.
  910.   WORD_WLH = -1                 # See line 713.
  911.   WORD_FONTCOLOUR = 0           # See line 715.
  912.   WORD_FONTNAME = ["Verdana", "Arial", "Courier New"] # See line 718.
  913.   WORD_FONTSIZE = 20            # See line 722.
  914.   WORD_DIM = "MessageBack"      # See line 724.
  915.   WORD_USE_DIM = 2              # See line 726.
  916.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  917.   #      END EDITABLE REGION
  918.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  919.   ATS_2 = false
  920.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  921.   # * Public Instance Variables
  922.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  923.   # For each constant, create accessor
  924.   for name in self.class.constants
  925.     # Run the script
  926.     attr_accessor name.downcase.to_sym
  927.   end
  928.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  929.   # * Object Initialization
  930.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  931.   def initialize
  932.     reset
  933.   end
  934.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  935.   # * Reset
  936.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  937.   def reset
  938.     constants = Game_ATS.constants
  939.     constants.each { |name|
  940.       self.send ("#{name.downcase}=".to_sym, Game_ATS.const_get(name))
  941.     }
  942.   end
  943.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  944.   # * Set Sound Effect
  945.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  946.   def set_sound_effect (settings)
  947.     return settings if settings.is_a? (RPG::SE)
  948.     settings = [settings] if settings.is_a? (String)
  949.     settings[1] = 80 if !settings[1]
  950.     return RPG::SE.new (*settings)
  951.   end
  952.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  953.   # * Overwrite SE methods * Thanks Zeriab
  954.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  955.   for method in ["letter", "terminate", "pause", "start", "finish"]
  956.     # Run the script
  957.     eval("def #{method}_se= (*args); @#{method}_se = set_sound_effect (*args); end")
  958.   end
  959.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  960.   # * Set Random Pitch
  961.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  962.   def random_pitch= (val)
  963.     @random_pitch = val.is_a? (Integer) ? self.letter_se.pitch..val : val
  964.   end
  965. end
  966.  
  967. #==============================================================================
  968. # ** Game_Message
  969. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  970. #  Summary of Changes:
  971. #    new attr_accessor - all Game_ATS accessors; char_ref; character;
  972. #      appending_text; choices; disabled_choices; help_choices; skip_choices;
  973. #      override_run
  974. #    aliased methods - initialize; clear; busy
  975. #    new methods - convert_special_characters; perform_substitution;
  976. #      perform_conversion; play_se; random_pitch=
  977. #==============================================================================
  978.  
  979. class Game_Message
  980.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  981.   # * Public Instance Variables
  982.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  983.   # For each ATS constant, create accessor
  984.   for name in (Game_ATS.constants) do attr_accessor name.downcase.to_sym end
  985.   # Non Game_ATS variables
  986.   attr_accessor :char_ref
  987.   attr_accessor :character
  988.   attr_accessor :appending_text
  989.   attr_accessor :choices
  990.   attr_accessor :disabled_choices
  991.   attr_accessor :skip_choices
  992.   attr_accessor :help_choices
  993.   attr_accessor :override_run
  994.   attr_accessor :highlight
  995.   attr_accessor :underline
  996.   attr_accessor :do_not_refresh
  997.   attr_accessor :do_not_start
  998.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  999.   # * Object Initialization
  1000.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1001.   alias malgb_advtx_inliz_2fk9 initialize unless $@
  1002.   def initialize (*args)
  1003.     @do_not_refresh = false
  1004.     malgb_advtx_inliz_2fk9 (*args)
  1005.   end
  1006.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1007.   # * Clear
  1008.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1009.   alias malg_ats3_clr_msg_9lo1 clear unless $@
  1010.   def clear (*args)
  1011.     @do_not_start = @do_not_refresh
  1012.     @texts = []
  1013.     @choices = []
  1014.     @disabled_choices = []
  1015.     @skip_choices = []
  1016.     @help_choices = []
  1017.     @choice_start = 99
  1018.     @choice_max = 0
  1019.     @choice_cancel_type = 0
  1020.     @choice_proc = nil
  1021.     @ignored_codes = []
  1022.     return if @do_not_start
  1023.     malg_ats3_clr_msg_9lo1 (*args) # Run Original Method
  1024.     @alignment = 0
  1025.     @appending_text = false
  1026.     @character = -1
  1027.     @char_ref = 0
  1028.     @override_run = false
  1029.     @highlight = -1
  1030.     @underline = false
  1031.     # Set ATS variables
  1032.     (Game_ATS.constants).each { |name|
  1033.       self.send ("#{name.downcase}=".to_sym, $game_ats.send (name.downcase.to_sym))
  1034.     }
  1035.   end
  1036.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1037.   # * Busy?
  1038.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1039.   alias malbr_busy_ats3_8ik2 busy unless $@
  1040.   def busy (*args)
  1041.     return false if @appending_text
  1042.     return malbr_busy_ats3_8ik2 (*args)
  1043.   end
  1044.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1045.   # * Convert Special Characters
  1046.   #    text : the text to convert
  1047.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1048.   def convert_special_characters (text)
  1049.     return if text == nil
  1050.     @ignored_codes.clear
  1051.     # Remove Ignore code strings
  1052.     text.gsub! (/\\\$(.*?)\/\$/i) {
  1053.       @ignored_codes.push ($1.to_s)
  1054.       "\x0a<#{@ignored_codes.size - 1}>"
  1055.     }
  1056.     # Get substitutions
  1057.     text = perform_substitution (text)
  1058.     text = perform_conversion (text)
  1059.     text.gsub! (/\\\\/)           { "\\" }
  1060.     text.gsub! (/\x0a<(\d+)>/) { @ignored_codes[$1.to_i] } # Recover Protected strings
  1061.     return text
  1062.   end
  1063.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1064.   # * Convert Substitution Codes
  1065.   #    text : the text to convert
  1066.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1067.   def perform_substitution (text)
  1068.     # Switch conditional text
  1069.     text.gsub! (/\\V\[(\d+)\]/i) { $game_variables[$1.to_i] }   # Variable
  1070.     text.gsub! (/\\PID\[(\d+)\]/i)  { $game_party.members[($1.to_i % $game_party.members.size)].id } # Party Member X
  1071.     text.gsub! (/\\P\[(\d+)\]/i) { $game_party.members[($1.to_i % $game_party.members.size)].id } # Party Member X
  1072.     text.gsub! (/\\V\[(\d+)\]/i) { $game_variables[$1.to_i] }   # Variable
  1073.     # FILTERS
  1074.     text.gsub!(/\\F\[["'](.+?)["']\]/i)  { Game_ATS::FILTERS[$1.to_s] }
  1075.    text.gsub!(/\\F\[(.+?)\]/i)    { Game_ATS::FILTERS[$1.to_i] }
  1076.    # Party ID to Actor ID
  1077.    text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name rescue ""} # Actor Name
  1078.    # New Codes
  1079.    text.gsub! (/\\AC\[(\d+)\]/i) { $game_actors[$1.to_i].class.name rescue "" } # Actor Class
  1080.    text.gsub! (/\\VOCAB\[(\w+)\]/i) { Vocab.send ($1.downcase) rescue "" }
  1081.    # Actor, Item, Weapon, Armor, Skill Stats
  1082.    data_arrays = [$game_actors, $data_items, $data_weapons,  $data_armors,
  1083.    $data_skills, $data_states, $data_enemies]
  1084.    regexp_array = ["ACTOR_", "I_", "W_", "A_", "S_", "T_", "ENEMY_"]
  1085.    for i in 0...regexp_array.size
  1086.      regexp = regexp_array[i]
  1087.      data = data_arrays[i]
  1088.      if i != 0
  1089.        text.gsub! (/\\#{regexp}N\[(\d+)\]/i) {
  1090.          id = $1.to_i
  1091.          data[id].note[/\\MSG\[(.+?)\]MSG\//i].nil? ? data[id].note : $1.to_s.gsub (/\n/) { "" }            # Remove \n
  1092.        }
  1093.      end
  1094.      # Item Stats
  1095.      text.gsub! (/\\#{regexp}([^\[]+?)\[(\d+)\]/i) { |match| data[$2.to_i].send ($1.downcase).to_s rescue match }
  1096.    end
  1097.    text.gsub! (/\\MAP\[(\d+)\]/i) { (load_data ("Data/MapInfos.rvdata"))[$1.to_i].name rescue "" }
  1098.    text.gsub! (/\\MAP/i) { (load_data ("Data/MapInfos.rvdata"))[$game_map.map_id].name rescue "" }
  1099.    text.gsub! (/\\NL\[(\d+)\]/i){ $data_system.elements[$1.to_i] rescue "" }
  1100.    text.gsub! (/\\NC\[(\d+)\]/i) { $data_classes[$1.to_i].name rescue "" } # Class Name
  1101.    text.gsub! (/\\NE\[(\d+)\]/i) { $game_map.events[$1.to_i].name rescue "" } # Event Name
  1102.    text.gsub! (/\\NM\[(\d+)\]/i) { $data_enemies[$1.to_i].name rescue "" } # Monster Name
  1103.    text.gsub! (/\\NI\[(\d+)\]/i) { $data_items[$1.to_i].name rescue "" }   # Item Name
  1104.    text.gsub! (/\\NW\[(\d+)\]/i) { $data_weapons[$1.to_i].name rescue "" } # Weapon Name
  1105.    text.gsub! (/\\NA\[(\d+)\]/i) { $data_armors[$1.to_i].name rescue "" } # Armor Name
  1106.    text.gsub! (/\\NS\[(\d+)\]/i) { $data_skills[$1.to_i].name rescue "" } # Skill Name
  1107.    text.gsub! (/\\NT\[(\d+)\]/i) { $data_states[$1.to_i].name rescue "" } # State Name
  1108.    text.gsub! (/\\NP\[(\d+)\]/i) { $game_party.members[($1.to_i % $game_party.members.size)].name } # Party Name
  1109.    text.gsub! (/\\NV\[(\d+)\]/i) { $data_system.variables[$1.to_i] rescue "" } # Variable Name
  1110.    text.gsub! (/\\NSW\[(\d+)\]/i){ $data_system.switches[$1.to_i] rescue "" } # Switch Name
  1111.    text.gsub! (/\\PI\[(\d+)\]/i) { $data_items[$1.to_i].price.to_s rescue "" } # Item Price
  1112.    text.gsub! (/\\PW\[(\d+)\]/i) { $data_weapons[$1.to_i].price.to_s rescue "" } # Weapon Price
  1113.    text.gsub! (/\\PA\[(\d+)\]/i) { $data_armors[$1.to_i].price.to_s rescue "" } # Armor Price
  1114.    text.gsub! (/\\DI\[(\d+)\]/i) { $data_items[$1.to_i].description rescue "" } # Item Description
  1115.    text.gsub! (/\\DW\[(\d+)\]/i) { $data_weapons[$1.to_i].description rescue "" } # Weapon Description
  1116.    text.gsub! (/\\DA\[(\d+)\]/i) { $data_armors[$1.to_i].description rescue "" } # Armor Description
  1117.    text.gsub! (/\\DS\[(\d+)\]/i) { $data_skills[$1.to_i].description rescue "" } # Skill Description
  1118.    text.gsub! (/\\I#\[(\d+)\]/i) { $game_party.item_number ($data_items[$1.to_i]) } # Item Number
  1119.    text.gsub! (/\\W#\[(\d+)\]/i) { $game_party.item_number ($data_weapons[$1.to_i]) } # Weapon Number
  1120.    text.gsub! (/\\A#\[(\d+)\]/i) { $game_party.item_number ($data_armors[$1.to_i]) } # Armor Number
  1121.    text.gsub! (/\\S\!<(\d+),(.+?)>/i) { $game_switches[$1.to_i] ? "" : $2.to_s }
  1122.    text.gsub! (/\\S<(\d+),(.+?)>/i)  { $game_switches[$1.to_i] ? $2.to_s : "" }
  1123.    text.gsub! (/\\#\{(.+?)\}#/im) { (eval ($1.to_s)).to_s rescue "" }
  1124.    return text.sub! (/\\RESUB/i, "") != nil ? perform_substitution (text) : text
  1125.  end
  1126.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1127.  # * Perform Conversion
  1128.  #    text : the text to convert
  1129.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1130.  def perform_conversion (text)
  1131.    text.gsub! (/\\C\[(\d+)\]/i)        { "\x01<#{$1}>" } # Colour
  1132.    text.gsub! (/\\C\[#([\dABCDEF]{6,6})\]/i) { "\x01<##{$1}>"} # Colour Hex
  1133.    text.gsub! (/\\G/i)                 { "\x02" }        # Gold Window
  1134.    text.gsub! (/\\\./)                 { "\x03<15>" }    # Wait 15 frames
  1135.    text.gsub! (/\\\|/)                 { "\x03<60>" }    # Wait 60 frames
  1136.    text.gsub! (/\\W\[(\d+)\]/i)        { "\x03<#{$1}>" } # Wait x frames
  1137.    text.gsub! (/\\!/)                  { "\x04" }        # Wait for Input
  1138.    text.gsub! (/\\@@/)                 { "\x05<0>" }     # Show Fast ON
  1139.    text.gsub! (/\/@@/)                 { "\x05<1>" }     # Show Fast OFF
  1140.    text.gsub! (/\\@/)                  { "\x06<0>" }     # Show Line Fast ON
  1141.    text.gsub! (/\/@/)                  { "\x06<1>" }     # Show Line Fast OFF
  1142.    text.gsub! (/\\\^/)                 { "\x07" }        # Skip Pause
  1143.    text.gsub! (/\\>/)                  { "\x08<-1>" }     # Message speed- 1
  1144.    text.gsub! (/\\</)                  { "\x08<1>" }    # Message speed + 1
  1145.    text.gsub! (/\\[Ss]\[(=?-?\d+)\]/i) { "\x08<#{$1}>" } # Message speed + x
  1146.    text.gsub! (/\\%/)                  { "\xb0<0>" }     # Enable Skip
  1147.    text.gsub! (/\/%/)                  { "\xb0<1>" }     # Disable Skip
  1148.    # Animation and Balloons
  1149.    text.gsub! (/\\ANI\[(\d+),\s*(\d+)\]/i) { "\x0b<#{$1},#{$2},0>" } # Animation
  1150.    text.gsub! (/\\BLN\[(\d+),\s*(\d+)\]/i) { "\x0b<#{$1},#{$2},1>" } # Balloon
  1151.    # Position to Character
  1152.    text.gsub! (/\\OC\[(\d+)\]/i)     { "\x0c<#{$1},0>" } # Over Character
  1153.    text.gsub! (/\\LC\[(\d+)\]/i)     { "\x0c<#{$1},1>" } # Left of Character
  1154.    text.gsub! (/\\UC\[(\d+)\]/i)     { "\x0c<#{$1},2>" } # Under Character
  1155.    text.gsub! (/\\RC\[(\d+)\]/i)     { "\x0c<#{$1},3>" } # Right of Character
  1156.    text.gsub! (/\\E\[(\d+)\]/i)      { "\x0c<#{$1},4>" } # Under if over doesn't work
  1157.     text.gsub! (/\\SE\[(.+?)\]/i)    { "\x1b<#{$1},SE>" } # Play Sound Effect
  1158.     text.gsub! (/\\ME\[(.+?)\]/i)    { "\x1b<#{$1},ME>" } # Play Musical Effect
  1159.     # Show Icons
  1160.     text.gsub! (/\\IC?O?N?\[(\d+)\]/i)  { "\x0d<#{$1}>" } # Show Icon X
  1161.     text.gsub! (/\\IIC?O?N?\[(\d+)\]/i) { "\x0d<#{$data_items[$1.to_i].icon_index}>" rescue "" } # Item Icon
  1162.     text.gsub! (/\\WIC?O?N?\[(\d+)\]/i) { "\x0d<#{$data_weapons[$1.to_i].icon_index}>" rescue "" } # Weapon Icon
  1163.     text.gsub! (/\\AIC?O?N?\[(\d+)\]/i) { "\x0d<#{$data_armors[$1.to_i].icon_index}>" rescue "" } # Armor Icon
  1164.     text.gsub! (/\\SIC?O?N?\[(\d+)\]/i) { "\x0d<#{$data_skills[$1.to_i].icon_index}>" rescue "" }
  1165.     text.gsub! (/\\TIC?O?N?\[(\d+)\]/i) { "\x0d<#{$data_states[$1.to_i].icon_index}>" rescue "" }
  1166.     text.gsub! (/\\[Bb]/)               { "\x0e<0>" }     # Bold ON
  1167.     text.gsub! (/\/[Bb]/)               { "\x0e<1>" }     # Bold OFF
  1168.     text.gsub! (/\\[Ii]/)               { "\x0f<0>" }     # Italics ON
  1169.     text.gsub! (/\/[Ii]/)               { "\x0f<1>" }     # Italics OFF
  1170.     text.gsub! (/\\[Ss]/)               { "\x10<0>" }     # Shadow ON
  1171.     text.gsub! (/\/[Ss]/)               { "\x10<1>" }     # Shadow OFF
  1172.     text.gsub! (/\\[Uu]/)               { "\x11<0>" }     # Underline ON
  1173.     text.gsub! (/\/[Uu]/)               { "\x11<1>" }     # Underline OFF
  1174.     text.gsub! (/\\HL\[(-?\d+)\]/i)     { "\x12<#{$1}>" } # Higlight X
  1175.     text.gsub! (/\/HL/i)                { "\x12<-1>" }    # Highlight OFF
  1176.     text.gsub! (/\\FN\[(.+?)\]/i)       { "\x13<#{$1}>" } # Font Name
  1177.     text.gsub! (/\\FS\[(\d+)\]/i)       { "\x14<#{$1}>" } # Font Size
  1178.     text.gsub! (/\\FA\[(\d+)\]/i)       { "\x15<#{$1}>" } # Font Alpha
  1179.     text.gsub! (/\\LB/i)                { "\x16" }        # Force Line Break
  1180.     text.gsub! (/\\AF\[(\d+)\]/i)  { "\x17<#{$1.to_s}>" } # Use Actor Face
  1181.     text.gsub! (/\\LEFT/i)              { "\x18<0>" }     # Align Left
  1182.     text.gsub! (/\\L/i)                 { "\x18<0>" }     # Align Left
  1183.     text.gsub! (/\\CENTRE/i)            { "\x18<1>" }     # Align Centre
  1184.     text.gsub! (/\\CE?NTE?R/i)          { "\x18<1>" }     # Align Centre
  1185.     text.gsub! (/\\C/i)                 { "\x18<1>" }     # Align Centre
  1186.     text.gsub! (/\\RI?GHT/i)            { "\x18<2>" }     # Align Right
  1187.     text.gsub! (/\\R/i)                 { "\x18<2>" }     # Align Right
  1188.     text.gsub! (/\\PB/i)                { "\x1d" }        # Force Page Break
  1189.     text.gsub! (/(\x1d\s*)\x00/i)       { $1.to_s }       # If force page, remove x00 code
  1190.     text.gsub! (/\\T/i)                 { "\x09" }        # Tab
  1191.     text.gsub! (/\\X\[(\d+)\]/i)        { "\xb1<#{$1}>" } # Content X
  1192.     # Position Direct Setting
  1193.     text.gsub! (/\\[PM]XY\[(-?\d+),\s*(-?\d+)\]/im) { "\x1f<0,#{$1.to_s},#{$2.to_s}>" }
  1194.     # Face Direct Setting
  1195.     text.gsub! (/\\FXY\[(-?\d+),\s*(-?\d+)\]/im) { "\x1f<1,#{$1.to_s},#{$2.to_s}>" }
  1196.     # Name Direct Setting
  1197.     text.gsub! (/\\NXY\[(-?\d+),\s*(-?\d+)\]/im) { "\x1f<2,#{$1.to_s},#{$2.to_s}>" }
  1198.     text.gsub! (/\\#\!\{(.+?)\}#/im)    { "\x7f{#{$1}#}" }
  1199.     text.gsub! (/\\NB\[(.*?)\]/im)      { "\x19{#{$1}}" } # Name Window
  1200.     text.gsub! (/\/NB/i)                { "\x19{}"}
  1201.     text.gsub! (/\\NAME\[(.*?)\]/im)    { "\x19{#{$1}}" } # Name Window
  1202.     text.gsub! (/\\WB\[(.*?)\]/im)      { "\x1a{#{$1}}" } # Word Box
  1203.     text.gsub! (/\/WB/i)                { "\x1a{}" }
  1204.     return text
  1205.   end
  1206.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1207.   # * Play SE
  1208.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1209.   def play_se (se)
  1210.     # Avoid FileErrors
  1211.     begin
  1212.       se.play
  1213.     rescue
  1214.     end
  1215.   end
  1216.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1217.   # * Set Choice Texts
  1218.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1219.   def choice_text= (string)
  1220.     if string.is_a? (String)
  1221.       @choice_text = convert_special_characters (string)
  1222.       @choice_text += "%s" if @choice_text[/%s/] == nil
  1223.     else
  1224.       @choice_text = "%s"
  1225.     end
  1226.   end
  1227.   def choicebox_text= (string)
  1228.     if string.is_a? (String)
  1229.       @choicebox_text = convert_special_characters (string)
  1230.       @choicebox_text += "%s" if @choicebox_text[/%s/] == nil
  1231.     else
  1232.       @choicebox_text = "%s"
  1233.     end
  1234.   end
  1235.   def disabled_choice_text= (string)
  1236.     @disabled_choice_text = string.is_a? (String) ? convert_special_characters (string) : "%s"
  1237.   end
  1238.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1239.   # * Set Random Pitch
  1240.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1241.   def random_pitch= (val)
  1242.     @random_pitch = val.is_a? (Integer) ? self.letter_se.pitch..val : val
  1243.   end
  1244.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1245.   # * Overwrite SE methods * Thanks Zeriab
  1246.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1247.   for method in ["letter", "terminate", "pause", "start", "finish"]
  1248.     # Run the script
  1249.     eval("def #{method}_se= (*args); @#{method}_se = $game_ats.set_sound_effect (*args); end")
  1250.   end
  1251. end
  1252.  
  1253. #==============================================================================
  1254. # ** Game_Event
  1255. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1256. #  Summary of Changes:
  1257. #    new method - name
  1258. #==============================================================================
  1259.  
  1260. class Game_Event
  1261.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1262.   # * Name
  1263.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1264.   def name
  1265.     return @event.name
  1266.   end
  1267. end
  1268.  
  1269. #==============================================================================
  1270. # ** Game_Player
  1271. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1272. #  Summary of Changes:
  1273. #    aliased methods - movable?; move_by_input
  1274. #==============================================================================
  1275.  
  1276. class Game_Player
  1277.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1278.   # * Move By Input
  1279.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1280.   alias mabr_adtxs3_inpmv_6yw2 move_by_input unless $@
  1281.   def move_by_input (*args)
  1282.     $game_message.override_run = $game_message.move_when_visible
  1283.     mabr_adtxs3_inpmv_6yw2 (*args) # Run Original Method
  1284.     $game_message.override_run = false
  1285.   end
  1286.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1287.   # * Check if Player can Move
  1288.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1289.   alias malg_advtxt3_movble_5sa2 movable? unless $@
  1290.   def movable? (*args)
  1291.     true_visible = $game_message.visible
  1292.     $game_message.visible = false if $game_message.move_when_visible
  1293.     check = malg_advtxt3_movble_5sa2 (*args) # Run Original Method
  1294.     $game_message.visible = true_visible
  1295.     return check
  1296.   end
  1297. end
  1298.  
  1299. #==============================================================================
  1300. # ** Game_Interpreter
  1301. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1302. #  Summary of Changes:
  1303. #    overwritten methods - command_403; setup_choices; setup_num_input
  1304. #    aliased methods - command_101; command_102; running?
  1305. #    new methods - interpret_choices; choice_plus; choice_switch; choice_help;
  1306. #      ats_next; ats_all
  1307. #==============================================================================
  1308.  
  1309. class Game_Interpreter
  1310.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1311.   # * Show Message
  1312.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1313.   alias modalg_ats_apnd_txt_show_94b command_101 unless $@
  1314.   def command_101 (*args)
  1315.     value = modalg_ats_apnd_txt_show_94b (*args)
  1316.     if $game_message.append_text && @list[@index].code == 101 && @list[@index].parameters == @params
  1317.       $game_message.appending_text = true
  1318.       value = command_101 (*args)
  1319.       $game_message.appending_text = false
  1320.     end
  1321.     return value
  1322.   end
  1323.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1324.   # * Show Choices
  1325.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1326.   alias malgr_ats3_shwchc_4ac2 command_102 unless $@
  1327.   def command_102 (*args)
  1328.     if @list[@index].indent > 1000
  1329.       @list[@index - 1].indent -= 1000
  1330.       @list[@index].indent -= 1000
  1331.       return command_skip
  1332.     else
  1333.       return malgr_ats3_shwchc_4ac2 (*args) # Run Original Method
  1334.     end
  1335.   end
  1336.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1337.   # * When [Cancel]
  1338.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1339.   def command_403
  1340.     if @branch[@indent] == 999              # If canceling choice
  1341.       @branch.delete(@indent)               # Erase branching data
  1342.       return true                           # Continue
  1343.     else                                    # If doesn't match condition
  1344.       return command_skip                   # Command skip
  1345.     end
  1346.   end
  1347.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1348.   # * Setup Choices
  1349.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1350.   def setup_choices (params)
  1351.     params = interpret_choices (Marshal.load (Marshal.dump (params)))
  1352.     $game_message.choice_start = $game_message.texts.size
  1353.     $game_message.choice_max = params[0].size
  1354.     for s in params[0]
  1355.       $game_message.choices.push(s)
  1356.     end
  1357.     $game_message.texts.push ("\x1c") if $game_message.texts.empty?
  1358.     $game_message.choice_cancel_type = params[1]
  1359.     $game_message.choice_proc = Proc.new { |n| @branch[@indent] = n }
  1360.     @index += 1
  1361.   end
  1362.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1363.   # * Number Input Setup
  1364.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1365.   def setup_num_input(params)
  1366.     if $game_message.texts.size < $game_message.max_lines || $game_message.scrolling
  1367.       $game_message.num_input_variable_id = params[0]
  1368.       $game_message.num_input_digits_max = params[1]
  1369.       @index += 1
  1370.     end
  1371.   end
  1372.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1373.   # * Interpret Choices
  1374.   #    params : the parameters of the initial 102 command.
  1375.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1376.   def interpret_choices (params)
  1377.     # Collect all next choices as well.
  1378.     ind = @index + 1
  1379.     choice_id = 0
  1380.     params[1] = 1000 if params[1] == 5
  1381.     choice_text = $game_message.choice_window ? $game_message.choicebox_text : $game_message.choice_text
  1382.     loop do
  1383.       # Advance to next choice code
  1384.       while (@list[ind].indent % 1000) > @indent
  1385.         ind += 1                           # Advance index
  1386.       end
  1387.       case @list[ind].code
  1388.       when 402
  1389.         choice_s = @list[ind].parameters[1].dup
  1390.         ind += 1
  1391.         # Choice+ processing.
  1392.         choice_s, ind = choice_plus (choice_s, ind)
  1393.         # SOFF and SON processing
  1394.         choice_s, delete, disable = choice_switch (choice_s)
  1395.         choice_s, help = choice_help (choice_s)
  1396.         if delete || choice_s.empty?
  1397.           @list[ind - 1].parameters[0] = -1
  1398.           params[0].delete_at (choice_id)
  1399.         else
  1400.           $game_message.help_choices[choice_id] = help
  1401.           choice_s = sprintf (choice_text, choice_s)
  1402.           if disable
  1403.             choice_s = sprintf ($game_message.disabled_choice_text, choice_s)
  1404.             $game_message.disabled_choices.push (choice_id)
  1405.           end
  1406.           # Choice Skip?
  1407.           choice_s.gsub! (/\x1e/i) { $game_message.skip_choices.push (choice_id); "" }
  1408.           @list[ind - 1].parameters[0] = choice_id
  1409.           params[0][choice_id] = choice_s
  1410.           choice_id += 1
  1411.         end
  1412.       when 403
  1413.         ind += 1
  1414.       when 404
  1415.         if !$game_message.append_choice || @list[ind + 1].code != 102
  1416.           @index = ind if $game_message.skip_choices.size == params.size
  1417.           $game_message.help_choices.clear if $game_message.help_choices.uniq.size == 1 && $game_message.help_choices[0].empty?
  1418.           break
  1419.         end
  1420.         p2 = @list[ind + 1].parameters.dup
  1421.         @list[ind].indent += 1000 if @list[ind].indent < 1000
  1422.         @list[ind + 1].indent += 1000 if @list[ind + 1].indent < 1000
  1423.         params[1] = p2[1] == 5 ? 1000 : p2[1] == 0 ? params[1] : params[0].size + p2[1]
  1424.         params[0].push (*p2[0])
  1425.         ind += 2
  1426.       else
  1427.         break
  1428.       end
  1429.     end
  1430.     return params
  1431.   end
  1432.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1433.   # * Running?
  1434.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1435.   alias modral_atsys3_runn_5tg3 running? unless $@
  1436.   def running? (*args)
  1437.     return false if $game_message.override_run
  1438.     return modral_atsys3_runn_5tg3 (*args)
  1439.   end
  1440.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1441.   # * Choice + Processing
  1442.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1443.   def choice_plus (choice_s, ind)
  1444.     # Choice + Processing
  1445.     if @list[ind].code == 108 # Comment
  1446.       string = @list[ind].parameters[0].dup
  1447.       ind2 = ind + 1
  1448.       while @list[ind2].code == 408
  1449.         string += @list[ind2].parameters[0]
  1450.         ind2 += 1
  1451.       end
  1452.       string.gsub (/\\\+{(.+?)}/im) { choice_s += $1.to_s; "" }
  1453.       choice_s.gsub! (/\n/)                   { "" }            # Remove \n
  1454.     end
  1455.     return choice_s, ind
  1456.   end
  1457.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1458.   # * Choice Switch
  1459.   #    s : the choice string
  1460.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1461.   def choice_switch (s)
  1462.     del = false
  1463.     dis = false
  1464.     s.gsub! (/\\SOFF\[(\d+)\]/i) { del = true if $game_switches[$1.to_i]; "" }
  1465.     s.gsub! (/\\SON\[(\d+)\]/i) { del = true if !$game_switches[$1.to_i]; "" }        
  1466.     if !del
  1467.       s.gsub! (/\\D\[(\d+)\]/i) { dis = true if !$game_switches[$1.to_i]; "" }
  1468.       s.gsub! (/\\D!\[(\d+)\]/i) { dis = true if $game_switches[$1.to_i]; "" }
  1469.       s.gsub! (/\\SKIP/i) { "\x1e" }
  1470.       s.gsub! (/\\PB/i) { "" } # Delete any page breaks.
  1471.       $game_message.convert_special_characters (s)
  1472.       s.gsub! (/\x16/) { "\x00" }        # Force Line Break
  1473.     end
  1474.     return s, del, dis
  1475.   end
  1476.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1477.   # * Choice Help
  1478.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1479.   def choice_help (choice_s)
  1480.     help_text = ""
  1481.     choice_s.gsub! (/\x1a{(.+?)}/im) { help_text += $1.to_s; "" }
  1482.     return choice_s, help_text
  1483.   end
  1484.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1485.   # * Change ATS parameter for next message
  1486.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1487.   def ats_next (parameter, *args)
  1488.     $game_message.send ("#{parameter}=".to_sym, *args) unless args.empty?
  1489.     return $game_message.send (parameter)
  1490.   end
  1491.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1492.   # * Change ATS
  1493.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1494.   def ats_all (parameter, *args)
  1495.     $game_ats.send ("#{parameter}=".to_sym, *args) unless args.empty?
  1496.     $game_message.send ("#{parameter}=".to_sym, *args) unless args.empty?
  1497.     return $game_message.send (parameter)
  1498.   end
  1499. end
  1500.  
  1501. #==============================================================================
  1502. # ** P_Formatter_ATS
  1503. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1504. #  A special formatter class designed to accomodate ATS message codes
  1505. #==============================================================================
  1506.  
  1507. class P_Formatter_ATS
  1508.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1509.   # * Public Instance Variables
  1510.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1511.   attr_accessor :bitmap
  1512.   attr_reader   :force_break
  1513.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1514.   # * Object Initialization
  1515.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1516.   def initialize (font = nil)
  1517.     @bitmap = Bitmap.new (1, 1)
  1518.     @bitmap.font = font if font
  1519.     @curly_args_codes = ["\x19", "\x1a", "\x7f"]
  1520.     @args_codes = ["\x01", "\x03", "\x05", "\x06", "\x08", "\x0b",
  1521.       "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14",
  1522.       "\x15", "\x17", "\x18", "\x1b", "\x1f", "\xb0", "\xb1"]
  1523.     @no_args_codes = ["\x00", "\x02", "\x04", "\x07", "\x09", "\x16", "\x1c",
  1524.       "\x1d", "\x1e"]
  1525.     @force_break = false
  1526.   end
  1527.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1528.   # * Dispose Bitmap
  1529.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1530.   def dispose
  1531.     @bitmap.dispose unless @bitmap.nil? || @bitmap.disposed?
  1532.   end
  1533.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1534.   # * Format By Line
  1535.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1536.   def format_by_line (string, width)
  1537.     @string = string
  1538.     @max_width = width
  1539.     @justify = $game_message.justified_text
  1540.     return 0, 0, @justify if string.empty?
  1541.     @line_width = 0
  1542.     @word_length = 0
  1543.     @w_draw_count = 0
  1544.     @l_draw_count = 0
  1545.     @curly_argument = 0
  1546.     @code_argument = 0
  1547.     # Set up
  1548.     @line_space = 0
  1549.     @last_word = 0
  1550.     @break_loop = false
  1551.     @last_space_counted = false
  1552.     @force_break = false
  1553.     i = 0
  1554.     while !@break_loop
  1555.       if i >= @string.size
  1556.         if @l_draw_count != 0
  1557.           @l_draw_count += 1
  1558.           @line_width += @bitmap.text_size (" ").width
  1559.         end
  1560.         @l_draw_count += @w_draw_count
  1561.         @line_width += @word_length
  1562.         next_line (i)
  1563.       else
  1564.         format_character (i)
  1565.         i += 1
  1566.       end
  1567.     end
  1568.     return @line_space, @l_draw_count, @justify
  1569.   end
  1570.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1571.   # * Format Character
  1572.   #    i : index of character to format, or the character
  1573.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1574.   def format_character (i)
  1575.     character = @string[i, 1]
  1576.     if @curly_argument > 0
  1577.       @curly_argument -= 1 if character == "}"
  1578.     elsif @code_argument > 0
  1579.       @code_argument -= 1 if character == ">"
  1580.     elsif @curly_args_codes.include? (character)
  1581.       extract_curly_args_code (character, i)
  1582.     elsif @args_codes.include? (character)
  1583.       extract_args_code (character, i)
  1584.     elsif @no_args_codes.include? (character)
  1585.       extract_no_args_code (character, i)
  1586.     elsif character == " "
  1587.       next_word (i)
  1588.       return if @break_loop
  1589.       @line_width += @bitmap.text_size (" ").width
  1590.       @l_draw_count += 1
  1591.       @last_space_counted = true
  1592.     else # Regular Character
  1593.       @word_length += @bitmap.text_size(character).width
  1594.       @w_draw_count += 1
  1595.       if i == @string.size - 1 && @line_width + @word_length > @max_width
  1596.         next_line (@last_word)
  1597.       end
  1598.     end
  1599.   end
  1600.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1601.   # * Next Word
  1602.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1603.   def next_word (i)
  1604.     if @line_width + @word_length > @max_width
  1605.       if @line_width == 0
  1606.         @last_word = i
  1607.         @line_width = @word_length
  1608.         @l_draw_count = @w_draw_count
  1609.         @word_length = 0
  1610.         @w_draw_count = 0
  1611.       end
  1612.       next_line (@last_word)
  1613.     end
  1614.     @last_word = i
  1615.     @line_width += @word_length
  1616.     @l_draw_count += @w_draw_count
  1617.     @word_length = 0
  1618.     @w_draw_count = 0
  1619.   end
  1620.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1621.   # * Proceed to Next Line
  1622.   #    last_word : the index of the beginning of the previous word
  1623.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1624.   def next_line (last_word)
  1625.     @justify = false if last_word == @string.size
  1626.     @string[last_word, 1] = "\x00"
  1627.     if @last_space_counted
  1628.       @line_width -= @bitmap.text_size (" ").width
  1629.       @l_draw_count -= 1
  1630.     end
  1631.     # Calculates the blank space left to cover in the line
  1632.     line_blank = @max_width - @line_width
  1633.     @line_space = ( line_blank.to_f / [(@l_draw_count.to_f - 1.0), 1.0].max )
  1634.     @break_loop = true
  1635.   end
  1636.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1637.   # * Extract Curly Argument Code
  1638.   #    code : the code to extract
  1639.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1640.   def extract_curly_args_code (code, index)
  1641.     @curly_argument += 1
  1642.   end
  1643.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1644.   # * Extract Argument Code
  1645.   #    code : the code to extract
  1646.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1647.   def extract_args_code (code, index)
  1648.     case code
  1649.     when "\x0d" # Icon
  1650.       @w_draw_count += 1
  1651.       @word_length += 24
  1652.     when "\x0e" # Bold
  1653.       @bitmap.font.bold = (@string[index + 2, 1].to_i == 0)    
  1654.     when "\x0f" # Italic
  1655.       @bitmap.font.italic = (@string[index + 2, 1].to_i == 0)  
  1656.     when "\x10" # Shadow
  1657.       @bitmap.font.shadow = (@string[index + 2, 1].to_i == 0)
  1658.     when "\x13" # Font Name
  1659.       bmp = @bitmap
  1660.       bmp.font.name = bmp.font.name.to_ary if !bmp.font.name.is_a? (Array)
  1661.       @string[index, @string.size - index][/<(.*?)>/]
  1662.       bmp.font.name = ([$1.to_s] + bmp.font.name).uniq
  1663.     when "\x14" # Font Size
  1664.       @string[index, @string.size - index][/<(\d*)>/]
  1665.       @bitmap.font.size = $1.to_i
  1666.     when "\xb1" # Set Contents_X
  1667.       @string[index, @string.size - index][/<(\d*)>/]
  1668.       @word_length = $1.to_i
  1669.     end
  1670.     @code_argument += 1
  1671.   end
  1672.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1673.   # * Extract No Argument Code
  1674.   #    code : the code to extract
  1675.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1676.   def extract_no_args_code (code, index)
  1677.     if ["\x00", "\x1d"].include? (code) # New line or New Page
  1678.       if @line_width + @word_length > @max_width
  1679.         next_line (@last_word)
  1680.       else
  1681.         @line_width += @word_length
  1682.         @l_draw_count += @w_draw_count
  1683.         line_blank = @max_width - @line_width
  1684.         @line_space = ( line_blank.to_f / [(@l_draw_count.to_f - 1.0), 1.0].max )
  1685.         @break_loop = true
  1686.         @justify = false
  1687.         @force_break = true
  1688.       end
  1689.     elsif code == "\x09" # Tab
  1690.       next_word (index)
  1691.       @line_width = $game_message.justified_text ? @line_width + 32 :((@line_width / 32) + 1)*32
  1692.     end
  1693.   end
  1694. end
  1695.  
  1696. #==============================================================================
  1697. # ** Sprite MessageFace
  1698. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1699. #  This sprite displays face graphics
  1700. #==============================================================================
  1701.  
  1702. class Sprite_MessageFace < Sprite_Base
  1703.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1704.   # * Object Initialization
  1705.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1706.   def initialize (face_file, face_index, viewport = nil)
  1707.     super (viewport)
  1708.     wdth, hght = $game_message.face_width, $game_message.face_height
  1709.     face = Cache.face (face_file)
  1710.     if face_file[/^\$/] != nil # SINGLE
  1711.       wdth = face.width if wdth <= 0
  1712.       wdth = [face.width, wdth].min
  1713.       hght = face.height if hght <= 0
  1714.       hght = [face.height, hght].min
  1715.       rect = Rect.new((face.width-wdth) / 2, (face.height-hght) / 2, wdth, hght)
  1716.     else
  1717.       # Resize if face smaller than allotted size
  1718.       wdth = face.width / 4 if wdth <= 0
  1719.       wdth = [face.width / 4, wdth].min
  1720.       hght = face.height / 2 if hght <= 0
  1721.       hght = [face.height / 2, hght].min
  1722.       rect = Rect.new(0, 0, wdth, hght)
  1723.       rect.x = (face_index % 4) * wdth + ((face.width / 4) - wdth) / 2
  1724.       rect.y = (face_index / 4) * hght + ((face.height / 2) - hght) / 2
  1725.     end
  1726.     self.bitmap = Bitmap.new (rect.width, rect.height)
  1727.     self.bitmap.blt(0, 0, face, rect)
  1728.     self.mirror = $game_message.face_mirror
  1729.     self.blend_type = $game_message.face_blend_type
  1730.     self.visible = false
  1731.     self.opacity = $game_message.face_fadein ? 0 : $game_message.face_opacity
  1732.     $game_message.face_width, $game_message.face_height = rect.width, rect.height
  1733.   end
  1734. end
  1735.  
  1736. #==============================================================================
  1737. # ** Sprite SpeechTag
  1738. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1739. #  This sprite displays the tag when speaking
  1740. #==============================================================================
  1741.  
  1742. class Sprite_SpeechTag < Sprite
  1743.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1744.   # * Public Instance Variable
  1745.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1746.   attr_reader :speech_tag_index
  1747.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1748.   # * Object Initialization
  1749.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1750.   def initialize (viewport = nil, *args)
  1751.     @border_sprite = Sprite.new (viewport)
  1752.     super (viewport, *args)
  1753.     @border_sprite.z = self.z + 1
  1754.     @bitmaps = []
  1755.     reset_graphic
  1756.     self.visible = false
  1757.   end
  1758.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1759.   # * Dispose
  1760.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1761.   def dispose (*args)
  1762.     if self.bitmap
  1763.       self.bitmap.dispose
  1764.       @border_sprite.bitmap.dispose
  1765.     end
  1766.     @border_sprite.dispose
  1767.     super (*args)
  1768.   end
  1769.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1770.   # * Reset Graphic
  1771.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1772.   def reset_graphic (index = $game_message.speech_tag_index)
  1773.     return if @speech_tag_index == index
  1774.     @speech_tag_index = index
  1775.     return if index < 0
  1776.     begin
  1777.       bitmap = Cache.system ($game_message.speech_tag_graphics[index])
  1778.     rescue
  1779.       return
  1780.     end
  1781.     @bitmaps.each { |bmp| bmp.dispose unless bmp.disposed? }
  1782.     @bitmaps.clear
  1783.     dummy_bmp = Bitmap.new (bitmap.width / 2, bitmap.height / 2)
  1784.     src_rect = Rect.new (0, 0, bitmap.width / 2, bitmap.height / 2)
  1785.     for i in 0...4
  1786.       new_bmp = dummy_bmp.dup
  1787.       src_rect.x, src_rect.y = (i % 2)*new_bmp.width, (i / 2)*new_bmp.height
  1788.       new_bmp.blt (0, 0, bitmap, src_rect)
  1789.       @bitmaps.push (new_bmp)
  1790.     end
  1791.     dummy_bmp.dispose
  1792.     self.bitmap = @bitmaps[0]
  1793.     @border_sprite.bitmap = @bitmaps[1]
  1794.     self.back_opacity = $game_message.message_backopacity
  1795.     self.opacity = $game_message.message_opacity
  1796.   end
  1797.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1798.   # * Set Direction
  1799.   #    dir : 0 => Down; 2 => Up
  1800.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1801.   def set_direction (dir)
  1802.     self.bitmap = @bitmaps[dir]
  1803.     @border_sprite.bitmap = @bitmaps[dir + 1]
  1804.   end
  1805.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1806.   # * Set Back Opacity
  1807.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1808.   alias back_opacity= opacity= unless self.method_defined? (:back_opacity=) unless $@
  1809.   def opacity= (value)
  1810.     self.back_opacity = (self.opacity*(value.to_f / 255.0)).to_i
  1811.     @border_sprite.opacity = value
  1812.   end
  1813.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1814.   # * Visible
  1815.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1816.   def visible= (boolean)
  1817.     super (boolean)
  1818.     @border_sprite.visible = boolean
  1819.   end
  1820.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1821.   # * X=, Y=, Z=, Angle
  1822.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1823.   for attr in ["x", "y", "z", "angle"]
  1824.     ATS_ATTR = <<_END_
  1825.       def #{attr}= (*args)
  1826.         old_val = self.#{attr}
  1827.         super (*args)
  1828.         diff = self.#{attr} - old_val
  1829.         @border_sprite.#{attr} += diff
  1830.       end
  1831. _END_
  1832.     eval (ATS_ATTR)
  1833.   end
  1834. end
  1835.  
  1836. #==============================================================================
  1837. # *** Window_MessageBase
  1838. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1839. #  This module holds methods shared by all ATS windows
  1840. #==============================================================================
  1841.  
  1842. module Window_MessageBase
  1843.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1844.   # * Message Draw Icon
  1845.   #    allows for different opacities
  1846.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1847.   def message_draw_icon (icon_index, x, y, o = $game_message.message_fontalpha)
  1848.     bitmap = Cache.system("Iconset")
  1849.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  1850.     self.contents.blt(x, y, bitmap, rect, o)
  1851.   end
  1852.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1853.   # * Text Color
  1854.   #    n : either a windowskin palette or the array
  1855.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1856.   def text_color (n)
  1857.     if n.is_a? (Array)
  1858.       return Color.new (*n)
  1859.     else
  1860.       return super (n)
  1861.     end
  1862.   end
  1863.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1864.   # * Set Alignment
  1865.   #    align : The alignment ( 1 => Centre, 2 => Right )
  1866.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1867.   def set_alignment (align = 1)
  1868.     # Get rest of line
  1869.     formatter = P_Formatter_ATS.new (self.contents.font.dup)
  1870.     ls, lc, j = formatter.format_by_line (@text.dup, @contents_width - @contents_x)
  1871.     formatter.dispose
  1872.     es = ls * (lc - 1)
  1873.     @contents_x += (es / 2)*align
  1874.   end
  1875.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1876.   # * Draw Message Character
  1877.   #    c : the character to be drawn
  1878.   #``````````````````````````````````````````````````````````````````````````
  1879.   #  This method utilizes the codes shared between the MessageBox, WordBox,
  1880.   # and ChoiceBox
  1881.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1882.   def draw_message_character (c, bmp = self.contents)
  1883.     @text = "" if @text.nil?
  1884.     case c
  1885.     when "\x01"                       # \C[n] (text character color change)
  1886.       @text.sub! (/<(#?)(.+?)>/i, "")
  1887.       if $1 == ""
  1888.         bmp.font.color = text_color($2.to_i)
  1889.         if $game_message.message_fontalpha != 255
  1890.           bmp.font.color.alpha = $game_message.message_fontalpha
  1891.         end
  1892.       else
  1893.         a = $2.to_s.scan (/../)
  1894.         bmp.font.color = text_color ([a[0].to_i (16), a[1].to_i (16), a[2].to_i (16), $game_message.message_fontalpha])
  1895.       end
  1896.     when "\x09"                       # Tab
  1897.       x = @line_x + (((@contents_x - @line_x).to_i / 32) + 1)*32
  1898.       highlight_underline (x - @contents_x)
  1899.       @contents_x = x
  1900.     when "\xb1"                        # Set Contents X
  1901.       @text.sub! (/<(\d*)>/, "")
  1902.       @contents_x = $1.to_i
  1903.       return false if self.is_a? (Window_Message)
  1904.     when "\x0d"                       # Icon
  1905.       @text.sub!(/<(\d*)>/, "")
  1906.       highlight_underline (24)
  1907.       message_draw_icon ($1.to_i, @contents_x, @contents_y)
  1908.       @contents_x += 24
  1909.       @contents_x += @ls if self.is_a? (Window_Message)
  1910.     when "\x0e"                       # Bold
  1911.       @text.sub!(/<([01])>/, "")
  1912.       bmp.font.bold = (Game_ATS::ATS_2 && $1.to_i == 0) ? !bmp.font.bold : $1.to_i == 0
  1913.     when "\x0f"                       # Italics
  1914.       @text.sub!(/<([01])>/, "")
  1915.       bmp.font.italic = (Game_ATS::ATS_2 && $1.to_i == 0) ? !bmp.font.italic : $1.to_i == 0
  1916.     when "\x10"                       # Shadow
  1917.       @text.sub!(/<([01])>/, "")
  1918.       bmp.font.shadow = (Game_ATS::ATS_2 && $1.to_i == 0) ? !bmp.font.shadow : $1.to_i == 0
  1919.     when "\x11"                        # Underline
  1920.       @text.sub!(/<([01])>/, "")
  1921.       @underline = (Game_ATS::ATS_2 && $1.to_i == 0) ? !@underline : $1.to_i == 0
  1922.     when "\x12"                        # Highlight
  1923.       @text.sub! (/<(-?\d+)>/, "")
  1924.       @highlight = $1.to_i
  1925.     when "\x13"                       # Font Name
  1926.       bmp.font.name = bmp.font.name.to_ary if !bmp.font.name.is_a? (Array)
  1927.       @text.sub!(/<(.*?)>/, "")
  1928.       bmp.font.name = ([$1.to_s] + bmp.font.name).uniq
  1929.     when "\x14"                       # Font Size
  1930.       @text.sub!(/<(\d*)>/, "")
  1931.       bmp.font.size = $1.to_i
  1932.     when "\x15"                       # Font Alpha
  1933.       @text.sub! (/<(\d*)>/, "")
  1934.       $game_message.message_fontalpha = $1.to_i
  1935.       bmp.font.color.alpha = $game_message.message_fontalpha
  1936.     when "\x18"                       # Alignment
  1937.       @text.sub! (/<([012])>/, "")
  1938.       return true if @align == $1.to_i
  1939.       @align = $1.to_i
  1940.       set_alignment (@align)
  1941.     else
  1942.       return false    
  1943.     end
  1944.     return true
  1945.   end
  1946.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1947.   # * Draw Regular Character
  1948.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1949.   def draw_regular_character (c, bmp = self.contents)
  1950.     c_width = bmp.text_size(c).width
  1951.     c_width += @ls if !@ls.nil?
  1952.     highlight_underline (c_width)
  1953.     bmp.draw_text(@contents_x, @contents_y, c_width + 4, @wlh, c)
  1954.     @contents_x += c_width
  1955.   end
  1956.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1957.   # * Highlight and Underline section
  1958.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1959.   def highlight_underline (c_width)
  1960.     # Highlight
  1961.     if @highlight >=0
  1962.       hl_rect = Rect.new (@contents_x, @contents_y + 1, c_width, @wlh - 2)
  1963.       colour = text_color (@highlight)
  1964.       colour.alpha = 128 if colour.alpha > 128
  1965.       contents.fill_rect (hl_rect, colour)
  1966.     end
  1967.     # Underline
  1968.     if @underline
  1969.       y = @contents_y + contents.font.size + (@wlh - contents.font.size) / 2
  1970.       contents.fill_rect (@contents_x, y, c_width, 2, contents.font.color)
  1971.     end
  1972.   end
  1973.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1974.   # * Create Background Sprite
  1975.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1976.   def create_back_sprite (dim, use_dim)
  1977.     @back_sprite.viewport = self.viewport
  1978.     bmp = Cache.system(dim)
  1979.     @back_sprite.bitmap = Bitmap.new (self.width, self.height)
  1980.     @back_sprite.bitmap.stretch_blt (@back_sprite.bitmap.rect, bmp, bmp.rect)
  1981.     if use_dim.is_a? (Integer)
  1982.       @back_sprite.visible = use_dim == 0 ? false : use_dim == 1 ? true : $game_message.background == 1
  1983.     else
  1984.       @back_sprite.visible = use_dim
  1985.     end
  1986.     @back_sprite.x = self.x
  1987.     @back_sprite.y = self.y
  1988.     @back_sprite.z = self.z - 10
  1989.     self.opacity = 0 if @back_sprite.visible
  1990.   end
  1991.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1992.   # * X, Y, Z
  1993.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1994.   for attr in ["x", "y", "z"]
  1995.     ATS_NAMATTR = <<__END__
  1996.       def #{attr}= (*args)
  1997.         old_val = self.#{attr}
  1998.         super (*args)
  1999.         diff = self.#{attr} - old_val
  2000.         @back_sprite.#{attr} += diff
  2001.       end
  2002. __END__
  2003.     eval (ATS_NAMATTR)
  2004.   end
  2005.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2006.   # * Get Top Row
  2007.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2008.   def top_row
  2009.     return super if !@wlh
  2010.     return self.oy / @wlh
  2011.   end
  2012.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2013.   # * Set Top Row
  2014.   #     row : row shown on top
  2015.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2016.   def top_row=(row)
  2017.     if !@wlh
  2018.       super (row)
  2019.     else
  2020.       row = 0 if row < 0
  2021.       self.oy = row * @wlh
  2022.     end
  2023.   end
  2024.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2025.   # * Get Number of Rows Displayable on 1 Page
  2026.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2027.   def page_row_max
  2028.     return super if !@wlh
  2029.     return (self.height - 32) / @wlh
  2030.   end
  2031. end
  2032.  
  2033. #==============================================================================
  2034. # ** Window_WordBox
  2035. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2036. #  This window will show a single line of text
  2037. #==============================================================================
  2038.  
  2039. class Window_WordBox < Window_Base
  2040.   include Window_MessageBase
  2041.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2042.   # * Object Initialization
  2043.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2044.   def initialize (viewport, word, x = 0, y = 0, width = -1, height = 56, name = false)
  2045.     @back_sprite = Sprite.new (viewport)
  2046.     @text = $game_message.convert_special_characters (word)
  2047.     @wlh = name ? $game_message.name_wlh : $game_message.word_wlh
  2048.     @wlh = $game_message.wlh if @wlh < 0
  2049.     height = 32 + (((word.scan (/\x00/).size) + 1)*@wlh) if height == -1
  2050.     @underline = false
  2051.     @highlight = -1
  2052.     # Get Text Size
  2053.     dummy_formatter = P_Formatter_ATS.new
  2054.     lines = (@text + "\x00").scan (/.+?\x00/)
  2055.     tw = 32
  2056.     for line in lines
  2057.       ls, lc, j = dummy_formatter.format_by_line (line, 5000)
  2058.       tw1 = 5000 - (ls * (lc - 1))
  2059.       tw = tw1 if tw1 > tw
  2060.     end
  2061.     dummy_formatter.dispose
  2062.     if width < 0
  2063.       width = [(name ? tw + ($game_message.name_border_size*2) + 4 : tw + 36), 33].max
  2064.     end
  2065.     super (x, y, width, height)
  2066.     self.viewport = viewport
  2067.     self.openness = 0
  2068.     self.z = 300
  2069.     set_stats
  2070.     @contents_x, @line_x = 0, 0
  2071.     @contents_y = 0
  2072.     @contents_width = contents.width
  2073.     @align = 0
  2074.   end
  2075.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2076.   # * Set Stats
  2077.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2078.   def set_stats
  2079.     self.windowskin = Cache.system ($game_message.word_windowskin)
  2080.     self.opacity = $game_message.word_opacity
  2081.     self.back_opacity = $game_message.word_backopacity
  2082.     create_back_sprite ($game_message.word_dim, $game_message.word_use_dim)
  2083.     self.contents.font.name = $game_message.word_fontname
  2084.     self.contents.font.size = $game_message.word_fontsize
  2085.     self.contents.font.color = text_color ($game_message.word_fontcolour)
  2086.   end
  2087.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2088.   # * Dispose
  2089.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2090.   def dispose (*args)
  2091.     @back_sprite.bitmap.dispose
  2092.     @back_sprite.dispose
  2093.     super (*args)
  2094.   end
  2095.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2096.   # * Draw Word
  2097.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2098.   def draw_word (text = @text, bmp = self.contents)
  2099.     @text = text.dup
  2100.     loop do
  2101.       c = @text.slice!(/./m)            # Get next text character
  2102.       # Stop when text finished
  2103.       break if c.nil?    
  2104.       if !draw_message_character (c, bmp)
  2105.         if c == "\x00"
  2106.           @contents_y += @wlh
  2107.           @contents_x, @line_x = 0, 0
  2108.           set_alignment (@align)
  2109.         else
  2110.           draw_regular_character (c, bmp)
  2111.         end
  2112.       end
  2113.     end
  2114.   end
  2115. end
  2116.  
  2117. #==============================================================================
  2118. # ** Window_NameBox
  2119. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2120. #  This window shows the name
  2121. #==============================================================================
  2122.  
  2123. class Window_NameBox < Window_WordBox
  2124.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2125.   # * Object Initialization
  2126.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2127.   def initialize (name, viewport = nil)
  2128.     @word_sprite = Sprite_Base.new (viewport)
  2129.     wlh = $game_message.name_wlh > 0 ? $game_message.name_wlh : $game_message.wlh
  2130.     rows = (name.scan (/\x00/).size) + 1
  2131.     hght = [($game_message.name_border_size*2) + rows*wlh, 33].max
  2132.     super (viewport, name, 0, 0, -1, hght, true)
  2133.     self.viewport = viewport
  2134.     @word_sprite.x, @word_sprite.y = $game_message.name_border_size, $game_message.name_border_size
  2135.     @word_sprite.bitmap = Bitmap.new (self.width - (2*$game_message.name_border_size), self.height - (2*$game_message.name_border_size))
  2136.     @word_sprite.bitmap.font.name = $game_message.name_fontname
  2137.     @word_sprite.bitmap.font.size = $game_message.name_fontsize
  2138.     @word_sprite.bitmap.font.color = text_color ($game_message.name_fontcolour)
  2139.     @contents_x, @line_x = 2, 2
  2140.     draw_word (name, @word_sprite.bitmap)
  2141.   end
  2142.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2143.   # * Set Stats
  2144.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2145.   def set_stats
  2146.     self.opacity = $game_message.name_opacity
  2147.     self.back_opacity = $game_message.name_backopacity
  2148.     create_back_sprite ($game_message.name_dim, $game_message.name_use_dim)
  2149.     self.windowskin = Cache.system ($game_message.name_windowskin)
  2150.   end
  2151.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2152.   # * Dispose
  2153.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2154.   def dispose (*args)
  2155.     super (*args)
  2156.     @word_sprite.bitmap.dispose
  2157.     @word_sprite.dispose
  2158.   end
  2159.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2160.   # * X, Y, Z
  2161.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2162.   for attr in ["x", "y", "z"]
  2163.     ATS_NAMATTR = <<__END__
  2164.       def #{attr}= (*args)
  2165.         old_val = self.#{attr}
  2166.         super (*args)
  2167.         diff = self.#{attr} - old_val
  2168.         @word_sprite.#{attr} += diff
  2169.       end
  2170. __END__
  2171.     eval (ATS_NAMATTR)
  2172.   end
  2173. end
  2174.  
  2175. #==============================================================================
  2176. # ** Window_FaceBox
  2177. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2178. #  This window processes faces
  2179. #==============================================================================
  2180.  
  2181. class Window_FaceBox < Window_Base
  2182.   include Window_MessageBase
  2183.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2184.   # * Public Instance Variables
  2185.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2186.   attr_reader   :busy
  2187.   attr_reader   :face_sprites
  2188.   attr_accessor :scroll_x
  2189.   attr_accessor :scroll_y
  2190.   attr_accessor :scroll_x_speed
  2191.   attr_accessor :scroll_y_speed
  2192.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2193.   # * Object Initialization
  2194.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2195.   def initialize (viewport)
  2196.     @back_sprite = Sprite.new (viewport)
  2197.     @face_sprites = []
  2198.     @animate_face_count = 0
  2199.     @fade_count = 0
  2200.     @active_face = 0
  2201.     @busy = false
  2202.     @scroll_x = 0
  2203.     @scroll_y = 0
  2204.     @scroll_x_speed = 8
  2205.     @scroll_y_speed = 8
  2206.     super (0, 0, 128, 128)
  2207.     self.viewport = viewport
  2208.     self.visible = false
  2209.   end
  2210.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2211.   # * Remake Window
  2212.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2213.   def remake_window (width = $game_message.face_width, height = $game_message.face_height)
  2214.     self.width = [width + 2*$game_message.face_border_size, 33].max
  2215.     self.height = [height + 2*$game_message.face_border_size, 33].max
  2216.     create_contents
  2217.     self.windowskin = Cache.system ($game_message.face_windowskin)
  2218.     if $game_message.face_fadein
  2219.       self.back_opacity = 0
  2220.       @fade_count = $game_message.face_opacity
  2221.     else
  2222.       self.back_opacity = $game_message.face_opacity
  2223.     end
  2224.     create_back_sprite ($game_message.face_dim, $game_message.face_use_dim)
  2225.     self.visible = $game_message.face_window
  2226.   end
  2227.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2228.   # * Dispose
  2229.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2230.   def dispose (*args)
  2231.     super (*args)
  2232.     clear
  2233.   end
  2234.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2235.   # * Clear
  2236.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2237.   def clear
  2238.     @face_sprites.each { |face| face.dispose } # Dispose all faces
  2239.     @face_sprites.clear
  2240.     return if self.disposed?
  2241.     self.visible = false
  2242.     @busy = false
  2243.   end
  2244.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2245.   # * Update
  2246.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2247.   def update
  2248.     if !@face_sprites.empty? && @face_sprites[@active_face].visible
  2249.       # Update Fade In
  2250.       if @fade_count > 0
  2251.         speed = [$game_message.face_fade_speed, @fade_count].min
  2252.         @fade_count -= speed
  2253.         self.back_opacity += speed
  2254.         @face_sprites.each { |sprite| sprite.opacity += speed }
  2255.       end
  2256.       # Update Horizontal Scroll
  2257.       if @scroll_x != 0
  2258.         speed = @scroll_x > 0 ? [@scroll_x_speed, @scroll_x].min : [-1*@scroll_x_speed, @scroll_x].max
  2259.         self.x += speed
  2260.         @scroll_x -= speed
  2261.       end
  2262.       # Update Verticaltal Scroll
  2263.       if @scroll_y != 0
  2264.         speed = @scroll_y > 0 ? [@scroll_y_speed, @scroll_y].min : [-1*@scroll_y_speed, @scroll_y].max
  2265.         self.y += speed
  2266.         @scroll_y -= speed
  2267.       end
  2268.     end
  2269.   end
  2270.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2271.   # * Animate Face
  2272.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2273.   def animate_face
  2274.     if @face_sprites.size > 1
  2275.       @face_sprites[@active_face].visible = false
  2276.       @animate_face_count = (@animate_face_count + 1) % $game_message.letters_per_face
  2277.       @active_face = (@active_face + 1) % @face_sprites.size if @animate_face_count == 0
  2278.       @face_sprites[@active_face].visible = true
  2279.     end
  2280.   end
  2281.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2282.   # * Pause Animation
  2283.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2284.   def pause
  2285.     return if @face_sprites.size < 2
  2286.     @face_sprites[@active_face].visible = false
  2287.     @active_face = 0
  2288.     @face_sprites[0].visible = true
  2289.   end
  2290.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2291.   # * Set Face
  2292.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2293.   def set_face (face_file, index = 0)
  2294.     clear
  2295.     name = face_file.dup
  2296.     loop do
  2297.       # Make face and store in @face_sprites unless invalied
  2298.       face = Sprite_MessageFace.new (name, index, self.viewport) rescue break
  2299.       @face_sprites.push (face)
  2300.       break unless $game_message.animate_faces
  2301.       # If face_file has a number appended, add all of it's animations
  2302.       if name[/\_(\d+)$/i] != nil  
  2303.         name.sub! (/(\d+)$/) { ($1.to_i + 1).to_s }
  2304.       elsif name[/^\!\[(\d+)\]./] != nil # If name has exclamation code
  2305.         # Take all animations from the same face file
  2306.         index += 1
  2307.         break if index == $1.to_i
  2308.       else
  2309.         break
  2310.       end
  2311.     end
  2312.     @active_face = 0
  2313.     @face_sprites[@active_face].visible = true if @face_sprites[@active_face]
  2314.     @busy = true
  2315.     remake_window
  2316.   end
  2317.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2318.   # * Goal X; Goal Y : accomodate for scrolling
  2319.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2320.   def goal_x
  2321.     return self.x + @scroll_x
  2322.   end
  2323.   def goal_y
  2324.     return self.y + @scroll_y
  2325.   end
  2326.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2327.   # * X=; Y=; Z=
  2328.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2329.   def x= (value)
  2330.     super (value)
  2331.     @face_sprites.each { |sprite| sprite.x = self.x + $game_message.face_border_size}
  2332.   end
  2333.   def y= (value)
  2334.     super (value)
  2335.     @face_sprites.each { |sprite| sprite.y = self.y + $game_message.face_border_size}
  2336.   end
  2337.   def z= (value)
  2338.     super (value)
  2339.     @face_sprites.each { |sprite| sprite.z = self.z }
  2340.   end
  2341. end
  2342.  
  2343. #==============================================================================
  2344. # ** Window_ChoiceBox
  2345. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2346. #  This makes a separate window for handling choices, if desired.
  2347. #==============================================================================
  2348.  
  2349. class Window_ChoiceBox < Window_Selectable
  2350.   include Window_MessageBase
  2351.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2352.   # * Object Initialization
  2353.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2354.   def initialize (viewport = nil)
  2355.     font = Font.new ($game_message.choice_fontname, $game_message.choice_fontsize)
  2356.     @wlh = $game_message.choice_wlh > 0 ? $game_message.choice_wlh : $game_message.wlh
  2357.     width, height, line_num = prepare_choices (font.dup)
  2358.     @back_sprite = Sprite.new (viewport)
  2359.     super (0, 0, width, height)
  2360.     if line_num*@wlh > (height - 32)
  2361.       self.contents.dispose
  2362.       self.contents = Bitmap.new (width - 32, line_num*@wlh)
  2363.     end
  2364.     self.viewport = viewport
  2365.     self.windowskin = Cache.system ($game_message.choice_windowskin)
  2366.     self.opacity = $game_message.choice_opacity
  2367.     self.back_opacity = $game_message.choice_backopacity
  2368.     self.openness = 0
  2369.     self.contents.font = font
  2370.     self.contents.font.color = text_color ($game_message.choice_fontcolour)
  2371.     create_back_sprite ($game_message.choice_dim, $game_message.choice_use_dim)
  2372.     @spacing = $game_message.choice_spacing
  2373.     @column_max = $game_message.column_max
  2374.     @item_max = $game_message.choices.size
  2375.     @underline = false
  2376.     @highlight = -1
  2377.     @last_index = -1
  2378.     refresh
  2379.   end
  2380.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2381.   # * Prepare Choices
  2382.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2383.   def prepare_choices (font)
  2384.     max_width = ($game_message.choice_width > 32 ? $game_message.choice_width : Graphics.width) - 32
  2385.     max_width = (max_width - ($game_message.choice_spacing*($game_message.column_max - 1))) / $game_message.column_max
  2386.     longest_line = 1
  2387.     line_num = 0
  2388.     formatter = P_Formatter_ATS.new (font)
  2389.     @group_sizes = []
  2390.     @choices = []
  2391.     group_size = 1
  2392.     $game_message.choices.each_index { |i|
  2393.       lines = []
  2394.       line_sizes = []
  2395.       if i % $game_message.column_max == 0
  2396.         if i != 0
  2397.           line_num += group_size
  2398.           @group_sizes.push (group_size)
  2399.         end
  2400.         group_size = 1
  2401.       end
  2402.       string = $game_message.choices[i].dup
  2403.       while !string.empty?
  2404.         ls, lc, j = formatter.format_by_line (string, max_width)
  2405.         length = max_width - (ls*(lc - 1))
  2406.         string.sub! (/(.*?)\x00/) { "" }
  2407.         lines.push ($1.to_s)
  2408.         line_sizes.push (length)
  2409.         longest_line = [length, longest_line].max
  2410.       end
  2411.       group_size = [group_size, lines.size].max
  2412.       @choices.push ([lines, line_sizes])
  2413.     }
  2414.     line_num += group_size
  2415.     @group_sizes.push (group_size)
  2416.     if $game_message.choice_width > 32
  2417.       width = $game_message.choice_width
  2418.       @line_size = max_width
  2419.     else
  2420.       width = 36 + ((longest_line + $game_message.choice_spacing)*$game_message.column_max) - $game_message.choice_spacing
  2421.       @line_size = longest_line
  2422.     end
  2423.     height = $game_message.choice_height > 32 ? $game_message.choice_height : 32 + (@wlh*[line_num, $game_message.row_max].min)
  2424.     return width, height, line_num
  2425.   end
  2426.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2427.   # * Refresh
  2428.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2429.   def refresh
  2430.     @choices.each_index { |i|
  2431.       @align = 0
  2432.       rect = item_rect (i)
  2433.       start_x = rect.x
  2434.       @contents_y = rect.y
  2435.       for j in 0...@choices[i][0].size
  2436.         @text = @choices[i][0][j].dup
  2437.         length = @choices[i][1][j]
  2438.         @contents_x, @line_x = start_x, start_x
  2439.         @contents_width = start_x + @line_size
  2440.         set_alignment (@align)
  2441.         while !@text.empty?
  2442.           c = @text.slice! (/./m)
  2443.           draw_regular_character (c) if !draw_message_character (c)
  2444.         end
  2445.         @contents_y += @wlh
  2446.       end
  2447.     }
  2448.   end
  2449.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2450.   # * Item Rect
  2451.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2452.   def item_rect(index)
  2453.     rect = super (index)
  2454.     rect.y = 0
  2455.     for j in 0...(index / $game_message.column_max)
  2456.       rect.y += @group_sizes[j]
  2457.     end
  2458.     rect.y *= @wlh
  2459.     rect.height = @group_sizes[index / $game_message.column_max]*@wlh
  2460.     return rect
  2461.   end
  2462.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2463.   # * Update Cursor
  2464.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2465.   def update_cursor
  2466.     if @index < 0                   # If the cursor position is less than 0
  2467.       self.cursor_rect.empty        # Empty cursor
  2468.     else                            # If the cursor position is 0 or more
  2469.       @help_window.set_text (@index) if @help_window
  2470.       return if @index == @last_index
  2471.       if $game_message.skip_choices.include? (@index)
  2472.         mod = @index - @last_index
  2473.         @index = (@index + mod) % $game_message.choice_max
  2474.         return
  2475.       end
  2476.       rect = item_rect(@index)      # Get rectangle of selected item
  2477.       row = rect.y / @wlh           # Get current row
  2478.       # Scroll up if before the currently displayed
  2479.       self.top_row = row if row < top_row
  2480.       # Scroll down if after the currently displayed
  2481.       row += (rect.height / @wlh) - 1
  2482.       self.bottom_row = row if row > bottom_row
  2483.       rect.y -= self.oy             # Match rectangle to scroll position
  2484.       self.cursor_rect = rect       # Refresh cursor rectangle
  2485.       @last_index = @index
  2486.     end
  2487.   end
  2488. end
  2489.  
  2490. #==============================================================================
  2491. # ** Window ChoiceHelp
  2492. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2493. #  This window shows help text when hovering over choices
  2494. #==============================================================================
  2495.  
  2496. class Window_ChoiceHelp < Window_Base
  2497.   include Window_MessageBase
  2498.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2499.   # * Object Initialization
  2500.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2501.   def initialize (choice_helps)
  2502.     @back_sprite = Sprite.new
  2503.     @choice_helps = []
  2504.     @underline = false
  2505.     @highlight = -1
  2506.     font = Font.new ($game_message.choicehelp_fontname, $game_message.choicehelp_fontsize)
  2507.     p_formatter = P_Formatter_ATS.new (font)
  2508.     longest_line = 1
  2509.     x, y = $game_message.choicehelp_x, $game_message.choicehelp_y
  2510.     width, height = $game_message.choicehelp_width, $game_message.choicehelp_height
  2511.     @wlh = $game_message.choicehelp_wlh < 0 ? $game_message.wlh : $game_message.choicehelp_wlh
  2512.     wdth = width > 0 ? width - 32 : 5000
  2513.     tallest = 1
  2514.     choice_helps.each { |string|
  2515.       s_d = $game_message.convert_special_characters (string.dup)
  2516.       s_d.gsub! (/\x16/) { "\x00" }
  2517.       lines = []
  2518.       line_lengths = []
  2519.       while !s_d.empty?
  2520.         ls, lc, j = p_formatter.format_by_line (s_d, wdth)
  2521.         line_lengths.push (wdth - (ls * (lc - 1)))
  2522.         lines.push (s_d.slice! (/.*?\x00/))
  2523.       end
  2524.       tallest = [tallest, lines.size].max
  2525.       @choice_helps.push ([lines, line_lengths])
  2526.     }
  2527.     p_formatter.dispose
  2528.     width = line_lengths.max + 32 if width < 0
  2529.     x = x >= 0 ? x : [(Graphics.width - width) / 2, 0].max
  2530.     y = $game_message.choicehelp_y < 0 ? 0 : $game_message.choicehelp_y
  2531.     width = [33, [width, Graphics.width - x].min].max
  2532.     height = height < 0 ? 32 + (tallest*@wlh) : [height, 33].max
  2533.     super (x, y, width, height)
  2534.     @contents_width = contents.width
  2535.     self.windowskin = Cache.system ($game_message.choicehelp_windowskin)
  2536.     self.opacity = $game_message.choicehelp_opacity
  2537.     self.back_opacity = $game_message.choicehelp_backopacity
  2538.     self.openness = 0
  2539.     create_back_sprite ($game_message.choicehelp_dim, $game_message.choicehelp_use_dim)
  2540.     self.contents.font = Font.new ($game_message.choicehelp_fontname, $game_message.choicehelp_fontsize)
  2541.     self.contents.font.color = text_color ($game_message.choicehelp_fontcolour)
  2542.     @index = -1
  2543.   end
  2544.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2545.   # * Set Text
  2546.   #    index : the index of the choice being highlighted
  2547.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2548.   def set_text (index)
  2549.     if index != @index
  2550.       return if self.disposed?
  2551.       contents.clear
  2552.       @index = index
  2553.       lines = @choice_helps[index][0]
  2554.       lengths = @choice_helps[index][1]
  2555.       @contents_y = $game_message.choicehelp_center ? (contents.height - (lines.size*@wlh)) / 2 : 0
  2556.       @align = 0
  2557.       lines.each_index { |i|
  2558.         @text = lines[i].dup
  2559.         @contents_x, @line_x = 0, 0
  2560.         set_alignment (@align)
  2561.         while !@text.empty? # Stop when text finished
  2562.           c = @text.slice!(/./m)            # Get next text character
  2563.           draw_regular_character (c) if !draw_message_character (c)
  2564.         end
  2565.         @contents_y += @wlh
  2566.       }
  2567.     end
  2568.   end
  2569. end
  2570.  
  2571. #==============================================================================
  2572. # ** Window_Gold
  2573. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2574. #  Summary of Changes:
  2575. #    Make @closing and @opening publicly accessible
  2576. #==============================================================================
  2577.  
  2578. class Window_Gold
  2579.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2580.   # * Public Instance Variables
  2581.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2582.   attr_reader :closing
  2583.   attr_reader :opening
  2584. end
  2585.  
  2586. #==============================================================================
  2587. # ** Window_Message
  2588. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2589. #  Summary of Changes:
  2590. #    overwritten methods - create_back_sprite; update_message; update_cursor;
  2591. #      convert_special_characters; reset_window; draw_face; input_pause; z=;
  2592. #      close; visible=
  2593. #    aliased methods - initialize; dispose; update; update_show_fast; new_page;
  2594. #      start_message; new_line; finish_message; start_choice; terminate_message
  2595. #      start_number_input; input_choice
  2596. #    new methods - create_namebox; create_wordbox; create_choicebox;
  2597. #      create_choicehelp; remake_window; fit_window_to_text; set_position;
  2598. #      position_to_character; do_not_obscure_characters; set_face_position;
  2599. #      set_speechtag_position; set_name_position; set_choice_position;
  2600. #      dispose_ats_windows; update_letter_se; format_line; start_scroll_message;
  2601. #      contents_width; draw_message_character; set_alignment
  2602. #==============================================================================
  2603.  
  2604. class Window_Message
  2605.   include Window_MessageBase
  2606.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2607.   # * Object Initialization
  2608.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2609.   alias modalg_ats3_win_msg_init_9id1 initialize unless $@
  2610.   def initialize (viewport = nil, *args)
  2611.     @back_sprite = Sprite.new
  2612.     modalg_ats3_win_msg_init_9id1 (*args)
  2613.     remake_window
  2614.     self.viewport = viewport ? viewport : Viewport.new (0, 0, Graphics.width, Graphics.height)
  2615.     self.viewport.z = self.z
  2616.     @face_window = Window_FaceBox.new (self.viewport)
  2617.     @speechtag_sprite = Sprite_SpeechTag.new (self.viewport)
  2618.     @longest_line = 0
  2619.     @scrolling = 0
  2620.     @review_scroll = 0
  2621.     @letter_se_count = 0
  2622.     @ls = 0
  2623.     @underline = false
  2624.     @highlight = -1
  2625.     @last_index = -1
  2626.     @align = 0
  2627.     @max_oy = 0
  2628.     @p_formatter = P_Formatter_ATS.new (self.contents.font.dup)
  2629.     @wlh = $game_message.wlh
  2630.     @anti_update = true if self.is_a? (Window_BattleMessage) # Yanfly Melody compatibility measure
  2631.   end
  2632.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2633.   # * Dispose
  2634.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2635.   alias modrna_atxts3_dsps_9th5 dispose unless $@
  2636.   def dispose (*args)
  2637.     modrna_atxts3_dsps_9th5 (*args) # Run Original Method
  2638.     dispose_ats_windows
  2639.     @face_window.dispose
  2640.     @speechtag_sprite.dispose
  2641.   end
  2642.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2643.   # * Update
  2644.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2645.   alias mdrnalg_advtxt3_upd_3xa2 update unless $@
  2646.   def update (*args)
  2647.     # Graphic Novel Support
  2648.     if $game_message.graphic_novel && !self.is_a? (Window_BattleMessage)
  2649.       if $game_message.gn_press_or_toggle # Press
  2650.         self.viewport.visible = !Input.press? ($game_message.hide_button)
  2651.       else # Toggle
  2652.         self.viewport.visible = !self.viewport.visible if Input.trigger? ($game_message.hide_button)
  2653.       end
  2654.       return if !self.viewport.visible
  2655.     end
  2656.     [@choice_window, @choicehelp_window, @word_window, @name_window].each { |window|
  2657.       window.update if window && !window.disposed? }
  2658.     mdrnalg_advtxt3_upd_3xa2 (*args)
  2659.     # If Window opening, but no text and just a choice window.
  2660.     if @opening && $game_message.choice_window && @text.empty? && !$game_message.choices.empty?
  2661.       close
  2662.       $game_message.visible = @closing
  2663.     end
  2664.   end
  2665.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2666.   # * Create Background Sprite
  2667.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2668.   def create_back_sprite
  2669.     if @back_sprite
  2670.       @back_sprite.bitmap.dispose if @back_sprite.bitmap && !@back_sprite.bitmap.disposed?
  2671.       @back_sprite.dispose if !@back_sprite.disposed?
  2672.     end
  2673.     @back_sprite = Sprite.new (self.viewport)
  2674.     bmp = Cache.system($game_message.message_dim)
  2675.     @back_sprite.bitmap = Bitmap.new (self.width, self.height + 32)
  2676.     @back_sprite.bitmap.stretch_blt (@back_sprite.bitmap.rect, bmp, bmp.rect)
  2677.     @back_sprite.visible = (@background == 1)
  2678.     @back_sprite.x = self.x
  2679.     @back_sprite.y = self.y
  2680.     @back_sprite.z = 190
  2681.   end
  2682.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2683.   # * Create Namebox
  2684.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2685.   def create_namebox (name)
  2686.     @name_window.dispose unless @name_window.nil? || @name_window.disposed?
  2687.     return if name.empty?
  2688.     @name_window = Window_NameBox.new (name, self.viewport)
  2689.     @name_window.open
  2690.     set_name_position
  2691.   end
  2692.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2693.   # * Create Wordbox
  2694.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2695.   def create_wordbox (word)
  2696.     @word_window.dispose unless @word_window.nil? || @word_window.disposed?
  2697.     return if word.empty?
  2698.     x = $game_message.word_x
  2699.     y = $game_message.word_y == -1 ? @gold_window.y : $game_message.word_y
  2700.     @word_window = Window_WordBox.new (self.viewport, word, x, y, $game_message.word_width, $game_message.word_height)
  2701.     if $game_message.word_x == -1
  2702.       if $game_message.word_y == -1 && (@gold_window.opening || (@gold_window.openness == 255 && !@gold_window.closing))
  2703.         @word_window.x = @gold_window.x - @word_window.width
  2704.         if @word_window.x < 0
  2705.           val = @gold_window.y == 0 ? @gold_window.height : -1*@word_window.height
  2706.           @word_window.y += val
  2707.           @word_window.x = (Graphics.width - @word_window.width) / 2
  2708.         end
  2709.       else
  2710.         @word_window.x = (Graphics.width - @word_window.width) / 2
  2711.       end
  2712.     end
  2713.     @word_window.draw_word
  2714.     @word_window.open
  2715.   end
  2716.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2717.   # * Create Choicebox
  2718.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2719.   def create_choicebox
  2720.     @choice_window = Window_ChoiceBox.new (self.viewport)
  2721.     @choice_window.z = self.z + 10
  2722.     @choice_window.open
  2723.     set_choice_position
  2724.     $game_message.choices.clear
  2725.   end
  2726.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2727.   # * Create ChoiceHelp Window
  2728.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2729.   def create_choicehelp
  2730.     @choicehelp_window = Window_ChoiceHelp.new ($game_message.help_choices)
  2731.     @choicehelp_window.open
  2732.     @choicehelp_window.viewport = self.viewport
  2733.     if $game_message.choicehelp_y < 0
  2734.       unless Graphics.height - @choicehelp_window.height < self.y + self.height
  2735.         @choicehelp_window.y = Graphics.height - @choicehelp_window.height
  2736.       end
  2737.     end
  2738.     @choicehelp_window.z = self.z + 5
  2739.     @choice_window.help_window = @choicehelp_window if @choice_window
  2740.   end
  2741.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2742.   # * Remake Window
  2743.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2744.   def remake_window (width = $game_message.message_width, height = $game_message.message_height)
  2745.     return if width <= 32 || height <= 32
  2746.     self.width, self.height = width, height
  2747.     self.contents.dispose
  2748.     self.contents = Bitmap.new (width - 32, height - 32)
  2749.     create_back_sprite
  2750.   end
  2751.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2752.   # * Fit Window to Text
  2753.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2754.   def fit_window_to_text
  2755.     all_lines = $game_message.texts.dup
  2756.     all_lines += $game_message.choices.dup if !$game_message.choice_window
  2757.     return if all_lines.size < 1
  2758.     @longest_line = 0
  2759.     con_hght = [$game_message.max_lines, all_lines.size].min
  2760.     $game_message.message_height = 32 + (con_hght*@wlh)
  2761.     $game_message.max_lines = con_hght
  2762.     # Get Width of longest line
  2763.     dummy_formatter = P_Formatter_ATS.new
  2764.     all_lines.each { |line|
  2765.       c_line = $game_message.convert_special_characters (line.dup)
  2766.       ls, lc, j = dummy_formatter.format_by_line (c_line, 5000)
  2767.       @longest_line = [@longest_line, (5000 - ls * (lc - 1))].max
  2768.       if @longest_line > (Graphics.width - 32)
  2769.         @longest_line = Graphics.width - 32
  2770.         break
  2771.       end
  2772.     }
  2773.     dummy_formatter.dispose
  2774.     $game_message.message_width = 32 + @longest_line
  2775.     $game_message.choice_on_line = false if $game_message.message_width + $game_message.choice_width > Graphics.width
  2776.   end
  2777.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2778.   # * Set Position
  2779.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2780.   def set_position (x = $game_message.message_x, y = $game_message.message_y)
  2781.     if $game_message.character >= 0
  2782.       position_to_character ($game_message.character, $game_message.char_ref)
  2783.       self.x = $game_message.message_x
  2784.       self.y = $game_message.message_y
  2785.     else
  2786.       # Set the y position, either directly or by default
  2787.       if y == -1
  2788.         do_not_obscure_characters if $game_message.do_not_obscure
  2789.         self.y = ((Graphics.height - $game_message.message_height) / 2)*@position
  2790.       else
  2791.         self.y = y
  2792.       end
  2793.       if self.y < @gold_window.height
  2794.         @gold_window.y = Graphics.height - @gold_window.height
  2795.       else
  2796.         @gold_window.y = 0
  2797.       end
  2798.       # Set the x position
  2799.       if x == -1 # Centre by default
  2800.         self.x = (Graphics.width - $game_message.message_width) / 2
  2801.       else
  2802.         self.x = x
  2803.       end
  2804.     end
  2805.     set_face_position
  2806.     set_name_position
  2807.   end
  2808.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2809.   # * Position To Character
  2810.   #    character_id : the character around which the message window is to go
  2811.   #    type : Over, Below, Left or Right of character
  2812.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2813.   def position_to_character (character_id, type)
  2814.     whatever_fits = (type == 4)
  2815.     type = 0 if whatever_fits # Above if fits, else Under
  2816.     character = character_id == 0 ? $game_player : $game_map.events[character_id]
  2817.     # Do not change position if character does not exist
  2818.     return if character == nil
  2819.     # Do not change position if the character is not on screen.
  2820.     return unless character.screen_x.between? (0, Graphics.width) && character.screen_y.between? (0, Graphics.height)
  2821.     # Get the size of the character
  2822.     bmp = Cache.character (character.character_name).clone
  2823.     if character.character_name[/^.?\$/] == nil
  2824.       c_wdth, c_hght = bmp.width / 12, bmp.height / 8
  2825.     else
  2826.       c_wdth, c_hght = bmp.width / 3, bmp.height / 4
  2827.     end
  2828.     bmp.dispose
  2829.     # Centre X or Y depending on position
  2830.     if type % 2 == 0
  2831.       # Centre X
  2832.       x = [character.screen_x - (self.width / 2) , 0].max
  2833.       x = (x + self.width <= Graphics.width) ? x : Graphics.width - self.width
  2834.     else
  2835.       # Centre Y
  2836.       y = [character.screen_y - ((self.height + c_hght) / 2), 0].max
  2837.       y = (y + self.height <= Graphics.height) ? y : Graphics.height - self.height
  2838.     end
  2839.     case type
  2840.     when 0 # Over
  2841.       if whatever_fits && character.screen_y - c_hght - self.height < 0
  2842.         position_to_character (character_id, 2)
  2843.         return
  2844.       end
  2845.       y = [character.screen_y - c_hght - self.height, 0].max
  2846.     when 1 # Left
  2847.       x = [character.screen_x - (c_wdth / 2) - self.width, 0].max
  2848.     when 2 # Below
  2849.       y = [character.screen_y, Graphics.height - self.height].min
  2850.     when 3 # Right
  2851.       x = [character.screen_x + (c_wdth / 2), Graphics.width - self.width].min
  2852.     end
  2853.     $game_message.message_x = x
  2854.     $game_message.message_y = y
  2855.     if character_id >= 0 && $game_message.speech_tag_index >= 0
  2856.       set_speech_sprite_position (character.screen_x, character.screen_y, c_wdth, c_hght, type)
  2857.       position_to_character (character_id, 2) if whatever_fits && !@speechtag_sprite.visible
  2858.     end
  2859.   end
  2860.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2861.   # * Do Not Obstruct Characters
  2862.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2863.   def do_not_obscure_characters
  2864.     obscured = [0, 0, 0]
  2865.     positions = [2, 0, 1]
  2866.     positions.delete (@position)
  2867.     positions.unshift (@position)
  2868.     positions.each { |pos|
  2869.       y = ((Graphics.height - $game_message.message_height) / 2)*pos
  2870.       range = y..(y + self.height)
  2871.       $game_message.obscure_characters.each { |id|
  2872.         char = id == 0 ? $game_player : $game_map.events[id]
  2873.         next if char.nil?
  2874.         range2 = (char.screen_y - $game_message.obscure_buffer)..char.screen_y
  2875.         obscured[pos] += 1 if range === range2.first || range2 === range.first
  2876.       }
  2877.       if obscured[pos] == 0
  2878.         @position = pos
  2879.         return
  2880.       end
  2881.     }
  2882.     @position = obscured.index (obscured.min)
  2883.   end
  2884.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2885.   # * Set Speech Sprite Position
  2886.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2887.   def set_speech_sprite_position (c_x, c_y, c_w, c_h, char_ref)
  2888.     @speechtag_sprite.opacity = $game_message.message_opacity
  2889.     @speechtag_sprite.set_direction (char_ref)
  2890.     @speechtag_sprite.x = c_x - (@speechtag_sprite.width / 2)
  2891.     if char_ref == 0
  2892.       return if $game_message.message_y < @speechtag_sprite.height - 16
  2893.       @speechtag_sprite.y = c_y - c_h - @speechtag_sprite.height
  2894.       $game_message.message_y -= (@speechtag_sprite.height - 16)
  2895.       @speechtag_sprite.visible = true
  2896.     elsif char_ref == 2
  2897.       return if $game_message.message_y + (@speechtag_sprite.height - 16) > Graphics.height
  2898.       @speechtag_sprite.y = c_y
  2899.       $game_message.message_y += @speechtag_sprite.height - 16
  2900.       @speechtag_sprite.visible = true
  2901.     else
  2902.       @speechtag_sprite.visible = false
  2903.     end
  2904.   end
  2905.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2906.   # * Set Face Position
  2907.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2908.   def set_face_position (x = $game_message.face_x, y = $game_message.face_y)
  2909.     return if @face_window.nil? || @face_window.disposed?
  2910.     # Determine Goal X
  2911.     if x == -1
  2912.       if $game_message.face_side
  2913.         x = (self.x + 16 - $game_message.face_border_size) + $game_message.face_offset_x
  2914.       else
  2915.         x = (self.x + self.width - @face_window.width - 16 + $game_message.face_border_size) - $game_message.face_offset_x
  2916.       end
  2917.     end
  2918.     if y == -1
  2919.       if @face_window.height < self.height
  2920.         y = self.y + ((self.height - @face_window.height) / 2) # Centre
  2921.       else
  2922.         y = (self.y + self.height) - @face_window.height
  2923.       end
  2924.       y = self.y if y < 0 # Align to top of window if out of bounds
  2925.       y += $game_message.face_offset_y
  2926.     end
  2927.     # Set up Horizontal Scroll
  2928.     if $game_message.face_scroll_x
  2929.       left = x + @face_window.width
  2930.       right = Graphics.width - x
  2931.       if left < right
  2932.         @face_window.x = -1*@face_window.width
  2933.         @face_window.scroll_x = left
  2934.         @face_window.scroll_x_speed = left / $game_message.face_scroll_speed
  2935.       else
  2936.         @face_window.x = Graphics.width
  2937.         @face_window.scroll_x = -1*right
  2938.         @face_window.scroll_x_speed = right / $game_message.face_scroll_speed
  2939.       end
  2940.     else
  2941.       @face_window.x = x
  2942.     end
  2943.     # Set up Vertical Scroll
  2944.     if $game_message.face_scroll_y
  2945.       up = y + @face_window.height
  2946.       down = Graphics.height - y
  2947.       if up < down
  2948.         @face_window.y = -1*@face_window.height
  2949.         @face_window.scroll_y = up
  2950.         @face_window.scroll_y_speed = up / $game_message.face_scroll_speed
  2951.       else
  2952.         @face_window.y = Graphics.height
  2953.         @face_window.scroll_y = -1*down
  2954.         @face_window.scroll_y_speed = down / $game_message.face_scroll_speed
  2955.       end
  2956.     else
  2957.       @face_window.y = y
  2958.     end
  2959.     # If there is overlap and meant to fit to text_size
  2960.     if $game_message.fit_window_to_text && @longest_line > 0
  2961.       con_x, con_w = contents_width (-1)
  2962.       $game_message.message_width = @longest_line + contents.width + 32 - con_w
  2963.       remake_window
  2964.       if self.x + self.width > Graphics.width
  2965.         diff = self.x - (Graphics.width - self.width)
  2966.         self.x -= diff
  2967.         @face_window.x -= diff
  2968.       end
  2969.     end
  2970.   end
  2971.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2972.   # * Set Name Position
  2973.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2974.   def set_name_position (x = $game_message.name_x, y = $game_message.name_y)
  2975.     return if @name_window.nil? || @name_window.disposed?
  2976.     # Set NameBox coordinates
  2977.     if y == -1
  2978.       y = self.y - @name_window.height + $game_message.name_offset_y
  2979.       y = self.y + self.height - $game_message.name_offset_y if y < 0
  2980.     end
  2981.     if x == -1
  2982.       if $game_message.face_side
  2983.         x = self.x + $game_message.name_offset_x
  2984.       else
  2985.         x = self.x + self.width - @name_window.width - $game_message.name_offset_x
  2986.       end
  2987.       # If face is showing
  2988.       if @face_window.busy
  2989.       # If overlap with face
  2990.         if ((@face_window.goal_y + $game_message.face_border_size + 1).between? (y, y + @name_window.height) ||
  2991.           y.between? (@face_window.goal_y + $game_message.face_border_size + 1, @face_window.goal_y + @face_window.height)) &&
  2992.           (x.between? (@face_window.goal_x + $game_message.face_border_size, @face_window.goal_x + @face_window.width) ||
  2993.           @face_window.goal_x.between? (x, x + @name_window.width))
  2994.           if $game_message.face_side
  2995.             x = @face_window.goal_x + @face_window.width
  2996.           else
  2997.             x = @face_window.goal_x - @name_window.width
  2998.           end
  2999.         end
  3000.       end
  3001.     end
  3002.     @name_window.x = x
  3003.     @name_window.y = y
  3004.   end
  3005.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3006.   # * Set Choice Position
  3007.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3008.   def set_choice_position (x = $game_message.choice_x, y = $game_message.choice_y)
  3009.     return if @choice_window.nil? || @choice_window.disposed?
  3010.     if y == -1
  3011.       if self.openness == 0
  3012.         y = (Graphics.height - @choice_window.height) / 2
  3013.       else
  3014.         y = self.y - @choice_window.height + $game_message.choice_offset_y
  3015.         y = self.y + self.height - $game_message.choice_offset_y if y < 0
  3016.       end
  3017.     end
  3018.     if x == -1
  3019.       choice_side = $game_message.choice_opposite_face ? !$game_message.face_side : $game_message.face_side
  3020.       if self.openness == 0
  3021.         x = (Graphics.width - @choice_window.width) / 2
  3022.       elsif choice_side
  3023.         x = self.x - $game_message.choice_offset_x
  3024.       else
  3025.         x = self.x + self.width - @choice_window.width + $game_message.choice_offset_x
  3026.       end
  3027.     end
  3028.     @choice_window.x = x
  3029.     @choice_window.y = y
  3030.     @choice_window.y = self.y if $game_message.choice_on_line
  3031.   end
  3032.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3033.   # * Dispose Windows
  3034.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3035.   def dispose_ats_windows
  3036.     ats_windows = [@name_window, @word_window, @choice_window, @choicehelp_window]
  3037.     ats_windows.each { |window| window.dispose unless window.nil? || window.disposed? }
  3038.     @name_window = nil
  3039.     @word_window = nil
  3040.     @choice_window = nil
  3041.     @choicehelp_window = nil
  3042.   end
  3043.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3044.   # * Update Show Fast
  3045.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3046.   alias mrnagb_atsys3_updshfst_6yv3 update_show_fast unless $@
  3047.   def update_show_fast (*args)
  3048.     real_count = @wait_count
  3049.     @wait_count = 2 if $game_message.skip_disabled
  3050.     mrnagb_atsys3_updshfst_6yv3 (*args) # Run Original Method
  3051.     @wait_count = real_count
  3052.     @face_window.update
  3053.   end
  3054.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3055.   # * Update Message
  3056.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3057.   def update_message
  3058.     loop do
  3059.       if @scrolling > 0
  3060.         speed = [$game_message.scroll_speed, @scrolling].min
  3061.         @scrolling -= speed
  3062.         self.oy += speed
  3063.         if @scrolling <= 0 && self.contents.height < self.oy + self.height - 32
  3064.           bmp = self.contents
  3065.           # Max # of lines before cutting top out approx. 200
  3066.           if self.contents.width * (self.oy + self.height - 32) < 2500000
  3067.             self.contents = Bitmap.new (self.contents.width, self.oy + self.height - 32)
  3068.             self.contents.font = bmp.font.dup
  3069.             src_rect = bmp.rect
  3070.           else
  3071.             src_rect = Rect.new (0, @wlh, bmp.rect.width, bmp.rect.height - @wlh)
  3072.           end
  3073.           self.contents.blt (0, 0, bmp, src_rect)
  3074.           bmp.dispose if src_rect.y != 0
  3075.         end
  3076.         break
  3077.       end
  3078.       c = @text.slice!(/./m)            # Get next text character
  3079.       # If no text left
  3080.       if c.nil?
  3081.         if @choice_sizes
  3082.           @choice_sizes[-1].push (@line_count - @choice_sizes[-1][0])
  3083.         end
  3084.         if $game_message.choices.empty?
  3085.           $game_message.choice_start = @choice_sizes[0][0] if @choice_sizes
  3086.           finish_message                  # Finish update
  3087.           break
  3088.         else
  3089.           if @choice_sizes.nil?
  3090.             $game_message.scroll_by_page = false
  3091.             if $game_message.choice_window
  3092.               create_choicebox
  3093.               finish_message
  3094.               return
  3095.             end
  3096.             if !$game_message.scrolling
  3097.               if $game_message.max_lines < @line_count + $game_message.choices.size
  3098.                 self.pause = true
  3099.                 $game_message.choice_start = 0
  3100.                 @text = "\x1d"
  3101.               end
  3102.               $game_message.scrolling = true
  3103.               return
  3104.             end
  3105.             @choice_sizes = []
  3106.           end
  3107.           @text = "#{$game_message.choices.shift}\x00"
  3108.           # New line stuff
  3109.           format_line
  3110.           @choice_sizes.push ([@line_count])
  3111.           c = @text.slice!(/./m)            # Get next text character
  3112.         end
  3113.       end
  3114.       draw_message_character (c)
  3115.       break unless @show_fast || @line_show_fast || $game_message.message_speed < 0
  3116.       break if self.pause
  3117.     end
  3118.   end
  3119.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3120.   # * Update Letter SE
  3121.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3122.   def update_letter_se
  3123.     return if !$game_message.letter_sound || @show_fast || @line_show_fast ||
  3124.       $game_message.message_speed < 0
  3125.     # Randomize Pitch
  3126.     rp = $game_message.random_pitch
  3127.     $game_message.letter_se.pitch = rp.first + rand(rp.last - rp.first) unless rp.first == rp.last
  3128.     # Update Sound
  3129.     $game_message.play_se ($game_message.letter_se) if @letter_se_count == 0
  3130.     @letter_se_count = (@letter_se_count + 1) % $game_message.letters_per_se
  3131.   end
  3132.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3133.   # * Update cursor
  3134.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3135.   def update_cursor
  3136.     return if @choice_window
  3137.     if @index >= 0
  3138.       @choicehelp_window.set_text (@index) if @choicehelp_window
  3139.       return if @index == @last_index
  3140.       if $game_message.skip_choices.include? (@index)
  3141.         mod = @last_index < @index ? 1 : -1
  3142.         @index = (@index + mod) % $game_message.choice_max
  3143.         return
  3144.       end
  3145.       row = @choice_sizes[@index][0]
  3146.       hght = @choice_sizes[@index][1]*@wlh
  3147.       y = (row) * @wlh
  3148.       x, con_width = contents_width (self.contents.height > self.height - 32 ? -1 : y)
  3149.       # Scroll up if before the currently displayed
  3150.       self.top_row = row if row < top_row
  3151.       row += @choice_sizes[@index][1] - 1
  3152.       # Scroll down if after the currently displayed
  3153.       self.bottom_row = row if row > bottom_row
  3154.       self.cursor_rect.set(x, y - self.oy, con_width, hght)
  3155.       @last_index = @index
  3156.     else
  3157.       self.cursor_rect.empty
  3158.     end
  3159.   end
  3160.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3161.   # * Start Message
  3162.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3163.   alias malg_atxs3_msgstrt_8ik3 start_message unless $@
  3164.   def start_message (*args)
  3165.     @starting = true
  3166.     @wlh = $game_message.wlh
  3167.     @align = 0
  3168.     @max_oy = 0
  3169.     @line_x = 0
  3170.     @underline = $game_message.underline
  3171.     @highlight = $game_message.highlight
  3172.     malg_atxs3_msgstrt_8ik3 (*args)
  3173.     @text.gsub! (/([^\s])\s*\x00/) { "#{$1} " } if $game_message.paragraph_format
  3174.     # Remove x00 from middle of wb and nb boxes
  3175.     @text.gsub! (/[\x19\x1a]{.*?}/) { |match| match.gsub (/\x00/) { "" } }
  3176.     @text.gsub! (/\x16/) { "\x00" }
  3177.     format_line
  3178.     self.windowskin = Cache.system ($game_message.message_windowskin).dup
  3179.     self.windowskin.clear_rect (80, 16, 32, 32) unless $game_message.scroll_show_arrows
  3180.     self.contents.font.name = $game_message.message_fontname
  3181.     self.contents.font.size = $game_message.message_fontsize
  3182.     @p_formatter.bitmap.font = self.contents.font.dup
  3183.     $game_message.play_se ($game_message.start_se) if $game_message.start_sound
  3184.     @starting = false
  3185.   end
  3186.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3187.   # * New Page
  3188.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3189.   alias malba_advts3_nwpge_7uj2 new_page unless $@
  3190.   def new_page (*args)
  3191.     if !$game_message.do_not_start || !@starting
  3192.       if @text.sub! (/\A\x17<(\d+)>/, "") != nil
  3193.         actor = $game_actors[$1.to_i]
  3194.         if !actor.nil?
  3195.           $game_message.face_name = actor.face_name
  3196.           $game_message.face_index = actor.face_index
  3197.         end
  3198.       end
  3199.       @face_window.clear if !@face_window.nil? && !@face_window.disposed?
  3200.       malba_advts3_nwpge_7uj2 (*args) # Run Original Method
  3201.       self.contents.font.color = text_color ($game_message.message_fontcolour)
  3202.       self.contents.font.color.alpha = $game_message.message_fontalpha if $game_message.message_fontalpha != 255
  3203.       self.oy = 0
  3204.     elsif (@line_count - (self.oy / @wlh)) >= $game_message.max_lines
  3205.       # If scrolling
  3206.       start_scroll_message if $game_message.scrolling
  3207.     end
  3208.     @contents_x, @contents_width = contents_width
  3209.     @line_x = @contents_x
  3210.     unless @starting
  3211.       @text.sub! ("\x00", " ") if @text && $game_message.paragraph_format && !(@p_formatter && @p_formatter.force_break)
  3212.       format_line
  3213.     end
  3214.   end
  3215.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3216.   # * New Line
  3217.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3218.   alias modalg_ats3_nl_scroll_0ol2 new_line unless $@
  3219.   def new_line (*args)
  3220.     modalg_ats3_nl_scroll_0ol2 (*args)
  3221.     @contents_y = @line_count*@wlh
  3222.     @contents_x, @contents_width = contents_width (@contents_y)
  3223.     @line_x = @contents_x
  3224.     format_line
  3225.     # If Reached end of page
  3226.     if (@line_count - (self.oy / @wlh)) >= $game_message.max_lines
  3227.       # Do not pause if message is over
  3228.       return if @text == "" && ($game_message.choices.empty? || $game_message.choice_window)
  3229.       # If scrolling
  3230.       if $game_message.scrolling
  3231.         start_scroll_message
  3232.       else
  3233.         self.pause = true
  3234.       end
  3235.     end
  3236.   end
  3237.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3238.   # * Format Line
  3239.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3240.   def format_line
  3241.     if $game_message.paragraph_format
  3242.       @ls, dc, justify = @p_formatter.format_by_line (@text, @contents_width)
  3243.     else
  3244.       @ls = 0
  3245.     end
  3246.     set_alignment (@align) if @align != 0
  3247.     @ls = 0 if @ls > 0 && (!justify || @align != 0)
  3248.   end
  3249.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3250.   # * Convert Special Characters
  3251.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3252.   def convert_special_characters
  3253.     $game_message.convert_special_characters (@text)
  3254.   end
  3255.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3256.   # * Set Window Background and Position
  3257.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3258.   def reset_window
  3259.     @background = $game_message.background
  3260.     @position = $game_message.position
  3261.     $game_message.choice_on_line = false if $game_message.choice_width < 32
  3262.     fit_window_to_text if $game_message.fit_window_to_text
  3263.     if $game_message.choice_window && $game_message.choice_on_line
  3264.       $game_message.message_width = [$game_message.message_width, Graphics.width - $game_message.choice_width].min
  3265.       total_width = $game_message.message_width + $game_message.choice_width
  3266.       if $game_message.message_x == -1
  3267.         $game_message.message_x = (Graphics.width - total_width) / 2
  3268.       elsif $game_message.message_x + total_width > Graphics.width
  3269.         $game_message.message_x = Graphics.width - total_width
  3270.       end
  3271.       choice_side = $game_message.choice_opposite_face ? !$game_message.face_side : $game_message.face_side
  3272.       if choice_side
  3273.         $game_message.choice_x = $game_message.message_x
  3274.         $game_message.message_x += $game_message.choice_width
  3275.       else
  3276.         $game_message.choice_x = $game_message.message_x + $game_message.message_width
  3277.       end
  3278.       $game_message.choice_height = $game_message.message_height
  3279.     end
  3280.     remake_window unless $game_message.do_not_start
  3281.     # Set opacity
  3282.     self.opacity = @background == 0 ? $game_message.message_opacity : 0
  3283.     self.back_opacity = $game_message.message_backopacity
  3284.     # Remake speech bubble if different
  3285.     @speechtag_sprite.reset_graphic
  3286.     @speechtag_sprite.z = self.z + 1
  3287.     if @text.include? ("\x1c")
  3288.       @text = ""
  3289.       self.openness = 0 unless $game_message.do_not_refresh
  3290.     end
  3291.     set_position
  3292.   end
  3293.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3294.   # * Finish Message
  3295.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3296.   alias malbra_ats3_fnmsg_7uj2 finish_message unless $@
  3297.   def finish_message (*args)
  3298.     @face_window.pause
  3299.     $game_message.play_se ($game_message.finish_se) if $game_message.finish_sound
  3300.     malbra_ats3_fnmsg_7uj2 (*args)
  3301.   end
  3302.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3303.   # * Start Choices
  3304.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3305.   alias modrn_ats3_strtchc_5sf2 start_choice unless $@
  3306.   def start_choice (*args)
  3307.     modrn_ats3_strtchc_5sf2 (*args)
  3308.     $game_message.move_when_visible = false
  3309.     if @choice_window
  3310.       self.index = -1
  3311.       @choice_window.index = 0
  3312.     end
  3313.     create_choicehelp if !$game_message.help_choices.empty?
  3314.     @max_oy = [(@line_count - $game_message.max_lines)*@wlh, 0].max
  3315.   end
  3316.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3317.   # * Start Number Input
  3318.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3319.   alias malgr_advts3_strtnuminp_8qw2 start_number_input unless $@
  3320.   def start_number_input (*args)
  3321.     malgr_advts3_strtnuminp_8qw2 (*args) # Run Original Method
  3322.     if $game_message.scrolling
  3323.       self.oy += @wlh if @line_count >= $game_message.max_lines
  3324.       @number_input_window.y -= self.oy
  3325.     end
  3326.   end
  3327.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3328.   # * Start Scroll Message
  3329.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3330.   def start_scroll_message
  3331.     scroll_plus = @wlh
  3332.     scroll_plus *= $game_message.max_lines if $game_message.scroll_by_page
  3333.     @scrolling += scroll_plus
  3334.     @show_fast = false
  3335.     if $game_message.scroll_autopause && !@text.nil? && !@text.empty?
  3336.       self.pause = true
  3337.       $game_message.play_se ($game_message.pause_se) if $game_message.pause_sound
  3338.     end
  3339.   end
  3340.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3341.   # * End Message
  3342.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3343.   alias modal_atsv3_trmmsg_8yx4 terminate_message unless $@
  3344.   def terminate_message (*args)
  3345.     if !$game_message.do_not_refresh
  3346.       if !@face_window.nil? && !@face_window.disposed?
  3347.         if self.is_a? (Window_BattleMessage)
  3348.           @face_window.visible = false
  3349.           @face_window.clear
  3350.           create_contents if contents.height > height - 32
  3351.           self.oy = 0
  3352.         end
  3353.       end
  3354.       dispose_ats_windows
  3355.     else
  3356.       @choice_window.dispose if @choice_window && !@choice_window.disposed?
  3357.       @choicehelp_window.dispose if @choicehelp_window && !@choicehelp_window.disposed?
  3358.       @choice_window = nil
  3359.       @choicehelp_window = nil
  3360.     end
  3361.     $game_message.play_se ($game_message.terminate_se) if $game_message.terminate_sound
  3362.     modal_atsv3_trmmsg_8yx4 (*args) # Run Original Method
  3363.     @last_index = -1
  3364.     @choice_sizes = nil
  3365.     @speechtag_sprite.visible = false
  3366.   end
  3367.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3368.   # * Contents Width
  3369.   #    y : the line to check it on
  3370.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3371.   def contents_width (y = 0)
  3372.     # If can scroll, make sure no overlap over whole range. Get the ranges
  3373.     if y < 0 || ($game_message.scrolling && $game_message.texts.size > $game_message.max_lines)
  3374.       m_range = (self.y + 16)..(self.y + 16 + ($game_message.max_lines*@wlh))
  3375.     else
  3376.       screen_y = self.y + 16 + y - self.oy
  3377.       m_range = screen_y..screen_y + @wlh
  3378.     end
  3379.     return 0, contents.width if @face_window.z < self.z
  3380.     f_range = @face_window.goal_y..(@face_window.goal_y + @face_window.height)
  3381.     # If there is overlap with the face window
  3382.     if @face_window.busy && (m_range === f_range.first || f_range === m_range.first)
  3383.       left = @face_window.goal_x - (self.x + 20)
  3384.       right = self.x + self.width - 20 - (@face_window.goal_x + @face_window.width)
  3385.       if left >= right
  3386.         return 0, left
  3387.       else
  3388.         return @face_window.goal_x + @face_window.width - (self.x + 12), right
  3389.       end
  3390.     end
  3391.     return 0, contents.width # Start X, total width
  3392.   end
  3393.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3394.   # * Draw Face
  3395.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3396.   def draw_face (face_file, face_index, *args)
  3397.     @face_window.set_face (face_file, face_index)
  3398.     set_face_position
  3399.     @face_window.z = self.z + $game_message.face_z
  3400.   end
  3401.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3402.   # * Draw Message Character
  3403.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3404.   def draw_message_character (c)
  3405.     return if super (c)
  3406.     case c
  3407.     when "\x00"                       # New line
  3408.       new_line
  3409.     when "\x02"                       # \G    (gold display)
  3410.       @gold_window.refresh
  3411.       @gold_window.openness > 0 ? @gold_window.close : @gold_window.open
  3412.     when "\x03"                       # \W[x]     (Wait x frames)
  3413.       @text.sub!(/<(\d+)>/, "")
  3414.       @wait_count = $1.to_i
  3415.       @face_window.pause
  3416.       @show_fast, @line_show_fast = false, false
  3417.     when "\x04"                       # \!        (Wait for input)
  3418.       self.pause = true
  3419.       $game_message.play_se ($game_message.pause_se) if $game_message.pause_sound
  3420.       @show_fast, @line_show_fast = false, false
  3421.     when "\x05"                       # \/@  (Fast display ON)
  3422.       @text.sub!(/<([01])>/, "")
  3423.       @line_show_fast = (Game_ATS::ATS_2 && $1.to_i == 0) ? !@line_show_fast: $1.to_i == 0
  3424.     when "\x06"                       # \/@@  (Fast display OFF)
  3425.       @text.sub!(/<([01])>/, "")
  3426.       @show_fast = (Game_ATS::ATS_2 && $1.to_i == 0) ? !@show_fast : $1.to_i == 0
  3427.     when "\x07"                       # \^  (No wait for input)
  3428.       @pause_skip = true
  3429.     when "\x08"                       # Speed Change
  3430.       @text.sub!(/<(=?-?\d+)>/, "")
  3431.       s = $1.to_s
  3432.       s.sub! (/(=)/, "")
  3433.       if $1.nil?
  3434.         $game_message.message_speed = [$game_message.message_speed + s.to_i, -1].max
  3435.       else
  3436.         $game_message.message_speed = [s.to_i, -1].max
  3437.       end
  3438.     when "\x0b"                        # Show Animation
  3439.       # Extract Target and Graphic ID
  3440.       @text.sub! (/<(\d*),(\d*),([01])>/, "")
  3441.       return if self.is_a? (Window_BattleMessage)
  3442.       char = $1.to_i < 1 ? $game_player : $game_map.events[$1.to_i] # Target
  3443.       if char != nil
  3444.         $3.to_i == 0 ? char.animation_id = $2.to_i : char.balloon_id = $2.to_i
  3445.       end
  3446.     when "\x0c"                        # Position to Character
  3447.       @text.sub! (/<(\d+),([0-4])>/, "")
  3448.       return if self.is_a? (Window_BattleMessage)
  3449.       $game_message.character = $1.to_i
  3450.       $game_message.char_ref = $2.to_i
  3451.       set_position
  3452.       new_page
  3453.     when "\x17"                        # Use Actor Face
  3454.       @text.sub! (/<(\d+)>/, "")
  3455.       $game_message.face_name = $game_actors[$1.to_i].face_name
  3456.       $game_message.face_index = $game_actors[$1.to_i].face_index
  3457.       draw_face ($game_message.face_name, $game_message.face_index)
  3458.       set_name_position
  3459.     when "\x19"                       # Name Box
  3460.       @text.sub! (/{(.*?)}/, "")
  3461.       create_namebox ($1.to_s)
  3462.     when "\x1a"                       # Word Box
  3463.       @text.sub! (/{(.*?)}/, "")
  3464.       create_wordbox ($1.to_s)
  3465.     when "\x1b"                        # Play SE
  3466.       @text.sub! (/<(.+?),([MS]E)>/, "")
  3467.       $game_message.play_se ((RPG.const_get ($2.to_s)).new ($1.to_s))
  3468.     when "\x1d"                        # New Page
  3469.       create_contents
  3470.       new_page
  3471.     when "\x1f"                        # Position setting
  3472.       @text.sub! (/<([012]),(-?\d+),(-?\d+)>/, "" )
  3473.       return if self.is_a? (Window_BattleMessage)
  3474.       case $1.to_i
  3475.       when 0 then set_position ($2.to_i, $3.to_i)
  3476.       when 1 then set_face_position ($2.to_i, $3.to_i)
  3477.       when 2 then set_name_position ($2.to_i, $3.to_i)
  3478.       end
  3479.       new_page unless $1.to_i == 2
  3480.     when "\x7f"                        # Evaluate Code
  3481.       @text.sub! (/\{(.+?)#\}/, "")
  3482.       eval ($1.to_s)
  3483.     when "\xb0"                        # Enable/Disable Skipping
  3484.       @text.sub!(/<([01])>/, "")
  3485.       $game_message.skip_disabled = (Game_ATS::ATS_2 && $1.to_i == 0) ? !$game_message.skip_disabled : $1.to_i == 0
  3486.       @show_fast, @line_show_fast = false, false
  3487.     when "\xb1"                        # Set Contents X
  3488.       start_x, throwaway = contents_width (@contents_y)
  3489.       @contents_x += start_x
  3490.     else                               # Normal text character
  3491.       draw_regular_character (c)
  3492.       @wait_count += $game_message.message_speed if !@show_fast &&
  3493.         !@line_show_fast && $game_message.message_speed > 0
  3494.       update_letter_se
  3495.       @face_window.animate_face
  3496.     end
  3497.   end
  3498.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3499.   # * Set Alignment
  3500.   #    align : The alignment ( 1 => Centre, 2 => Right )
  3501.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3502.   def set_alignment (align = 1)
  3503.     # Get rest of line
  3504.     formatter = P_Formatter_ATS.new (self.contents.font.dup)
  3505.     txt = @text[/.*?\x00/]
  3506.     txt = "" if txt.nil?
  3507.     ls, lc, j = formatter.format_by_line (txt, @line_x + @contents_width - @contents_x)
  3508.     formatter.dispose
  3509.     es = ls * (lc - 1)
  3510.     @contents_x += (es / 2)*align
  3511.     @ls = 0 if align > 0
  3512.   end
  3513.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3514.   # * Input Pause
  3515.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3516.   def input_pause (*args)
  3517.     # Allow to review message before inputting
  3518.     if $game_message.scroll_review
  3519.       if @review_scroll != 0
  3520.         scroll_plus = @review_scroll > 0 ? [@review_scroll, $game_message.scroll_speed].min :
  3521.           [@review_scroll, -1*$game_message.scroll_speed].max
  3522.         self.oy += scroll_plus
  3523.         self.oy = [[self.oy, 0].max, @max_oy].min
  3524.         @review_scroll -= scroll_plus
  3525.       end
  3526.       if Input.press? (Input::UP)
  3527.         @review_scroll -= $game_message.scroll_speed
  3528.       elsif Input.press? (Input::DOWN)
  3529.         @review_scroll += $game_message.scroll_speed
  3530.       end
  3531.     end
  3532.     # Original Method
  3533.     if Input.trigger?(Input::B) or Input.trigger?(Input::C)
  3534.       self.oy = @max_oy
  3535.       self.pause = false
  3536.       if @text != nil and not @text.empty?
  3537.         new_page if !$game_message.scrolling && @line_count >= $game_message.max_lines
  3538.       else
  3539.         terminate_message
  3540.       end
  3541.     end
  3542.   end
  3543.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3544.   # * Choice Input
  3545.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3546.   alias modab_ats3_inptchc_7yh2 input_choice unless $@
  3547.   def input_choice (*args)
  3548.     if Input.trigger?(Input::C)
  3549.       indx = @choice_window ? @choice_window.index : self.index
  3550.       if $game_message.disabled_choices.include? (indx)
  3551.         Sound.play_buzzer
  3552.       else
  3553.         Sound.play_decision
  3554.         $game_message.choice_proc.call(indx)
  3555.         terminate_message
  3556.       end
  3557.       return
  3558.     end
  3559.     modab_ats3_inptchc_7yh2 (*args)
  3560.   end
  3561.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3562.   # * Pause=
  3563.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3564.   alias malabra_ats3_setpause_8uj2 pause= unless (self.method_defined? (:malabra_ats3_setpause_8uj2) || $@)
  3565.   def pause= (boolean)
  3566.     malabra_ats3_setpause_8uj2 (boolean)
  3567.     if boolean
  3568.       @max_oy = self.oy
  3569.       @face_window.pause
  3570.     end
  3571.   end
  3572.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3573.   # * Z=
  3574.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3575.   def z= (*args)
  3576.     diff = -1*self.z
  3577.     super (*args)
  3578.     diff += self.z
  3579.     ats_gfx = [@face_window, @name_window, @word_window, @speechtag_sprite,
  3580.       @back_sprite, @choice_window, @choicehelp_window]
  3581.     ats_gfx.each { |gfx| gfx.z += diff unless gfx.nil? }
  3582.   end
  3583.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3584.   # * Visible =
  3585.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3586.   def visible= (boolean)
  3587.     super (boolean)
  3588.     @face_window.clear if @face_window && !@face_window.disposed? && !boolean
  3589.   end
  3590.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3591.   # * Close
  3592.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3593.   def close (*args)
  3594.     super (*args)
  3595.     if !@face_window.nil? && !@face_window.disposed?
  3596.       @face_window.clear
  3597.       @face_window.close
  3598.     end
  3599.     @name_window.close if @name_window && !@name_window.disposed?
  3600.   end
  3601. end
  3602.  
  3603. #==============================================================================
  3604. # ** Window_BattleMessage
  3605. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  3606. #  Summary of Changes:
  3607. #    aliased method - initialize
  3608. #    overwritten method - draw_line
  3609. #==============================================================================
  3610.  
  3611. class Window_BattleMessage
  3612.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3613.   # * Object Initialization
  3614.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3615.   alias modrna_ynfl_melatscomp_5yh2 initialize unless $@
  3616.   def initialize (*args) # Yanfly Melody compatibility measure
  3617.     modrna_ynfl_melatscomp_5yh2 (*args)
  3618.     @anti_update = false
  3619.   end
  3620.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3621.   # * Draw Line
  3622.   #    index : the line to draw on
  3623.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3624.   def draw_line(index)
  3625.     return if !@text.nil?
  3626.     rect = Rect.new(0, 0, 0, 0)
  3627.     rect.x += 4
  3628.     rect.y += index * @wlh
  3629.     rect.width = contents.width - 8
  3630.     rect.height = @wlh
  3631.     self.contents.clear_rect(rect)
  3632.     self.contents.font.color = normal_color
  3633.     @wlh = $game_message.battle_wlh
  3634.     @text = @lines[index].dup
  3635.     convert_special_characters
  3636.     @contents_x = rect.x
  3637.     @contents_y = rect.y
  3638.     loop do
  3639.       c = @text.slice!(/./m)            # Get next text character
  3640.       # Stop when text finished
  3641.       break if c.nil?    
  3642.       draw_message_character (c)
  3643.     end
  3644.     @text = nil
  3645.   end
  3646. end
  3647.  
  3648. #==============================================================================
  3649. # ** Scene_Title
  3650. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  3651. #  Summary of Changes:
  3652. #      aliased method - create_game_objects
  3653. #==============================================================================
  3654.  
  3655. class Scene_Title
  3656.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3657.   # * Create Game Objects
  3658.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3659.   alias modalg_ats3_gm_obj_create create_game_objects unless $@
  3660.   def create_game_objects (*args)
  3661.     # Create the object which holds default values for message
  3662.     $game_ats = $ats_default = Game_ATS.new
  3663.     # Run original method
  3664.     modalg_ats3_gm_obj_create (*args)
  3665.   end
  3666. end
  3667.  
  3668. #==============================================================================
  3669. # ** Scene_File
  3670. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  3671. #  Summary of Changes:
  3672. #      aliased methods - write_save_data; read_save_data
  3673. #==============================================================================
  3674.  
  3675. class Scene_File
  3676.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3677.   # * Write Save Data
  3678.   #       file : the file being written to
  3679.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3680.   alias modalg_ats3_write_save write_save_data unless $@
  3681.   def write_save_data (file, *args)
  3682.     # Run Original Method
  3683.     modalg_ats3_write_save (file, *args)
  3684.     Marshal.dump($game_ats,         file)
  3685.   end
  3686.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3687.   # * Read Save Data
  3688.   #       file : the file being read from
  3689.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3690.   alias modalg_ats3_read_save_data read_save_data unless $@
  3691.   def read_save_data (file, *args)
  3692.     # Run Original Method
  3693.     modalg_ats3_read_save_data (file, *args)
  3694.     begin
  3695.       $game_ats = $ats_default = Marshal.load (file)
  3696.     rescue # Initialize if old save
  3697.       $game_ats = $ats_default = Game_ATS.new
  3698.       $game_message.clear
  3699.     end
  3700.   end
  3701. end
Advertisement
Add Comment
Please, Sign In to add comment