mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-08-28 01:06:49 +08:00
add: channel switch
This commit is contained in:
+86
-89
@@ -1,179 +1,176 @@
|
||||
import './ui/laya.patch.js';
|
||||
import './ui/runtime.js';
|
||||
import './ui/laya.patch.js'
|
||||
import './ui/runtime.js'
|
||||
import './ui/pluginFunction.js'
|
||||
import './ui/promisesLaya.js'
|
||||
import './ui/layaUI.max.all.js';
|
||||
import UIManager from './ui/uiManager.js';
|
||||
import * as utils from './functions/util.js';
|
||||
import './ui/layaUI.max.all.js'
|
||||
import UIManager from './ui/uiManager.js'
|
||||
import * as utils from './functions/util.js'
|
||||
|
||||
globalThis.UIManager =
|
||||
globalThis.UI =
|
||||
UIManager;
|
||||
globalThis.UIManager = globalThis.UI = UIManager
|
||||
|
||||
globalThis.$_ = utils;
|
||||
globalThis.$_ = utils
|
||||
|
||||
globalThis.goto = async tag => {
|
||||
let url;
|
||||
let url
|
||||
switch (tag) {
|
||||
case 'github': url = 'https://github.com/VickScarlet/lifeRestart'; break;
|
||||
case 'discord': url = 'https://discord.gg/U3qrf49NMQ'; break;
|
||||
case 'sponsor_afd': url = 'https://afdian.com/a/LifeRestart'; break;
|
||||
case 'sponsor_ddf': url = 'https://dun.mianbaoduo.com/@vickscarlet'; break;
|
||||
case 'github': url = 'https://github.com/VickScarlet/lifeRestart'; break
|
||||
case 'discord': url = 'https://discord.gg/U3qrf49NMQ'; break
|
||||
case 'sponsor_afd': url = 'https://afdian.com/a/LifeRestart'; break
|
||||
case 'sponsor_ddf': url = 'https://dun.mianbaoduo.com/@vickscarlet'; break
|
||||
}
|
||||
try {
|
||||
if (Laya.Browser.onIOS) {
|
||||
window.location.href = url;
|
||||
window.location.href = url
|
||||
} else {
|
||||
window.open(url, '_blank');
|
||||
window.open(url, '_blank')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
class App {
|
||||
name = 'lifeRestart'
|
||||
version = '2.1.0'
|
||||
constructor() {
|
||||
this.name = 'lifeRestart';
|
||||
this.version = '2.0.0';
|
||||
console.log(`${this.name} ${this.version}`);
|
||||
console.log(`${this.name} ${this.version}`)
|
||||
}
|
||||
|
||||
#language;
|
||||
#language
|
||||
static languages = {
|
||||
'zh-cn': 'zh-cn',
|
||||
'en-us': 'en-us',
|
||||
};
|
||||
}
|
||||
|
||||
#initLaya() {
|
||||
/**
|
||||
*...特殊的字符,如泰文,必须重新实现这个类
|
||||
*/
|
||||
*...特殊的字符,如泰文,必须重新实现这个类
|
||||
*/
|
||||
//class laya.webgl.text.CharSegment
|
||||
class CharSegment {
|
||||
constructor() {
|
||||
this._sourceStr = null;
|
||||
}
|
||||
_sourceStr = null
|
||||
constructor() {}
|
||||
textToSpit(str) {
|
||||
this._sourceStr = str;
|
||||
var texLen = str.length;
|
||||
var idx = -1;
|
||||
this._words = [];
|
||||
this._sourceStr = str
|
||||
const texLen = str.length
|
||||
let idx = -1
|
||||
this._words = []
|
||||
while (++idx < texLen) {
|
||||
var character = str.charAt(idx);
|
||||
var code = str.charCodeAt(idx);
|
||||
if (code >= 0xD800 && code <= 0xDBFF) {
|
||||
this._words.push(character + str.charAt(++idx));
|
||||
const character = str.charAt(idx)
|
||||
const code = str.codePointAt(idx)
|
||||
if (code >= 0xd800 && code <= 0xdbff) {
|
||||
this._words.push(character + str.charAt(++idx))
|
||||
} else {
|
||||
this._words.push(character);
|
||||
this._words.push(character)
|
||||
}
|
||||
}
|
||||
}
|
||||
getChar(i) {
|
||||
return this._words;
|
||||
return this._words
|
||||
}
|
||||
getCharCode(i) {
|
||||
return this._words[i].codePointAt(0);
|
||||
return this._words[i].codePointAt(0)
|
||||
}
|
||||
length() {
|
||||
return this._words.length;
|
||||
return this._words.length
|
||||
}
|
||||
}
|
||||
Laya.class(CharSegment, 'laya.webgl.text.CharSegment');
|
||||
Laya.imps(CharSegment.prototype, { "laya.webgl.text.ICharSegment": true })
|
||||
|
||||
Laya.class(CharSegment, 'laya.webgl.text.CharSegment')
|
||||
Laya.imps(CharSegment.prototype, { 'laya.webgl.text.ICharSegment': true })
|
||||
|
||||
// Laya.init(1125, 2436, Laya.WebGL);
|
||||
Laya.Config.isAntialias = true;
|
||||
Laya.init(...this.#fitScreen, Laya.WebGL);
|
||||
Laya.Config.isAntialias = true
|
||||
Laya.init(...this.#fitScreen, Laya.WebGL)
|
||||
|
||||
Laya.stage.alignV = Laya.Stage.ALIGN_MIDDLE;
|
||||
Laya.stage.alignH = Laya.Stage.ALIGN_CENTER;
|
||||
Laya.stage.alignV = Laya.Stage.ALIGN_MIDDLE
|
||||
Laya.stage.alignH = Laya.Stage.ALIGN_CENTER
|
||||
|
||||
Laya.stage.scaleMode = "showall";
|
||||
Laya.stage.bgColor = "#000000";
|
||||
window.onresize = () => Laya.stage.size(...this.#fitScreen);
|
||||
Laya.stage.scaleMode = 'showall'
|
||||
Laya.stage.bgColor = '#000000'
|
||||
window.onresize = () => Laya.stage.size(...this.#fitScreen)
|
||||
}
|
||||
|
||||
get #fitScreen() {
|
||||
const designWidth = 1125;
|
||||
const designHeight = 2436;
|
||||
const maxWidth = designHeight * 3 / 4;
|
||||
const maxHeight = designWidth * 24 / 9;
|
||||
const designRatio = designWidth / designHeight;
|
||||
const designWidth = 1125
|
||||
const designHeight = 2436
|
||||
const maxWidth = (designHeight * 3) / 4
|
||||
const maxHeight = (designWidth * 24) / 9
|
||||
const designRatio = designWidth / designHeight
|
||||
|
||||
const screenWidth = window.innerWidth;
|
||||
const screenHeight = window.innerHeight;
|
||||
const screenRatio = screenWidth / screenHeight;
|
||||
const screenWidth = window.innerWidth
|
||||
const screenHeight = window.innerHeight
|
||||
const screenRatio = screenWidth / screenHeight
|
||||
if (screenRatio > designRatio) {
|
||||
return [
|
||||
Math.min(screenWidth * designHeight / screenHeight, maxWidth),
|
||||
designHeight
|
||||
Math.min((screenWidth * designHeight) / screenHeight, maxWidth),
|
||||
designHeight,
|
||||
]
|
||||
} else {
|
||||
return [
|
||||
designWidth,
|
||||
Math.min(screenHeight * designWidth / screenWidth, maxHeight)
|
||||
Math.min((screenHeight * designWidth) / screenWidth, maxHeight),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
async setLanguage(language) {
|
||||
return this.#setLanguage(language);
|
||||
return this.#setLanguage(language)
|
||||
}
|
||||
|
||||
async #setLanguage(language) {
|
||||
switch (language) {
|
||||
case App.languages['en-us']:
|
||||
case App.languages['zh-cn']:
|
||||
this.#language = language;
|
||||
break;
|
||||
this.#language = language
|
||||
break
|
||||
default:
|
||||
this.#language = App.languages['zh-cn'];
|
||||
break;
|
||||
this.#language = App.languages['zh-cn']
|
||||
break
|
||||
}
|
||||
globalThis.$lang =
|
||||
Laya.Text.langPacks =
|
||||
(await import(`./i18n/${this.#language}.js`)).default;
|
||||
Laya.Text.langPacks =
|
||||
(await import(`./i18n/${this.#language}.js`)).default
|
||||
}
|
||||
|
||||
resigterEvent() {
|
||||
$$on('achievement', achievement => {
|
||||
$ui.popup(UI.popups.ACHIEVEMENT, { achievement });
|
||||
$ui.popup(UI.popups.ACHIEVEMENT, { achievement })
|
||||
})
|
||||
$$on('message', ([message, ...args]) => {
|
||||
if (Array.isArray(message)) {
|
||||
message = message.map(([m, ...a]) => $_.format($lang[m], ...a)).join('\n');
|
||||
message = message.map(([m, ...a]) => $_.format($lang[m], ...a)).join('\n')
|
||||
} else {
|
||||
message = $_.format(
|
||||
$lang[message], ...args
|
||||
);
|
||||
message = $_.format($lang[message], ...args)
|
||||
}
|
||||
$ui.popup(UI.popups.MESSAGE, { message });
|
||||
$ui.popup(UI.popups.MESSAGE, { message })
|
||||
})
|
||||
}
|
||||
|
||||
async start({
|
||||
language = App.languages['zh-cn'],
|
||||
theme = 'default',
|
||||
}) {
|
||||
this.resigterEvent();
|
||||
this.#initLaya();
|
||||
globalThis.$ui = UIManager.getInstance();
|
||||
async start(
|
||||
{ language = App.languages['zh-cn'], theme = 'default' },
|
||||
features = [],
|
||||
) {
|
||||
this.resigterEvent()
|
||||
this.#initLaya()
|
||||
globalThis.$ui = UIManager.getInstance()
|
||||
|
||||
if (theme == 'default') {
|
||||
theme = localStorage.getItem('theme') || 'default';
|
||||
theme = localStorage.getItem('theme') || 'default'
|
||||
}
|
||||
|
||||
$ui.theme = theme;
|
||||
await this.#setLanguage(language);
|
||||
await $ui.setLoading(UI.pages.LOADING);
|
||||
await $ui.switchView(UI.pages.LOADING);
|
||||
$ui.theme = theme
|
||||
await this.#setLanguage(language)
|
||||
await $ui.setLoading(UI.pages.LOADING)
|
||||
await $ui.switchView(UI.pages.LOADING)
|
||||
await core.initial(
|
||||
dataSet => Laya.promises.loader.load(`data/${this.#language}/${dataSet}.json`, null, Laya.Loader.JSON),
|
||||
dataSet => Laya.promises.loader.load(`data/${dataSet}.json`, null, Laya.Loader.JSON),
|
||||
);
|
||||
await $ui.switchView(UI.pages.MAIN);
|
||||
|
||||
)
|
||||
await $ui.switchView(UI.pages.MAIN)
|
||||
for (const { feature, options } of features) {
|
||||
const f = await import(`./features/${feature}.js`)
|
||||
await f.default(options)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default App;
|
||||
export default App
|
||||
|
||||
+79
-82
@@ -1,127 +1,124 @@
|
||||
function parseCondition(condition) {
|
||||
|
||||
const conditions = [];
|
||||
const length = condition.length;
|
||||
const stack = [];
|
||||
stack.unshift(conditions);
|
||||
let cursor = 0;
|
||||
const conditions = []
|
||||
const length = condition.length
|
||||
const stack = []
|
||||
stack.unshift(conditions)
|
||||
let cursor = 0
|
||||
const catchString = i => {
|
||||
const str = condition.substring(cursor, i).trim();
|
||||
cursor = i;
|
||||
if(str) stack[0].push(str);
|
||||
};
|
||||
const str = condition.substring(cursor, i).trim()
|
||||
cursor = i
|
||||
if (str) stack[0].push(str)
|
||||
}
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
switch(condition[i]) {
|
||||
case ' ': continue;
|
||||
|
||||
case '(':
|
||||
catchString(i);
|
||||
cursor ++;
|
||||
const sub = [];
|
||||
stack[0].push(sub);
|
||||
stack.unshift(sub);
|
||||
break;
|
||||
for (let i = 0; i < length; i++) {
|
||||
switch (condition[i]) {
|
||||
case ' ': continue
|
||||
|
||||
case '(': {
|
||||
catchString(i)
|
||||
cursor++
|
||||
const sub = []
|
||||
stack[0].push(sub)
|
||||
stack.unshift(sub)
|
||||
break
|
||||
}
|
||||
case ')':
|
||||
catchString(i);
|
||||
cursor ++;
|
||||
stack.shift();
|
||||
break;
|
||||
catchString(i)
|
||||
cursor++
|
||||
stack.shift()
|
||||
break
|
||||
|
||||
case '|':
|
||||
case '&':
|
||||
catchString(i);
|
||||
catchString(i+1);
|
||||
break;
|
||||
default: continue;
|
||||
catchString(i)
|
||||
catchString(i + 1)
|
||||
break
|
||||
default: continue
|
||||
}
|
||||
}
|
||||
|
||||
catchString(length);
|
||||
catchString(length)
|
||||
|
||||
return conditions;
|
||||
return conditions
|
||||
}
|
||||
|
||||
export function checkCondition(property, condition) {
|
||||
const conditions = parseCondition(condition);
|
||||
return checkParsedConditions(property, conditions);
|
||||
const conditions = parseCondition(condition)
|
||||
return checkParsedConditions(property, conditions)
|
||||
}
|
||||
|
||||
function checkParsedConditions(property, conditions) {
|
||||
if(!Array.isArray(conditions)) return checkProp(property, conditions);
|
||||
if(conditions.length == 0) return true;
|
||||
if(conditions.length == 1) return checkParsedConditions(property, conditions[0]);
|
||||
if (!Array.isArray(conditions)) return checkProp(property, conditions)
|
||||
if (conditions.length == 0) return true
|
||||
if (conditions.length == 1) return checkParsedConditions(property, conditions[0])
|
||||
|
||||
let ret = checkParsedConditions(property, conditions[0]);
|
||||
for(let i=1; i<conditions.length; i+=2) {
|
||||
switch(conditions[i]) {
|
||||
let ret = checkParsedConditions(property, conditions[0])
|
||||
for (let i = 1; i < conditions.length; i += 2) {
|
||||
switch (conditions[i]) {
|
||||
case '&':
|
||||
if(ret) ret = checkParsedConditions(property, conditions[i+1]);
|
||||
break;
|
||||
if (ret) ret = checkParsedConditions(property, conditions[i + 1])
|
||||
break
|
||||
case '|':
|
||||
if(ret) return true;
|
||||
ret = checkParsedConditions(property, conditions[i+1]);
|
||||
break;
|
||||
default: return false;
|
||||
if (ret) return true
|
||||
ret = checkParsedConditions(property, conditions[i + 1])
|
||||
break
|
||||
default: return false
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return ret
|
||||
}
|
||||
|
||||
function checkProp(property, condition) {
|
||||
const length = condition.length
|
||||
let i = condition.search(/[><!?=]/)
|
||||
|
||||
const length = condition.length;
|
||||
let i = condition.search(/[><\!\?=]/);
|
||||
const prop = condition.substring(0, i)
|
||||
const symbol = condition.substring(i, (i += condition[i + 1] == '=' ? 2 : 1))
|
||||
const d = condition.substring(i, length)
|
||||
|
||||
const prop = condition.substring(0,i);
|
||||
const symbol = condition.substring(i, i+=(condition[i+1]=='='?2:1));
|
||||
const d = condition.substring(i, length);
|
||||
const propData = property.get(prop)
|
||||
const conditionData = d[0] == '[' ? JSON.parse(d) : Number(d)
|
||||
|
||||
const propData = property.get(prop);
|
||||
const conditionData = d[0]=='['? JSON.parse(d): Number(d);
|
||||
|
||||
switch(symbol) {
|
||||
case '>': return propData > conditionData;
|
||||
case '<': return propData < conditionData;
|
||||
case '>=': return propData >= conditionData;
|
||||
case '<=': return propData <= conditionData;
|
||||
switch (symbol) {
|
||||
case '>': return propData > conditionData
|
||||
case '<': return propData < conditionData
|
||||
case '>=': return propData >= conditionData
|
||||
case '<=': return propData <= conditionData
|
||||
case '=':
|
||||
if(Array.isArray(propData))
|
||||
return propData.includes(conditionData);
|
||||
return propData == conditionData;
|
||||
if (Array.isArray(propData)) return propData.includes(conditionData)
|
||||
return propData == conditionData
|
||||
case '!=':
|
||||
if(Array.isArray(propData))
|
||||
return !propData.includes(conditionData);
|
||||
return propData != conditionData;
|
||||
if (Array.isArray(propData))
|
||||
return !propData.includes(conditionData)
|
||||
return propData != conditionData
|
||||
case '?':
|
||||
if(Array.isArray(propData)) {
|
||||
for(const p of propData)
|
||||
if(conditionData.includes(p)) return true;
|
||||
return false;
|
||||
if (Array.isArray(propData)) {
|
||||
for (const p of propData)
|
||||
if (conditionData.includes(p)) return true
|
||||
return false
|
||||
}
|
||||
return conditionData.includes(propData);
|
||||
return conditionData.includes(propData)
|
||||
case '!':
|
||||
if(Array.isArray(propData)) {
|
||||
for(const p of propData)
|
||||
if(conditionData.includes(p)) return false;
|
||||
return true;
|
||||
if (Array.isArray(propData)) {
|
||||
for (const p of propData)
|
||||
if (conditionData.includes(p)) return false
|
||||
return true
|
||||
}
|
||||
return !conditionData.includes(propData);
|
||||
return !conditionData.includes(propData)
|
||||
|
||||
default: return false;
|
||||
default: return false
|
||||
}
|
||||
}
|
||||
|
||||
export function extractMaxTriggers(condition) {
|
||||
// Assuming only age related talents can be triggered multiple times.
|
||||
const RE_AGE_CONDITION = /AGE\?\[([0-9\,]+)\]/;
|
||||
const match_object = RE_AGE_CONDITION.exec(condition);
|
||||
const RE_AGE_CONDITION = /AGE\?\[([0-9,]+)\]/
|
||||
const match_object = RE_AGE_CONDITION.exec(condition)
|
||||
if (match_object == null) {
|
||||
// Not age related, single trigger.
|
||||
return 1;
|
||||
return 1
|
||||
}
|
||||
|
||||
const age_list = match_object[1].split(",");
|
||||
return age_list.length;
|
||||
}
|
||||
const age_list = match_object[1].split(',')
|
||||
return age_list.length
|
||||
}
|
||||
|
||||
+6
-6
@@ -1,4 +1,4 @@
|
||||
export default ({
|
||||
export default {
|
||||
UI_Next: 'Next',
|
||||
UI_Back: 'Back',
|
||||
UI_Skip: 'Skip',
|
||||
@@ -26,7 +26,7 @@ export default ({
|
||||
UI_Property_Spirit: 'SPR',
|
||||
|
||||
UI_Title_Remake: 'Remake Simulate',
|
||||
UI_Title_Subsequent: 'The rubbish life doesn\'t want to stay for a second',
|
||||
UI_Title_Subsequent: "The rubbish life doesn't want to stay for a second",
|
||||
UI_Remake: '↻Remake Now',
|
||||
UI_Thanks: 'Thx',
|
||||
UI_Achievement: 'Achv',
|
||||
@@ -146,11 +146,11 @@ export default ({
|
||||
UI_UniqueWaTaShiContent: '\nUnique character card different from other 60 million player\nAll property, All talent, All random\nAll has only one chance',
|
||||
UI_GenerateNow: 'Generate Now',
|
||||
|
||||
|
||||
M_NoRank: 'There is no rank',
|
||||
M_PleaseSelectOne: 'Please Select One',
|
||||
M_UnGenerate: 'Unique Character no generate',
|
||||
M_DisableExtendTalent: 'Celebrity mode can\'t extends talent',
|
||||
M_DisableExtendTalent: "Celebrity mode can't extends talent",
|
||||
M_SponsorThanks: 'Thanks for your support',
|
||||
|
||||
F_RemakeTimes: 'Remake {0} Times',
|
||||
F_AchievementCount: 'Achievement {0}',
|
||||
@@ -160,5 +160,5 @@ export default ({
|
||||
F_TalentSelectNotComplect: 'Please select {0} talent',
|
||||
F_PropertyPointLeft: 'You have left {0} property point',
|
||||
F_TalentReplace: 'Talent replace [{source.name}] -> [{target.name}]',
|
||||
F_PropertyStr: 'CHR{CHR} INT{INT} STR{STR} MNY{MNY}'
|
||||
});
|
||||
F_PropertyStr: 'CHR{CHR} INT{INT} STR{STR} MNY{MNY}',
|
||||
}
|
||||
|
||||
+4
-3
@@ -1,4 +1,4 @@
|
||||
export default ({
|
||||
export default {
|
||||
UI_Next: '下一步',
|
||||
UI_Back: '返回',
|
||||
UI_Skip: '跳过',
|
||||
@@ -152,6 +152,7 @@ export default ({
|
||||
M_PleaseSelectOne: '请选择一个名人',
|
||||
M_UnGenerate: '独一无二的我还没有生成',
|
||||
M_DisableExtendTalent: '名人模式不能继承天赋',
|
||||
M_SponsorThanks: '感谢支持',
|
||||
|
||||
F_RemakeTimes: '已重开{0}次',
|
||||
F_AchievementCount: '成就达成{0}个',
|
||||
@@ -161,5 +162,5 @@ export default ({
|
||||
F_TalentSelectNotComplect: '要选满{0}个天赋',
|
||||
F_PropertyPointLeft: '你还有 {0} 属性点没有分配完',
|
||||
F_TalentReplace: '天赋替换【{source.name}】->【{target.name}】',
|
||||
F_PropertyStr: '颜值{CHR} 智力{INT} 体质{STR} 家境{MNY}'
|
||||
});
|
||||
F_PropertyStr: '颜值{CHR} 智力{INT} 体质{STR} 家境{MNY}',
|
||||
}
|
||||
|
||||
+117
-126
@@ -1,74 +1,65 @@
|
||||
import App from './app.js';
|
||||
import Life from './modules/life.js';
|
||||
import App from './app.js'
|
||||
import Life from './modules/life.js'
|
||||
|
||||
globalThis.$$eventMap = new Map();
|
||||
if (!globalThis.$channel) globalThis.$channel = {}
|
||||
globalThis.$$eventMap = new Map()
|
||||
globalThis.$$event = (tag, data) => {
|
||||
const listener = $$eventMap.get(tag);
|
||||
if(listener) listener.forEach(fn=>fn(data));
|
||||
const listener = $$eventMap.get(tag)
|
||||
if (listener) listener.forEach(fn => fn(data))
|
||||
}
|
||||
globalThis.$$on = (tag, fn) => {
|
||||
let listener = $$eventMap.get(tag);
|
||||
if(!listener) {
|
||||
listener = new Set();
|
||||
$$eventMap.set(tag, listener);
|
||||
let listener = $$eventMap.get(tag)
|
||||
if (!listener) {
|
||||
listener = new Set()
|
||||
$$eventMap.set(tag, listener)
|
||||
}
|
||||
listener.add(fn);
|
||||
listener.add(fn)
|
||||
}
|
||||
globalThis.$$off = (tag, fn) => {
|
||||
const listener = $$eventMap.get(tag);
|
||||
if(listener) listener.delete(fn);
|
||||
const listener = $$eventMap.get(tag)
|
||||
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") {
|
||||
const result = await navigator.permissions.query({ name: 'clipboard-write' })
|
||||
if (result.state == 'granted' || result.state == 'prompt') {
|
||||
navigator.clipboard.writeText(text)
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
const input = document.createElement('input');
|
||||
input.setAttribute('style', 'opacity: 0;');
|
||||
document.body.appendChild(input);
|
||||
input.value = text;
|
||||
input.select();
|
||||
const r = document.execCommand("copy");
|
||||
document.body.removeChild(input);
|
||||
return r;
|
||||
return false
|
||||
}
|
||||
|
||||
globalThis.$$read = async ()=>{
|
||||
const result = await navigator.permissions.query({ name: "clipboard-read" })
|
||||
if (result.state == "granted" || result.state == "prompt") {
|
||||
return await navigator.clipboard.readText();
|
||||
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();
|
||||
const r = document.execCommand("paste");
|
||||
const text = input.value;
|
||||
document.body.removeChild(input);
|
||||
return r?text:r;
|
||||
};
|
||||
return null
|
||||
}
|
||||
|
||||
const core = new Life();
|
||||
const game = new App();
|
||||
globalThis.core = core;
|
||||
globalThis.game = game;
|
||||
const core = new Life()
|
||||
const game = new App()
|
||||
globalThis.core = core
|
||||
globalThis.game = game
|
||||
|
||||
const query = {};
|
||||
location.search.substr(1).split('&').forEach(item => {
|
||||
const parts = item.split('=');
|
||||
query[parts[0]] = parts[1];
|
||||
});
|
||||
const query = {}
|
||||
location.search
|
||||
.substring(1)
|
||||
.split('&')
|
||||
.forEach(item => {
|
||||
const parts = item.split('=')
|
||||
query[parts[0]] = parts[1]
|
||||
})
|
||||
|
||||
core.config({
|
||||
defaultPropertyPoints: 20, // default number of points for a property
|
||||
talentSelectLimit: 3, // max number of talents that can be selected
|
||||
propertyAllocateLimit: [0, 10], // scoop of properties that can be allocated,
|
||||
defaultPropertys: { SPR: 5 }, // default properties
|
||||
talentConfig: { // config for talent
|
||||
talentConfig: {
|
||||
// config for talent
|
||||
talentPullCount: 10, // number of talents to pull from the talent pool
|
||||
talentRate: { 1:100, 2:10, 3:1, total: 1000 }, // rate of talent pull
|
||||
talentRate: { 1: 100, 2: 10, 3: 1, total: 1000 }, // rate of talent pull
|
||||
additions: {
|
||||
TMS: [
|
||||
[ 10, { 2: 1 }],
|
||||
@@ -83,78 +74,78 @@ core.config({
|
||||
[ 50, { 2: 3 }],
|
||||
[ 70, { 2: 4 }],
|
||||
[100, { 2: 5 }],
|
||||
]
|
||||
],
|
||||
},
|
||||
},
|
||||
propertyConfig: { // config for property
|
||||
judge: {
|
||||
// type: [min, grade, judge]
|
||||
RTLT: [
|
||||
[ 0, 0],
|
||||
[ 0.3, 1],
|
||||
[ 0.6, 2],
|
||||
[ 0.9, 3],
|
||||
[0, 0],
|
||||
[0.3, 1],
|
||||
[0.6, 2],
|
||||
[0.9, 3],
|
||||
],
|
||||
REVT: [
|
||||
[ 0, 0],
|
||||
[ 0.2, 1],
|
||||
[ 0.4, 2],
|
||||
[ 0.6, 3],
|
||||
[0, 0],
|
||||
[0.2, 1],
|
||||
[0.4, 2],
|
||||
[0.6, 3],
|
||||
],
|
||||
TMS: [
|
||||
[ 0, 0, 'UI_Remake_Times_Judge_Level_0'],
|
||||
[ 10, 1, 'UI_Remake_Times_Judge_Level_1'],
|
||||
[ 30, 1, 'UI_Remake_Times_Judge_Level_2'],
|
||||
[ 50, 2, 'UI_Remake_Times_Judge_Level_3'],
|
||||
[ 70, 2, 'UI_Remake_Times_Judge_Level_4'],
|
||||
[ 100, 3, 'UI_Remake_Times_Judge_Level_5'],
|
||||
[ 0, 0, 'UI_Remake_Times_Judge_Level_0'],
|
||||
[ 10, 1, 'UI_Remake_Times_Judge_Level_1'],
|
||||
[ 30, 1, 'UI_Remake_Times_Judge_Level_2'],
|
||||
[ 50, 2, 'UI_Remake_Times_Judge_Level_3'],
|
||||
[ 70, 2, 'UI_Remake_Times_Judge_Level_4'],
|
||||
[100, 3, 'UI_Remake_Times_Judge_Level_5'],
|
||||
],
|
||||
CACHV: [
|
||||
[ 0, 0, 'UI_Achievement_Count_Judge_Level_0'],
|
||||
[ 10, 1, 'UI_Achievement_Count_Judge_Level_1'],
|
||||
[ 30, 1, 'UI_Achievement_Count_Judge_Level_2'],
|
||||
[ 50, 2, 'UI_Achievement_Count_Judge_Level_3'],
|
||||
[ 70, 2, 'UI_Achievement_Count_Judge_Level_4'],
|
||||
[ 100, 3, 'UI_Achievement_Count_Judge_Level_5'],
|
||||
[ 0, 0, 'UI_Achievement_Count_Judge_Level_0'],
|
||||
[ 10, 1, 'UI_Achievement_Count_Judge_Level_1'],
|
||||
[ 30, 1, 'UI_Achievement_Count_Judge_Level_2'],
|
||||
[ 50, 2, 'UI_Achievement_Count_Judge_Level_3'],
|
||||
[ 70, 2, 'UI_Achievement_Count_Judge_Level_4'],
|
||||
[100, 3, 'UI_Achievement_Count_Judge_Level_5'],
|
||||
],
|
||||
HCHR: [
|
||||
[ 0, 0, 'UI_Judge_Level_0'],
|
||||
[ 1, 0, 'UI_Judge_Level_1'],
|
||||
[ 2, 0, 'UI_Judge_Level_2'],
|
||||
[ 4, 0, 'UI_Judge_Level_3'],
|
||||
[ 7, 1, 'UI_Judge_Level_4'],
|
||||
[ 9, 2, 'UI_Judge_Level_5'],
|
||||
[ 11, 3, 'UI_Judge_Level_6'],
|
||||
[ 0, 0, 'UI_Judge_Level_0'],
|
||||
[ 1, 0, 'UI_Judge_Level_1'],
|
||||
[ 2, 0, 'UI_Judge_Level_2'],
|
||||
[ 4, 0, 'UI_Judge_Level_3'],
|
||||
[ 7, 1, 'UI_Judge_Level_4'],
|
||||
[ 9, 2, 'UI_Judge_Level_5'],
|
||||
[11, 3, 'UI_Judge_Level_6'],
|
||||
],
|
||||
HMNY: [
|
||||
[ 0, 0, 'UI_Judge_Level_0'],
|
||||
[ 1, 0, 'UI_Judge_Level_1'],
|
||||
[ 2, 0, 'UI_Judge_Level_2'],
|
||||
[ 4, 0, 'UI_Judge_Level_3'],
|
||||
[ 7, 1, 'UI_Judge_Level_4'],
|
||||
[ 9, 2, 'UI_Judge_Level_5'],
|
||||
[ 11, 3, 'UI_Judge_Level_6'],
|
||||
[ 0, 0, 'UI_Judge_Level_0'],
|
||||
[ 1, 0, 'UI_Judge_Level_1'],
|
||||
[ 2, 0, 'UI_Judge_Level_2'],
|
||||
[ 4, 0, 'UI_Judge_Level_3'],
|
||||
[ 7, 1, 'UI_Judge_Level_4'],
|
||||
[ 9, 2, 'UI_Judge_Level_5'],
|
||||
[11, 3, 'UI_Judge_Level_6'],
|
||||
],
|
||||
HSPR: [
|
||||
[ 0, 0, 'UI_Spirit_Judge_Level_0'],
|
||||
[ 1, 0, 'UI_Spirit_Judge_Level_1'],
|
||||
[ 2, 0, 'UI_Spirit_Judge_Level_2'],
|
||||
[ 4, 0, 'UI_Spirit_Judge_Level_3'],
|
||||
[ 7, 1, 'UI_Spirit_Judge_Level_4'],
|
||||
[ 9, 2, 'UI_Spirit_Judge_Level_5'],
|
||||
[ 11, 3, 'UI_Spirit_Judge_Level_6'],
|
||||
[ 0, 0, 'UI_Spirit_Judge_Level_0'],
|
||||
[ 1, 0, 'UI_Spirit_Judge_Level_1'],
|
||||
[ 2, 0, 'UI_Spirit_Judge_Level_2'],
|
||||
[ 4, 0, 'UI_Spirit_Judge_Level_3'],
|
||||
[ 7, 1, 'UI_Spirit_Judge_Level_4'],
|
||||
[ 9, 2, 'UI_Spirit_Judge_Level_5'],
|
||||
[11, 3, 'UI_Spirit_Judge_Level_6'],
|
||||
],
|
||||
HINT: [
|
||||
[ 0, 0, 'UI_Judge_Level_0'],
|
||||
[ 1, 0, 'UI_Judge_Level_1'],
|
||||
[ 2, 0, 'UI_Judge_Level_2'],
|
||||
[ 4, 0, 'UI_Judge_Level_3'],
|
||||
[ 7, 1, 'UI_Judge_Level_4'],
|
||||
[ 9, 2, 'UI_Judge_Level_5'],
|
||||
[ 11, 3, 'UI_Judge_Level_6'],
|
||||
[ 21, 3, 'UI_Intelligence_Judge_Level_7'],
|
||||
[ 131, 3, 'UI_Intelligence_Judge_Level_8'],
|
||||
[ 501, 3, 'UI_Intelligence_Judge_Level_9'],
|
||||
[ 0, 0, 'UI_Judge_Level_0'],
|
||||
[ 1, 0, 'UI_Judge_Level_1'],
|
||||
[ 2, 0, 'UI_Judge_Level_2'],
|
||||
[ 4, 0, 'UI_Judge_Level_3'],
|
||||
[ 7, 1, 'UI_Judge_Level_4'],
|
||||
[ 9, 2, 'UI_Judge_Level_5'],
|
||||
[ 11, 3, 'UI_Judge_Level_6'],
|
||||
[ 21, 3, 'UI_Intelligence_Judge_Level_7'],
|
||||
[131, 3, 'UI_Intelligence_Judge_Level_8'],
|
||||
[501, 3, 'UI_Intelligence_Judge_Level_9'],
|
||||
],
|
||||
HSTR: [
|
||||
[ 0, 0, 'UI_Judge_Level_0'],
|
||||
@@ -171,28 +162,28 @@ core.config({
|
||||
[2001, 3, 'UI_Strength_Judge_Level_11'],
|
||||
],
|
||||
HAGE: [
|
||||
[ 0, 0, 'UI_AGE_Judge_Level_0'],
|
||||
[ 1, 0, 'UI_AGE_Judge_Level_1'],
|
||||
[ 10, 0, 'UI_AGE_Judge_Level_2'],
|
||||
[ 18, 0, 'UI_AGE_Judge_Level_3'],
|
||||
[ 40, 0, 'UI_AGE_Judge_Level_4'],
|
||||
[ 60, 1, 'UI_AGE_Judge_Level_5'],
|
||||
[ 70, 1, 'UI_AGE_Judge_Level_6'],
|
||||
[ 80, 2, 'UI_AGE_Judge_Level_7'],
|
||||
[ 90, 2, 'UI_AGE_Judge_Level_8'],
|
||||
[ 95, 3, 'UI_AGE_Judge_Level_9'],
|
||||
[ 100, 3, 'UI_AGE_Judge_Level_10'],
|
||||
[ 500, 3, 'UI_AGE_Judge_Level_11'],
|
||||
[ 0, 0, 'UI_AGE_Judge_Level_0'],
|
||||
[ 1, 0, 'UI_AGE_Judge_Level_1'],
|
||||
[ 10, 0, 'UI_AGE_Judge_Level_2'],
|
||||
[ 18, 0, 'UI_AGE_Judge_Level_3'],
|
||||
[ 40, 0, 'UI_AGE_Judge_Level_4'],
|
||||
[ 60, 1, 'UI_AGE_Judge_Level_5'],
|
||||
[ 70, 1, 'UI_AGE_Judge_Level_6'],
|
||||
[ 80, 2, 'UI_AGE_Judge_Level_7'],
|
||||
[ 90, 2, 'UI_AGE_Judge_Level_8'],
|
||||
[ 95, 3, 'UI_AGE_Judge_Level_9'],
|
||||
[100, 3, 'UI_AGE_Judge_Level_10'],
|
||||
[500, 3, 'UI_AGE_Judge_Level_11'],
|
||||
],
|
||||
SUM: [
|
||||
[ 0, 0, 'UI_Judge_Level_0'],
|
||||
[ 41, 0, 'UI_Judge_Level_1'],
|
||||
[ 50, 0, 'UI_Judge_Level_2'],
|
||||
[ 60, 0, 'UI_Judge_Level_3'],
|
||||
[ 80, 1, 'UI_Judge_Level_4'],
|
||||
[ 100, 2, 'UI_Judge_Level_5'],
|
||||
[ 110, 3, 'UI_Judge_Level_6'],
|
||||
[ 120, 3, 'UI_Judge_Level_7'],
|
||||
[ 0, 0, 'UI_Judge_Level_0'],
|
||||
[ 41, 0, 'UI_Judge_Level_1'],
|
||||
[ 50, 0, 'UI_Judge_Level_2'],
|
||||
[ 60, 0, 'UI_Judge_Level_3'],
|
||||
[ 80, 1, 'UI_Judge_Level_4'],
|
||||
[100, 2, 'UI_Judge_Level_5'],
|
||||
[110, 3, 'UI_Judge_Level_6'],
|
||||
[120, 3, 'UI_Judge_Level_7'],
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -213,12 +204,12 @@ core.config({
|
||||
[10, 1],
|
||||
],
|
||||
talentWeight: [
|
||||
[ 1, 1],
|
||||
[ 2, 2],
|
||||
[ 3, 3],
|
||||
[ 4, 2],
|
||||
[ 5, 1],
|
||||
[1, 1],
|
||||
[2, 2],
|
||||
[3, 3],
|
||||
[4, 2],
|
||||
[5, 1],
|
||||
],
|
||||
},
|
||||
});
|
||||
game.start(query);
|
||||
})
|
||||
game.start(query, globalThis.$channel.features ?? [])
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// 滚动条太灵敏
|
||||
const SCROLL_START_DISTANCE = 30;
|
||||
Laya.ScrollBar.prototype.loop=function(){
|
||||
var mouseY=Laya.stage.mouseY;
|
||||
var mouseX=Laya.stage.mouseX;
|
||||
let mouseY=Laya.stage.mouseY;
|
||||
let mouseX=Laya.stage.mouseX;
|
||||
this._lastOffset=this.isVertical ? (mouseY-this._lastPoint.y):(mouseX-this._lastPoint.x);
|
||||
if (this._clickOnly){
|
||||
if (Math.abs(this._lastOffset *(this.isVertical ? Laya.stage._canvasTransform.getScaleY():Laya.stage._canvasTransform.getScaleX()))> SCROLL_START_DISTANCE){
|
||||
|
||||
@@ -12,7 +12,7 @@ plugin.extractComponents = function(uiView, componentNames) {
|
||||
uiView.child.splice(i, 1);
|
||||
continue;
|
||||
}
|
||||
deepSearch(child, componentNames, components);
|
||||
deepSearch(child, componentNames);
|
||||
}
|
||||
};
|
||||
deepSearch(uiView, componentNames);
|
||||
|
||||
+8
-33
@@ -3,16 +3,12 @@ Laya.runtime = {};
|
||||
|
||||
runtime.ColorFilterItem =
|
||||
class ColorFilterItem extends Laya.Image {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
#hexToRgba = (hex) => {
|
||||
const rgba = [];
|
||||
hex = hex.replace('#', '');
|
||||
hex = hex.match(new RegExp('(.{2})(.{2})(.{2})(.{2})', 'i'));
|
||||
hex = hex.match(/(.{2})(.{2})(.{2})(.{2})/i);
|
||||
hex.forEach((item, index) => {
|
||||
rgba[index] = parseInt(item, 16);
|
||||
rgba[index] = Number.parseInt(item, 16);
|
||||
});
|
||||
rgba.shift();
|
||||
return rgba;
|
||||
@@ -47,26 +43,9 @@ class ColorFilterItem extends Laya.Image {
|
||||
}
|
||||
}
|
||||
}
|
||||
runtime.UIBase =
|
||||
class UIBase extends Laya.View {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
runtime.ViewBase =
|
||||
class ViewBase extends runtime.UIBase {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
runtime.DialogBase =
|
||||
class DialogBase extends runtime.UIBase {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
runtime.UIBase = class UIBase extends Laya.View {}
|
||||
runtime.ViewBase = class ViewBase extends runtime.UIBase {}
|
||||
runtime.DialogBase = class DialogBase extends runtime.UIBase {}
|
||||
|
||||
runtime.ScaleButton =
|
||||
class ScaleButton extends Laya.Button {
|
||||
@@ -156,12 +135,12 @@ class RGBAItem {
|
||||
}
|
||||
|
||||
#hex(v) {
|
||||
v = parseInt(v).toString(16);
|
||||
v = Number.parseInt(v).toString(16);
|
||||
return v.length == 1 ? '0' + v : v;
|
||||
}
|
||||
|
||||
#dec(v) {
|
||||
return parseInt(v, 16);
|
||||
return Number.parseInt(v, 16);
|
||||
}
|
||||
|
||||
get hex() {
|
||||
@@ -303,7 +282,7 @@ class ColorfulBox extends Laya.Box {
|
||||
const tween = (colorItem, target, last) => {
|
||||
Laya.Tween.clearAll(colorItem);
|
||||
const distance = colorItem.distance(target, last);
|
||||
if(!isFinite(distance)) {
|
||||
if(!Number.isFinite(distance)) {
|
||||
colorItem.hex = target;
|
||||
return;
|
||||
}
|
||||
@@ -544,10 +523,6 @@ class BlankBox extends Laya.Box {
|
||||
|
||||
runtime.ColorAgentLabel =
|
||||
class ColorAgentLabel extends Laya.Label {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
}
|
||||
|
||||
get #brothers() {
|
||||
const brothers = [];
|
||||
if(!this.parent) return brothers;
|
||||
|
||||
+29
-24
@@ -1,38 +1,43 @@
|
||||
export default class CyberMain extends ui.view.CyberTheme.CyberMainUI {
|
||||
constructor() {
|
||||
super();
|
||||
this.btnRemake.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.MODE));
|
||||
this.btnAchievement.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.ACHIEVEMENT));
|
||||
this.btnThanks.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.THANKS));
|
||||
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));
|
||||
super()
|
||||
this.btnRemake.on(Laya.Event.CLICK, this, () => $ui.switchView(UI.pages.MODE))
|
||||
this.btnAchievement.on(Laya.Event.CLICK, this, () => $ui.switchView(UI.pages.ACHIEVEMENT))
|
||||
this.btnThanks.on(Laya.Event.CLICK, this, () => $ui.switchView(UI.pages.THANKS))
|
||||
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,
|
||||
this.height / this.imgBg.height
|
||||
);
|
||||
this.imgBg.scale(scale, scale);
|
||||
});
|
||||
this.height / this.imgBg.height,
|
||||
)
|
||||
this.imgBg.scale(scale, scale)
|
||||
})
|
||||
}
|
||||
|
||||
static load() {
|
||||
return [
|
||||
"fonts/方正像素12.ttf",
|
||||
"images/atlas/images/accessories.atlas",
|
||||
"images/atlas/images/border.atlas",
|
||||
"images/atlas/images/button.atlas",
|
||||
"images/atlas/images/icons.atlas",
|
||||
"images/atlas/images/progress.atlas",
|
||||
"images/atlas/images/slider.atlas",
|
||||
'fonts/方正像素12.ttf',
|
||||
'images/atlas/images/accessories.atlas',
|
||||
'images/atlas/images/border.atlas',
|
||||
'images/atlas/images/button.atlas',
|
||||
'images/atlas/images/icons.atlas',
|
||||
'images/atlas/images/progress.atlas',
|
||||
'images/atlas/images/slider.atlas',
|
||||
]
|
||||
}
|
||||
|
||||
init() {
|
||||
this.banner.visible =
|
||||
this.btnDiscord.visible =
|
||||
this.btnAchievement.visible =
|
||||
this.btnThanks.visible = !!core.times;
|
||||
const leastOnce = !!core.times
|
||||
this.banner.visible = leastOnce
|
||||
this.btnAchievement.visible = leastOnce
|
||||
this.btnThanks.visible = leastOnce
|
||||
|
||||
const disabled = globalThis.$channel?.disabled || {}
|
||||
this.btnDiscord.visible = leastOnce && !disabled.discord
|
||||
this.btnGithub.visible = !disabled.github
|
||||
this.btnSaveLoad.visible = !disabled.saveload
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,32 @@
|
||||
export default class Main extends ui.view.DefaultTheme.MainUI {
|
||||
constructor() {
|
||||
super();
|
||||
this.btnRemake.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.MODE));
|
||||
this.btnAchievement.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.ACHIEVEMENT));
|
||||
this.btnThanks.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.THANKS));
|
||||
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));
|
||||
super()
|
||||
this.btnRemake.on(Laya.Event.CLICK, this, () => $ui.switchView(UI.pages.MODE))
|
||||
this.btnAchievement.on(Laya.Event.CLICK, this, () => $ui.switchView(UI.pages.ACHIEVEMENT))
|
||||
this.btnThanks.on(Laya.Event.CLICK, this, () => $ui.switchView(UI.pages.THANKS))
|
||||
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() {
|
||||
return [
|
||||
"images/atlas/images/icons.atlas",
|
||||
]
|
||||
return ['images/atlas/images/icons.atlas']
|
||||
}
|
||||
|
||||
init() {
|
||||
this.banner.visible =
|
||||
this.btnDiscord.visible =
|
||||
this.btnAchievement.visible =
|
||||
this.btnThanks.visible = !!core.times;
|
||||
const text = this.labSubTitle.text;
|
||||
this.labSubTitle.text = ' ';
|
||||
this.labSubTitle.text = text;
|
||||
const text = this.labSubTitle.text
|
||||
this.labSubTitle.text = ' '
|
||||
this.labSubTitle.text = text
|
||||
|
||||
const leastOnce = !!core.times
|
||||
this.banner.visible = leastOnce
|
||||
this.btnAchievement.visible = leastOnce
|
||||
this.btnThanks.visible = leastOnce
|
||||
|
||||
const disabled = globalThis.$channel?.disabled || {}
|
||||
this.btnDiscord.visible = leastOnce && !disabled.discord
|
||||
this.btnGithub.visible = !disabled.github
|
||||
this.btnSaveLoad.visible = !disabled.saveload
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,13 @@ export default class Thanks extends ui.view.DefaultTheme.ThanksUI {
|
||||
this.listSupports.renderHandler = Laya.Handler.create(this, this.renderSupport, null, false);
|
||||
this.panelTopSupports.vScrollBar.elasticDistance = 150;
|
||||
this.listSupports.scrollBar.elasticDistance = 150;
|
||||
this.btnAFD.on(Laya.Event.CLICK, this, goto, ['sponsor_afd']);
|
||||
this.btnDDF.on(Laya.Event.CLICK, this, goto, ['sponsor_ddf']);
|
||||
if (globalThis.$channel?.disabled?.sponsor) {
|
||||
this.btnAFD.on(Laya.Event.CLICK, this, $$event, ['message', ['M_SponsorThanks']]);
|
||||
} else {
|
||||
this.btnAFD.on(Laya.Event.CLICK, this, goto, ['sponsor_afd']);
|
||||
// this.btnDDF.on(Laya.Event.CLICK, this, goto, ['sponsor_ddf']);
|
||||
}
|
||||
this.btnDDF.on(Laya.Event.CLICK, this, $$event, ['message', ['M_SponsorThanks']]);
|
||||
}
|
||||
|
||||
static #createComponent = Laya.plugin.extractComponents(Thanks.uiView, ['boxTopSupport']);
|
||||
|
||||
+89
-96
@@ -1,78 +1,77 @@
|
||||
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, async ()=>{
|
||||
const result = await $$copy(this.input.text = this.data);
|
||||
$$event('message', [result? 'UI_CopySuccess': 'UI_CopyFailed']);
|
||||
});
|
||||
this.btnWrite.on(Laya.Event.CLICK, this, async ()=>{
|
||||
const text = await $$read();
|
||||
if(text == false) {
|
||||
super()
|
||||
this.btnClose.on(Laya.Event.CLICK, this, async () => {
|
||||
await this.close()
|
||||
$ui.switchView(UI.pages.MAIN)
|
||||
})
|
||||
this.btnRead.on(Laya.Event.CLICK, this, async () => {
|
||||
this.input.text = this.data
|
||||
const result = await $$copy(this.data)
|
||||
$$event('message', [result ? 'UI_CopySuccess' : 'UI_CopyFailed'])
|
||||
})
|
||||
this.btnWrite.on(Laya.Event.CLICK, this, async () => {
|
||||
const text = await $$read()
|
||||
if (text == null) {
|
||||
this.data = [
|
||||
this.input.text,
|
||||
'UI_PasteFailedDecodeSuccess',
|
||||
'UI_PasteFailedDecodeFailed'
|
||||
];
|
||||
'UI_PasteFailedDecodeFailed',
|
||||
]
|
||||
} else {
|
||||
this.input.text = text;
|
||||
this.input.text = text
|
||||
this.data = [
|
||||
text,
|
||||
'UI_PasteSuccessDecodeSuccess',
|
||||
'UI_PasteSuccessDecodeFailed'
|
||||
];
|
||||
'UI_PasteSuccessDecodeFailed',
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
})
|
||||
|
||||
this.btnBackup.on(Laya.Event.CLICK, this, ()=>{
|
||||
const board = document.createElement("div");
|
||||
document.body.appendChild(board);
|
||||
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()
|
||||
a.remove()
|
||||
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 = async e => {
|
||||
const f = e.target.files[0]
|
||||
if (!f) return
|
||||
this.data = [await f.text()]
|
||||
file.remove()
|
||||
}
|
||||
})
|
||||
this.input.on(Laya.Event.MOUSE_DOWN, this, () => {
|
||||
this.input.setSelection(0, this.input.text.length)
|
||||
})
|
||||
|
||||
this.btnBackup.on(Laya.Event.CLICK, this, () => {
|
||||
const board = document.createElement('div')
|
||||
document.body.appendChild(board)
|
||||
board.style = `
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
opacity: 0.95`;
|
||||
opacity: 0.95`
|
||||
|
||||
const bg = document.createElement("div");
|
||||
const bg = document.createElement('div')
|
||||
bg.style = `
|
||||
position: absolute;
|
||||
top: 0;
|
||||
@@ -80,18 +79,14 @@ export default class SaveLoad extends ui.view.SaveLoadUI {
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: #fff;
|
||||
opacity: 0.95`;
|
||||
document.body.appendChild(board);
|
||||
board.appendChild(bg);
|
||||
const textarea = document.createElement("textarea");
|
||||
opacity: 0.95`
|
||||
document.body.appendChild(board)
|
||||
board.appendChild(bg)
|
||||
const textarea = document.createElement('textarea')
|
||||
textarea.style = `position: absolute; width: ${window.innerWidth}px; height: ${window.innerHeight}px;`
|
||||
textarea.value = JSON.stringify(
|
||||
JSON.parse(this.data),
|
||||
null,
|
||||
4
|
||||
);
|
||||
board.appendChild(textarea);
|
||||
const close = document.createElement("div");
|
||||
textarea.value = JSON.stringify(JSON.parse(this.data), null, 4)
|
||||
board.appendChild(textarea)
|
||||
const close = document.createElement('div')
|
||||
close.style = `
|
||||
position: absolute;
|
||||
top: 0;
|
||||
@@ -103,12 +98,12 @@ export default class SaveLoad extends ui.view.SaveLoadUI {
|
||||
padding: 0;
|
||||
line-height: 100px;
|
||||
color: white;
|
||||
opacity: 0.7`;
|
||||
close.innerHTML = '×';
|
||||
board.appendChild(close);
|
||||
close.onclick = ()=>board.remove();
|
||||
opacity: 0.7`
|
||||
close.innerHTML = '×'
|
||||
board.appendChild(close)
|
||||
close.onclick = () => board.remove()
|
||||
|
||||
const load = document.createElement("div");
|
||||
const load = document.createElement('div')
|
||||
load.style = `
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
@@ -120,43 +115,41 @@ export default class SaveLoad extends ui.view.SaveLoadUI {
|
||||
padding: 0;
|
||||
line-height: 50px;
|
||||
color: white;
|
||||
opacity: 0.7`;
|
||||
load.innerHTML = 'LOAD<br>读取';
|
||||
board.appendChild(load);
|
||||
load.onclick = ()=>this.data = [textarea.value, '成功/success', '失败/failed', true];
|
||||
});
|
||||
opacity: 0.7`
|
||||
load.innerHTML = 'LOAD<br>读取'
|
||||
board.appendChild(load)
|
||||
load.onclick = () => (this.data = [textarea.value, '成功/success', '失败/failed', true])
|
||||
})
|
||||
}
|
||||
|
||||
static load() {
|
||||
return ["images/atlas/images/radio.atlas"];
|
||||
return ['images/atlas/images/radio.atlas']
|
||||
}
|
||||
|
||||
init() {
|
||||
this.input.text = this.data;
|
||||
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);
|
||||
const data = {}
|
||||
Object.keys(localStorage)
|
||||
.filter(v => !v.startsWith('goog'))
|
||||
.forEach(key => (data[key] = localStorage[key]))
|
||||
return JSON.stringify(data)
|
||||
}
|
||||
|
||||
set data([v, success = 'UI_LoadSuccess', failed = 'UI_LoadFailed', altMsg]) {
|
||||
try {
|
||||
const data = JSON.parse(v);
|
||||
for(const key in data)
|
||||
localStorage.setItem(key, data[key]);
|
||||
if(altMsg) alert(success);
|
||||
else $$event('message', [success]);
|
||||
$ui.theme = $ui.theme;
|
||||
this.btnClose.event(Laya.Event.CLICK);
|
||||
const data = JSON.parse(v)
|
||||
for (const key in data) localStorage.setItem(key, data[key])
|
||||
if (altMsg) alert(success)
|
||||
else $$event('message', [success])
|
||||
$ui.theme = $ui.theme ?? null
|
||||
this.btnClose.event(Laya.Event.CLICK)
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
if(altMsg) alert(`${failed}\n${e}`);
|
||||
else $$event('message', [failed]);
|
||||
console.error(e)
|
||||
if (altMsg) alert(`${failed}\n${e}`)
|
||||
else $$event('message', [failed])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+25
-32
@@ -34,7 +34,7 @@ export default class UIManager {
|
||||
this.#dialogMask.graphics.drawRect(0, 0, 5000, 5000, '#000000')
|
||||
this.#dialogMask.alpha = 0.4
|
||||
this.#dialogMask.on(Laya.Event.CLICK, this, () => {
|
||||
this.#dialogStack[this.#dialogStack.length - 1]?.close?.()
|
||||
this.#dialogStack.at(-1)?.close?.()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ export default class UIManager {
|
||||
args,
|
||||
actions?.load,
|
||||
viewName,
|
||||
'pages'
|
||||
'pages',
|
||||
)
|
||||
|
||||
view.top = view.bottom = view.left = view.right = 0
|
||||
@@ -115,7 +115,7 @@ export default class UIManager {
|
||||
if (this.#loading) {
|
||||
timeout = setTimeout(
|
||||
() => this.#stage.addChild(this.#loading),
|
||||
3000
|
||||
3000,
|
||||
)
|
||||
}
|
||||
const onProgress = this.#loading?.onProgress
|
||||
@@ -128,7 +128,7 @@ export default class UIManager {
|
||||
? this.scanResource(ViewClass.uiView)
|
||||
: []
|
||||
if (preload) {
|
||||
preload = [].concat(preload).concat(scanedResourceList)
|
||||
preload = preload.concat(scanedResourceList)
|
||||
} else {
|
||||
preload = scanedResourceList
|
||||
}
|
||||
@@ -162,19 +162,19 @@ export default class UIManager {
|
||||
|
||||
async loadRes(resourceList, preload, onProgress) {
|
||||
const cnt = (resourceList?.length || 0) + (preload?.length || 0)
|
||||
if (resourceList && resourceList.length) {
|
||||
if (resourceList?.length) {
|
||||
const s = resourceList.length / cnt
|
||||
await Laya.promises.loader.load(
|
||||
resourceList,
|
||||
Laya.Handler.create(null, prg => onProgress?.(prg * s))
|
||||
Laya.Handler.create(null, prg => onProgress?.(prg * s)),
|
||||
)
|
||||
}
|
||||
if (preload && preload.length) {
|
||||
if (preload?.length) {
|
||||
const s = 1 - preload.length / cnt
|
||||
const l = preload.length / cnt
|
||||
await Laya.promises.loader.load(
|
||||
preload,
|
||||
Laya.Handler.create(null, prg => onProgress?.(prg * l + s))
|
||||
Laya.Handler.create(null, prg => onProgress?.(prg * l + s)),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ export default class UIManager {
|
||||
args,
|
||||
actions?.load,
|
||||
dialogName,
|
||||
'pages'
|
||||
'pages',
|
||||
)
|
||||
|
||||
const index = this.#dialogStack.indexOf(dialog)
|
||||
@@ -223,7 +223,7 @@ export default class UIManager {
|
||||
dialog,
|
||||
{ scaleX: 1, scaleY: 1 },
|
||||
300,
|
||||
Laya.Ease.backOut
|
||||
Laya.Ease.backOut,
|
||||
)
|
||||
})
|
||||
await open(dialog)
|
||||
@@ -237,7 +237,7 @@ export default class UIManager {
|
||||
dialog,
|
||||
{ scaleX: 0, scaleY: 0 },
|
||||
300,
|
||||
Laya.Ease.strongIn
|
||||
Laya.Ease.strongIn,
|
||||
)
|
||||
}
|
||||
const index = this.#dialogStack.indexOf(dialog)
|
||||
@@ -255,7 +255,7 @@ export default class UIManager {
|
||||
const popup = await this.getView(className, args, null, type, 'popups')
|
||||
this.#popupLayer.addChild(popup)
|
||||
await popup.popup(args, this.#popupLayer)
|
||||
this.#popupLayer.removeChild(popup)
|
||||
popup.removeSelf()
|
||||
}
|
||||
|
||||
clearAllDialog() {
|
||||
@@ -266,7 +266,7 @@ export default class UIManager {
|
||||
#config(view, key, type) {
|
||||
const config = this.#configs?.[type]?.[key]
|
||||
if (!config) return
|
||||
if (view.config && view.config(config)) return
|
||||
if (view.config?.(config)) return
|
||||
const applyConfig = (target, config) => {
|
||||
if (!target) return
|
||||
if (typeof config == 'string') {
|
||||
@@ -278,7 +278,7 @@ export default class UIManager {
|
||||
if (config.names)
|
||||
for (const name in config.names)
|
||||
this.#deepGetChildsByName(view, name).forEach(child =>
|
||||
applyConfig(child, config.names[name])
|
||||
applyConfig(child, config.names[name]),
|
||||
)
|
||||
|
||||
if (config.vars)
|
||||
@@ -288,7 +288,7 @@ export default class UIManager {
|
||||
|
||||
#deepGetChildsByName(parent, name) {
|
||||
const list = []
|
||||
if (!parent || !parent._childs) return list
|
||||
if (!parent?._childs) return list
|
||||
|
||||
for (const child of parent._childs) {
|
||||
if (child.name == name) list.push(child)
|
||||
@@ -311,7 +311,7 @@ export default class UIManager {
|
||||
}
|
||||
|
||||
#subSkin(skin, type) {
|
||||
if (!skin || !skin.replace(/\s/g, '')) return []
|
||||
if (!skin?.replace(/\s/g, '')) return []
|
||||
switch (type) {
|
||||
case 'ProgressBar':
|
||||
return [skin, ...this.#progressBarSkin(skin)]
|
||||
@@ -340,21 +340,14 @@ export default class UIManager {
|
||||
|
||||
scanResource(uiView) {
|
||||
if (!uiView) return []
|
||||
const resourceList = []
|
||||
|
||||
resourceList.push(...this.#subSkin(uiView.props?.skin, uiView.type))
|
||||
resourceList.push(
|
||||
...this.#subSkin(uiView.props?.hScrollBarSkin, 'ScrollBar')
|
||||
)
|
||||
resourceList.push(
|
||||
...this.#subSkin(uiView.props?.vScrollBarSkin, 'ScrollBar')
|
||||
)
|
||||
|
||||
uiView.child?.forEach(child => {
|
||||
resourceList.push(...this.scanResource(child))
|
||||
})
|
||||
|
||||
return resourceList
|
||||
return [
|
||||
this.#subSkin(uiView.props?.skin, uiView.type),
|
||||
this.#subSkin(uiView.props?.hScrollBarSkin, 'ScrollBar'),
|
||||
this.#subSkin(uiView.props?.vScrollBarSkin, 'ScrollBar'),
|
||||
uiView.child?.flatMap(child => this.scanResource(child)),
|
||||
]
|
||||
.flat()
|
||||
.filter(item => !!item)
|
||||
}
|
||||
|
||||
get currentView() {
|
||||
@@ -362,7 +355,7 @@ export default class UIManager {
|
||||
}
|
||||
|
||||
get currentDialog() {
|
||||
return this.#dialogStack[this.#dialogStack.length - 1]
|
||||
return this.#dialogStack.at(-1)
|
||||
}
|
||||
|
||||
get theme() {
|
||||
|
||||
Reference in New Issue
Block a user