From e6830402cbbef8feb313903c64b9c249e6b2692a Mon Sep 17 00:00:00 2001 From: libccy Date: Sun, 24 Jul 2016 23:51:55 +0800 Subject: [PATCH] ace --- game/ace.js | 60 ++++++++++++++++++------------------- game/game.js | 62 ++++++++++++++++++++++++++++++++++++--- layout/default/layout.css | 7 ++++- layout/default/menu.css | 56 ++++++++++++++++++++++++++++++++--- test.html | 30 ------------------- 5 files changed, 146 insertions(+), 69 deletions(-) delete mode 100644 test.html diff --git a/game/ace.js b/game/ace.js index 40ac8f683..be50d31e9 100644 --- a/game/ace.js +++ b/game/ace.js @@ -2959,7 +2959,7 @@ function DragdropHandler(mouseHandler) { var blankImage = dom.createElement("img"); blankImage.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; if (useragent.isOpera) - blankImage.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;"; + blankImage.style.cssText = "width:1px;height:1px;position:fixed !important;top:0;left:0;z-index:2147483647;opacity:0;"; var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"]; @@ -10750,12 +10750,12 @@ exports.commands = [{ }, readOnly: true }, { - name: "find", - bindKey: bindKey("Ctrl-F", "Command-F"), - exec: function(editor) { - config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor)}); - }, - readOnly: true + // name: "find", + // bindKey: bindKey("Ctrl-F", "Command-F"), + // exec: function(editor) { + // config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor)}); + // }, + // readOnly: true }, { name: "overwrite", bindKey: "Insert", @@ -13001,7 +13001,7 @@ var Editor = function(renderer, session) { if (!this.$scrollAnchor) this.$scrollAnchor = document.createElement("div"); var scrollAnchor = this.$scrollAnchor; - scrollAnchor.style.cssText = "position:absolute"; + scrollAnchor.style.cssText = "position:absolute !important"; this.container.insertBefore(scrollAnchor, this.container.firstChild); var onChangeSelection = this.on("changeSelection", function() { shouldScroll = true; @@ -14753,13 +14753,13 @@ var RenderLoop = require("./renderloop").RenderLoop; var FontMetrics = require("./layer/font_metrics").FontMetrics; var EventEmitter = require("./lib/event_emitter").EventEmitter; var editorCss = ".ace_editor {\ -position: relative;\ +position: relative !important;\ overflow: hidden;\ font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\ direction: ltr;\ }\ .ace_scroller {\ -position: absolute;\ +position: absolute !important;\ overflow: hidden;\ top: 0;\ bottom: 0;\ @@ -14771,14 +14771,14 @@ user-select: none;\ cursor: text;\ }\ .ace_content {\ -position: absolute;\ +position: absolute !important;\ -moz-box-sizing: border-box;\ -webkit-box-sizing: border-box;\ box-sizing: border-box;\ min-width: 100%;\ }\ .ace_dragging .ace_scroller:before{\ -position: absolute;\ +position: absolute !important;\ top: 0;\ left: 0;\ right: 0;\ @@ -14794,7 +14794,7 @@ background: rgba(0, 0, 0, 0.01);\ cursor: text !important;\ }\ .ace_gutter {\ -position: absolute;\ +position: absolute !important;\ overflow : hidden;\ width: auto;\ top: 0;\ @@ -14808,7 +14808,7 @@ z-index: 4;\ user-select: none;\ }\ .ace_gutter-active-line {\ -position: absolute;\ +position: absolute !important;\ left: 0;\ right: 0;\ }\ @@ -14837,13 +14837,13 @@ background-position: 2px center;\ background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\ }\ .ace_scrollbar {\ -position: absolute;\ +position: absolute !important;\ right: 0;\ bottom: 0;\ z-index: 6;\ }\ .ace_scrollbar-inner {\ -position: absolute;\ +position: absolute !important;\ cursor: text;\ left: 0;\ top: 0;\ @@ -14859,11 +14859,11 @@ overflow-y: hidden;\ left: 0;\ }\ .ace_print-margin {\ -position: absolute;\ +position: absolute !important;\ height: 100%;\ }\ .ace_text-input {\ -position: absolute;\ +position: absolute !important;\ z-index: 0;\ width: 0.5em;\ height: 1em;\ @@ -14894,7 +14894,7 @@ text-indent: 0;\ }\ .ace_layer {\ z-index: 1;\ -position: absolute;\ +position: absolute !important;\ overflow: hidden;\ word-wrap: normal;\ white-space: pre;\ @@ -14906,7 +14906,7 @@ box-sizing: border-box;\ pointer-events: none;\ }\ .ace_gutter-layer {\ -position: relative;\ +position: relative !important;\ width: auto;\ text-align: right;\ pointer-events: auto;\ @@ -14923,7 +14923,7 @@ z-index: 4;\ }\ .ace_cursor {\ z-index: 4;\ -position: absolute;\ +position: absolute !important;\ -moz-box-sizing: border-box;\ -webkit-box-sizing: border-box;\ box-sizing: border-box;\ @@ -14948,23 +14948,23 @@ transition: opacity 0.18s;\ border-left-width: 1px;\ }\ .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\ -position: absolute;\ +position: absolute !important;\ z-index: 3;\ }\ .ace_marker-layer .ace_selection {\ -position: absolute;\ +position: absolute !important;\ z-index: 5;\ }\ .ace_marker-layer .ace_bracket {\ -position: absolute;\ +position: absolute !important;\ z-index: 6;\ }\ .ace_marker-layer .ace_active-line {\ -position: absolute;\ +position: absolute !important;\ z-index: 2;\ }\ .ace_marker-layer .ace_selected-word {\ -position: absolute;\ +position: absolute !important;\ z-index: 4;\ -moz-box-sizing: border-box;\ -webkit-box-sizing: border-box;\ @@ -15006,7 +15006,7 @@ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\ color: black;\ max-width: 100%;\ padding: 3px 4px;\ -position: fixed;\ +position: fixed !important;\ z-index: 999999;\ -moz-box-sizing: border-box;\ -webkit-box-sizing: border-box;\ @@ -15101,12 +15101,12 @@ font-style: italic;\ }\ .ace_error-marker {\ background-color: rgba(255, 0, 0,0.2);\ -position: absolute;\ +position: absolute !important;\ z-index: 9;\ }\ .ace_highlight-marker {\ background-color: rgba(255, 255, 0,0.2);\ -position: absolute;\ +position: absolute !important;\ z-index: 8;\ }\ .ace_br1 {border-top-left-radius : 3px;}\ @@ -18592,7 +18592,7 @@ dom.importCssString("\ border-color: #5aaa5a\ }\ .error_widget_arrow {\ - position: absolute;\ + position: absolute !important;\ border: solid 5px;\ border-top-color: transparent!important;\ border-right-color: transparent!important;\ diff --git a/game/game.js b/game/game.js index f712984ce..844c2d6f6 100755 --- a/game/game.js +++ b/game/game.js @@ -21451,6 +21451,7 @@ createModeConfig(i,start.firstChild); } (function(){ + if(!game.download) return; var page=ui.create.div('#create-extension'); var node=ui.create.div('.menubutton.large','制作扩展',start.firstChild,clickMode); node.link=page; @@ -21485,14 +21486,15 @@ exportExtLine.querySelectorAll('span')[1].onclick=function(){ exportExtLine.style.display='none'; }; - var dashboard=ui.create.div('#extension-dashboard',pageboard); + var dashboard=ui.create.div(pageboard); var clickDash=function(){ pageboard.hide(); this.link.show(); }; var createDash=function(str1,str2,node){ + var dash=ui.create.div('.menubutton.large.dashboard'); + dashboard.appendChild(dash); page.appendChild(node); - var dash=ui.create.div('.menubutton.large',dashboard); dash.link=node; dash.listen(clickDash); ui.create.div('',str1,dash); @@ -21644,11 +21646,63 @@ var dash3=ui.create.div('.hidden',page); var dash4=(function(){ var page=ui.create.div('.hidden.menu-buttons'); - ui.create.div('.config.more','
返回',page,function(){ + ui.create.div('.config.more.margin-bottom','
返回',page,function(){ page.hide(); pageboard.show(); }); - + var createCode=function(str1,str2,sub,func,link,str){ + var dash=ui.create.div('.menubutton.large.dashboard'); + sub.appendChild(dash); + dash.listen(func); + dash.link=link; + ui.create.div('',str1,dash); + ui.create.div('',str2,dash); + var container=ui.create.div('.popup-container.editor'); + var editorpage=ui.create.div(container); + var discardConfig=ui.create.div('.editbutton','取消',editorpage,function(){ + ui.window.classList.remove('shortcutpaused'); + ui.window.classList.remove('systempaused'); + container.delete(); + }); + var saveConfig=ui.create.div('.editbutton','保存',editorpage,function(){ + ui.window.classList.remove('shortcutpaused'); + ui.window.classList.remove('systempaused'); + container.delete(); + }); + var editor=ui.create.div('#editor-'+link,editorpage); + editor.innerHTML=str; + dash.editor=editor; + dash.node=container; + }; + var clickCode=function(){ + var node=this.node; + ui.window.classList.add('shortcutpaused'); + ui.window.classList.add('systempaused'); + if(node.aced){ + ui.window.appendChild(node); + } + else{ + var id=this.editor.id; + var aceReady=function(){ + ui.window.appendChild(node); + var editor=window.ace.edit(id); + editor.setTheme("ace/theme/chrome"); + editor.getSession().setUseWorker(false); + editor.getSession().setMode("ace/mode/javascript"); + node.aced=true; + } + if(!window.ace){ + lib.init.js('game','ace',aceReady); + } + else{ + aceReady(); + } + } + }; + createCode('主','主代码',page,clickCode,'content','function(config,pack){\n\t\/\/执行时机为界面加载之后,其它扩展内容加载之前\n\t\/\/参数1为选项值;参数2为扩展定义的武将、卡牌和技能(可修改)\n}'); + createCode('启','启动代码',page,clickCode,'precontent','function(){\n\t\/\/执行时机为游戏启动时,游戏包加载之前,且不受禁用扩展的限制\n\t\/\/除添加模式外请慎用\n}'); + createCode('选','选项代码',page,clickCode,'config','{\n\tswitcher_example:{\n\t\tname:"示例列表选项",\n\t\tinit:"3",\n\t\titem:{"1":"一","2":"二","3":"三"}\n\t},\n\ttoggle_example:{\n\t\tname:"示例开关选项",\n\t\tinit:true\n\t}\n}\n\n\/\/传入主代码函数的参数为{switcher_example:"3",toggle_example:true}'); + createCode('帮','帮助代码',page,clickCode,'help','{\n\t"帮助条目":"<ul><li>列表1-条目1<li>列表1-条目2<\/ul><ol><li>列表2-条目1<li>列表2-条目2<\/ul>"\n}'); return page; }()); createDash('将','编辑武将',dash1); diff --git a/layout/default/layout.css b/layout/default/layout.css index 5e861bec3..663ac693d 100755 --- a/layout/default/layout.css +++ b/layout/default/layout.css @@ -12,7 +12,11 @@ body{ text-rendering:optimizeLegibility; font-family:'STHeiti','SimHei','Microsoft JhengHei','Microsoft YaHei','WenQuanYi Micro Hei',Helvetica,Arial,sans-serif } -div{display: inline-block;position: absolute;transition: all 0.5s;} +div{ + display: inline-block; + position: absolute; + transition: all 0.5s; +} table{table-layout: fixed;} /*--------场景--------*/ @@ -41,6 +45,7 @@ table{table-layout: fixed;} } #window.shortcutpaused>div:not(.background):not(#shortcut):not(#system):not(#arena):not(.hidden):not(.removing):not(.dialog):not(.centermenu):not(.popup-container){opacity: 0.3 !important} #window.shortcutpaused>#arena>div:not(#timer):not(.removing):not(.hidden):not(#autonode){opacity: 0.3 !important} +#window.shortcutpaused>#system{opacity: 0.3 !important;} #window.noclick_important *{pointer-events: none !important;} #window.noclick_important .noclick_click_important div{pointer-events: auto !important} diff --git a/layout/default/menu.css b/layout/default/menu.css index 92a5e48c2..c50aa70e5 100644 --- a/layout/default/menu.css +++ b/layout/default/menu.css @@ -708,22 +708,23 @@ top:0; } -#extension-dashboard>.menubutton.large{ +.menubutton.large.dashboard{ width: 80px; height: 80px; margin: 6px; + position: relative !important; } -#extension-dashboard>.menubutton.large>div:first-child{ +.menubutton.large.dashboard>div:first-child{ font-family: 'lishu','xiaozhuan'; font-size: 60px; line-height: 60px; position: absolute; left: 0; - top: 10px; + top: 7px; width: 100%; height: 60px; } -#extension-dashboard>.menubutton.large>div:last-child{ +.menubutton.large.dashboard>div:last-child{ font-size: 18px; position: absolute; left: 0; @@ -732,6 +733,8 @@ } #create-extension{ height: calc(100% - 5px); + width: calc(100% - 10px); + overflow: hidden; } #create-extension>div{ position: absolute; @@ -744,11 +747,17 @@ #create-extension>.menu-buttons{ left:10px; height: calc(100% - 5px); + width: calc(100% - 15px) !important; } #create-extension>.menu-buttons>.config.more{ margin-left: 0px !important; margin-top: 10px !important; } +#create-extension>.menu-buttons>.config.more.margin-bottom{ + margin-left: 0px !important; + margin-top: 10px !important; + margin-bottom: 5px !important; +} #create-extension>.hidden{ pointer-events: none; } @@ -766,3 +775,42 @@ margin-right: 3px; margin-bottom: 3px; } +.popup-container.editor>div{ + width: 80%; + height: 90%; + position: absolute; + left: 10%; + top: 5%; + border-radius: 4px; + box-shadow: rgba(0, 0, 0, 0.2) 0 0 0 1px, rgba(0, 0, 0, 0.45) 0 0 10px; + background: white; + +} +.popup-container.editor>div>.editbutton{ + font-family: 'lishu'; + font-size: 18px; + color: rgb(60,60,60); + text-shadow: none; + position: absolute; + left: 0; + padding: 7px; + font-size: 24px; +} +.popup-container.editor>div>.editbutton:first-child{ + left: auto; + right: 0; +} +.popup-container.editor>div>div:last-child{ + width: 100%; + height: calc(100% - 40px); + position: absolute; + top:40px; + border-radius: 0 0 4px 4px; + border-top: 1px solid rgba(0,0,0,0.2); +} +.popup-container.editor>div>div:last-child div{ + text-shadow: none; + transition: all 0s; + position: static; + display: block; +} diff --git a/test.html b/test.html deleted file mode 100644 index 4df98e60e..000000000 --- a/test.html +++ /dev/null @@ -1,30 +0,0 @@ - - - -ACE in Action - - - - -
function foo(items) { - var x = "All this is syntax highlighted"; - return x; -}
- - - - -