kob 4 天之前
父節點
當前提交
ebded3a5ff

+ 0 - 1
assets/scripts/modules/lobby/ui/SeasonPassView/Prize/NodeItem.ts

@@ -2,7 +2,6 @@ import { AppKernel } from '@scripts/app/AppKernel';
 import { UIViewID } from '@scripts/define/UIDefine';
 import { UIView } from '@scripts/framework/ui/UIView';
 import { formatMailTimeToMMDDYYYY, parseMailRewardStr } from '@scripts/utils/Helper';
-import { setSpriteFrame } from '@scripts/utils/ResHelper';
 import { addBtnClick, removeBtnClick } from '@scripts/utils/UIHelper';
 import { _decorator, Button, Component, Enum, instantiate, Label, Node, NodePool, Prefab, ProgressBar, Sprite, SpriteFrame, tween, UIOpacity } from 'cc';
 const { ccclass, property } = _decorator;

+ 12 - 8
assets/scripts/modules/lobby/ui/SeasonPassView/Tasks/RewardItem.ts

@@ -2,9 +2,9 @@ import { AppKernel } from '@scripts/app/AppKernel';
 import { UIViewID } from '@scripts/define/UIDefine';
 import { UIView } from '@scripts/framework/ui/UIView';
 import { formatMailTimeToMMDDYYYY, parseMailRewardStr } from '@scripts/utils/Helper';
-import { setSpriteFrame } from '@scripts/utils/ResHelper';
+import { setOriginalSp, setSpriteFrame } from '@scripts/utils/ResHelper';
 import { addBtnClick, removeBtnClick } from '@scripts/utils/UIHelper';
-import { _decorator, Button, Component, Enum, instantiate, Label, Node, NodePool, Prefab, ProgressBar, Sprite, UIOpacity } from 'cc';
+import { _decorator, Button, Component, Enum, instantiate, Label, Node, NodePool, Prefab, ProgressBar, Sprite, UIOpacity, UITransform } from 'cc';
 const { ccclass, property } = _decorator;
 
 export enum RewardType {
@@ -76,7 +76,8 @@ export class RewardItem extends Component {
 
 
         const { task_type, target_value, progress, reward, status } = this._data;
-
+        const path_prefix = 'textures/seasonPass/tasks/detailIcon/';
+        let path = path_prefix;
         switch (task_type) {
             // 1 签到
             // 2 完成指定数量的子游戏
@@ -84,27 +85,30 @@ export class RewardItem extends Component {
             // 4 子游戏游玩时长(需指定 game_id)
             // 5 获得 SC
             case 1:
-                setSpriteFrame(this.task_icon, 'textures/seasonPass/tasks/detailIcon/icon_check');
+                path += 'icon_check';
                 this.task_detail.string = `CHECK IN TODAY`;
                 if (this._rewardType == RewardType.Seasonal) this.task_detail.string = `CHECK IN ${target_value} DAYS`;
+
+
                 break;
             case 2:
-                setSpriteFrame(this.task_icon, 'textures/seasonPass/tasks/detailIcon/icon_game');
+                path += 'icon_game';
                 this.task_detail.string = `PLAY ${target_value} SUBGAMES`;
                 break;
             case 3:
-                setSpriteFrame(this.task_icon, 'textures/seasonPass/tasks/detailIcon/icon_win');
+                path += 'icon_win';
                 this.task_detail.string = `WIN ${target_value} SUBGAMES`;
                 break;
             case 4:
-                setSpriteFrame(this.task_icon, 'textures/seasonPass/tasks/detailIcon/icon_time');
+                path += 'icon_time';
                 this.task_detail.string = `PLAY ${target_value} MINS`;
                 break;
             case 5:
-                setSpriteFrame(this.task_icon, 'textures/seasonPass/tasks/detailIcon/icon_sc');
+                path += 'icon_sc';
                 this.task_detail.string = `OBTAIN SC`;
                 break;
         }
+        setOriginalSp(this.task_icon, path);
 
         this.progress.progress = progress / target_value;
         this.progress_label.string = `${progress}/${target_value}`;

+ 21 - 1
assets/scripts/utils/ResHelper.ts

@@ -1,7 +1,7 @@
 import { AppKernel } from "@scripts/app/AppKernel";
 import { AssetSlot } from "@scripts/components/AssetSlot";
 import { BUNDLE_ID } from "@scripts/define/ResDefine";
-import { isValid, Sprite, SpriteFrame } from "cc";
+import { isValid, Sprite, SpriteFrame, UITransform } from "cc";
 import { ImgFitMode, setSpriteFitMode } from "./UIHelper";
 
 const GoodsIconRes = "common/goodsIcon/img_icon";
@@ -56,6 +56,26 @@ export async function setSpriteFrame(sprite: Sprite, path?: string, optins?: ISe
     return res;
 }
 
+export async function setOriginalSp(sprite: Sprite, path?: string) {
+    if (!path) {
+        return;
+    }
+
+    let res: SpriteFrame = null;
+    const resources = AppKernel.resources;
+    if (path.startsWith("http")) {
+        res = await resources.loadRemoteSp(path);
+    } else {
+        if (!path.endsWith("/spriteFrame")) path += "/spriteFrame";
+        res = await resources.load(BUNDLE_ID.Lobby, path, SpriteFrame);
+    }
+
+    // cb && cb(res);
+    sprite.spriteFrame = res;
+    sprite.getComponent(UITransform).width = res.originalSize.width;
+    sprite.getComponent(UITransform).height = res.originalSize.height;
+}
+
 export async function setGoodsIcon(sprite: Sprite, type: number, isGCOnly = false) {
     const iconPath = isGCOnly ? `${GoodsIconRes}gc` : `${GoodsIconRes}${type}`;
     return setSpriteFrame(sprite, `${iconPath}`);