IceDragon200

ATS Patch

Aug 8th, 2011
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.55 KB | None | 0 0
  1. # // Script Installation Order
  2. # // ATS
  3. # // YERD Menu System Options
  4. # // This Patch
  5. module IRS
  6.  
  7.   def self.get_windowskin_name
  8.     unless $game_variables.nil?()
  9.       winvar = YE::SYSTEM::WINDOW_VARIABLE
  10.       if $game_variables[winvar] == 0
  11.         $game_variables[winvar] = YE::SYSTEM::DEFAULT_WINDOW
  12.       elsif !YE::SYSTEM::WINDOW_HASH.include?($game_variables[winvar])
  13.         $game_variables[winvar] = YE::SYSTEM::DEFAULT_WINDOW
  14.       end
  15.       mso_windowskin = YE::SYSTEM::WINDOW_HASH[$game_variables[winvar]]
  16.     else
  17.       mso_windowskin = YE::SYSTEM::WINDOW_HASH[YE::SYSTEM::DEFAULT_WINDOW]
  18.     end
  19.     return mso_windowskin
  20.   end
  21.  
  22. end
  23.  
  24. class Game_Message
  25.  
  26.   alias :ips_gmms_clear :clear unless $@
  27.   def clear( *args, &block )
  28.     ips_gmms_clear( *args, &block )
  29.     wsn = IRS.get_windowskin_name()
  30.     self.message_windowskin    = wsn
  31.     self.face_windowskin       = wsn
  32.     self.choice_windowskin     = wsn
  33.     self.choicehelp_windowskin = wsn
  34.     self.name_windowskin       = wsn
  35.     self.word_windowskin       = wsn
  36.   end
  37.  
  38. end
  39.  
  40. class Window_WordBox
  41.  
  42.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  43.   # * Set Stats
  44.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  45.   def set_stats
  46.     self.windowskin = Cache.windows ($game_message.word_windowskin)
  47.     self.opacity = $game_message.word_opacity
  48.     self.back_opacity = $game_message.word_backopacity
  49.     create_back_sprite ($game_message.word_dim, $game_message.word_use_dim)
  50.     self.contents.font.name = $game_message.word_fontname
  51.     self.contents.font.size = $game_message.word_fontsize
  52.     self.contents.font.color = text_color ($game_message.word_fontcolour)
  53.   end
  54.  
  55. end
  56.  
  57. class Window_NameBox
  58.  
  59.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  60.   # * Set Stats
  61.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  62.   def set_stats
  63.     self.opacity = $game_message.name_opacity
  64.     self.back_opacity = $game_message.name_backopacity
  65.     create_back_sprite ($game_message.name_dim, $game_message.name_use_dim)
  66.     self.windowskin = Cache.windows ($game_message.name_windowskin)
  67.   end
  68.  
  69. end
  70.  
  71. class Window_FaceBox
  72.  
  73.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74.   # * Remake Window
  75.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  76.   def remake_window (width = $game_message.face_width, height = $game_message.face_height)
  77.     self.width = [width + 2*$game_message.face_border_size, 33].max
  78.     self.height = [height + 2*$game_message.face_border_size, 33].max
  79.     create_contents
  80.     self.windowskin = Cache.windows ($game_message.face_windowskin)
  81.     if $game_message.face_fadein
  82.       self.back_opacity = 0
  83.       @fade_count = $game_message.face_opacity
  84.     else
  85.       self.back_opacity = $game_message.face_opacity
  86.     end
  87.     create_back_sprite ($game_message.face_dim, $game_message.face_use_dim)
  88.     self.visible = $game_message.face_window
  89.   end
  90.  
  91. end
  92.  
  93. class Window_ChoiceBox < Window_Selectable
  94.  
  95.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  96.   # * Object Initialization
  97.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  98.   def initialize (viewport = nil)
  99.     font = Font.new ($game_message.choice_fontname, $game_message.choice_fontsize)
  100.     @wlh = $game_message.choice_wlh > 0 ? $game_message.choice_wlh : $game_message.wlh
  101.     width, height, line_num = prepare_choices (font.dup)
  102.     @back_sprite = Sprite.new (viewport)
  103.     super (0, 0, width, height)
  104.     if line_num*@wlh > (height - 32)
  105.       self.contents.dispose
  106.       self.contents = Bitmap.new (width - 32, line_num*@wlh)
  107.     end
  108.     self.viewport = viewport
  109.     self.windowskin = Cache.windows ($game_message.choice_windowskin)
  110.     self.opacity = $game_message.choice_opacity
  111.     self.back_opacity = $game_message.choice_backopacity
  112.     self.openness = 0
  113.     self.contents.font = font
  114.     self.contents.font.color = text_color ($game_message.choice_fontcolour)
  115.     create_back_sprite ($game_message.choice_dim, $game_message.choice_use_dim)
  116.     @spacing = $game_message.choice_spacing
  117.     @column_max = $game_message.column_max
  118.     @item_max = $game_message.choices.size
  119.     @underline = false
  120.     @highlight = -1
  121.     @last_index = -1
  122.     refresh
  123.   end
  124.  
  125. end
  126.  
  127. class Window_ChoiceHelp < Window_Base
  128.  
  129.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  130.   # * Object Initialization
  131.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  132.   def initialize (choice_helps)
  133.     @back_sprite = Sprite.new
  134.     @choice_helps = []
  135.     @underline = false
  136.     @highlight = -1
  137.     font = Font.new ($game_message.choicehelp_fontname, $game_message.choicehelp_fontsize)
  138.     p_formatter = P_Formatter_ATS.new (font)
  139.     longest_line = 1
  140.     x, y = $game_message.choicehelp_x, $game_message.choicehelp_y
  141.     width, height = $game_message.choicehelp_width, $game_message.choicehelp_height
  142.     @wlh = $game_message.choicehelp_wlh < 0 ? $game_message.wlh : $game_message.choicehelp_wlh
  143.     wdth = width > 0 ? width - 32 : 5000
  144.     tallest = 1
  145.     choice_helps.each { |string|
  146.       s_d = $game_message.convert_special_characters (string.dup)
  147.       s_d.gsub! (/\x16/) { "\x00" }
  148.       lines = []
  149.       line_lengths = []
  150.       while !s_d.empty?
  151.         ls, lc, j = p_formatter.format_by_line (s_d, wdth)
  152.         line_lengths.push (wdth - (ls * (lc - 1)))
  153.         lines.push (s_d.slice! (/.*?\x00/))
  154.       end
  155.       tallest = [tallest, lines.size].max
  156.       @choice_helps.push ([lines, line_lengths])
  157.     }
  158.     p_formatter.dispose
  159.     width = line_lengths.max + 32 if width < 0
  160.     x = x >= 0 ? x : [(Graphics.width - width) / 2, 0].max
  161.     y = $game_message.choicehelp_y < 0 ? 0 : $game_message.choicehelp_y
  162.     width = [33, [width, Graphics.width - x].min].max
  163.     height = height < 0 ? 32 + (tallest*@wlh) : [height, 33].max
  164.     super (x, y, width, height)
  165.     @contents_width = contents.width
  166.     self.windowskin = Cache.windows ($game_message.choicehelp_windowskin)
  167.     self.opacity = $game_message.choicehelp_opacity
  168.     self.back_opacity = $game_message.choicehelp_backopacity
  169.     self.openness = 0
  170.     create_back_sprite ($game_message.choicehelp_dim, $game_message.choicehelp_use_dim)
  171.     self.contents.font = Font.new ($game_message.choicehelp_fontname, $game_message.choicehelp_fontsize)
  172.     self.contents.font.color = text_color ($game_message.choicehelp_fontcolour)
  173.     @index = -1
  174.   end
  175.  
  176. end  
  177.  
  178. class Window_Message
  179.  
  180.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  181.   # * Start Message
  182.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  183.   def start_message (*args)
  184.     @starting = true
  185.     @wlh = $game_message.wlh
  186.     @align = 0
  187.     @max_oy = 0
  188.     @line_x = 0
  189.     @underline = $game_message.underline
  190.     @highlight = $game_message.highlight
  191.     malg_atxs3_msgstrt_8ik3 (*args)
  192.     @text.gsub! (/([^\s])\s*\x00/) { "#{$1} " } if $game_message.paragraph_format
  193.     # Remove x00 from middle of wb and nb boxes
  194.     @text.gsub! (/[\x19\x1a]{.*?}/) { |match| match.gsub (/\x00/) { "" } }
  195.     @text.gsub! (/\x16/) { "\x00" }
  196.     format_line
  197.     self.windowskin = Cache.windows ($game_message.message_windowskin).dup
  198.     self.windowskin.clear_rect (80, 16, 32, 32) unless $game_message.scroll_show_arrows
  199.     self.contents.font.name = $game_message.message_fontname
  200.     self.contents.font.size = $game_message.message_fontsize
  201.     @p_formatter.bitmap.font = self.contents.font.dup
  202.     $game_message.play_se ($game_message.start_se) if $game_message.start_sound
  203.     @starting = false
  204.   end
  205.  
  206. end
  207.  
  208. class Window_FaceBox < Window_Base
  209.  
  210.   alias :irs_pt_wfb_initialize :initialize unless $@
  211.   def initialize( *args, &block )
  212.     irs_pt_wfb_initialize( *args, &block ) ; self.update_windowskin
  213.   end
  214.  
  215.  
  216. end
  217.  
  218. class Window_NameBox < Window_Base
  219.  
  220.   alias :irs_pt_wnb_initialize :initialize unless $@
  221.   def initialize( *args, &block )
  222.     irs_pt_wnb_initialize( *args, &block ) ; self.update_windowskin
  223.   end
  224.  
  225. end
  226.  
  227. class Window_ChoiceBox < Window_Command
  228.  
  229.   alias :irs_pt_wcb_initialize :initialize unless $@
  230.   def initialize( *args, &block )
  231.     irs_pt_wcb_initialize( *args, &block ) ; self.update_windowskin
  232.   end
  233.  
  234. end
  235.  
  236. class Window_Message < Window_Selectable
  237.  
  238.   alias :irs_pt_wm_initialize :initialize unless $@
  239.   def initialize( *args, &block )
  240.     irs_pt_wm_initialize( *args, &block ) ; self.update_windowskin
  241.   end
  242.  
  243. end
Advertisement
Add Comment
Please, Sign In to add comment