查看: 2047|回复: 5

[有事请教] 请教大佬们,mz如何用脚本获取系统时间

[复制链接]
梦石
0
星屑
832
在线时间
105 小时
注册时间
2020-12-26
回帖
67
发表于 2022-4-29 11:08:34 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
请教大佬们,mz如何用脚本获取系统时间
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2022-4-29 11:25:16 | 显示全部楼层
//=============================================================================
// Chronus.js
// ----------------------------------------------------------------------------
// (C) 2015 Triacontane
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------

Chronus.js
  1. //=============================================================================
  2. // Chronus.js
  3. // ----------------------------------------------------------------------------
  4. // (C) 2015 Triacontane
  5. // This software is released under the MIT License.
  6. // [url]http://opensource.org/licenses/mit-license.php[/url]
  7. // ----------------------------------------------------------------------------
  8. // Version
  9. // 2.2.0 2021/07/15 アナログ時計の短針を24時間で1周するよう変更する機能を追加
  10. // 2.1.0 2020/11/21 自然時間加算間隔を変更するプラグインコマンドを追加
  11. // 2.0.2 2020/11/12 イベントコマンド『天候の設定』を実行するとエラーになる問題を修正
  12. // 2.0.1 2020/08/26 ベースプラグインの説明を追加
  13. // 2.0.0 2020/08/26 MZで動作するよう修正
  14. // 1.17.1 2020/05/17 まったく同じ時間にSET_TIMEしたとき翌日の同時刻になるよう仕様変更
  15. // 1.17.0 2020/04/12 累計日数をカレンダーに出力できる機能を追加、累計日数のカウントを1からに変更
  16. // 1.16.2 2019/11/17 1.15.0の修正以後、場所移動したときのタイルセット情報の取得が、移動前のものになっていた問題を修正
  17. // 1.16.1 2019/11/10 1.16.1で追加したアラーム機能で、アラームに設定した時間を超過して判定された場合、次回のインターバルが超過した時間からカウントされてしまう問題を修正
  18. // 1.16.0 2019/11/09 1.15.0で追加したアラーム機能にインターバル機能を追加
  19. // 1.15.0 2019/10/23 特定のゲーム内時刻になるとスイッチ操作されるアラーム機能を追加
  20. //                   タイルセット変更した場合に、新しいタイルセットの色調や天候有無の設定が反映されない問題を修正
  21. // 1.14.1 2019/10/17 ヘルプの記載漏れを修正
  22. // 1.14.0 2019/09/01 時間帯名称をカレンダーに表示する機能を追加
  23. // 1.13.1 2019/06/09 ニューゲーム時もしくはプロジェクト保存後のロード時に場所移動の時間が経過してしまう問題を修正
  24. // 1.13.0 2019/04/20 カレンダーを初期状態で非表示にできるパラメータを追加
  25. // 1.12.0 2018/12/27 カレンダー表示に行間を設定できる機能を追加
  26. // 1.11.1 2018/10/14 実時間表示に切り替えてから内部時間に反映されるまでにラグがある問題の修正
  27. // 1.11.0 2018/10/14 カレンダーの枠を非表示にできる機能を追加
  28. // 1.10.3 2018/10/08 プラグインコマンドで天候変化を無効にした場合でも、内部で制御している天候による色調の調整が反映されてしまう問題を修正
  29. // 1.10.2 2018/04/11 時間表示方法(実時間、ゲーム時間)を切り替えた直後に、時間変数の値が更新されない問題を修正
  30. // 1.10.1 2018/03/07 場所移動の際、移動先マップの色調有効フラグが異なっていた場合に、色調がリフレッシュされない問題を修正
  31. // 1.10.0 2018/02/24 日付フォーマットに基づいて計算した時間を変数に自動設定する機能を追加
  32. // 1.9.4 2018/02/19 カレンダーの初期表示をtrueに変更しました。
  33. // 1.9.3 2017/11/18 マップロード時に色調を時間に合わせて瞬間変更していた仕様を撤廃
  34. // 1.9.2 2017/11/02 イベント実行中に時間を変更した場合にアナログ時計の表示が変更されない問題を修正
  35. // 1.9.1 2017/11/02 時間経過の初期状態を「停止」から「開始」に変更
  36. // 1.9.0 2017/10/05 アナログ時計の画像を変更できる機能を追加
  37. //                  カレンダーウィンドウのフォントサイズと不透明度を変更できる機能を追加
  38. // 1.8.3 2017/07/18 タイマーの機能のプラグインコマンドに関する説明が一部間違っていた問題を修正
  39. // 1.8.2 2017/07/05 時間変動間隔を変更したときにアナログ時計が正しく表示されない問題を修正
  40. // 1.8.1 2017/06/29 1.8.0で追加した累計時間の初期化機能で、現在時間まで初期化されてしまう問題を修正
  41. // 1.8.0 2017/06/28 累計経過日数を格納するパラメータと、累計時間および日数を初期化できるプラグインコマンドを追加
  42. //                  パラメータの型指定に対応
  43. // 1.7.0 2017/06/01 実時間およびゲーム内時間と連動するタイマー機能を追加
  44. //                  時間が変動する間隔を自由に指定できる機能を追加
  45. // 1.6.0 2017/04/23 降雪マップをマップ単位でタイルセット単位で設定する機能を追加、降水確率を調整できる機能を追加
  46. // 1.5.0 2017/01/23 カレンダーに月名を表記する書式「MON」を追加
  47. // 1.4.0 2017/01/07 ゲーム開始からの累計時間(分単位)を指定したゲーム変数に格納する機能を追加
  48. // 1.3.3 2017/01/02 色調変更を禁止しているときにイベントで色調変更した場合、すぐにリセットされてしまう問題を修正
  49. // 1.3.2 2016/07/24 1.3.1でロード時にエラーになる問題の修正
  50. // 1.3.1 2016/07/23 イベント処理中の時間経過有無をイベントごとに設定できるよう変更
  51. //                  一部コードのリファクタリング
  52. // 1.3.0 2016/07/21 イベント処理中も時間が経過する設定を追加
  53. // 1.2.7 2016/07/10 自然時間加算が0の場合に色調や天候の変化が正しく行われない問題を修正
  54. // 1.2.6 2016/05/30 曜日に「Y」を含む文字列を指定できないバグを修正
  55. // 1.2.5 2016/04/29 createUpperLayerによる競合対策
  56. // 1.2.4 2016/03/13 アナログ時計を指定しないで起動した場合にエラーになる現象の修正
  57. // 1.2.3 2016/03/10 時間帯と時間帯ごとの色調をカスタマイズできるようにユーザ書き換え領域を作成
  58. // 1.2.2 2016/03/04 本体バージョン1.1.0の未使用素材の削除機能への対応
  59. // 1.2.1 2016/02/25 実時間表示設定でロードするとエラーが発生する現象の修正
  60. // 1.2.0 2016/02/14 アナログ時計の表示機能を追加
  61. //                  現実の時間を反映させる機能の追加
  62. // 1.1.3 2016/01/21 競合対策(YEP_MessageCore.js)
  63. // 1.1.2 2016/01/10 カレンダーウィンドウの表示位置をカスタマイズできる機能を追加
  64. // 1.1.1 2015/12/29 日の値に「1」を設定した場合に日付の表示がおかしくなる不具合を修正
  65. //                  一部コードのリファクタリング
  66. // 1.1.0 2015/12/01 天候と時間帯をゲーム変数に格納できるよう機能追加
  67. // 1.0.0 2015/11/27 初版
  68. // ----------------------------------------------------------------------------
  69. // [Blog]   : [url]https://triacontane.blogspot.jp/[/url]
  70. // [Twitter]: [url]https://twitter.com/triacontane/[/url]
  71. // [GitHub] : [url]https://github.com/triacontane/[/url]
  72. //=============================================================================

  73. /*:
  74. * @plugindesc ゲーム内時間の導入プラグイン
  75. * @target MZ
  76. * @url [url]https://github.com/triacontane/RPGMakerMV/tree/mz_master/Chronus.js[/url]
  77. * @base PluginCommonBase
  78. * @author トリアコンタン
  79. *
  80. * @param 月ごとの日数配列
  81. * @desc 各月の日数の配列です。カンマ区切りで指定してください。個数は自由です。
  82. * @default 31,28,31,30,31,30,31,31,30,31,30,31
  83. *
  84. * @param 月名配列
  85. * @desc 月の名称配列です。カンマ区切りで指定してください。個数は自由です。
  86. * @default Jan.,Feb.,Mar.,Apr.,May.,Jun.,Jul.,Aug.,Sep.,Oct.,Nov.,Dec.
  87. *
  88. * @param 曜日配列
  89. * @desc 曜日の名称配列です。カンマ区切りで指定してください。個数は自由です。
  90. * @default (日),(月),(火),(水),(木),(金),(土)
  91. *
  92. * @param 自然時間加算
  93. * @type number
  94. * @desc 1秒(自然時間加算間隔で指定した間隔)ごとに加算されるゲーム時間(分単位)の値です。イベント処理中は無効です。
  95. * @default 5
  96. *
  97. * @param 自然時間加算間隔
  98. * @type number
  99. * @desc ゲーム時間の自然加算が行われる間隔(フレーム数)です。1F=1/60秒
  100. * @default 60
  101. *
  102. * @param 場所移動時間加算
  103. * @type number
  104. * @desc 1回の場所移動で加算されるゲーム時間(分単位)の値です。
  105. * @default 30
  106. *
  107. * @param 戦闘時間加算(固定)
  108. * @type number
  109. * @desc 1回の戦闘で加算されるゲーム時間(分単位)の値です。
  110. * @default 30
  111. *
  112. * @param 戦闘時間加算(ターン)
  113. * @type number
  114. * @desc 1回の戦闘で消費したターン数ごとに加算されるゲーム時間(分単位)の値です。
  115. * @default 5
  116. *
  117. * @param 年のゲーム変数
  118. * @type variable
  119. * @desc 指定した番号のゲーム変数に「年」の値が自動設定されます。
  120. * @default 0
  121. *
  122. * @param 月のゲーム変数
  123. * @type variable
  124. * @desc 指定した番号のゲーム変数に「月」の値が自動設定されます。
  125. * @default 0
  126. *
  127. * @param 日のゲーム変数
  128. * @type variable
  129. * @desc 指定した番号のゲーム変数に「日」の値が自動設定されます。
  130. * @default 0
  131. *
  132. * @param 曜日IDのゲーム変数
  133. * @type variable
  134. * @desc 指定した番号のゲーム変数に「曜日」のIDが自動設定されます。
  135. * @default 0
  136. *
  137. * @param 曜日名のゲーム変数
  138. * @type variable
  139. * @desc 指定した番号のゲーム変数に「曜日」の名称が自動設定されます。
  140. * ゲーム変数に文字列が入るので注意してください。
  141. * @default 0
  142. *
  143. * @param 時のゲーム変数
  144. * @type variable
  145. * @desc 指定した番号のゲーム変数に「時」の値が自動設定されます。
  146. * @default 0
  147. *
  148. * @param 分のゲーム変数
  149. * @type variable
  150. * @desc 指定した番号のゲーム変数に「分」の値が自動設定されます。
  151. * @default 0
  152. *
  153. * @param 累計時間のゲーム変数
  154. * @type variable
  155. * @desc 指定した番号のゲーム変数に「累計時間」(分単位)の値が自動設定されます。
  156. * @default 0
  157. *
  158. * @param 累計日数のゲーム変数
  159. * @type variable
  160. * @desc 指定した番号のゲーム変数に「累計日数」の値が自動設定されます。
  161. * @default 0
  162. *
  163. * @param 時間帯IDのゲーム変数
  164. * @type variable
  165. * @desc 指定した番号のゲーム変数に「時間帯」のIDが自動設定されます。
  166. * 0:深夜 1:早朝 2:朝 3:昼 4:夕方 5:夜
  167. * @default 0
  168. *
  169. * @param 天候IDのゲーム変数
  170. * @type variable
  171. * @desc 指定した番号のゲーム変数に「天候」のIDが自動設定されます。
  172. * 0:なし 1:雨 2:嵐 3:雪
  173. * @default 0
  174. *
  175. * @param フォーマット時間の変数
  176. * @type variable
  177. * @desc 「フォーマット時間の計算式」に基づいて計算した結果が自動設定されます。
  178. * @default 0
  179. *
  180. * @param フォーマット時間の計算式
  181. * @desc 日時フォーマットを使った計算式の内容です。
  182. * YYYY:年 MON:月名 MM:月 DD:日 など(詳細はヘルプ参照)
  183. * @default HH24 * 60 + MI
  184. *
  185. * @param 日時フォーマット1
  186. * @desc マップ上の日付ウィンドウ1行目に表示される文字列です。
  187. * YYYY:年 MON:月名 MM:月 DD:日 など(詳細はヘルプ参照)
  188. * @default YYYY年 MM月 DD日 DY
  189. *
  190. * @param 日時フォーマット2
  191. * @desc マップ上の日付ウィンドウ2行目に表示される文字列です。
  192. * YYYY:年 MON:月名 MM:月 DD:日 など(詳細はヘルプ参照)
  193. * @default AMHH時 MI分
  194. *
  195. * @param 日時フォーマット行間
  196. * @type number
  197. * @desc カレンダー表示の行間です。
  198. * @default 0
  199. *
  200. * @param カレンダー表示X座標
  201. * @type number
  202. * @desc カレンダーの表示 X 座標です。
  203. * @default 0
  204. *
  205. * @param カレンダー表示Y座標
  206. * @type number
  207. * @desc カレンダーの表示 Y 座標です。
  208. * @default 0
  209. *
  210. * @param カレンダーフォントサイズ
  211. * @type number
  212. * @desc カレンダーのフォントサイズです。0を指定するとデフォルトとなります。
  213. * @default 0
  214. *
  215. * @param カレンダー不透明度
  216. * @type number
  217. * @desc カレンダーの背景の不透明度(0-255)です。
  218. * @default 192
  219. *
  220. * @param カレンダー枠の非表示
  221. * @type boolean
  222. * @desc カレンダーのウィンドウ枠を非表示にします。
  223. * @default false
  224. *
  225. * @param カレンダーの非表示
  226. * @type boolean
  227. * @desc カレンダーを非表示します。プラグインコマンドから表示できます。
  228. * @default false
  229. *
  230. * @param カレンダー余白
  231. * @type number
  232. * @desc カレンダーの余白(8-)です。
  233. * @default 8
  234. *
  235. * @param 文字盤画像ファイル
  236. * @desc アナログ時計を表示する場合の文字盤画像ファイル名(拡張子は不要)です。
  237. * 画像は「img/pictures/」以下に保存してください。
  238. * @default
  239. * @require 1
  240. * @dir img/pictures/
  241. * @type file
  242. *
  243. * @param 長針画像ファイル
  244. * @desc アナログ時計を表示する場合の長針画像ファイル名(拡張子は不要)です。
  245. * 画像は「img/pictures/」以下に保存してください。
  246. * @default
  247. * @require 1
  248. * @dir img/pictures/
  249. * @type file
  250. *
  251. * @param 短針画像ファイル
  252. * @desc アナログ時計を表示する場合の長針画像ファイル名(拡張子は不要)です。
  253. * 画像は「img/pictures/」以下に保存してください。
  254. * @default
  255. * @require 1
  256. * @dir img/pictures/
  257. * @type file
  258. *
  259. * @param 24hourClock
  260. * @text 24時間時計
  261. * @desc 有効にすると短針が24時間で1周する時計になります。
  262. * @default false
  263. * @type boolean
  264. *
  265. * @param 時計X座標
  266. * @type number
  267. * @desc アナログ時計の表示X座標です。画像の中心座標を指定してください。
  268. * @default 84
  269. *
  270. * @param 時計Y座標
  271. * @type number
  272. * @desc アナログ時計の表示Y座標です。画像の中心座標を指定してください。
  273. * @default 156
  274. *
  275. * @param イベント中時間経過
  276. * @desc イベント実行中も時間経過するようになります。(ON/OFF)
  277. * @default false
  278. * @type boolean
  279. *
  280. * @command ADD_TIME
  281. * @text 時間加算
  282. * @desc 指定した値(分単位)だけ時間が経過します。
  283. *
  284. * @arg time
  285. * @text 時間
  286. * @desc 加算する時間です。制御文字\v[n]を使う場合はテキストタブから入力してください。他の項目も同様
  287. * @default 0
  288. * @type number
  289. *
  290. * @command SET_TIME
  291. * @text 時間設定
  292. * @desc 指定した時間に変更します。
  293. *
  294. * @arg hour
  295. * @text 時間
  296. * @desc 設定する時間です。
  297. * @default 0
  298. * @type number
  299. * @min 0
  300. * @max 23
  301. *
  302. * @arg minute
  303. * @text 分
  304. * @desc 設定する分です。
  305. * @default 0
  306. * @type number
  307. * @min 0
  308. * @max 59
  309. *
  310. * @command ADD_DAY
  311. * @text 日付加算
  312. * @desc 指定した値(日単位)だけ日数が経過します。
  313. *
  314. * @arg day
  315. * @text 日数
  316. * @desc 加算する時間です。
  317. * @default 0
  318. * @type number
  319. *
  320. * @command SET_DAY
  321. * @text 日付設定
  322. * @desc 指定した日付に変更します。
  323. * @default 0
  324. * @type number
  325. *
  326. * @arg year
  327. * @text 年
  328. * @desc 設定する年です。
  329. * @default 1
  330. * @type number
  331. *
  332. * @arg month
  333. * @text 月
  334. * @desc 設定する月です。
  335. * @default 1
  336. * @type number
  337. *
  338. * @arg day
  339. * @text 日
  340. * @desc 設定する日です。
  341. * @default 1
  342. * @type number
  343. *
  344. * @command STOP
  345. * @text 時間停止
  346. * @desc 時間の進行を停止します。
  347. *
  348. * @command START
  349. * @text 時間開始
  350. * @desc 時間の進行を開始します。
  351. *
  352. * @command SHOW
  353. * @text カレンダー表示
  354. * @desc カレンダーを表示します。
  355. *
  356. * @command HIDE
  357. * @text カレンダー非表示
  358. * @desc カレンダーを非表示にします。
  359. *
  360. * @command DISABLE_TINT
  361. * @text 色調変化禁止
  362. * @desc 時間帯による色調の変更を禁止します。
  363. *
  364. * @command ENABLE_TINT
  365. * @text 色調変化許可
  366. * @desc 時間帯による色調の変更を許可します。
  367. *
  368. * @command DISABLE_WEATHER
  369. * @text 天候変化禁止
  370. * @desc 時間経過による天候の変化を禁止します。
  371. *
  372. * @command ENABLE_WEATHER
  373. * @text 天候変化許可
  374. * @desc 時間経過による天候の変化を許可します。
  375. *
  376. * @command SET_SNOW_LAND
  377. * @text 降雪地設定
  378. * @desc 悪天候時に雪が降るようになります。
  379. *
  380. * @command RESET_SNOW_LAND
  381. * @text 降雪地解除
  382. * @desc 悪天候時に雨もしくは嵐が降るようになります。
  383. *
  384. * @command RESET_SNOW_LAND
  385. * @text 降雪地解除
  386. * @desc 悪天候時に雨もしくは嵐が降るようになります。
  387. *
  388. * @command SET_SPEED
  389. * @text 速度設定
  390. * @desc 実時間1秒あたりの時間の経過速度を設定します。
  391. *
  392. * @arg speed
  393. * @text 速度
  394. * @desc 時間の経過速度です。
  395. * @default 1
  396. * @type number
  397. *
  398. * @command SET_AUTO_ADD_INTERVAL
  399. * @text 自然時間加算間隔設定
  400. * @desc 自然時間の加算間隔を変更します。
  401. *
  402. * @arg interval
  403. * @text 間隔フレーム数
  404. * @desc 自然時間の加算間隔フレーム数です。
  405. * @default 60
  406. * @type number
  407. *
  408. * @command SHOW_CLOCK
  409. * @text アナログ時計表示
  410. * @desc アナログ時計を表示します。
  411. *
  412. * @command HIDE_CLOCK
  413. * @text アナログ時計非表示
  414. * @desc アナログ時計を非表示にします。
  415. *
  416. * @command SET_TIME_REAL
  417. * @text 実時間表示
  418. * @desc 時間の取得方法を実時間に変更します。
  419. *
  420. * @command SET_TIME_VIRTUAL
  421. * @text 仮想時間表示
  422. * @desc 時間の取得方法をゲーム内時間に変更します。
  423. *
  424. * @command SET_RAINY_PERCENT
  425. * @text 降水確率設定
  426. * @desc 降水確率(0-100)を設定します。
  427. *
  428. * @arg percent
  429. * @text 確率
  430. * @desc 降水確率です。
  431. * @default 0
  432. * @type number
  433. * @max 100
  434. *
  435. * @command INIT_TOTAL_TIME
  436. * @text 累計時間初期化
  437. * @desc 累計時間、累計日数を初期化します。
  438. *
  439. * @command SET_CLOCK_IMAGE
  440. * @text 時計画像ファイル変更
  441. * @desc アナログ時計のファイルを変更します。実際に画像が変更されるのはマップを移動した後になります。
  442. *
  443. * @arg baseFileName
  444. * @text 文字盤画像のファイル名
  445. * @desc 文字盤画像のファイル名です。ピクチャから選択します。指定しなかった場合、変更されません。
  446. * @default
  447. * @type file
  448. * @dir img/pictures
  449. *
  450. * @arg hourFileName
  451. * @text 短針画像のファイル名
  452. * @desc 短針画像のファイル名です。ピクチャから選択します。指定しなかった場合、変更されません。
  453. * @default
  454. * @type file
  455. * @dir img/pictures
  456. *
  457. * @arg minuteFileName
  458. * @text 長針画像のファイル名
  459. * @desc 長針画像のファイル名です。ピクチャから選択します。指定しなかった場合、変更されません。
  460. * @default
  461. * @type file
  462. * @dir img/pictures
  463. *
  464. * @command SET_SWITCH_TIMER
  465. * @text スイッチタイマー設定
  466. * @desc 指定した時間経過後にスイッチをONにできます。
  467. *
  468. * @arg name
  469. * @text タイマー名称
  470. * @desc タイマーの識別子です。解除するときに必要になるので、解除したい場合は設定してください。
  471. * @default
  472. *
  473. * @arg timeout
  474. * @text 時間
  475. * @desc 時間切れまでの時間(分)です。
  476. * @default 1
  477. * @type number
  478. * @min 1
  479. *
  480. * @arg switchId
  481. * @text スイッチ番号
  482. * @desc ONにするスイッチ番号です。
  483. * @default 1
  484. * @type switch
  485. *
  486. * @arg loop
  487. * @text ループ有無
  488. * @desc タイマーをループさせるかどうかです。
  489. * @default false
  490. * @type boolean
  491. *
  492. * @command SET_SELF_SWITCH_TIMER
  493. * @text セルフスイッチタイマー設定
  494. * @desc 指定した時間経過後にスイッチをONにできます。
  495. *
  496. * @arg name
  497. * @text タイマー名称
  498. * @desc タイマーの識別子です。解除するときに必要になるので、解除したい場合は設定してください。
  499. * @default
  500. *
  501. * @arg timeout
  502. * @text 時間
  503. * @desc 時間切れまでの時間(分)です。
  504. * @default 1
  505. * @type number
  506. * @min 1
  507. *
  508. * @arg selfSwitchId
  509. * @text セルフスイッチ番号
  510. * @desc ONにするセルフスイッチ番号です。
  511. * @default A
  512. * @type select
  513. * @option A
  514. * @option B
  515. * @option C
  516. * @option D
  517. *
  518. * @arg loop
  519. * @text ループ有無
  520. * @desc タイマーをループさせるかどうかです。
  521. * @default false
  522. * @type boolean
  523. *
  524. * @command SET_SWITCH_ALARM
  525. * @text スイッチアラーム設定
  526. * @desc 指定した時刻にスイッチをONにできます。
  527. *
  528. * @arg name
  529. * @text アラーム名称
  530. * @desc アラームの識別子です。解除するときに必要になるので、解除したい場合は設定してください。
  531. * @default
  532. *
  533. * @arg year
  534. * @text アラーム年
  535. * @desc アラームがONになる年です。0を指定すると現在年になります。
  536. * @default 0
  537. * @type number
  538. *
  539. * @arg month
  540. * @text アラーム月
  541. * @desc アラームがONになる月です。0を指定すると現在月になります。
  542. * @default 0
  543. * @type number
  544. *
  545. * @arg day
  546. * @text アラーム日
  547. * @desc アラームがONになる日です。0を指定すると現在日になります。
  548. * @default 0
  549. * @type number
  550. *
  551. * @arg hour
  552. * @text アラーム時間
  553. * @desc アラームがONになる時間です。
  554. * @default 0
  555. * @type number
  556. * @max 23
  557. *
  558. * @arg minute
  559. * @text アラーム分
  560. * @desc アラームがONになる分です。
  561. * @default 0
  562. * @type number
  563. * @max 59
  564. *
  565. * @arg switchId
  566. * @text スイッチ番号
  567. * @desc ONにするスイッチ番号です。
  568. * @default 1
  569. * @type switch
  570. *
  571. * @arg interval
  572. * @text インターバル
  573. * @desc アラームが有効になった後さらに指定した分だけ経過するとまたアラームが有効になります。
  574. * @default 0
  575. * @type number
  576. *
  577. * @command SET_SELF_SWITCH_ALARM
  578. * @text セルフスイッチアラーム設定
  579. * @desc 指定した時刻にセルフスイッチをONにできます。
  580. *
  581. * @arg name
  582. * @text アラーム名称
  583. * @desc アラームの識別子です。解除するときに必要になるので、解除したい場合は設定してください。
  584. * @default
  585. *
  586. * @arg year
  587. * @text アラーム年
  588. * @desc アラームがONになる年です。0を指定すると現在年になります。
  589. * @default 0
  590. * @type number
  591. *
  592. * @arg month
  593. * @text アラーム月
  594. * @desc アラームがONになる月です。0を指定すると現在月になります。
  595. * @default 0
  596. * @type number
  597. *
  598. * @arg day
  599. * @text アラーム日
  600. * @desc アラームがONになる日です。0を指定すると現在日になります。
  601. * @default 0
  602. * @type number
  603. *
  604. * @arg hour
  605. * @text アラーム時間
  606. * @desc アラームがONになる時間です。
  607. * @default 0
  608. * @type number
  609. * @max 23
  610. *
  611. * @arg minute
  612. * @text アラーム分
  613. * @desc アラームがONになる分です。
  614. * @default 0
  615. * @type number
  616. * @max 59
  617. *
  618. * @arg selfSwitchId
  619. * @text セルフスイッチ番号
  620. * @desc ONにするセルフスイッチ番号です。
  621. * @default A
  622. * @type select
  623. * @option A
  624. * @option B
  625. * @option C
  626. * @option D
  627. *
  628. * @arg interval
  629. * @text インターバル
  630. * @desc アラームが有効になった後さらに指定した分だけ経過するとまたアラームが有効になります。
  631. * @default 0
  632. * @type number
  633. *
  634. * @command CLEAR_TIMER
  635. * @text タイマー・アラーム解除
  636. * @desc タイマーおよびアラームを解除します。解除したタイマーは再開できません。
  637. *
  638. * @arg name
  639. * @text タイマー名称
  640. * @desc タイマーの識別子です。
  641. * @default
  642. *
  643. * @command STOP_TIMER
  644. * @text タイマー・アラーム停止
  645. * @desc タイマーおよびアラームを停止します。停止している間は条件を満たしてもスイッチはONになりません。
  646. *
  647. * @arg name
  648. * @text タイマー名称
  649. * @desc タイマーの識別子です。
  650. * @default
  651. *
  652. * @command START_TIMER
  653. * @text タイマー・アラーム再開
  654. * @desc タイマーおよびアラームを再開します。
  655. *
  656. * @arg name
  657. * @text タイマー名称
  658. * @desc タイマーの識別子です。
  659. * @default
  660. *
  661. * @help ゲーム内で時刻と天候の概念を表現できるプラグインです。
  662. * 自動、マップ移動、戦闘で時間が経過し、時間と共に天候と色調が変化します。
  663. * これらの時間は調節可能で、またイベント中は時間の進行が停止します。
  664. *
  665. * さらに、現実の時間をゲーム中に反映させる機能もあります。
  666. * 設定を有効にすると現実の時間がゲーム内とリンクします。
  667. *
  668. * 日付や曜日も記録し、曜日の数や名称を自由に設定できます。
  669. * 現在日付はフォーマットに従って、画面左上に表示されます。
  670. *
  671. * 日付フォーマットには以下を利用できます。
  672. * YYYY:年 MON:月名 MM:月 DD:日 HH24:時(24) HH:時(12)
  673. * AM:午前 or 午後 MI:分 DY:曜日 TZ 時間帯名称
  674. * DDALL:累計日数
  675. *
  676. * また、規格に沿った画像を用意すればアナログ時計も表示できます。
  677. * 表示位置は各画像の表示可否は調整できます。
  678. *
  679. * 画像の規格は以下の通りです。
  680. * ・文字盤 : 任意のサイズの正方形画像
  681. * ・長針  : 文字盤と同じサイズの画像で、上(0)を指している針の画像
  682. * ・短針  : 文字盤と同じサイズの画像で、上(0)を指している針の画像
  683. *
  684. * ツクマテにて規格に合った時計画像をリクエストしました。
  685. * 使用する場合は、以下のURLより利用規約を別途確認の上、ご使用ください。
  686. * [url]http://tm.lucky-duet.com/viewtopic.php?f=47&t=555&p=1615#p1615[/url]
  687. *
  688. * ・タイマー操作系コマンド
  689. * コマンド実行から指定した時間[分]が経過後にスイッチやセルフスイッチを
  690. * ONにできるプラグインコマンドです。
  691. * 実時間連動機能と併せて使用することもできます。
  692. * スイッチの場合はIDを、セルフスイッチの場合は種類(A,B,C,D)を指定します。
  693. *
  694. * メモ欄詳細
  695. *  タイトルセットおよびマップのメモ欄に以下を入力すると、
  696. *  一時的に天候と色調変化を自動で無効化できます。
  697. *  屋内マップやイベントシーンなどで一時的に無効化したい場合に利用できます。
  698. *  設定はマップのメモ欄が優先されます。
  699. *
  700. * <C_Tint:OFF>    # 色調の変更を一時的に無効化します。
  701. * <C_色調:OFF>    # 同上
  702. * <C_Weather:OFF> # 天候を一時的に無効化します。
  703. * <C_天候:OFF>    # 同上
  704. * <C_Snow:ON>     # 天候を雪に設定します。
  705. * <C_雪:ON>       # 同上
  706. *
  707. * イベント実行中にも時間経過するかどうかをイベントごとに設定できます。
  708. * この設定はパラメータの設定よりも優先されます。
  709. * イベントのメモ欄に以下を入力してください。
  710. * <C_時間経過:ON> # イベント実行中に時間経過します。(ON/OFF)
  711. * <C_NoStop:ON>   # 同上
  712. *
  713. * 高度な設定
  714. * ソースコード中の「ユーザ書き換え領域」を参照すると以下を変更できます。
  715. *  時間帯の情報(朝が何時から何時まで等)
  716. *  時間帯ごとの色調(ただし、悪天候の場合は補正が掛かります)
  717. *
  718. * スクリプト
  719. *  frameで指定したフレーム数を自然時間加算間隔に設定します。
  720. *  $gameSystem.setAutoAddInterval(frame);
  721. *
  722. * このプラグインの利用にはベースプラグイン『PluginCommonBase.js』が必要です。
  723. * 『PluginCommonBase.js』は、RPGツクールMZのインストールフォルダ配下の
  724. * 以下のフォルダに格納されています。
  725. * dlc/BasicResources/plugins/official
  726. *
  727. * 利用規約:
  728. *  作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)
  729. *  についても制限はありません。
  730. *  このプラグインはもうあなたのものです。
  731. */

  732. /**
  733. * ゲーム内時間を扱うゲームオブジェクトです。
  734. * @constructor
  735. */
  736. function Game_Chronus() {
  737.     this.initialize.apply(this, arguments);
  738. }

  739. /**
  740. * ゲーム内タイマーを扱うゲームオブジェクトです。
  741. * @constructor
  742. */
  743. function Game_ChronusTimer() {
  744.     this.initialize.apply(this, arguments);
  745. }

  746. /**
  747. * 時計画像を扱うスプライトです。
  748. * @constructor
  749. */
  750. function Sprite_Chronicle_Clock() {
  751.     this.initialize.apply(this, arguments);
  752. }

  753. /**
  754. * ゲーム内時間を描画するウィンドウです。
  755. * @constructor
  756. */
  757. function Window_Chronus() {
  758.     this.initialize.apply(this, arguments);
  759. }

  760. (function() {
  761.     'use strict';
  762.     //=============================================================================
  763.     // ユーザ書き換え領域 - 開始 -
  764.     //=============================================================================
  765.     var settings = {
  766.         /* timeZone:時間帯 */
  767.         timeZone: [
  768.             /* name:時間帯名称 start:開始時刻 end:終了時刻 timeId:時間帯ID */
  769.             {name: '深夜', start: 0, end: 4, timeId: 0},
  770.             {name: '早朝', start: 5, end: 6, timeId: 1},
  771.             {name: '朝', start: 7, end: 11, timeId: 2},
  772.             {name: '昼', start: 12, end: 16, timeId: 3},
  773.             {name: '夕方', start: 17, end: 18, timeId: 4},
  774.             {name: '夜', start: 19, end: 21, timeId: 5},
  775.             {name: '深夜', start: 22, end: 24, timeId: 0}
  776.         ],
  777.         /* timeTone:時間帯ごとの色調 */
  778.         timeTone: [
  779.             /* timeId:時間帯ID value:色調[赤(-255...255),緑(-255...255),青(-255...255),グレー(0...255)] */
  780.             {timeId: 0, value: [-102, -102, -68, 102]},
  781.             {timeId: 1, value: [-68, -68, 0, 0]},
  782.             {timeId: 2, value: [0, 0, 0, 0]},
  783.             {timeId: 3, value: [34, 34, 34, 0]},
  784.             {timeId: 4, value: [68, -34, -34, 0]},
  785.             {timeId: 5, value: [-68, -68, 0, 68]}
  786.         ]
  787.     };
  788.     //=============================================================================
  789.     // ユーザ書き換え領域 - 終了 -
  790.     //=============================================================================
  791.     var pluginName    = 'Chronus';
  792.     var metaTagPrefix = 'C_';

  793.     var getParamString = function(paramNames) {
  794.         var value = getParamOther(paramNames);
  795.         return value === null ? '' : value;
  796.     };

  797.     var getParamNumber = function(paramNames, min, max) {
  798.         var value = getParamOther(paramNames);
  799.         if (arguments.length < 2) min = -Infinity;
  800.         if (arguments.length < 3) max = Infinity;
  801.         return (parseInt(value, 10) || 0).clamp(min, max);
  802.     };

  803.     var getParamOther = function(paramNames) {
  804.         if (!Array.isArray(paramNames)) paramNames = [paramNames];
  805.         for (var i = 0; i < paramNames.length; i++) {
  806.             var name = PluginManager.parameters(pluginName)[paramNames[i]];
  807.             if (name) return name;
  808.         }
  809.         return null;
  810.     };

  811.     var getParamBoolean = function(paramNames) {
  812.         var value = (getParamOther(paramNames) || '').toUpperCase();
  813.         return value === 'ON' || value === 'TRUE';
  814.     };

  815.     var isParamExist = function(paramNames) {
  816.         return getParamOther(paramNames) !== null;
  817.     };

  818.     var getParamArrayString = function(paramNames) {
  819.         var values = getParamString(paramNames).split(',');
  820.         for (var i = 0; i < values.length; i++) values[i] = values[i].trim();
  821.         return values;
  822.     };

  823.     var getParamArrayNumber = function(paramNames, min, max) {
  824.         var values = getParamArrayString(paramNames);
  825.         if (arguments.length < 2) min = -Infinity;
  826.         if (arguments.length < 3) max = Infinity;
  827.         for (var i = 0; i < values.length; i++) values[i] = (parseInt(values[i], 10) || 0).clamp(min, max);
  828.         return values;
  829.     };

  830.     var getArgBoolean = function(arg) {
  831.         return (arg || '').toUpperCase() === 'ON' || (arg || '').toUpperCase() === 'TRUE';
  832.     };

  833.     var getMetaValue = function(object, name) {
  834.         var metaTagName = metaTagPrefix + (name ? name : '');
  835.         return object.meta.hasOwnProperty(metaTagName) ? object.meta[metaTagName] : undefined;
  836.     };

  837.     var getMetaValues = function(object, names) {
  838.         if (!Array.isArray(names)) return getMetaValue(object, names);
  839.         for (var i = 0, n = names.length; i < n; i++) {
  840.             var value = getMetaValue(object, names[i]);
  841.             if (value !== undefined) return value;
  842.         }
  843.         return undefined;
  844.     };

  845.     var _DataManager_extractSaveContents = DataManager.extractSaveContents;
  846.     DataManager.extractSaveContents      = function(contents) {
  847.         _DataManager_extractSaveContents.apply(this, arguments);
  848.         $gameSystem.onLoad();
  849.     };

  850.     //=============================================================================
  851.     // パラメータの取得と整形
  852.     //=============================================================================
  853.     var paramAutoAddInterval     = getParamNumber('自然時間加算間隔', 1) || 60;
  854.     var paramCalendarFontSize    = getParamNumber('カレンダーフォントサイズ', 0);
  855.     var paramCalendarOpacity     = getParamNumber('カレンダー不透明度', 0);
  856.     var paramCalendarPadding     = getParamNumber('カレンダー余白', 8);
  857.     var paramClockBaseFile       = getParamString('文字盤画像ファイル');
  858.     var paramMinutesHandFile     = getParamString('長針画像ファイル');
  859.     var paramHourHandFile        = getParamString('短針画像ファイル');
  860.     var paramCalendarFrameHidden = getParamBoolean('カレンダー枠の非表示');
  861.     var paramCalendarLineSpacing = getParamNumber('日時フォーマット行間', 0);
  862.     var paramCalendarHidden      = getParamBoolean('カレンダーの非表示');
  863.     var param24hourClock         = getParamBoolean('24hourClock');

  864.     const script = document.currentScript;
  865.     PluginManagerEx.registerCommand(script, 'ADD_TIME', args => {
  866.         $gameSystem.chronus().addTime(args.time);
  867.     });

  868.     PluginManagerEx.registerCommand(script, 'ADD_DAY', args => {
  869.         $gameSystem.chronus().addDay(args.day);
  870.     });

  871.     PluginManagerEx.registerCommand(script, 'SET_TIME', args => {
  872.         $gameSystem.chronus().setTime(args.hour, args.minute);
  873.     });

  874.     PluginManagerEx.registerCommand(script, 'SET_DAY', args => {
  875.         $gameSystem.chronus().setDay(args.year, args.month, args.day);
  876.     });

  877.     PluginManagerEx.registerCommand(script, 'STOP', args => {
  878.         $gameSystem.chronus().stop();
  879.     });

  880.     PluginManagerEx.registerCommand(script, 'START', args => {
  881.         $gameSystem.chronus().start();
  882.     });

  883.     PluginManagerEx.registerCommand(script, 'SHOW', args => {
  884.         $gameSystem.chronus().showCalendar();
  885.     });

  886.     PluginManagerEx.registerCommand(script, 'HIDE', args => {
  887.         $gameSystem.chronus().hideCalendar();
  888.     });

  889.     PluginManagerEx.registerCommand(script, 'DISABLE_TINT', args => {
  890.         $gameSystem.chronus().disableTint();
  891.     });

  892.     PluginManagerEx.registerCommand(script, 'ENABLE_TINT', args => {
  893.         $gameSystem.chronus().enableTint();
  894.     });

  895.     PluginManagerEx.registerCommand(script, 'DISABLE_WEATHER', args => {
  896.         $gameSystem.chronus().disableWeather();
  897.     });

  898.     PluginManagerEx.registerCommand(script, 'ENABLE_WEATHER', args => {
  899.         $gameSystem.chronus().enableWeather();
  900.     });

  901.     PluginManagerEx.registerCommand(script, 'SET_SNOW_LAND', args => {
  902.         $gameSystem.chronus().setSnowLand();
  903.     });

  904.     PluginManagerEx.registerCommand(script, 'RESET_SNOW_LAND', args => {
  905.         $gameSystem.chronus().resetSnowLand();
  906.     });

  907.     PluginManagerEx.registerCommand(script, 'SET_SPEED', args => {
  908.         $gameSystem.chronus().setTimeAutoAdd(args.speed);
  909.     });

  910.     PluginManagerEx.registerCommand(script, 'SHOW_CLOCK', args => {
  911.         $gameSystem.chronus().showClock();
  912.     });

  913.     PluginManagerEx.registerCommand(script, 'HIDE_CLOCK', args => {
  914.         $gameSystem.chronus().hideClock();
  915.     });

  916.     PluginManagerEx.registerCommand(script, 'SET_TIME_REAL', args => {
  917.         $gameSystem.chronus().setTimeReal();
  918.     });

  919.     PluginManagerEx.registerCommand(script, 'SET_TIME_VIRTUAL', args => {
  920.         $gameSystem.chronus().setTimeVirtual();
  921.     });

  922.     PluginManagerEx.registerCommand(script, 'SET_RAINY_PERCENT', args => {
  923.         $gameSystem.chronus().setRainyPercent(args.percent);
  924.     });

  925.     PluginManagerEx.registerCommand(script, 'SET_SWITCH_TIMER', function(args) {
  926.         this.setSwitchTimer(args);
  927.     });

  928.     PluginManagerEx.registerCommand(script, 'SET_SELF_SWITCH_TIMER', function(args) {
  929.         this.setSwitchTimer(args);
  930.     });

  931.     PluginManagerEx.registerCommand(script, 'SET_SWITCH_ALARM', function(args) {
  932.         this.setSwitchAlarm(args);
  933.     });

  934.     PluginManagerEx.registerCommand(script, 'SET_SELF_SWITCH_ALARM', function(args) {
  935.         this.setSwitchAlarm(args);
  936.     });

  937.     PluginManagerEx.registerCommand(script, 'STOP_TIMER', args => {
  938.         $gameSystem.chronus().stopTimer(args.name);
  939.     });

  940.     PluginManagerEx.registerCommand(script, 'START_TIMER', args => {
  941.         $gameSystem.chronus().startTimer(args.name);
  942.     });

  943.     PluginManagerEx.registerCommand(script, 'CLEAR_TIMER', args => {
  944.         $gameSystem.chronus().clearTimer(args.name);
  945.     });

  946.     PluginManagerEx.registerCommand(script, 'INIT_TOTAL_TIME', args => {
  947.         $gameSystem.chronus().initTotalTime();
  948.     });

  949.     PluginManagerEx.registerCommand(script, 'SET_CLOCK_IMAGE', args => {
  950.         if (args.baseFileName) {
  951.             $gameSystem.chronus().setClockBaseFile(args.baseFileName);
  952.         }
  953.         if (args.hourFileName) {
  954.             $gameSystem.chronus().setHourHandFile(args.hourFileName);
  955.         }
  956.         if (args.minuteFileName) {
  957.             $gameSystem.chronus().setMinuteHandFile(args.minuteFileName);
  958.         }
  959.     });

  960.     PluginManagerEx.registerCommand(script, 'SET_AUTO_ADD_INTERVAL', args => {
  961.         $gameSystem.chronus().setAutoAddInterval(args.interval);
  962.     });

  963.     Game_Interpreter.prototype.setSwitchTimer = function(args) {
  964.         var switchKey = this.getSwitchKey(args.switchId, args.selfSwitchId);
  965.         $gameSystem.chronus().makeTimer(args.name || null, args.timeout, switchKey, args.loop);
  966.     };

  967.     Game_Interpreter.prototype.setSwitchAlarm = function(args) {
  968.         var switchKey = this.getSwitchKey(args.switchId, args.selfSwitchId);
  969.         $gameSystem.chronus().makeAlarm(args.name || null, this.createAlarmTime(args), switchKey, args.interval);
  970.     };

  971.     Game_Interpreter.prototype.createAlarmTime = function(args) {
  972.         var chronus = $gameSystem.chronus();
  973.         var year = args.year || chronus.getYear();
  974.         var month = args.year || chronus.getMonth();
  975.         var day = args.day || chronus.getDay();
  976.         return args.minute + args.hour * 100 + day * 10000 + month * 1000000 * year + 100000000;
  977.     };

  978.     Game_Interpreter.prototype.getSwitchKey = function(switchId, selfSwitchId) {
  979.         return selfSwitchId ? [$gameMap.mapId(), this.eventId(), selfSwitchId.toUpperCase()] : switchId;
  980.     };

  981.     var _Game_Interpreter_command236      = Game_Interpreter.prototype.command236;
  982.     Game_Interpreter.prototype.command236 = function(params) {
  983.         var result = _Game_Interpreter_command236.apply(this, arguments);
  984.         if (!$gameParty.inBattle()) {
  985.             var chronus = $gameSystem.chronus();
  986.             chronus.setWeatherType(Game_Chronus.weatherTypes.indexOf(params[0]));
  987.             chronus.setWeatherPower(params[1]);
  988.             chronus.refreshTint(true);
  989.             chronus.forceSetBatWeatherLevel(params[0], params[1]);
  990.         }
  991.         return result;
  992.     };

  993.     var _Game_Interpreter_command282 = Game_Interpreter.prototype.command282;
  994.     Game_Interpreter.prototype.command282 = function() {
  995.         var result =  _Game_Interpreter_command282.apply(this, arguments);
  996.         if (!$gameParty.inBattle()) {
  997.             var chronus = $gameSystem.chronus();
  998.             chronus.refreshTint(true);
  999.             chronus.refreshWeather(true);
  1000.         }
  1001.         return result;
  1002.     };

  1003.     //=============================================================================
  1004.     // Game_System
  1005.     //  ゲーム内時間を扱うクラス「Game_Chronus」を追加定義します。
  1006.     //=============================================================================
  1007.     var _Game_System_initialize      = Game_System.prototype.initialize;
  1008.     Game_System.prototype.initialize = function() {
  1009.         _Game_System_initialize.apply(this, arguments);
  1010.         this._chronus = new Game_Chronus();
  1011.     };

  1012.     Game_System.prototype.chronus = function() {
  1013.         return this._chronus;
  1014.     };

  1015.     Game_System.prototype.onBattleEnd = function() {
  1016.         this.chronus().onBattleEnd();
  1017.     };

  1018.     var _Game_System_onLoad      = Game_System.prototype.onLoad;
  1019.     Game_System.prototype.onLoad = function() {
  1020.         if (_Game_System_onLoad) _Game_System_onLoad.apply(this, arguments);
  1021.         if (!this.chronus()) this._chronus = new Game_Chronus();
  1022.         this._chronus.onLoad();
  1023.     };

  1024.     //=============================================================================
  1025.     // Game_Map
  1026.     //  マップ及びタイルセットから、色調変化無効フラグを取得します。
  1027.     //=============================================================================
  1028.     Game_Map.prototype.isDisableTint = function() {
  1029.         return !this.isChronicleMetaInfo(['Tint', '色調'], true);
  1030.     };

  1031.     Game_Map.prototype.isDisableWeather = function() {
  1032.         return !this.isChronicleMetaInfo(['Weather', '天候'], true);
  1033.     };

  1034.     Game_Map.prototype.isSnowLand = function() {
  1035.         return this.isChronicleMetaInfo(['Snow', '雪'], false);
  1036.     };

  1037.     Game_Map.prototype.isChronicleMetaInfo = function(tagNames, defaultValue) {
  1038.         if (DataManager.isBattleTest() || DataManager.isEventTest()) return false;
  1039.         var metaValue1 = getMetaValues($dataMap, tagNames);
  1040.         if (metaValue1 !== undefined) {
  1041.             return getArgBoolean(metaValue1);
  1042.         }
  1043.         var tileset = $gamePlayer.isTransferring() ? $dataTilesets[$dataMap.tilesetId] : this.tileset();
  1044.         var metaValue2 = getMetaValues(tileset, tagNames);
  1045.         if (metaValue2 !== undefined) {
  1046.             return getArgBoolean(metaValue2);
  1047.         }
  1048.         return defaultValue;
  1049.     };

  1050.     Game_Map.prototype.isTimeStopEventRunning = function() {
  1051.         if (this.isEventRunning()) {
  1052.             if (!this._isTimeStopEventRunning) this._isTimeStopEventRunning = this.getTimeStopEventRunning();
  1053.         } else {
  1054.             this._isTimeStopEventRunning = false;
  1055.         }
  1056.         return this._isTimeStopEventRunning;
  1057.     };

  1058.     Game_Map.prototype.getTimeStopEventRunning = function() {
  1059.         var event = this.event(this._interpreter.eventId());
  1060.         if (!event) return false;
  1061.         var stop = getMetaValues(event.event(), ['時間経過', 'NoStop']);
  1062.         if (stop) {
  1063.             return !getArgBoolean(stop);
  1064.         } else {
  1065.             return !getParamBoolean('イベント中時間経過');
  1066.         }
  1067.     };

  1068.     //=============================================================================
  1069.     // Game_Player
  1070.     //  場所移動時の時間経過を追加定義します。
  1071.     //=============================================================================
  1072.     var _Game_Player_performTransfer      = Game_Player.prototype.performTransfer;
  1073.     Game_Player.prototype.performTransfer = function() {
  1074.         var realTransfer = this._newMapId !== $gameMap.mapId() && $gameMap.mapId() > 0;
  1075.         $gameSystem.chronus().transfer(realTransfer);
  1076.         _Game_Player_performTransfer.call(this);
  1077.     };

  1078.     //=============================================================================
  1079.     // Scene_Map
  1080.     //  Game_Chronusの更新を追加定義します。
  1081.     //=============================================================================
  1082.     var _Scene_Map_onMapLoaded      = Scene_Map.prototype.onMapLoaded;
  1083.     Scene_Map.prototype.onMapLoaded = function() {
  1084.         $gameSystem.chronus().onMapLoaded();
  1085.         _Scene_Map_onMapLoaded.apply(this, arguments);
  1086.     };

  1087.     var _Scene_Map_updateMain      = Scene_Map.prototype.updateMain;
  1088.     Scene_Map.prototype.updateMain = function() {
  1089.         _Scene_Map_updateMain.apply(this, arguments);
  1090.         $gameSystem.chronus().update();
  1091.     };

  1092.     var _Scene_Map_createAllWindows      = Scene_Map.prototype.createAllWindows;
  1093.     Scene_Map.prototype.createAllWindows = function() {
  1094.         _Scene_Map_createAllWindows.apply(this, arguments);
  1095.         this.createChronusWindow();
  1096.     };

  1097.     Scene_Map.prototype.createChronusWindow = function() {
  1098.         this._chronusWindow = new Window_Chronus();
  1099.         this.addWindow(this._chronusWindow);
  1100.     };

  1101.     //=============================================================================
  1102.     // BattleManager
  1103.     //  戦闘終了時のゲーム内時間経過処理を追加定義します。
  1104.     //=============================================================================
  1105.     var _BattleManager_endBattle = BattleManager.endBattle;
  1106.     BattleManager.endBattle      = function(result) {
  1107.         $gameSystem.onBattleEnd();
  1108.         _BattleManager_endBattle.call(this, result);
  1109.     };

  1110.     //=============================================================================
  1111.     // Window_Chronus
  1112.     //  ゲーム内時間情報を描画するウィンドウです。
  1113.     //=============================================================================
  1114.     Window_Chronus.prototype             = Object.create(Window_Base.prototype);
  1115.     Window_Chronus.prototype.constructor = Window_Chronus;

  1116.     var _Window_Chronus_initialize      = Window_Chronus.prototype.initialize;
  1117.     Window_Chronus.prototype.initialize = function() {
  1118.         _Window_Chronus_initialize.call(this, new Rectangle(0, 0, this.getDefaultWidth(), this.getDefaultHeight()));
  1119.         this.createContents();
  1120.         this.x = getParamNumber('カレンダー表示X座標');
  1121.         this.y = getParamNumber('カレンダー表示Y座標');
  1122.         if (paramCalendarFrameHidden) {
  1123.             this.opacity = 0;
  1124.         }
  1125.         this.refresh();
  1126.     };

  1127.     Window_Chronus.prototype.getDefaultWidth = function() {
  1128.         var bitmap      = new Bitmap();
  1129.         bitmap.fontSize = this.standardFontSize();
  1130.         var width1      = bitmap.measureTextWidth(this.getDateFormat(1));
  1131.         var width2      = bitmap.measureTextWidth(this.getDateFormat(2));
  1132.         return Math.max(width1, width2) + this.standardPadding() * 2;
  1133.     };

  1134.     Window_Chronus.prototype.getDefaultHeight = function() {
  1135.         return this.standardFontSize() * (this.getDateFormat(2) ? 2 : 1) + this.standardPadding() * 2 + paramCalendarLineSpacing;
  1136.     };

  1137.     Window_Chronus.prototype.standardPadding = function() {
  1138.         return paramCalendarPadding || $gameSystem.windowPadding();
  1139.     };

  1140.     Window_Chronus.prototype.standardBackOpacity = function() {
  1141.         return paramCalendarOpacity;
  1142.     };

  1143.     Window_Chronus.prototype.lineHeight = function() {
  1144.         return this.standardFontSize();
  1145.     };

  1146.     Window_Chronus.prototype.standardFontSize = function() {
  1147.         return paramCalendarFontSize || $gameSystem.mainFontSize();
  1148.     };

  1149.     var _Window_Chronus_resetFontSettings = Window_Chronus.prototype.resetFontSettings;
  1150.     Window_Chronus.prototype.resetFontSettings = function() {
  1151.         _Window_Chronus_resetFontSettings.apply(this, arguments);
  1152.         this.contents.fontSize = this.standardFontSize();
  1153.     };

  1154.     var _Window_Chronus_updatePadding = Window_Chronus.prototype.updatePadding;
  1155.     Window_Chronus.prototype.updatePadding = function() {
  1156.         _Window_Chronus_updatePadding.apply(this, arguments);
  1157.         this.padding = this.standardPadding();
  1158.     };

  1159.     Window_Chronus.prototype.refresh = function() {
  1160.         this.contents.clear();
  1161.         var width  = this.contents.width;
  1162.         var height = this.lineHeight();
  1163.         this.contents.drawText(this.getDateFormat(1), 0, 0, width, height, 'left');
  1164.         this.contents.drawText(this.getDateFormat(2), 0, height + paramCalendarLineSpacing, width, height, 'left');
  1165.         this.update();
  1166.     };

  1167.     Window_Chronus.prototype.update = function() {
  1168.         if (this.chronus().isShowingCalendar()) {
  1169.             this.show();
  1170.             if (this.chronus().isNeedRefresh()) this.refresh();
  1171.         } else {
  1172.             this.hide();
  1173.         }
  1174.     };

  1175.     Window_Chronus.prototype.chronus = function() {
  1176.         return $gameSystem.chronus();
  1177.     };

  1178.     Window_Chronus.prototype.getDateFormat = function(lineNumber) {
  1179.         return this.chronus().getDateFormat(lineNumber);
  1180.     };

  1181.     //=============================================================================
  1182.     // Sprite_Chronicle_Clock
  1183.     //  アナログ時計表示スプライトクラスです。
  1184.     //=============================================================================
  1185.     Sprite_Chronicle_Clock.prototype             = Object.create(Sprite.prototype);
  1186.     Sprite_Chronicle_Clock.prototype.constructor = Sprite_Chronicle_Clock;

  1187.     var _Sprite_Chronicle_Clock_initialize      = Sprite_Chronicle_Clock.prototype.initialize;
  1188.     Sprite_Chronicle_Clock.prototype.initialize = function() {
  1189.         _Sprite_Chronicle_Clock_initialize.apply(this, arguments);
  1190.         this.x        = getParamNumber('時計X座標');
  1191.         this.y        = getParamNumber('時計Y座標');
  1192.         this.anchor.x = 0.5;
  1193.         this.anchor.y = 0.5;
  1194.         this.bitmap   = ImageManager.loadPicture(this.chronus().getClockBaseFile());
  1195.         this.createHourHandSprite();
  1196.         this.createMinuteHandSprite();
  1197.     };

  1198.     Sprite_Chronicle_Clock.prototype.createHourHandSprite = function() {
  1199.         var handName        = this.chronus().getHourHandFile();
  1200.         var handSprite      = new Sprite();
  1201.         handSprite.anchor.x = 0.5;
  1202.         handSprite.anchor.y = 0.5;
  1203.         handSprite.bitmap   = handName ? ImageManager.loadPicture(handName) : ImageManager.loadEmptyBitmap();
  1204.         handSprite.visible  = !!handName;
  1205.         this.hourHandSprite = handSprite;
  1206.         this.addChild(this.hourHandSprite);
  1207.     };

  1208.     Sprite_Chronicle_Clock.prototype.createMinuteHandSprite = function() {
  1209.         var handName          = this.chronus().getMinuteHandFile();
  1210.         var handSprite        = new Sprite();
  1211.         handSprite.anchor.x   = 0.5;
  1212.         handSprite.anchor.y   = 0.5;
  1213.         handSprite.bitmap     = handName ? ImageManager.loadPicture(handName) : ImageManager.loadEmptyBitmap();
  1214.         handSprite.visible    = !!handName;
  1215.         this.minuteHandSprite = handSprite;
  1216.         this.addChild(this.minuteHandSprite);
  1217.     };

  1218.     Sprite_Chronicle_Clock.prototype.update = function() {
  1219.         this.visible = this.chronus().isShowingClock();
  1220.         if (this.visible) {
  1221.             this.updateHourHand();
  1222.             this.updateMinuteHand();
  1223.         }
  1224.     };

  1225.     Sprite_Chronicle_Clock.prototype.updateHourHand = function() {
  1226.         if (!this.hourHandSprite.visible) return;
  1227.         this.hourHandSprite.rotation = this.chronus().getRotationHourHand();
  1228.     };

  1229.     Sprite_Chronicle_Clock.prototype.updateMinuteHand = function() {
  1230.         if (!this.minuteHandSprite.visible) return;
  1231.         this.minuteHandSprite.rotation = this.chronus().getRotationMinuteHand();
  1232.     };

  1233.     Sprite_Chronicle_Clock.prototype.chronus = function() {
  1234.         return $gameSystem.chronus();
  1235.     };

  1236.     //=============================================================================
  1237.     // Spriteset_Map
  1238.     //  アナログ時計の画像を追加定義します。
  1239.     //=============================================================================
  1240.     var _Spriteset_Base_createUpperLayer      = Spriteset_Base.prototype.createUpperLayer;
  1241.     Spriteset_Base.prototype.createUpperLayer = function() {
  1242.         _Spriteset_Base_createUpperLayer.apply(this, arguments);
  1243.         if (this instanceof Spriteset_Map) this.createClockSprite();
  1244.     };

  1245.     Spriteset_Map.prototype.createClockSprite = function() {
  1246.         if (isParamExist('文字盤画像ファイル')) {
  1247.             this._clockSprite = new Sprite_Chronicle_Clock();
  1248.             this.addChild(this._clockSprite);
  1249.         }
  1250.     };

  1251.     //=============================================================================
  1252.     // Game_Chronus
  1253.     //  時の流れを扱うクラスです。このクラスはGame_Systemクラスで生成されます。
  1254.     //  セーブデータの保存対象のためグローバル領域に定義します。
  1255.     //=============================================================================
  1256.     Game_Chronus.weatherTypes         = ['none', 'rain', 'storm', 'snow'];
  1257.     Game_Chronus.prototype.initialize = function() {
  1258.         this._stop            = false;        // 停止フラグ(全ての加算に対して有効。ただし手動による加算は例外)
  1259.         this._disableTint     = false;        // 色調変更禁止フラグ
  1260.         this._calendarVisible = !paramCalendarHidden; // カレンダー表示フラグ
  1261.         this._disableWeather  = false;        // 天候制御禁止フラグ
  1262.         this._weatherType     = 0;            // 天候タイプ(0:なし 1:雨 2:嵐 :3雪)
  1263.         this._weatherPower    = 0;            // 天候の強さ
  1264.         this._weatherSnowLand = false;        // 降雪地帯フラグ
  1265.         this._clockVisible    = true;         // アナログ時計表示フラグ
  1266.         this._realTime        = false;        // 実時間フラグ
  1267.         this._badWeaterLevel  = 0;            // 悪天候の度合い
  1268.         this._frameCount      = 0;
  1269.         this._demandRefresh   = false;
  1270.         this._prevHour        = -1;
  1271.         this._nowDate         = null;
  1272.         this._clearTone       = false;
  1273.         this._timeAutoAdd     = getParamNumber('自然時間加算', 0, 99);
  1274.         this._timeTransferAdd = getParamNumber('場所移動時間加算', 0);
  1275.         this._timeBattleAdd   = getParamNumber('戦闘時間加算(固定)', 0);
  1276.         this._timeTurnAdd     = getParamNumber('戦闘時間加算(ターン)', 0);
  1277.         this._weekNames       = getParamArrayString('曜日配列');
  1278.         this._monthNames      = getParamArrayString('月名配列');
  1279.         this._daysOfMonth     = getParamArrayNumber('月ごとの日数配列');
  1280.         this._clockBaseFile   = null;
  1281.         this._minuteHandFile  = null;
  1282.         this._hourHandFile    = null;
  1283.         this._timeMeter       = 0;
  1284.         this._dayMeter        = 0;
  1285.         this._initDate        = Date.now();
  1286.         this.initTotalTime();
  1287.         this.onLoad();
  1288.     };

  1289.     Game_Chronus.prototype.initTotalTime = function() {
  1290.         this._criterionTime = this._timeMeter;
  1291.         this._criterionDay  = this._dayMeter;
  1292.         this._initDate      = Date.now();
  1293.     };

  1294.     Game_Chronus.prototype.onLoad = function() {
  1295.         this._nowDate = new Date();
  1296.         if (!this._frameCount) this._frameCount = 0;
  1297.         if (!this._timers) this._timers = [];
  1298.         if (!this._namedTimers) this._namedTimers = {};
  1299.     };

  1300.     Game_Chronus.prototype.onMapLoaded = function() {
  1301.         this.updateWeatherType();
  1302.         this.updateWeatherPower();
  1303.         this.refreshWeather(true);
  1304.     };

  1305.     Game_Chronus.prototype.update = function() {
  1306.         this.updateTimer();
  1307.         this.updateEffect();
  1308.         if (this.isTimeStop()) return;
  1309.         this._frameCount++;
  1310.         if (this._frameCount >= this.getAutoAddInterval()) {
  1311.             if (this.isRealTime()) {
  1312.                 this.updateRealTime();
  1313.             }
  1314.             this.addTime();
  1315.         }
  1316.     };

  1317.     Game_Chronus.prototype.getAutoAddInterval = function() {
  1318.         return this._autoAddInterval ? this._autoAddInterval : paramAutoAddInterval;
  1319.     };

  1320.     Game_Chronus.prototype.setAutoAddInterval = function(value) {
  1321.         this._autoAddInterval = value;
  1322.     };

  1323.     Game_Chronus.prototype.updateRealTime = function() {
  1324.         this._nowDate.setTime(Date.now());
  1325.     };

  1326.     Game_Chronus.prototype.updateTimer = function() {
  1327.         for (var timerName in this._namedTimers) {
  1328.             if (this._namedTimers.hasOwnProperty(timerName)) {
  1329.                 var valid = this._namedTimers[timerName].update();
  1330.                 if (!valid) this.clearTimer(timerName);
  1331.             }
  1332.         }
  1333.         this._timers = this._timers.filter(function(timer) {
  1334.             return timer.update();
  1335.         });
  1336.     };

  1337.     Game_Chronus.prototype.isRealTime = function() {
  1338.         return this._realTime;
  1339.     };

  1340.     Game_Chronus.prototype.isTimeStop = function() {
  1341.         return this.isStop() || $gameMap.isTimeStopEventRunning();
  1342.     };

  1343.     Game_Chronus.prototype.updateEffect = function() {
  1344.         var hour = this.getHour();
  1345.         if (this._prevHour !== hour) {
  1346.             this.updateWeather();
  1347.             this.refreshTint(false);
  1348.             this._prevHour = this.getHour();
  1349.         }
  1350.     };

  1351.     Game_Chronus.prototype.refreshTint = function(swift) {
  1352.         if (this.isEnableTint()) {
  1353.             this.setTint(this.getTimeZone(), swift);
  1354.             this._clearTone = false;
  1355.         } else if (!this._clearTone) {
  1356.             $gameScreen.clearTone();
  1357.             this._clearTone = true;
  1358.         }
  1359.     };

  1360.     Game_Chronus.prototype.setTint = function(timeId, swift) {
  1361.         var tone = [0, 0, 0, 0];
  1362.         settings.timeTone.forEach(function(toneInfo) {
  1363.             if (toneInfo.timeId === timeId) {
  1364.                 tone = toneInfo.value.clone();
  1365.                 if (tone.length < 4) throw new Error('色調の値が不正です。:' + tone);
  1366.             }
  1367.         }.bind(this));
  1368.         if (this.getWeatherTypeId() !== 0) {
  1369.             tone[0] = tone[0] > 0 ? tone[0] / 7 : tone[0] - 14;
  1370.             tone[1] = tone[1] > 0 ? tone[1] / 7 : tone[1] - 14;
  1371.             tone[2] = tone[2] > 0 ? tone[2] / 7 : tone[1] - 14;
  1372.             tone[3] = tone[3] === 0 ? 68 : tone[3] + 14;
  1373.         }
  1374.         $gameScreen.startTint(tone, swift ? 0 : this.getEffectDuration());
  1375.     };

  1376.     Game_Chronus.prototype.setWeatherType = function(value) {
  1377.         this._weatherType = value.clamp(0, Game_Chronus.weatherTypes.length - 1);
  1378.     };

  1379.     Game_Chronus.prototype.setWeatherPower = function(value) {
  1380.         this._weatherPower = value.clamp(0, 10);
  1381.     };

  1382.     Game_Chronus.prototype.setTimeAutoAdd = function(value) {
  1383.         this._timeAutoAdd = value.clamp(0, 99);
  1384.     };

  1385.     Game_Chronus.prototype.updateWeather = function() {
  1386.         if (!this._disableWeather) {
  1387.             this.updateBatWeatherLevel();
  1388.         } else {
  1389.             this._weatherType  = 0;
  1390.             this._weatherPower = 0;
  1391.         }
  1392.         this.refreshWeather(false);
  1393.     };

  1394.     Game_Chronus.prototype.updateBatWeatherLevel = function() {
  1395.         var frequency = this.getChangeWeatherFrequency();
  1396.         var max       = this.getBadWeatherLevelMax();
  1397.         var newLevel  = (this._badWeaterLevel || 0).clamp(frequency, max - frequency);
  1398.         if (Math.randomInt(10) <= 1) frequency *= 5;
  1399.         this._badWeaterLevel = (newLevel + (Math.randomInt(frequency * 2) - frequency)).clamp(0, max);
  1400.         this.updateWeatherType();
  1401.         this.updateWeatherPower();
  1402.     };

  1403.     Game_Chronus.prototype.forceSetBatWeatherLevel = function(type, power) {
  1404.         var newLevel = 0;
  1405.         switch (type) {
  1406.             case Game_Chronus.weatherTypes[1]:
  1407.                 newLevel = this.getBadWeatherLevelRainy() + power;
  1408.                 break;
  1409.             case Game_Chronus.weatherTypes[2]:
  1410.                 newLevel = this.getBadWeatherLevelHeavyRainy() + power;
  1411.                 break;
  1412.             case Game_Chronus.weatherTypes[3]:
  1413.                 newLevel = this.getBadWeatherLevelRainy() + power * 2;
  1414.                 break;
  1415.         }
  1416.         this._badWeaterLevel = newLevel;
  1417.     };

  1418.     Game_Chronus.prototype.updateWeatherType = function() {
  1419.         var type        = 0;
  1420.         var border      = this.getBadWeatherLevelRainy();
  1421.         var heavyBorder = this.getBadWeatherLevelHeavyRainy();
  1422.         if (this._badWeaterLevel >= border) {
  1423.             type = (this.isSnowLand() ? 3 : this._badWeaterLevel >= heavyBorder ? 2 : 1);
  1424.         }
  1425.         this.setWeatherType(type);
  1426.     };

  1427.     Game_Chronus.prototype.updateWeatherPower = function() {
  1428.         var power  = 0;
  1429.         var border = this.getBadWeatherLevelRainy();
  1430.         if (this._badWeaterLevel >= border) {
  1431.             power = Math.floor((this._badWeaterLevel - border) / 2);
  1432.         }
  1433.         this.setWeatherPower(power);
  1434.     };

  1435.     Game_Chronus.prototype.getBadWeatherLevelMax = function() {
  1436.         return this._badWeaterLevelMax || 40;
  1437.     };

  1438.     Game_Chronus.prototype.getBadWeatherLevelRainy = function() {
  1439.         return this.getBadWeatherLevelMax() - 20;
  1440.     };

  1441.     Game_Chronus.prototype.getBadWeatherLevelHeavyRainy = function() {
  1442.         return this.getBadWeatherLevelMax() - 10;
  1443.     };

  1444.     Game_Chronus.prototype.getChangeWeatherFrequency = function() {
  1445.         return 4;
  1446.     };

  1447.     Game_Chronus.prototype.refreshWeather = function(swift) {
  1448.         if (this.isEnableWeather()) {
  1449.             this.setScreenWeather(swift);
  1450.         } else {
  1451.             $gameScreen.changeWeather(0, 0, 0);
  1452.         }
  1453.     };

  1454.     Game_Chronus.prototype.setScreenWeather = function(swift) {
  1455.         $gameScreen.changeWeather(this.getWeatherType(), this._weatherPower, swift ? 0 : this.getEffectDuration());
  1456.     };

  1457.     Game_Chronus.prototype.getEffectDuration = function() {
  1458.         if (this.isRealTime()) {
  1459.             return 600;
  1460.         }
  1461.         return this._timeAutoAdd === 0 ? 1 : Math.floor(60 * 5 / (this.getRealAddSpeed() / 10));
  1462.     };

  1463.     Game_Chronus.prototype.getRealAddSpeed = function() {
  1464.         return this._timeAutoAdd * 60 / paramAutoAddInterval;
  1465.     };

  1466.     Game_Chronus.prototype.disableTint = function() {
  1467.         this._disableTint = true;
  1468.         this.refreshTint(true);
  1469.     };

  1470.     Game_Chronus.prototype.enableTint = function() {
  1471.         this._disableTint = false;
  1472.         this.refreshTint(true);
  1473.     };

  1474.     Game_Chronus.prototype.isEnableTint = function() {
  1475.         return !this._disableTint && !$gameMap.isDisableTint();
  1476.     };

  1477.     Game_Chronus.prototype.disableWeather = function() {
  1478.         this._disableWeather = true;
  1479.         this.refreshWeather(true);
  1480.     };

  1481.     Game_Chronus.prototype.enableWeather = function() {
  1482.         this._disableWeather = false;
  1483.         this.refreshWeather(true);
  1484.     };

  1485.     Game_Chronus.prototype.isEnableWeather = function() {
  1486.         return !this._disableWeather && !$gameMap.isDisableWeather();
  1487.     };

  1488.     Game_Chronus.prototype.setSnowLand = function() {
  1489.         this._weatherSnowLand = true;
  1490.         this.updateWeatherType();
  1491.         this.refreshWeather(true);
  1492.     };

  1493.     Game_Chronus.prototype.resetSnowLand = function() {
  1494.         this._weatherSnowLand = false;
  1495.         this.updateWeatherType();
  1496.         this.refreshWeather(true);
  1497.     };

  1498.     Game_Chronus.prototype.setRainyPercent = function(value) {
  1499.         this._badWeaterLevelMax = (value > 0 ? 2000 / value : Infinity);
  1500.         this.updateWeather();
  1501.     };

  1502.     Game_Chronus.prototype.setTimeReal = function() {
  1503.         this._realTime = true;
  1504.         this.updateRealTime();
  1505.         this.setGameVariable();
  1506.     };

  1507.     Game_Chronus.prototype.setTimeVirtual = function() {
  1508.         this._realTime = false;
  1509.         this.setGameVariable();
  1510.     };

  1511.     Game_Chronus.prototype.onBattleEnd = function() {
  1512.         if (this.isStop()) return;
  1513.         this.addTime(this._timeBattleAdd + this._timeTurnAdd * $gameTroop.turnCount());
  1514.     };

  1515.     Game_Chronus.prototype.transfer = function(realTransfer) {
  1516.         if (this.isStop()) return;
  1517.         if (realTransfer) {
  1518.             this.addTime(this._timeTransferAdd);
  1519.         }
  1520.         this.demandRefresh(true);
  1521.     };

  1522.     Game_Chronus.prototype.stop = function() {
  1523.         this._stop = true;
  1524.     };

  1525.     Game_Chronus.prototype.start = function() {
  1526.         this._stop = false;
  1527.     };

  1528.     Game_Chronus.prototype.isStop = function() {
  1529.         return this._stop;
  1530.     };

  1531.     Game_Chronus.prototype.showCalendar = function() {
  1532.         this._calendarVisible = true;
  1533.     };

  1534.     Game_Chronus.prototype.hideCalendar = function() {
  1535.         this._calendarVisible = false;
  1536.     };

  1537.     Game_Chronus.prototype.isShowingCalendar = function() {
  1538.         return this._calendarVisible;
  1539.     };

  1540.     Game_Chronus.prototype.isSnowLand = function() {
  1541.         return this._weatherSnowLand || $gameMap.isSnowLand();
  1542.     };

  1543.     Game_Chronus.prototype.showClock = function() {
  1544.         this._clockVisible = true;
  1545.     };

  1546.     Game_Chronus.prototype.hideClock = function() {
  1547.         this._clockVisible = false;
  1548.     };

  1549.     Game_Chronus.prototype.isShowingClock = function() {
  1550.         return this._clockVisible;
  1551.     };

  1552.     Game_Chronus.prototype.addTime = function(value) {
  1553.         if (arguments.length === 0) value = this._timeAutoAdd;
  1554.         this._timeMeter += value;
  1555.         while (this._timeMeter >= 60 * 24) {
  1556.             this.addDay();
  1557.             this._timeMeter -= 60 * 24;
  1558.         }
  1559.         this.demandRefresh(false);
  1560.     };

  1561.     Game_Chronus.prototype.setTime = function(hour, minute) {
  1562.         var time = hour * 60 + minute;
  1563.         if (this._timeMeter >= time) this.addDay();
  1564.         this._timeMeter = time;
  1565.         this.demandRefresh(true);
  1566.     };

  1567.     Game_Chronus.prototype.addDay = function(value) {
  1568.         if (arguments.length === 0) value = 1;
  1569.         this._dayMeter += value;
  1570.         this.demandRefresh(false);
  1571.     };

  1572.     Game_Chronus.prototype.setDay = function(year, month, day) {
  1573.         this._dayMeter = this.calcNewDay(year, month, day);
  1574.         this.demandRefresh(true);
  1575.     };

  1576.     Game_Chronus.prototype.calcNewDay = function(year, month, day) {
  1577.         var newDay = (year - 1) * this.getDaysOfYear();
  1578.         for (var i = 1; i < month; i++) {
  1579.             newDay += this.getDaysOfMonth(i);
  1580.         }
  1581.         newDay += day - 1;
  1582.         return newDay;
  1583.     };

  1584.     Game_Chronus.prototype.demandRefresh = function(effectRefreshFlg) {
  1585.         this._demandRefresh = true;
  1586.         this._frameCount    = 0;
  1587.         this.setGameVariable();
  1588.         if (effectRefreshFlg) {
  1589.             this.refreshTint(true);
  1590.             this.updateWeather();
  1591.         }
  1592.     };

  1593.     Game_Chronus.prototype.isNeedRefresh = function() {
  1594.         var needRefresh     = this._demandRefresh;
  1595.         this._demandRefresh = false;
  1596.         return needRefresh;
  1597.     };

  1598.     Game_Chronus.prototype.getDaysOfWeek = function() {
  1599.         return this._weekNames.length;
  1600.     };

  1601.     Game_Chronus.prototype.getDaysOfMonth = function(month) {
  1602.         return this._daysOfMonth[month - 1];
  1603.     };

  1604.     Game_Chronus.prototype.getDaysOfYear = function() {
  1605.         var result = 0;
  1606.         this._daysOfMonth.forEach(function(days) {
  1607.             result += days;
  1608.         });
  1609.         return result;
  1610.     };

  1611.     Game_Chronus.prototype.setGameVariable = function() {
  1612.         this.setGameVariableSub('年のゲーム変数', this.getYear.bind(this));
  1613.         this.setGameVariableSub('月のゲーム変数', this.getMonth.bind(this));
  1614.         this.setGameVariableSub('日のゲーム変数', this.getDay.bind(this));
  1615.         this.setGameVariableSub('曜日IDのゲーム変数', this.getWeekIndex.bind(this));
  1616.         this.setGameVariableSub('曜日名のゲーム変数', this.getWeekName.bind(this));
  1617.         this.setGameVariableSub('時のゲーム変数', this.getHour.bind(this));
  1618.         this.setGameVariableSub('分のゲーム変数', this.getMinute.bind(this));
  1619.         this.setGameVariableSub('時間帯IDのゲーム変数', this.getTimeZone.bind(this));
  1620.         this.setGameVariableSub('天候IDのゲーム変数', this.getWeatherTypeId.bind(this));
  1621.         this.setGameVariableSub('累計時間のゲーム変数', this.getTotalTime.bind(this));
  1622.         this.setGameVariableSub('累計日数のゲーム変数', this.getTotalDay.bind(this));
  1623.         this.setGameVariableSub('フォーマット時間の変数', this.getFormatTimeFormula.bind(this));
  1624.     };

  1625.     Game_Chronus.prototype.setGameVariableSub = function(paramName, callBack) {
  1626.         var index = getParamNumber(paramName, 0);
  1627.         if (index !== 0) {
  1628.             $gameVariables.setValue(index, callBack());
  1629.         }
  1630.     };

  1631.     Game_Chronus.prototype.getMonthOfYear = function() {
  1632.         return this._daysOfMonth.length;
  1633.     };

  1634.     Game_Chronus.prototype.getWeekName = function() {
  1635.         return this._weekNames[this.getWeekIndex()];
  1636.     };

  1637.     Game_Chronus.prototype.getWeekIndex = function() {
  1638.         return this.isRealTime() ? this._nowDate.getDay() : this._dayMeter % this.getDaysOfWeek();
  1639.     };

  1640.     Game_Chronus.prototype.getYear = function() {
  1641.         return this.isRealTime() ? this._nowDate.getFullYear() : Math.floor(this._dayMeter / this.getDaysOfYear()) + 1;
  1642.     };

  1643.     Game_Chronus.prototype.getMonth = function() {
  1644.         if (this.isRealTime()) return this._nowDate.getMonth() + 1;
  1645.         var days = this._dayMeter % this.getDaysOfYear();
  1646.         for (var i = 0; i < this._daysOfMonth.length; i++) {
  1647.             days -= this._daysOfMonth[i];
  1648.             if (days < 0) return i + 1;
  1649.         }
  1650.         return null;
  1651.     };

  1652.     Game_Chronus.prototype.getDay = function() {
  1653.         if (this.isRealTime()) return this._nowDate.getDate();
  1654.         var days = this._dayMeter % this.getDaysOfYear();
  1655.         for (var i = 0; i < this._daysOfMonth.length; i++) {
  1656.             if (days < this._daysOfMonth[i]) return days + 1;
  1657.             days -= this._daysOfMonth[i];
  1658.         }
  1659.         return null;
  1660.     };

  1661.     Game_Chronus.prototype.getHour = function() {
  1662.         return this.isRealTime() ? this._nowDate.getHours() : Math.floor(this._timeMeter / 60);
  1663.     };

  1664.     Game_Chronus.prototype.getMinute = function() {
  1665.         return this.isRealTime() ? this._nowDate.getMinutes() : this._timeMeter % 60;
  1666.     };

  1667.     Game_Chronus.prototype.getFormatTimeFormula = function() {
  1668.         this._disablePadding = true;
  1669.         var formula          = this.convertDateFormatText(getParamString('フォーマット時間の計算式'));
  1670.         this._disablePadding = false;
  1671.         return eval(formula);
  1672.     };

  1673.     Game_Chronus.prototype.getDateFormat = function(index) {
  1674.         return this.convertDateFormatText(getParamString('日時フォーマット' + String(index)));
  1675.     };

  1676.     Game_Chronus.prototype.convertDateFormatText = function(format) {
  1677.         format = format.replace(/(YYYY)/gi, function() {
  1678.             return this.getValuePadding(this.getYear(), arguments[1].length);
  1679.         }.bind(this));
  1680.         format = format.replace(/MON/gi, function() {
  1681.             return this._monthNames[this.getMonth() - 1];
  1682.         }.bind(this));
  1683.         format = format.replace(/MM/gi, function() {
  1684.             return this.getValuePadding(this.getMonth(), String(this.getMonthOfYear()).length);
  1685.         }.bind(this));
  1686.         format = format.replace(/DDALL/gi, function() {
  1687.             return this.getValuePadding(this.getTotalDay());
  1688.         }.bind(this));
  1689.         format = format.replace(/DD/gi, function() {
  1690.             return this.getValuePadding(this.getDay(),
  1691.                 String(this.getDaysOfMonth(this.getMonth())).length);
  1692.         }.bind(this));
  1693.         format = format.replace(/HH24/gi, function() {
  1694.             return this.getValuePadding(this.getHour(), 2);
  1695.         }.bind(this));
  1696.         format = format.replace(/HH/gi, function() {
  1697.             return this.getValuePadding(this.getHour() % 12, 2);
  1698.         }.bind(this));
  1699.         format = format.replace(/AM/gi, function() {
  1700.             return Math.floor(this.getHour() / 12) === 0 ?
  1701.                 $gameSystem.isJapanese() ? '午前' : 'Morning  ' :
  1702.                 $gameSystem.isJapanese() ? '午後' : 'Afternoon';
  1703.         }.bind(this));
  1704.         format = format.replace(/MI/gi, function() {
  1705.             return this.getValuePadding(this.getMinute(), 2);
  1706.         }.bind(this));
  1707.         format = format.replace(/DY/gi, function() {
  1708.             return this.getWeekName();
  1709.         }.bind(this));
  1710.         format = format.replace(/TZ/gi, function() {
  1711.             return this.getTimeZoneName();
  1712.         }.bind(this));
  1713.         return format;
  1714.     };

  1715.     Game_Chronus.prototype.getTimeZone = function() {
  1716.         var timeId = 0;
  1717.         settings.timeZone.forEach(function(zoneInfo) {
  1718.             if (this.isHourInRange(zoneInfo.start, zoneInfo.end)) timeId = zoneInfo.timeId;
  1719.         }.bind(this));
  1720.         return timeId;
  1721.     };

  1722.     Game_Chronus.prototype.getTimeZoneName = function() {
  1723.         var timeId = this.getTimeZone();
  1724.         return settings.timeZone.filter(function(zoneInfo) {
  1725.             return zoneInfo.timeId === timeId;
  1726.         })[0].name;
  1727.     };

  1728.     Game_Chronus.prototype.getWeatherTypeId = function() {
  1729.         return this._weatherType;
  1730.     };

  1731.     Game_Chronus.prototype.getWeatherType = function() {
  1732.         return Game_Chronus.weatherTypes[this.getWeatherTypeId()];
  1733.     };

  1734.     Game_Chronus.prototype.getValuePadding = function(value, digit, padChar) {
  1735.         if (this._disablePadding) {
  1736.             return value;
  1737.         }
  1738.         if (arguments.length === 2) padChar = '0';
  1739.         var result = '';
  1740.         for (var i = 0; i < digit; i++) result += padChar;
  1741.         result += value;
  1742.         return result.substr(-digit);
  1743.     };

  1744.     Game_Chronus.prototype.isHourInRange = function(min, max) {
  1745.         var hour = this.getHour();
  1746.         return hour >= min && hour <= max;
  1747.     };

  1748.     Game_Chronus.prototype.getAnalogueHour = function() {
  1749.         return this.getHour() + (this.getAnalogueMinute() / 60);
  1750.     };

  1751.     Game_Chronus.prototype.getAnalogueMinute = function() {
  1752.         return this.getMinute() + (this.isRealTime() ? 0 : this._frameCount / paramAutoAddInterval * this._timeAutoAdd);
  1753.     };

  1754.     Game_Chronus.prototype.getRotationHourHand = function() {
  1755.         var numberOfHour = param24hourClock ? 24 : 12;
  1756.         return (this.getAnalogueHour() % numberOfHour) * (360 / numberOfHour) * Math.PI / 180;
  1757.     };

  1758.     Game_Chronus.prototype.getRotationMinuteHand = function() {
  1759.         return this.getAnalogueMinute() * (360 / 60) * Math.PI / 180;
  1760.     };

  1761.     Game_Chronus.prototype.getTotalTime = function() {
  1762.         if (this.isRealTime()) {
  1763.             return (this._nowDate - this._initDate) / (1000 * 60);
  1764.         } else {
  1765.             var dayMeter  = this._dayMeter - (this._criterionDay || 0);
  1766.             var timeMeter = this._timeMeter - (this._criterionTime || 0);
  1767.             return dayMeter * 24 * 60 + timeMeter;
  1768.         }
  1769.     };

  1770.     Game_Chronus.prototype.getTotalDay = function() {
  1771.         return Math.floor(this.getTotalTime() / (24 * 60)) + 1;
  1772.     };

  1773.     Game_Chronus.prototype.makeAlarm = function(timerName, timeNumber, switchKey, interval) {
  1774.         var baseTime   = this.getTotalTime();
  1775.         var min        = timeNumber % 100;
  1776.         var hour       = Math.floor(timeNumber / 100) % 100;
  1777.         var timeMeter  = hour * 60 + min - (this._criterionTime || 0);
  1778.         var day        = Math.floor(timeNumber / 10000) % 100;
  1779.         var month      = Math.floor(timeNumber / 1000000) % 100;
  1780.         var year       = Math.floor(timeNumber / 100000000);
  1781.         var dayMeter   = this.calcNewDay(year, month, day) - (this._criterionDay || 0);
  1782.         var targetTime = dayMeter * 24 * 60 + timeMeter;
  1783.         this.makeTimer(timerName, (targetTime - baseTime) || 0, switchKey, true, interval);
  1784.     };

  1785.     Game_Chronus.prototype.makeTimer = function(timerName, timeout, switchKey, loop, interval) {
  1786.         var timer = new Game_ChronusTimer(timeout, switchKey, loop, interval);
  1787.         if (timerName) {
  1788.             this._namedTimers[timerName] = timer;
  1789.         } else {
  1790.             this._timers.push(timer);
  1791.         }
  1792.     };

  1793.     Game_Chronus.prototype.clearTimer = function(timerName) {
  1794.         delete this._namedTimers[timerName];
  1795.     };

  1796.     Game_Chronus.prototype.stopTimer = function(timerName) {
  1797.         var timer = this._namedTimers[timerName];
  1798.         if (timer) {
  1799.             timer.stop();
  1800.         }
  1801.     };

  1802.     Game_Chronus.prototype.startTimer = function(timerName) {
  1803.         var timer = this._namedTimers[timerName];
  1804.         if (timer) {
  1805.             timer.start();
  1806.         }
  1807.     };

  1808.     Game_Chronus.prototype.getClockBaseFile = function() {
  1809.         return this._clockBaseFile || paramClockBaseFile;
  1810.     };

  1811.     Game_Chronus.prototype.getMinuteHandFile = function() {
  1812.         return this._minuteHandFile || paramMinutesHandFile;
  1813.     };

  1814.     Game_Chronus.prototype.getHourHandFile = function() {
  1815.         return this._hourHandFile || paramHourHandFile;
  1816.     };

  1817.     Game_Chronus.prototype.setClockBaseFile = function(name) {
  1818.         this._clockBaseFile = name;
  1819.     };

  1820.     Game_Chronus.prototype.setMinuteHandFile = function(name) {
  1821.         this._minuteHandFile = name;
  1822.     };

  1823.     Game_Chronus.prototype.setHourHandFile = function(name) {
  1824.         this._hourHandFile = name;
  1825.     };

  1826.     //=============================================================================
  1827.     // Game_ChronusTimer
  1828.     //  ゲーム内時間のタイマーを扱うクラスです。このクラスはGame_Chronusクラスで生成されます。
  1829.     //  セーブデータの保存対象のためグローバル領域に定義します。
  1830.     //=============================================================================
  1831.     Game_ChronusTimer.prototype             = Object.create(Game_ChronusTimer.prototype);
  1832.     Game_ChronusTimer.prototype.constructor = Game_ChronusTimer;

  1833.     Game_ChronusTimer.prototype.initialize = function(timeout, switchKey, loop, interval) {
  1834.         this._timeout = timeout;
  1835.         this._interval = interval || timeout;
  1836.         this._loop    = loop;
  1837.         this._baseTime = this.getTotalTime();
  1838.         if (Array.isArray(switchKey)) {
  1839.             this.setCallBackSelfSwitch(switchKey);
  1840.         } else {
  1841.             this.setCallBackSwitch(switchKey);
  1842.         }
  1843.         this.start();
  1844.     };

  1845.     Game_ChronusTimer.prototype.start = function() {
  1846.         this._start = true;
  1847.     };

  1848.     Game_ChronusTimer.prototype.stop = function() {
  1849.         this._start = false;
  1850.     };

  1851.     Game_ChronusTimer.prototype.getTotalTime = function() {
  1852.         return $gameSystem.chronus().getTotalTime();
  1853.     };

  1854.     Game_ChronusTimer.prototype.setCallBackSwitch = function(switchId) {
  1855.         this._callBackSwitchId = switchId;
  1856.     };

  1857.     Game_ChronusTimer.prototype.setCallBackSelfSwitch = function(selfSwitchKey) {
  1858.         this._callBackSelfSwitchKey = selfSwitchKey;
  1859.     };

  1860.     Game_ChronusTimer.prototype.update = function() {
  1861.         if (!this._start || !this.isTimeout()) {
  1862.             return true;
  1863.         }
  1864.         this.onTimeout();
  1865.         if (this._loop) {
  1866.             this.resetBaseTime();
  1867.             return true;
  1868.         } else {
  1869.             return false;
  1870.         }
  1871.     };

  1872.     Game_ChronusTimer.prototype.resetBaseTime = function() {
  1873.         while(this.isTimeout()) {
  1874.             this._baseTime += this._timeout;
  1875.             this._timeout = this._interval;
  1876.         }
  1877.     };

  1878.     Game_ChronusTimer.prototype.isTimeout = function() {
  1879.         return this._baseTime + this._timeout <= this.getTotalTime();
  1880.     };

  1881.     Game_ChronusTimer.prototype.onTimeout = function() {
  1882.         if (this._callBackSwitchId) {
  1883.             $gameSwitches.setValue(this._callBackSwitchId, true);
  1884.         }
  1885.         if (this._callBackSelfSwitchKey) {
  1886.             $gameSelfSwitches.setValue(this._callBackSelfSwitchKey, true);
  1887.         }
  1888.     };
  1889. })();
