12 |
- global.pluginNodeModulesPath=Editor.url("packages://mini_font/node_modules"),global.pluginDistPath="packages://mini_font/dist";var t=Editor.url("packages://mini_font/libs/fixrequire.js");t&&""!==t&&require(t);var e=require("fs"),n=require("path");function i(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var s=i(e),a=i(n),r=require("fontmin"),o=function(){this.input_path="",this.out_path="",this.text_content="",this.text_content2="",this.switch_number=!0,this.switch_lowercase_letters=!0,this.switch_capital_letters=!0,this.switch_symbol_letters=!0,this.switch_find_ts=!0,this.switch_find_js=!0,this.switch_find_json=!0},_=["0","1","2","3","4","5","6","7","8","9"],c=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],l=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],h=['!@#$%^&*()_+;.,<>:"{}[]=-|`'],u=function(){function t(){}return t.init=function(t){var e=this;this.panel_context=t,this.cfg_path=Editor.Project.path+"/settings/font_cfg.json",s.existsSync(this.cfg_path)?this.setting_data=JSON.parse(s.readFileSync(this.cfg_path,"utf-8").toString()):this.setting_data=new o,this.read_path(),this.panel_context.$btn_find.addEventListener("confirm",(function(){e.panel_context.$text_content2.value="";var t="";e.dir(Editor.Project.path+"/assets",(function(n){var i=function(n){s.readFile(n,(function(n,i){if(n)Editor.error(n);else for(var s=i.toString(),a=0;a<s.length;a++){var r=s[a];e.is_chinese(r)&&-1===t.indexOf(r)&&(t+=r,e.panel_context.$text_content2.value=t)}}))};(n.endsWith(".json")&&e.panel_context.$switch_find_json.value||n.endsWith(".ts")&&e.panel_context.$switch_find_ts.value||n.endsWith(".js")&&e.panel_context.$switch_find_js.value)&&i(n)}))})),this.panel_context.$btn_input_path.addEventListener("confirm",(function(){var t=Editor.Dialog.openFile({title:"\u9009\u62e9\u6587\u4ef6",defaultPath:"",properties:["openFile"],filters:[{name:"Custom File Type",extensions:["ttf"]}]});-1!==t&&(e.setting_data.input_path=t[0],e.panel_context.$input_path.value=t[0],e.save())})),this.panel_context.$btn_out_path.addEventListener("confirm",(function(){var t=Editor.Dialog.openFile({title:"\u9009\u62e9\u8f93\u51fa\u76ee\u5f55",defaultPath:"",properties:["openDirectory"]});-1!==t&&(e.setting_data.out_path=t[0],e.panel_context.$out_path.value=t[0],e.save())})),this.panel_context.$btn_ok.addEventListener("confirm",(function(){if(""!==e.panel_context.$text_content.value)if(""!==e.setting_data.input_path)if(""!==e.setting_data.out_path){var t=e.panel_context.$text_content.value+e.panel_context.$text_content2.value;t=e.check_number(t),t=e.check_lowercase_letters(t),t=e.check_capital_letters(t),t=e.check_symbol_letters(t),(new r).src(e.setting_data.input_path).use(r.glyph({text:t,hinting:!1})).dest(e.setting_data.out_path).run((function(t,n){if(t)Editor.error(t);else{Editor.log("\u6210\u529f!");var i=n[0];if(e.setting_data.out_path.indexOf(Editor.Project.path)>=0){var s=Editor.remote.assetdb.fspathToUrl(i.path);Editor.remote.assetdb.refresh(s)}e.save()}}))}else Editor.warn("\u8f93\u51fa\u8def\u5f84\u4e0d\u80fd\u4e3a\u7a7a!");else Editor.warn("\u8f93\u5165\u8def\u5f84\u4e0d\u80fd\u4e3a\u7a7a!");else Editor.warn("\u5185\u5bb9\u4e0d\u80fd\u4e3a\u7a7a!")}))},t.save=function(){this.setting_data.text_content=this.panel_context.$text_content.value,this.setting_data.text_content2=this.panel_context.$text_content2.value,this.setting_data.switch_number=this.panel_context.$switch_number.value,this.setting_data.switch_symbol_letters=this.panel_context.$switch_symbol_letters.value,this.setting_data.switch_capital_letters=this.panel_context.$switch_capital_letters.value,this.setting_data.switch_lowercase_letters=this.panel_context.$switch_lowercase_letters.value,this.setting_data.switch_find_js=this.panel_context.$switch_find_js.value,this.setting_data.switch_find_json=this.panel_context.$switch_find_json.value,this.setting_data.switch_find_ts=this.panel_context.$switch_find_ts.value,s.writeFile(this.cfg_path,JSON.stringify(this.setting_data),(function(t){t&&Editor.error(t)}))},t.read_path=function(){this.panel_context.$input_path.value=this.setting_data.input_path,this.panel_context.$out_path.value=this.setting_data.out_path,this.panel_context.$text_content.value=this.setting_data.text_content,this.panel_context.$text_content2.value=this.setting_data.text_content2,this.panel_context.$switch_number.value=this.setting_data.switch_number,this.panel_context.$switch_symbol_letters.value=this.setting_data.switch_symbol_letters,this.panel_context.$switch_capital_letters.value=this.setting_data.switch_capital_letters,this.panel_context.$switch_lowercase_letters.value=this.setting_data.switch_lowercase_letters,this.panel_context.$switch_find_js.value=this.setting_data.switch_find_js,this.panel_context.$switch_find_json.value=this.setting_data.switch_find_json,this.panel_context.$switch_find_ts.value=this.setting_data.switch_find_ts},t.check_number=function(t){for(var e=0;e<_.length;e++){var n=_[e];this.panel_context.$switch_number.value&&-1===t.indexOf(n)&&(t+=n)}return t},t.check_lowercase_letters=function(t){for(var e=0;e<c.length;e++){var n=c[e];this.panel_context.$switch_lowercase_letters.value&&-1===t.indexOf(n)&&(t+=n)}return t},t.check_capital_letters=function(t){for(var e=0;e<l.length;e++){var n=l[e];this.panel_context.$switch_capital_letters.value&&-1===t.indexOf(n)&&(t+=n)}return t},t.check_symbol_letters=function(t){for(var e=0;e<h.length;e++){var n=h[e];this.panel_context.$switch_symbol_letters.value&&-1===t.indexOf(n)&&(t+=n)}return t},t.is_chinese=function(t){return/^[\u4E00-\u9FA5]+$/.test(t)},t.dir=function(t,e){var n=this;s.readdir(t,(function(i,r){i?console.error(i):r.forEach((function(i){var r=a.join(t,i),o=s.statSync(r);o.isFile()?e(r,o):o.isDirectory()&&n.dir(r,e)}))}))},t}();Editor.Panel.extend({style:":host {\r\n margin: 5px;\r\n}\r\n\r\nh2 {\r\n color: rgb(219, 205, 182);\r\n}\r\n\r\n.left {\r\n float: left;\r\n width: 47%;\r\n}\r\n\r\n.right {\r\n float: right;\r\n width: 47%;\r\n}",template:'<!DOCTYPE html>\r\n<html lang="zh-cn">\r\n<head>\r\n <meta charset="UTF-8">\r\n <title>\u5b57\u4f53\u7626\u8eab\u5de5\u5177</title>\r\n</head>\r\n<body>\r\n<div class="layout horizontal center" style="margin-top: 10px">\r\n <div style="width: 60px">\u8f93\u5165\u8def\u5f84</div>\r\n <ui-input id="input_path" class="flex-1"></ui-input>\r\n <ui-button id="btn_input_path">\u9009\u62e9</ui-button>\r\n</div>\r\n\r\n<div class="layout horizontal center" style="margin-top: 10px">\r\n <div style="width: 60px">\u8f93\u51fa\u8def\u5f84</div>\r\n <ui-input id="out_path" class="flex-1"></ui-input>\r\n <ui-button id="btn_out_path">\u9009\u62e9</ui-button>\r\n</div>\r\n<div style="margin-top: 10px">\r\n <ui-box-container class="left">\r\n <textarea id="text_content"\r\n style="width :100%;height: 400px; resize:none;border:none;color: #eeeeee;background-color: #444444;"></textarea>\r\n </ui-box-container>\r\n <ui-box-container class="right">\r\n <div>\r\n <textarea id="text_content2"\r\n style="width :100%;height: 350px; resize:none;border:none;color: #eeeeee;background-color: #444444;"></textarea>\r\n <div style="margin-top: 10px;margin-left: 10px">\u67e5\u627e\u5f53\u524d\u9879\u76ee\u4e2d\u6240\u6709\u6c49\u5b57</div>\r\n <div class="layout horizontal center">\r\n <ui-checkbox id="switch_find_json" style="margin-left: 10px">json</ui-checkbox>\r\n <ui-checkbox id="switch_find_ts" style="margin-left: 10px">ts</ui-checkbox>\r\n <ui-checkbox id="switch_find_js" style="margin-left: 10px">js</ui-checkbox>\r\n <ui-button id="btn_find" style="margin-left: 10px">\u67e5\u627e</ui-button>\r\n </div>\r\n </div>\r\n </ui-box-container>\r\n</div>\r\n\x3c!--clear both\u89e3\u51b3float\u7684\u9519\u4e71\u95ee\u9898--\x3e\r\n<div style="clear: both"></div>\r\n<div class="layout horizontal" style="margin-left: 60px;margin-top: 20px;">\r\n <ui-checkbox style="margin-left: 10px" id="switch_number">\u6570\u5b57</ui-checkbox>\r\n <ui-checkbox style="margin-left: 10px" id="switch_capital_letters">\u5927\u5199\u5b57\u6bcd</ui-checkbox>\r\n <ui-checkbox style="margin-left: 10px" id="switch_lowercase_letters">\u5c0f\u5199\u5b57\u6bcd</ui-checkbox>\r\n <ui-checkbox style="margin-left: 10px" id="switch_symbol_letters">\u7b26\u53f7</ui-checkbox>\r\n</div>\r\n<div align="center" style="margin-top: 20px;">\r\n <ui-button id="btn_ok">\u751f\u6210</ui-button>\r\n</div>\r\n</body>\r\n</html>\r\n\r\n',$:{input_path:"#input_path",out_path:"#out_path",btn_input_path:"#btn_input_path",btn_out_path:"#btn_out_path",text_content:"#text_content",text_content2:"#text_content2",btn_ok:"#btn_ok",btn_find:"#btn_find",switch_number:"#switch_number",switch_lowercase_letters:"#switch_lowercase_letters",switch_capital_letters:"#switch_capital_letters",switch_symbol_letters:"#switch_symbol_letters",switch_find_js:"#switch_find_js",switch_find_ts:"#switch_find_ts",switch_find_json:"#switch_find_json"},ready:function(){u.init(this)},messages:{}});
|