=begin
**************************************************
CUSTOMIZATION
**************************************************
WINDOW_POS:
Specify in which corner you'd like the time window to appear
1 = upper left
2 = upper right
3 = lower left
4 = lower right
Default: 4 (lower right)
(note that if your game is using a resolution other than 640x480,
which is the RMXP default game resolution, this will not work properly)
POSTALITY_KNIGHT:
Set it to true if you're using RMXP Postality Knight Edition
Set it to false if you're using original RMXP 1.0.2 to prevent errors
Default: false
OPACITY:
In case you want to set the window opacity, specify it here
Range: 0 (transparent) to 255 (opaque)
Default: 255
WINDOWSKIN (not tested, but hope works):
If you want to change the windowskin to be different than others,
you can specify it here
Default: 001-Blue01
=end
WINDOW_POS = 4
POSTALITY_KNIGHT = false
OPACITY = 255
WINDOWSKIN = "001-Blue01"
# CUSTOMIZATION ENDS HERE
class Game_Time
attr_accessor :timestr, :monthstr, :datestr
alias time_initialize initialize
def initialize
get_time_string
end
def get_time_string
@timestr = Time.now.strftime("%I:%M %p")
@monthstr = Time.now.strftime("%A")
@datestr = Time.now.strftime("%b %d")
# using "st", "nd", "rd", or "th"?
datenow = Time.now.day
case datenow
when 1, 21, 31
daysuffix = "st"
when 2, 22
daysuffix = "nd"
when 3, 23
daysuffix = "rd"
else
daysuffix = "th"
end
# now combine date with its suffix
@datestr += daysuffix
end
end
class Window_Time < Window_Base
#--------------------------------------------------------------------------
def initialize
case WINDOW_POS
when 1 #upper left
x, y, width, height = 0, 0, 320, 64
when 2 #upper right
x, y, width, height = 320, 0, 320, 64
when 3 #lower left
x, y, width, height = 0, 416, 320, 64
when 4 #lower right
x, y, width, height = 320, 416, 320, 64
end
super(x, y, width, height)
self.windowskin = RPG::Cache.windowskin(WINDOWSKIN)
self.contents = Bitmap.new(width - 32, height - 32)
if POSTALITY_KNIGHT
self.contents.font.name = $defaultfonttype # "Time" window font
self.contents.font.size = $defaultfontsize
end
self.opacity = OPACITY
refresh
end
#--------------------------------------------------------------------------
def refresh
$game_time.get_time_string
@minute=$game_time.minutess
self.contents.clear
@total_sec = Graphics.frame_count / Graphics.frame_rate
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, 92, 32, $game_time.timestr)
self.contents.draw_text(96, 0, 92, 32, $game_time.monthstr)
self.contents.draw_text(192, 0, 92, 32, $game_time.datestr)
end
#--------------------------------------------------------------------------
def update
$game_time.get_time
if $game_time.minutess != @minute
refresh
end
end
end
class Scene_Map
alias time_main main
def main
@time_window = Window_Time.new
time_main
@time_window.dispose
end
alias time_update update
def update
@time_window.update
time_update
end
end