Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # ***TPS-Addon: Period Pop-Up***
- #
- # Author: eugene222 (Evgenij)
- # Version: 1.3
- # Date: 01.09.2014
- # Requires: Time and Period System V 1.2 by eugene222
- #===============================================================================
- # Changelog:
- #
- # 03.04.2014 - V. 1.0-alpha1 - script created
- # 05.04.2014 - V. 1.0 - released script
- # 09.04.2014 - V. 1.1 - made this compatible with Core 1.1
- # 15.05.2014 - V. 1.2 - code optimized
- # 01.09.2014 - V. 1.3 - added custom position
- #
- #===============================================================================
- # Terms of Use:
- # You can use this script for free and commercial projects as long as you give
- # credits.
- #===============================================================================
- # Beschreibung:
- # When a new period starts, there will be a popup similiar to the mapname which
- # shows the new period.
- #
- # Scriptcalls:
- # $game_time.enable_popup # Enable Popup
- # $game_time_disable_popup # Disable Popup
- #
- #===============================================================================
- module TPS_POPUP_CONFIG
- #-----------------------------------------------------------------------------
- # PopUp show in <indoor> maps?
- #-----------------------------------------------------------------------------
- SHOW_INDOOR_POPUP = false
- #-----------------------------------------------------------------------------
- # How long should the popup last? (In Frames)
- #-----------------------------------------------------------------------------
- ANIMATION_COUNT = 120
- #-----------------------------------------------------------------------------
- # :left, :mid, :right
- # or you can use an array like this: POSITION = [x, y] if you want custom position
- #-----------------------------------------------------------------------------
- POSITION = :right
- #-----------------------------------------------------------------------------
- # The Graphic of the background need to be in the Graphics\System Folder
- # The size should be 240px x 48px.
- #-----------------------------------------------------------------------------
- USE_CUSTOM_BACKGROUND = false
- CUSTOM_BACKGROUND = "popup_bg"
- #-----------------------------------------------------------------------------
- # Disable PopUps for certain periods?
- #-----------------------------------------------------------------------------
- DISABLE_POPUP_FOR = [ # Diese Zeile nicht verändern!
- :noon,
- #-----------------------------------------------------------------------------
- ] # Diese Zeile nicht verändern!
- #-----------------------------------------------------------------------------
- end
- #===============================================================================
- # END OF CONFIG
- #===============================================================================
- $imported ||= {}
- $imported[:e222_tps_popup] = 1.2
- unless $imported[:e222_tps_core]
- msgbox("\"TBS-Addon: Period Pop-Up\" requires the \"TBS-Core\" script.\n"+
- "The \"TBS-Core\" script must be placed above the addon script.")
- exit
- end
- #===============================================================================
- # Game_Time
- # aliased methods: initialize, set_period
- # new methods: enable_popup, disable_popup
- #===============================================================================
- class Game_Time
- #-----------------------------------------------------------------------------
- attr_accessor :start_popup
- #-----------------------------------------------------------------------------
- # Initialize
- #-----------------------------------------------------------------------------
- alias :tps_pp_reinitialize_e222 :reinitialize
- def reinitialize
- tps_pp_reinitialize_e222
- @start_popup = false if @start_popup.nil?
- @popup_enabled = true if @popup_enabled.nil?
- end
- #-----------------------------------------------------------------------------
- # Refresh Period
- #-----------------------------------------------------------------------------
- alias :tps_pp_refresh_period_e222 :refresh_period
- #-----------------------------------------------------------------------------
- def refresh_period
- tps_pp_refresh_period_e222
- if popup_period? && @popup_enabled && show_indoor_popup?
- @start_popup = true
- end
- end
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # Boolean Methods:
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #-----------------------------------------------------------------------------
- # Show Indoor PopUp?
- #-----------------------------------------------------------------------------
- def show_indoor_popup?
- $game_map.indoor? ? TPS_POPUP_CONFIG::SHOW_INDOOR_POPUP : true
- end
- #-----------------------------------------------------------------------------
- # PopUp Period?
- #-----------------------------------------------------------------------------
- def popup_period?
- !TPS_POPUP_CONFIG::DISABLE_POPUP_FOR.include?(@current_period)
- end
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # PopUp Script Calls:
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #-----------------------------------------------------------------------------
- # Enable PopUp
- #-----------------------------------------------------------------------------
- def enable_popup
- @popup_enabled = true
- end
- #-----------------------------------------------------------------------------
- # Disable PopUp
- #-----------------------------------------------------------------------------
- def disable_popup
- @popup_enabled = false
- end
- #-----------------------------------------------------------------------------
- end # /Game_Time
- #===============================================================================
- # Window_TimePopUp
- # new Class
- #===============================================================================
- class Window_TimePopUp < Window_Base
- #-----------------------------------------------------------------------------
- include TPS_POPUP_CONFIG
- #-----------------------------------------------------------------------------
- # Initialize
- #-----------------------------------------------------------------------------
- def initialize
- super(window_x, window_y, window_width, window_height)
- self.opacity = 0
- self.contents_opacity = 0
- @show_count = 0
- refresh
- end
- #-----------------------------------------------------------------------------
- # Window X
- #-----------------------------------------------------------------------------
- def window_x
- case POSITION
- when :mid
- Graphics.width / 2 - window_width / 2
- when :right
- Graphics.width - window_width - window_y
- else
- POS.is_a?(Array) ? POS.first : window_y
- end
- end
- #-----------------------------------------------------------------------------
- # Window Y
- #-----------------------------------------------------------------------------
- def window_y
- if POS.is_a?(Array)
- POS.last
- else
- USE_CUSTOM_BACKGROUND ? -12 : 0
- end
- end
- #-----------------------------------------------------------------------------
- # Window Height
- #-----------------------------------------------------------------------------
- def window_height
- USE_CUSTOM_BACKGROUND ? 72 : 48
- end
- #-----------------------------------------------------------------------------
- # Window Width
- #-----------------------------------------------------------------------------
- def window_width
- return 240
- end
- #-----------------------------------------------------------------------------
- # Rect For Text
- #-----------------------------------------------------------------------------
- def rect_for_text
- if USE_CUSTOM_BACKGROUND
- temp_rect = contents.rect.clone
- temp_rect.height = 24
- temp_rect.y += 12
- temp_rect
- else
- contents.rect
- end
- end
- #-----------------------------------------------------------------------------
- # Update
- #-----------------------------------------------------------------------------
- def update
- super
- if @show_count > 0
- update_fadein
- @show_count -= 1
- else
- update_fadeout
- end
- end
- #-----------------------------------------------------------------------------
- # * Update Fadein
- #-----------------------------------------------------------------------------
- def update_fadein
- self.contents_opacity += 16
- end
- #-----------------------------------------------------------------------------
- # * Update Fadeout
- #-----------------------------------------------------------------------------
- def update_fadeout
- self.contents_opacity -= 16
- end
- #-----------------------------------------------------------------------------
- # Open
- #-----------------------------------------------------------------------------
- def open
- refresh
- @show_count = ANIMATION_COUNT
- self.contents_opacity = 0
- self
- end
- #-----------------------------------------------------------------------------
- # Refresh
- #-----------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_background(contents.rect)
- draw_text(rect_for_text, $game_time.period_text, 1)
- end
- #-----------------------------------------------------------------------------
- # Draw Background
- #-----------------------------------------------------------------------------
- def draw_background(rect)
- if USE_CUSTOM_BACKGROUND
- create_custom_background(rect)
- else
- create_default_background(rect)
- end
- end
- #-----------------------------------------------------------------------------
- # Create Custom BG
- #-----------------------------------------------------------------------------
- def create_custom_background(rect)
- bitmap = Cache.system(CUSTOM_BACKGROUND)
- contents.blt(0,0, bitmap, bitmap.rect)
- end
- #-----------------------------------------------------------------------------
- # Create Default BG
- #-----------------------------------------------------------------------------
- def create_default_background(rect)
- temp_rect = rect.clone
- temp_rect.width /= 2
- contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
- temp_rect.x = temp_rect.width
- contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
- end
- #-----------------------------------------------------------------------------
- # * Back Color 1
- #-----------------------------------------------------------------------------
- def back_color1
- Color.new(0, 0, 0, 192)
- end
- #-----------------------------------------------------------------------------
- # * Back Color 2
- #-----------------------------------------------------------------------------
- def back_color2
- Color.new(0, 0, 0, 0)
- end
- #-----------------------------------------------------------------------------
- end
- #===============================================================================
- # Scene_Map
- # aliased methods: create_all_windows, update
- # new methods: create_time_popup_window, start_time_popup
- #===============================================================================
- class Scene_Map
- #-----------------------------------------------------------------------------
- # Create All Windows
- #-----------------------------------------------------------------------------
- alias :scene_map_create_all_windows_e222 :create_all_windows
- #-----------------------------------------------------------------------------
- def create_all_windows
- scene_map_create_all_windows_e222
- create_time_popup_window
- end
- #-----------------------------------------------------------------------------
- # * Create Time PopUp Window
- #-----------------------------------------------------------------------------
- def create_time_popup_window
- @time_popup_window = Window_TimePopUp.new
- end
- #-----------------------------------------------------------------------------
- # * Update
- #-----------------------------------------------------------------------------
- alias :scene_map_update_e222 :update
- def update
- scene_map_update_e222
- start_time_popup if $game_time.start_popup
- end
- #-----------------------------------------------------------------------------
- # * Start Time PopUp
- #-----------------------------------------------------------------------------
- def start_time_popup
- @time_popup_window.open
- $game_time.start_popup = false
- end
- #-----------------------------------------------------------------------------
- end
- #===============================================================================
- # SCRIPT END
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement