6bc4c8b1-0f3e-4663-84cd-3d5670f40a40.js 29.7 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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634
"use strict";
cc._RF.push(module, '6bc4cixDz5GY4TNPVZw9ApA', 'DatingEventViewPresenter');
// script/game/ui/presenter/DatingEventViewPresenter.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.DatingEventSubpresenter = void 0;
const simba_cc_resutils_1 = require("simba-cc-resutils");
const simba_config_manager_1 = require("simba-config-manager");
const AVG_1 = require("../../../avg/AVG");
const EditorEnums_1 = require("../../../avg/EditorEnums");
const PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const GameTextData_1 = require("../../../common/gameplay/gamedata/GameTextData");
const UIManager_1 = require("../../../common/gameplay/managers/UIManager");
const StringUtils_1 = require("../../../common/utils/StringUtils");
const DateSceneConfig_1 = require("../../../config/DateSceneConfig");
const GameConfig_1 = require("../../../GameConfig");
const Enums_1 = require("../../Enums");
const GameDotMgr_1 = require("../../GameDotMgr");
const CDKeyEventManager_1 = require("../../model/CDKeyEventManager");
const DatingEventSceneModel_1 = require("../../model/DatingEventSceneModel");
const ExtraStoryModelManager_1 = require("../../model/ExtraStoryModelManager");
const GameModelManager_1 = require("../../model/GameModelManager");
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const SectionBtn_1 = require("../SectionBtn");
const DatingEventSubview_1 = require("../view/type/DatingEventSubview");
const DatingEventView_1 = require("../view/type/DatingEventView");
const AlertDialogViewPresenter_1 = require("./AlertDialogViewPresenter");
const DatingScenePresenter_1 = require("./DatingScenePresenter");
const GuideViewPresenter_1 = require("./GuideViewPresenter");
let DatingEventViewPresenter = /** @class */ (() => {
    let DatingEventViewPresenter = class DatingEventViewPresenter extends PresenterBase_1.Presenter {
        constructor() {
            super();
            this.onShowDatingEventArrowGuide = (isShow, wordPos) => {
                this.view.showArrowGuide(isShow, wordPos);
            };
            this._viewProps = {};
        }
        onOpen() {
            super.onOpen(undefined);
            this._disposable.add(GameModelManager_1.GameModelManager.ShowDatingEventArrowGuide.on(this.onShowDatingEventArrowGuide));
            this.onShow();
        }
        onEnterForeground() {
            super.onEnterForeground();
        }
        onShow() {
            super.onShow();
            this.view.setProps(this._viewProps);
            if (GameConfig_1.GameConfig.debug) {
                this.view.showRoleLikeLabel();
                this.view.showMaskLabel();
            }
        }
        onClose() {
            super.onClose();
        }
    };
    DatingEventViewPresenter.uuid = "DatingEventViewPresenter";
    DatingEventViewPresenter = __decorate([
        PresenterCCViewFactory_1.RegPresenter(DatingEventView_1.DatingEventViewType)
    ], DatingEventViewPresenter);
    return DatingEventViewPresenter;
})();
exports.default = DatingEventViewPresenter;
let DatingEventSubpresenter = /** @class */ (() => {
    let DatingEventSubpresenter = class DatingEventSubpresenter extends PresenterBase_1.Subpresenter {
        constructor() {
            super(...arguments);
            // private _items: DatingEventItemProps[];
            this._lineStyle = 0;
            this._modelMap = {};
            this._dailySceneNum = -1;
            this._curChapterIndex = 1;
            this._maxChapterIndex = 1;
            this._maxChapterIsChange = false;
            this._isStartBranches = false;
            this._clickKey = "";
            this.onScrollBegin = () => {
                GameModelManager_1.GameModelManager.ShowDatingEventArrowGuide.emit(false);
            };
            this.onScrollEnd = () => {
                this.refreshArrowGuide();
            };
            this.onItemAdModeClick = (key) => {
                GameModelManager_1.GameModelManager.setGuideEventItemRecord(key, Enums_1.GuideState.Complete);
                let m = this._modelMap[key];
                let hasRecord = this.checkIsSceneHasAdRecord(m.id);
                CDKeyEventManager_1.default.getInstance().shiftCDKeyRemovePlotAD();
                let removeAdCardNum = CDKeyEventManager_1.default.getInstance().checkCDKeyRemovePlotAD();
                if (m.status !== DatingEventSceneModel_1.DatingEventStatus.Completed) {
                    GameDotMgr_1.default.getInstance().dotClickUI("click_date_card" + m.config.id);
                }
                let showAdAlert = !(removeAdCardNum > 0) && !hasRecord && m.config.ads === 1 && m.status == DatingEventSceneModel_1.DatingEventStatus.New;
                if (showAdAlert) {
                    let temp = {
                        dataptr: { key },
                        titlecontent: GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.GAME_TEXT_WAIT_VALUE),
                        content: GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.GAME_TEXT_SHOW_AD_UNLOCK_DATE_VALUE),
                        ishasad: true,
                        istwobtn: true,
                        adconfig: "inject_fruit",
                        location: Enums_1.CommonLocation.Event,
                        callback: this.showAdCallBack,
                        hasBanner: false,
                        isthreebtn: true
                    };
                    console.log("Push AlertDialogViewPros data end");
                    UIManager_1.UIManager.pushPresenter(AlertDialogViewPresenter_1.default, temp);
                    console.log("pushPresenter=========");
                }
                else {
                    this.enterDatingScene(key);
                }
            };
            this.showAdCallBack = (type, ret, param) => {
                if (ret) {
                    //if (type === "video" || channel == "dummy") {
                    if (true) {
                        let key = param["key"];
                        let m = this._modelMap[key];
                        this.pushSceneAdToRecord(m.id);
                        setTimeout(() => {
                            this.enterDatingScene(key);
                        }, 300);
                    }
                    else {
                        UIManager_1.UIManager.popPresenter();
                        setTimeout(() => {
                            let temp = {
                                dataptr: {},
                                titlecontent: "提示",
                                content: "今天广告君太累了,休息啦~~可以点击去除广告,或者明天再来哦(*•̀ᴗ•́*)و ̑̑",
                                ishasad: false,
                                istwobtn: true,
                                adconfig: "",
                                callback: () => {
                                },
                                hasBanner: false,
                                isadlimit: true
                            };
                            UIManager_1.UIManager.pushPresenter(AlertDialogViewPresenter_1.default, temp);
                        }, 500);
                    }
                }
                else {
                    if (type === "video") {
                        UIManager_1.UIManager.showToast("解锁失败,请完整观看视频,不可点击跳过");
                    }
                }
            };
            this.checkGuideItem = () => {
                let k = GameModelManager_1.GameModelManager.getEventItemGuideKey();
                if (k && "" !== k) {
                    let node = this.view.getItemNode(k);
                    if (node) {
                        let wp = node.convertToWorldSpaceAR(cc.v2(0, 0));
                        let m = {
                            x: wp.x,
                            y: wp.y,
                            w: node.width,
                            h: node.height,
                            d: Enums_1.DirectionType.DOWM,
                            call: () => {
                                this.onItemAdModeClick(k);
                                // this.onItemEnergyCostClick(k);
                                GameModelManager_1.GameModelManager.setGuideEventItemRecord(k, Enums_1.GuideState.Complete);
                            }
                        };
                        UIManager_1.UIManager.pushPresenter(GuideViewPresenter_1.default, m);
                    }
                }
                this.refreshArrowGuide();
            };
            this.onOptionChapter = (stepType) => {
                let tempIndex = stepType === Enums_1.StepType.Add ? this._curChapterIndex + 1 : this._curChapterIndex - 1;
                this._curChapterIndex = tempIndex >= 1 && tempIndex <= this._maxChapterIndex ? tempIndex : this._curChapterIndex;
                this.refreshItems();
            };
            this.costEnergyCallBack = (type, ret, param) => {
                if (ret) {
                    let oprType = this.isReview ? Enums_1.EventOperationType.memory : Enums_1.EventOperationType.event;
                    let location = Enums_1.EventLocation.ClickEnergyCost;
                    let role = GameModelManager_1.GameModelManager.getPlayerData();
                    let key = param["key"];
                    let m = this._modelMap[key];
                    this.pushSceneAdToRecord(m.id);
                    setTimeout(() => {
                        this.enterDatingScene(key);
                    }, 300);
                }
            };
            this.onForceClickItem = (id) => {
                console.log("DatingEventSubpresenter onForceClickItem id = ", id);
                let k = id + "";
                if (!this._modelMap || !this._modelMap[k]) {
                    return;
                }
                this._clickKey = k;
                if (!this._isStartBranches) {
                    this.onItemAdModeClick(k);
                }
                else {
                    //@ts-ignore
                    this.view.schedule(this.checkCanEnterDatingScene, 0.1);
                }
            };
            this.checkCanEnterDatingScene = () => {
                if (!this._isStartBranches) {
                    this.onItemAdModeClick(this._clickKey);
                    //@ts-ignore
                    this.view.unschedule(this.checkCanEnterDatingScene);
                }
            };
            this.onRefreshAllStatus = () => {
                this.selectCurChapter();
                this.onShow();
            };
            this.onCloseDatingSceneView = (eventId) => {
                // this.view.setCurrEventId(eventId);
                let cfg = simba_config_manager_1.ConfigManager.getAllConfig(DateSceneConfig_1.dateSceneConfig);
                for (const id in cfg) {
                    if (cfg[id].id == eventId) {
                        this._curChapterIndex = cfg[id].chapter_index;
                    }
                }
                this.refreshItems();
                this.checkGuideItem();
                this.refreshArrowGuide();
                this.changeButtonState();
                this.checkLastChapterIsOver();
            };
            this.onCloseExtraSceneView = async () => {
                await this.updateExtraPlotButtonRedDot();
            };
            this.onLeftButtonClickCallback = () => {
                GameModelManager_1.GameModelManager.setIsMainPlotSceneType(false);
                if (this._curChapterIndex == 1) {
                    this.view.getLeftButton().node.opacity = 0;
                }
                else {
                    this._curChapterIndex--;
                    this.view.getLeftButton().node.opacity = 255;
                    this.onShow();
                }
            };
            this.onRightButtonClickCallback = () => {
                GameModelManager_1.GameModelManager.setIsMainPlotSceneType(false);
                if (this._curChapterIndex == this._maxChapterIndex) {
                    this.view.getRightButton().node.opacity = 0;
                }
                else {
                    this._curChapterIndex++;
                    this.view.getRightButton().node.opacity = 255;
                    this.onShow();
                }
            };
            this.onNameButtonClickCallback = () => {
                let allChapterInfo = this.getAllChapterInfo();
                // console.log("allChapterInfo", allChapterInfo);
                this.view.getScrollViewRoot().active = true;
                let scrollView = this.view.getScrollViewRoot().getChildByName("ScrollView");
                scrollView.scaleY = 0;
                cc.tween(scrollView)
                    .to(0.2, { scaleY: 1 })
                    .call(() => {
                    this.view.getScrollViewContent().removeAllChildren();
                    for (let i = 0; i < allChapterInfo.length; ++i) {
                        let btn = cc.instantiate(this.view.getSectionBtn());
                        let isCurrChapter = allChapterInfo[i].chapterIndex == this._curChapterIndex;
                        btn.getComponent(SectionBtn_1.default).setData(allChapterInfo[i].chapterIndex, allChapterInfo[i].chapterName, isCurrChapter, () => {
                            this._curChapterIndex = allChapterInfo[i].chapterIndex;
                            this.onShow();
                            this.onCloseSectionViewCallBack();
                        });
                        btn.parent = this.view.getScrollViewContent();
                    }
                })
                    .start();
            };
            this.onCloseSectionViewCallBack = () => {
                this.view.getScrollViewContent().removeAllChildren();
                let scrollView = this.view.getScrollViewRoot().getChildByName("ScrollView");
                cc.tween(scrollView)
                    .to(0.2, { scaleY: 0 })
                    .call(() => {
                    this.view.getScrollViewRoot().active = false;
                })
                    .start();
            };
        }
        sceneModelToViewModel(item, index) {
            this._modelMap[item.id.toString()] = item;
            // let cfg = ConfigManager.getConfig(dateSceneConfig, item.id);
            // let progress = GameModelManager.getDateSceneKeyPlotsProgress(item.id);
            let direct = Enums_1.DatePrefabDirectType.Left;
            if (this._curChapterIndex % 2 === 1) {
                direct = (index + 1) % 2 === 1 ? Enums_1.DatePrefabDirectType.Left : Enums_1.DatePrefabDirectType.Right;
            }
            else {
                direct = (index + 1) % 2 === 0 ? Enums_1.DatePrefabDirectType.Left : Enums_1.DatePrefabDirectType.Right;
            }
            return {
                key: item.id + "",
                title: GameModelManager_1.GameModelManager.getConfigLanguageTxt(item.config.name),
                // date: item.config.date,
                // time: item.config.time,
                status: item.status,
                coverImage: "textures/dating_event/cover/" + item.config.background,
                // lineStyle: this._lineStyle,
                // progress: progress,
                // showItemClear: item.status === DatingEventStatus.Completed && progress === 100,
                // showProgress: item.status === DatingEventStatus.Completed,
                // firstCostNum: cfg.first_energy_cost,
                // reviewCostNum: cfg.memory_energy_cost,
                itype: direct
            };
        }
        refreshItems() {
            let items = [];
            let srcModels = GameModelManager_1.GameModelManager.getMainDatingEventScenesModelByChapterindex(this._curChapterIndex);
            // let srcModels = GameModelManager.getMainDatingEventScenesModel();
            for (let i = srcModels.length - 1; i >= 0; i--) {
                items.push(this.sceneModelToViewModel(srcModels[i], i));
            }
            // if (items.length) {
            //     items[0].lineStyle = "none";
            // }
            //count dailySceneNum from table
            if (this._dailySceneNum == -1) {
                let maxItemsNum = 0;
                let cfg = simba_config_manager_1.ConfigManager.getAllConfig(DateSceneConfig_1.dateSceneConfig);
                for (let id in cfg) {
                    let c = cfg[id];
                    if (c) {
                        maxItemsNum++;
                    }
                }
                this._dailySceneNum = maxItemsNum;
            }
            let showContinue = false;
            if (srcModels.length !== 0) {
                let c = 0;
                let cfgs = simba_config_manager_1.ConfigManager.getAllConfig(DateSceneConfig_1.dateSceneConfig);
                for (let id in cfgs) {
                    let cfg = cfgs[id];
                    if (cfg) {
                        c++;
                    }
                }
                let last = srcModels[srcModels.length - 1];
                showContinue = last.id === c;
            }
            this.view.setProps({
                items,
                onItemClick: this.onItemAdModeClick,
                // onItemClick: this.onItemEnergyCostClick,
                showContinue: showContinue,
                chapterName: this.getChapterName(this._curChapterIndex),
                showLeft: this._curChapterIndex !== 1,
                showRight: this._curChapterIndex !== this._maxChapterIndex,
                showChapterClear: this.checkChapterClear(items, this._curChapterIndex),
                onOptionChapter: this.onOptionChapter,
                chapterIndex: this._curChapterIndex,
                onScrollBegin: this.onScrollBegin,
                onScrollEnd: this.onScrollEnd,
                onLeftButtonClickCallback: this.onLeftButtonClickCallback,
                onRightButtonClickCallback: this.onRightButtonClickCallback,
                onNameButtonClickCallback: this.onNameButtonClickCallback,
                onCloseSectionViewCallBack: this.onCloseSectionViewCallBack
            });
        }
        checkChapterClear(items, chapterIndex) {
            let showClear = true;
            let cfg = simba_config_manager_1.ConfigManager.getAllConfig(DateSceneConfig_1.dateSceneConfig);
            let cnt = 0;
            for (let id in cfg) {
                let c = cfg[id];
                if (c && c.chapter_index === chapterIndex) {
                    cnt++;
                }
            }
            if (cnt !== items.length) {
                return false;
            }
            // for (let i = 0; i < items.length; i++) {
            //     if (items[i].showItemClear === false) {
            //         showClear = false;
            //         break;
            //     }
            // }
            return showClear;
        }
        getChapterName(chapterIndex) {
            chapterIndex -= 1;
            let nameArr = [
                "一", "二", "三", "四", "五", "六", "七", "八", "九", "十",
                "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十"
            ];
            let name = StringUtils_1.StringUtils.format(GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.GAME_TEXT_CHAPTER_NAME), nameArr[chapterIndex]);
            return name;
        }
        checkIsSceneHasAdRecord(id) {
            let ret = false;
            let record = AVG_1.GameRecord.globalVariables["date_ad_arr"];
            if (record) {
                let a = JSON.parse(record);
                let i = a.findIndex((v) => v === id);
                ret = i !== -1;
            }
            return ret;
        }
        pushSceneAdToRecord(id) {
            let record = AVG_1.GameRecord.globalVariables["date_ad_arr"];
            let a = [];
            let isExsit = false;
            if (record) {
                a = JSON.parse(record);
                let i = a.findIndex((v) => v === id);
                if (i >= 0) {
                    isExsit = true;
                }
            }
            if (!isExsit) {
                a.push(id);
                a.reverse();
                AVG_1.GameRecord.globalVariables["date_ad_arr"] = JSON.stringify(a);
                AVG_1.GameRecord.autoSave();
            }
        }
        enterDatingScene(key) {
            GameModelManager_1.GameModelManager.ShowDatingEventArrowGuide.emit(false);
            UIManager_1.UIManager.pushPresenter(DatingScenePresenter_1.DatingScenePresenter, this._modelMap[key], true);
        }
        onOwnerShow() {
            if (!this.view.isHidden) {
                this.selectCurChapter();
                this.refreshMaxChapterIndex();
                this.refreshItems();
                this.refreshArrowGuide();
                this.changeButtonState();
                this.checkLastChapterIsOver();
                this.onCloseSectionViewCallBack();
            }
        }
        onOwnerEnterForeground() {
            if (!this.view.isHidden) {
                this.refreshMaxChapterIndex();
                this.refreshItems();
                this.refreshArrowGuide();
                this.changeButtonState();
                this.checkLastChapterIsOver();
            }
            if (this._maxChapterIsChange) {
                this.selectCurChapter();
            }
        }
        onOpen() {
            super.onOpen();
            this._disposable.add(GameModelManager_1.GameModelManager.CheckDateGuide.on(this.checkGuideItem));
            this._disposable.add(GameModelManager_1.GameModelManager.ForceClickDatingItem.on(this.onForceClickItem));
            this._disposable.add(GameModelManager_1.GameModelManager.RefreshAllStatus.on(this.onRefreshAllStatus));
            this._disposable.add(GameModelManager_1.GameModelManager.CloseDatingSceneView.on(this.onCloseDatingSceneView));
            this._disposable.add(GameModelManager_1.GameModelManager.CloseExtraSceneView.on(this.onCloseExtraSceneView));
            this.selectCurChapter();
            if (!this.view.isHidden) {
                this.refreshMaxChapterIndex();
                this.onShow();
            }
        }
        async onShow() {
            this.refreshMaxChapterIndex();
            this.refreshItems();
            this.checkGuideItem();
            this.refreshArrowGuide();
            this.changeButtonState();
            this.checkLastChapterIsOver();
            await this.updateExtraPlotButtonRedDot();
        }
        onHide() {
        }
        selectCurChapter() {
            let models = GameModelManager_1.GameModelManager.getMainDatingEventScenesModel();
            if (models && models.length) {
                let last = models[models.length - 1];
                this._curChapterIndex = last.config.chapter_index;
                if (this._curChapterIndex !== 1) {
                    GameModelManager_1.GameModelManager.setNotNeedEnterCurDateChapter();
                }
            }
        }
        refreshMaxChapterIndex() {
            let maxChapterIndex = this._maxChapterIndex;
            let arr = GameModelManager_1.GameModelManager.getMainDatingEventScenesModel();
            if (arr && arr.length) {
                let dId = arr[arr.length - 1].id;
                let cfg = simba_config_manager_1.ConfigManager.getConfig(DateSceneConfig_1.dateSceneConfig, dId);
                this._maxChapterIndex = cfg.chapter_index;
            }
            this._maxChapterIsChange = maxChapterIndex == this._maxChapterIndex ? false : true;
        }
        refreshArrowGuide() {
            let srcModels = GameModelManager_1.GameModelManager.getMainDatingEventScenesModelByChapterindex(this._curChapterIndex);
            if (!srcModels || srcModels.length === 0) {
                return;
            }
            let model = srcModels[srcModels.length - 1];
            if (model.status !== DatingEventSceneModel_1.DatingEventStatus.Completed) {
                let key = model.id + "";
                let node = this.view.getItemNode(key);
                if (node) {
                    let wp = node.convertToWorldSpaceAR(cc.v2(0, 0));
                    //世界坐标y是否在屏幕区域内
                    if (wp.y > 120 && wp.y < cc.winSize.height - 200) {
                        GameModelManager_1.GameModelManager.ShowDatingEventArrowGuide.emit(true, cc.v3(wp.x, wp.y, 0));
                    }
                    else {
                        GameModelManager_1.GameModelManager.ShowDatingEventArrowGuide.emit(false);
                    }
                }
            }
            else {
                GameModelManager_1.GameModelManager.ShowDatingEventArrowGuide.emit(false);
            }
        }
        changeButtonState() {
            let nameSprite = this.view.getNameButton().node.getComponent(cc.Sprite);
            nameSprite.scheduleOnce(async () => {
                let spritePath = "textures/main_view/dating/chapterIcon/chapter";
                nameSprite.spriteFrame = await simba_cc_resutils_1.ResUtils.loadRes(spritePath + this._curChapterIndex, cc.SpriteFrame);
                if (this._curChapterIndex == this._maxChapterIndex) {
                    this.view.getRightButton().node.opacity = 0;
                }
                else {
                    this.view.getRightButton().node.opacity = 255;
                }
                if (this._curChapterIndex == 1) {
                    this.view.getLeftButton().node.opacity = 0;
                }
                else {
                    this.view.getLeftButton().node.opacity = 255;
                }
            });
        }
        checkLastChapterIsOver() {
            let isOver = false;
            let arr = GameModelManager_1.GameModelManager.getMainDatingEventScenesModel();
            if (arr && arr.length) {
                let lastChapter = arr[arr.length - 1];
                isOver = lastChapter.status == DatingEventSceneModel_1.DatingEventStatus.Completed ? true : false;
            }
            if (!isOver && this._curChapterIndex !== this._maxChapterIndex) {
                this.view.getRightButton().node.getChildByName("RedDotSprite").active = true;
                this.startButtonAction(this.view.getRightButton().node);
            }
            else {
                this.view.getRightButton().node.getChildByName("RedDotSprite").active = false;
                this.stopButtonAction(this.view.getRightButton().node);
            }
        }
        startButtonAction(node) {
            let fadeInAct = cc.fadeTo(1, 255);
            let fadeOutAct = cc.fadeTo(1, 100);
            let scaleInAct = cc.scaleTo(1, 1.2);
            let scaleOutAct = cc.scaleTo(1, 1);
            node.stopAllActions();
            node.runAction(cc.repeatForever(cc.sequence(fadeInAct, fadeOutAct)));
            node.runAction(cc.repeatForever(cc.sequence(scaleInAct, scaleOutAct)));
        }
        stopButtonAction(node) {
            node.stopAllActions();
            node.scale = 1;
            node.opacity = 255;
        }
        getAllChapterInfo() {
            let chapterIndex = [];
            let chapterName = [];
            let cfg = simba_config_manager_1.ConfigManager.getAllConfig(DateSceneConfig_1.dateSceneConfig);
            for (const id in cfg) {
                if (chapterIndex.indexOf(cfg[id].chapter_index) == -1 && cfg[id].chapter_index <= this._maxChapterIndex) {
                    chapterIndex.push(cfg[id].chapter_index);
                    chapterName.push(cfg[id].chapter_name);
                }
            }
            let chapterInfo = [];
            for (let i = 0; i < chapterIndex.length; i++) {
                if (chapterName[i]) {
                    chapterInfo.push({
                        chapterIndex: chapterIndex[i],
                        chapterName: chapterName[i]
                    });
                }
            }
            return chapterInfo;
        }
        async updateExtraPlotButtonRedDot() {
            //return;
            this._isStartBranches = true;
            this.view.getExtraPlotButton().getChildByName("RedDotSprite").active = false;
            let cfg = simba_config_manager_1.ConfigManager.getAllConfig(DateSceneConfig_1.dateSceneConfig);
            let startPlotIds = [];
            let cfgIds = [];
            for (const id in cfg) {
                if (cfg[id].DateType == EditorEnums_1.DateType.Date_Sp) {
                    startPlotIds.push(cfg[id].start_plot_id);
                    cfgIds.push(Number(id));
                }
            }
            await ExtraStoryModelManager_1.ExtraStoryModelManager.startBranches(startPlotIds, (index, startPlotId) => {
                let branchStatus = ExtraStoryModelManager_1.ExtraStoryModelManager.getBranchStatus(cfgIds[index], startPlotId);
                if (branchStatus == DatingEventSceneModel_1.DatingEventStatus.New || branchStatus == DatingEventSceneModel_1.DatingEventStatus.InProgress) {
                    this.view.getExtraPlotButton().getChildByName("RedDotSprite").active = true;
                }
            });
            await ExtraStoryModelManager_1.ExtraStoryModelManager.exitExtraStory();
            GameModelManager_1.GameModelManager.setIsMainPlotSceneType(false);
            this._isStartBranches = false;
        }
    };
    DatingEventSubpresenter = __decorate([
        PresenterCCViewFactory_1.RegSubpresenter(DatingEventSubview_1.DatingEventSubviewType)
    ], DatingEventSubpresenter);
    return DatingEventSubpresenter;
})();
exports.DatingEventSubpresenter = DatingEventSubpresenter;

cc._RF.pop();