mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-03-22 12:08:20 +08:00
add save/load
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
"x":0,
|
"x":0,
|
||||||
"type":"View",
|
"type":"View",
|
||||||
"selectedBox":1,
|
"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},
|
"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,
|
"nodeParent":-1,
|
||||||
"label":"View",
|
"label":"View",
|
||||||
@@ -617,6 +617,45 @@
|
|||||||
"hasChild":true,
|
"hasChild":true,
|
||||||
"compId":88,
|
"compId":88,
|
||||||
"child":[
|
"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,
|
"x":30,
|
||||||
"type":"Box",
|
"type":"Box",
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"x":0,
|
"x":0,
|
||||||
"type":"View",
|
"type":"View",
|
||||||
"selectedBox":1,
|
"selectedBox":99,
|
||||||
"selecteID":11,
|
"selecteID":100,
|
||||||
"props":{"y":1218,"x":562,"width":1125,"sceneColor":"#000000","runtime":"Laya.runtime.ViewBase","height":2436,"anchorY":0.5,"anchorX":0.5},
|
"props":{"y":1218,"x":562,"width":1125,"sceneColor":"#000000","runtime":"Laya.runtime.ViewBase","height":2436,"anchorY":0.5,"anchorX":0.5},
|
||||||
"nodeParent":-1,
|
"nodeParent":-1,
|
||||||
"label":"View",
|
"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,
|
"x":15,
|
||||||
"type":"Box",
|
"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},
|
"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,
|
"nodeParent":1,
|
||||||
"label":"Box(btnThemes)",
|
"label":"Box(btnThemes)",
|
||||||
"isOpen":true,
|
"isOpen":false,
|
||||||
"isDirectory":true,
|
"isDirectory":true,
|
||||||
"isAniNode":true,
|
"isAniNode":true,
|
||||||
"hasChild":true,
|
"hasChild":true,
|
||||||
"compId":96,
|
"compId":96,
|
||||||
"child":[
|
"child":[
|
||||||
{
|
{
|
||||||
"x":30,
|
|
||||||
"type":"Image",
|
"type":"Image",
|
||||||
"props":{"width":90,"skin":"images/icons/icon_themes.png","height":90,"centerY":0,"centerX":0},
|
"props":{"width":90,"skin":"images/icons/icon_themes.png","height":90,"centerY":0,"centerX":0},
|
||||||
"nodeParent":96,
|
"nodeParent":96,
|
||||||
|
|||||||
@@ -1,6 +1,251 @@
|
|||||||
{
|
{
|
||||||
"type":"View",
|
"x":0,
|
||||||
"props":{"width":800,"sceneColor":"#000000","height":400},
|
"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":[
|
"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
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
@@ -119,6 +119,14 @@ export default ({
|
|||||||
UI_Support_Programmer: 'Programmer',
|
UI_Support_Programmer: 'Programmer',
|
||||||
UI_Support_Designer: 'Designer',
|
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',
|
M_NoRank: 'There is no rank',
|
||||||
|
|
||||||
F_RemakeTimes: 'Remake {0} Times',
|
F_RemakeTimes: 'Remake {0} Times',
|
||||||
|
|||||||
@@ -119,6 +119,14 @@ export default ({
|
|||||||
UI_Support_Programmer: '打赏程序(顿顿饭)',
|
UI_Support_Programmer: '打赏程序(顿顿饭)',
|
||||||
UI_Support_Designer: '打赏策划(爱发电)',
|
UI_Support_Designer: '打赏策划(爱发电)',
|
||||||
|
|
||||||
|
UI_Save: '存档',
|
||||||
|
UI_Load: '读档',
|
||||||
|
UI_Read: '复制',
|
||||||
|
UI_Write: '粘贴',
|
||||||
|
|
||||||
|
UI_LoadSuccess: '读档成功!',
|
||||||
|
UI_LoadFaild: '读档失败!',
|
||||||
|
|
||||||
M_NoRank: '别卷了,没有排行榜',
|
M_NoRank: '别卷了,没有排行榜',
|
||||||
|
|
||||||
F_RemakeTimes: '已重开{0}次',
|
F_RemakeTimes: '已重开{0}次',
|
||||||
|
|||||||
30
src/index.js
30
src/index.js
@@ -34,6 +34,36 @@ globalThis.$$off = (tag, fn) => {
|
|||||||
if(listener) listener.delete(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 core = new Life();
|
||||||
const game = new App();
|
const game = new App();
|
||||||
globalThis.core = core;
|
globalThis.core = core;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -7,6 +7,7 @@ export default class CyberMain extends ui.view.CyberTheme.CyberMainUI {
|
|||||||
this.btnGithub.on(Laya.Event.CLICK, this, goto, ['github']);
|
this.btnGithub.on(Laya.Event.CLICK, this, goto, ['github']);
|
||||||
this.btnDiscord.on(Laya.Event.CLICK, this, goto, ['discord']);
|
this.btnDiscord.on(Laya.Event.CLICK, this, goto, ['discord']);
|
||||||
this.btnThemes.on(Laya.Event.CLICK, this, ()=>$ui.showDialog(UI.pages.THEMES));
|
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, () => {
|
this.on(Laya.Event.RESIZE, this, () => {
|
||||||
const scale = Math.max(
|
const scale = Math.max(
|
||||||
this.width / this.imgBg.width,
|
this.width / this.imgBg.width,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export default class Main extends ui.view.DefaultTheme.MainUI {
|
|||||||
this.btnGithub.on(Laya.Event.CLICK, this, goto, ['github']);
|
this.btnGithub.on(Laya.Event.CLICK, this, goto, ['github']);
|
||||||
this.btnDiscord.on(Laya.Event.CLICK, this, goto, ['discord']);
|
this.btnDiscord.on(Laya.Event.CLICK, this, goto, ['discord']);
|
||||||
this.btnThemes.on(Laya.Event.CLICK, this, ()=>$ui.showDialog(UI.pages.THEMES));
|
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() {
|
static load() {
|
||||||
|
|||||||
83
src/ui/themes/saveload.js
Normal file
83
src/ui/themes/saveload.js
Normal file
@@ -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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ const pages = {
|
|||||||
ACHIEVEMENT: 'ACHIEVEMENT',
|
ACHIEVEMENT: 'ACHIEVEMENT',
|
||||||
THANKS: 'THANKS',
|
THANKS: 'THANKS',
|
||||||
THEMES: 'THEMES',
|
THEMES: 'THEMES',
|
||||||
|
SAVELOAD: 'SAVELOAD',
|
||||||
};
|
};
|
||||||
|
|
||||||
const popups = {
|
const popups = {
|
||||||
@@ -26,6 +27,7 @@ const cyber = {
|
|||||||
[pages.ACHIEVEMENT]: "cyber/achievement",
|
[pages.ACHIEVEMENT]: "cyber/achievement",
|
||||||
[pages.THANKS]: "default/thanks",
|
[pages.THANKS]: "default/thanks",
|
||||||
[pages.THEMES]: 'themes',
|
[pages.THEMES]: 'themes',
|
||||||
|
[pages.SAVELOAD]: 'saveload',
|
||||||
},
|
},
|
||||||
popups: {
|
popups: {
|
||||||
[popups.ACHIEVEMENT]: "cyber/popup/achievementPopup",
|
[popups.ACHIEVEMENT]: "cyber/popup/achievementPopup",
|
||||||
@@ -61,6 +63,16 @@ const cyber = {
|
|||||||
defaultColor: '#cccccc',
|
defaultColor: '#cccccc',
|
||||||
radius: 100,
|
radius: 100,
|
||||||
},
|
},
|
||||||
|
btnSaveLoad: {
|
||||||
|
defaultColor: '#5865f2',
|
||||||
|
defaultStroke: '#eeeeee',
|
||||||
|
defaultLabel: '#eeeeee',
|
||||||
|
hoverColor: '#1160b0',
|
||||||
|
hoverStroke: '#eeeeee',
|
||||||
|
hoverLabel: '#eeeeee',
|
||||||
|
lineWidth: 0,
|
||||||
|
radius: 100,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[pages.THANKS]: {
|
[pages.THANKS]: {
|
||||||
@@ -112,8 +124,39 @@ const cyber = {
|
|||||||
radius: 80,
|
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.ACHIEVEMENT]: "default/achievement",
|
||||||
[pages.THANKS]: "default/thanks",
|
[pages.THANKS]: "default/thanks",
|
||||||
[pages.THEMES]: 'themes',
|
[pages.THEMES]: 'themes',
|
||||||
|
[pages.SAVELOAD]: 'saveload',
|
||||||
},
|
},
|
||||||
popups: {
|
popups: {
|
||||||
[popups.ACHIEVEMENT]: "default/popup/achievementPopup",
|
[popups.ACHIEVEMENT]: "default/popup/achievementPopup",
|
||||||
@@ -373,6 +417,16 @@ const dark = {
|
|||||||
defaultColor: '#cccccc',
|
defaultColor: '#cccccc',
|
||||||
radius: 100,
|
radius: 100,
|
||||||
},
|
},
|
||||||
|
btnSaveLoad: {
|
||||||
|
defaultColor: '#5865f2',
|
||||||
|
defaultStroke: '#eeeeee',
|
||||||
|
defaultLabel: '#eeeeee',
|
||||||
|
hoverColor: '#1160b0',
|
||||||
|
hoverStroke: '#eeeeee',
|
||||||
|
hoverLabel: '#eeeeee',
|
||||||
|
lineWidth: 0,
|
||||||
|
radius: 100,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
names: {
|
names: {
|
||||||
title: 'title',
|
title: 'title',
|
||||||
@@ -498,7 +552,38 @@ const dark = {
|
|||||||
radius: 80,
|
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: {
|
||||||
[popups.ACHIEVEMENT]: {
|
[popups.ACHIEVEMENT]: {
|
||||||
@@ -526,6 +611,7 @@ const light = {
|
|||||||
[pages.ACHIEVEMENT]: "default/achievement",
|
[pages.ACHIEVEMENT]: "default/achievement",
|
||||||
[pages.THANKS]: "default/thanks",
|
[pages.THANKS]: "default/thanks",
|
||||||
[pages.THEMES]: 'themes',
|
[pages.THEMES]: 'themes',
|
||||||
|
[pages.SAVELOAD]: 'saveload',
|
||||||
},
|
},
|
||||||
popups: {
|
popups: {
|
||||||
[popups.ACHIEVEMENT]: "default/popup/achievementPopup",
|
[popups.ACHIEVEMENT]: "default/popup/achievementPopup",
|
||||||
@@ -765,6 +851,16 @@ const light = {
|
|||||||
defaultColor: '#cccccc',
|
defaultColor: '#cccccc',
|
||||||
radius: 100,
|
radius: 100,
|
||||||
},
|
},
|
||||||
|
btnSaveLoad: {
|
||||||
|
defaultColor: '#5865f2',
|
||||||
|
defaultStroke: '#eeeeee',
|
||||||
|
defaultLabel: '#eeeeee',
|
||||||
|
hoverColor: '#1160b0',
|
||||||
|
hoverStroke: '#eeeeee',
|
||||||
|
hoverLabel: '#eeeeee',
|
||||||
|
lineWidth: 0,
|
||||||
|
radius: 100,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
names: {
|
names: {
|
||||||
title: 'title',
|
title: 'title',
|
||||||
@@ -890,7 +986,38 @@ const light = {
|
|||||||
radius: 80,
|
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: {
|
||||||
[popups.ACHIEVEMENT]: {
|
[popups.ACHIEVEMENT]: {
|
||||||
|
|||||||
Reference in New Issue
Block a user