mrbubble

Compatibility Patch: YEA System Options + KMS Generic Gauge

Jan 31st, 2012
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.22 KB | None | 0 0
  1. #==============================================================================
  2. # Compatibility Patch :                                          v1.0 (1/31/12)
  3. #   YEA System Options + KMS Generic Gauge
  4. #==============================================================================
  5. # Script by:
  6. #     Mr. Bubble
  7. #--------------------------------------------------------------------------
  8. # Place this script below both YEA System Options and KMS Generic Gauge
  9. # in your script edtior.
  10. #
  11. # Due to the nature of both scripts, several methods in YEA System Options
  12. # were overwritten.
  13. #==============================================================================
  14.  
  15. module Bubs
  16. module GGPatch
  17.  
  18.   #--------------------------------------------------------------------------
  19.   # All Generic Gauge images must be placed in the "Graphics/System"
  20.   # folder of your project.
  21.   #--------------------------------------------------------------------------
  22.  
  23.   #--------------------------------------------------------------------------
  24.   # Window Tone Gauge Settings
  25.   #--------------------------------------------------------------------------
  26.   WINDOW_TONE_GAUGE_SETTINGS = {  
  27.     :window_red => "GaugeRed",    # Red Tone Gauge
  28.     :window_grn => "GaugeGreen",  # Green Tone Gauge
  29.     :window_blu => "GaugeBlue",   # Blue Tone Gauge
  30.    
  31.     #------------------------------------------------------------------------
  32.     # The following settings affect all Window Tone generic gauges
  33.     #------------------------------------------------------------------------
  34.     :offset => [-23, -2],  # Gauge Position Offset [x, y]
  35.     :length => -4,         # Gauge Length Adjustment
  36.     :slope  => 30,         # Gauge Slope; Must be between -89 ~ 89 degrees
  37.    
  38.   } # <-- Do not delete
  39.  
  40.   #--------------------------------------------------------------------------
  41.   # Volume Gauge Settings
  42.   #--------------------------------------------------------------------------
  43.   VOLUME_GAUGE_SETTINGS = {
  44.     :volume_bgm => "GaugeBGM",  # BGM Gauge
  45.     :volume_bgs => "GaugeBGS",  # BGS Gauge
  46.     :volume_sfx => "GaugeSFX",  # SFX Gauge
  47.    
  48.     #------------------------------------------------------------------------
  49.     # The following settings affect all Volume generic gauges
  50.     #------------------------------------------------------------------------
  51.     :offset => [-23, -2],  # Gauge Position Offset [x, y]
  52.     :length => -4,         # Gauge Length Adjustment
  53.     :slope  => 30,         # Gauge Slope; Must be between -89 ~ 89 degrees
  54.    
  55.   } # <-- Do not delete
  56.  
  57.   #--------------------------------------------------------------------------
  58.   # Custom Variable Gauge Settings
  59.   #--------------------------------------------------------------------------
  60.   CUSTOM_VARIABLE_GAUGE_SETTINGS = {
  61.     #------------------------------------------------------------------------
  62.     # Default gauge used if custom variable gauge is not defined
  63.     #------------------------------------------------------------------------
  64.     :default_gauge => "GaugeHP",
  65.    
  66.     #------------------------------------------------------------------------
  67.     # Variable index must match the same index that you defined in
  68.     # CUSTOM_VARIABLES in YEA System Options. Otherwise, :default_gauge
  69.     # will be used.
  70.     #------------------------------------------------------------------------
  71.     1 => "GaugeMP", # Variable 1 Gauge
  72.     2 => "GaugeTP", # Variable 2 Gauge
  73.    
  74.     #------------------------------------------------------------------------
  75.     # The following settings affect all Custom Variable generic gauges
  76.     #------------------------------------------------------------------------
  77.     :offset => [-23, -2],  # Gauge Position Offset [x, y]
  78.     :length => -4,         # Gauge Length Adjustment
  79.     :slope  => 30,         # Gauge Slope; Must be between -89 ~ 89 degrees
  80.  
  81.   } # <-- Do not delete
  82.  
  83. end
  84. end
  85.  
  86. $imported = {} if $imported.nil?
  87. $kms_imported = {} if $kms_imported.nil?
  88.  
  89. #==============================================================================
  90. # ■ Window_SystemOptions
  91. #==============================================================================
  92.  
  93. class Window_SystemOptions < Window_Command
  94.   if $imported["YEA-SystemOptions"] && $kms_imported["GenericGauge"]
  95.   #--------------------------------------------------------------------------
  96.   # overwrite : draw_window_tone
  97.   #--------------------------------------------------------------------------
  98.   def draw_window_tone(rect, index, symbol)
  99.     name = @list[index][:name]
  100.     draw_text(0, rect.y, contents.width/2, line_height, name, 1)
  101.     #---
  102.     dx = contents.width / 2
  103.     tone = $game_system.window_tone
  104.     case symbol
  105.     when :window_red
  106.       rate = (tone.red + 255.0) / 510.0
  107.       colour1 = Color.new(128, 0, 0)
  108.       colour2 = Color.new(255, 0, 0)
  109.       value = tone.red.to_i
  110.     when :window_grn
  111.       rate = (tone.green + 255.0) / 510.0
  112.       colour1 = Color.new(0, 128, 0)
  113.       colour2 = Color.new(0, 255, 0)
  114.       value = tone.green.to_i
  115.     when :window_blu
  116.       rate = (tone.blue + 255.0) / 510.0
  117.       colour1 = Color.new(0, 0, 128)
  118.       colour2 = Color.new(0, 0, 255)
  119.       value = tone.blue.to_i
  120.     end
  121.     #---
  122.     draw_gauge(Bubs::GGPatch::WINDOW_TONE_GAUGE_SETTINGS[symbol],
  123.               dx, rect.y, contents.width - dx - 48, rate,
  124.               Bubs::GGPatch::WINDOW_TONE_GAUGE_SETTINGS[:offset],
  125.               Bubs::GGPatch::WINDOW_TONE_GAUGE_SETTINGS[:length],
  126.               Bubs::GGPatch::WINDOW_TONE_GAUGE_SETTINGS[:slope])
  127.     #---
  128.     draw_text(dx, rect.y, contents.width - dx - 48, line_height, value, 2)
  129.   end
  130.  
  131.   #--------------------------------------------------------------------------
  132.   # overwrite : draw_volume
  133.   #--------------------------------------------------------------------------
  134.   def draw_volume(rect, index, symbol)
  135.     name = @list[index][:name]
  136.     draw_text(0, rect.y, contents.width/2, line_height, name, 1)
  137.     #---
  138.     dx = contents.width / 2
  139.     case symbol
  140.     when :volume_bgm
  141.       rate = $game_system.volume(:bgm)
  142.     when :volume_bgs
  143.       rate = $game_system.volume(:bgs)
  144.     when :volume_sfx
  145.       rate = $game_system.volume(:sfx)
  146.     end
  147.     colour1 = text_color(YEA::SYSTEM::COMMAND_VOCAB[symbol][1])
  148.     colour2 = text_color(YEA::SYSTEM::COMMAND_VOCAB[symbol][2])
  149.     value = sprintf("%d%%", rate)
  150.     rate *= 0.01
  151.     #---
  152.     draw_gauge(Bubs::GGPatch::VOLUME_GAUGE_SETTINGS[symbol],
  153.               dx, rect.y, contents.width - dx - 48, rate,
  154.               Bubs::GGPatch::VOLUME_GAUGE_SETTINGS[:offset],
  155.               Bubs::GGPatch::VOLUME_GAUGE_SETTINGS[:length],
  156.               Bubs::GGPatch::VOLUME_GAUGE_SETTINGS[:slope])
  157.     #---
  158.     draw_text(dx, rect.y, contents.width - dx - 48, line_height, value, 2)
  159.   end
  160.  
  161.   #--------------------------------------------------------------------------
  162.   # overwrite : draw_custom_variable
  163.   #--------------------------------------------------------------------------
  164.   def draw_custom_variable(rect, index, ext)
  165.     name = @list[index][:name]
  166.     draw_text(0, rect.y, contents.width/2, line_height, name, 1)
  167.     #---
  168.     dx = contents.width / 2
  169.     value = $game_variables[YEA::SYSTEM::CUSTOM_VARIABLES[ext][0]]
  170.     colour1 = text_color(YEA::SYSTEM::CUSTOM_VARIABLES[ext][2])
  171.     colour2 = text_color(YEA::SYSTEM::CUSTOM_VARIABLES[ext][3])
  172.     minimum = YEA::SYSTEM::CUSTOM_VARIABLES[ext][4]
  173.     maximum = YEA::SYSTEM::CUSTOM_VARIABLES[ext][5]
  174.     rate = (value - minimum).to_f / [(maximum - minimum).to_f, 0.01].max
  175.     dx = contents.width/2
  176.     #---
  177.     var_index = YEA::SYSTEM::CUSTOM_VARIABLES[ext][0]
  178.     if Bubs::GGPatch::CUSTOM_VARIABLE_GAUGE_SETTINGS.include?(var_index)
  179.       image = Bubs::GGPatch::CUSTOM_VARIABLE_GAUGE_SETTINGS[var_index]
  180.     else
  181.       image = Bubs::GGPatch::CUSTOM_VARIABLE_GAUGE_SETTINGS[:default_gauge]
  182.     end
  183.    
  184.     draw_gauge(image, dx, rect.y, contents.width - dx - 48, rate,
  185.               Bubs::GGPatch::CUSTOM_VARIABLE_GAUGE_SETTINGS[:offset],
  186.               Bubs::GGPatch::CUSTOM_VARIABLE_GAUGE_SETTINGS[:length],
  187.               Bubs::GGPatch::CUSTOM_VARIABLE_GAUGE_SETTINGS[:slope])
  188.     #---
  189.     draw_text(dx, rect.y, contents.width - dx - 48, line_height, value, 2)
  190.   end
  191.  
  192.   end # $imported
  193. end
Advertisement
Add Comment
Please, Sign In to add comment