From 76aa1ae4c0ff7c248f553e06a5b169c11a61ce6a Mon Sep 17 00:00:00 2001 From: Rintim Date: Thu, 7 Sep 2023 22:31:54 +0800 Subject: [PATCH] add dynamicStyle.update --- game/game.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/game/game.js b/game/game.js index 14260a993..423ab5e79 100644 --- a/game/game.js +++ b/game/game.js @@ -32197,7 +32197,33 @@ has:name=>game.dynamicStyle._cache.rules.some(item=>item[0]==name), get:name=>game.dynamicStyle.find(item=>item[0]==name), find:fn=>game.dynamicStyle._cache.rules.find(fn), - size:()=>game.dynamicStyle._cache.rules.length + size:()=>game.dynamicStyle._cache.rules.length, + indexOf:name=>{ + for (let i=0;i{ + const that=game.dynamicStyle; + try{ + if(this.has(name)){ + const index=that.indexOf(name); + that._cache.sheet.deleteRule(index); + that._cache.sheet.insertRule(that.generate(name, style), index); + that._cache.rules[index] = [name, style]; + }else{ + const index=that._cache.rules.length; + that._cache.rules.push([name, style]); + that._cache.sheet.insertRule(that.generate(name, style), index); + } + return true; + } + catch(e){ + console.log(e); + return false; + } + } }, //Add a background music to the config option //在设置选项中添加一首背景音乐