import { _decorator, Component, Node, Sprite, Vec3, tween, UITransform, path, } from "cc"; import ResManager from "db://assets/Scripts/Main/Manager/ResManager"; import Utils from "db://assets/Scripts/Main/Common/Utils"; import { ViewManager } from "db://assets/Scripts/Main/Manager/ViewManager"; import { DataId, DataManager } from "../../data/DataManager"; import { GirlData } from "../../data/GirlData"; import proto from "db://assets/Scripts/proto/proto.pb.js"; import { GButton } from "../../../Main/Common/GButton"; const { ccclass, property } = _decorator; @ccclass("ImagePopup") export class ImagePopup extends Component { @property(Sprite) image: Sprite; start() { this.node.setPosition(new Vec3(-1500, 493, 0)); GButton.BandClick(this.image.node, this.openImage, this); this.node.active = false; } onDestroy() { //this.image.node.off(Node.EventType.TOUCH_START,this.openImage); } categoryId: string; girlId: number; resId: number; //url: string; refresh(categoryId: string, girlId: number, resId: number, clear = false) { this.node.active = true; const girlData = DataManager.I.getDataById(DataId.Girl); this.categoryId = categoryId; this.girlId = girlId; this.resId = resId; const url = girlData.getGrilPhotoPic(categoryId, girlId, resId); //this.url = path; ResManager.I.changeBundleSpriteFrame( this.image, url + (clear ? "" : "_thumbnail_blur"), "Girls", () => { let sizeTran = this.image.node.parent.getComponent(UITransform); Utils.adjustBgPixelRatioToSize( sizeTran.contentSize, this.image.node, 2 ); this.popUp(); } ); } refreshSelf() { this.refresh(this.categoryId, this.girlId, this.resId, true); } openImage() { const girlData = DataManager.I.getDataById(DataId.Girl); const isUnlock = girlData.isImageUnlock( this.categoryId, this.girlId, this.resId ); if (isUnlock) { let data = { url: girlData.getGrilPhotoPic(this.categoryId, this.girlId, this.resId), isImg: true, }; ViewManager.I.openBundlesView("ShowPanel", data); } else { ViewManager.I.openBundlesView("PopupGirlDetailPanel", { category: this.categoryId, resId: this.resId, girlId: this.girlId, base: this, type: proto.cs.EnmResType.ERT_Image, }); } // } popUp() { tween(this.node) .to(0.5, { position: new Vec3(-559.374, 493, 0) }, { easing: "backOut" }) .start(); this.scheduleOnce(() => { this.popDown(); }, 5); } popDown() { tween(this.node) .to(0.5, { position: new Vec3(-1500, 493, 0) }, { easing: "backIn" }) .start(); } }