diff --git a/Modules/Bars.lua b/Modules/Bars.lua index d7dc423..55f18d9 100644 --- a/Modules/Bars.lua +++ b/Modules/Bars.lua @@ -17,6 +17,10 @@ local WidgetBar = LibStub("StarLibWidgetBar-1.0") local LibCore = LibStub("StarLibCore-1.0") local Utils = LibStub("StarLibUtils-1.0") +local environment = {} + +local unit + local anchors = { "TOP", "TOPRIGHT", @@ -57,11 +61,11 @@ return UnitHealth("mouseover") min = "return 0", max = "return UnitHealthMax('mouseover')", color1 = [[ -if not UnitExists("mouseover") or not self then return end +if not UnitExists(unit) or not self then return end if self.visitor.visitor.db.profile.classColors then - return ClassColor("mouseover") + return ClassColor("player") else - local min, max = UnitHealth("mouseover"), UnitHealthMax("mouseover") + local min, max = UnitHealth(unit), UnitHealthMax("mouseover") return HPColor(min, max) end ]], @@ -196,6 +200,15 @@ function createBars() del(v[2]) end wipe(mod.bars) + environment.unit = "mouseover" + if UnitInRaid("player") and unit then + for i=1, GetNumRaidMembers() do + if UnitGUID(unit) == UnitGUID("raid" .. i) then + environment.unit = "raid" .. i + end + end + end + local appearance = StarTip:GetModule("Appearance") for k, v in pairs(copy(self.db.profile.bars)) do if v.enabled then @@ -275,6 +288,8 @@ function mod:OnInitialize() tinsert(self.db.profile.bars, v) end end + + self.db.profile.bars = copy(defaultWidgets) --[[ for k, v in pairs(defaultWidgets) do for kk, vv in pairs(self.db.profile.bars) do @@ -295,7 +310,7 @@ function mod:OnInitialize() end end - self.core = LibCore:New(mod, StarTip.environment, "StarTip.Bars", {["StarTip.Bars"] = {}}, nil, StarTip.db.profile.errorLevel) + self.core = LibCore:New(mod, environment, "StarTip.Bars", {["StarTip.Bars"] = {}}, nil, StarTip.db.profile.errorLevel) StarTip:SetOptionsDisabled(options, true) @@ -332,6 +347,7 @@ function mod:GetOptions() end function mod:SetUnit() + unit = GameTooltip:GetUnit() GameTooltipStatusBar:Hide() createBars() for i, bar in pairs(self.bars) do diff --git a/Modules/Histograms.lua b/Modules/Histograms.lua index 7bd4222..cc77966 100644 --- a/Modules/Histograms.lua +++ b/Modules/Histograms.lua @@ -17,6 +17,9 @@ local LSM = LibStub("LibSharedMedia-3.0") local WidgetHistogram = LibStub("StarLibWidgetHistogram-1.0") local LibCore = LibStub("StarLibCore-1.0") +local unit +local environment = {} + local createHistograms local widgets = {} @@ -127,29 +130,29 @@ end update = 1000 }, ["widget_health_histogram"] = { - expression = "return UnitHealth('player')", + expression = "return UnitHealth(unit)", min = "return 0", - max = "return UnitHealthMax('player')", + max = "return UnitHealthMax(unit)", enabled = true, width = 10, height = 50, point = {"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, -12}, color = [[ -return HPColor(UnitHealth("player"), UnitHealthMax("player")) +return HPColor(UnitHealth(unit), UnitHealthMax(unit)) ]], layer = 1, update = 1000 }, ["widget_mana_histogram"] = { - expression = "return UnitMana('player')", + expression = "return UnitMana(unit)", min = "return 0", - max = "return UnitManaMax('player')", + max = "return UnitManaMax(unit)", enabled = true, width = 10, height = 50, point = {"TOPRIGHT", "GameTooltip", "BOTTOMRIGHT", -100, -12}, color = [[ -return PowerColor("RAGE", "player") +return PowerColor("RAGE", unit) ]], layer = 1, update = 1000 @@ -255,6 +258,16 @@ function createHistograms() end wipe(widget.bars) end + + environment.unit = "mouseover" + if UnitInRaid("player") then + for i=1, GetNumRaidMembers() do + if UnitGUID("mouseover") == UnitGUID("raid" .. i) then + environment.unit = "raid" .. i + end + end + end + local appearance = StarTip:GetModule("Appearance") for k, v in pairs(self.db.profile.histograms) do if v.enabled then @@ -302,6 +315,8 @@ function mod:OnInitialize() if not self.db.profile.histograms then self.db.profile.histograms = {} end + + self.db.profile.histograms = copy(defaultWidgets) for i, v in ipairs(defaultWidgets) do for j, vv in ipairs(self.db.profile.histograms) do @@ -322,7 +337,7 @@ function mod:OnInitialize() end end - self.core = LibCore:New(mod, StarTip.environment, "StarTip.Histograms", {["StarTip.Histograms"] = {}}, nil, StarTip.db.profile.errorLevel) + self.core = LibCore:New(mod, environment, "StarTip.Histograms", {["StarTip.Histograms"] = {}}, nil, StarTip.db.profile.errorLevel) self.offset = 0 @@ -397,7 +412,9 @@ function mod:OnHide() for i = 1, widget.width or WidgetHistogram.defaults.width do widget.bars[i]:Hide() end - widget:Stop() + if not widget.persistent then + widget:Stop() + end end end diff --git a/Modules/Text.lua b/Modules/Text.lua index c152518..7568c1e 100644 --- a/Modules/Text.lua +++ b/Modules/Text.lua @@ -28,7 +28,7 @@ local select = _G.select local format = _G.format local floor = _G.floor local tostring = _G.tostring -local environment = StarTip.environment +local environment = {} local LSM = _G.LibStub("LibSharedMedia-3.0") local factionList = {} local linesToAdd = {} @@ -376,8 +376,8 @@ function mod:OnInitialize() self:RegisterEvent("UPDATE_FACTION") StarTip:SetOptionsDisabled(options, true) - --self.core = LibCore:New(mod, environment, self:GetName(), {[self:GetName()] = {}}, "text", StarTip.db.profile.errorLevel) - self.core = StarTip.core + self.core = LibCore:New(mod, environment, self:GetName(), {[self:GetName()] = {}}, "text", StarTip.db.profile.errorLevel) + --self.core = StarTip.core if ResourceServer then ResourceServer:New(environment) end --self.lcd = LCDText:New(self.core, 1, 40, 0, 0, 0, StarTip.db.profile.errorLevel) --self.core.lcd = self.lcd @@ -403,7 +403,7 @@ end function mod:OnDisable() StarTip:SetOptionsDisabled(options, true) if self.timer then self.timer:Del() end -ad +end function mod:GetOptions() self:RebuildOpts() @@ -473,24 +473,20 @@ function mod:CreateLines() lines = setmetatable(llines, {__call=function(self, unitTimer) environment.unit = "mouseover" if UnitInRaid("player") then - local txt = '' for i=1, GetNumRaidMembers() do - if UnitGUID(unit) == UnitGUID("raid" .. i) then + if UnitGUID("mouseover") == UnitGUID("raid" .. i) then environment.unit = "raid" .. i end end - if txt ~= '' then - GameTooltip:AddLine("Targeting: " .. txt, .5, .5, 1, 1) - end end - + local lineNum = 0 GameTooltip:ClearLines() for i, v in ipairs(self) do if v.enabled and not v.deleted then local left, right, c, cc = '', '' - if v.right and v.right ~= "" then + if v.right and v.right ~= "" then right = mod.evaluator.ExecuteCode(environment, v.name .. " right", v.right) left = mod.evaluator.ExecuteCode(environment, v.name .. " left", v.left) if right == "" then right = "nil" end @@ -1092,7 +1088,7 @@ function mod:SetUnit() end lastLine = lastLine + 1 - + wipe(linesToAdd) wipe(linesToAddR) wipe(linesToAddG) @@ -1121,20 +1117,20 @@ function mod:SetUnit() -- End lines() - + self:RefixEndLines() - + GameTooltip:Show() if self.db.profile.refreshRate > 0 and self.timer then self.timer:Start() - end + end end function mod:RefixEndLines() -- Another part taken from CowTip for i, left in ipairs(linesToAdd) do - + local right = linesToAddRight[i] if right then GameTooltip:AddDoubleLine(left, right, linesToAddR[i], linesToAddG[i], linesToAddB[i], linesToAddRightR[i], linesToAddRightG[i], linesToAddRightB[i]) @@ -1143,4 +1139,4 @@ function mod:RefixEndLines() end end -- End -end \ No newline at end of file +end