From e050c8b1667e08be1b8e8aaef118a990933c9c06 Mon Sep 17 00:00:00 2001 From: Rintim Date: Mon, 27 Nov 2023 19:16:35 +0800 Subject: [PATCH] feat: provide announce time for theme change. --- game/game.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/game/game.js b/game/game.js index b9215318e..8bf10a89e 100644 --- a/game/game.js +++ b/game/game.js @@ -1563,25 +1563,30 @@ new Promise(resolve=>{ node.menu=ui.create.div(node,'','
'); } }, - onclick:function(theme){ + onclick:gnc.of(function*(theme){ game.saveConfig('theme',theme); ui.arena.hide(); lib.init.background(); if(lib.config.autostyle){ - if(theme=='simple'){ - lib.configMenu.appearence.config.player_border.onclick('slim'); + if(theme === "simple"){ + lib.configMenu.appearence.config.player_border.onclick("slim"); } else{ - lib.configMenu.appearence.config.player_border.onclick('normal'); + lib.configMenu.appearence.config.player_border.onclick("normal"); } } - setTimeout(function(){ - var theme=ui.css.theme; - ui.css.theme=lib.init.css(lib.assetURL+'theme/'+lib.config.theme,'style'); - theme.remove(); - setTimeout(function(){ui.arena.show();},100); - },500); - } + lib.announce.publish("Noname.Apperaence.Theme.onChanging", theme); + yield new Promise(resolve => setTimeout(resolve, 500)); + + const deletingTheme = ui.css.theme; + ui.css.theme=lib.init.css(lib.assetURL+'theme/'+lib.config.theme,'style'); + deletingTheme.remove(); + lib.announce.publish("Noname.Apperaence.Theme.onChanged", theme); + yield new Promise(resolve => setTimeout(resolve, 100)); + + ui.arena.show(); + lib.announce.publish("Noname.Apperaence.Theme.onChangeFinished", theme); + }) }, layout:{ name:'布局',