日历添加左右按钮

This commit is contained in:
2025-06-03 19:36:55 +08:00
parent cc6efbc801
commit ce90518d06
3 changed files with 168 additions and 17 deletions

View File

@@ -3,8 +3,8 @@
"_$id": "r0x6htig",
"_$type": "Box",
"name": "DailyChallenge",
"width": 1920,
"height": 1080,
"width": 1080,
"height": 1920,
"_mouseState": 2,
"left": 0,
"right": 0,
@@ -35,6 +35,12 @@
"btn_right": {
"_$ref": "e2xuqxps"
},
"btn_left2": {
"_$ref": "ybbojil0"
},
"btn_right2": {
"_$ref": "rp3gmpnp"
},
"bg_dc": {
"_$ref": "hdia0flx"
},
@@ -78,7 +84,6 @@
"_$id": "jfzgpbyj",
"_$type": "Box",
"name": "top",
"x": 420,
"width": 1080,
"height": 1080,
"_mouseState": 2,
@@ -366,8 +371,7 @@
"_$id": "rq2jiwrh",
"_$type": "Box",
"name": "bottom",
"x": 420,
"y": -265,
"y": 575,
"width": 1080,
"height": 1345,
"bottom": 0,
@@ -7156,6 +7160,66 @@
"valign": "middle",
"padding": "0,0,0,0"
},
{
"_$id": "ybbojil0",
"_$type": "Box",
"name": "btn_left",
"x": -61,
"y": -490,
"width": 48,
"height": 96,
"_mouseState": 2,
"_$comp": [
{
"_$type": "a541bdfc-e8e1-4795-b68e-7138c5190f17",
"scriptPath": "../src/views/common/CommonHover.ts",
"hoverAlpha": true
}
],
"_$child": [
{
"_$id": "wmm7xhim",
"_$type": "Image",
"name": "Image",
"width": 48,
"height": 97,
"mouseThrough": true,
"skin": "res://535f9c82-7994-4fd9-a6b5-e7d08199cd4f",
"useSourceSize": true,
"color": "#5b86b1"
}
]
},
{
"_$id": "rp3gmpnp",
"_$type": "Box",
"name": "btn_right",
"x": 951,
"y": -490,
"width": 48,
"height": 96,
"_mouseState": 2,
"_$comp": [
{
"_$type": "a541bdfc-e8e1-4795-b68e-7138c5190f17",
"scriptPath": "../src/views/common/CommonHover.ts",
"hoverAlpha": true
}
],
"_$child": [
{
"_$id": "hxt6cgnk",
"_$type": "Image",
"name": "Image",
"width": 48,
"height": 97,
"mouseThrough": true,
"skin": "res://25320e1c-b60c-45af-9122-cdc433872fa7",
"useSourceSize": true,
"color": "#5b86b1"
}
]
},
{
"_$id": "mv2bgo4b",
"_$type": "HBox",

View File

@@ -32,6 +32,12 @@
"btn_right": {
"_$ref": "cesch3ua"
},
"btn_left2": {
"_$ref": "ooo778f6"
},
"btn_right2": {
"_$ref": "9u1eta96"
},
"bg_dc": {
"_$ref": "s1tpy9gm"
},
@@ -7322,6 +7328,70 @@
]
}
]
},
{
"_$id": "ooo778f6",
"_$type": "Box",
"name": "btn_left",
"x": 18,
"y": 308,
"width": 36,
"height": 72,
"_mouseState": 2,
"_$comp": [
{
"_$type": "a541bdfc-e8e1-4795-b68e-7138c5190f17",
"scriptPath": "../src/views/common/CommonHover.ts",
"hoverAlpha": true
}
],
"_$child": [
{
"_$id": "c58rx218",
"_$type": "Image",
"name": "Image",
"width": 48,
"height": 97,
"scaleX": 0.75,
"scaleY": 0.75,
"mouseThrough": true,
"skin": "res://535f9c82-7994-4fd9-a6b5-e7d08199cd4f",
"useSourceSize": true,
"color": "#748290"
}
]
},
{
"_$id": "9u1eta96",
"_$type": "Box",
"name": "btn_right",
"x": 1140,
"y": 308,
"width": 36,
"height": 72,
"_mouseState": 2,
"_$comp": [
{
"_$type": "a541bdfc-e8e1-4795-b68e-7138c5190f17",
"scriptPath": "../src/views/common/CommonHover.ts",
"hoverAlpha": true
}
],
"_$child": [
{
"_$id": "te6v8xqq",
"_$type": "Image",
"name": "Image",
"width": 48,
"height": 97,
"scaleX": 0.75,
"scaleY": 0.75,
"mouseThrough": true,
"skin": "res://25320e1c-b60c-45af-9122-cdc433872fa7",
"useSourceSize": true,
"color": "#748290"
}
]
}
]
}

View File

@@ -33,6 +33,12 @@ export class DailyChallenge extends Laya.Script {
@property(Laya.Box)
public btn_right: Laya.Box
@property(Laya.Box)
public btn_left2: Laya.Box
@property(Laya.Box)
public btn_right2: Laya.Box
@property(Laya.Image)
public bg_dc: Laya.Image
@@ -128,18 +134,12 @@ export class DailyChallenge extends Laya.Script {
break
}
}
this.btn_left.on(Laya.Event.CLICK, this, () => {
if (this.currentIndex > 0) {
this.currentIndex--
this.loadWithIndex(this.currentIndex)
}
})
this.btn_right.on(Laya.Event.CLICK, this, () => {
if (this.currentIndex < this.indexMax) {
this.currentIndex++
this.loadWithIndex(this.currentIndex)
}
})
this.btn_left.on(Laya.Event.CLICK, this, this.onClickLeft)
this.btn_right.on(Laya.Event.CLICK, this, this.onClickRight)
this.btn_left2.on(Laya.Event.CLICK, this, this.onClickLeft)
this.btn_right2.on(Laya.Event.CLICK, this, this.onClickRight)
EventManager.getInstance().RegisterEvent(EVENT_TYPES.NOT_SET_TROPHY_BUTTON, DailyChallenge.EventUpdateTrophyButton)
}
@@ -169,6 +169,8 @@ export class DailyChallenge extends Laya.Script {
public loadWithIndex(index: number): void {
this.btn_left.visible = this.currentIndex > 0
this.btn_right.visible = this.currentIndex < this.indexMax
this.btn_left2.visible = this.currentIndex > 0
this.btn_right2.visible = this.currentIndex < this.indexMax
const info = MONTH_LIST[index]
UIManager.getInstance().setCurrentDCMonth(info.year, info.month)
console.log("DailyChallenge loadWithIndex >>>>>>>>>>>>>>>", info.year, info.month)
@@ -274,6 +276,21 @@ export class DailyChallenge extends Laya.Script {
this.onApplyUnit(unit)
}
onClickLeft(): void {
if (this.currentIndex > 0) {
this.currentIndex--
this.loadWithIndex(this.currentIndex)
}
}
onClickRight(): void {
if (this.currentIndex < this.indexMax) {
this.currentIndex++
this.loadWithIndex(this.currentIndex)
}
}
onStart(): void {
const user = StorageManager.getInstance().getUser()
const find = user.get_trophyHasNew()