Advertisement
eugene222

TPS Tints for Periods

Jul 11th, 2014
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.89 KB | None | 0 0
  1. #===============================================================================
  2. # ***TPS-Addon: Tints for Periods***
  3. #
  4. # Author:     eugene222 (Evgenij)
  5. # Version:    1.3a
  6. # Date:       01.09.2014
  7. # Requires:   Time and Period System V. 1.2 by eugene222
  8. #===============================================================================
  9. # Changelog:
  10. #
  11. #   04.04.2014 - V. 1.0-alpha1 - script created
  12. #   05.04.2014 - V. 1.0        - released the script  
  13. #   09.04.2014 - V. 1.1        - made this compatible with Core V. 1.1
  14. #   21.05.2014 - V. 1.2        - tints for phases added
  15. #   31.08.2014 - V. 1.3        - experimental khas support (cant test this currently)
  16. #   01.09.2014 - V. 1.3a       - Tested Khas support and fixed few things
  17. #
  18. #===============================================================================
  19. # Terms of Use:
  20. #   You can use this script for free and commercial projects as long as you give
  21. #   credits.
  22. #===============================================================================
  23. # Beschreibung:
  24. #  Tints for periods.
  25. #
  26. # Scriptcalls:
  27. #  $game_time.stop_tint    # stop automatic tints
  28. #  $game_time.resume_tint  # resume automatic tints
  29. #
  30. #===============================================================================
  31. module TPS_TINT
  32.   #-----------------------------------------------------------------------------
  33.   # Use Battle Tints?
  34.   #-----------------------------------------------------------------------------
  35.   TONE_BATTLE = true
  36.   #-----------------------------------------------------------------------------
  37.   # FADE TIME FOR TINTS (in Frames)  
  38.   #-----------------------------------------------------------------------------
  39.   FADE_TIME = 60
  40.  
  41.   #-----------------------------------------------------------------------------
  42.   # ENABLE THIS WHEN USING KHAS AWESOME LIGHT EFFECTS
  43.   #-----------------------------------------------------------------------------
  44.   USE_KHAS_TINTING = false
  45.    
  46.   #-----------------------------------------------------------------------------
  47.   DEFAULT = { # Diese Zeile nicht verändern!
  48.   #-----------------------------------------------------------------------------
  49.   # THE DEFAULT TINTS
  50.   #-----------------------------------------------------------------------------
  51.    
  52.    
  53.     :morning    =>  [-51, -34, -17, 62],    
  54.     :forenoon   =>  [-51, -34, -17, 68],    
  55.     :noon       =>  [0,0,0,0],    
  56.     :afternoon  =>  [0, -17, -34, 0],  
  57.     :evening    =>  [0, -34, -68, 34],  
  58.     :night      =>  [-102, -85, -34, 85],
  59.      
  60.   #-----------------------------------------------------------------------------
  61.   } # Diese Zeile nicht verändern!
  62.   #-----------------------------------------------------------------------------
  63.  
  64.  
  65.   #-----------------------------------------------------------------------------
  66.   # If you use the Addon: Phases and Weather you can overwrite the default tints
  67.   # for your custom phases
  68.   #  - When more than one phase is active and get its own tint, the tint for the
  69.   #    phase with the highest priority will be taken (the priority is definable
  70.   #    in the other Addon)
  71.   #-----------------------------------------------------------------------------
  72.   PHASES = {
  73.  
  74.     #-----------------------------------------------------------------------
  75.     # Overwrite some tints for winter.
  76.     #-----------------------------------------------------------------------
  77.     :winter => {
  78.        
  79.         :noon    =>  [-5, 0, 15, 15],
  80.         :afternoon => [-15, -5, 20, 25],
  81.         :evening => [-80, -85, -34, 51],
  82.    
  83.     },
  84.   }
  85. end
  86. #===============================================================================
  87. # END OF CONFIG
  88. #===============================================================================
  89. $imported ||= {}
  90. $imported[:e222_tps_tints] = 1.2
  91. unless $imported[:e222_tps_core]
  92.   msgbox("\"TBS-Addon: Tints for Periods\" requires the \"TBS-Core\" script.\n"+
  93.          "The \"TBS-Core\" script must be placed above the addon script.")
  94.   exit
  95. end
  96. #===============================================================================
  97. # Game_Time
  98. #   aliased methods: initialize, post_set_period
  99. #   new methods:  stop_tint, resume_tint
  100. #===============================================================================
  101. class Game_Time
  102.   #-----------------------------------------------------------------------------
  103.   attr_reader   :tint_screen
  104.   #-----------------------------------------------------------------------------
  105.   # Initialize
  106.   #-----------------------------------------------------------------------------
  107.   alias :tps_tint_reinitialize_e222             :reinitialize
  108.   #-----------------------------------------------------------------------------
  109.   def reinitialize
  110.     tps_tint_reinitialize_e222  
  111.     @tint_screen   = true if @tint_screen.nil?
  112.     @tone_phases ||= []
  113.   end
  114.   #-----------------------------------------------------------------------------
  115.   # Initialize Period
  116.   #-----------------------------------------------------------------------------
  117.   alias :tps_tint_initialize_period_e222        :initialize_period
  118.   #-----------------------------------------------------------------------------
  119.   def initialize_period
  120.     tps_tint_initialize_period_e222
  121.     initialize_tone_phases
  122.     refresh_map_tone(0)
  123.   end
  124.   #-----------------------------------------------------------------------------
  125.   # Refresh Period
  126.   #-----------------------------------------------------------------------------
  127.   alias :tps_tint_refresh_period_e222           :refresh_period
  128.   #-----------------------------------------------------------------------------
  129.   def refresh_period
  130.     tps_tint_refresh_period_e222
  131.     case SceneManager.scene
  132.     when Scene_Map
  133.       refresh_map_tone(TPS_TINT::FADE_TIME)
  134.     when Scene_Battle
  135.       refresh_battle_tone(TPS_TINT::FADE_TIME)
  136.     end
  137.   end
  138.   #-----------------------------------------------------------------------------
  139.   # Refresh Map Tone
  140.   #-----------------------------------------------------------------------------
  141.   def refresh_map_tone(fade_time)
  142.     return unless SceneManager.scene_is?(Scene_Map)
  143.     $game_map.indoor? ? refresh_indoor_tone : refresh_outdoor_tone(fade_time)  
  144.   end
  145.   #-----------------------------------------------------------------------------
  146.   # Refresh Indoor Tone
  147.   #-----------------------------------------------------------------------------
  148.   def refresh_indoor_tone
  149.     $game_map.set_screen_tone([0,0,0,0], 0)
  150.   end
  151.   #-----------------------------------------------------------------------------
  152.   # Refresh Outdoor Tone
  153.   #-----------------------------------------------------------------------------  
  154.   def refresh_outdoor_tone(fade_time)
  155.     return unless @tint_screen
  156.     $game_map.set_screen_tone(get_tone, fade_time)
  157.   end
  158.   #-----------------------------------------------------------------------------
  159.   # Refresh Battle Tone
  160.   #-----------------------------------------------------------------------------      
  161.   def refresh_battle_tone(fade_time)
  162.     return if $game_map.indoor? || !TPS_TINT::TONE_BATTLE || !@tint_screen
  163.     $game_troop.set_screen_tone(get_tone, fade_time)
  164.   end
  165.   #-----------------------------------------------------------------------------
  166.   # Sort Active Phases
  167.   #-----------------------------------------------------------------------------
  168.   if Game_Time.instance_methods.include?(:sort_active_phases)
  169.     alias :tps_tint_sap_e222 :sort_active_phases
  170.     #---------------------------------------------------------------------------
  171.     def sort_active_phases
  172.       tps_tint_sap_e222
  173.       initialize_tone_phases
  174.     end
  175.     #---------------------------------------------------------------------------
  176.   end
  177.   #=============================================================================
  178.   # For Phases and Weather Addon:
  179.   #=============================================================================
  180.  
  181.   #-----------------------------------------------------------------------------
  182.   # Initialize Tone Phases
  183.   #-----------------------------------------------------------------------------
  184.   def initialize_tone_phases
  185.     return unless $imported[:e222_tps_phases]
  186.     tint_phases = TPS_TINT::PHASES
  187.     @tone_phases = tint_phases.select {|k, v| tone_phase?(k)}.keys
  188.     @tone_phases.sort_by! {|k| TPS_PHASES::CONDITIONS[k][:priority]}
  189.   end
  190.   #-----------------------------------------------------------------------------
  191.   # Tone Phase
  192.   #-----------------------------------------------------------------------------
  193.   def tone_phase
  194.     return @tone_phases.last
  195.   end
  196.   #-----------------------------------------------------------------------------
  197.   # Tone Phase ?
  198.   #-----------------------------------------------------------------------------
  199.   def tone_phase?(key)
  200.     return TPS_PHASES::CONDITIONS[key] && phase_active?(key)
  201.   end
  202.   #-----------------------------------------------------------------------------
  203.   # Get Tone
  204.   #-----------------------------------------------------------------------------
  205.   def get_tone
  206.     if $imported[:e222_tps_phases] && tone_phase
  207.       return phase_tone if phase_tone
  208.       return TPS_TINT::DEFAULT[@current_period]
  209.     else
  210.       return TPS_TINT::DEFAULT[@current_period]
  211.     end
  212.   end
  213.   #-----------------------------------------------------------------------------
  214.   # Phase Tone
  215.   #-----------------------------------------------------------------------------
  216.   def phase_tone
  217.     return TPS_TINT::PHASES[tone_phase][@current_period]
  218.   end
  219.   #-----------------------------------------------------------------------------
  220. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  221. # Tint Script Calls:
  222. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  223.   #-----------------------------------------------------------------------------
  224.   # Stop Tint
  225.   #-----------------------------------------------------------------------------
  226.   def stop_tint
  227.     @tint_screen = false
  228.   end
  229.   #-----------------------------------------------------------------------------
  230.   # Resume Tine
  231.   #-----------------------------------------------------------------------------
  232.   def resume_tint
  233.     @tint_screen = true
  234.     refresh_period
  235.   end
  236.   #-----------------------------------------------------------------------------
  237. end
  238. #===============================================================================
  239. # Game_Troop
  240. #   new method: set_screen_tone
  241. #===============================================================================
  242. class Game_Troop
  243.   #-----------------------------------------------------------------------------
  244.   # Set Screen Tone
  245.   #-----------------------------------------------------------------------------
  246.   def set_screen_tone(tone, fade_time)
  247.     screen.start_tone_change(Tone.new(*tone), fade_time)  
  248.   end
  249.   #-----------------------------------------------------------------------------
  250. end
  251. #===============================================================================
  252. # Window_TimePopUp
  253. #   new method: set_screen_tone
  254. #===============================================================================
  255. class Game_Map
  256.   #-----------------------------------------------------------------------------
  257.   # Set Screen Tone
  258.   #-----------------------------------------------------------------------------
  259.   def set_screen_tone(tone, fade_time)
  260.     if TPS_TINT::USE_KHAS_TINTING
  261.       if fade_time <= 0
  262.         @effect_surface.set_alpha(tone[3])
  263.         @effect_surface.set_color(tone[0], tone[1], tone[2])
  264.       else
  265.         @effect_surface.change_color(fade_time, *tone)
  266.       end
  267.     else
  268.       screen.start_tone_change(Tone.new(*tone), fade_time)
  269.     end  
  270.   end
  271.   #-----------------------------------------------------------------------------
  272. end
  273. #===============================================================================
  274. # SCRIPT END
  275. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement