Advertisement
KK20

Revamp

Aug 15th, 2015
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.72 KB | None | 0 0
  1. class Window_Base < Window
  2. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  3. # NEW! Function(s): draw_actor_sparam, draw_actor_xparam
  4. # Overwrites: draw_actor_param
  5. #   : Identical to drawing normal parameters, but for s/x params instead.
  6. #   : Also draws icons when available for the various stats.
  7.   def draw_actor_param(actor, x, y, param_id)
  8.     name = Vocab::param(param_id)
  9.     if J::StatIcons::ICONS.include?(name)
  10.       draw_icon(J::StatIcons::ICONS[name], x-32, y)
  11.     end
  12.     value = sprintf("%04d", actor.param(param_id).to_s)
  13.     change_color(system_color)
  14.     draw_text(x-10, y, 120, line_height, name)
  15.     change_color(normal_color)
  16.     draw_text(x + 50, y, 48, line_height, value, 2)
  17.   end#def
  18.  
  19.   def draw_actor_sparam(actor, x, y, sparam_id)
  20.     name = Vocab::sparam(sparam_id)
  21.     if J::StatIcons::ICONS.include?(name)
  22.       draw_icon(J::StatIcons::ICONS[name], x-24, y)
  23.     end
  24.     value = ((actor.sparam(sparam_id)*100) - 100).to_i
  25.     change_color(system_color)
  26.     draw_text(x - 10, y, 120, line_height, name)
  27.     change_color(normal_color)
  28.     draw_text(x + 50, y, 48, line_height, value, 2)
  29.   end#def
  30.  
  31.   def draw_actor_xparam(actor, x, y, xparam_id)
  32.     name = Vocab::xparam(xparam_id)
  33.     if J::StatIcons::ICONS.include?(name)
  34.       draw_icon(J::StatIcons::ICONS[name], x-24, y)
  35.     end
  36.     change_color(system_color)
  37.     draw_text(x - 10, y, 120, line_height, name)
  38.     change_color(normal_color)
  39.     draw_text(x + 50, y, 48, line_height, (actor.xparam(xparam_id)*100).to_i, 2)
  40.   end#def
  41.  
  42. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-  # * Draw HP
  43. # Overwrites: make_font_bigger, make_font_smaller
  44. #   : Modifies existing method to allow custom input for font-size adjustments.
  45.   def make_font_bigger(size = 8)
  46.     contents.font.size += size if contents.font.size <= 64
  47.   end#def
  48.  
  49.   def make_font_smaller(size = 8)
  50.     contents.font.size -= size if contents.font.size >= 16
  51.   end#def
  52.  
  53. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-  # * Draw HP
  54. # Overwrites: draw_actor_hp, draw_actor_mp
  55. #   : Modifies existing method to draw fixed number of digits (4).
  56.   def draw_actor_hp(actor, x, y, width = 124)
  57.     c_hp = sprintf("%04d", actor.hp); m_hp = sprintf("%04d", actor.mhp)
  58.     draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
  59.     change_color(system_color)
  60.     draw_text(x, y, 30, line_height, Vocab::hp_a)
  61.     draw_current_and_max_values(x, y, width, c_hp, m_hp,
  62.       hp_color(actor), normal_color)
  63.   end#def
  64.  
  65.   def draw_actor_mp(actor, x, y, width = 124)
  66.     c_mp = sprintf("%04d", actor.mp); m_mp = sprintf("%04d", actor.mmp)
  67.     draw_gauge(x, y, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
  68.     change_color(system_color)
  69.     draw_text(x, y, 30, line_height, Vocab::mp_a)
  70.     draw_current_and_max_values(x, y, width, c_mp, m_mp,
  71.       mp_color(actor), normal_color)
  72.   end#def
  73. end#Window_Base
  74.  
  75.  
  76. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  77. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  78. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  79. # Overwrites: Entire status menu.
  80. #   : WARNING! Do not use with other scripts that modify the status menu.
  81. #   : NOTE there is 14 standard rows available for use with 360 height.
  82. #   : This is copy-pasta, in effort to accomplish goals of new stat drawing.
  83.  
  84. class Window_Status < Window_Selectable
  85.  
  86.   def initialize(actor)
  87.     super(0, 0, Graphics.width, Graphics.height)
  88.     @actor = actor
  89.     @data = []
  90.     refresh
  91.     activate
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * Get Digit Count
  95.   #--------------------------------------------------------------------------
  96.   def col_max
  97.     return 3
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # * Get Number of Items
  101.   #--------------------------------------------------------------------------
  102.   def item_max
  103.     @data ? @data.size : 1
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # * Get Item
  107.   #--------------------------------------------------------------------------
  108.   def item
  109.     @data && index >= 0 ? @data[index] : nil
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # * Get Activation State of Selection Item
  113.   #--------------------------------------------------------------------------
  114. #~   def current_item_enabled?
  115. #~     enable?(@data[index])
  116. #~   end
  117.   #--------------------------------------------------------------------------
  118.   # * Get Item Height
  119.   #--------------------------------------------------------------------------
  120.   def item_height
  121.     20 #(height - standard_padding * 2) / 4
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # * Create Item List
  125.   #--------------------------------------------------------------------------
  126. #~   def make_item_list(actor)
  127. #~     6.times {|bid| @data << actor.param(bid)}
  128. #~     10.times {|sid| @data << actor.sparam(sid)}
  129. #~     10.times {|xid| @data << actor.xparam(xid)}
  130. #~   end
  131.  
  132.   def refresh
  133.     contents.clear
  134. #    make_item_list(@actor)
  135. #    create_contents
  136. #    draw_all_items
  137.     draw_block_header     (line_height * 0)
  138.     draw_block_allparams  (line_height * 4)
  139.     draw_block_explife    (line_height * 0)
  140.   end#def
  141.  
  142.   def draw_block_allparams(y = 0)
  143.     draw_b_parameters( 20, y)
  144.     draw_s_parameters(170, y)
  145.     draw_x_parameters(320, y)
  146.     draw_equipments(440, y)
  147.   end#def
  148.  
  149.   def draw_block_header(y)
  150.     draw_actor_face(@actor, 0, y)
  151.     make_font_bigger(4)
  152.     draw_actor_name(@actor, 100, y + line_height * 0)
  153.     make_font_smaller(8)
  154.     draw_actor_class(@actor, 100, y + line_height * 1)
  155.     draw_actor_nickname(@actor, 100, y + line_height * 2)
  156.     make_font_bigger(4)
  157.     draw_actor_level(@actor, 100, y + line_height * 3)
  158.   end#def
  159.  
  160.   def draw_block_explife(y)
  161.     draw_actor_hp(@actor, 240, y + line_height * 0, 80)
  162.     draw_actor_mp(@actor, 240, y + line_height * 1, 80)
  163.     draw_actor_icons(@actor, 240, y + line_height * 2)
  164.     draw_exp_info(370, y)
  165.   end#def
  166.  
  167.   def draw_equipments(x, y)
  168.     @actor.equips.each_with_index do |item, i|
  169.       draw_item_name(item, x, y + line_height * i)
  170.     end#each
  171.   end#def
  172.  
  173. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  174. # Overwrites: draw_exp_info
  175. #   : Modifies existing method to draw fixed number of digits (10).
  176. #   : Draws in only 2 lines instead of 4 to save vertical space.
  177.   def draw_exp_info(x, y)
  178.     if @actor.max_level?
  179.       s2 = "-------";
  180.     else
  181.       s1 = sprintf("%010d", @actor.exp)
  182.       s2 = sprintf("%010d", (@actor.next_level_exp - @actor.exp))
  183.     end
  184.     s_e = sprintf("Exp.: ")#(Vocab::ExpNext, Vocab::level)
  185.     s_n = sprintf("Next: ")#(Vocab::ExpNext, Vocab::ExpTotal)
  186.     change_color(system_color)
  187.     draw_text(x + 0, y + line_height * 0, 180, line_height, s_e)
  188.     draw_text(x + 0, y + line_height * 1, 180, line_height, s_n)
  189.     change_color(normal_color)
  190.     draw_text(x + 64, y + line_height * 0, 180, line_height, s1)
  191.     draw_text(x + 64, y + line_height * 1, 180, line_height, s2)
  192.   end#def
  193.  
  194. # Draws a 2px vertical line at the given location.
  195.   def draw_vert_line(x, y)
  196.     # (origin x, origin y, line_width, how tall, color)
  197.     contents.fill_rect(x, y, 2, 200, line_color)
  198.   end#def
  199.  
  200. # Draws the base parameters that the database normally modifies.
  201.   def draw_b_parameters(x, y)
  202.     lh = line_height - 4
  203.     make_font_smaller(4)
  204.     8.times {|i| draw_actor_param(@actor, x, y + lh * i, i) }
  205.     make_font_bigger(4)
  206.   end#def
  207.  
  208. # Draws the secondary parameters like MCR/PDR/EXR.
  209.   def draw_s_parameters(x, y)
  210.     lh = line_height - 4
  211.     make_font_smaller(4)
  212.     10.times {|i| draw_actor_sparam(@actor, x, y + lh * i, i) }
  213.     make_font_bigger(4)
  214.   end#def
  215.  
  216. # Draws the extra parameters like Hit/crit/evade.
  217.   def draw_x_parameters(x, y)
  218.     lh = line_height - 4
  219.     make_font_smaller(4)
  220.     10.times {|i| draw_actor_xparam(@actor, x, y + lh * i, i) }
  221.     make_font_bigger(4)
  222.   end#def
  223.  
  224. end#Window_Status
  225.  
  226.  
  227.  
  228.  
  229. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  230. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  231. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  232. # NEW! class used explicity with this script.
  233. #   : Draws the three categories of parameters to drill down into for details.
  234.  
  235. class Window_Parameter_Choice < Window_Selectable
  236.   def initialize(x, y)
  237.     super(x, y, 460, 240)
  238.   end#def
  239.  
  240.   def item_max
  241.     return 30
  242.   end
  243.  
  244.  
  245.   def col_max; return 3; end
  246.  
  247.   def item_rect(index)
  248.     rect = Rect.new
  249.     rect.width = item_width
  250.     rect.height = item_height - 2
  251.     rect.x = index % col_max * 150#(item_width) + spacing)
  252.     rect.y = index / col_max * item_height + 2
  253.     rect
  254.   end#def
  255.  
  256.   def item_width
  257.     (width - standard_padding * 2 + spacing) / col_max - spacing
  258.   end#def
  259.  
  260.   def item_height
  261.     20#line_height
  262.   end#def
  263.  
  264.   #--------------------------------------------------------------------------
  265.   # * Move Cursor Down
  266.   #--------------------------------------------------------------------------
  267.   def cursor_down(wrap = false)
  268.     if index == 21
  269.       return
  270.     else
  271.       super(wrap)
  272.     end
  273.   end
  274.   #--------------------------------------------------------------------------
  275.   # * Move Cursor Right
  276.   #--------------------------------------------------------------------------
  277.   def cursor_right(wrap = false)
  278.     if index == 26 || index == 23
  279.       select(index == 23 ? 25 : 28)
  280.     else
  281.       super(wrap)
  282.     end
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # * Move Cursor Left
  286.   #--------------------------------------------------------------------------
  287.   def cursor_left(wrap = false)
  288.     if index == 28 || index == 25
  289.       select(index == 25 ? 23 : 26)
  290.     else
  291.       super(wrap)
  292.     end
  293.   end
  294.  
  295.   def select(index)
  296.     super(index)
  297.     @help_window.set_text(Vocab.paramInfo(@index))
  298.   end
  299.  
  300.  
  301. # Writes in the horizontal list of the 3 sections.
  302.   #def make_command_list(*args, &block)
  303.   #  add_command("B", :paramb)
  304.   #  add_command("S", :params)
  305.   #  add_command("X", :paramx)
  306.   #end
  307. end#Window_Parameter_Choice
  308.  
  309.  
  310.  
  311.  
  312. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  313. # Overwrites: Scene_Status
  314. #   : Modified to handle the new windows and methods created above.
  315. #   : Modified to allow for parameter help descriptions.
  316. class Scene_Status < Scene_MenuBase
  317.   def start
  318.     super
  319.     create_status_window
  320.     create_help_window
  321.     create_select_window
  322.   end
  323.  
  324.   def create_status_window
  325.     @status_window = Window_Status.new(@actor)
  326.     @status_window.actor = @actor
  327.     @status_window.set_handler(:cancel,   method(:return_scene))
  328.     @status_window.set_handler(:pagedown, method(:next_actor))
  329.     @status_window.set_handler(:pageup,   method(:prev_actor))
  330.     end
  331.  
  332.   def create_help_window
  333.     @help_window = Window_Help.new
  334.     @help_window.viewport = @viewport
  335.     @help_window.opacity = 0 #for visibility, will be 0 later
  336.     @help_window.y = 310
  337.   end
  338.  
  339.   def create_select_window
  340.     @select_window = Window_Parameter_Choice.new(0, 96)
  341.     @select_window.opacity = 0
  342.     @select_window.active = true
  343.     @select_window.help_window = @help_window
  344.     @select_window.select(0) # Put cursor to MaxHP and draw help text for it
  345.    
  346.   end
  347.    
  348.   def on_actor_change
  349.     @status_window.actor = @actor
  350.     @status_window.activate
  351.     @help_window.refresh
  352.   end
  353.  
  354. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement