
import Gamecfg from "../../../../common/gameCfg";
import { MergeItem } from "../../../../data/model/GridMap/GridMapModel";
import ResSprite from "../../../../frameWork/compment/ResSprite";
import { Autowire } from "../../../../frameWork/fgui/Autowire";
import { ItemRender } from "../../../../frameWork/fgui/ListUtil";
import { HcType } from "../../../../shared/hc/PtlHcInfo";

export default class HomeMergeTipItem extends ItemRender {

	@Autowire
	IconLoad: fgui.GLoader;
	@Autowire
	RateLabel: fgui.GTextField;
	private mData: MergeItem;
	sp_item: ResSprite;
	onInit() {
		this.sp_item = this.IconLoad.node.addComponent(ResSprite);
	}

	onShow(): void {
	}

	onHide(): void {
	}

	setData(data: MergeItem, index?: number, param?: { refresh: boolean }) {
		this.mData = data;
		this.RateLabel.text = `${(data.rate / 100).toFixed(0)}%`;
		let quality = 0;
		if (this.mData.type == HcType.emitter) {
			let mergePropCfg = Gamecfg.emitterInfo.getItem(this.mData.id.toString());
			this.sp_item.setSpriteFrame('gridMap', `mergeProp/${mergePropCfg.icon}`);
			quality = mergePropCfg.quality;
		} else if (this.mData.type == HcType.material) {
			let mergePropCfg = Gamecfg.mergePropInfo.getItem(this.mData.id.toString());
			this.sp_item.setSpriteFrame('gridMap', `mergeProp/${mergePropCfg.icon}`);
			quality = mergePropCfg.quality;
		} else if (this.mData.type == HcType.equip) {
			let mergePropCfg = Gamecfg.equipInfo.getItem(this.mData.id.toString());
			this.sp_item.setSpriteFrame('gridMap', `mergeEquip/${mergePropCfg.icon}`);
			quality = mergePropCfg.quality;
		} else if (this.mData.type == HcType.monster) {
			// this.ueHomeRole = AssetMgr.instantiateUE(UEHomeRole);
			// this.itemNode.addChild(this.ueHomeRole.node);
			// this.ueHomeRole.Init(this.mData);
		}
	}


}
