a21abc61-863d-4b61-9f90-995f04a35c25.js
5.35 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
"use strict";
cc._RF.push(module, 'a21abxhhj1LYZ+QmV8Eo1wl', 'SentenceSelectorViewImpl');
// script/game/ui/view/impl/message/SentenceSelectorViewImpl.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 });
const CCDummyObjects_1 = require("../../../../../common/CCDummyObjects");
const PlotModel_1 = require("../../../../../avg/model/PlotModel");
const RichTextUtils_1 = require("../../../../../avg/utils/RichTextUtils");
const PresenterCCViewFactory_1 = require("../../../PresenterCCViewFactory");
const SentenceSelectorView_1 = require("../../type/SentenceSelectorView");
const CCViewBase_1 = require("../../../../../common/classbase/CCViewBase");
const ResUtils_1 = require("../../../../../common/utils/ResUtils");
const { ccclass, property } = cc._decorator;
let SentenceSelectorViewImpl = /** @class */ (() => {
let SentenceSelectorViewImpl = class SentenceSelectorViewImpl extends CCViewBase_1.CCPureView {
constructor() {
super(...arguments);
//#region
this.background = CCDummyObjects_1.DummySprite;
this.contentLayout = CCDummyObjects_1.DummyLayout;
this.selectButtonTemplate = CCDummyObjects_1.DummyNode;
this.selectButtonTemplate1 = CCDummyObjects_1.DummyNode;
//#endregion
this.onButtonClick = (index) => {
return () => {
this._props.onSelectIndexCallback(index);
};
};
this.setContent = (content) => {
this.contentLayout.node.removeAllChildren();
for (let i = 0; i < content.value.length; i++) {
let option = content.value[i];
let node = cc.instantiate(this._props.optionStyle1 ? this.selectButtonTemplate1 : this.selectButtonTemplate);
node.parent = this.contentLayout.node;
node.active = true;
let label = node.getChildByName("Label").getComponent(cc.RichText);
if (option.content && option.content.type === PlotModel_1.SentenceType.TEXT && !option.summary) {
label.string = RichTextUtils_1.richNodesToCocosString(option.content.value);
}
else {
label.string = option.summary;
}
node.on("click", this.onButtonClick(i));
}
};
}
open(parent) {
super.open(parent);
this.background.node.opacity = 0;
}
onPropsReceive() {
super.onPropsReceive();
this.background.node.opacity = 255;
}
onLoad() {
this.bindProp("sentence", async (value) => {
if (value != null)
this.setContent(value);
});
this.bindProp("backgroundpath", async (value) => {
if (value != "") {
this.background.spriteFrame = await ResUtils_1.ResUtils.loadRes(value, cc.SpriteFrame);
}
else {
this.background.spriteFrame = undefined;
}
});
this.bindProp("y", (v) => {
if (v === undefined) {
this.background.getComponent(cc.Widget).enabled = true;
this.background.node.y = -this.node.height / 2;
}
else {
this.background.getComponent(cc.Widget).enabled = false;
this.background.node.y = v;
}
});
}
onPropsLoad(props) {
super.onPropsLoad(props);
if (this._props.clickcausehide) {
this.node.on(cc.Node.EventType.TOUCH_END, this.onCloseHandleClick, this);
}
else {
this.node.off(cc.Node.EventType.TOUCH_END);
}
}
onCloseHandleClick(event) {
this.close();
}
onPropChange(key) {
super.onPropChange(key);
}
};
__decorate([
property(cc.Sprite)
], SentenceSelectorViewImpl.prototype, "background", void 0);
__decorate([
property(cc.Layout)
], SentenceSelectorViewImpl.prototype, "contentLayout", void 0);
__decorate([
property(cc.Node)
], SentenceSelectorViewImpl.prototype, "selectButtonTemplate", void 0);
__decorate([
property(cc.Node)
], SentenceSelectorViewImpl.prototype, "selectButtonTemplate1", void 0);
SentenceSelectorViewImpl = __decorate([
ccclass,
PresenterCCViewFactory_1.RegView(SentenceSelectorView_1.SentenceSelectorViewType, "prefab/ui/SentenceSelectorView")
], SentenceSelectorViewImpl);
return SentenceSelectorViewImpl;
})();
exports.default = SentenceSelectorViewImpl;
cc._RF.pop();