502 lines
20 KiB
Lua
502 lines
20 KiB
Lua
|
---@class WBP_SaveGamePanel_C:UUserWidget
|
||
|
---@field Category_Item_1 UWBP_SaveGame_Category_Item_C
|
||
|
---@field Category_Item_2 UWBP_SaveGame_Category_Item_C
|
||
|
---@field Category_Item_3 UWBP_SaveGame_Category_Item_C
|
||
|
---@field Category_Item_4 UWBP_SaveGame_Category_Item_C
|
||
|
---@field Category_Item_5 UWBP_SaveGame_Category_Item_C
|
||
|
---@field Category_Item_6 UWBP_SaveGame_Category_Item_C
|
||
|
---@field Image_CurAchievement_Icon UImage
|
||
|
---@field Panel_AchievementInfo UCanvasPanel
|
||
|
---@field Panel_BG UWBP_WidgetHeader_C
|
||
|
---@field ScrollBox_Achievements UScrollBox
|
||
|
---@field TextBlock_CurAchievement_Condition UTextBlock
|
||
|
---@field TextBlock_CurAchievement_Desc UTextBlock
|
||
|
---@field TextBlock_CurAchievement_State UTextBlock
|
||
|
---@field WrapBox_Achievements UWrapBox
|
||
|
--Edit Below--
|
||
|
require("Script.Global.SaveGameConfigs")
|
||
|
local WBP_SaveGamePanel = {
|
||
|
bInitDoOnce = false,
|
||
|
CategoryButtons = {},
|
||
|
|
||
|
AchievementInfoList = {},
|
||
|
AchievementItems = {},
|
||
|
|
||
|
CurCategoryIndex = -1,
|
||
|
|
||
|
ArchiveTable = nil,
|
||
|
OwnerArchiveData = nil,
|
||
|
};
|
||
|
|
||
|
function WBP_SaveGamePanel:Construct()
|
||
|
self.Panel_BG:Construct()
|
||
|
|
||
|
for i = 1, 6 do
|
||
|
self.CategoryButtons[i] = self["Category_Item_"..tostring(i)]
|
||
|
self.CategoryButtons[i].OwnerPanel = self
|
||
|
end
|
||
|
self.ItemClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/WBP_SaveGame_Achievement_Item.WBP_SaveGame_Achievement_Item_C'))
|
||
|
|
||
|
self.WrapBox_Achievements:ClearChildren()
|
||
|
self.AchievementItems = {}
|
||
|
end
|
||
|
|
||
|
function WBP_SaveGamePanel:Destruct()
|
||
|
self.CategoryButtons = {}
|
||
|
end
|
||
|
|
||
|
function WBP_SaveGamePanel:OnShowPanel()
|
||
|
if self.ArchiveTable == nil then
|
||
|
self.ArchiveTable = require('Script.Global.ArchiveTable')
|
||
|
end
|
||
|
self.OwnerArchiveData = GameDataManager.GetLocalPlayerState().ArchiveData
|
||
|
table.print("[WBP_SaveGamePanel][OnShowPanel] OwnerArchiveData", self.OwnerArchiveData)
|
||
|
log_tree("OwnerArchiveData ", self.OwnerArchiveData)
|
||
|
if self.CurCategoryIndex < 0 then
|
||
|
self.CurCategoryIndex = 1
|
||
|
end
|
||
|
self:OnCurCategoryChanged(self.CurCategoryIndex)
|
||
|
|
||
|
NewPlayerGuideManager:RemoveGuide(31)
|
||
|
end
|
||
|
|
||
|
function WBP_SaveGamePanel:OnCurCategoryChanged(InCategory)
|
||
|
if self.OwnerArchiveData == nil then
|
||
|
return
|
||
|
end
|
||
|
|
||
|
self.CurCategoryIndex = InCategory
|
||
|
for i = 1, 6 do
|
||
|
if i ~= InCategory then
|
||
|
self.CategoryButtons[i]:SetIsSelected(false)
|
||
|
else
|
||
|
self.CategoryButtons[i]:SetIsSelected(true)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
self:SetCurAchievementItems(InCategory)
|
||
|
|
||
|
if not table.isEmpty(self.AchievementItems) then
|
||
|
self.Panel_AchievementInfo:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
||
|
self.ScrollBox_Achievements:ScrollToStart() --滚动框滑到顶
|
||
|
self:OnCurAchievementChanged(self.AchievementItems[1]) --默认选取第一个成就
|
||
|
else
|
||
|
self.Panel_AchievementInfo:SetVisibility(ESlateVisibility.Collapsed)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WBP_SaveGamePanel:OnCurAchievementChanged(InAchievementItem)
|
||
|
for _, Item in pairs(self.AchievementItems) do
|
||
|
if Item == InAchievementItem then
|
||
|
Item:SetAchievementIsSelected(true)
|
||
|
else
|
||
|
Item:SetAchievementIsSelected(false)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
--Icon
|
||
|
local Info = InAchievementItem.Info
|
||
|
if Info.HasGained then
|
||
|
self.TextBlock_CurAchievement_State:SetColorAndOpacity({SpecifiedColor={R=1,G=0.258763,B=0.029837,A=1},ColorUseRule=0})
|
||
|
self.TextBlock_CurAchievement_State:SetText("已获得")
|
||
|
else
|
||
|
self.TextBlock_CurAchievement_State:SetColorAndOpacity({SpecifiedColor={R=0.015625,G=0.015625,B=0.015625,A=1},ColorUseRule=0})
|
||
|
self.TextBlock_CurAchievement_State:SetText("未获得")
|
||
|
end
|
||
|
|
||
|
self.TextBlock_CurAchievement_Condition:SetText(Info.Condition)
|
||
|
self.TextBlock_CurAchievement_Desc:SetText(Info.Desc)
|
||
|
UIManager.LoadTexture(self.Image_CurAchievement_Icon, Info.Icon)
|
||
|
end
|
||
|
|
||
|
function WBP_SaveGamePanel:SetCurAchievementItems(Index)
|
||
|
if self.AchievementInfoList[Index] == nil then
|
||
|
if Index == 1 then
|
||
|
self.AchievementInfoList[Index] = self:SetGameClearanceAchievements()
|
||
|
elseif Index == 2 then
|
||
|
self.AchievementInfoList[Index] = self:SetScoreAchievements()
|
||
|
elseif Index == 3 then
|
||
|
self.AchievementInfoList[Index] = self:SetEasterEggAchievements()
|
||
|
elseif Index == 4 then
|
||
|
self.AchievementInfoList[Index] = self:SetDropItemAchievements()
|
||
|
elseif Index == 5 then
|
||
|
self.AchievementInfoList[Index] = self:SetGameAchievements()
|
||
|
elseif Index == 6 then --商店类,暂无
|
||
|
self.AchievementInfoList[Index] = {}
|
||
|
end
|
||
|
end
|
||
|
self:SetupAchievementItems(self.AchievementInfoList[Index])
|
||
|
end
|
||
|
|
||
|
function WBP_SaveGamePanel:SetGameClearanceAchievements()
|
||
|
local PlayedGames = self.OwnerArchiveData.PlayedGames
|
||
|
local AchievementList = {}
|
||
|
|
||
|
local IconPath = SaveGameConfigs.Icons.GameClearance
|
||
|
|
||
|
local GameClearanceRewards = self.ArchiveTable.GameClearanceRewards
|
||
|
|
||
|
for GameDifficulty, RewardInfo in pairs(GameClearanceRewards) do
|
||
|
local DifficultyStr = "难"..tostring(GameDifficulty)
|
||
|
local PlayedTimes = PlayedGames[GameDifficulty]
|
||
|
for ConditionTimes, Info in pairs(RewardInfo) do
|
||
|
local AchievementData = {
|
||
|
HasGained = false,
|
||
|
ConditionTimes = ConditionTimes,
|
||
|
Difficulty = GameDifficulty,
|
||
|
Icon = IconPath,
|
||
|
Num = DifficultyStr,
|
||
|
Condition = string.format("%s难度通关%d次以上", DifficultyStr, ConditionTimes),
|
||
|
Desc = self:ParseRewardDesc(Info),
|
||
|
}
|
||
|
if PlayedTimes and PlayedTimes >= ConditionTimes then
|
||
|
AchievementData.HasGained = true
|
||
|
end
|
||
|
table.insert(AchievementList, AchievementData)
|
||
|
end
|
||
|
end
|
||
|
table.sort(AchievementList, function(a, b)
|
||
|
if a.HasGained == true and b.HasGained == false then
|
||
|
return true
|
||
|
elseif a.HasGained == b.HasGained then
|
||
|
if a.Difficulty < b.Difficulty then
|
||
|
return true
|
||
|
elseif a.Difficulty == b.Difficulty then
|
||
|
return a.ConditionTimes < b.ConditionTimes
|
||
|
end
|
||
|
return false
|
||
|
end
|
||
|
return false
|
||
|
end)
|
||
|
return AchievementList
|
||
|
end
|
||
|
|
||
|
function WBP_SaveGamePanel:SetScoreAchievements()
|
||
|
local AchievementList = {}
|
||
|
local PlayerScore = self.OwnerArchiveData.Score
|
||
|
--local RewardTable = self.ArchiveTable.CreditRewards
|
||
|
for Index, RewardInfo in pairs(ArchiveTable.CreditRewards) do
|
||
|
local AchievementData = {
|
||
|
HasGained = false,
|
||
|
Icon = SaveGameConfigs.Icons.Score,
|
||
|
Num = RewardInfo.Reach,
|
||
|
Condition = string.format("积分达到%d以上", RewardInfo.Reach),
|
||
|
Desc = self:ParseRewardDesc(RewardInfo.Reward),
|
||
|
}
|
||
|
if PlayerScore >= RewardInfo.Reach then
|
||
|
AchievementData.HasGained = true
|
||
|
end
|
||
|
table.insert(AchievementList, AchievementData)
|
||
|
end
|
||
|
table.sort(AchievementList, function(a, b)
|
||
|
if a.Num < b.Num then
|
||
|
if a.HasGained == true and b.HasGained == false then
|
||
|
return true
|
||
|
elseif a.HasGained == false and b.HasGained == true then
|
||
|
return false
|
||
|
end
|
||
|
return true
|
||
|
end
|
||
|
return false
|
||
|
end)
|
||
|
return AchievementList
|
||
|
end
|
||
|
|
||
|
function WBP_SaveGamePanel:SetEasterEggAchievements()
|
||
|
local AchievementList = {}
|
||
|
local PlayerEasterEggs = self.OwnerArchiveData.EasterEggs
|
||
|
local RewardTable = self.ArchiveTable.EasterEggs
|
||
|
for k, v in pairs(PlayerEasterEggs) do
|
||
|
local RewardInfo = RewardTable[k]
|
||
|
if RewardInfo == nil then
|
||
|
UE.Log("[WBP_SaveGamePanel][SetEasterEggAchievements] Can't Find RewardInfo")
|
||
|
else
|
||
|
local AchievementData = {
|
||
|
HasGained = false,
|
||
|
Index = k,
|
||
|
Icon = SaveGameConfigs.Icons.EasterEggs[k],
|
||
|
Num = RewardInfo.Name,
|
||
|
Condition = RewardInfo.Condition,
|
||
|
Desc = self:ParseRewardDesc(RewardInfo.Reward),
|
||
|
}
|
||
|
if v.Active == true then
|
||
|
AchievementData.HasGained = true
|
||
|
end
|
||
|
table.insert(AchievementList, AchievementData)
|
||
|
end
|
||
|
end
|
||
|
table.sort(AchievementList, function(a, b)
|
||
|
if a.HasGained == true and b.HasGained == false then
|
||
|
return true
|
||
|
elseif a.HasGained == b.HasGained then
|
||
|
if a.Index < b.Index then
|
||
|
if a.HasGained == true and b.HasGained == false then
|
||
|
return true
|
||
|
elseif a.HasGained == false and b.HasGained == true then
|
||
|
return false
|
||
|
end
|
||
|
return true
|
||
|
end
|
||
|
return false
|
||
|
end
|
||
|
return false
|
||
|
end)
|
||
|
return AchievementList
|
||
|
end
|
||
|
|
||
|
function WBP_SaveGamePanel:SetDropItemAchievements()
|
||
|
local AchievementList = {}
|
||
|
local PlayerBossDropItems = self.OwnerArchiveData.BossDropItems
|
||
|
local PlayerGameDropItems = self.OwnerArchiveData.GameDropItems
|
||
|
local BossDropItemName = {'武器','盔甲','腿铠','足屐','套装',}
|
||
|
local GameDropItemName = {'握把','枪口','弹夹','枪托','瞄准镜'}
|
||
|
--local RewardTable1 = self.ArchiveTable.BossDropItems
|
||
|
--local RewardTable2 = self.ArchiveTable.DropGameItems
|
||
|
|
||
|
for BossName, RewardInfo in pairs(self.ArchiveTable.BossDropItems) do
|
||
|
for Type, Data in pairs(RewardInfo) do
|
||
|
local AchievementData = {
|
||
|
HasGained = false,
|
||
|
Icon = SaveGameConfigs.Icons.BossDropItems[BossName][Type],
|
||
|
Num = string.format("%s之%s", BossName, BossDropItemName[Type]),
|
||
|
Condition = "",
|
||
|
Desc = "",
|
||
|
BossName = BossName,
|
||
|
AchievementType = 2,
|
||
|
ItemType = Type,
|
||
|
}
|
||
|
local CurPlayerDropData = PlayerBossDropItems[BossName]
|
||
|
if Type <= 4 then
|
||
|
if CurPlayerDropData and CurPlayerDropData[Type] and CurPlayerDropData[Type] > 0 then
|
||
|
AchievementData.HasGained = true
|
||
|
AchievementData.Desc = self:ParseRewardDescWithTable(Data.Rewards, CurPlayerDropData[Type])
|
||
|
else
|
||
|
AchievementData.Desc = self:ParseRewardDescWithTable(Data.Rewards, 1)
|
||
|
end
|
||
|
else
|
||
|
AchievementData.Desc = self:ParseRewardDescWithTable(Data.Rewards, 1)
|
||
|
if table.getCount(CurPlayerDropData) >= 4 and CurPlayerDropData[1] ~= nil then
|
||
|
AchievementData.HasGained = true
|
||
|
end
|
||
|
end
|
||
|
table.insert(AchievementList, AchievementData)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
-- 读取碎片
|
||
|
local ChipCount = 0
|
||
|
for GameDifficulty, Data in pairs(PlayerGameDropItems) do
|
||
|
for Type, Count in pairs(Data) do
|
||
|
if Type == 6 then
|
||
|
ChipCount = ChipCount + Count*GameDifficulty
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
local WeaponPartName = '碎片'
|
||
|
local ChipAchievementData = {
|
||
|
HasGained = false,
|
||
|
Icon = SaveGameConfigs.Icons.GameDropItems[WeaponPartName],
|
||
|
Num = "",
|
||
|
Condition = "",
|
||
|
Desc = "",
|
||
|
AchievementType = 0,
|
||
|
ItemType = 0,
|
||
|
}
|
||
|
if ChipCount > 0 then
|
||
|
ChipAchievementData.HasGained = true
|
||
|
ChipAchievementData.Num = string.format("碎片*%d", ChipCount)
|
||
|
ChipAchievementData.Desc = self:ParseRewardDescWithTable(self.ArchiveTable.DropGameItems[WeaponPartName], ChipCount)
|
||
|
else
|
||
|
ChipAchievementData.Num = string.format("碎片*%d", 0)
|
||
|
ChipAchievementData.Desc = self:ParseRewardDescWithTable(self.ArchiveTable.DropGameItems[WeaponPartName], 1)
|
||
|
end
|
||
|
table.insert(AchievementList, ChipAchievementData)
|
||
|
|
||
|
for Difficulty = 1, 66 do
|
||
|
for Type = 1, 5 do
|
||
|
local WeaponPartName = GameDropItemName[Type]
|
||
|
local AchievementData = {
|
||
|
HasGained = false,
|
||
|
Icon = SaveGameConfigs.Icons.GameDropItems[WeaponPartName],
|
||
|
Num = string.format("难%d %s", Difficulty, WeaponPartName),
|
||
|
Condition = "",
|
||
|
Desc = self:ParseRewardDesc(self.ArchiveTable.DropGameItems[WeaponPartName]),
|
||
|
Difficulty = Difficulty,
|
||
|
AchievementType = 1,
|
||
|
ItemType = Type,
|
||
|
}
|
||
|
local GameDropData = PlayerGameDropItems[Difficulty]
|
||
|
if GameDropData and GameDropData[Type] then
|
||
|
AchievementData.HasGained = true
|
||
|
end
|
||
|
table.insert(AchievementList, AchievementData)
|
||
|
end
|
||
|
if PlayerGameDropItems[Difficulty] and table.getCount(PlayerGameDropItems[Difficulty]) >= 5 and PlayerGameDropItems[Difficulty][1] ~= nil then
|
||
|
local WeaponPartName = '套装'
|
||
|
local AchievementData = {
|
||
|
HasGained = true,
|
||
|
Icon = SaveGameConfigs.Icons.GameDropItems[WeaponPartName],
|
||
|
Num = string.format("难%d %s", Difficulty, WeaponPartName),
|
||
|
Condition = "",
|
||
|
Desc = self:ParseRewardDescWithTable(self.ArchiveTable.DropGameItems[WeaponPartName], 1),
|
||
|
Difficulty = Difficulty,
|
||
|
AchievementType = 1,
|
||
|
ItemType = 6,
|
||
|
}
|
||
|
table.insert(AchievementList, AchievementData)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
table.sort(AchievementList, function(a, b)
|
||
|
if a.HasGained == true and b.HasGained == false then
|
||
|
return true
|
||
|
elseif a.HasGained == b.HasGained then
|
||
|
if a.AchievementType == b.AchievementType then
|
||
|
if a.AchievementType == 1 then
|
||
|
if a.Difficulty == b.Difficulty then
|
||
|
return a.ItemType < b.ItemType
|
||
|
end
|
||
|
return a.Difficulty < b.Difficulty
|
||
|
elseif a.AchievementType == 2 then
|
||
|
if a.BossName == b.BossName then
|
||
|
return a.ItemType < b.ItemType
|
||
|
else
|
||
|
local BossNameIndex = {['幻'] = 1, ['慎'] = 2, ['魅'] = 3, ['瞬'] = 4, ['春'] = 5, ['蛮'] = 6}
|
||
|
return BossNameIndex[a.BossName] < BossNameIndex[b.BossName]
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
return a.AchievementType < b.AchievementType
|
||
|
end
|
||
|
return false
|
||
|
end)
|
||
|
|
||
|
return AchievementList
|
||
|
end
|
||
|
|
||
|
function WBP_SaveGamePanel:SetGameAchievements()
|
||
|
local AchievementList = {}
|
||
|
local GameAchievements = {
|
||
|
['通关'] = {Value = self.OwnerArchiveData.GameClearanceTimes, ConditionStr = "通关%d次"},
|
||
|
['击败'] = {Value = self.OwnerArchiveData.TotalBossKilledTimes, ConditionStr = "共击败首领%d次"},
|
||
|
['金币'] = {Value = self.OwnerArchiveData.TotalCoinPoint / 10000, ConditionStr = "共获得%dw金币"},
|
||
|
['科技点'] = {Value = self.OwnerArchiveData.TotalKillPoint, ConditionStr = "共获得%d科技点"},
|
||
|
['技能'] = {Value = self.OwnerArchiveData.TotalSuperSkill, ConditionStr = "共获得超级技能%d个"},
|
||
|
--['配件'] = {Value = self.OwnerArchiveData.TotalSuperFitting, ConditionStr = "共获得超级配件%d个"},
|
||
|
['开箱'] = {Value = self.OwnerArchiveData.TotalUnpackTimes, ConditionStr = "开箱次数达到%d次"},
|
||
|
}
|
||
|
for AchievementName, Data in pairs(GameAchievements) do
|
||
|
local RewardTable = self.ArchiveTable.AchievementRewards[AchievementName]
|
||
|
for RewardReach, RewardInfo in pairs(RewardTable) do
|
||
|
local AchievementData = {
|
||
|
HasGained = false,
|
||
|
Sort = {Name = AchievementName, Reach = RewardReach},
|
||
|
Icon = SaveGameConfigs.Icons.Achievements[AchievementName][RewardReach],
|
||
|
Num = RewardInfo.Name,
|
||
|
Condition = string.format(Data.ConditionStr, RewardReach),
|
||
|
Desc = self:ParseRewardDesc(RewardInfo.Reward),
|
||
|
}
|
||
|
if Data.Value >= RewardReach then
|
||
|
AchievementData.HasGained = true
|
||
|
end
|
||
|
table.insert(AchievementList, AchievementData)
|
||
|
end
|
||
|
end
|
||
|
table.sort(AchievementList, function(a, b)
|
||
|
if a.HasGained == true and b.HasGained == false then
|
||
|
return true
|
||
|
elseif a.HasGained == b.HasGained then
|
||
|
local NameSort = {['通关'] = 1, ['击败'] = 2, ['金币'] = 3, ['科技点'] = 4, ['技能'] = 5, ['配件'] = 6, ['开箱'] = 7,}
|
||
|
local NameIndex1 = NameSort[a.Sort.Name]
|
||
|
local NameIndex2 = NameSort[b.Sort.Name]
|
||
|
if NameIndex1 == NameIndex2 then
|
||
|
return a.Sort.Reach < b.Sort.Reach
|
||
|
elseif NameIndex1 > NameIndex2 then
|
||
|
return false
|
||
|
end
|
||
|
return true
|
||
|
end
|
||
|
return false
|
||
|
end)
|
||
|
return AchievementList
|
||
|
end
|
||
|
|
||
|
function WBP_SaveGamePanel:SetupAchievementItems(AchievementDataList)
|
||
|
if AchievementDataList == nil then
|
||
|
return
|
||
|
end
|
||
|
|
||
|
self.AchievementItems = {}
|
||
|
local ChildIndex = 0
|
||
|
for _, AchievementData in pairs(AchievementDataList) do
|
||
|
local AchievementItemWidget = self.WrapBox_Achievements:GetChildAt(ChildIndex)
|
||
|
if AchievementItemWidget == nil then
|
||
|
AchievementItemWidget = UserWidget.NewWidgetObjectBP(UGCGameSystem.GameState, self.ItemClass)
|
||
|
AchievementItemWidget.OwnerPanel = self
|
||
|
self.WrapBox_Achievements:AddChildWrapBox(AchievementItemWidget)
|
||
|
else
|
||
|
AchievementItemWidget:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
||
|
end
|
||
|
AchievementItemWidget:InitAchievementInfo(AchievementData)
|
||
|
table.insert(self.AchievementItems, AchievementItemWidget)
|
||
|
|
||
|
ChildIndex = ChildIndex + 1
|
||
|
end
|
||
|
|
||
|
local ChildCount = self.WrapBox_Achievements:GetChildrenCount()
|
||
|
if ChildIndex < ChildCount then
|
||
|
for i = ChildIndex, ChildCount do
|
||
|
local AchievementItemWidget = self.WrapBox_Achievements:GetChildAt(i)
|
||
|
if AchievementItemWidget and UE.IsValid(AchievementItemWidget) then
|
||
|
AchievementItemWidget:SetVisibility(ESlateVisibility.Collapsed)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WBP_SaveGamePanel:ParseRewardDesc(InfoTable)
|
||
|
local Type = InfoTable.Type
|
||
|
local Value = InfoTable.Value
|
||
|
local Unit = InfoTable.Unit
|
||
|
if Type == nil or Value == nil or Unit == nil then
|
||
|
return ""
|
||
|
end
|
||
|
|
||
|
local NeedPercentSign = false
|
||
|
local DescStr = string.gsub(Type,"%p+","")..(Value >= 0 and "+" or "-")
|
||
|
if Unit == "%" then
|
||
|
Value = (math.abs(Value)) * 100.0
|
||
|
NeedPercentSign = true
|
||
|
end
|
||
|
local int, decimal = math.modf(Value)
|
||
|
local ValueStr = decimal > 0.001 and string.format("%.1f", Value) or string.format("%d", math.floor(Value))
|
||
|
DescStr = DescStr..ValueStr..(NeedPercentSign and "%" or "")
|
||
|
return DescStr
|
||
|
end
|
||
|
|
||
|
function WBP_SaveGamePanel:ParseRewardDescWithTable(RewardRewardInfo, Count)
|
||
|
Count = Count or 1.0
|
||
|
local DescStr = ""
|
||
|
for index, Info in pairs(RewardRewardInfo) do
|
||
|
local NeedPercentSign = false
|
||
|
local Type = Info.Type
|
||
|
local Value = Info.Value
|
||
|
local Unit = Info.Unit
|
||
|
if Type == nil or Value == nil or Unit == nil then
|
||
|
break
|
||
|
end
|
||
|
|
||
|
DescStr = DescStr..string.gsub(Type,"%p+","")..(Value >= 0 and "+" or "-")
|
||
|
if Unit == "%" then
|
||
|
Value = (math.abs(Value)) * 100.0
|
||
|
NeedPercentSign = true
|
||
|
end
|
||
|
Value = Value * Count
|
||
|
local int, decimal = math.modf(Value)
|
||
|
local ValueStr = decimal > 0.001 and string.format("%.1f", Value) or string.format("%d", math.floor(Value))
|
||
|
DescStr = DescStr..ValueStr..(NeedPercentSign and "%" or "")..(next(RewardRewardInfo, index) ~= nil and "\n" or "")
|
||
|
end
|
||
|
return DescStr
|
||
|
end
|
||
|
|
||
|
return WBP_SaveGamePanel;
|