Go to most recent revision | Compare with Previous | Blame | View Log
local f = WINDOW_MANAGER:CreateTopLevelWindow("ZAM_ReactionColors") local reticle = ZO_ReticleContainerReticle local stealthEye = ZO_ReticleContainerStealthEye local GetUnitReactionColor = GetUnitReactionColor local IsGameCameraUnitHightlightedValid = IsGameCameraUnitHightlightedValid local GetUnitLevel = GetUnitLevel local GetUnitReaction = GetUnitReaction local GetConColor = GetConColor local playerLevel = GetUnitLevel("player") local reaction, targetName, targetLevel, warning, db local colorByChoices = {"Reaction", "Level", "Level if hostile", "Disabled"} local defaults = { warning = true, warningLevel = 5, colorBy = "Reaction", colorTargetName = true, colorTargetLevel = true, } local function CreateWarningTexture() warning = WINDOW_MANAGER:CreateControl("ReactionColorsReticleWarning", ZO_ReticleContainer, CT_TEXTURE) --warning:SetTexture("EsoUI\\pts\\Addons\\ZAM_ReactionColors\\Aura7.dds") warning:SetTexture("EsoUI\\Art\\TreeIcons\\tutorial_idexicon_death_down.dds") warning:SetDimensions(85,85) warning:SetAnchor(CENTER, ZO_ReticleContainer, CENTER, 0, -50) warning:SetColor(1, 0, 0, .5) warning:SetHidden(true) end local function UpdateColor() if IsGameCameraUnitHightlightedValid() then local r, g, b = GetUnitReactionColor("reticleover") local level = GetUnitLevel("reticleover") local r2, g2, b2 = GetConColor(level, playerLevel) local hostile = GetUnitReaction("reticleover") == UNIT_REACTION_HOSTILE if db.colorBy == "Reaction" then reticle:SetColor(r, g, b) stealthEye:SetColor(r, g, b) elseif db.colorBy == "Level" or (db.colorBy == "Level if hostile" and hostile) then reticle:SetColor(r2, g2, b2) stealthEye:SetColor(r2, g2, b2) --[[elseif db.colorBy == "Level if hostile" and hostile then reticle:SetColor(r2, g2, b2) stealthEye:SetColor(r2, g2, b2)]] end if db.colorTargetName then if not targetName then targetName = ZO_TargetUnitFramereticleoverName end targetName:SetColor(r, g, b, 1) end if db.colorTargetLevel then if not targetLevel then targetLevel = ZO_TargetUnitFramereticleoverLevel end targetLevel:SetColor(r2, g2, b2) end if warning and db.warning then if hostile and (level - playerLevel >= db.warningLevel) then warning:SetHidden(false) else warning:SetHidden(true) end end else reticle:SetColor(1, 1, 1, 1) stealthEye:SetColor(1, 1, 1, 1) end end local function CreateOptions() local LAM = LibStub("LibAddonMenu-1.0") local zamPanel = LAM:CreateControlPanel("ZAM_ADDON_OPTIONS", "ZAM Addons") LAM:AddHeader(zamPanel, "ZAM_ReactionColors_Options_Header", "ZAM ReactionColors") LAM:AddDropdown(zamPanel, "ZAM_ReactionColors_Options_ColorBy", "Color the targeting reticle by...", "Select when to color the targeting reticle.", colorByChoices, function() return db.colorBy end, function(colorBy)db.colorBy = colorBy end) LAM:AddCheckbox(zamPanel, "ZAM_ReactionColors_Options_Warning", "Warning Icon", "Display a warning icon for high level hostile targets.", function() return db.warning end, function() db.warning = not db.warning if db.warning and not warning then CreateWarningTexture() end end) LAM:AddSlider(zamPanel, "ZAM_ReactionColors_Options_WarningLevel", "Warning Threshold", "Display the warning icon if the target is this many levels higher than you.", 2, 10, 1, function() return db.warningLevel end, function(value) db.warningLevel = value end) LAM:AddCheckbox(zamPanel, "ZAM_ReactionColors_Options_ColorTargetName", "Color Target's Name", "Color the target's name by reaction.", function() return db.colorTargetName end, function() db.colorTargetName = not db.colorTargetName if not db.colorTargetName then targetName:SetColor(1, 1, 1) end end) LAM:AddCheckbox(zamPanel, "ZAM_ReactionColors_Options_ColorTargetLevel", "Color Target's Level", "Color the target's level by difficulty.", function() return db.colorTargetLevel end, function() db.colorTargetLevel = not db.colorTargetLevel if not db.colorTargetLevel then targetLevel:SetColor(1, 1, 1) end end) end local function Initialize() ZAM_ReactionColorsDB = ZAM_ReactionColorsDB or {} for k,v in pairs(defaults) do if type(ZAM_ReactionColorsDB[k]) == "nil" then ZAM_ReactionColorsDB[k] = v end end db = ZAM_ReactionColorsDB if db.warning then CreateWarningTexture() end CreateOptions() end EVENT_MANAGER:RegisterForEvent("ZAM_ReactionColors", EVENT_RETICLE_TARGET_CHANGED, UpdateColor) EVENT_MANAGER:RegisterForEvent("ZAM_ReactionColors", EVENT_DISPOSITION_UPDATE, UpdateColor) EVENT_MANAGER:RegisterForEvent("ZAM_ReactionColors", EVENT_ADD_ON_LOADED, function(event, addon) if addon == "ZAM_ReactionColors" then Initialize() end end)