68 lines
1.6 KiB
Lua
68 lines
1.6 KiB
Lua
local PickBar = {}
|
|
local Reactive = require("Core.Reactive")
|
|
local ESlateVisibility = import("ESlateVisibility")
|
|
|
|
local function ResetWatcher(Bar)
|
|
if Bar.watcher then
|
|
Bar.watcher:Destroy()
|
|
Bar.watcher = nil
|
|
end
|
|
end
|
|
|
|
function PickBar:ctor()
|
|
self.watcher = nil
|
|
self.level_item = nil
|
|
end
|
|
|
|
function PickBar:OnInitialized()
|
|
self.ProcessBar:SetVisibility(ESlateVisibility.Collapsed)
|
|
print("PickBar:OnInitialized")
|
|
end
|
|
|
|
function PickBar:BindLevelItem(LevelItem)
|
|
ResetWatcher(self)
|
|
self.level_item = LevelItem
|
|
|
|
-- self.watcher = Reactive.Watcher(function()
|
|
-- self:UpdateState()
|
|
-- end)
|
|
|
|
|
|
self.watcher = Reactive.Watcher(function()
|
|
local process = LevelItem:GetPickProcess()
|
|
if process < 1.0 then
|
|
self.ProcessBar:SetPercent(process)
|
|
self.ProcessBar:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
else
|
|
self.ProcessBar:SetVisibility(ESlateVisibility.Collapsed)
|
|
self.ProcessBar:SetPercent(1.0)
|
|
end
|
|
end)
|
|
end
|
|
|
|
-- function PickBar:UpdateState()
|
|
-- local process = self.level_item:GetPickProcess()
|
|
-- if process < 1.0 then
|
|
-- self.ProcessBar:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
-- self.ProcessBar:SetPercent(process)
|
|
-- else
|
|
-- self.ProcessBar:SetVisibility(ESlateVisibility.Collapsed)
|
|
-- self.ProcessBar:SetPercent(1.0)
|
|
-- end
|
|
-- end
|
|
|
|
function PickBar:OnDestroy()
|
|
ResetWatcher(self)
|
|
end
|
|
|
|
function PickBar:Construct()
|
|
print("PickBar:Construct")
|
|
end
|
|
|
|
function PickBar:Destruct()
|
|
print("PickBar:Destruct")
|
|
end
|
|
|
|
|
|
|
|
return Class(nil, nil, PickBar) |