Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.80 KB | None | 0 0
  1. - Returns the correct difficulty color compared to the player
  2. local GetQuestDifficultyColor = function(level, playerLevel)
  3.     level = level - (playerLevel or K.Level)
  4.     if (level > 4) then
  5.         return "|CFFCC1A1A"
  6.     elseif (level > 2) then
  7.         return "|CFFFF8040"
  8.     elseif (level >= -2) then
  9.         return "|CFFE5B226"
  10.     elseif (level >= -GetQuestGreenRange()) then
  11.         return "|CFF59C959"
  12.     else
  13.         return "|CFF787878"
  14.     end
  15. end
  16.  
  17. local function AreaLabel_OnUpdate(self)
  18.     self:ClearLabel(MAP_AREA_LABEL_TYPE.AREA_NAME)
  19.     local map = self.dataProvider:GetMap()
  20.     if (map:IsCanvasMouseFocus()) then
  21.         local name, description
  22.         local mapID = map:GetMapID()
  23.         local normalizedCursorX, normalizedCursorY = map:GetNormalizedCursorPosition()
  24.         local positionMapInfo = C_Map.GetMapInfoAtPosition(mapID, normalizedCursorX, normalizedCursorY)
  25.         if (positionMapInfo and (positionMapInfo.mapID ~= mapID)) then
  26.             name = positionMapInfo.name
  27.             local playerMinLevel, playerMaxLevel, playerFaction
  28.             if (K.WorldMapLevelZoneData[positionMapInfo.mapID]) then
  29.                 playerMinLevel = K.WorldMapLevelZoneData[positionMapInfo.mapID].min
  30.                 playerMaxLevel = K.WorldMapLevelZoneData[positionMapInfo.mapID].max
  31.                 playerFaction = K.WorldMapLevelZoneData[positionMapInfo.mapID].faction
  32.             end
  33.  
  34.             if (playerFaction) then
  35.                 local englishFaction = UnitFactionGroup("player")
  36.                 if (playerFaction == "Alliance") then
  37.                     description = string.format(FACTION_CONTROLLED_TERRITORY, FACTION_ALLIANCE)
  38.                 elseif (playerFaction == "Horde") then
  39.                     description = string.format(FACTION_CONTROLLED_TERRITORY, FACTION_HORDE)
  40.                 end
  41.                 if (englishFaction == playerFaction) then
  42.                     description = "|CFF40D326" .. description.."|r" .. FONT_COLOR_CODE_CLOSE
  43.                 else
  44.                     description = "|CFFF52E24" .. description.."|r" .. FONT_COLOR_CODE_CLOSE
  45.                 end
  46.             end
  47.             if (name and playerMinLevel and playerMaxLevel and (playerMinLevel > 0) and (playerMaxLevel > 0)) then
  48.                 local playerLevel = K.Level
  49.                 local color
  50.                 if (playerLevel < playerMinLevel) then
  51.                     color = GetQuestDifficultyColor(playerMinLevel, playerLevel)
  52.                 elseif (playerLevel > playerMaxLevel) then
  53.                     -- subtract 2 from the maxLevel so zones entirely below the player's level won't be yellow
  54.                     color = GetQuestDifficultyColor(playerMaxLevel - 2, playerLevel)
  55.                 else
  56.                     color = "|CFFE5B226"
  57.                 end
  58.  
  59.                 if (playerMinLevel ~= playerMaxLevel) then
  60.                     name = name..color.." ("..playerMinLevel.."-"..playerMaxLevel..")|r"..FONT_COLOR_CODE_CLOSE
  61.                 else
  62.                     name = name..color.." ("..playerMaxLevel..")|r"..FONT_COLOR_CODE_CLOSE
  63.                 end
  64.             end
  65.         else
  66.             name = MapUtil.FindBestAreaNameAtMouse(mapID, normalizedCursorX, normalizedCursorY)
  67.         end
  68.  
  69.         if name then
  70.             self:SetLabel(MAP_AREA_LABEL_TYPE.AREA_NAME, name, description)
  71.         end
  72.     end
  73.     self:EvaluateLabels()
  74. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement