UIUtils.ts 2.44 KB
import { DeepReadonly } from "simba-utils";
import { DailyQuestType } from "../../avg/EditorEnums";
import { GameTextData } from "../../common/gameplay/gamedata/GameTextData";
import { UIManager } from "../../common/gameplay/managers/UIManager";
import { StringUtils } from "../../common/utils/StringUtils";
import { IItemConfig } from "../../config/ItemConfig";
import { CommonLocation, ExposureType, ShowLocationType, ShowType } from "../Enums";
import GameDotMgr from "../GameDotMgr";
import { GameModelManager } from "../model/GameModelManager";
import AlertDialogViewPresenter from "./presenter/AlertDialogViewPresenter";
import { AlertDialogViewProps } from "./view/type/AlertDialogView";

export namespace UIUtils {
    // export function showAddEnergy(itemConfig: DeepReadonly<IItemConfig>, itemCount?: number) {
    //     return new Promise<boolean>((resolve) => {
    //         itemCount = itemCount === undefined ? 0 : itemCount;
    //         let isAd = itemCount <= 0;
    //         let txt = "";
    //         if (isAd) {
    //             txt = StringUtils.format(GameModelManager.getLanguageTxt(GameTextData.GAME_TEXT_MAIN_ENERGY_PLAYAD_VALUE));
    //         } else {
    //             txt = StringUtils.format(GameModelManager.getLanguageTxt(GameTextData.GAME_TEXT_MAIN_ENERGY_USEDRINKS_VALUE), itemConfig.energy_recover, itemCount);
    //         }
    //         let temp: AlertDialogViewProps =
    //         {
    //             dataptr: {},
    //             titlecontent: GameModelManager.getLanguageTxt(GameTextData.GAME_TEXT_MAIN_ENERGY_NOTENOUGH_VALUE),
    //             content: txt,
    //             ishasad: isAd,
    //             istwobtn: true,
    //             adconfig: "inject_fruit",
    //             location: CommonLocation.Energy,
    //             hasBanner: !isAd,
    //             callback: (type, ret) => {
    //                 if (ret && !isAd) {
    //                     let player = GameModelManager.getPlayerData();
    //                     player.addProps(itemConfig.id, -1);
    //                 }

    //                 if (ret && type === "video") {
    //                     GameModelManager.addDailyTasks(DailyQuestType.Dq_AdsWatch, 1);
    //                 }
    //                 resolve(ret);
    //             }
    //         };
    //         UIManager.pushPresenter(AlertDialogViewPresenter, temp);
    //         GameDotMgr.getInstance().dotExposure(ExposureType.Energy);
    //     })
    // };
}