cde0e608-3a09-4f9a-bc95-9aee3115c34f.js
6.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
"use strict";
cc._RF.push(module, 'cde0eYIOglPmryVmu4xFcNP', 'DatingSceneViewImpl');
// script/game/ui/view/impl/dating/DatingSceneViewImpl.ts
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatingSceneViewImpl = void 0;
const CCViewBase_1 = require("../../../../../common/classbase/CCViewBase");
const DatingSceneView_1 = require("../../type/DatingSceneView");
const PresenterCCViewFactory_1 = require("../../../PresenterCCViewFactory");
const CCDummyObjects_1 = require("../../../../../common/CCDummyObjects");
const ResUtils_1 = require("../../../../../common/utils/ResUtils");
const { ccclass, property } = cc._decorator;
let DatingSceneViewImpl = /** @class */ (() => {
let DatingSceneViewImpl = class DatingSceneViewImpl extends CCViewBase_1.CCView {
constructor() {
super(...arguments);
//#region editor bindings
this.backgroundSprite = CCDummyObjects_1.DummySprite;
this.portraitSprite = CCDummyObjects_1.DummySprite;
this.selfSmallPortrait = CCDummyObjects_1.DummySprite;
this.otherDialogNode = CCDummyObjects_1.DummyNode;
this.selfDialogNode = CCDummyObjects_1.DummyNode;
this.narratorDialogNode = CCDummyObjects_1.DummyNode;
this.backRedDot = CCDummyObjects_1.DummyNode;
this.touchEndHandler = () => {
if (this.completePlotCallback)
this.completePlotCallback();
};
}
closeAction() {
this.backgroundSprite.spriteFrame = undefined;
this.portraitSprite.spriteFrame = undefined;
this.selfSmallPortrait.spriteFrame = undefined;
this.otherDialogNode.active = false;
this.selfDialogNode.active = false;
this.narratorDialogNode.active = false;
this.backRedDot.active = false;
this.close();
}
onEnable() {
this.node.on(cc.Node.EventType.TOUCH_END, this.touchEndHandler, this);
}
onDisable() {
this.node.off(cc.Node.EventType.TOUCH_END, this.touchEndHandler, this);
}
guideBack() {
this.backRedDot.active = true;
}
async setContent(isSelf, text, name, portraitImg, otherPortraitImg) {
let promises = [];
if (!((isSelf && otherPortraitImg) || portraitImg)) { // 防止切换过程中闪
this.portraitSprite.spriteFrame = undefined;
}
if (portraitImg) {
promises.push(ResUtils_1.ResUtils.loadRes(portraitImg, cc.SpriteFrame).then((sf) => {
if (this.node.active) {
if (isSelf) {
this.selfSmallPortrait.spriteFrame = sf;
}
else {
this.portraitSprite.spriteFrame = sf;
}
}
}));
}
if (isSelf && otherPortraitImg) {
promises.push(ResUtils_1.ResUtils.loadRes(otherPortraitImg, cc.SpriteFrame).then((sf) => {
this.portraitSprite.spriteFrame = sf;
}));
}
this.otherDialogNode.active = false;
this.selfDialogNode.active = false;
this.narratorDialogNode.active = false;
if (text) {
if (isSelf) { // 自己
this.selfDialogNode.active = true;
this.selfDialogNode.children[0].getComponent(cc.Label).string = name;
this.selfDialogNode.children[1].getComponent(cc.RichText).string = text;
}
else if (name) { // 别人
this.otherDialogNode.active = true;
this.otherDialogNode.children[0].getComponent(cc.Label).string = name;
this.otherDialogNode.children[1].getComponent(cc.RichText).string = text;
}
else { // 旁白
this.narratorDialogNode.active = true;
this.narratorDialogNode.children[0].getComponent(cc.RichText).string = text;
}
}
try {
await Promise.all(promises);
}
catch (e) {
console.error(e);
}
}
async setBackground(bgImage) {
if (!bgImage) {
this.backgroundSprite.spriteFrame = undefined;
}
else {
try {
let sf = await ResUtils_1.ResUtils.loadRes(bgImage, cc.SpriteFrame);
this.backgroundSprite.spriteFrame = sf;
this.backgroundSprite.node.height = this.node.height;
this.backgroundSprite.node.width = sf.getOriginalSize().width / sf.getOriginalSize().height * this.node.height;
}
catch (e) {
console.error(e);
}
}
}
};
__decorate([
property(cc.Sprite)
], DatingSceneViewImpl.prototype, "backgroundSprite", void 0);
__decorate([
property(cc.Sprite)
], DatingSceneViewImpl.prototype, "portraitSprite", void 0);
__decorate([
property(cc.Sprite)
], DatingSceneViewImpl.prototype, "selfSmallPortrait", void 0);
__decorate([
property(cc.Node)
], DatingSceneViewImpl.prototype, "otherDialogNode", void 0);
__decorate([
property(cc.Node)
], DatingSceneViewImpl.prototype, "selfDialogNode", void 0);
__decorate([
property(cc.Node)
], DatingSceneViewImpl.prototype, "narratorDialogNode", void 0);
__decorate([
property(cc.Node)
], DatingSceneViewImpl.prototype, "backRedDot", void 0);
DatingSceneViewImpl = __decorate([
ccclass,
PresenterCCViewFactory_1.RegView(DatingSceneView_1.DatingSceneViewType, "prefab/ui/DatingSceneView")
], DatingSceneViewImpl);
return DatingSceneViewImpl;
})();
exports.DatingSceneViewImpl = DatingSceneViewImpl;
cc._RF.pop();