update model region
This commit is contained in:
@@ -96,9 +96,7 @@ end
|
||||
local poolModelApi = CreateObjectPool(CreateModel)
|
||||
local poolUnitApi = CreateObjectPool(CreateModel)
|
||||
|
||||
local function AcquireModel(region, data)
|
||||
local pool = data.modelIsUnit and poolUnitApi or poolModelApi
|
||||
local model = pool:Acquire()
|
||||
local function ConfigureModel(region, model, data)
|
||||
model.modelIsUnit = data.modelIsUnit
|
||||
|
||||
model:ClearAllPoints()
|
||||
@@ -112,6 +110,12 @@ local function AcquireModel(region, data)
|
||||
model:SetPosition(data.model_z, data.model_x, data.model_y);
|
||||
model:SetFacing(rad(region.rotation));
|
||||
|
||||
model:SetScript("OnShow", function()
|
||||
WeakAuras.SetModel(model, data.model_path, data.modelIsUnit, data.modelDisplayInfo)
|
||||
model:SetPosition(data.model_z, data.model_x, data.model_y);
|
||||
model:SetFacing(rad(region.rotation));
|
||||
end)
|
||||
|
||||
if data.modelIsUnit then
|
||||
model:RegisterEvent("UNIT_MODEL_CHANGED");
|
||||
if (data.model_path == "target") then
|
||||
@@ -146,6 +150,12 @@ local function AcquireModel(region, data)
|
||||
else
|
||||
model:SetScript("OnUpdate", nil)
|
||||
end
|
||||
end
|
||||
|
||||
local function AcquireModel(region, data)
|
||||
local pool = data.modelIsUnit and poolUnitApi or poolModelApi
|
||||
local model = pool:Acquire()
|
||||
ConfigureModel(region, model, data)
|
||||
return model
|
||||
end
|
||||
|
||||
@@ -248,6 +258,8 @@ local function modify(parent, region, data)
|
||||
function region:PreShow()
|
||||
if not region.model then
|
||||
region.model = AcquireModel(self, data)
|
||||
else
|
||||
ConfigureModel(region, region.model, data)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -274,10 +286,12 @@ do
|
||||
end
|
||||
Private.StopProfileAura(id);
|
||||
end
|
||||
for model in pairs(Private.barmodels) do
|
||||
model:PreShow()
|
||||
end
|
||||
Private.StopProfileSystem("model");
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Register new region type with WeakAuras
|
||||
WeakAuras.RegisterRegionType("model", create, modify, default, GetProperties);
|
||||
|
||||
Reference in New Issue
Block a user