From f75c726656ca1754fb6a5173ab8c5e6b11efc97c Mon Sep 17 00:00:00 2001 From: shijian <2954700422@qq.com> Date: Sat, 30 Sep 2023 01:47:49 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=E9=BB=98=E8=AE=A4=E5=AD=97=E4=BD=93?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=AD=97=E4=BD=93=E5=A4=A7=E5=B0=8F=E5=8A=9F=E8=83=BD=E8=8F=9C?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/game.js | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/game/game.js b/game/game.js index 76771a5e4..8297131ee 100644 --- a/game/game.js +++ b/game/game.js @@ -40951,7 +40951,11 @@ } //创建ul列表 const createMenu=function(pos,self,List,click){ - if (self&&self.createMenu) return false; + if (self&&self.createMenu) { + createList.push(self.createMenu); + ui.window.appendChild(self.createMenu); + return self.createMenu; + } const parent=self.parentNode; if (parent){ for(let i=0;icontainer.editor.refresh(),0); - game.saveConfig('codeMirror_theme', theme); + game.saveConfig('codeMirror_theme',theme); closeMenu.call(self); }; const ul=createMenu(pos,self,list,click); this.createMenu=ul; }); const edit=ui.create.div('.editbutton','编辑',editorpage,function(){ - if(this&&this.createMenu){ + if(this&&this.createMenu&&this.createMenu.parentNode){ return closeMenu.call(this); } const self=this; @@ -41078,6 +41084,24 @@ const ul=createMenu(pos,self,list,click); this.createMenu=ul; }); + const fontSize=ui.create.div('.editbutton','字号',editorpage,function(){ + if(this&&this.createMenu&&this.createMenu.parentNode){ + return closeMenu.call(this); + } + const self=this; + const pos=this.getBoundingClientRect(); + const list=['16px','18px','20px','22px','24px','26px']; + const click=function(e){ + const size=this.innerHTML; + container.style.fontSize=size.slice(0,-2)/game.documentZoom+'px'; + Array.from(self.parentElement.children).map(v=>v.createMenu).filter(Boolean).forEach(v=>{v.style.fontSize=size.slice(0,-2)/game.documentZoom+'px'}); + container.listenTransition(()=>container.editor.refresh()); + game.saveConfig('codeMirror_fontSize',size); + closeMenu.call(self); + }; + const ul=createMenu(pos,self,list,click); + this.createMenu=ul; + }); const editor=ui.create.div(editorpage); return editor; }, From d1e0022a622089aa0ef79bad63346e17a417adfb Mon Sep 17 00:00:00 2001 From: shijian <2954700422@qq.com> Date: Sat, 30 Sep 2023 02:02:35 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/game.js | 120 +++++++++++++++++++++++++++++---------------------- 1 file changed, 68 insertions(+), 52 deletions(-) diff --git a/game/game.js b/game/game.js index 8297131ee..9895e11df 100644 --- a/game/game.js +++ b/game/game.js @@ -40951,18 +40951,19 @@ } //创建ul列表 const createMenu=function(pos,self,List,click){ - if (self&&self.createMenu) { - createList.push(self.createMenu); - ui.window.appendChild(self.createMenu); - return self.createMenu; - } + if(!self||self==window) return; const parent=self.parentNode; if (parent){ for(let i=0;icontainer.editor.refresh(),0); - game.saveConfig('codeMirror_theme',theme); - closeMenu.call(self); - }; - const ul=createMenu(pos,self,list,click); - this.createMenu=ul; + if(!this.createMenu){ + //主题列表 + const list=['mdn-like','mbo']; + //正在使用的主题 + const active=container.editor.options.theme; + //排个序 + list.remove(active).splice(0,0,active); + //元素位置 + const pos=self.getBoundingClientRect(); + //点击事件 + const click=function(e){ + const theme=this.innerHTML; + container.editor.setOption("theme",theme); + setTimeout(()=>container.editor.refresh(),0); + game.saveConfig('codeMirror_theme',theme); + closeMenu.call(self); + }; + const ul=createMenu(pos,self,list,click); + self.createMenu=ul; + }else{ + createMenu(null,self); + } }); const edit=ui.create.div('.editbutton','编辑',editorpage,function(){ - if(this&&this.createMenu&&this.createMenu.parentNode){ + if(!this||this==window) return; + if(this.createMenu&&this.createMenu.parentNode){ return closeMenu.call(this); } const self=this; - const pos=this.getBoundingClientRect(); - const list=['撤销 Ctrl+Z', '恢复撤销 Ctrl+Y']; - const click=function(e){ - const num=this.innerHTML.indexOf("Ctrl"); - const inner=this.innerHTML.slice(num).replace("+", "-"); - container.editor.execCommand(container.editor.options.extraKeys[inner]); - setTimeout(()=>container.editor.refresh(),0); - closeMenu.call(self); - }; - const ul=createMenu(pos,self,list,click); - this.createMenu=ul; + if(!this.createMenu){ + const pos=this.getBoundingClientRect(); + const list=['撤销 Ctrl+Z', '恢复撤销 Ctrl+Y']; + const click=function(e){ + const num=this.innerHTML.indexOf("Ctrl"); + const inner=this.innerHTML.slice(num).replace("+", "-"); + container.editor.execCommand(container.editor.options.extraKeys[inner]); + setTimeout(()=>container.editor.refresh(),0); + closeMenu.call(self); + }; + const ul=createMenu(pos,self,list,click); + this.createMenu=ul; + }else{ + createMenu(null,self); + } }); const fontSize=ui.create.div('.editbutton','字号',editorpage,function(){ - if(this&&this.createMenu&&this.createMenu.parentNode){ + if(!this||this==window) return; + if(this.createMenu&&this.createMenu.parentNode){ return closeMenu.call(this); } const self=this; - const pos=this.getBoundingClientRect(); - const list=['16px','18px','20px','22px','24px','26px']; - const click=function(e){ - const size=this.innerHTML; - container.style.fontSize=size.slice(0,-2)/game.documentZoom+'px'; - Array.from(self.parentElement.children).map(v=>v.createMenu).filter(Boolean).forEach(v=>{v.style.fontSize=size.slice(0,-2)/game.documentZoom+'px'}); - container.listenTransition(()=>container.editor.refresh()); - game.saveConfig('codeMirror_fontSize',size); - closeMenu.call(self); - }; - const ul=createMenu(pos,self,list,click); - this.createMenu=ul; + if(!this.createMenu){ + const pos=this.getBoundingClientRect(); + const list=['16px','18px','20px','22px','24px','26px']; + const click=function(e){ + const size=this.innerHTML; + container.style.fontSize=size.slice(0,-2)/game.documentZoom+'px'; + Array.from(self.parentElement.children).map(v=>v.createMenu).filter(Boolean).forEach(v=>{v.style.fontSize=size.slice(0,-2)/game.documentZoom+'px'}); + container.listenTransition(()=>container.editor.refresh()); + game.saveConfig('codeMirror_fontSize',size); + closeMenu.call(self); + }; + const ul=createMenu(pos,self,list,click); + this.createMenu=ul; + }else{ + createMenu(null,self); + } }); const editor=ui.create.div(editorpage); return editor; From 77264d7cd6b301be096a8d8b39fa1a94814cb605 Mon Sep 17 00:00:00 2001 From: shijian <2954700422@qq.com> Date: Sat, 30 Sep 2023 02:04:46 +0800 Subject: [PATCH 3/3] fix bug --- game/game.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game/game.js b/game/game.js index 9895e11df..f26b49b90 100644 --- a/game/game.js +++ b/game/game.js @@ -40960,7 +40960,7 @@ } } if(self.createMenu){ - createList.push(self.createMenu); + createList.add(self.createMenu); ui.window.appendChild(self.createMenu); return self.createMenu; }