mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-03-30 05:58:03 +08:00
daily update
This commit is contained in:
14
src/app.js
14
src/app.js
@@ -1,9 +1,11 @@
|
||||
import UIManager from './ui/uiManager.js';
|
||||
import * as utils from './functions/util.js';
|
||||
|
||||
globalThis.UIManager =
|
||||
globalThis.UI =
|
||||
UIManager;
|
||||
|
||||
globalThis.$_ = utils;
|
||||
class App{
|
||||
constructor(){
|
||||
this.name = 'lifeRestart';
|
||||
@@ -87,17 +89,7 @@ class App{
|
||||
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));
|
||||
await $ui.switchView(UI.pages.MAIN, null, {
|
||||
load: [
|
||||
"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",
|
||||
]
|
||||
});
|
||||
await $ui.switchView(UI.pages.MAIN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,4 +62,9 @@ function getConvertedMap(map, fn) {
|
||||
return newMap;
|
||||
}
|
||||
|
||||
export { clone, max, min, sum, average, weightRandom, listRandom, getListValuesMap, mapConvert, getConvertedMap };
|
||||
function mapSet(target, source) {
|
||||
for(const key in source)
|
||||
target[key] = source[key];
|
||||
}
|
||||
|
||||
export { clone, max, min, sum, average, weightRandom, listRandom, getListValuesMap, mapConvert, getConvertedMap, mapSet };
|
||||
File diff suppressed because one or more lines are too long
@@ -264,9 +264,9 @@ class ColorfulBox extends Laya.Box {
|
||||
constructor() {
|
||||
super();
|
||||
this.on(Laya.Event.MOUSE_OVER, this, this.onMouse, [Laya.Event.MOUSE_DOWN]);
|
||||
this.on(Laya.Event.MOUSE_DOWN, this, this.onMouse, [Laya.Event.MOUSE_DOWN]);
|
||||
// this.on(Laya.Event.MOUSE_DOWN, this, this.onMouse, [Laya.Event.MOUSE_DOWN]);
|
||||
this.on(Laya.Event.MOUSE_OUT, this, this.onMouse, [Laya.Event.MOUSE_OUT]);
|
||||
this.on(Laya.Event.MOUSE_UP, this, this.onMouse, [Laya.Event.MOUSE_UP]);
|
||||
// this.on(Laya.Event.MOUSE_UP, this, this.onMouse, [Laya.Event.MOUSE_UP]);
|
||||
this.#draw();
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ class ColorfulBox extends Laya.Box {
|
||||
#hoverLabel = '#000000';
|
||||
#color = new RGBAItem({hex: this.#defaultColor, on: ()=>this.#draw()});
|
||||
#stroke = new RGBAItem({hex: this.#defaultStroke, on: ()=>this.#draw()});
|
||||
#label = new RGBAItem({hex: this.#defaultLabel, on: (hex)=>{
|
||||
#label = new RGBAItem({hex: this.#defaultLabel, on: ({hex})=>{
|
||||
const label = this.getChildByName('label');
|
||||
if (!label) return;
|
||||
label.color = hex;
|
||||
@@ -292,6 +292,11 @@ class ColorfulBox extends Laya.Box {
|
||||
const label = this.getChildByName('label');
|
||||
const tween = (colorItem, target, last) => {
|
||||
Laya.Tween.clearAll(colorItem);
|
||||
const distance = colorItem.distance(target, last);
|
||||
if(!isFinite(distance)) {
|
||||
colorItem.hex = target;
|
||||
return;
|
||||
}
|
||||
Laya.Tween.to(colorItem, colorItem.cRgb(target), colorItem.distance(target, last) * this.#animationTime);
|
||||
}
|
||||
switch (type) {
|
||||
@@ -378,6 +383,9 @@ class ColorfulBox extends Laya.Box {
|
||||
}
|
||||
set defaultColor(value) {
|
||||
this.#defaultColor = value;
|
||||
Laya.Tween.clearAll(this.#color);
|
||||
Laya.Tween.clearAll(this.#stroke);
|
||||
Laya.Tween.clearAll(this.#label);
|
||||
this.#color.hex = value;
|
||||
}
|
||||
|
||||
@@ -393,6 +401,9 @@ class ColorfulBox extends Laya.Box {
|
||||
}
|
||||
set defaultStroke(value) {
|
||||
this.#defaultStroke = value;
|
||||
Laya.Tween.clearAll(this.#color);
|
||||
Laya.Tween.clearAll(this.#stroke);
|
||||
Laya.Tween.clearAll(this.#label);
|
||||
this.#stroke.hex = value;
|
||||
}
|
||||
|
||||
@@ -410,6 +421,9 @@ class ColorfulBox extends Laya.Box {
|
||||
this.#defaultLabel = value;
|
||||
const label = this.getChildByName('label');
|
||||
if (!label) return;
|
||||
Laya.Tween.clearAll(this.#color);
|
||||
Laya.Tween.clearAll(this.#stroke);
|
||||
Laya.Tween.clearAll(this.#label);
|
||||
label.color = value;
|
||||
}
|
||||
|
||||
@@ -442,5 +456,13 @@ class ColorfulBox extends Laya.Box {
|
||||
this.#lineWidth = value;
|
||||
this.#draw();
|
||||
}
|
||||
get label() {
|
||||
return this.getChildByName('label')?.text;
|
||||
}
|
||||
set label(value) {
|
||||
const label = this.getChildByName('label');
|
||||
if (!label) return;
|
||||
label.text = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,11 +37,11 @@ export default class CyberAchievement extends CyberAchievementUI {
|
||||
|
||||
this.labRemakeTimes.text = statistics[pt.TMS].value;
|
||||
this.labRemakeTimesJudge.text = statistics[pt.TMS].judge;
|
||||
this.labAchievementCountJudge.color = $ui.gradeColor(statistics[pt.TMS].grade);
|
||||
this.labAchievementCountJudge.color = $ui.common.grade[statistics[pt.TMS].grade];
|
||||
|
||||
this.labAchievementCount.text = statistics[pt.CACHV].value;
|
||||
this.labAchievementCountJudge.text = statistics[pt.CACHV].judge;
|
||||
this.labAchievementCountJudge.color = $ui.gradeColor(statistics[pt.CACHV].grade);
|
||||
this.labAchievementCountJudge.color = $ui.common.grade[statistics[pt.CACHV].grade];
|
||||
|
||||
this.labEventRate.text = parseInt(statistics[pt.REVT].value*100)+'%';
|
||||
this.prgEventRate.value = statistics[pt.REVT].value;
|
||||
|
||||
@@ -15,6 +15,18 @@ export default class CyberMain extends CyberMainUI {
|
||||
});
|
||||
}
|
||||
|
||||
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",
|
||||
]
|
||||
}
|
||||
|
||||
init() {
|
||||
this.btnDiscord.visible =
|
||||
this.btnAchievement.visible =
|
||||
|
||||
@@ -8,7 +8,7 @@ export default class CyberAchievementPopup extends CyberAchievementPopupUI {
|
||||
Laya.Tween.clearAll(this.boxBg);
|
||||
this.alpha = 0.8;
|
||||
this.labName.text = achievement.name;
|
||||
this.labName.color = $ui.gradeColor(achievement.grade);
|
||||
this.labName.color = $ui.common.grade[achievement.grade];
|
||||
this.x = - this.width;
|
||||
this.boxBg.x = this.boxBg.width;
|
||||
await Promise.all([
|
||||
|
||||
@@ -15,18 +15,8 @@ export default class CyberSummary extends CyberSummaryUI {
|
||||
|
||||
init({talents}) {
|
||||
const {summary, lastExtendTalent} = core;
|
||||
const gradeFilters = [
|
||||
$ui.common.grade0,
|
||||
$ui.common.grade1,
|
||||
$ui.common.grade2,
|
||||
$ui.common.grade3,
|
||||
];
|
||||
const gradeColors = [
|
||||
$ui.common.filter0,
|
||||
$ui.common.filter1,
|
||||
$ui.common.filter2,
|
||||
$ui.common.filter3,
|
||||
];
|
||||
const gradeFilters = $ui.common.filter;
|
||||
const gradeColors = $ui.common.grade;
|
||||
|
||||
const age = summary[core.PropertyTypes.HAGE];
|
||||
this.labAge.text = ''+age.value;
|
||||
|
||||
@@ -37,11 +37,11 @@ export default class Achievement extends AchievementUI {
|
||||
|
||||
this.labRemakeTimes.text = statistics[pt.TMS].value;
|
||||
this.labRemakeTimesJudge.text = statistics[pt.TMS].judge;
|
||||
this.labAchievementCountJudge.color = $ui.gradeColor(statistics[pt.TMS].grade);
|
||||
this.labAchievementCountJudge.color = $ui.common.grade[statistics[pt.TMS].grade];
|
||||
|
||||
this.labAchievementCount.text = statistics[pt.CACHV].value;
|
||||
this.labAchievementCountJudge.text = statistics[pt.CACHV].judge;
|
||||
this.labAchievementCountJudge.color = $ui.gradeColor(statistics[pt.CACHV].grade);
|
||||
this.labAchievementCountJudge.color = $ui.common.grade[statistics[pt.CACHV].grade];
|
||||
|
||||
this.labEventRate.text = parseInt(statistics[pt.REVT].value*100)+'%';
|
||||
this.prgEventRate.value = statistics[pt.REVT].value;
|
||||
|
||||
@@ -8,6 +8,12 @@ export default class Main extends MainUI {
|
||||
this.btnDiscord.on(Laya.Event.CLICK, this, goto, ['discord']);
|
||||
}
|
||||
|
||||
static load() {
|
||||
return [
|
||||
"images/atlas/images/icons.atlas",
|
||||
]
|
||||
}
|
||||
|
||||
init() {
|
||||
this.btnDiscord.visible =
|
||||
this.btnAchievement.visible =
|
||||
|
||||
@@ -8,7 +8,7 @@ export default class achievementPopup extends AchievementPopupUI {
|
||||
Laya.Tween.clearAll(this.boxBg);
|
||||
this.alpha = 0.8;
|
||||
this.labName.text = achievement.name;
|
||||
this.labName.color = $ui.gradeColor(achievement.grade);
|
||||
this.labName.color = $ui.common.grade[achievement.grade];
|
||||
this.x = - this.width;
|
||||
this.boxBg.x = this.boxBg.width;
|
||||
await Promise.all([
|
||||
|
||||
@@ -5,19 +5,9 @@ export default class Talent extends TalentUI {
|
||||
this.btnNext.on(Laya.Event.CLICK, this, this.onClickNext);
|
||||
this.listTalents.renderHandler = Laya.Handler.create(this, this.renderTalent, null, false);
|
||||
this.listTalents.scrollBar.elasticDistance = 150;
|
||||
this.on(Laya.Event.RESIZE, this, () => {
|
||||
const renderWidth = this.listTalents?._itemRender?.props?.width;
|
||||
if(renderWidth) {
|
||||
const col = Math.max(Math.floor((this.width - 40) / renderWidth), 1);
|
||||
this.listTalents.width = col * renderWidth + (col - 1) * (this.listTalents.spaceY || 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#selected = new Set();
|
||||
static load() {
|
||||
return ['images/background/background_2@3x.png'];
|
||||
}
|
||||
|
||||
init() {
|
||||
this.pageDrawCard.visible = true;
|
||||
@@ -46,51 +36,11 @@ export default class Talent extends TalentUI {
|
||||
renderTalent(box, index) {
|
||||
const dataSource = box.dataSource;
|
||||
|
||||
const hboxTitle = box.getChildByName("hboxTitle");
|
||||
const labTitle = hboxTitle.getChildByName("labTitle");
|
||||
const grades = hboxTitle.getChildByName("grades");
|
||||
const grade1 = grades.getChildByName("grade1");
|
||||
const grade2 = grades.getChildByName("grade2");
|
||||
const grade3 = grades.getChildByName("grade3");
|
||||
const labDescription = box.getChildByName("labDescription");
|
||||
const unselected = box.getChildByName("unselected");
|
||||
const selected = box.getChildByName("selected");
|
||||
box.label = `${dataSource.name}(${dataSource.description})`;
|
||||
const style = $ui.common.card[dataSource.grade];
|
||||
|
||||
$_.mapSet(box, this.#selected.has(index)? style.selected: style.normal);
|
||||
|
||||
switch (dataSource.grade) {
|
||||
case 1:
|
||||
grades.x = 0;
|
||||
labTitle.x = 1;
|
||||
grade1.visible = true;
|
||||
grade2.visible = false;
|
||||
grade3.visible = false;
|
||||
break;
|
||||
case 2:
|
||||
grades.x = 0;
|
||||
labTitle.x = 1;
|
||||
grade1.visible = false;
|
||||
grade2.visible = true;
|
||||
grade3.visible = false;
|
||||
break;
|
||||
case 3:
|
||||
grades.x = 0;
|
||||
labTitle.x = 1;
|
||||
grade1.visible = false;
|
||||
grade2.visible = false;
|
||||
grade3.visible = true;
|
||||
break;
|
||||
default:
|
||||
grades.x = 1;
|
||||
labTitle.x = 0;
|
||||
grade1.visible = false;
|
||||
grade2.visible = false;
|
||||
grade3.visible = false;
|
||||
break;
|
||||
}
|
||||
labTitle.text = dataSource.name;
|
||||
labTitle.event(Laya.Event.RESIZE);
|
||||
labDescription.text = dataSource.description;
|
||||
unselected.visible = !( selected.visible = this.#selected.has(index) );
|
||||
box.offAll(Laya.Event.CLICK);
|
||||
box.on(Laya.Event.CLICK, this, () => {
|
||||
if(this.#selected.has(index)) {
|
||||
@@ -105,7 +55,8 @@ export default class Talent extends TalentUI {
|
||||
this.btnNext.label = this.#selected.size === core.talentSelectLimit
|
||||
? 'UI_Next'
|
||||
: 'UI_Talent_Select_Uncomplete';
|
||||
unselected.visible = !( selected.visible = this.#selected.has(index) );
|
||||
|
||||
$_.mapSet(box, this.#selected.has(index)? style.selected: style.normal);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -59,9 +59,9 @@ export default class Trajectory extends TrajectoryUI {
|
||||
return ['images/slider/vslider_1@3x$bar.png'];
|
||||
}
|
||||
|
||||
static #createComponent = plugin.extractComponents(CyberTrajectory.uiView, ['boxTrajectoryItem']);
|
||||
static #createComponent = plugin.extractComponents(Trajectory.uiView, ['boxTrajectoryItem']);
|
||||
#createTrajectoryItem() {
|
||||
const item = CyberTrajectory.#createComponent('boxTrajectoryItem');
|
||||
const item = Trajectory.#createComponent('boxTrajectoryItem');
|
||||
item.labContent = item.getChildByName('labContent');
|
||||
item.labAge = item.getChildByName('hboxAge').getChildByName('labAge');
|
||||
return item;
|
||||
|
||||
@@ -62,14 +62,108 @@ const def = {
|
||||
configs: {
|
||||
bgColor: '#222831',
|
||||
common: {
|
||||
grade0: '#cccccc',
|
||||
grade1: '#55fffe',
|
||||
grade2: '#b17cff',
|
||||
grade3: '#ffce45',
|
||||
filter0: '#ccccccff',
|
||||
filter0: '#55fffeff',
|
||||
filter0: '#b17cffff',
|
||||
filter0: '#ffce45ff',
|
||||
grade: [
|
||||
'#cccccc',
|
||||
'#55fffe',
|
||||
'#b17cff',
|
||||
'#ffce45',
|
||||
],
|
||||
filter: [
|
||||
'#ccccccff',
|
||||
'#55fffeff',
|
||||
'#b17cffff',
|
||||
'#ffce45ff',
|
||||
],
|
||||
card: [
|
||||
{
|
||||
normal: {
|
||||
defaultColor: '#464646',
|
||||
defaultStroke: '#f8f8f8',
|
||||
defaultLabel: '#eeeeee',
|
||||
hoverColor: '#c0c0c0',
|
||||
hoverStroke: '#f8f8f8',
|
||||
hoverLabel: '#3b3b3b',
|
||||
lineWidth: 4,
|
||||
radius: 4,
|
||||
},
|
||||
selected: {
|
||||
defaultColor: '#c0c0c0',
|
||||
defaultStroke: '#a5ff88',
|
||||
defaultLabel: '#3b3b3b',
|
||||
hoverColor: '#c0c0c0',
|
||||
hoverStroke: '#a5ff88',
|
||||
hoverLabel: '#3b3b3b',
|
||||
lineWidth: 4,
|
||||
radius: 4,
|
||||
}
|
||||
},
|
||||
{
|
||||
normal: {
|
||||
defaultColor: '#6495ed',
|
||||
defaultStroke: '#f8f8f8',
|
||||
defaultLabel: '#eeeeee',
|
||||
hoverColor: '#87cefa',
|
||||
hoverStroke: '#f8f8f8',
|
||||
hoverLabel: '#3b3b3b',
|
||||
lineWidth: 4,
|
||||
radius: 4,
|
||||
},
|
||||
selected: {
|
||||
defaultColor: '#87cefa',
|
||||
defaultStroke: '#a5ff88',
|
||||
defaultLabel: '#3b3b3b',
|
||||
hoverColor: '#87cefa',
|
||||
hoverStroke: '#a5ff88',
|
||||
hoverLabel: '#3b3b3b',
|
||||
lineWidth: 4,
|
||||
radius: 4,
|
||||
}
|
||||
},
|
||||
{
|
||||
normal: {
|
||||
defaultColor: '#e2a7ff',
|
||||
defaultStroke: '#f8f8f8',
|
||||
defaultLabel: '#eeeeee',
|
||||
hoverColor: '#e7beff',
|
||||
hoverStroke: '#f8f8f8',
|
||||
hoverLabel: '#3b3b3b',
|
||||
lineWidth: 4,
|
||||
radius: 4,
|
||||
},
|
||||
selected: {
|
||||
defaultColor: '#e7beff',
|
||||
defaultStroke: '#a5ff88',
|
||||
defaultLabel: '#3b3b3b',
|
||||
hoverColor: '#e7beff',
|
||||
hoverStroke: '#a5ff88',
|
||||
hoverLabel: '#3b3b3b',
|
||||
lineWidth: 4,
|
||||
radius: 4,
|
||||
}
|
||||
},
|
||||
{
|
||||
normal: {
|
||||
defaultColor: '#ffa07a',
|
||||
defaultStroke: '#f8f8f8',
|
||||
defaultLabel: '#eeeeee',
|
||||
hoverColor: '#f7a989',
|
||||
hoverStroke: '#f8f8f8',
|
||||
hoverLabel: '#3b3b3b',
|
||||
lineWidth: 4,
|
||||
radius: 4,
|
||||
},
|
||||
selected: {
|
||||
defaultColor: '#f8f8f8',
|
||||
defaultStroke: '#a5ff88',
|
||||
defaultLabel: '#eeeeee',
|
||||
hoverColor: '#3b3b3b',
|
||||
hoverStroke: '#a5ff88',
|
||||
hoverLabel: '#3b3b3b',
|
||||
lineWidth: 4,
|
||||
radius: 4,
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
class: {
|
||||
btn_main: {
|
||||
@@ -91,6 +185,9 @@ const def = {
|
||||
hoverLabel: '#eeeeee',
|
||||
lineWidth: 0,
|
||||
radius: 4,
|
||||
},
|
||||
title: {
|
||||
color: '#ffffff',
|
||||
}
|
||||
},
|
||||
pages: {
|
||||
@@ -103,6 +200,15 @@ const def = {
|
||||
names: {
|
||||
btnSmall: 'btn_small',
|
||||
}
|
||||
},
|
||||
[pages.TALENT]: {
|
||||
vars: {
|
||||
btnDrawCard: 'btn_main',
|
||||
btnNext: 'btn_main',
|
||||
},
|
||||
names: {
|
||||
title: 'title',
|
||||
}
|
||||
}
|
||||
},
|
||||
popups: {
|
||||
|
||||
@@ -138,12 +138,16 @@ export default class UIManager {
|
||||
}
|
||||
|
||||
async loadRes(resourceList, preload, onProgress) {
|
||||
let list = [];
|
||||
if(resourceList) list = list.concat(resourceList);
|
||||
if(preload) list = list.concat(preload);
|
||||
|
||||
if(list.length) {
|
||||
await Laya.promises.loader.load(list, Laya.Handler.create(null, onProgress));
|
||||
const cnt = (resourceList?.length || 0)
|
||||
+(preload?.length || 0);
|
||||
if(resourceList && resourceList.length) {
|
||||
const s = resourceList.length / cnt;
|
||||
await Laya.promises.loader.load(resourceList, Laya.Handler.create(null, prg=>onProgress?.(prg*s)));
|
||||
}
|
||||
if(preload && 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)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +186,7 @@ export default class UIManager {
|
||||
#config(view, key, type) {
|
||||
const config = this.#configs?.[type]?.[key];
|
||||
if(!config) return;
|
||||
if(view.config) return view.config(config);
|
||||
if(view.config && view.config(config)) return;
|
||||
const applyConfig = (target, config) => {
|
||||
if(!target) return;
|
||||
if(typeof config == 'string') {
|
||||
@@ -293,12 +297,12 @@ export default class UIManager {
|
||||
return UIManager.theme(this.#theme, 'configs');
|
||||
}
|
||||
get common() {
|
||||
return this.#configs?.common;
|
||||
return this.#configs.common;
|
||||
}
|
||||
gradeColor(grade) {
|
||||
return this.common?.['grade'+grade];
|
||||
return this.common.grade[grade];
|
||||
}
|
||||
gradeFilter(grade) {
|
||||
return this.common?.['filter'+grade];
|
||||
return this.common.filter[grade];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user