Merge branch 'main' of 47.107.44.202:xionglijia/18xchat
This commit is contained in:
@@ -4,23 +4,22 @@ import GameRootUI from "../Main/Common/GameRootUI";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//主界面场景
|
||||
@ccclass('MainScene')
|
||||
@ccclass("MainScene")
|
||||
export class MainScene extends Component {
|
||||
@property(Node)
|
||||
UIRoot: Node = null;
|
||||
@property(Node)
|
||||
UILayerMod: Node = null;
|
||||
@property(Camera)
|
||||
MainCamera: Camera = null;
|
||||
|
||||
@property(Node)
|
||||
UIRoot: Node = null
|
||||
@property(Node)
|
||||
UILayerMod: Node = null
|
||||
@property(Camera)
|
||||
MainCamera: Camera = null
|
||||
|
||||
start() {
|
||||
//每个场景必须添加的
|
||||
let gameRootUI = this.node.getComponent(GameRootUI)
|
||||
if (!gameRootUI){
|
||||
gameRootUI = this.node.addComponent(GameRootUI)
|
||||
gameRootUI.InitByCreate(this.UIRoot, this.UILayerMod, "ThemePanel");
|
||||
}
|
||||
GameRootUI.MainCamera = this.MainCamera
|
||||
start() {
|
||||
//每个场景必须添加的
|
||||
let gameRootUI = this.node.getComponent(GameRootUI);
|
||||
if (!gameRootUI) {
|
||||
gameRootUI = this.node.addComponent(GameRootUI);
|
||||
gameRootUI.InitByCreate(this.UIRoot, this.UILayerMod, "ThemePanel");
|
||||
}
|
||||
}
|
||||
GameRootUI.MainCamera = this.MainCamera;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
import { _decorator, Button, Component, Node, Label, View } from "cc";
|
||||
import {
|
||||
_decorator,
|
||||
Button,
|
||||
Component,
|
||||
Node,
|
||||
Label,
|
||||
View,
|
||||
Sprite,
|
||||
UITransform,
|
||||
} from "cc";
|
||||
import li_BaseView from "../../../Main/Common/li_BaseView";
|
||||
import Utils from "../../../Main/Common/Utils";
|
||||
import { GButton } from "../../../Main/Common/GButton";
|
||||
@@ -12,6 +21,7 @@ import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
import LanguageUtils from "../../../Main/Common/LanguageUtils";
|
||||
import { ViewManager } from "../../../Main/Manager/ViewManager";
|
||||
import { TipsPanel } from "./TipsPanel";
|
||||
import ResManager from "../../../Main/Manager/ResManager";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("GirlListPopupPanel")
|
||||
@@ -25,6 +35,8 @@ export class GirlListPopupPanel extends li_BaseView {
|
||||
private girlTag: Label;
|
||||
|
||||
base: GirlListItem;
|
||||
img: Sprite;
|
||||
uitransform: UITransform;
|
||||
openUIDataCT(data) {
|
||||
this.category = data.category;
|
||||
this.girlId = data.id;
|
||||
@@ -32,6 +44,8 @@ export class GirlListPopupPanel extends li_BaseView {
|
||||
}
|
||||
onLoadCT() {
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
this.img = this._nodeTab.img.getComponent(Sprite);
|
||||
this.uitransform = this._nodeTab.Img_Frame.getComponent(UITransform);
|
||||
this.girlName = this._nodeTab.Name.getComponent(Label);
|
||||
this.girlTag = this._nodeTab.Tag.getComponent(Label);
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
@@ -48,6 +62,13 @@ export class GirlListPopupPanel extends li_BaseView {
|
||||
this.girlTag.string = LanguageUtils.getText(
|
||||
girlData.getGrilTagKey(this.category.toString(), this.girlId)
|
||||
);
|
||||
|
||||
const path = girlData.getGrilAvatar(this.category.toString(), this.girlId);
|
||||
|
||||
//console.log(path);
|
||||
ResManager.I.changeBundleSpriteFrame(this.img, path, "Girls", () => {
|
||||
this.scaleToFillItem();
|
||||
});
|
||||
}
|
||||
registerListener() {
|
||||
GButton.BandClick(this._nodeTab.BuyBtn, this.buyCharacter, this);
|
||||
@@ -83,4 +104,44 @@ export class GirlListPopupPanel extends li_BaseView {
|
||||
}
|
||||
// TipsPanel.show("Insufficient balance, need to purchase");
|
||||
}
|
||||
|
||||
scaleToFillItem() {
|
||||
if (!this.img || !this.img.spriteFrame) return;
|
||||
|
||||
// 延迟一帧确保UI布局完成
|
||||
this.doScaleToFill();
|
||||
}
|
||||
|
||||
doScaleToFill() {
|
||||
if (!this.img || !this.img.spriteFrame) return;
|
||||
if (!this.uitransform)
|
||||
this.uitransform = this.node.getComponent(UITransform);
|
||||
const itemSize = this.uitransform.contentSize;
|
||||
const imageSize = this.img.spriteFrame.originalSize;
|
||||
|
||||
if (
|
||||
itemSize.width === 0 ||
|
||||
itemSize.height === 0 ||
|
||||
imageSize.width === 0 ||
|
||||
imageSize.height === 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const scaleX = itemSize.width / imageSize.width;
|
||||
const scaleY = itemSize.height / imageSize.height;
|
||||
const scale = Math.max(scaleY, scaleY);
|
||||
|
||||
// 设置Sprite的sizeMode为CUSTOM,允许自定义大小
|
||||
this.img.sizeMode = Sprite.SizeMode.CUSTOM;
|
||||
|
||||
// 获取图片节点的UITransform并设置大小
|
||||
const imgTransform = this.img.node.getComponent(UITransform);
|
||||
if (imgTransform) {
|
||||
imgTransform.setContentSize(
|
||||
imageSize.width * scale,
|
||||
imageSize.height * scale
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { _decorator, Component, Node, Label } from "cc";
|
||||
import { _decorator, Component, Node, Label, UITransform, Sprite } from "cc";
|
||||
import li_BaseView from "../../../Main/Common/li_BaseView";
|
||||
import { GButton } from "../../../Main/Common/GButton";
|
||||
import Utils from "../../../Main/Common/Utils";
|
||||
@@ -11,6 +11,7 @@ import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
import LanguageUtils from "../../../Main/Common/LanguageUtils";
|
||||
import { ImagePopup } from "../components/ImagePopup";
|
||||
import { TipsPanel } from "./TipsPanel";
|
||||
import ResManager from "../../../Main/Manager/ResManager";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("PopupGirlDetailPanel")
|
||||
@@ -24,6 +25,9 @@ export class PopupGirlDetailPanel extends li_BaseView {
|
||||
private base: DetailImageItem | ImagePopup;
|
||||
|
||||
private desc: Label;
|
||||
|
||||
img: Sprite;
|
||||
uitransform: UITransform;
|
||||
openUIDataCT(data) {
|
||||
this.category = data.category;
|
||||
this.resId = data.resId;
|
||||
@@ -34,12 +38,15 @@ export class PopupGirlDetailPanel extends li_BaseView {
|
||||
onLoadCT() {
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
this.desc = this._nodeTab.content.getComponent(Label);
|
||||
|
||||
this.uitransform = this._nodeTab.Img_Frame.getComponent(UITransform);
|
||||
this.img = this._nodeTab.img.getComponent(Sprite);
|
||||
let descText = LanguageUtils.getText("popupgirldetailpanel.content");
|
||||
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
// 价格
|
||||
this.priceLabel = this._nodeTab.Price.getComponent(Label);
|
||||
|
||||
let url = "";
|
||||
if (this.type === proto.cs.EnmResType.ERT_Image) {
|
||||
// 图片
|
||||
this.priceLabel.string = girlData
|
||||
@@ -49,6 +56,11 @@ export class PopupGirlDetailPanel extends li_BaseView {
|
||||
this.resId
|
||||
)
|
||||
.toString();
|
||||
url = girlData.getGrilPhotoPic(
|
||||
this.category.toString(),
|
||||
this.girlId,
|
||||
this.resId
|
||||
);
|
||||
} else if (this.type === proto.cs.EnmResType.ERT_Video) {
|
||||
// 视频
|
||||
this.priceLabel.string = girlData
|
||||
@@ -58,8 +70,16 @@ export class PopupGirlDetailPanel extends li_BaseView {
|
||||
this.resId
|
||||
)
|
||||
.toString();
|
||||
url = girlData.getGrilVideoPath(
|
||||
this.category.toString(),
|
||||
this.girlId,
|
||||
this.resId
|
||||
);
|
||||
}
|
||||
|
||||
const path = url + "_thumbnail_blur";
|
||||
ResManager.I.changeBundleSpriteFrame(this.img, path, "Girls", () => {
|
||||
this.scaleToFillItem();
|
||||
});
|
||||
this.desc.string = descText.replace("{price}", this.priceLabel.string);
|
||||
|
||||
this.registerListener();
|
||||
@@ -108,4 +128,44 @@ export class PopupGirlDetailPanel extends li_BaseView {
|
||||
TipsPanel.show("Insufficient balance, need to purchase");
|
||||
}
|
||||
}
|
||||
|
||||
scaleToFillItem() {
|
||||
if (!this.img || !this.img.spriteFrame) return;
|
||||
|
||||
// 延迟一帧确保UI布局完成
|
||||
this.doScaleToFill();
|
||||
}
|
||||
|
||||
doScaleToFill() {
|
||||
if (!this.img || !this.img.spriteFrame) return;
|
||||
if (!this.uitransform)
|
||||
this.uitransform = this.node.getComponent(UITransform);
|
||||
const itemSize = this.uitransform.contentSize;
|
||||
const imageSize = this.img.spriteFrame.originalSize;
|
||||
|
||||
if (
|
||||
itemSize.width === 0 ||
|
||||
itemSize.height === 0 ||
|
||||
imageSize.width === 0 ||
|
||||
imageSize.height === 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const scaleX = itemSize.width / imageSize.width;
|
||||
const scaleY = itemSize.height / imageSize.height;
|
||||
const scale = Math.max(scaleY, scaleY);
|
||||
|
||||
// 设置Sprite的sizeMode为CUSTOM,允许自定义大小
|
||||
this.img.sizeMode = Sprite.SizeMode.CUSTOM;
|
||||
|
||||
// 获取图片节点的UITransform并设置大小
|
||||
const imgTransform = this.img.node.getComponent(UITransform);
|
||||
if (imgTransform) {
|
||||
imgTransform.setContentSize(
|
||||
imageSize.width * scale,
|
||||
imageSize.height * scale
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export class ThemePanel extends li_BaseView {
|
||||
this.coinNum = this._nodeTab.coinNum.getComponent(Label);
|
||||
this.uid = this._nodeTab.uid.getComponent(Label);
|
||||
this.recName = this._nodeTab.characterNameText.getComponent(Label);
|
||||
this.recSprite = this._nodeTab.recPicSlot.getComponent(Sprite);
|
||||
this.recSprite = this._nodeTab.recPic.getComponent(Sprite);
|
||||
this.vipLeftTime = this._nodeTab.vipText.getComponent(Label);
|
||||
|
||||
this.registerListener();
|
||||
@@ -66,6 +66,7 @@ export class ThemePanel extends li_BaseView {
|
||||
|
||||
rectNameKey: string;
|
||||
async Show() {
|
||||
this._nodeTab.loadingRec.active = true;
|
||||
//some temp data
|
||||
this.refreshCoinNum();
|
||||
this.refreshVipExpire();
|
||||
@@ -121,6 +122,7 @@ export class ThemePanel extends li_BaseView {
|
||||
}
|
||||
);
|
||||
}
|
||||
this._nodeTab.loadingRec.active = false;
|
||||
|
||||
// 获取商品列表,提前把数据拿下来
|
||||
this.reqShopList();
|
||||
|
||||
@@ -36,7 +36,8 @@ export class DetailImageItem extends Component {
|
||||
priceFrame: Node;
|
||||
@property(Label)
|
||||
videoPrice: Label;
|
||||
|
||||
@property(Node)
|
||||
loading: Node;
|
||||
base: GirlDetailPanel;
|
||||
url: string;
|
||||
isImage: boolean;
|
||||
@@ -142,8 +143,9 @@ export class DetailImageItem extends Component {
|
||||
this.category = category;
|
||||
this.girlId = id;
|
||||
this.resId = resId;
|
||||
this.question.active = true; // 显示问号,表示加载中
|
||||
//this.question.active = true; // 显示问号,表示加载中
|
||||
|
||||
this.loading.active = true;
|
||||
this.test_resID = this.node.getChildByName("resID");
|
||||
|
||||
this.test_resID.getComponent(Label).string =
|
||||
@@ -209,8 +211,9 @@ export class DetailImageItem extends Component {
|
||||
}
|
||||
|
||||
ResManager.I.changeBundleSpriteFrame(this.img, imgPath, "Girls", () => {
|
||||
this.question.active = false; // 图片加载成功后隐藏问号
|
||||
if (!this.isVisible) this.question.active = false; // 图片加载成功后隐藏问号
|
||||
this.scaleToFillItem();
|
||||
this.loading.active = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ export class GirlListItem extends Component {
|
||||
|
||||
@property(Node)
|
||||
starParent: Node;
|
||||
|
||||
@property(Node)
|
||||
loading: Node;
|
||||
stars: Sprite[];
|
||||
|
||||
id: number = -1;
|
||||
@@ -133,15 +134,16 @@ export class GirlListItem extends Component {
|
||||
// this.price.node.active = priceType == PriceType.pay;
|
||||
// this.freeNode.active = priceType == PriceType.free;
|
||||
//this.tryNode.active = priceType == PriceType.first_time_free;
|
||||
let listAvatarPath = girlData.getGrilAvatar(
|
||||
let avatarPath = girlData.getGrilAvatar(
|
||||
this.category.toString(),
|
||||
this.id
|
||||
);
|
||||
this.loading.active = true;
|
||||
|
||||
//listAvatarPath = listAvatarPath.replace("Avatar", "avatar"); //临时
|
||||
ResManager.I.changeBundleSpriteFrame(
|
||||
this.avatar,
|
||||
listAvatarPath,
|
||||
avatarPath,
|
||||
"Girls",
|
||||
() => {
|
||||
let sizeTran = this.avatar.node.parent.getComponent(UITransform);
|
||||
@@ -150,6 +152,7 @@ export class GirlListItem extends Component {
|
||||
this.avatar.node,
|
||||
2
|
||||
);
|
||||
this.loading.active = false;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { _decorator, Animation, Component, Node } from "cc";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("LoadingItem")
|
||||
export class LoadingItem extends Component {
|
||||
@property(Animation)
|
||||
animation: Animation;
|
||||
protected onEnable(): void {
|
||||
if (this.animation) {
|
||||
this.animation.play();
|
||||
}
|
||||
}
|
||||
|
||||
protected onDisable(): void {
|
||||
if (this.animation) {
|
||||
this.animation.pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "38c1255e-0b9d-4c11-aae0-ebc28d580222",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -19,6 +19,9 @@ export class ThemeItem extends Component {
|
||||
@property(Label)
|
||||
titleName: Label;
|
||||
|
||||
@property(Node)
|
||||
loading: Node;
|
||||
|
||||
@property(Sprite)
|
||||
img: Sprite;
|
||||
|
||||
@@ -39,13 +42,16 @@ export class ThemeItem extends Component {
|
||||
}
|
||||
|
||||
refresh(themeId: number) {
|
||||
this.loading.active = true;
|
||||
// 主题数据
|
||||
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
|
||||
this.lockImg.node.active = this.lockCover.node.active =
|
||||
!themeData.getIsReleaseById(themeId);
|
||||
this.isLocked = !themeData.getIsReleaseById(themeId);
|
||||
this.key = themeData.getLanKeyById(themeId);
|
||||
this.titleName.string = LanguageUtils.getText(themeData.getLanKeyById(themeId));
|
||||
this.titleName.string = LanguageUtils.getText(
|
||||
themeData.getLanKeyById(themeId)
|
||||
);
|
||||
this.category = themeData.getCategoryById(themeId);
|
||||
ResManager.I.changeBundleSpriteFrame(
|
||||
this.img,
|
||||
@@ -54,6 +60,7 @@ export class ThemeItem extends Component {
|
||||
() => {
|
||||
let sizeTran = this.img.node.parent.getComponent(UITransform);
|
||||
Utils.adjustBgPixelRatioToSize(sizeTran.contentSize, this.img.node, 3);
|
||||
this.loading.active = false;
|
||||
}
|
||||
);
|
||||
GButton.RemoveAndBandClick(this.node, this.OnClickThis, this);
|
||||
|
||||
Reference in New Issue
Block a user