Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Library.LibRowdy.Setup(...);
- import "core";
- import "table";
- import "class";
- import "string";
- import "ui";
- addonPackage "carla.ui";
- local base, metatable, methods = nil, nil, { };
- -- private members
- -- public members
- methods.SetAura = function(self, aura)
- local protected = self[AuraBar];
- protected.icon:SetTexture("Rift", aura.icon);
- if (aura.duration) then
- local time, duration, remaining = _G.Inspect.Time.Frame(), aura.duration, aura.remaining;
- if (remaining == nil) then
- remaining = 0;
- end
- protected.progressBar:SetMinMaxValues(-(time + remaining), -(time - (duration - remaining)));
- protected.progressBar:SetValue(-time);
- self.Update = nil;
- protected.endTime = time + remaining;
- else
- protected.progressBar:SetMinMaxValues(0, 1);
- protected.progressBar:SetValue(1);
- self.Update = dummy;
- protected.endTime = 4294967295;
- end
- local auraTitle = aura.name;
- if (type(aura.stack) == "number" and aura.stack > 1) then
- auraTitle = tostring(aura.stack) .. "x " .. tostring(auraTitle);
- end
- protected.text:SetText(auraTitle);
- protected.progressBar:Update();
- end
- methods.Update = function(self)
- local protected = self[AuraBar];
- local time = _G.Inspect.Time.Frame();
- protected.progressBar:SetValue(-time);
- protected.progressBar:Update();
- if (protected.endTime ~= 4294967295 and protected.lastRemainingUpdate - time >= .1) then
- local remaining = math.max(protected.endTime - time, 0);
- local remainingText = strformat("%.1f", remaining);
- protected.remaining:SetText(remainingText);
- end
- end
- methods.UpdateLayout = function(self)
- local protected = self[AuraBar];
- protected.progressBar:Update();
- end
- methods.SetHeight = function(self, value)
- local protected = self[AuraBar];
- base.SetHeight(self, value);
- protected.icon:SetHeight(value);
- protected.icon:SetWidth(value);
- protected.progressBar:SetPoint("LEFT", self, "LEFT", value, nil);
- end
- methods.GetEndTime = function(self)
- return self[AuraBar].endTime;
- end
- -- constructor
- AuraBar = function(name, parent)
- local self = UI.Frame(name, parent);
- self:SetBackgroundColor(1, 1, 1, .5);
- local icon = UI.Texture(name .. "Icon", self);
- icon:SetPoint("TOPLEFT", self, "TOPLEFT", 0, 0);
- local progressBar = UI.ProgressBar(name .. "ProgressBar", self);
- progressBar:SetAllPoints(self);
- local text = UI.Text(name .. "Text", self);
- text:SetPoint("CENTERLEFT", progressBar, "CENTERLEFT", 5, 0);
- text:SetLayer(100);
- text:SetAutoSize(true);
- text:SetFontSize(13);
- local remaining = UI.Text(name .. "Remaining", self);
- remaining:SetPoint("CENTERRIGHT", progressBar, "CENTERRIGHT", -5, 0);
- remaining:SetLayer(100);
- remaining:SetAutoSize(true);
- remaining:SetFontSize(13);
- self[AuraBar] = {
- icon = icon,
- progressBar = progressBar,
- text = text,
- remaining = remaining,
- lastRemainingUpdate = 0,
- };
- base, metatable = class(base, metatable, methods, self, AuraBar);
- self:SetWidth(250);
- self:SetHeight(25);
- return self;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement