4c1e1ec2-e61e-474d-b4e2-9268b8a524a5.js
9.1 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
"use strict";
cc._RF.push(module, '4c1e17C5h5HTbTikmi4pSSl', 'ItemIntroductionViewPresenter');
// script/game/ui/presenter/ItemIntroductionViewPresenter.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_cc_resutils_1 = require("simba-cc-resutils");
const simba_config_manager_1 = require("simba-config-manager");
const simba_sdk_1 = require("simba-sdk");
const PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const GameConstData_1 = require("../../../common/gameplay/gamedata/GameConstData");
const UIManager_1 = require("../../../common/gameplay/managers/UIManager");
const ItemTbl_1 = require("../../../config/ItemTbl");
const GameConfig_1 = require("../../../GameConfig");
const GameDotMgr_1 = require("../../GameDotMgr");
const GameModelManager_1 = require("../../model/GameModelManager");
const UnlockItemModelManager_1 = require("../../model/UnlockItemModelManager");
const UnlockSpecialPlotEventManager_1 = require("../../model/UnlockSpecialPlotEventManager");
const UnlockSpecialPlotModelManager_1 = require("../../model/UnlockSpecialPlotModelManager");
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const ItemIntroductionView_1 = require("../view/type/ItemIntroductionView");
const SpecialPlotViewPresenter_1 = require("./SpecialPlotViewPresenter");
let ItemIntroductionViewPresenter = /** @class */ (() => {
let ItemIntroductionViewPresenter = class ItemIntroductionViewPresenter extends PresenterBase_1.Presenter {
constructor() {
super();
this.specialPresenter = undefined;
this.showItemSpr = async (itemId) => {
try {
let cfg = undefined;
if (itemId) {
cfg = simba_config_manager_1.ConfigManager.getConfig(ItemTbl_1.itemTbl, itemId);
if (cfg) {
//如果没有模糊图,那么直接展示简介图
if (cfg.foggy === 0) {
UnlockItemModelManager_1.UnlockItemModelManager.saveUnlockedIntroductionItemIdToGameRecord(itemId);
let path = GameConstData_1.GameConstData.GAME_CONST_ITEM_BIG_SPR_DIR + cfg.type;
let itemSpriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(path, cc.SpriteFrame);
this.view.getItemSpriteNode().spriteFrame = itemSpriteFrame;
}
//如果有模糊图,那么就判断是否已经解锁了清晰的简介图
else {
let unlockedIntroduction = false;
let unlockedIntroductionItems = UnlockItemModelManager_1.UnlockItemModelManager.unlockedIntroductionItems;
for (let i = 0; i < unlockedIntroductionItems.length; i++) {
if (itemId == unlockedIntroductionItems[i]) {
unlockedIntroduction = true;
}
}
if (!unlockedIntroduction) {
let path = GameConstData_1.GameConstData.GAME_CONST_ITEM_BIG_SPR_DIR + cfg.foggyPicture;
let itemSpriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(path, cc.SpriteFrame);
this.view.getItemSpriteNode().spriteFrame = itemSpriteFrame;
}
else {
UnlockItemModelManager_1.UnlockItemModelManager.saveUnlockedIntroductionItemIdToGameRecord(itemId);
let path = GameConstData_1.GameConstData.GAME_CONST_ITEM_BIG_SPR_DIR + cfg.type;
let itemSpriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(path, cc.SpriteFrame);
this.view.getItemSpriteNode().spriteFrame = itemSpriteFrame;
}
}
}
}
this.updateSpecialPlotBtnRedDotStatus();
}
catch (error) {
console.error(error);
}
};
this.onSpecialPlotClickCallBack = () => {
let itemCfg = undefined;
itemCfg = simba_config_manager_1.ConfigManager.getConfig(ItemTbl_1.itemTbl, this._viewProps.itemId);
let unlockedSpecialPlots = UnlockSpecialPlotModelManager_1.UnlockSpecialPlotModelManager.unlockedSpecialPlotIdByItemId(this._viewProps.itemId);
if (itemCfg) {
let unlockedSpecialPlot = false;
if (unlockedSpecialPlots.length > 0) {
unlockedSpecialPlot = true;
}
if (unlockedSpecialPlot) {
this.openSpecialPlotView(this._viewProps.itemId, unlockedSpecialPlots);
}
else {
UIManager_1.UIManager.showToast(itemCfg.toastMsg);
return;
}
}
this.view.close();
};
this.onShopBtnClickCallBack = () => {
GameDotMgr_1.default.getInstance().dotClickUI("shop_btn_introduction");
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("该功能在当前平台不可使用");
}
};
}
onOpen(props) {
super.onOpen(props);
this._viewProps = props;
this._viewProps.showItemSpr = this.showItemSpr;
this._viewProps.onSpecialPlotBtnClick = this.onSpecialPlotClickCallBack;
this._viewProps.onShopBtnClick = this.onShopBtnClickCallBack;
this.view.setProps(this._viewProps);
this.onShow();
PresenterBase_1.createPresenter(SpecialPlotViewPresenter_1.default).then((presenter) => {
this.specialPresenter = presenter;
});
}
onShow() {
super.onShow();
this.showItemSpr(this._viewProps.itemId);
}
onEnterBackground() {
super.onEnterBackground();
}
onEnterForeground() {
super.onEnterForeground();
}
onClose() {
super.onClose();
}
openSpecialPlotView(itemId, specialPlotIds) {
if (this.specialPresenter) {
let temp = {
itemId: itemId,
specialPlotIds: specialPlotIds,
onLeftBtnClick: () => { },
onRightBtnClick: () => { },
createGameClubBtn: () => { },
onShopBtnClick: () => { },
onCloseBtnClick: () => { }
};
this.specialPresenter.open(this.view.getContainer(), temp);
}
}
updateSpecialPlotBtnRedDotStatus() {
this.view.showSpecialPlotBtnRedDot(UnlockSpecialPlotEventManager_1.default.getInstance().isShowBedRoomRedDotStatus(this._viewProps.itemId));
}
};
ItemIntroductionViewPresenter.uuid = "ItemIntroductionViewPresenter";
ItemIntroductionViewPresenter = __decorate([
PresenterCCViewFactory_1.RegPresenter(ItemIntroductionView_1.ItemIntroductionViewType)
], ItemIntroductionViewPresenter);
return ItemIntroductionViewPresenter;
})();
exports.default = ItemIntroductionViewPresenter;
cc._RF.pop();