复制代码
回复

使用道具 举报

梦石
0
星屑
3081
在线时间
236 小时
注册时间
2021-4-22
回帖
203
发表于 2022-4-29 14:48:26 | 显示全部楼层

var myDate = new Date();
var myDate = new Date();myDate.getYear();        //获取当前年份(2位)
var myDate = new Date();myDate.getFullYear();    //获取完整的年份(4位,1970-????)
var myDate = new Date();myDate.getMonth();       //获取当前月份(0-11,0代表1月)
var myDate = new Date();myDate.getDate();        //获取当前日(1-31)
var myDate = new Date();myDate.getDay();         //获取当前星期X(0-6,0代表星期天)
var myDate = new Date();myDate.getTime();        //获取当前时间(从1970.1.1开始的毫秒数)
var myDate = new Date();myDate.getHours();       //获取当前小时数(0-23)
var myDate = new Date();myDate.getMinutes();     //获取当前分钟数(0-59)
var myDate = new Date();myDate.getSeconds();     //获取当前秒数(0-59)
var myDate = new Date();myDate.getMilliseconds();    //获取当前毫秒数(0-999)
var myDate = new Date();myDate.toLocaleDateString();     //获取当前日期
var mytime=myDate.toLocaleTimeString();     //获取当前时间
var myDate = new Date();myDate.toLocaleString( );        //获取日期与时间
回复

使用道具 举报

梦石
0
星屑
832
在线时间
105 小时
注册时间
2020-12-26
回帖
67
 楼主| 发表于 2022-4-29 17:34:19 | 显示全部楼层
灰常感激!!!
回复

使用道具 举报

梦石
0
星屑
780
在线时间
77 小时
注册时间
2019-4-7
回帖
52
发表于 2022-6-17 10:21:28 | 显示全部楼层
本帖最后由 破晓酱11 于 2022-6-17 10:48 编辑
dabaxhei 发表于 2022-4-29 14:48
var myDate = new Date();
var myDate = new Date();myDate.getYear();        //获取当前年份(2位)
var m ...


大佬,这个mv也可以用吗?还有就是你这个范例中的调用的这个插件指令是需要搭配哪一个插件?

点评

可以,这个不是插件  发表于 2022-6-17 14:31
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部