restructure
This commit is contained in:
259
tools/panorama_decompile/decompiled_scrips/team_select_card.js
Normal file
259
tools/panorama_decompile/decompiled_scrips/team_select_card.js
Normal file
@@ -0,0 +1,259 @@
|
||||
|
||||
|
||||
// 卡池中的卡片事件
|
||||
function setCardPoolEvent(panel, card) {
|
||||
panel.SetPanelEvent("oncontextmenu", function () {
|
||||
if (card.IsDisabled() || ShowingCardGroup) return;
|
||||
card.Select();
|
||||
})
|
||||
panel.SetPanelEvent("ondblclick", function () {
|
||||
if (card.IsDisabled() || ShowingCardGroup) return;
|
||||
card.Select();
|
||||
})
|
||||
panel.SetPanelEvent("onactivate", function () {
|
||||
card.ShowInfo();
|
||||
Game.EmitSound("UI.ClickCard");
|
||||
})
|
||||
}
|
||||
|
||||
function TouhouCard( parent, itemName, itemData, isPreview ) {
|
||||
var panel = $.CreatePanel("Panel", parent, "");
|
||||
panel.BLoadLayoutSnippet("CardPoolCard");
|
||||
setCardPoolEvent(panel, this);
|
||||
|
||||
panel.SetDialogVariable("remaining_count", "0");
|
||||
panel.SetDialogVariable("level", "0");
|
||||
panel.SetAttributeString("itemname", itemName);
|
||||
panel.SetHasClass(GetQualityText(itemData.quality), true);
|
||||
panel.FindChild("CardBackGround").SetImage("s2r://panorama/images/custom_game/cards/item_" + GetQualityText(itemData.quality) + "_png.vtex");
|
||||
panel.FindChild("CardImage").SetImage("s2r://panorama/images/custom_game/cards/" + itemData.cardname + "_png.vtex");
|
||||
|
||||
this.hPanel = panel;
|
||||
this.szItemName = itemName;
|
||||
this.hItemData = itemData;
|
||||
this.bIsItem = itemData.cardname.indexOf("item_") === 0;
|
||||
this.nSelectedCount = 0;
|
||||
if (itemName === "item_2021" || itemName === "item_2022")
|
||||
this.nMaxCount = 1;
|
||||
else if (isPreview)
|
||||
this.nMaxCount = 0;
|
||||
else
|
||||
this.nMaxCount = GetSingleCardMaxCount(itemData.quality, this.bIsItem);
|
||||
|
||||
if (this.bIsItem) {
|
||||
panel.GetChild(panel.GetChildCount() - 1).visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 物品名称
|
||||
TouhouCard.prototype.GetItemName = function() {
|
||||
return this.szItemName
|
||||
};
|
||||
|
||||
//
|
||||
TouhouCard.prototype.GetItemData = function() {
|
||||
return this.hItemData
|
||||
};
|
||||
|
||||
// 获取已选数量
|
||||
TouhouCard.prototype.GetSelectedCount = function() {
|
||||
return this.nSelectedCount
|
||||
};
|
||||
|
||||
// 获取品质
|
||||
TouhouCard.prototype.GetQuality = function() {
|
||||
return this.hItemData.quality
|
||||
};
|
||||
|
||||
// 更新卡牌
|
||||
TouhouCard.prototype.Update = function() {
|
||||
var itemname = this.szItemName;
|
||||
var isItem = this.bIsItem;
|
||||
var quality = this.hItemData.quality;
|
||||
var singleCount = this.nSelectedCount;
|
||||
var maxCount = this.nMaxCount;
|
||||
var remainingCount = maxCount - singleCount;
|
||||
var panel = this.hPanel;
|
||||
|
||||
// 设置剩余数量
|
||||
if (ShowingCardGroup) {
|
||||
this.nSelectedCount = 0;
|
||||
panel.SetDialogVariable("remaining_count", maxCount.toString());
|
||||
} else {
|
||||
panel.SetDialogVariable("remaining_count", remainingCount.toString());
|
||||
}
|
||||
|
||||
if (!isItem) {
|
||||
var level = GameUI.PowerLevel && GameUI.PowerLevel[itemname] ? GameUI.PowerLevel[itemname] : 0;
|
||||
panel.SetDialogVariable("level", level.toString());
|
||||
panel.GetChild(panel.GetChildCount() - 1).visible = level > 0;
|
||||
}
|
||||
|
||||
if (quality === 4) Current_SSR_Count = FindCardCount(4);
|
||||
else if (quality === 3) Current_SR_Count = FindCardCount(3);
|
||||
else if (quality === 2) Current_R_Count = FindCardCount(2);
|
||||
else if (quality === 1) Current_N_Count = FindCardCount(1);
|
||||
|
||||
// 设置禁用状态
|
||||
if (ShowingCardGroup) {
|
||||
panel.SetHasClass("disable", true);
|
||||
|
||||
} else if (remainingCount <= 0) {
|
||||
panel.SetHasClass("disable", true);
|
||||
|
||||
} else if (quality === 4) {
|
||||
panel.SetHasClass("disable", (Current_SSR_Count === CardCount_SSR) || singleCount >= maxCount);
|
||||
|
||||
} else if (quality === 3) {
|
||||
panel.SetHasClass("disable", (Current_SR_Count === CardCount_SR) || singleCount >= maxCount);
|
||||
|
||||
} else if (quality === 2) {
|
||||
panel.SetHasClass("disable", (Current_R_Count === CardCount_R) || singleCount >= maxCount);
|
||||
|
||||
} else if (quality === 1) {
|
||||
panel.SetHasClass("disable", (Current_N_Count >= MaxCardCount_N) || singleCount >= maxCount);
|
||||
}
|
||||
};
|
||||
|
||||
// 是否为禁用状态
|
||||
TouhouCard.prototype.IsDisabled = function() {
|
||||
return this.hPanel.BHasClass("disable");
|
||||
};
|
||||
|
||||
// 选择卡牌
|
||||
TouhouCard.prototype.Select = function() {
|
||||
var count = FindCardCount(quality);
|
||||
if (count >= GetQualityMaxCount(quality)) return;
|
||||
|
||||
var data = this.hItemData;
|
||||
var quality = data.quality;
|
||||
var itemname = this.szItemName;
|
||||
var singleCount = this.nSelectedCount;
|
||||
var maxCount = this.nMaxCount;
|
||||
var isItem = this.bIsItem;
|
||||
|
||||
if (singleCount >= maxCount) {
|
||||
this.Update();
|
||||
return;
|
||||
}
|
||||
|
||||
this.nSelectedCount++;
|
||||
|
||||
UpdateSelectedCards(itemname);
|
||||
UpdateCardPool();
|
||||
|
||||
Game.EmitSound('UI.SelectCard');
|
||||
};
|
||||
|
||||
// 移除卡牌
|
||||
TouhouCard.prototype.Remove = function() {
|
||||
this.nSelectedCount--;
|
||||
if (this.nSelectedCount < 0) this.nSelectedCount = 0;
|
||||
UpdateCardPool();
|
||||
};
|
||||
|
||||
// 显示查看卡牌信息
|
||||
TouhouCard.prototype.ShowInfo = function() {
|
||||
if (LastShowInfoCard) {
|
||||
LastShowInfoCard.hPanel.SetHasClass("ShowInfo", false);
|
||||
}
|
||||
this.hPanel.SetHasClass("ShowInfo", true);
|
||||
LastShowInfoCard = this;
|
||||
|
||||
var data = this.hItemData;
|
||||
var isItem = this.bIsItem;
|
||||
var quality = data.quality;
|
||||
if ( isItem ) {
|
||||
$("#CardInfoName").text = $.Localize("DOTA_Tooltip_ability_" + data.cardname);
|
||||
} else {
|
||||
$("#CardInfoName").text = $.Localize(data.cardname);
|
||||
}
|
||||
|
||||
var CardInfoContent = $("#CardInfoContent");
|
||||
var Card = CardInfoContent.GetChild(0);
|
||||
Card.SetHasClass("SwapCard", false);
|
||||
Card.SetHasClass("SwapCard", true);
|
||||
Card.SetHasClass("SSR", false);
|
||||
Card.SetHasClass("SR", false);
|
||||
Card.SetHasClass("R", false);
|
||||
Card.SetHasClass("N", false);
|
||||
Card.SetHasClass(GetQualityText(quality), true);
|
||||
if (data.cardname.indexOf("item_") === 0) {
|
||||
Card.FindChildTraverse("CardImage").SetImage("s2r://panorama/images/custom_game/cards/" + data.cardname + "_png.vtex");
|
||||
} else {
|
||||
Card.FindChildTraverse("CardImage").SetImage("s2r://panorama/images/custom_game/cards/" + data.cardname + "_big_png.vtex");
|
||||
}
|
||||
|
||||
if (GameUI.LuckCardCrit > 0 && (data.cardname === GameUI.LuckCardName || GameUI.LuckCardName === "all")) {
|
||||
Card.FindChildTraverse("CardName").SetImage("s2r://panorama/images/custom_game/cards/luck_png.vtex");
|
||||
} else {
|
||||
Card.FindChildTraverse("CardName").SetImage("s2r://panorama/images/custom_game/cards/" + data.cardname + "_name_png.vtex");
|
||||
}
|
||||
|
||||
Card.FindChildTraverse("CardBackGround").SetImage("s2r://panorama/images/custom_game/cards/item_" + GetQualityText(quality) + "_png.vtex");
|
||||
|
||||
// 特效
|
||||
var CardEffect = Card.FindChildTraverse("CardEffect");
|
||||
CardEffect.FireEntityInput("SSR", "StopPlayEndCap", "1");
|
||||
CardEffect.FireEntityInput("SR", "StopPlayEndCap", "1");
|
||||
CardEffect.FireEntityInput(GetQualityText(quality), "Start", "1");
|
||||
|
||||
// 显示培养按钮
|
||||
|
||||
var decomposeValue = 0;
|
||||
if (quality === 1)
|
||||
decomposeValue = 5;
|
||||
else
|
||||
decomposeValue = 10;
|
||||
|
||||
var DecomposeCardButton = $("#DecomposeCardButton");
|
||||
DecomposeCardButton.enabled = !isItem && decomposeValue > 0;
|
||||
DecomposeCardButton.SetDialogVariableInt("amount", decomposeValue);
|
||||
|
||||
// 显示技能
|
||||
var CardAbilities = $("#CardAbilities");
|
||||
var index = 0;
|
||||
if (isItem) {
|
||||
$("#CardInfoItem").visible = true;
|
||||
$("#CardInfoItem").itemname = data.cardname;
|
||||
} else {
|
||||
$("#CardInfoItem").visible = false;
|
||||
|
||||
// 显示技能
|
||||
for (var i = 0; i < 8; i++) {
|
||||
var abilityname = "thtd_" + data.cardname + "_0" + i;
|
||||
var key = "DOTA_Tooltip_ability_" + abilityname;
|
||||
var nameText = $.Localize(key);
|
||||
if (nameText !== key) {
|
||||
if (nameText.substr(0, 5) === "link_") {
|
||||
key = nameText.substr(5, nameText.length - 5);
|
||||
abilityname = key.substr("DOTA_Tooltip_ability_".length, key.length - "DOTA_Tooltip_ability_".length);
|
||||
nameText = $.Localize(key);
|
||||
}
|
||||
var panel = CardAbilities.GetChild(index++);
|
||||
if (!panel) {
|
||||
var panel = $.CreatePanel("Panel", CardAbilities, "");
|
||||
panel.BLoadLayoutSnippet("CardAbility");
|
||||
(function (main) {
|
||||
main.SetPanelEvent("onmouseover", function () {
|
||||
var name = main.GetAttributeString("abilityname", "");
|
||||
$.DispatchEvent("DOTAShowAbilityTooltip", main, name);
|
||||
});
|
||||
main.SetPanelEvent("onmouseout", function () {
|
||||
$.DispatchEvent("DOTAHideAbilityTooltip");
|
||||
});
|
||||
})(panel)
|
||||
}
|
||||
panel.SetAttributeString("abilityname", abilityname);
|
||||
panel.FindChildTraverse("AbilityImage").abilityname = abilityname;
|
||||
panel.FindChildTraverse("AbilityName").text = nameText;
|
||||
panel.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var max = CardAbilities.GetChildCount();
|
||||
for (var i = index; i < max; i++) {
|
||||
CardAbilities.GetChild(i).visible = false;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user