From cc38f04da5700b53402e9c7e91b0ddfabc65db1d Mon Sep 17 00:00:00 2001 From: DazFather <39210887+DazFather@users.noreply.github.com> Date: Mon, 23 May 2022 19:14:29 +0200 Subject: [PATCH 1/2] Improved headless on click handling --- dist/css/style.css | 25 +++++++++++++++++----- dist/index.html | 2 +- src/Controllers/ControlPanel.js | 37 +++++---------------------------- 3 files changed, 26 insertions(+), 38 deletions(-) diff --git a/dist/css/style.css b/dist/css/style.css index aecddcdd..5d5ec70d 100644 --- a/dist/css/style.css +++ b/dist/css/style.css @@ -262,14 +262,29 @@ input:hover,input:active { /* display: none; */ } +body { + margin: 0; + padidng: 0; + background-color: #333333; +} + #headless-notification { - display: none; + display: grid; + place-content: center; position: fixed; - color: white; + top: 1rem; + width: 100%; font-size: 200px; - left: 0; - top: 0; - padding-left: 10px; + animation: blink infinite alternate 0.5s; + transition: visibility 0.5s, opacity 0.5s; +} +#headless-notification.hide { + opacity: 0; + visibility: collapse; +} +@keyframes blink { + from { color: hsl(0, 0%, 80%); } + to { color: hsl(0, 0%, 40%); } } #minimize { diff --git a/dist/index.html b/dist/index.html index e4465e62..9e69e53b 100644 --- a/dist/index.html +++ b/dist/index.html @@ -285,7 +285,7 @@

Statistics

-
+
diff --git a/src/Controllers/ControlPanel.js b/src/Controllers/ControlPanel.js index ca87c2bd..69d3113a 100644 --- a/src/Controllers/ControlPanel.js +++ b/src/Controllers/ControlPanel.js @@ -20,8 +20,6 @@ class ControlPanel { this.env_controller.setControlPanel(this); this.editor_controller.setControlPanel(this); this.stats_panel = new StatsPanel(this.engine.env); - this.headless_opacity = 1; - this.opacity_change_rate = -0.8; this.paused=false; this.setHyperparamDefaults(); } @@ -132,15 +130,10 @@ class ControlPanel { }.bind(this)); $('.headless').click(function() { - $('.headless').find("i").toggleClass("fa fa-eye"); - $('.headless').find("i").toggleClass("fa fa-eye-slash"); - if (WorldConfig.headless){ - $('#headless-notification').css('display', 'none'); - this.engine.env.renderFull(); - } - else { - $('#headless-notification').css('display', 'block'); - } + $('.headless').find("i").toggleClass("fa-eye fa-eye-slash"); + $('#headless-notification').toggleClass('hide'); + if (WorldConfig.headless) this.engine.env.renderFull(); + WorldConfig.headless = !WorldConfig.headless; }.bind(this)); } @@ -477,30 +470,10 @@ class ControlPanel { this.fps = this.engine.fps; } - updateHeadlessIcon(delta_time) { - if (!this.engine.running) - return; - const min_opacity = 0.4; - var op = this.headless_opacity + (this.opacity_change_rate*delta_time/1000); - if (op <= min_opacity){ - op=min_opacity; - this.opacity_change_rate = -this.opacity_change_rate; - } - else if (op >= 1){ - op=1; - this.opacity_change_rate = -this.opacity_change_rate; - } - this.headless_opacity = op; - $('#headless-notification').css('opacity',(op*100)+'%'); - } - - update(delta_time) { + update() { $('#fps-actual').text("Actual FPS: " + Math.floor(this.engine.actual_fps)); $('#reset-count').text("Auto reset count: " + this.engine.env.reset_count); this.stats_panel.updateDetails(); - if (WorldConfig.headless) - this.updateHeadlessIcon(delta_time); - } } From 5d6dbdb357b991450b44fc3781d47488dd9d2be0 Mon Sep 17 00:00:00 2001 From: DazFather <39210887+DazFather@users.noreply.github.com> Date: Mon, 23 May 2022 19:17:53 +0200 Subject: [PATCH 2/2] Small cleanup --- dist/css/style.css | 6 ------ 1 file changed, 6 deletions(-) diff --git a/dist/css/style.css b/dist/css/style.css index 5d5ec70d..96dfbe3f 100644 --- a/dist/css/style.css +++ b/dist/css/style.css @@ -262,12 +262,6 @@ input:hover,input:active { /* display: none; */ } -body { - margin: 0; - padidng: 0; - background-color: #333333; -} - #headless-notification { display: grid; place-content: center;