85 lines
3.2 KiB
Lua
85 lines
3.2 KiB
Lua
---@class WB_MiniGameSettlement_Item_C:UUserWidget
|
|
---@field Border_ImageColor UBorder
|
|
---@field Button_Result_AddFriend UButton
|
|
---@field Image_Head UImage
|
|
---@field Image_Head_4th UImage
|
|
---@field TextBlock_Name UTextBlock
|
|
---@field TextBlock_Rank UTextBlock
|
|
---@field TextBlock_Score UTextBlock
|
|
---@field TextBlock_StarCount UTextBlock
|
|
---@field WidgetSwitcher_Is4th UWidgetSwitcher
|
|
--Edit Below--
|
|
local WB_MiniGameSettlement_Item = {
|
|
bInitDoOnce = false;
|
|
TargetScore = 0;
|
|
RankColor = {
|
|
[1] = {R=1.000000,G=0.467513,B=0.000000,A=1.000000},
|
|
[2] = {R=0.583333,G=0.583333,B=0.583333,A=1.000000},
|
|
[3] = {R=0.584079,G=0.194618,B=0.052861,A=1.000000},
|
|
[4] = {R=0.046875,G=0.046875,B=0.046875,A=1.000000}
|
|
},
|
|
RankStr = {
|
|
[1] = "1 st",
|
|
[2] = "2 nd",
|
|
[3] = "3 rd",
|
|
[4] = "4 th",
|
|
}
|
|
};
|
|
|
|
|
|
--[==[ Construct
|
|
function WB_MiniGameSettlement_Item:Construct()
|
|
|
|
end
|
|
-- Construct ]==]
|
|
|
|
-- function WB_MiniGameSettlement_Item:Tick(MyGeometry, InDeltaTime)
|
|
|
|
-- end
|
|
|
|
-- function WB_MiniGameSettlement_Item:Destruct()
|
|
|
|
-- end
|
|
|
|
---@param PlayerScoreInfo {RankNum = uint, PlayerKey = uint, Score = uint}
|
|
function WB_MiniGameSettlement_Item:UpdatePlayerRankInfo(RankNum, PlayerScoreInfo)
|
|
WidgetLibrary.BindButtonClicked(self.Button_Result_AddFriend, self.AddFriend, self)
|
|
if PlayerScoreInfo then
|
|
self.TargetPlayerKey = PlayerScoreInfo.PlayerKey
|
|
local HeadUrl = UGCGameSystem.GameState:GetHeadIconByPlayerKey(PlayerScoreInfo.PlayerKey)
|
|
local Color = self.RankColor[RankNum]
|
|
self.TextBlock_Rank:SetColorAndOpacity({SpecifiedColor=Color,ColorUseRule=0})
|
|
self.TextBlock_Rank:SetText(self.RankStr[RankNum])
|
|
self.TargetScore = PlayerScoreInfo.Score
|
|
self.TextBlock_Score:SetText(tostring(self.TargetScore))
|
|
local PlayerName = UGCGameSystem.GameState:GetPlayerNameByPlayerKey(PlayerScoreInfo.PlayerKey)
|
|
self.TextBlock_Name:SetText(PlayerName)
|
|
UGCSystemLibrary.DownloadImageToUImage(self.Image_Head, HeadUrl);
|
|
self.Border_ImageColor:SetContentColorAndOpacity(Color)
|
|
--if RankNum < 4 then
|
|
-- UGCSystemLibrary.DownloadImageToUImage(self.Image_Head, HeadUrl);
|
|
-- self.Border_ImageColor:SetContentColorAndOpacity(Color)
|
|
--else
|
|
-- self.WidgetSwitcher_Is4th:SetActiveWidgetIndex(1)
|
|
-- UGCSystemLibrary.DownloadImageToUImage(self.Image_Head_4th, HeadUrl);
|
|
--end
|
|
if self.TargetPlayerKey == UGCSystemLibrary.GetLocalPlayerKey() then
|
|
self.Button_Result_AddFriend:SetVisibility(ESlateVisibility.Collapsed)
|
|
end
|
|
|
|
local StarCount = UGCGameSystem.GameState:GetPlayerStar(self.TargetPlayerKey)
|
|
self.TextBlock_StarCount:SetText(tostring(StarCount))
|
|
else
|
|
self:SetVisibility(ESlateVisibility.Hidden);
|
|
end
|
|
end
|
|
|
|
function WB_MiniGameSettlement_Item:AddFriend()
|
|
local TargetPlayerData = UGCGameSystem.GameState.PlayerPersonalInfos[self.TargetPlayerKey]
|
|
if TargetPlayerData then
|
|
UGCLogSystem.Log("[WB_MiniGameSettlement_Item_AddFriend] UID:%s", tostring(TargetPlayerData.UID))
|
|
UGCGameSystem.AddFriend(TargetPlayerData.UID)
|
|
end
|
|
end
|
|
|
|
return WB_MiniGameSettlement_Item; |