/
RaskolnickOFF
/
3D
Обзор
Документация
Войти
/
RaskolnickOFF
/
3D
Код
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
js/debug/TimeDebugOverlay.js
90 строк
4 KB
RaskolnickOFF
debug: fix time display format (8.86 → 8:51), add season and week info
16 июн 2026, 02:13
16 июн 2026, 02:13
6042dcd
Код
Авторство
О чём код?
// js/debug/TimeDebugOverlay.js import LIB from 'LIB'; export class TimeDebugOverlay { constructor(timeInterval, SETTINGS, container) { this.settings = SETTINGS; if (!this.settings.debug.time) return; this.cfg = this.settings.UI.debug; this._interval = timeInterval; this.timer = 0; this.container = container; this._nightEl = null; this._dayEl = null; this._timeEl = null; this._timelineEl = null; this._renderDOM(this.container); } _renderDOM(container) { if (!this.settings.debug.time) return; const label = document.createElement('label'); const span = document.createElement('span'); span.textContent = this.cfg.timeCurrent; span.className = this.cfg.timeCurrentClass; const row = LIB.dom.infoRow({ [this.cfg.dayNightClass]: this.cfg.timeDayNight, [this.cfg.timeDayClass]: this.cfg.timeDay, [this.cfg.timeWeekClass]: this.cfg.timeWeek }); label.append(span, row); const timelineLabel = document.createElement('label'); const timelineSpan = document.createElement('span'); timelineSpan.textContent = this.cfg.timelineLabel; timelineSpan.className = this.cfg.timelineSeasonClass; const timeline = LIB.dom.range( null, this.cfg.timelineClass, null, this.settings.debug.timelineMin, this.settings.debug.timelineMax, this.settings.debug.timelineStep ); const buttonsFirstLine = LIB.dom.buttonsRow([ ['⏸️', 'pause'], ['▶️', 'resume'], ['🐌 x0.1', 'scale-0.1'], ['🚗 x1', 'scale-1'], ['🚀 x10', 'scale-10'] ], null, this.cfg.timeButtonClass); //null is label const buttonsSecondLine = LIB.dom.buttonsRow([ ['Утро', 'sunrise'], ['Полдень', 'noon'], ['Вечер', 'sunset'], ['Полночь', 'midnight'] ], null, this.cfg.timeButtonClass); timelineLabel.append(timelineSpan, buttonsFirstLine, timeline, buttonsSecondLine); container.append(label, timelineLabel); this._nightEl = row.querySelector('.' + this.cfg.dayNightClass); this._dayEl = row.querySelector('.' + this.cfg.timeDayClass); this._weekEl = row.querySelector('.' + this.cfg.timeWeekClass); this._timelineEl = timeline; this._currentTime = label.querySelector('.' + this.cfg.timeCurrentClass); this._timeLineSeason = timelineLabel.querySelector('.' + this.cfg.timelineSeasonClass); } update(env, acc) { if (!this.settings.debug.time) return; this.timer += acc; if (this.timer < this._interval) return; this.timer -= this._interval; this._nightEl.textContent = env.isNight ? this.cfg.nightIcon : this.cfg.dayIcon; this._dayEl.textContent = env.day; this._weekEl.textContent = env.week; if (document.activeElement !== this._timelineEl) { this._timelineEl.value = env.timeOfDay; } this._timeLineSeason.textContent = `${this.cfg.timelineLabel}${this.cfg.timelineSeason} ${this.cfg.timelineSeasons[env.season]}`; const h = Math.floor(env.timeOfDay); const m = Math.floor((env.timeOfDay - h) * 60); this._currentTime.textContent = `${this.cfg.timeCurrent} ${h}:${m.toString().padStart(2, '0')}`; } updateInterval(interval) { if (!this.settings.debug.time) return; if (interval !== this._interval) { this._interval = interval; } } }