From 5e4d32361502ef0e11b33fab922cd360fb1231cd Mon Sep 17 00:00:00 2001 From: Rintim Date: Thu, 7 Sep 2023 19:00:34 +0800 Subject: [PATCH] add basic css-string-like methods. --- game/game.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/game/game.js b/game/game.js index c008bdbfb..b680bbcaa 100644 --- a/game/game.js +++ b/game/game.js @@ -32166,10 +32166,18 @@ that._cache.rules=[]; that._cache.style=document.createElement("style"); document.head.append(that._cache.style); - that._cache.sheet = this.#style.sheet; + that._cache.sheet = that._cache.style.sheet; delete game.dynamicStyle.init; return true; - } + }, + translate:style=>{ + let result=[]; + for(const name in style){ + result.push(`${name.replace(/([A-Z])/g, match => `-${match.toLowerCase()}`)}: ${style[name]};`); + } + return result.join(" "); + }, + generate:(name, style)=>[`${name} {`, game.dynamicStyle.translate(style), "}"].join(" ") }, //Add a background music to the config option //在设置选项中添加一首背景音乐