75c442d0-a44a-477f-80a4-2570d6cb45dc.js
8.45 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
"use strict";
cc._RF.push(module, '75c44LQpEpHf4CkJXDWy0Xc', 'SpecialPlotViewPresenter');
// script/game/ui/presenter/SpecialPlotViewPresenter.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 simba_config_manager_1 = require("simba-config-manager");
const simba_sdk_1 = require("simba-sdk");
const PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const UIManager_1 = require("../../../common/gameplay/managers/UIManager");
const StoryTbl_1 = require("../../../config/StoryTbl");
const GameConfig_1 = require("../../../GameConfig");
const GameDotMgr_1 = require("../../GameDotMgr");
const GameModelManager_1 = require("../../model/GameModelManager");
const UnlockSpecialPlotEventManager_1 = require("../../model/UnlockSpecialPlotEventManager");
const UnlockSpecialPlotModelManager_1 = require("../../model/UnlockSpecialPlotModelManager");
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const SpecialPlotView_1 = require("../view/type/SpecialPlotView");
let SpecialPlotViewPresenter = /** @class */ (() => {
let SpecialPlotViewPresenter = class SpecialPlotViewPresenter extends PresenterBase_1.Presenter {
constructor() {
super();
this._value = 0;
this._cfg = undefined;
this.onLeftBtnClickCallBack = () => {
if (this._value <= 0) {
return;
}
else {
this._value -= 1;
this.showSpecialPlot(this._viewProps.specialPlotIds[this._value]);
}
};
this.onRightBtnClickCallBack = () => {
if (this._value >= this._viewProps.specialPlotIds.length - 1) {
UIManager_1.UIManager.showToast(this._cfg.toastMsg);
return;
}
else {
this._value += 1;
this.showSpecialPlot(this._viewProps.specialPlotIds[this._value]);
}
};
this.createGameClubBtn = () => {
this.view.getViewNode().getComponent(cc.Widget).updateAlignment();
let info = simba_sdk_1.SDK.systemInfo.displayInfo;
let aspect = info.windowSize.height / cc.view.getVisibleSize().height;
this.view.getViewNode().getComponent(cc.Widget).updateAlignment();
let pos = this.view.getForumBtnNode().convertToWorldSpaceAR(cc.v2(0, 0));
pos.x += cc.view.getViewportRect().x / cc.view.getScaleX();
let xPos = pos.x * aspect;
let yPos = info.windowSize.height - pos.y * aspect;
let width = this.view.getForumBtnNode().width * aspect;
let height = this.view.getForumBtnNode().height * aspect;
let left = xPos - width / 2;
let top = yPos - height / 2;
simba_sdk_1.SDK.createGameClubButton({
type: "text",
text: "",
style: {
left: left,
top: top,
width: width,
height: height
},
icon: "green"
});
};
this.onShopBtnClickCallBack = () => {
GameDotMgr_1.default.getInstance().dotClickUI("shop_btn_specoalPlot");
let type = GameModelManager_1.GameModelManager.getTypeByBedroomItemId(this._viewProps.itemId);
if (GameConfig_1.channel == "wechat") {
// GameCenter.getInstance().openSubProgram(GameConfig.youZanShopAppId);
if (type) {
let link = GameModelManager_1.GameModelManager.getYouZanShopUrlByType(type);
if (link) {
simba_sdk_1.SDK.openProgramV2(GameConfig_1.GameConfig.youZanShopAppId, link);
}
}
}
else if (GameConfig_1.channel == "android") {
if (type) {
let link = GameModelManager_1.GameModelManager.getTaoBaoShopUrlByType(type);
if (link) {
GameModelManager_1.GameModelManager.jumpToTaobaoShop(link);
}
}
}
else {
UIManager_1.UIManager.showToast("该功能在当前平台不可使用");
}
};
this.onCloseBtnClick = () => {
this.view.close();
GameModelManager_1.GameModelManager.BackToBedRoom.emit();
};
}
onOpen(props) {
super.onOpen(props);
this._viewProps = props;
this._viewProps.onLeftBtnClick = this.onLeftBtnClickCallBack;
this._viewProps.onRightBtnClick = this.onRightBtnClickCallBack;
this._viewProps.createGameClubBtn = this.createGameClubBtn;
this._viewProps.onShopBtnClick = this.onShopBtnClickCallBack;
this._viewProps.onCloseBtnClick = this.onCloseBtnClick;
this.view.setProps(this._viewProps);
this.onShow();
}
onShow() {
super.onShow();
this.showSpecialPlot(this._viewProps.specialPlotIds[this._value]);
this.createGameClubBtn();
this.showGameClubBtn();
}
onClose() {
super.onClose();
simba_sdk_1.SDK.destroyGameClubButton();
}
onEnterBackground() {
super.onEnterBackground();
this.hideGameClubBtn();
}
onEnterForeground() {
super.onEnterForeground();
this.showGameClubBtn();
}
showGameClubBtn() {
simba_sdk_1.SDK.showGameClubButton();
}
hideGameClubBtn() {
simba_sdk_1.SDK.hideGameClubButton();
}
showSpecialPlot(specialPlotId) {
try {
if (specialPlotId) {
this._cfg = simba_config_manager_1.ConfigManager.getConfig(StoryTbl_1.storyTbl, specialPlotId);
if (this._cfg) {
this.view.getSpecialPlotTitleNode().getComponent(cc.Label).string = this._cfg.title;
let cfgStr = this._cfg.content.split("%%");
let specialPlotNodeStr = "";
for (let i = 0; i < cfgStr.length; i++) {
specialPlotNodeStr = specialPlotNodeStr + cfgStr[i] + "\n";
}
this.view.getSpecialPlotNode().getComponent(cc.Label).string = specialPlotNodeStr;
UnlockSpecialPlotModelManager_1.UnlockSpecialPlotModelManager.saveClickedSpecialPlotIdByItemIdToGameRecord(specialPlotId);
}
this.updateLeftOrRightBtnStatus();
this.updateRightBtnRedDotStatus();
this.view.getSpecialPlotScrollView().scrollToTop();
}
}
catch (error) {
console.error(error);
}
}
updateLeftOrRightBtnStatus() {
//处理左按钮显隐,右按钮暂不处理
if (this._value <= 0) {
this.view.showLeftBtn(false);
}
else {
this.view.showLeftBtn(true);
}
}
updateRightBtnRedDotStatus() {
this.view.showRedDot(UnlockSpecialPlotEventManager_1.default.getInstance().isShowBedRoomRedDotStatus(this._viewProps.itemId));
}
};
SpecialPlotViewPresenter.uuid = "SpecialPlotViewPresenter";
SpecialPlotViewPresenter = __decorate([
PresenterCCViewFactory_1.RegPresenter(SpecialPlotView_1.SpecialPlotViewType)
], SpecialPlotViewPresenter);
return SpecialPlotViewPresenter;
})();
exports.default = SpecialPlotViewPresenter;
cc._RF.pop();