Advertisement
Bigace360

Multi Variable Window [RMVXA]

Feb 24th, 2013
1,337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.19 KB | None | 0 0
  1.  
  2. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  3. # ■ Multi Variable Window                          
  4. # ■ Author: Bigace360  
  5. # ■ Version: 1.2
  6. # ■ Date: Feb. 5, 2013
  7. # ■ Blog: http://bigaceworld.wordpress.com/
  8. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  9. #                               VERSION HISTORY                                #
  10. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  11. # o v1.0 <> 02.05.2013 - Started and Finished Script
  12. # o v1.2 <> 02.08.2013 - You can now change the y-axis of the window form the
  13. #                        module.
  14. #                      - Compatible wity Yanfly digit grouping method
  15. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  16. #                                INTRODUCTION                                  #
  17. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  18. # This alters the side windows at the bottom to display variables, time, steps,
  19. # gold, or your own custom variable. The script uses Yanfly's digit grouping
  20. # method, if you have Yanfly's ACE Core Engine installed.
  21. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  22. #                                  SECTIONS                                    #
  23. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  24. #  ■ Game_Objects
  25. # ** ACE Module
  26. # ** Numeric
  27. #
  28. #  ■ Windows
  29. # ** Window_MultiVariable
  30. #
  31. #  ■ Scenes
  32. # ** Scene_Menu
  33. #
  34. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  35. #
  36. # Credits/Thanks:
  37. #   - Bigace360, for the script.
  38. #
  39. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  40. #                     Script Conflicts and Compatability                       #
  41. #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
  42. # ● Overwriten methods
  43. #   class Scene_Menu
  44. #      def create_gold_window
  45. #
  46. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  47. #
  48. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  49. # ■ Module ACE::Variable
  50. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  51. module ACE
  52.     module Variable
  53.         #--------------------------------------------------------------------------
  54.         # ◆ Section I. Multi Variable Window ◆
  55.         # -------------------------------------------------------------------------
  56.         # This alters the side windows at the bottom to display variables, time,
  57.         # steps, gold, etc. This window appears at the bottom of the screen.
  58.         # Variable ID => Windows
  59.         # -2          => Play Time
  60.         # -1          => Steps
  61.         #  0          => Gold
  62.         #--------------------------------------------------------------------------
  63.         VARIABLE ={
  64.             # Variables will be shown in this order. Use 0 to show gold. Adjust the
  65.             # following information as seen necessary.
  66.             :shown => [-2, 0, -1, 1],
  67.             :icons => true,
  68.       # use this to change the y-axis of the variable window. It must be in a
  69.       # string to work.
  70.       :y_axis => "@command_window.height",
  71.             :hash =>{# Do not remove this.
  72.                 # VarID => [Icon, Text]
  73.                 -2 => [15, "Time"],     #Default
  74.                 -1 => [48, "Steps"],    #Default
  75.                 0 => [360, "Gold"],     #Default
  76.                 1 => [339, "Monsters"], #Example
  77.             },# Do not remove this.
  78.         }
  79.     end
  80. end
  81.  
  82. #==============================================================================
  83. # ▼ Editting anything past this point may potentially result in causing
  84. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  85. # halitosis so edit at your own risk.
  86. #==============================================================================
  87. #
  88. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  89. #                         ▼ Import to Global Hash ▼                            #
  90. ($ace_script ||= {})[:multi_variables] = 1.2
  91. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  92.  
  93. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  94. # ■ Numeric
  95. ($imported ||= {})["YEA-CoreEngine"] = true
  96. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  97. class Numeric
  98.   #--------------------------------------------------------------------------
  99.   # new method: group_digits
  100.   #--------------------------------------------------------------------------
  101.   def group; return self.to_s; end  unless $imported["YEA-CoreEngine"]
  102. end # Numeric
  103.  
  104. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  105. # ■ Window_MultiVariable
  106. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  107. class Window_MultiVariable < Window_Selectable
  108.     include ACE::Variable
  109.     def initialize(dy)
  110.         super(0, dy, window_width, fitting_height(VARIABLE[:shown].size))
  111.         @data = []
  112.         refresh
  113.     end
  114.     def window_width
  115.         return 160
  116.     end
  117.     def draw_var
  118.         return VARIABLE[:hash]
  119.     end
  120.   def gold
  121.     $game_party.gold
  122.   end
  123.   def steps
  124.     $game_party.steps
  125.   end
  126.   def variables(item)
  127.     $game_variables[item]
  128.   end
  129.     def item_max
  130.         @data ? @data.size : 0
  131.     end
  132.     def refresh
  133.         make_item_list
  134.         create_contents
  135.         draw_all_items
  136.     end
  137.     def make_item_list
  138.         VARIABLE[:shown].each do |i|
  139.             next unless draw_var.include?(i)
  140.             @time_index = @data.size if i == -2
  141.             @data << i
  142.         end
  143.     end
  144.     def draw_item(index)
  145.         rect = item_rect(index)
  146.         clear_item(index)
  147.         item = @data[index]
  148.         case item
  149.         when -2 then draw_variables(rect, game_time, draw_var[-2])
  150.         when -1 then draw_variables(rect, steps.group, draw_var[-1])
  151.         when 0 then draw_variables(rect, gold.group, draw_var[0])
  152.         else draw_variables(rect, variables(item).group, draw_var[item])
  153.         end
  154.     end
  155.     def draw_variables(rect, text, variable)
  156.         if VARIABLE[:icons]
  157.             rect.width -= 24
  158.             draw_text(rect, text, 2)
  159.             draw_icon(variable[0], rect.width, rect.y)
  160.     elsif VARIABLE[:shown].include?(-2)
  161.       draw_time_value(variable[1], text, 0, rect.y, rect.width)
  162.         else draw_currency_value(variable[1], text, 0, rect.y, rect.width)
  163.         end    
  164.     end
  165.   def draw_time_value(value, unit, x, y, width)
  166.     cx = text_size(unit).width
  167.     change_color(normal_color)
  168.     draw_text(x, y, width - cx - 2, line_height, value, 2)
  169.     change_color(system_color)
  170.     draw_text(x, y, width, line_height, unit, 2)
  171.   end
  172.     def game_time
  173.         gametime = Graphics.frame_count / Graphics.frame_rate
  174.         hours = gametime / 3600
  175.         minutes = gametime / 60 % 60
  176.         seconds = gametime % 60
  177.         result = sprintf("%d:%02d:%02d", hours, minutes, seconds)
  178.         return result
  179.     end
  180.     if VARIABLE[:shown].include?(-2)
  181.         def update
  182.             if game_time != (Graphics.frame_count / Graphics.frame_rate)
  183.                 draw_item(@time_index)
  184.             end
  185.             super
  186.         end
  187.     end
  188.     def open
  189.         refresh
  190.         super
  191.     end
  192. end
  193.  
  194. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  195. # ■ Scene_Menu
  196. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  197. class Scene_Menu < Scene_MenuBase
  198.     def create_gold_window
  199.         dy = eval(ACE::Variable::VARIABLE[:y_axis])
  200.         @gold_window = Window_MultiVariable.new(dy)
  201.     end
  202. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement