From fdfa99ef6c81c8bd835f60e47e85c1e4b7dd7fcd Mon Sep 17 00:00:00 2001 From: ogihara88sai Date: Fri, 12 Aug 2022 22:36:50 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20`[ambient=5Flight=5Fon]``[ambient=5Flig?= =?UTF-8?q?ht=5Foff]`=E8=BF=BD=E5=8A=A0:=20=E7=92=B0=E5=A2=83=E5=85=89?= =?UTF-8?q?=E3=81=AE=E3=82=AA=E3=83=B3=E3=82=AA=E3=83=95=E5=88=87=E3=82=8A?= =?UTF-8?q?=E6=9B=BF=E3=81=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 20 ++++- .../data/others/plugin/ambient_light/main.js | 57 ++++++++++--- .../data/others/plugin/ambient_light/main.js | 83 ++++++++++--------- .../data/others/plugin/ambient_light/main.js | 57 ++++++++++--- package.json | 2 +- 5 files changed, 154 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index a7cea9a..2703400 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ 【開発環境】Windows 10 64bit OS 【製作者】荻原(おぎはら) 【連絡先】https://twitter.com/ogihara88sai -【バージョン】1.0.2 -【最終更新日】2022.07.21 19:11:12 +【バージョン】1.1.0 +【最終更新日】2022.08.12 22:22:27 【動作デモ】https://ogihara88sai.github.io/tsp-ambient-light/latest/ 【ダウンロード】https://github.com/ogihara88sai/tsp-ambient-light/releases 【ライセンス】MIT @@ -173,6 +173,18 @@ name パラメータを指定することで現在画面上に出ているキャ 指定できるパラメータはありません。 +### [ambient_light_off] 環境光の無効化 + +環境光の効果をオフにします。環境光の効果を再開するには [ambient_light_on] タグを使用してください。 + +指定できるパラメータはありません。 + +### [ambient_light_on] 環境光の有効化 + +環境光の効果をオンにします(プラグインを読み込んだ直後はオンの状態です)。環境光の効果を一時的にオフにしたい場合には [ambient_light_off] タグを使用してください。 + +指定できるパラメータはありません。 + --- ## 更新履歴 @@ -188,3 +200,7 @@ name パラメータを指定することで現在画面上に出ているキャ #### v1.0.2 - v1.0.1 で Mac を一律で非サポートと判定していましたが、Mac においても Chrome なら動作可能との報告を受けましたので(ダメなのは Safari)、「iOS および Safari」でプラグインを無効化する仕様に変更しました。 + +### v1.1.0 + +- [ambient_light_on] タグおよび [ambient_light_off] タグを追加しました。 diff --git a/docs/latest/data/others/plugin/ambient_light/main.js b/docs/latest/data/others/plugin/ambient_light/main.js index b5548c3..4abe893 100644 --- a/docs/latest/data/others/plugin/ambient_light/main.js +++ b/docs/latest/data/others/plugin/ambient_light/main.js @@ -19,6 +19,7 @@ default_shadow: true, default_shadow_size: 16, default_shadow_opacity: 0.3, + is_enabled: true, storage_map: {}, } @@ -65,12 +66,14 @@ const j_svg = $(` + - + + - + @@ -78,6 +81,7 @@ + `).appendTo('body') @@ -112,14 +116,17 @@ const updateStyle = () => { const css_map = TG.stat.ambient_light_config.css_map let css_str = '' - for (const selector in css_map) { - css_str += selector + '{' - const style_map = css_map[selector] - for (const prop in style_map) { - const value = style_map[prop] - css_str += `${prop}:${value};` + // 有効な場合のみ。無効な場合はスタイルを空っぽにする + if (TG.stat.ambient_light_config.is_enabled) { + for (const selector in css_map) { + css_str += selector + '{' + const style_map = css_map[selector] + for (const prop in style_map) { + const value = style_map[prop] + css_str += `${prop}:${value};` + } + css_str += '}' } - css_str += '}' } j_style.text(css_str) } @@ -648,7 +655,7 @@ pm: {}, - start: async () => { + start: () => { // 非サポート環境では即nextOrder if (!is_supported) { TG.ftag.nextOrder() @@ -660,9 +667,37 @@ }, } + // ================================ + // [ambient_light_on]タグ定義 + // ================================ + + TG.ftag.master_tag.ambient_light_on = { + kag: TG, + + start: () => { + TG.stat.ambient_light_config.is_enabled = true + restore() + TG.ftag.nextOrder() + }, + } + + // ================================ + // [ambient_light_off]タグ定義 + // ================================ + + TG.ftag.master_tag.ambient_light_off = { + kag: TG, + + start: () => { + TG.stat.ambient_light_config.is_enabled = false + restore() + TG.ftag.nextOrder() + }, + } + // TYRANO.kag.onが使えるなら使おう if (TG.on !== undefined) { - TG.on('load:complete', () => { + TG.on('load-beforemaking', () => { restore() }) } diff --git a/docs/tyranoscript_v488/data/others/plugin/ambient_light/main.js b/docs/tyranoscript_v488/data/others/plugin/ambient_light/main.js index fb63a28..5b0d69d 100644 --- a/docs/tyranoscript_v488/data/others/plugin/ambient_light/main.js +++ b/docs/tyranoscript_v488/data/others/plugin/ambient_light/main.js @@ -40,6 +40,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar default_shadow: true, default_shadow_size: 16, default_shadow_opacity: 0.3, + is_enabled: true, storage_map: {} }; // // プラグインがサポートされているかどうかを確認 @@ -72,7 +73,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar var link_target_tag = TG.stat.mp.link || 'bg'; // SVG Filterの追加 - var j_svg = $("\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ")).appendTo('body'); // , , への参照 + var j_svg = $("\n \n \n\n \n \n\n\n \n \n\n \n \n \n \n \n \n \n\n \n \n ")).appendTo('body'); // , , への参照 var e_flood_main = j_svg.find('#ambient_light_feflood').get(0); var e_flood_sub = j_svg.find('#ambient_light_feflood_2').get(0); @@ -100,18 +101,20 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar var updateStyle = function updateStyle() { var css_map = TG.stat.ambient_light_config.css_map; - var css_str = ''; + var css_str = ''; // 有効な場合のみ。無効な場合はスタイルを空っぽにする - for (var selector in css_map) { - css_str += selector + '{'; - var style_map = css_map[selector]; + if (TG.stat.ambient_light_config.is_enabled) { + for (var selector in css_map) { + css_str += selector + '{'; + var style_map = css_map[selector]; - for (var prop in style_map) { - var value = style_map[prop]; - css_str += "".concat(prop, ":").concat(value, ";"); - } + for (var prop in style_map) { + var value = style_map[prop]; + css_str += "".concat(prop, ":").concat(value, ";"); + } - css_str += '}'; + css_str += '}'; + } } j_style.text(css_str); @@ -822,42 +825,42 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar TG.ftag.master_tag.ambient_light_restore = { kag: TG, pm: {}, - start: function () { - var _start5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() { - return _regeneratorRuntime().wrap(function _callee8$(_context8) { - while (1) { - switch (_context8.prev = _context8.next) { - case 0: - if (is_supported) { - _context8.next = 3; - break; - } - - TG.ftag.nextOrder(); - return _context8.abrupt("return"); - - case 3: - restore(); - TG.ftag.nextOrder(); + start: function start() { + // 非サポート環境では即nextOrder + if (!is_supported) { + TG.ftag.nextOrder(); + return; + } - case 5: - case "end": - return _context8.stop(); - } - } - }, _callee8); - })); + restore(); + TG.ftag.nextOrder(); + } + }; // ================================ + // [ambient_light_on]タグ定義 + // ================================ - function start() { - return _start5.apply(this, arguments); - } + TG.ftag.master_tag.ambient_light_on = { + kag: TG, + start: function start() { + TG.stat.ambient_light_config.is_enabled = true; + restore(); + TG.ftag.nextOrder(); + } + }; // ================================ + // [ambient_light_off]タグ定義 + // ================================ - return start; - }() + TG.ftag.master_tag.ambient_light_off = { + kag: TG, + start: function start() { + TG.stat.ambient_light_config.is_enabled = false; + restore(); + TG.ftag.nextOrder(); + } }; // TYRANO.kag.onが使えるなら使おう if (TG.on !== undefined) { - TG.on('load:complete', function () { + TG.on('load-beforemaking', function () { restore(); }); } diff --git a/docs/tyranoscript_v514b/data/others/plugin/ambient_light/main.js b/docs/tyranoscript_v514b/data/others/plugin/ambient_light/main.js index b5548c3..4abe893 100644 --- a/docs/tyranoscript_v514b/data/others/plugin/ambient_light/main.js +++ b/docs/tyranoscript_v514b/data/others/plugin/ambient_light/main.js @@ -19,6 +19,7 @@ default_shadow: true, default_shadow_size: 16, default_shadow_opacity: 0.3, + is_enabled: true, storage_map: {}, } @@ -65,12 +66,14 @@ const j_svg = $(` + - + + - + @@ -78,6 +81,7 @@ + `).appendTo('body') @@ -112,14 +116,17 @@ const updateStyle = () => { const css_map = TG.stat.ambient_light_config.css_map let css_str = '' - for (const selector in css_map) { - css_str += selector + '{' - const style_map = css_map[selector] - for (const prop in style_map) { - const value = style_map[prop] - css_str += `${prop}:${value};` + // 有効な場合のみ。無効な場合はスタイルを空っぽにする + if (TG.stat.ambient_light_config.is_enabled) { + for (const selector in css_map) { + css_str += selector + '{' + const style_map = css_map[selector] + for (const prop in style_map) { + const value = style_map[prop] + css_str += `${prop}:${value};` + } + css_str += '}' } - css_str += '}' } j_style.text(css_str) } @@ -648,7 +655,7 @@ pm: {}, - start: async () => { + start: () => { // 非サポート環境では即nextOrder if (!is_supported) { TG.ftag.nextOrder() @@ -660,9 +667,37 @@ }, } + // ================================ + // [ambient_light_on]タグ定義 + // ================================ + + TG.ftag.master_tag.ambient_light_on = { + kag: TG, + + start: () => { + TG.stat.ambient_light_config.is_enabled = true + restore() + TG.ftag.nextOrder() + }, + } + + // ================================ + // [ambient_light_off]タグ定義 + // ================================ + + TG.ftag.master_tag.ambient_light_off = { + kag: TG, + + start: () => { + TG.stat.ambient_light_config.is_enabled = false + restore() + TG.ftag.nextOrder() + }, + } + // TYRANO.kag.onが使えるなら使おう if (TG.on !== undefined) { - TG.on('load:complete', () => { + TG.on('load-beforemaking', () => { restore() }) } diff --git a/package.json b/package.json index 1087cf6..a016f1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tsp-ambient-light", - "version": "1.0.2", + "version": "1.1.0", "description": "", "main": "index.js", "scripts": {