Merge branch 'main' of 47.107.44.202:xionglijia/18xchat
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
resources,
|
||||
BufferAsset,
|
||||
assetManager,
|
||||
AssetManager,
|
||||
} from "cc";
|
||||
import { resources, BufferAsset, assetManager, AssetManager } from "cc";
|
||||
import * as cfg from "../../schema/schema";
|
||||
import ByteBuf from "db://assets/Scripts/luban/ByteBuf";
|
||||
import { BaseConfig } from "../config/BaseConfig";
|
||||
@@ -18,12 +13,12 @@ import { AiCharacterConfig } from "../config/AiCharacterConfig";
|
||||
* 集中定义数据ID,避免写错字符串
|
||||
*/
|
||||
export enum ConfigId {
|
||||
Theme = "theme", // 主题配置
|
||||
Purchase = "purchase", // 商城配置
|
||||
Global = "global", // 全局配置
|
||||
Girl = "girl", // 技师的简要配置
|
||||
GirlDetail = "girlDetail", // 技师的详细配置
|
||||
AiCharacter = "aiCharacter", // 技师的详细配置
|
||||
Theme = "theme", // 主题配置
|
||||
Purchase = "purchase", // 商城配置
|
||||
Global = "global", // 全局配置
|
||||
Girl = "girl", // 技师的简要配置
|
||||
GirlDetail = "girlDetail", // 技师的详细配置
|
||||
AiCharacter = "aiCharacter", // 技师的详细配置
|
||||
}
|
||||
|
||||
/** 构造器类型 */
|
||||
@@ -43,9 +38,9 @@ export class ConfigManager {
|
||||
public static jsonFileNames: string[] = [];
|
||||
|
||||
// 数据实例缓存
|
||||
private _dataMap: Map<string, BaseConfig> = new Map();
|
||||
private _dataMap: Map<string, BaseConfig> = new Map();
|
||||
// 数据ID到构造器的映射
|
||||
private _config: Map<string, DataCtor> = new Map();
|
||||
private _config: Map<string, DataCtor> = new Map();
|
||||
|
||||
private constructor() {}
|
||||
|
||||
@@ -100,9 +95,6 @@ export class ConfigManager {
|
||||
Promise.all(promises).then((values) => {
|
||||
console.log("静态配置加载完成");
|
||||
ConfigManager.tables = new cfg.Tables(ConfigManager.I.getFileData);
|
||||
for (let item of ConfigManager.tables.TbGirls.getDataList()) {
|
||||
console.log(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
private getFileData(fileName: string): ByteBuf {
|
||||
@@ -129,17 +121,24 @@ export class ConfigManager {
|
||||
/**
|
||||
* 注册一个数据ID及其对应的构造器
|
||||
*/
|
||||
private register<T extends BaseConfig>(configId: string, ctor: DataCtor<T>): void {
|
||||
private register<T extends BaseConfig>(
|
||||
configId: string,
|
||||
ctor: DataCtor<T>
|
||||
): void {
|
||||
if (this._config.has(configId)) {
|
||||
console.warn(`[ConfigManager] 重复注册数据ID: ${configId},将覆盖旧构造器`);
|
||||
console.warn(
|
||||
`[ConfigManager] 重复注册数据ID: ${configId},将覆盖旧构造器`
|
||||
);
|
||||
}
|
||||
this._config.set(configId, ctor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据(已存在则直接返回;否则按配置自动实例化并缓存)
|
||||
*/
|
||||
public getDataById<T extends BaseConfig = BaseConfig>(configId: string): T | null {
|
||||
public getDataById<T extends BaseConfig = BaseConfig>(
|
||||
configId: string
|
||||
): T | null {
|
||||
// 先从缓存取
|
||||
const cached = this._dataMap.get(configId) as T | undefined;
|
||||
if (cached) return cached;
|
||||
@@ -157,7 +156,7 @@ export class ConfigManager {
|
||||
instance.init?.(configId);
|
||||
this._dataMap.set(configId, instance);
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除数据
|
||||
|
||||
@@ -41,8 +41,8 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
||||
@property(Label)
|
||||
girlName: Label = null;
|
||||
|
||||
@property(Sprite)
|
||||
girlImg: Sprite = null;
|
||||
// @property(Sprite)
|
||||
// girlImg: Sprite = null;
|
||||
|
||||
@property(VideoPlayer)
|
||||
girlVideo: VideoPlayer = null;
|
||||
@@ -188,19 +188,19 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
||||
|
||||
this.nameKey = data.nameKey;
|
||||
this.girlName.string = LanguageUtils.getText(data.nameKey);
|
||||
ResManager.I.changeBundleSpriteFrame(
|
||||
this.girlImg,
|
||||
data.avatarPath,
|
||||
"Chat18x",
|
||||
() => {
|
||||
let sizeTran = this.girlImg.node.parent.getComponent(UITransform);
|
||||
Utils.adjustBgPixelRatioToSize(
|
||||
sizeTran.contentSize,
|
||||
this.girlImg.node,
|
||||
2
|
||||
);
|
||||
}
|
||||
);
|
||||
// ResManager.I.changeBundleSpriteFrame(
|
||||
// this.girlImg,
|
||||
// data.avatarPath,
|
||||
// "Girls",
|
||||
// () => {
|
||||
// let sizeTran = this.girlImg.node.parent.getComponent(UITransform);
|
||||
// Utils.adjustBgPixelRatioToSize(
|
||||
// sizeTran.contentSize,
|
||||
// this.girlImg.node,
|
||||
// 2
|
||||
// );
|
||||
// }
|
||||
// );
|
||||
|
||||
// 通过ChatController获取商业视频数据
|
||||
const chatModel = this.chatController.getChatModel();
|
||||
@@ -238,7 +238,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
||||
ResManager.I.changeBundleVideo(
|
||||
this.girlVideo,
|
||||
initialVideo.path,
|
||||
"Chat18x"
|
||||
"Girls"
|
||||
);
|
||||
// Also immediately try to adjust scale (in case already loaded)
|
||||
this.adjustVideoScale();
|
||||
@@ -335,7 +335,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
||||
ResManager.I.changeBundleVideo(
|
||||
this.girlVideo,
|
||||
matchingVideo.path,
|
||||
"Chat18x"
|
||||
"Girls"
|
||||
);
|
||||
|
||||
// Update current emotion state
|
||||
@@ -401,7 +401,6 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
||||
}
|
||||
protected onEnable(): void {
|
||||
if (!this.manager) this.manager = DialogManager.getInstance();
|
||||
|
||||
}
|
||||
|
||||
public async OnClickSend() {
|
||||
@@ -451,7 +450,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
||||
console.error("Chat error:", error);
|
||||
// 出错时加载动画会被自动移除,可以在这里显示错误提示给用户
|
||||
}
|
||||
|
||||
|
||||
onChatLimitReached(): void {
|
||||
this.payToTalkPanel.show();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import { SimpleToggle } from "../components/SimpleToggle";
|
||||
import { DataManager, DataId } from "../../data/DataManager";
|
||||
import { GirlData } from "../../data/GirlData";
|
||||
import { GirlService } from "db://assets/Scripts/chat18x/network/services/GirlService";
|
||||
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -76,6 +76,7 @@ export class GirlDetailPanel extends li_BaseView {
|
||||
desc += tags[i];
|
||||
}
|
||||
this.tags.string = desc;
|
||||
this.desc.string = LanguageUtils.getText(this.descKey);
|
||||
});
|
||||
|
||||
this.imgToggle.callback = this.bindImgToggle.bind(this);
|
||||
@@ -134,6 +135,7 @@ export class GirlDetailPanel extends li_BaseView {
|
||||
}
|
||||
nameKey: string;
|
||||
tagKey: string;
|
||||
descKey: string;
|
||||
category: number;
|
||||
async refresh(index: number) {
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
@@ -148,14 +150,15 @@ export class GirlDetailPanel extends li_BaseView {
|
||||
girlData.setGirlDetailData(this.category.toString(), res.data);
|
||||
// 根据数据,刷新界面
|
||||
this.nameKey = girlData.getGrilName(this.category.toString(), this.id);
|
||||
this.girlName.string = LanguageUtils.getText(this.nameKey);
|
||||
this.desc.string = girlData.getGrilDesc(this.category.toString(), this.id);
|
||||
this.girlName.string = LanguageUtils.getText(this.nameKey);
|
||||
this.descKey = girlData.getGrilDesc(this.category.toString(), this.id);
|
||||
this.desc.string = LanguageUtils.getText(this.descKey);
|
||||
|
||||
let desc = "";
|
||||
this.tagKey = girlData.getGrilTagKey(this.category.toString(), this.id);
|
||||
const tags = LanguageUtils.getText(this.tagKey).split("|");
|
||||
for (let i = 0; i < tags.length; i++) {
|
||||
if (i != 0) desc += "|";
|
||||
if (i != 0) desc += "\n";
|
||||
desc += tags[i];
|
||||
}
|
||||
this.tags.string = desc;
|
||||
@@ -165,38 +168,61 @@ export class GirlDetailPanel extends li_BaseView {
|
||||
let age = girlData.getGrilAge(this.category.toString(), this.id);
|
||||
this.descAge.string =
|
||||
LanguageUtils.getText("girldetailpanel.age") + age.toString();
|
||||
|
||||
const firstPath = girlData.getFirstGrilVideoPath(this.category.toString(), this.id);
|
||||
ResManager.I.changeBundleVideo(
|
||||
this.avatarVideo,
|
||||
firstPath,
|
||||
"Chat18x"
|
||||
);
|
||||
|
||||
let resIds = girlData.getAllDisplayGrilPhotoId(this.category.toString(), this.id);
|
||||
const firstPath = girlData.getFirstGrilVideoPath(
|
||||
this.category.toString(),
|
||||
this.id
|
||||
);
|
||||
ResManager.I.changeBundleVideo(this.avatarVideo, firstPath, "Girls");
|
||||
|
||||
let resIds = girlData.getAllDisplayGrilPhotoId(
|
||||
this.category.toString(),
|
||||
this.id
|
||||
);
|
||||
// 也立即尝试调整(以防已经加载完成)
|
||||
this.adjustVideoScale();
|
||||
this.refreshImgs(proto.cs.EnmResType.ERT_Image, this.category, this.id, resIds);
|
||||
}
|
||||
this.refreshImgs(
|
||||
proto.cs.EnmResType.ERT_Image,
|
||||
this.category,
|
||||
this.id,
|
||||
resIds
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
bindImgToggle() {
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
let resIds = girlData.getAllDisplayGrilPhotoId(this.category.toString(), this.id);
|
||||
this.refreshImgs(proto.cs.EnmResType.ERT_Image, this.category, this.id, resIds);
|
||||
let resIds = girlData.getAllDisplayGrilPhotoId(
|
||||
this.category.toString(),
|
||||
this.id
|
||||
);
|
||||
this.refreshImgs(
|
||||
proto.cs.EnmResType.ERT_Image,
|
||||
this.category,
|
||||
this.id,
|
||||
resIds
|
||||
);
|
||||
}
|
||||
|
||||
bindVideoToggle() {
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
let resIds = girlData.getAllDisplayGrilVideoId(this.category.toString(), this.id);
|
||||
this.refreshImgs(proto.cs.EnmResType.ERT_Video, this.category, this.id, resIds);
|
||||
let resIds = girlData.getAllDisplayGrilVideoId(
|
||||
this.category.toString(),
|
||||
this.id
|
||||
);
|
||||
this.refreshImgs(
|
||||
proto.cs.EnmResType.ERT_Video,
|
||||
this.category,
|
||||
this.id,
|
||||
resIds
|
||||
);
|
||||
}
|
||||
|
||||
refreshImgs(
|
||||
type: proto.cs.EnmResType,
|
||||
category: number,
|
||||
id: number,
|
||||
resIds: number[]
|
||||
resIds: number[]
|
||||
) {
|
||||
for (let i = this.imgsLayout.children.length - 1; i >= 0; i--) {
|
||||
this.imgsLayout.children[i].destroy();
|
||||
|
||||
@@ -66,11 +66,11 @@ export class ShowPanel extends li_BaseView {
|
||||
|
||||
show(path: string) {
|
||||
if (this.isImg) {
|
||||
ResManager.I.changeBundleSpriteFrame(this.image, path, "Chat18x", () => {
|
||||
ResManager.I.changeBundleSpriteFrame(this.image, path, "Girls", () => {
|
||||
Utils.adjustBgPixelRatio(this.image.node, 3);
|
||||
});
|
||||
} else {
|
||||
ResManager.I.changeBundleVideo(this.videoPlayer, path, "Chat18x", () => {
|
||||
ResManager.I.changeBundleVideo(this.videoPlayer, path, "Girls", () => {
|
||||
this.adjustVideoScale();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -46,11 +46,12 @@ export class DetailImageItem extends Component {
|
||||
resId: number;
|
||||
type: proto.cs.EnmResType;
|
||||
|
||||
test_resID: Node;
|
||||
onLoad() {
|
||||
GButton.BandClick(this.node, this.onClickThis, this);
|
||||
this.uitransform = this.node.getComponent(UITransform);
|
||||
}
|
||||
|
||||
isVisible: boolean;
|
||||
onClickThis() {
|
||||
let data = {
|
||||
url: this.url,
|
||||
@@ -63,15 +64,8 @@ export class DetailImageItem extends Component {
|
||||
// 数据
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
// 是否可见,不可见代表需要解锁
|
||||
let isVisible = false;
|
||||
if (this.type === proto.cs.EnmResType.ERT_Image) {
|
||||
// 图片
|
||||
isVisible = girlData.isGirlPhotoVisible(this.category.toString(), this.girlId, this.resId);
|
||||
} else if (this.type === proto.cs.EnmResType.ERT_Video) {
|
||||
// 视频
|
||||
isVisible = girlData.isGirlVideoVisible(this.category.toString(), this.girlId, this.resId);
|
||||
}
|
||||
if (isVisible) {
|
||||
|
||||
if (this.isVisible) {
|
||||
if (this.url) {
|
||||
ViewManager.I.openBundlesView("ShowPanel", data);
|
||||
this.base.setVideEnable(false);
|
||||
@@ -149,51 +143,70 @@ export class DetailImageItem extends Component {
|
||||
this.resId = resId;
|
||||
this.question.active = true; // 显示问号,表示加载中
|
||||
|
||||
this.test_resID = this.node.getChildByName("resID");
|
||||
|
||||
this.test_resID.getComponent(Label).string =
|
||||
this.girlId.toString() + this.resId;
|
||||
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
let imgPath = "";
|
||||
this.video.enabled = type === proto.cs.EnmResType.ERT_Video;
|
||||
this.priceFrame.active = type === proto.cs.EnmResType.ERT_Video;
|
||||
let price = 0;
|
||||
// 是否可见,不可见代表需要解锁
|
||||
let isVisible = false;
|
||||
if (this.type === proto.cs.EnmResType.ERT_Image) {
|
||||
// 图片
|
||||
this.isVisible = girlData.isGirlPhotoVisible(
|
||||
this.category.toString(),
|
||||
this.girlId,
|
||||
this.resId
|
||||
);
|
||||
} else if (this.type === proto.cs.EnmResType.ERT_Video) {
|
||||
// 视频
|
||||
this.isVisible = girlData.isGirlVideoVisible(
|
||||
this.category.toString(),
|
||||
this.girlId,
|
||||
this.resId
|
||||
);
|
||||
}
|
||||
if (type === proto.cs.EnmResType.ERT_Image) {
|
||||
// 图片
|
||||
price = girlData.getGrilPhotoOriginalPrice(this.category.toString(), this.girlId, this.resId);
|
||||
price = girlData.getGrilPhotoOriginalPrice(
|
||||
this.category.toString(),
|
||||
this.girlId,
|
||||
this.resId
|
||||
);
|
||||
this.url = girlData.getGrilPhotoPic(
|
||||
this.category.toString(),
|
||||
this.girlId,
|
||||
this.resId
|
||||
);
|
||||
imgPath = this.url;
|
||||
this.isImage = true;
|
||||
isVisible = girlData.isGirlPhotoVisible(this.category.toString(), this.girlId, this.resId);
|
||||
} else if (type === proto.cs.EnmResType.ERT_Video) {
|
||||
// 视频
|
||||
price = girlData.getGrilVideoOriginalPrice(this.category.toString(), this.girlId, this.resId);
|
||||
price = girlData.getGrilVideoOriginalPrice(
|
||||
this.category.toString(),
|
||||
this.girlId,
|
||||
this.resId
|
||||
);
|
||||
this.isImage = false;
|
||||
this.url = girlData.getGrilVideoPath(
|
||||
this.category.toString(),
|
||||
this.girlId,
|
||||
this.resId
|
||||
);
|
||||
this.url = girlData.getGrilVideoPath(
|
||||
this.category.toString(),
|
||||
this.girlId,
|
||||
this.resId
|
||||
);
|
||||
|
||||
isVisible = girlData.isGirlVideoVisible(this.category.toString(), this.girlId, this.resId);
|
||||
if (isVisible) {
|
||||
imgPath = this.url + "_thumbnail_blur";
|
||||
} else {
|
||||
imgPath = this.url + "_thumbnail";
|
||||
}
|
||||
this.priceFrame.active = price > 0;
|
||||
|
||||
this.videoPrice.string = price.toString();
|
||||
}
|
||||
|
||||
ResManager.I.changeBundleSpriteFrame(this.img, imgPath, "Chat18x", () => {
|
||||
if (this.isVisible) {
|
||||
imgPath = this.url + "_thumbnail";
|
||||
} else {
|
||||
imgPath = this.url + "_thumbnail_blur";
|
||||
}
|
||||
this.priceFrame.active = price > 0;
|
||||
|
||||
this.videoPrice.string = price.toString();
|
||||
|
||||
ResManager.I.changeBundleSpriteFrame(this.img, imgPath, "Girls", () => {
|
||||
this.question.active = false; // 图片加载成功后隐藏问号
|
||||
this.scaleToFillItem();
|
||||
});
|
||||
@@ -202,7 +215,7 @@ export class DetailImageItem extends Component {
|
||||
refreshVideoBuy(success: boolean) {
|
||||
if (success) {
|
||||
const imgPath = this.url + "_thumbnail";
|
||||
ResManager.I.changeBundleSpriteFrame(this.img, imgPath, "Chat18x", () => {
|
||||
ResManager.I.changeBundleSpriteFrame(this.img, imgPath, "Girls", () => {
|
||||
this.question.active = false; // 图片加载成功后隐藏问号
|
||||
this.scaleToFillItem();
|
||||
});
|
||||
|
||||
@@ -107,24 +107,23 @@ export class GirlListItem extends Component {
|
||||
this.id
|
||||
);
|
||||
|
||||
if(isRelease)
|
||||
{
|
||||
if (isRelease) {
|
||||
this.price.node.active = false;
|
||||
this.freeNode.active =false;
|
||||
this.freeNode.active = false;
|
||||
this.starParent.active = true;
|
||||
this.chatIcon.active = true;
|
||||
this.unreleaseCover.active = false;
|
||||
}else{
|
||||
} else {
|
||||
this.unreleaseCover.active = true;
|
||||
this.chatIcon.active = false;
|
||||
this.starParent.active = false;
|
||||
if(priceType == PriceType.free)
|
||||
{
|
||||
this.price.node.active = false;
|
||||
this.freeNode.active = true;
|
||||
}else{
|
||||
if (priceType == PriceType.free) {
|
||||
this.price.node.active = false;
|
||||
this.freeNode.active = true;
|
||||
this.starParent.active = true;
|
||||
} else {
|
||||
this.price.node.active = true;
|
||||
this.freeNode.active = false;
|
||||
this.starParent.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +134,8 @@ export class GirlListItem extends Component {
|
||||
this.category.toString(),
|
||||
this.id
|
||||
);
|
||||
|
||||
listAvatarPath = listAvatarPath.replace("Avatar","avatar");//临时
|
||||
|
||||
listAvatarPath = listAvatarPath.replace("Avatar", "avatar"); //临时
|
||||
ResManager.I.changeBundleSpriteFrame(
|
||||
this.avatar,
|
||||
listAvatarPath,
|
||||
@@ -152,13 +151,13 @@ export class GirlListItem extends Component {
|
||||
);
|
||||
|
||||
//虚假好感度
|
||||
const ratio = randomRangeInt(0, 5);
|
||||
const star = girlData.getStar(this.category.toString(), this.id);
|
||||
// this.starParent.active = ratio != 0;
|
||||
// this.chatIcon.active = ratio != 0;
|
||||
// this.price.node.active = ratio == 0;
|
||||
for (let i = 0; i < this.stars.length; i++) {
|
||||
const element = this.stars[i];
|
||||
if (ratio > i) {
|
||||
if (star > i) {
|
||||
ResManager.I.changeResourceSpriteFrame(element, "ui/common/heart");
|
||||
} else {
|
||||
ResManager.I.changeResourceSpriteFrame(
|
||||
|
||||
Reference in New Issue
Block a user