---@class WB_Currency_C:UUserWidget ---@field Button_AddGold UButton ---@field Button_AddGoldBrick UButton ---@field Button_AddLevel UButton ---@field Button_ShowGuide UButton ---@field NewButton_Setting UNewButton ---@field TextBlock_Gold UTextBlock ---@field TextBlock_GoldBrick UTextBlock ---@field TextBlock_Level UTextBlock --Edit Below-- local WB_Currency = { bInitDoOnce = false; }; function WB_Currency:Construct() -- self:ShowRechargeEntrance() WidgetLibrary.BindButtonClicked(self.Button_AddGold, self.ClickAddGold, self) WidgetLibrary.BindButtonClicked(self.Button_AddGoldBrick, self.ClickAddGoldBrick, self) WidgetLibrary.BindButtonClicked(self.Button_AddLevel, self.ClickAddLevel, self) WidgetLibrary.BindButtonClicked(self.NewButton_Setting, self.ShowSettingPanel, self) WidgetLibrary.ButtonOnClickShowPanel(self.Button_ShowGuide, WidgetConfig.EUIType.Guide) UGCEventSystem.AddListener(ArchiveDataConfig.GetParamNotifyEvent(ArchiveDataConfig.EArchiveType.Gold), self.UpdateGoldCount, self) UGCEventSystem.AddListener(ArchiveDataConfig.GetParamNotifyEvent(ArchiveDataConfig.EArchiveType.Exp), self.UpdateLevelCount, self) UGCEventSystem.AddListener(ArchiveDataConfig.GetParamNotifyEvent(ArchiveDataConfig.EArchiveType.GoldBrick), self.UpdateGoldBrickCount, self) self:UpdateGoldCount() self:UpdateLevelCount() self:UpdateGoldBrickCount() end function WB_Currency:ShowRechargeEntrance() UGCCommoditySystem.ShowRechargeEntryUI() --UGCCommoditySystem.ShowRechargeEntryUI():Then( -- function (Result) -- local UI = Result:Get() -- UI:SetVisibility() -- end --) end function WB_Currency:ClickAddGold() --WidgetManager:ShowPanel(WidgetConfig.EUIType.Task, false) local LocalPK = UGCSystemLibrary.GetLocalPlayerKey() local SecondaryConfirmationWidget = WidgetManager:GetPanel(WidgetConfig.EUIType.SecondaryConfirmation_Strip) local GoldBrick = ArchiveDataConfig.GetPlayerArchiveDataFromType(LocalPK, ArchiveDataConfig.EArchiveType.GoldBrick) SecondaryConfirmationWidget:SetValRange(0, GoldBrick and GoldBrick or 0) SecondaryConfirmationWidget:SetTextInfo(function(Val) return string.format("消耗 %s 块金砖兑换 %s 个金币。", tostring(Val), tostring(Val * PlacementModeConfig.PlacingAttr.RatioGoldBrickToGold)) end) SecondaryConfirmationWidget:BindConfirmCallBack(self.ConfirmExchangeGoldBrickToGold, self) WidgetManager:ShowPanel(WidgetConfig.EUIType.SecondaryConfirmation_Strip, false) end function WB_Currency:ConfirmExchangeGoldBrickToGold(GoldBrickVal) UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "GoldBrickToGold", UGCSystemLibrary.GetLocalPlayerKey(), GoldBrickVal) end function WB_Currency:ClickAddGoldBrick() UGCLogSystem.Log("[WB_Currency_ConfirmExchangeOasisCoinToGoldBrick]") -- UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "GoldBrickToGold", UGCSystemLibrary.GetLocalPlayerKey(), GoldBrickVal) local Result = UGCCommoditySystem.BuyUGCCommodity( PlacementModeConfig.PlacingAttr.GoldBrickName, "金砖", UGCGameSystem.GetUGCResourcesFullPath('Asset/Texture/T_GoldBrick.T_GoldBrick'), "用于兑换经验和金币", PlacementModeConfig.PlacingAttr.BuyGoldBrickCount, PlacementModeConfig.PlacingAttr.RatioOasisCoinToGoldBrick ) UGCLogSystem.Log("[WB_Currency_ConfirmExchangeOasisCoinToGoldBrick] Finish") --local SecondaryConfirmationWidget = WidgetManager:GetPanel(WidgetConfig.EUIType.SecondaryConfirmation_Strip) --SecondaryConfirmationWidget:SetValRange(0, 1280) --SecondaryConfirmationWidget:SetTextInfo(function(Val) return string.format("消耗%s个绿洲币兑换%s个金砖。", tostring(Val), tostring(Val * PlacementModeConfig.PlacingAttr.RatioOasisCoinToGoldBrick)) end) --SecondaryConfirmationWidget:BindConfirmCallBack(self.ConfirmExchangeOasisCoinToGoldBrick, self) --WidgetManager:ShowPanel(WidgetConfig.EUIType.SecondaryConfirmation_Strip, false) end function WB_Currency:ConfirmExchangeOasisCoinToGoldBrick(Val) UGCLogSystem.Log("[WB_Currency_ConfirmExchangeOasisCoinToGoldBrick]") -- UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "GoldBrickToGold", UGCSystemLibrary.GetLocalPlayerKey(), GoldBrickVal) local Result = UGCCommoditySystem.BuyUGCCommodity( PlacementModeConfig.PlacingAttr.GoldBrickName, "金砖", UGCGameSystem.GetUGCResourcesFullPath('Asset/Texture/T_GoldBrick.T_GoldBrick'), "用于兑换经验和金币", 100, 1 ) UGCLogSystem.Log("[WB_Currency_ConfirmExchangeOasisCoinToGoldBrick] Finish") end function WB_Currency:ClickAddLevel() WidgetManager:ShowPanel(WidgetConfig.EUIType.Task, false) end function WB_Currency:UpdateGoldCount() local Gold = ArchiveDataConfig.GetPlayerArchiveDataFromType(UGCSystemLibrary.GetLocalPlayerKey(), ArchiveDataConfig.EArchiveType.Gold) if Gold == nil then Gold = 0 end self.TextBlock_Gold:SetText(tostring(Gold)) end function WB_Currency:UpdateLevelCount() local Exp = ArchiveDataConfig.GetPlayerArchiveDataFromType(UGCSystemLibrary.GetLocalPlayerKey(), ArchiveDataConfig.EArchiveType.Exp) if Exp == nil then Exp = 0 end local Level = LevelConfig.GetLevel(Exp) self.TextBlock_Level:SetText(tostring(Level)) end function WB_Currency:UpdateGoldBrickCount() local GoldBrick = ArchiveDataConfig.GetPlayerArchiveDataFromType(UGCSystemLibrary.GetLocalPlayerKey(), ArchiveDataConfig.EArchiveType.GoldBrick) if GoldBrick == nil then GoldBrick = 0 end self.TextBlock_GoldBrick:SetText(tostring(GoldBrick)) end -- function WB_Currency:Tick(MyGeometry, InDeltaTime) -- end -- function WB_Currency:Destruct() -- end function WB_Currency:ShowSettingPanel() UGCLogSystem.Log("[WB_Currency_ShowSettingPanel]") local MainControlPanel = GameBusinessManager.GetWidgetFromName(ingame, "MainControlPanelTochButton_C"); if MainControlPanel then -- MainControlPanel.MainControlBaseUI:OpenSettingPanel(); MainControlPanel.MainControlBaseUI:OpenSettingPanel(); if self.DoOnceOpenSettingPanel then MainControlPanel.MainControlBaseUI:OpenSettingPanel(); else self.DoOnceOpenSettingPanel = true end end end return WB_Currency;