Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # * [ACE] PC Clock Display
- #===============================================================================
- # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
- # * Version: 1.5
- # * Updated: 21/10/2016
- # * Requires: -------
- #-------------------------------------------------------------------------------
- # * < Change Log >
- #-------------------------------------------------------------------------------
- # * Version 0.1 (04/02/2015)
- # - Initial release (Alpha version).
- # * Version 1.0 (04/02/2015)
- # - Increased efficiency of the update methods (performance fix).
- # - Added the clock for the menu.
- # - Added button trigger to hide/show the timer on the map.
- # - Added background image option for the map timer.
- # * Version 1.1 (05/02/2015)
- # - Removed some dead code bits.
- # - Added a script call to change the background image during the game.
- # * Version 1.2 (07/02/2015)
- # - Added compatibility for (Venka+Dekita)'s Resolution Selection script.
- # The resolution change will be recognized even if it is done with that
- # script, so you can use Graphics.width and Graphics.height in the position
- # settings, but in a different format. Read more at the settings.
- # * Version 1.3 (19/02/2015)
- # - Now you can show the full date and the name of the current day too.
- # Configurations for setting up your own date format.
- # - Text position options are added too.
- # * Version 1.4 (17/10/2016)
- # - Changed the visibility toggle switches to operate the opposite way.
- # Now when they are ON, the clock HUD is shown, otherwise it's hidden.
- # * Version 1.5 (21/10/2016)
- # - Reworked some code, fixed some descriptions.
- # - Compatibility with my Global Setting Addon for Yanfly's System Options.
- # You must update this script if you use the above mentioned script!
- #-------------------------------------------------------------------------------
- # * < Description >
- #-------------------------------------------------------------------------------
- # * This script makes a real-time clock (based on PC time) on the map HUD as
- # well as on the main menu scene.
- # * Visual settings can be changed easily, some of them even during the game.
- # * 12/24 hours format available and can be changed at will even during the game.
- # * Show/hide switch available, as well as a button trigger to toggle the timer.
- #-------------------------------------------------------------------------------
- # * < Script Calls >
- #-------------------------------------------------------------------------------
- # rtime_pos(x,y) - Changes the position of the map timer window.
- # rtime_color(color) - Changes the color of the timer text both for the map and
- # for the menu window.
- # Same rules apply for the color as in the script settings.
- # rtime_skin(skin) - Changes the windowskin used for the map window.
- # Same rules and same format as in the script settings.
- # rtime_back(img) - Changes the background used for the map window.
- # Same rules and same format as in the script settings.
- #-------------------------------------------------------------------------------
- # * < Installation >
- #-------------------------------------------------------------------------------
- # * Place this script below Materials but above Main!
- # * If you will use my YF System Options Addon script too, you will need to put
- # this script above Yanfly's System Options and above my addon script also!
- #-------------------------------------------------------------------------------
- # * < Compatibility Info >
- #-------------------------------------------------------------------------------
- # * No known incompatibilities.
- #-------------------------------------------------------------------------------
- # * < Known Issues >
- #-------------------------------------------------------------------------------
- # * No known issues.
- #-------------------------------------------------------------------------------
- # * < Terms of Use >
- #-------------------------------------------------------------------------------
- # * Free to use for whatever purposes you want.
- # * Credit me (Sixth) in your game, pretty please! :P
- # * Posting modified versions of this script is allowed as long as you notice me
- # about it with a link to it!
- #===============================================================================
- $imported = {} if $imported.nil?
- $imported["SixthPCTimerDisplay"] = true
- #===============================================================================
- # Settings:
- #===============================================================================
- module Sixth_RTime_HUD
- #-----------------------------------------------------------------------------
- # Window Setup (Map HUD):
- #-----------------------------------------------------------------------------
- # :pos = The position of the window. Format: [x,y].
- # - Extra options (only effective for the map HUD timer!):
- # 1. If you want to use Graphics.width or Graphics.height in the position
- # setup, you will need to put the x or y value you have set up in an array,
- # and the value you set up in the array will be added to Graphics.width or
- # Graphics.height respectively. So if you want to position the window to the
- # top right corner, the setup would look like this:
- # :pos => [[-150],0],
- # The value used (150) is the width of the timer window, and minus, because
- # we want that much subtracted from Graphics.width.
- # 2. If you want to center the window depending on the resolution of the game,
- # you simply need to set :center to the value of X and Y position, like this:
- # :pos => [:center,[-48]],
- # This will put the window to the bottom of the game screen and will be
- # centered horizontally.
- # :size = The size of the window. Format: [width,height].
- # :skin = The windowskin used for the window.
- # The windowskin image must be in /Graphics/System/ folder.
- # :opacity = The opacity of the window shown.
- # Valid values: 0-255.
- # :z = The z value of the window.
- #-----------------------------------------------------------------------------
- Window_Setup_Map = { # <-- No touchy-touchy!
- :pos => [0,0],
- :size => [160,96],
- :skin => "Window",
- :opacity => 255,
- :z => 200,
- } # <-- No touchy-touchy!
- #-----------------------------------------------------------------------------
- # Background Setup (Map HUD):
- #-----------------------------------------------------------------------------
- # :enable = Enable/disable the background feature here.
- # true = enabled, false = disabled.
- # :graphic = The file name of the image used for the background.
- # The images used must be in /Graphics/Pictures/ folder!
- # :offset = The offset values for X and Y positions relative to the window's
- # position.
- # :opacity = The opacity of the background image.
- # :z = The z value of the background image.
- # Should be smaller than the z value of the window!
- #-----------------------------------------------------------------------------
- BackImg_Map = { # <-- No touchy-touchy!
- :enable => false,
- :graphic => "timerbackv1",
- :offset => [0,0],
- :opacity => 255,
- :z => 199,
- } # <-- No touchy-touchy!
- #-----------------------------------------------------------------------------
- # Window Setup (Menu):
- #-----------------------------------------------------------------------------
- # The settings are the same as for the on-map window.
- # The y position is rigged, the window will always appear below the command
- # window, so the setup for that one is not relevant here.
- # Additional setting:
- # :enable = Set it to true to show the time window in the main menu.
- # Set it to false to disable the time window in the main menu.
- #-----------------------------------------------------------------------------
- Window_Setup_Menu = { # <-- No touchy-touchy!
- :enable => true,
- :pos => [0,192],
- :size => [160,96],
- :skin => "Window",
- :opacity => 255,
- :z => 200,
- } # <-- No touchy-touchy!
- #-----------------------------------------------------------------------------
- # Text Settings:
- #-----------------------------------------------------------------------------
- # Adjust the general properties of the font used in the timer windows here.
- # You can also adjust the positions of each data displayed in the window.
- #
- # The :general settings will adjust the font used for the windows.
- #
- # :color = The color of the font. Use an integer number to get the color from
- # the windowskin, use an array of 4 numbers to get the color from an
- # RGBA value (red, green, blue, alpha (opacity)).
- # :size = The size of the text.
- # :font = The font type used for the text.
- # :align = The alignment used for the text in the window.
- #
- # The :time setup will adjust the position of the time display in the windows.
- # The :date setup will adjust the position of the date display in the windows.
- # The :day setup will adjust the position of the day display in the windows.
- #
- # The :time, :date and :day settings all got the same format.
- #
- # :pos => [x,y],
- # The X and Y position of the text in the window.
- #
- # :size => [width,height],
- # The reserved width and height for the text in the window.
- #
- # :align => value,
- # The alignment of the text inside the window.
- # 0 = left, 1 = middle, 2 = right.
- #-----------------------------------------------------------------------------
- Text_Setup = { # <-- No touchy-touchy!
- :general => {:color => 17, :size => 24, :font => ["Monotype Corsiva","Arial"]},
- :time => {:pos => [0, 0], :size => [136,24], :align => 1},
- :date => {:pos => [0,24], :size => [136,24], :align => 1},
- :day => {:pos => [0,48], :size => [136,24], :align => 1},
- } # <-- No touchy-touchy!
- #-----------------------------------------------------------------------------
- # Date Format Settings:
- #-----------------------------------------------------------------------------
- # These are the settings for the format of the date.
- # You got several options for each settings:
- #
- # :day => format,
- # The format of the day displayed. Can be:
- # "%A" = Displays the full name of the current day (Monday,Tuesday,etc).
- # "%a" = Displays the short name of the current day (Mon,Tue,etc).
- # This affects the separate day name display, not the day display in the date!
- #
- # :month => format,
- # The format of the month displayed. Can be:
- # "%B" = Displays the full name of the current month (January,February,etc).
- # "%b" = Displays the short name of the current month (Jan,Feb,etc).
- # "%m" = Displays the current month in numbers (1,2,etc).
- #
- # :year => format,
- # The format of the year displayed. Can be:
- # "%Y" = Displays the year with 4 digits (2014,2015,etc).
- # "%y" = Displays the year with 2 digits (14,15,etc).
- #
- # :after => ["text1","text2","text3"],
- # The texts displayed after the day, month and year.
- # So, you can end up with a date display like these:
- # - 19.02.2015.
- # - 19. February 2015.
- # - 19/02/'15
- # And so on.
- # The 1st text goes after the first data displayed, the 2nd goes after the 2nd,
- # and the 3rd goes after the 3rd.
- #-----------------------------------------------------------------------------
- Date_Format = { # <-- No touchy-touchy!
- :day => "%A", # %a or %A
- :month => "%b", # %b or %B or %m
- :year => "%Y", # %y or %Y
- :after => [". "," ","."],
- } # <-- No touchy-touchy!
- #-----------------------------------------------------------------------------
- # Date Display Order Settings:
- #-----------------------------------------------------------------------------
- # You can setup the order of the displayed data for the date here.
- # You can choose to show only the day and month, or you can choose to show all
- # but with a different order.
- # It should be obvious what the symbols do in the below array, so I won't
- # explain them.
- # The order how you arrange them here will be the display order used in the
- # window. You can remove some of them if you want too.
- #-----------------------------------------------------------------------------
- Date_Arrange = [:day,:month,:year]
- #-----------------------------------------------------------------------------
- # Switch Settings:
- #-----------------------------------------------------------------------------
- # Switch used to control the format of the time in the game.
- Format_Switch = 33 # ON = 24-hour, OFF = 12-hour.
- # Switch used to toggle the timer window's visibility in the game.
- Enable_Switch_Map = 134 # For the map window. ON = enabled, OFF = disabled.
- Enable_Switch_Menu = 135 # For the menu window. ON = enabled, OFF = disabled.
- #-----------------------------------------------------------------------------
- # Button Settings:
- #-----------------------------------------------------------------------------
- # Button trigger for showing/hiding the timer display on the map.
- # Use nil to disable it!
- #-----------------------------------------------------------------------------
- ShowHide_Button = :CTRL
- end # <-- No touchy-touchy!
- #===============================================================================
- # End of Settings! Editing anything below may lead to... You know what, right?
- #===============================================================================
- class Game_Interpreter
- def rtime_pos(x,y)
- $game_system.rtime_pos = [x,y]
- end
- def rtime_color(color)
- $game_system.rtime_color = color
- end
- def rtime_skin(skin)
- $game_system.rtime_skin = skin
- end
- def rtime_back(img)
- $game_system.rtime_back = img
- end
- end
- class Game_System
- attr_accessor :rtime_pos, :rtime_color, :rtime_skin, :rtime_back
- def rtime_pos
- @rtime_pos = Sixth_RTime_HUD::Window_Setup_Map[:pos] if @rtime_pos.nil?
- return @rtime_pos
- end
- def rtime_color
- @rtime_color = Sixth_RTime_HUD::Text_Setup[:general][:color] if @rtime_color.nil?
- return @rtime_color
- end
- def rtime_skin
- @rtime_skin = Sixth_RTime_HUD::Window_Setup_Map[:skin] if @rtime_skin.nil?
- return @rtime_skin
- end
- def rtime_back
- @rtime_back = Sixth_RTime_HUD::BackImg_Map[:graphic] if @rtime_back.nil?
- return @rtime_back
- end
- end
- class Scene_Map < Scene_Base
- alias sixth_rtimehud1222 create_all_windows
- def create_all_windows
- sixth_rtimehud1222
- create_rtime_window
- create_rtime_window_background if Sixth_RTime_HUD::BackImg_Map[:enable] == true
- end
- def create_rtime_window
- @rtime = Window_RTime.new
- @rtime.z = Sixth_RTime_HUD::Window_Setup_Map[:z]
- @hidden = $game_switches[Sixth_RTime_HUD::Enable_Switch_Map]
- @rtime.visible = @hidden
- end
- def create_rtime_window_background
- @rtback = Sprite.new
- @rtback.bitmap = Cache.picture($game_system.rtime_back)
- @rtback.x = @rtime.x + Sixth_RTime_HUD::BackImg_Map[:offset][0]
- @rtback.y = @rtime.y + Sixth_RTime_HUD::BackImg_Map[:offset][1]
- @rtback.opacity = Sixth_RTime_HUD::BackImg_Map[:opacity]
- @rtback.z = Sixth_RTime_HUD::BackImg_Map[:z]
- @rtback.visible = @hidden
- end
- alias sixth_rtimeupdate2231 update
- def update
- sixth_rtimeupdate2231
- update_rtime_changes
- end
- def update_rtime_changes
- if Input.trigger?(Sixth_RTime_HUD::ShowHide_Button)
- $game_switches[Sixth_RTime_HUD::Enable_Switch_Map] =
- !$game_switches[Sixth_RTime_HUD::Enable_Switch_Map]
- end
- if @hidden != $game_switches[Sixth_RTime_HUD::Enable_Switch_Map]
- @hidden = $game_switches[Sixth_RTime_HUD::Enable_Switch_Map]
- @rtime.visible = @hidden
- @rtback.visible = @hidden if @rtback
- end
- end
- alias sixth_rtime_disp1334 dispose_spriteset
- def dispose_spriteset
- if @rtback
- @rtback.bitmap.dispose
- @rtback.dispose
- end
- sixth_rtime_disp1334
- end
- end
- class Scene_Menu < Scene_MenuBase
- alias sixth_rtime_start1112 start
- def start
- sixth_rtime_start1112
- create_rtime_window if Sixth_RTime_HUD::Window_Setup_Menu[:enable]
- end
- def create_rtime_window
- if $game_switches[Sixth_RTime_HUD::Enable_Switch_Menu]
- @rtimer = Window_RTime_Menu.new
- @rtimer.y = @command_window.y + @command_window.height
- @rtimer.z = Sixth_RTime_HUD::Window_Setup_Menu[:z]
- end
- end
- end
- class Window_Base < Window
- def get_color_sixth(color)
- if color.is_a?(Integer)
- return text_color(color)
- else
- return Color.new(*color)
- end
- end
- def change_the_font(type,size)
- contents.font.name = type
- contents.font.size = size
- end
- end
- class Window_RTime < Window_Base
- include Sixth_RTime_HUD
- def initialize
- pos = $game_system.rtime_pos; size = Window_Setup_Map[:size]
- if pos[0] == :center
- x = (Graphics.width-Window_Setup_Map[:size][0])/2
- else
- x = pos[0].is_a?(Array) ? Graphics.width+pos[0][0] : pos[0]
- end
- if pos[1] == :center
- y = (Graphics.height-Window_Setup_Map[:size][1])/2
- else
- y = pos[1].is_a?(Array) ? Graphics.height+pos[1][0] : pos[1]
- end
- super(x,y,size[0],size[1])
- self.windowskin = Cache.system($game_system.rtime_skin)
- self.opacity = Window_Setup_Map[:opacity]
- @timr = Time.now.sec
- refresh
- end
- def refresh
- contents.clear
- t = Time.now
- change_color(get_color_sixth($game_system.rtime_color))
- change_the_font(Text_Setup[:general][:font],Text_Setup[:general][:size])
- if $game_switches[Format_Switch] == true
- txt1 = "#{t.strftime("%H")}:#{t.strftime("%M")}:#{t.strftime("%S")}"
- else
- txt1 = "#{t.strftime("%I")}:#{t.strftime("%M")}:#{t.strftime("%S")} #{t.strftime("%p")}"
- end
- txt2 = "#{t.strftime(Date_Format[:day])}"
- txt3 = ""
- Date_Arrange.each_with_index do |d,i|
- case d
- when :day
- txt3 += "#{t.strftime("%d")}"
- when :month
- txt3 += "#{t.strftime(Date_Format[:month])}"
- when :year
- txt3 += "#{t.strftime(Date_Format[:year])}"
- end
- txt3 += Date_Format[:after][i]
- end
- p1 = Text_Setup[:time][:pos]; p2 = Text_Setup[:date][:pos]; p3 = Text_Setup[:day][:pos]
- s1 = Text_Setup[:time][:size]; s2 = Text_Setup[:date][:size]; s3 = Text_Setup[:day][:size]
- draw_text(p1[0],p1[1],s1[0],s1[1],txt1,Text_Setup[:time][:align])
- draw_text(p2[0],p2[1],s2[0],s2[1],txt3,Text_Setup[:date][:align])
- draw_text(p3[0],p3[1],s3[0],s3[1],txt2,Text_Setup[:day][:align])
- end
- def update
- super
- update_rtimer if @timr != Time.now.sec
- end
- def update_rtimer
- refresh
- @timr = Time.now.sec
- end
- end
- class Window_RTime_Menu < Window_Base
- include Sixth_RTime_HUD
- def initialize
- pos = Window_Setup_Menu[:pos]; size = Window_Setup_Menu[:size]
- super(pos[0],pos[1],size[0],size[1])
- self.windowskin = Cache.system(Window_Setup_Menu[:skin])
- self.opacity = Window_Setup_Menu[:opacity]
- @timr = Time.now.sec
- refresh
- end
- def refresh
- contents.clear
- t = Time.now
- change_color(get_color_sixth($game_system.rtime_color))
- change_the_font(Text_Setup[:general][:font],Text_Setup[:general][:size])
- if $game_switches[Format_Switch] == true
- txt1 = "#{t.strftime("%H")}:#{t.strftime("%M")}:#{t.strftime("%S")}"
- else
- txt1 = "#{t.strftime("%I")}:#{t.strftime("%M")}:#{t.strftime("%S")} #{t.strftime("%p")}"
- end
- txt2 = "#{t.strftime(Date_Format[:day])}"
- txt3 = ""
- Date_Arrange.each_with_index do |d,i|
- case d
- when :day
- txt3 += "#{t.strftime("%d")}"
- when :month
- txt3 += "#{t.strftime(Date_Format[:month])}"
- when :year
- txt3 += "#{t.strftime(Date_Format[:year])}"
- end
- txt3 += Date_Format[:after][i]
- end
- p1 = Text_Setup[:time][:pos]; p2 = Text_Setup[:date][:pos]; p3 = Text_Setup[:day][:pos]
- s1 = Text_Setup[:time][:size]; s2 = Text_Setup[:date][:size]; s3 = Text_Setup[:day][:size]
- draw_text(p1[0],p1[1],s1[0],s1[1],txt1,Text_Setup[:time][:align])
- draw_text(p2[0],p2[1],s2[0],s2[1],txt3,Text_Setup[:date][:align])
- draw_text(p3[0],p3[1],s3[0],s3[1],txt2,Text_Setup[:day][:align])
- end
- def update
- return if self.disposed?
- super
- update_rtimer if @timr != Time.now.sec
- end
- def update_rtimer
- refresh
- @timr = Time.now.sec
- end
- end
- #==============================================================================
- # !!END OF SCRIPT - OHH, NOES!!
- #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement