Advertisement
Dekita

rtmw

Dec 24th, 2012
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.59 KB | None | 0 0
  1. =begin =========================================================================
  2. Dekita's v1.0
  3. ★ Real Time Menu Window™ ★
  4.  
  5. ================================================================================
  6. Script Information:
  7. ====================
  8. This script is a simple script to show the current time in the main menu
  9. Place this below any script that heavily modifies Scene_Menu.
  10.  
  11. ================================================================================
  12. ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  13. ================================================================================
  14. 1. You must give credit to "Dekita"
  15. 2. You are NOT allowed to repost this script.(or modified versions)
  16. 3. You are NOT allowed to convert this script.(into other game engines e.g RGSS2)
  17. 4. You are NOT allowed to use this script for Commercial games.
  18. 5. ENJOY!
  19.  
  20. "FINE PRINT"
  21. By using this script you hereby agree to the above terms and conditions,
  22. if any violation of the above terms occurs "legal action" may be taken.
  23. Not understanding the above terms and conditions does NOT mean that
  24. they do not apply to you.
  25. If you wish to discuss the terms and conditions in further detail you can
  26. contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com
  27.  
  28. ================================================================================
  29. History:
  30. =========
  31. D /M /Y
  32. 15/12/2o12 - started and finished,
  33.  
  34. ================================================================================
  35. Credit and Thanks to :
  36. =======================
  37.  
  38. ================================================================================
  39. Known Bugs:
  40. ============
  41. N/A
  42.  
  43. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  44. If a new bug is found please contact me at
  45. http://dekitarpg.wordpress.com/
  46.  
  47. ================================================================================
  48. INSTRUCTIONS:
  49. ==============
  50. Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  51.  
  52. =end #==========================================================================#
  53. module Dekita__Real_Time
  54.  
  55. Time_Vocab = "Time"
  56.  
  57. Time_Mode = 3
  58. # 0 = Hour : Minutes (12 hour clock)
  59. # 1 = Hour : minutes (24 hour clock)
  60. # 2 = Hour : Minutes : Seconds (12 hour clock)
  61. # 3 = Hour : Minutes : Seconds (24 hour clock)
  62. # NOTE : 12 hour clock will show am/pm.
  63.  
  64. end
  65.  
  66. $imported = {} if $imported.nil?
  67. $imported[:Dekita_RealTime_Menu_Window] = true
  68.  
  69. #==============================================================================
  70. class Window_Game_Time < Window_Base
  71. #==============================================================================
  72.  
  73. include Dekita__Real_Time
  74.  
  75. def initialize
  76. super(0, 0, window_width, fitting_height(1))
  77. refresh
  78. get_time_settings
  79. end
  80.  
  81. def get_time_settings
  82. tn = Time.now
  83. t1 = Time_Mode == 0 || 2 ? tn.strftime("%I") : tn.strftime("%H")
  84. @curr_time = [t1,tn.strftime("%M"),tn.strftime("%S")]
  85. end
  86.  
  87. def window_width
  88. return $imported[:Dekita_Pokemon_Menu] ? 120 : 160
  89. end
  90.  
  91. def refresh
  92. contents.clear
  93. draw_current_time(value, time_vocab, 0, 0, window_width - 24)
  94. end
  95.  
  96. def draw_current_time(value, unit, x, y, width)
  97. contents.font.size = Pokemon_MENU::Font_Size - 2 if $imported[:Dekita_Pokemon_Menu]
  98. change_color(normal_color)
  99. draw_text(x, y, width, line_height, value, 2)
  100. change_color(system_color)
  101. draw_text(x, y, width, line_height, unit)
  102. end
  103.  
  104. def value
  105. pm_am = Time.now.strftime("%p") == "PM" ? "pm" : "am"
  106. tn = Time.now
  107. case Time_Mode
  108. when 0
  109. time_text = "#{tn.strftime("%I")}:#{tn.strftime("%M")}#{pm_am}"
  110. when 1
  111. time_text = "#{tn.strftime("%H")}:#{tn.strftime("%M")}"
  112. when 2
  113. time_text = "#{tn.strftime("%I")}:#{tn.strftime("%M")}:#{tn.strftime("%S")}#{pm_am}"
  114. when 3
  115. time_text = "#{tn.strftime("%H")}:#{tn.strftime("%M")}:#{tn.strftime("%S")}"
  116. end
  117. return time_text
  118. end
  119.  
  120. def time_vocab
  121. return Time_Vocab
  122. end
  123.  
  124. def open
  125. refresh
  126. super
  127. end
  128.  
  129. def update
  130. super
  131. update_time
  132. end
  133.  
  134. def update_time
  135. case Time_Mode
  136. when 0, 1
  137. id = 0 ; val = Time.now.strftime("%M")
  138. when 2, 3
  139. id = 2 ; val = Time.now.strftime("%S")
  140. end
  141. refresh if @curr_time[id] != val
  142. end
  143.  
  144. end
  145.  
  146. #==============================================================================
  147. class Scene_Menu < Scene_MenuBase
  148. #==============================================================================
  149.  
  150. alias startdetime_now! start
  151. def start
  152. startdetime_now!
  153. create_REALTIME_window
  154. end
  155.  
  156. def create_REALTIME_window
  157. gwh = Graphics.height - @gold_window.height
  158. @realtime_window = Window_Game_Time.new
  159. gww = Graphics.width - @realtime_window.width
  160. @realtime_window.x = $imported[:Dekita_Pokemon_Menu] ? gww : 0
  161. @realtime_window.y = $imported[:Dekita_Pokemon_Menu] ? gwh : gwh - @realtime_window.height
  162. end
  163.  
  164. end
  165.  
  166. #===============================================================================#
  167. # - SCRIPT END - #
  168. #===============================================================================#
  169. # http://dekitarpg.wordpress.com/ #
  170. #===============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement