From eab1975791b13325dd687969f7a04fade15a3bd1 Mon Sep 17 00:00:00 2001 From: Vick Scarlet Date: Thu, 2 Dec 2021 17:56:28 +0800 Subject: [PATCH] add save/load --- laya/pages/view/CyberTheme/CyberMain.ui | 41 +++- laya/pages/view/DefaultTheme/Main.ui | 33 +++- laya/pages/view/SaveLoad.ui | 251 +++++++++++++++++++++++- src/i18n/en-us.js | 8 + src/i18n/zh-cn.js | 8 + src/index.js | 30 +++ src/ui/layaUI.max.all.js | 19 +- src/ui/themes/cyber/main.js | 1 + src/ui/themes/default/main.js | 1 + src/ui/themes/saveload.js | 83 ++++++++ src/ui/themes/views.js | 133 ++++++++++++- 11 files changed, 592 insertions(+), 16 deletions(-) create mode 100644 src/ui/themes/saveload.js diff --git a/laya/pages/view/CyberTheme/CyberMain.ui b/laya/pages/view/CyberTheme/CyberMain.ui index ec913df..36e5b53 100644 --- a/laya/pages/view/CyberTheme/CyberMain.ui +++ b/laya/pages/view/CyberTheme/CyberMain.ui @@ -2,7 +2,7 @@ "x":0, "type":"View", "selectedBox":1, - "selecteID":89, + "selecteID":90, "props":{"y":1218,"x":562,"width":1125,"sceneColor":"#000000","sceneBg":"laya/views/view/CyberTheme/CyberMain.png","runtime":"Laya.runtime.ViewBase","height":2436,"anchorY":0.5,"anchorX":0.5}, "nodeParent":-1, "label":"View", @@ -617,6 +617,45 @@ "hasChild":true, "compId":88, "child":[ + { + "x":30, + "type":"Box", + "props":{"y":-300,"x":-100,"width":110,"runtime":"Laya.runtime.ScaleButton","height":110,"anchorY":0.5,"anchorX":0.5}, + "nodeParent":88, + "label":"Box", + "isOpen":true, + "isDirectory":true, + "isAniNode":true, + "hasChild":true, + "compId":90, + "child":[ + { + "x":45, + "type":"Box", + "props":{"width":110,"var":"btnSaveLoad","runtime":"Laya.runtime.ColorfulBox","name":"btnSmall","height":110,"centerY":0,"centerX":0,"anchorY":0.5,"anchorX":0.5}, + "nodeParent":90, + "label":"Box(btnSaveLoad)", + "isOpen":true, + "isDirectory":true, + "isAniNode":true, + "hasChild":true, + "compId":91, + "child":[ + { + "x":60, + "type":"Image", + "props":{"width":80,"skin":"images/icons/icon_save.png","height":80,"centerY":0,"centerX":0}, + "nodeParent":91, + "label":"Image", + "isDirectory":false, + "isAniNode":true, + "hasChild":false, + "compId":92, + "child":[ + ] + }] + }] + }, { "x":30, "type":"Box", diff --git a/laya/pages/view/DefaultTheme/Main.ui b/laya/pages/view/DefaultTheme/Main.ui index 31cbbd4..130dc42 100644 --- a/laya/pages/view/DefaultTheme/Main.ui +++ b/laya/pages/view/DefaultTheme/Main.ui @@ -1,8 +1,8 @@ { "x":0, "type":"View", - "selectedBox":1, - "selecteID":11, + "selectedBox":99, + "selecteID":100, "props":{"y":1218,"x":562,"width":1125,"sceneColor":"#000000","runtime":"Laya.runtime.ViewBase","height":2436,"anchorY":0.5,"anchorX":0.5}, "nodeParent":-1, "label":"View", @@ -226,20 +226,45 @@ }] }] }, + { + "x":15, + "type":"Box", + "props":{"y":2201,"x":1020,"width":110,"var":"btnSaveLoad","runtime":"Laya.runtime.ColorfulBox","right":50,"name":"btnSmall","height":110,"bottom":180,"anchorY":0.5,"anchorX":0.5}, + "nodeParent":1, + "label":"Box(btnSaveLoad)", + "isOpen":true, + "isDirectory":true, + "isAniNode":true, + "hasChild":true, + "compId":99, + "child":[ + { + "x":30, + "type":"Image", + "props":{"width":80,"skin":"images/icons/icon_save.png","height":80,"centerY":0,"centerX":0}, + "nodeParent":99, + "label":"Image", + "isDirectory":false, + "isAniNode":true, + "hasChild":false, + "compId":100, + "child":[ + ] + }] + }, { "x":15, "type":"Box", "props":{"width":110,"var":"btnThemes","runtime":"Laya.runtime.ColorfulBox","right":50,"name":"btnThemes","height":110,"bottom":50,"anchorY":0.5,"anchorX":0.5}, "nodeParent":1, "label":"Box(btnThemes)", - "isOpen":true, + "isOpen":false, "isDirectory":true, "isAniNode":true, "hasChild":true, "compId":96, "child":[ { - "x":30, "type":"Image", "props":{"width":90,"skin":"images/icons/icon_themes.png","height":90,"centerY":0,"centerX":0}, "nodeParent":96, diff --git a/laya/pages/view/SaveLoad.ui b/laya/pages/view/SaveLoad.ui index 58f98fa..9ef1678 100644 --- a/laya/pages/view/SaveLoad.ui +++ b/laya/pages/view/SaveLoad.ui @@ -1,6 +1,251 @@ { - "type":"View", - "props":{"width":800,"sceneColor":"#000000","height":400}, + "x":0, + "type":"Dialog", + "selectedBox":1, + "selecteID":15, + "props":{"width":645,"sceneColor":"#000000","height":250}, + "nodeParent":-1, + "label":"Dialog", + "isOpen":true, + "isDirectory":true, + "isAniNode":true, + "hasChild":true, + "compId":1, "child":[ - ] + { + "x":15, + "type":"Box", + "props":{"top":0,"right":0,"left":0,"bottom":150}, + "nodeParent":1, + "label":"Box", + "isOpen":true, + "isDirectory":true, + "isAniNode":true, + "hasChild":true, + "compId":15, + "child":[ + { + "x":30, + "type":"Box", + "props":{"y":0,"x":0,"width":645,"height":2}, + "nodeParent":15, + "label":"Box", + "isOpen":null, + "isDirectory":true, + "isAniNode":true, + "hasChild":true, + "compId":19, + "child":[ + { + "type":"Rect", + "props":{"width":645,"lineWidth":1,"height":2,"fillColor":"#97ffe6"}, + "nodeParent":19, + "label":"Rect", + "isDirectory":false, + "isAniNode":true, + "hasChild":false, + "compId":17, + "child":[ + ] + }] + }, + { + "x":30, + "type":"Box", + "props":{"width":645,"height":2,"centerX":0,"bottom":0}, + "nodeParent":15, + "label":"Box", + "isOpen":null, + "isDirectory":true, + "isAniNode":true, + "hasChild":true, + "compId":20, + "child":[ + { + "type":"Rect", + "props":{"width":645,"lineWidth":1,"height":2,"fillColor":"#97ffe6"}, + "nodeParent":20, + "label":"Rect", + "isDirectory":false, + "isAniNode":true, + "hasChild":false, + "compId":21, + "child":[ + ] + }] + }, + { + "x":30, + "type":"Box", + "props":{"width":645,"height":100,"centerY":0,"centerX":0,"alpha":0.2}, + "nodeParent":15, + "label":"Box", + "isOpen":true, + "isDirectory":true, + "isAniNode":true, + "hasChild":true, + "compId":22, + "child":[ + { + "x":45, + "type":"Rect", + "props":{"width":645,"lineWidth":1,"height":100,"fillColor":"#000000"}, + "nodeParent":22, + "label":"Rect", + "isDirectory":false, + "isAniNode":true, + "hasChild":false, + "compId":23, + "child":[ + ] + }] + }] + }, + { + "x":15, + "type":"TextInput", + "props":{"wordWrap":false,"var":"input","valign":"middle","top":0,"text":"content","right":0,"overflow":"scroll","left":0,"fontSize":35,"font":"SimHei","color":"#ffffff","bottom":150}, + "nodeParent":1, + "label":"TextInput(input)", + "isDirectory":false, + "isAniNode":true, + "hasChild":false, + "compId":4, + "child":[ + ] + }, + { + "x":15, + "type":"Box", + "props":{"width":120,"var":"btnSave","runtime":"Laya.runtime.ColorfulBox","name":"btnSmall","left":5,"height":120,"bottom":5,"anchorY":0.5,"anchorX":0.5}, + "nodeParent":1, + "label":"Box(btnSave)", + "isOpen":false, + "isDirectory":true, + "isAniNode":true, + "hasChild":true, + "compId":5, + "child":[ + { + "type":"Label", + "props":{"text":"UI_Save","name":"label","fontSize":50,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0,"bold":true,"anchorY":0.5,"anchorX":0.5}, + "nodeParent":5, + "label":"Label(label)", + "isDirectory":false, + "isAniNode":true, + "hasChild":false, + "compId":7, + "child":[ + ] + }] + }, + { + "x":15, + "type":"Box", + "props":{"width":120,"var":"btnLoad","runtime":"Laya.runtime.ColorfulBox","name":"btnSmall","left":130,"height":120,"bottom":5,"anchorY":0.5,"anchorX":0.5}, + "nodeParent":1, + "label":"Box(btnLoad)", + "isOpen":false, + "isDirectory":true, + "isAniNode":true, + "hasChild":true, + "compId":6, + "child":[ + { + "type":"Label", + "props":{"text":"UI_Load","name":"label","fontSize":50,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0,"bold":true,"anchorY":0.5,"anchorX":0.5}, + "nodeParent":6, + "label":"Label(label)", + "isDirectory":false, + "isAniNode":true, + "hasChild":false, + "compId":8, + "child":[ + ] + }] + }, + { + "x":15, + "type":"Box", + "props":{"y":335,"width":120,"var":"btnRead","runtime":"Laya.runtime.ColorfulBox","name":"btnSmall","left":260,"height":120,"bottom":5,"anchorY":0.5,"anchorX":0.5}, + "nodeParent":1, + "label":"Box(btnRead)", + "isOpen":false, + "isDirectory":true, + "isAniNode":true, + "hasChild":true, + "compId":13, + "child":[ + { + "type":"Label", + "props":{"text":"UI_Read","name":"label","fontSize":50,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0,"bold":true,"anchorY":0.5,"anchorX":0.5}, + "nodeParent":13, + "label":"Label(label)", + "isDirectory":false, + "isAniNode":true, + "hasChild":false, + "compId":14, + "child":[ + ] + }] + }, + { + "x":15, + "type":"Box", + "props":{"y":335,"width":120,"var":"btnWrite","runtime":"Laya.runtime.ColorfulBox","name":"btnSmall","left":390,"height":120,"bottom":5,"anchorY":0.5,"anchorX":0.5}, + "nodeParent":1, + "label":"Box(btnWrite)", + "isOpen":false, + "isDirectory":true, + "isAniNode":true, + "hasChild":true, + "compId":11, + "child":[ + { + "type":"Label", + "props":{"text":"UI_Write","name":"label","fontSize":50,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0,"bold":true,"anchorY":0.5,"anchorX":0.5}, + "nodeParent":11, + "label":"Label(label)", + "isDirectory":false, + "isAniNode":true, + "hasChild":false, + "compId":12, + "child":[ + ] + }] + }, + { + "x":15, + "type":"Box", + "props":{"y":10,"x":10,"width":120,"var":"btnClose","runtime":"Laya.runtime.ColorfulBox","right":5,"name":"btnSmall","height":120,"bottom":5,"anchorY":0.5,"anchorX":0.5}, + "nodeParent":1, + "label":"Box(btnClose)", + "isOpen":false, + "isDirectory":true, + "isAniNode":true, + "hasChild":true, + "compId":9, + "child":[ + { + "type":"Label", + "props":{"text":"×","name":"label","fontSize":50,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0,"bold":true,"anchorY":0.5,"anchorX":0.5}, + "nodeParent":9, + "label":"Label(label)", + "isDirectory":false, + "isAniNode":true, + "hasChild":false, + "compId":10, + "child":[ + ] + }] + }], + "animations":[ + { + "nodes":[ + ], + "name":"ani1", + "id":1, + "frameRate":24, + "action":0 + }] } \ No newline at end of file diff --git a/src/i18n/en-us.js b/src/i18n/en-us.js index 1130091..6c1c4a0 100644 --- a/src/i18n/en-us.js +++ b/src/i18n/en-us.js @@ -119,6 +119,14 @@ export default ({ UI_Support_Programmer: 'Programmer', UI_Support_Designer: 'Designer', + UI_Save: 'Save', + UI_Load: 'Load', + UI_Read: 'Copy', + UI_Write: 'Paste', + + UI_LoadSuccess: 'Load Success!', + UI_LoadFaild: 'Load Faild!', + M_NoRank: 'There is no rank', F_RemakeTimes: 'Remake {0} Times', diff --git a/src/i18n/zh-cn.js b/src/i18n/zh-cn.js index 975ab9b..39901e2 100644 --- a/src/i18n/zh-cn.js +++ b/src/i18n/zh-cn.js @@ -119,6 +119,14 @@ export default ({ UI_Support_Programmer: '打赏程序(顿顿饭)', UI_Support_Designer: '打赏策划(爱发电)', + UI_Save: '存档', + UI_Load: '读档', + UI_Read: '复制', + UI_Write: '粘贴', + + UI_LoadSuccess: '读档成功!', + UI_LoadFaild: '读档失败!', + M_NoRank: '别卷了,没有排行榜', F_RemakeTimes: '已重开{0}次', diff --git a/src/index.js b/src/index.js index 7715611..7029704 100644 --- a/src/index.js +++ b/src/index.js @@ -34,6 +34,36 @@ globalThis.$$off = (tag, fn) => { if(listener) listener.delete(fn); } +globalThis.$$copy = async text => { + const result = await navigator.permissions.query({ name: "clipboard-write" }) + if (result.state == "granted" || result.state == "prompt") { + navigator.clipboard.writeText(data) + return; + } + const input = document.createElement('input'); + input.setAttribute('style', 'opacity: 0;'); + document.body.appendChild(input); + input.value = text; + input.select(); + document.execCommand("copy"); + document.body.removeChild(input); +} + +globalThis.$$read = async ()=>{ + const result = await navigator.permissions.query({ name: "clipboard-read" }) + if (result.state == "granted" || result.state == "prompt") { + return await navigator.clipboard.readText(); + } + const input = document.createElement('input'); + input.setAttribute('style', 'opacity: 0;'); + document.body.appendChild(input); + input.focus(); + document.execCommand("paste"); + const text = input.value; + document.body.removeChild(input); + return text; +}; + const core = new Life(); const game = new App(); globalThis.core = core; diff --git a/src/ui/layaUI.max.all.js b/src/ui/layaUI.max.all.js index 9c20750..57d4239 100644 --- a/src/ui/layaUI.max.all.js +++ b/src/ui/layaUI.max.all.js @@ -71,6 +71,7 @@ var CyberMainUI=(function(_super){ this.btnAchievement=null; this.btnGithub=null; this.btnDiscord=null; + this.btnSaveLoad=null; this.btnThemes=null; CyberMainUI.__super.call(this); @@ -89,7 +90,7 @@ var CyberMainUI=(function(_super){ } - CyberMainUI.uiView={"type":"View","props":{"y":1218,"x":562,"width":1125,"runtime":"Laya.runtime.ViewBase","height":2436,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"var":"imgBg","skin":"images/background/background_1@3x.png","name":"imgBg","centerY":0,"centerX":0},"child":[{"type":"Animation","props":{"y":0,"x":0,"width":1125,"source":"view/CyberTheme/animation/jumpBackground.ani","interval":80,"height":2436,"blendMode":"lighter","autoPlay":true,"alpha":0.3}}]},{"type":"Image","props":{"var":"imgTitle","skin":"images/accessories/title@3x.png","runtime":"Laya.runtime.ColorFilterItem","name":"imgTitle","centerY":-350,"centerX":0},"child":[{"type":"Box","props":{"y":0,"x":0},"child":[{"type":"Image","props":{"y":8,"x":8,"skin":"images/accessories/title_neon@3x.png","renderType":"mask"}},{"type":"Animation","props":{"y":286,"x":436,"source":"view/CyberTheme/animation/bottomBreath.ani","scaleY":1.5,"scaleX":5,"blendMode":"lighter","autoPlay":true}}]}]},{"type":"Image","props":{"skin":"images/accessories/insert_coin@3x.png","centerY":540,"centerX":0,"anchorY":0.5,"anchorX":0.5}},{"type":"Label","props":{"text":"UI_Title_Remake","fontSize":80,"font":"方正像素12","color":"#ffffff","centerY":-135,"centerX":0,"anchorY":0.5,"anchorX":0.5}},{"type":"Label","props":{"wordWrap":true,"text":"UI_Title_Subsequent","right":0,"left":0,"fontSize":48,"font":"方正像素12","color":"#828c95","centerY":-20,"anchorY":0.5,"anchorX":0.5,"align":"center"}},{"type":"Label","props":{"text":"UI_Cyber_Theme_Art_Design","right":50,"fontSize":48,"font":"方正像素12","color":"#00fffd","centerY":1165,"anchorY":0.5,"anchorX":0.5}},{"type":"Button","props":{"var":"btnRemake","skin":"images/button/button_main@3x.png","pivotY":96,"pivotX":329,"name":"btnRemake","labelSize":60,"label":"UI_Remake","centerY":720,"centerX":0,"stateNum":1,"anchorX":0.5,"anchorY":0.5,"sizeGrid":"45,200,45,200","labelFont":"方正像素12","labelColors":"#00fffc,#00fffc,#00fffc","runtime":"Laya.runtime.ScaleButton"},"child":[{"type":"Box","props":{},"child":[{"type":"Animation","props":{"y":93,"x":330,"width":0,"source":"view/CyberTheme/animation/circleFlash.ani","scaleX":5,"height":0,"blendMode":"lighter","autoPlay":true}},{"type":"Box","props":{"renderType":"mask"},"child":[{"type":"Rect","props":{"y":37,"x":25,"width":7,"lineWidth":1,"height":116,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":37,"x":625,"width":7,"lineWidth":1,"height":116,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":21,"x":44,"width":569,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":150,"x":171,"width":316,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":163,"x":44,"width":121,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":163,"x":493,"width":120,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":148,"x":29,"width":25,"rotation":40,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":150,"x":487,"width":19,"rotation":55,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":166,"x":160,"width":19,"rotation":-55,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":21,"x":613,"width":25,"rotation":40,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":26,"x":48,"width":25,"rotation":140,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":153,"x":632,"width":25,"rotation":140,"lineWidth":1,"height":6,"fillColor":"#ff0000"}}]}]},{"type":"Box","props":{},"child":[{"type":"Box","props":{"renderType":"mask"},"child":[{"type":"Poly","props":{"y":41,"x":35,"points":"0,0,8,-6,8,113,0,107","lineWidth":1,"lineColor":"#ff0000","fillColor":"#00ffff"}},{"type":"Poly","props":{"y":41,"x":621,"points":"0,0,-8,-6,-8,113,0,107","lineWidth":1,"lineColor":"#ff0000","fillColor":"#00ffff"}},{"type":"Poly","props":{"y":160,"x":177,"points":"0,0,305,0,311,10,-6,10","lineWidth":1,"lineColor":"#ff0000","fillColor":"#00ffff"}}]},{"type":"Animation","props":{"y":172,"x":330,"source":"view/CyberTheme/animation/bottomBreath.ani","scaleX":4,"blendMode":"lighter","autoPlay":true}}]}]},{"type":"Box","props":{"y":200,"x":200,"width":225,"var":"btnThanks","runtime":"Laya.runtime.ScaleButton","name":"btnThanks","height":90,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"top":0,"skin":"images/button/button_small@3x.png","right":0,"left":0,"bottom":0,"sizeGrid":"8,8,8,8","stateNum":1,"label":" ","runtime":"Laya.runtime.ScaleButton"}},{"type":"Box","props":{"width":90,"left":8,"height":90},"child":[{"type":"Image","props":{"skin":"images/icons/icon_thanks@3x.png","centerY":0,"centerX":0}}]},{"type":"Label","props":{"text":"UI_Thanks","fontSize":50,"font":"方正像素12","color":"#ffffff","centerY":0,"centerX":40,"anchorY":0.5,"anchorX":0.5}}]},{"type":"Box","props":{"y":0,"x":1100,"width":1,"top":0,"right":0,"height":1},"child":[{"type":"Box","props":{"y":200,"x":-200,"width":225,"var":"btnAchievement","runtime":"Laya.runtime.ScaleButton","name":"btnAchievement","height":90,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"top":0,"skin":"images/button/button_small@3x.png","right":0,"left":0,"bottom":0,"sizeGrid":"8,8,8,8","stateNum":1,"label":" ","runtime":"Laya.runtime.ScaleButton"}},{"type":"Box","props":{"width":90,"left":8,"height":90},"child":[{"type":"Image","props":{"skin":"images/icons/icon_achievement@3x.png","centerY":0,"centerX":0}}]},{"type":"Label","props":{"text":"UI_Achievement","fontSize":50,"font":"方正像素12","color":"#ffffff","centerY":0,"centerX":40,"anchorY":0.5,"anchorX":0.5}}]}]},{"type":"Box","props":{"width":1,"left":0,"height":1,"bottom":0},"child":[{"type":"Box","props":{"y":-175,"x":100,"width":160,"var":"btnGithub","runtime":"Laya.runtime.ScaleButton","name":"btnGithub","height":160,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"top":0,"skin":"images/icons/icon_github.png","right":0,"left":0,"bottom":0,"anchorY":0.5,"anchorX":0.5}}]},{"type":"Box","props":{"y":-355,"x":100,"width":160,"var":"btnDiscord","runtime":"Laya.runtime.ScaleButton","name":"btnDiscord","height":160,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"top":0,"skin":"images/icons/icon_discord.png","right":0,"left":0,"bottom":0,"anchorY":0.5,"anchorX":0.5}}]}]},{"type":"Box","props":{"right":0,"bottom":0},"child":[{"type":"Box","props":{"y":-175,"x":-100,"width":110,"runtime":"Laya.runtime.ScaleButton","height":110,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Box","props":{"width":110,"var":"btnThemes","runtime":"Laya.runtime.ColorfulBox","name":"btnThemes","height":110,"centerY":0,"centerX":0,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"width":90,"skin":"images/icons/icon_themes.png","height":90,"centerY":0,"centerX":0}}]}]}]}]}; + CyberMainUI.uiView={"type":"View","props":{"y":1218,"x":562,"width":1125,"runtime":"Laya.runtime.ViewBase","height":2436,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"var":"imgBg","skin":"images/background/background_1@3x.png","name":"imgBg","centerY":0,"centerX":0},"child":[{"type":"Animation","props":{"y":0,"x":0,"width":1125,"source":"view/CyberTheme/animation/jumpBackground.ani","interval":80,"height":2436,"blendMode":"lighter","autoPlay":true,"alpha":0.3}}]},{"type":"Image","props":{"var":"imgTitle","skin":"images/accessories/title@3x.png","runtime":"Laya.runtime.ColorFilterItem","name":"imgTitle","centerY":-350,"centerX":0},"child":[{"type":"Box","props":{"y":0,"x":0},"child":[{"type":"Image","props":{"y":8,"x":8,"skin":"images/accessories/title_neon@3x.png","renderType":"mask"}},{"type":"Animation","props":{"y":286,"x":436,"source":"view/CyberTheme/animation/bottomBreath.ani","scaleY":1.5,"scaleX":5,"blendMode":"lighter","autoPlay":true}}]}]},{"type":"Image","props":{"skin":"images/accessories/insert_coin@3x.png","centerY":540,"centerX":0,"anchorY":0.5,"anchorX":0.5}},{"type":"Label","props":{"text":"UI_Title_Remake","fontSize":80,"font":"方正像素12","color":"#ffffff","centerY":-135,"centerX":0,"anchorY":0.5,"anchorX":0.5}},{"type":"Label","props":{"wordWrap":true,"text":"UI_Title_Subsequent","right":0,"left":0,"fontSize":48,"font":"方正像素12","color":"#828c95","centerY":-20,"anchorY":0.5,"anchorX":0.5,"align":"center"}},{"type":"Label","props":{"text":"UI_Cyber_Theme_Art_Design","right":50,"fontSize":48,"font":"方正像素12","color":"#00fffd","centerY":1165,"anchorY":0.5,"anchorX":0.5}},{"type":"Button","props":{"var":"btnRemake","skin":"images/button/button_main@3x.png","pivotY":96,"pivotX":329,"name":"btnRemake","labelSize":60,"label":"UI_Remake","centerY":720,"centerX":0,"stateNum":1,"anchorX":0.5,"anchorY":0.5,"sizeGrid":"45,200,45,200","labelFont":"方正像素12","labelColors":"#00fffc,#00fffc,#00fffc","runtime":"Laya.runtime.ScaleButton"},"child":[{"type":"Box","props":{},"child":[{"type":"Animation","props":{"y":93,"x":330,"width":0,"source":"view/CyberTheme/animation/circleFlash.ani","scaleX":5,"height":0,"blendMode":"lighter","autoPlay":true}},{"type":"Box","props":{"renderType":"mask"},"child":[{"type":"Rect","props":{"y":37,"x":25,"width":7,"lineWidth":1,"height":116,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":37,"x":625,"width":7,"lineWidth":1,"height":116,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":21,"x":44,"width":569,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":150,"x":171,"width":316,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":163,"x":44,"width":121,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":163,"x":493,"width":120,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":148,"x":29,"width":25,"rotation":40,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":150,"x":487,"width":19,"rotation":55,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":166,"x":160,"width":19,"rotation":-55,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":21,"x":613,"width":25,"rotation":40,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":26,"x":48,"width":25,"rotation":140,"lineWidth":1,"height":6,"fillColor":"#ff0000"}},{"type":"Rect","props":{"y":153,"x":632,"width":25,"rotation":140,"lineWidth":1,"height":6,"fillColor":"#ff0000"}}]}]},{"type":"Box","props":{},"child":[{"type":"Box","props":{"renderType":"mask"},"child":[{"type":"Poly","props":{"y":41,"x":35,"points":"0,0,8,-6,8,113,0,107","lineWidth":1,"lineColor":"#ff0000","fillColor":"#00ffff"}},{"type":"Poly","props":{"y":41,"x":621,"points":"0,0,-8,-6,-8,113,0,107","lineWidth":1,"lineColor":"#ff0000","fillColor":"#00ffff"}},{"type":"Poly","props":{"y":160,"x":177,"points":"0,0,305,0,311,10,-6,10","lineWidth":1,"lineColor":"#ff0000","fillColor":"#00ffff"}}]},{"type":"Animation","props":{"y":172,"x":330,"source":"view/CyberTheme/animation/bottomBreath.ani","scaleX":4,"blendMode":"lighter","autoPlay":true}}]}]},{"type":"Box","props":{"y":200,"x":200,"width":225,"var":"btnThanks","runtime":"Laya.runtime.ScaleButton","name":"btnThanks","height":90,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"top":0,"skin":"images/button/button_small@3x.png","right":0,"left":0,"bottom":0,"sizeGrid":"8,8,8,8","stateNum":1,"label":" ","runtime":"Laya.runtime.ScaleButton"}},{"type":"Box","props":{"width":90,"left":8,"height":90},"child":[{"type":"Image","props":{"skin":"images/icons/icon_thanks@3x.png","centerY":0,"centerX":0}}]},{"type":"Label","props":{"text":"UI_Thanks","fontSize":50,"font":"方正像素12","color":"#ffffff","centerY":0,"centerX":40,"anchorY":0.5,"anchorX":0.5}}]},{"type":"Box","props":{"y":0,"x":1100,"width":1,"top":0,"right":0,"height":1},"child":[{"type":"Box","props":{"y":200,"x":-200,"width":225,"var":"btnAchievement","runtime":"Laya.runtime.ScaleButton","name":"btnAchievement","height":90,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"top":0,"skin":"images/button/button_small@3x.png","right":0,"left":0,"bottom":0,"sizeGrid":"8,8,8,8","stateNum":1,"label":" ","runtime":"Laya.runtime.ScaleButton"}},{"type":"Box","props":{"width":90,"left":8,"height":90},"child":[{"type":"Image","props":{"skin":"images/icons/icon_achievement@3x.png","centerY":0,"centerX":0}}]},{"type":"Label","props":{"text":"UI_Achievement","fontSize":50,"font":"方正像素12","color":"#ffffff","centerY":0,"centerX":40,"anchorY":0.5,"anchorX":0.5}}]}]},{"type":"Box","props":{"width":1,"left":0,"height":1,"bottom":0},"child":[{"type":"Box","props":{"y":-175,"x":100,"width":160,"var":"btnGithub","runtime":"Laya.runtime.ScaleButton","name":"btnGithub","height":160,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"top":0,"skin":"images/icons/icon_github.png","right":0,"left":0,"bottom":0,"anchorY":0.5,"anchorX":0.5}}]},{"type":"Box","props":{"y":-355,"x":100,"width":160,"var":"btnDiscord","runtime":"Laya.runtime.ScaleButton","name":"btnDiscord","height":160,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"top":0,"skin":"images/icons/icon_discord.png","right":0,"left":0,"bottom":0,"anchorY":0.5,"anchorX":0.5}}]}]},{"type":"Box","props":{"right":0,"bottom":0},"child":[{"type":"Box","props":{"y":-300,"x":-100,"width":110,"runtime":"Laya.runtime.ScaleButton","height":110,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Box","props":{"width":110,"var":"btnSaveLoad","runtime":"Laya.runtime.ColorfulBox","name":"btnSmall","height":110,"centerY":0,"centerX":0,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"width":80,"skin":"images/icons/icon_save.png","height":80,"centerY":0,"centerX":0}}]}]},{"type":"Box","props":{"y":-175,"x":-100,"width":110,"runtime":"Laya.runtime.ScaleButton","height":110,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Box","props":{"width":110,"var":"btnThemes","runtime":"Laya.runtime.ColorfulBox","name":"btnThemes","height":110,"centerY":0,"centerX":0,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"width":90,"skin":"images/icons/icon_themes.png","height":90,"centerY":0,"centerX":0}}]}]}]}]}; return CyberMainUI; })(View); var CyberPropertyUI=(function(_super){ @@ -314,6 +315,7 @@ var MainUI=(function(_super){ this.btnAchievement=null; this.btnGithub=null; this.btnDiscord=null; + this.btnSaveLoad=null; this.btnThemes=null; MainUI.__super.call(this); @@ -331,7 +333,7 @@ var MainUI=(function(_super){ } - MainUI.uiView={"type":"View","props":{"y":1218,"x":562,"width":1125,"runtime":"Laya.runtime.ViewBase","height":2436,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Label","props":{"text":"UI_Title_Remake","name":"title","fontSize":130,"font":"SimHei","color":"#ffffff","centerY":-260,"centerX":0,"bold":true,"anchorY":0.5,"anchorX":0.5}},{"type":"Label","props":{"wordWrap":true,"var":"labSubTitle","text":"UI_Title_Subsequent","right":0,"name":"title","left":0,"fontSize":70,"font":"SimHei","color":"#999999","centerY":-120,"anchorY":0.5,"anchorX":0.5,"align":"center"}},{"type":"Box","props":{"width":600,"var":"btnRemake","runtime":"Laya.runtime.ColorfulBox","name":"btnRemake","height":150,"centerY":600,"centerX":0},"child":[{"type":"Label","props":{"text":"UI_Remake","name":"label","fontSize":70,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0}}]},{"type":"Box","props":{"width":260,"var":"btnThanks","top":50,"runtime":"Laya.runtime.ColorfulBox","right":50,"name":"btnSmall","height":90,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Label","props":{"text":"UI_Thanks","name":"label","fontSize":50,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0,"anchorY":0.5,"anchorX":0.5}}]},{"type":"Box","props":{"width":260,"var":"btnAchievement","top":180,"runtime":"Laya.runtime.ColorfulBox","right":50,"name":"btnSmall","height":90,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Label","props":{"text":"UI_Achievement","name":"label","fontSize":50,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0,"anchorY":0.5,"anchorX":0.5}}]},{"type":"Box","props":{"y":0,"x":0,"width":160,"var":"btnGithub","runtime":"Laya.runtime.ScaleButton","rotation":-45,"name":"btnGithub","height":160,"anchorY":0,"anchorX":0.5},"child":[{"type":"Rect","props":{"y":0,"x":-70,"width":300,"lineWidth":1,"height":140,"fillColor":"#000000"}},{"type":"Image","props":{"top":0,"skin":"images/icons/icon_github.png","rotation":0,"right":0,"left":0,"bottom":0,"anchorY":0.5,"anchorX":0.5}},{"type":"Rect","props":{"y":0,"x":-70,"width":300,"renderType":"hit","lineWidth":1,"height":140,"fillColor":"#000000"}},{"type":"Box","props":{"y":0,"x":-70,"renderType":"mask"},"child":[{"type":"Rect","props":{"width":300,"lineWidth":1,"height":140,"fillColor":"#000000"}}]}]},{"type":"Box","props":{"width":160,"left":50,"height":160,"bottom":50},"child":[{"type":"Box","props":{"width":160,"var":"btnDiscord","runtime":"Laya.runtime.ScaleButton","name":"btnDiscord","height":160,"centerY":0,"centerX":0,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"top":0,"skin":"images/icons/icon_discord.png","right":0,"left":0,"bottom":0,"anchorY":0.5,"anchorX":0.5}}]}]},{"type":"Box","props":{"width":110,"var":"btnThemes","runtime":"Laya.runtime.ColorfulBox","right":50,"name":"btnThemes","height":110,"bottom":50,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"width":90,"skin":"images/icons/icon_themes.png","height":90,"centerY":0,"centerX":0}}]}]}; + MainUI.uiView={"type":"View","props":{"y":1218,"x":562,"width":1125,"runtime":"Laya.runtime.ViewBase","height":2436,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Label","props":{"text":"UI_Title_Remake","name":"title","fontSize":130,"font":"SimHei","color":"#ffffff","centerY":-260,"centerX":0,"bold":true,"anchorY":0.5,"anchorX":0.5}},{"type":"Label","props":{"wordWrap":true,"var":"labSubTitle","text":"UI_Title_Subsequent","right":0,"name":"title","left":0,"fontSize":70,"font":"SimHei","color":"#999999","centerY":-120,"anchorY":0.5,"anchorX":0.5,"align":"center"}},{"type":"Box","props":{"width":600,"var":"btnRemake","runtime":"Laya.runtime.ColorfulBox","name":"btnRemake","height":150,"centerY":600,"centerX":0},"child":[{"type":"Label","props":{"text":"UI_Remake","name":"label","fontSize":70,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0}}]},{"type":"Box","props":{"width":260,"var":"btnThanks","top":50,"runtime":"Laya.runtime.ColorfulBox","right":50,"name":"btnSmall","height":90,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Label","props":{"text":"UI_Thanks","name":"label","fontSize":50,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0,"anchorY":0.5,"anchorX":0.5}}]},{"type":"Box","props":{"width":260,"var":"btnAchievement","top":180,"runtime":"Laya.runtime.ColorfulBox","right":50,"name":"btnSmall","height":90,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Label","props":{"text":"UI_Achievement","name":"label","fontSize":50,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0,"anchorY":0.5,"anchorX":0.5}}]},{"type":"Box","props":{"y":0,"x":0,"width":160,"var":"btnGithub","runtime":"Laya.runtime.ScaleButton","rotation":-45,"name":"btnGithub","height":160,"anchorY":0,"anchorX":0.5},"child":[{"type":"Rect","props":{"y":0,"x":-70,"width":300,"lineWidth":1,"height":140,"fillColor":"#000000"}},{"type":"Image","props":{"top":0,"skin":"images/icons/icon_github.png","rotation":0,"right":0,"left":0,"bottom":0,"anchorY":0.5,"anchorX":0.5}},{"type":"Rect","props":{"y":0,"x":-70,"width":300,"renderType":"hit","lineWidth":1,"height":140,"fillColor":"#000000"}},{"type":"Box","props":{"y":0,"x":-70,"renderType":"mask"},"child":[{"type":"Rect","props":{"width":300,"lineWidth":1,"height":140,"fillColor":"#000000"}}]}]},{"type":"Box","props":{"width":160,"left":50,"height":160,"bottom":50},"child":[{"type":"Box","props":{"width":160,"var":"btnDiscord","runtime":"Laya.runtime.ScaleButton","name":"btnDiscord","height":160,"centerY":0,"centerX":0,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"top":0,"skin":"images/icons/icon_discord.png","right":0,"left":0,"bottom":0,"anchorY":0.5,"anchorX":0.5}}]}]},{"type":"Box","props":{"y":2201,"x":1020,"width":110,"var":"btnSaveLoad","runtime":"Laya.runtime.ColorfulBox","right":50,"name":"btnSmall","height":110,"bottom":180,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"width":80,"skin":"images/icons/icon_save.png","height":80,"centerY":0,"centerX":0}}]},{"type":"Box","props":{"width":110,"var":"btnThemes","runtime":"Laya.runtime.ColorfulBox","right":50,"name":"btnThemes","height":110,"bottom":50,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Image","props":{"width":90,"skin":"images/icons/icon_themes.png","height":90,"centerY":0,"centerX":0}}]}]}; return MainUI; })(View); var PropertyUI=(function(_super){ @@ -542,6 +544,12 @@ var MessagePopupUI=(function(_super){ var SaveLoadUI=(function(_super){ function SaveLoadUI(){ + this.input=null; + this.btnSave=null; + this.btnLoad=null; + this.btnRead=null; + this.btnWrite=null; + this.btnClose=null; SaveLoadUI.__super.call(this); } @@ -549,15 +557,16 @@ var SaveLoadUI=(function(_super){ CLASS$(SaveLoadUI,'ui.view.SaveLoadUI',_super); var __proto__=SaveLoadUI.prototype; __proto__.createChildren=function(){ - + View.regComponent("Laya.runtime.ColorfulBox",Laya.runtime.ColorfulBox); + laya.ui.Component.prototype.createChildren.call(this); this.createView(SaveLoadUI.uiView); } - SaveLoadUI.uiView={"type":"View","props":{"width":800,"height":400}}; + SaveLoadUI.uiView={"type":"Dialog","props":{"width":645,"height":250},"child":[{"type":"Box","props":{"top":0,"right":0,"left":0,"bottom":150},"child":[{"type":"Box","props":{"y":0,"x":0,"width":645,"height":2},"child":[{"type":"Rect","props":{"width":645,"lineWidth":1,"height":2,"fillColor":"#97ffe6"}}]},{"type":"Box","props":{"width":645,"height":2,"centerX":0,"bottom":0},"child":[{"type":"Rect","props":{"width":645,"lineWidth":1,"height":2,"fillColor":"#97ffe6"}}]},{"type":"Box","props":{"width":645,"height":100,"centerY":0,"centerX":0,"alpha":0.2},"child":[{"type":"Rect","props":{"width":645,"lineWidth":1,"height":100,"fillColor":"#000000"}}]}]},{"type":"TextInput","props":{"wordWrap":false,"var":"input","valign":"middle","top":0,"text":"content","right":0,"overflow":"scroll","left":0,"fontSize":35,"font":"SimHei","color":"#ffffff","bottom":150}},{"type":"Box","props":{"width":120,"var":"btnSave","runtime":"Laya.runtime.ColorfulBox","name":"btnSmall","left":5,"height":120,"bottom":5,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Label","props":{"text":"UI_Save","name":"label","fontSize":50,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0,"bold":true,"anchorY":0.5,"anchorX":0.5}}]},{"type":"Box","props":{"width":120,"var":"btnLoad","runtime":"Laya.runtime.ColorfulBox","name":"btnSmall","left":130,"height":120,"bottom":5,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Label","props":{"text":"UI_Load","name":"label","fontSize":50,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0,"bold":true,"anchorY":0.5,"anchorX":0.5}}]},{"type":"Box","props":{"y":335,"width":120,"var":"btnRead","runtime":"Laya.runtime.ColorfulBox","name":"btnSmall","left":260,"height":120,"bottom":5,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Label","props":{"text":"UI_Read","name":"label","fontSize":50,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0,"bold":true,"anchorY":0.5,"anchorX":0.5}}]},{"type":"Box","props":{"y":335,"width":120,"var":"btnWrite","runtime":"Laya.runtime.ColorfulBox","name":"btnSmall","left":390,"height":120,"bottom":5,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Label","props":{"text":"UI_Write","name":"label","fontSize":50,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0,"bold":true,"anchorY":0.5,"anchorX":0.5}}]},{"type":"Box","props":{"y":10,"x":10,"width":120,"var":"btnClose","runtime":"Laya.runtime.ColorfulBox","right":5,"name":"btnSmall","height":120,"bottom":5,"anchorY":0.5,"anchorX":0.5},"child":[{"type":"Label","props":{"text":"×","name":"label","fontSize":50,"font":"SimHei","color":"#ffffff","centerY":0,"centerX":0,"bold":true,"anchorY":0.5,"anchorX":0.5}}]}]}; return SaveLoadUI; - })(View); + })(Dialog); var ThemesUI=(function(_super){ function ThemesUI(){ diff --git a/src/ui/themes/cyber/main.js b/src/ui/themes/cyber/main.js index 7572340..c222b9a 100644 --- a/src/ui/themes/cyber/main.js +++ b/src/ui/themes/cyber/main.js @@ -7,6 +7,7 @@ export default class CyberMain extends ui.view.CyberTheme.CyberMainUI { this.btnGithub.on(Laya.Event.CLICK, this, goto, ['github']); this.btnDiscord.on(Laya.Event.CLICK, this, goto, ['discord']); this.btnThemes.on(Laya.Event.CLICK, this, ()=>$ui.showDialog(UI.pages.THEMES)); + this.btnSaveLoad.on(Laya.Event.CLICK, this, ()=>$ui.showDialog(UI.pages.SAVELOAD)); this.on(Laya.Event.RESIZE, this, () => { const scale = Math.max( this.width / this.imgBg.width, diff --git a/src/ui/themes/default/main.js b/src/ui/themes/default/main.js index 33a5d78..796b8f2 100644 --- a/src/ui/themes/default/main.js +++ b/src/ui/themes/default/main.js @@ -7,6 +7,7 @@ export default class Main extends ui.view.DefaultTheme.MainUI { this.btnGithub.on(Laya.Event.CLICK, this, goto, ['github']); this.btnDiscord.on(Laya.Event.CLICK, this, goto, ['discord']); this.btnThemes.on(Laya.Event.CLICK, this, ()=>$ui.showDialog(UI.pages.THEMES)); + this.btnSaveLoad.on(Laya.Event.CLICK, this, ()=>$ui.showDialog(UI.pages.SAVELOAD)); } static load() { diff --git a/src/ui/themes/saveload.js b/src/ui/themes/saveload.js new file mode 100644 index 0000000..c0dcda6 --- /dev/null +++ b/src/ui/themes/saveload.js @@ -0,0 +1,83 @@ +export default class SaveLoad extends ui.view.SaveLoadUI { + constructor() { + super(); + this.btnClose.on(Laya.Event.CLICK, this, async ()=>{ + await this.close(); + $ui.switchView(UI.pages.MAIN); + }); + this.btnRead.on(Laya.Event.CLICK, this,()=>$$copy(this.input.text = this.data)); + this.btnWrite.on(Laya.Event.CLICK, this, async ()=>{ + const text = await $$read(); + if(text) { + this.data = this.input.text = text; + } else { + this.data = this.input.text; + } + }); + + this.btnSave.on(Laya.Event.CLICK, this, ()=>{ + let blob = new Blob([this.data], { type: 'application/json' }); + const slice = blob.slice || blob.webkitSlice || blob.mozSlice; + blob = slice.call(blob, 0, blob.size, 'application/octet-stream'); + const a = document.createElementNS('http://www.w3.org/1999/xhtml', 'a'); + a.href = URL.createObjectURL(blob); + a.download = `Remake_save_${new Date().toISOString().replace(':','.')}.json`; + + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(a.href); + }); + this.btnLoad.on(Laya.Event.CLICK, this, ()=>{ + const file = document.createElement('input'); + file.setAttribute('type', 'file'); + file.setAttribute('name', 'file'); + file.setAttribute('accept', 'application/json'); + file.setAttribute('style', 'display: none;'); + document.body.appendChild(file); + file.click(); + file.onchange = (e)=>{ + const file = e.target.files[0]; + if(!file) return; + const reader = new FileReader(); + reader.onload = () => this.data = reader.result; + reader.readAsText(file); + document.body.removeChild(file); + }; + }); + this.input.on(Laya.Event.MOUSE_DOWN, this, ()=>{ + this.input.setSelection(0, this.input.text.length); + }) + } + + static load() { + return ["images/atlas/images/radio.atlas"]; + } + + init() { + this.input.text = this.data; + } + + get data() { + const data = {}; + Object + .keys(localStorage) + .filter(v=>v.substr(0,4)!='goog') + .forEach(key=>data[key] = localStorage[key]); + return JSON.stringify(data); + } + + set data(v) { + try { + const data = JSON.parse(v); + for(const key in data) + localStorage.setItem(key, data[key]); + $$event('message', ['UI_LoadSuccess']); + $ui.theme = $ui.theme; + this.btnClose.event(Laya.Event.CLICK); + } catch (e) { + console.error(e); + $$event('message', ['UI_LoadFaild']); + } + } +} \ No newline at end of file diff --git a/src/ui/themes/views.js b/src/ui/themes/views.js index edd86e7..7fcbf9a 100644 --- a/src/ui/themes/views.js +++ b/src/ui/themes/views.js @@ -8,6 +8,7 @@ const pages = { ACHIEVEMENT: 'ACHIEVEMENT', THANKS: 'THANKS', THEMES: 'THEMES', + SAVELOAD: 'SAVELOAD', }; const popups = { @@ -26,6 +27,7 @@ const cyber = { [pages.ACHIEVEMENT]: "cyber/achievement", [pages.THANKS]: "default/thanks", [pages.THEMES]: 'themes', + [pages.SAVELOAD]: 'saveload', }, popups: { [popups.ACHIEVEMENT]: "cyber/popup/achievementPopup", @@ -61,6 +63,16 @@ const cyber = { defaultColor: '#cccccc', radius: 100, }, + btnSaveLoad: { + defaultColor: '#5865f2', + defaultStroke: '#eeeeee', + defaultLabel: '#eeeeee', + hoverColor: '#1160b0', + hoverStroke: '#eeeeee', + hoverLabel: '#eeeeee', + lineWidth: 0, + radius: 100, + }, } }, [pages.THANKS]: { @@ -112,7 +124,38 @@ const cyber = { radius: 80, }, } - } + }, + [pages.SAVELOAD]: { + vars: { + btnClose: { + defaultColor: '#eb3941', + hoverColor: '#ff0000', + }, + btnSave: { + defaultColor: '#007046', + hoverColor: '#76f190', + }, + btnRead: { + defaultColor: '#007046', + hoverColor: '#76f190', + }, + btnLoad: { + defaultColor: '#fc5531', + hoverColor: '#f28b54', + }, + btnWrite: { + defaultColor: '#fc5531', + hoverColor: '#f28b54', + }, + }, + names: { + btnSmall: { + radius: 80, + defaultLabel: '#ffffff', + hoverLabel: '#ffffff', + } + } + }, } } } @@ -128,6 +171,7 @@ const dark = { [pages.ACHIEVEMENT]: "default/achievement", [pages.THANKS]: "default/thanks", [pages.THEMES]: 'themes', + [pages.SAVELOAD]: 'saveload', }, popups: { [popups.ACHIEVEMENT]: "default/popup/achievementPopup", @@ -373,6 +417,16 @@ const dark = { defaultColor: '#cccccc', radius: 100, }, + btnSaveLoad: { + defaultColor: '#5865f2', + defaultStroke: '#eeeeee', + defaultLabel: '#eeeeee', + hoverColor: '#1160b0', + hoverStroke: '#eeeeee', + hoverLabel: '#eeeeee', + lineWidth: 0, + radius: 100, + }, }, names: { title: 'title', @@ -498,7 +552,38 @@ const dark = { radius: 80, }, } - } + }, + [pages.SAVELOAD]: { + vars: { + btnClose: { + defaultColor: '#eb3941', + hoverColor: '#ff0000', + }, + btnSave: { + defaultColor: '#007046', + hoverColor: '#76f190', + }, + btnRead: { + defaultColor: '#007046', + hoverColor: '#76f190', + }, + btnLoad: { + defaultColor: '#fc5531', + hoverColor: '#f28b54', + }, + btnWrite: { + defaultColor: '#fc5531', + hoverColor: '#f28b54', + }, + }, + names: { + btnSmall: { + radius: 80, + defaultLabel: '#ffffff', + hoverLabel: '#ffffff', + } + } + }, }, popups: { [popups.ACHIEVEMENT]: { @@ -526,6 +611,7 @@ const light = { [pages.ACHIEVEMENT]: "default/achievement", [pages.THANKS]: "default/thanks", [pages.THEMES]: 'themes', + [pages.SAVELOAD]: 'saveload', }, popups: { [popups.ACHIEVEMENT]: "default/popup/achievementPopup", @@ -765,6 +851,16 @@ const light = { defaultColor: '#cccccc', radius: 100, }, + btnSaveLoad: { + defaultColor: '#5865f2', + defaultStroke: '#eeeeee', + defaultLabel: '#eeeeee', + hoverColor: '#1160b0', + hoverStroke: '#eeeeee', + hoverLabel: '#eeeeee', + lineWidth: 0, + radius: 100, + }, }, names: { title: 'title', @@ -890,7 +986,38 @@ const light = { radius: 80, }, } - } + }, + [pages.SAVELOAD]: { + vars: { + btnClose: { + defaultColor: '#eb3941', + hoverColor: '#ff0000', + }, + btnSave: { + defaultColor: '#007046', + hoverColor: '#76f190', + }, + btnRead: { + defaultColor: '#007046', + hoverColor: '#76f190', + }, + btnLoad: { + defaultColor: '#fc5531', + hoverColor: '#f28b54', + }, + btnWrite: { + defaultColor: '#fc5531', + hoverColor: '#f28b54', + }, + }, + names: { + btnSmall: { + radius: 80, + defaultLabel: '#ffffff', + hoverLabel: '#ffffff', + } + } + }, }, popups: { [popups.ACHIEVEMENT]: {