Приветствуем вас на форуме проекта WoW Circle. Если вы читаете это, значит не зарегистрировались у нас. Для того, чтобы получить доступ к расширенным возможностям нашего форума нажмите сюда и пройди регистрацию, которая не займет у вас много времени. После регистрации будут доступны новые, более расширенные, возможности.
Карта!

Упомянутые в теме пользователи:

Показано с 1 по 12 из 27

Тема: Карта!

Древовидный режим

Предыдущее сообщение Предыдущее сообщение   Следующее сообщение Следующее сообщение
  1. #14
    Почетный флудер Аватар для Artur91425
    Регистрация
    25.10.2012
    Адрес
    Россия
    Сообщений
    2,772
    Поблагодарил(а)
    339
    Получено благодарностей: 558 (сообщений: 391).
    Репутация: 1047
    Можно еще сделать отображение иконок в зависимости от роли, например для танка будет так
    Capture.PNG
    Но проблема в том, что эту роль очень плохо видно, да и кода гораздо больше становится. Мне кажется смысла в этом нет.

    - - - Updated - - -

    блин, нашел проблему с цветными никами в тултипе<br>

    - - - Updated - - -

    В общем было 2 проблемы:
    1) цвета вообще не отображались
    2) сломалась система, когда в тултипе объединялись имена

    Поправил все это.

    Код:
    WORLDMAP_UNITBUTTON_TEXTURE_SIZE = 16 -- default - 16
    BATTLEFIELDMINIMAP_UNITBUTTON_TEXTURE_SIZE = 12 -- default - 12
    
    local select = select
    local GetNumRaidMembers, UnitIsPlayer, UnitClass, UnitInParty = GetNumRaidMembers, UnitIsPlayer, UnitClass, UnitInParty
    
    local BLIP_TEX_COORDS = {
      ['WARRIOR'] = { 0, 0.125, 0, 0.25 },
      ['PALADIN'] = { 0.125, 0.25, 0, 0.25 },
      ['HUNTER'] = { 0.25, 0.375, 0, 0.25 },
      ['ROGUE'] = { 0.375, 0.5, 0, 0.25 },
      ['PRIEST'] = { 0.5, 0.625, 0, 0.25 },
      ['DEATHKNIGHT'] = { 0.625, 0.75, 0, 0.25 },
      ['SHAMAN'] = { 0.75, 0.875, 0, 0.25 },
      ['MAGE'] = { 0.875, 1, 0, 0.25 },
      ['WARLOCK'] = { 0, 0.125, 0.25, 0.5 },
      ['DRUID'] = { 0.25, 0.375, 0.25, 0.5 }
    }
    
    local BLIP_RAID_Y_OFFSET = 0.5
    
    local function GetColoredName(unit)
      local name = UnitName(unit)
      local class = select(2, UnitClass(unit))
      local color = RAID_CLASS_COLORS[class]
      local coloredName = ('|cFF%02x%02x%02x%s|r'):format(color.r * 255, color.g * 255, color.b * 255, name)
      return name, coloredName
    end
    
    local function ColoringUnit(text, unit)
      local name, coloredName = GetColoredName(unit)
      return text:gsub(name, coloredName)
    end
    
    -- replace texture
    local function OnLoad(frame)
      local size = frame == 'BattlefieldMinimap' and BATTLEFIELDMINIMAP_UNITBUTTON_TEXTURE_SIZE or WORLDMAP_UNITBUTTON_TEXTURE_SIZE
      for i=1,4 do
        local partyUnitButton = _G[frame..'Party'..i]
        partyUnitButton:SetSize(size, size)
        partyUnitButton.icon:SetTexture('Interface\\Minimap\\PartyRaidBlips.blp')
      end
      for i=1,40 do
        local raidUnitButton = _G[frame..'Raid'..i]
        raidUnitButton:SetSize(size, size)
        raidUnitButton.icon:SetTexture('Interface\\Minimap\\PartyRaidBlips.blp')
      end
    end
    
    -- set the correct texture depending on the class
    local function OnUpdate(self)
      local unit = self.unit
      if not UnitIsPlayer(unit) then return end
    
      local class = select(2, UnitClass(unit))
      local coord = BLIP_TEX_COORDS[class]
      if GetNumRaidMembers() > 0 then
        if UnitInParty(unit) then
          self.icon:SetTexCoord(coord[1], coord[2], coord[3], coord[4])
        else
          self.icon:SetTexCoord(coord[1], coord[2], coord[3] + BLIP_RAID_Y_OFFSET, coord[4] + BLIP_RAID_Y_OFFSET)
        end
      else
        self.icon:SetTexCoord(coord[1], coord[2], coord[3], coord[4])
      end
    end
    
    -- coloring nicknames
    local function OnEnter(self, frame)
      local unit = self.unit
      if not UnitIsPlayer(unit) then return end
    
      local unitButton;
      local tooltip = frame == 'BattlefieldMinimap' and GameTooltip or WorldMapTooltip
      local tooltipText = _G[tooltip:GetName()..'TextLeft1']:GetText()
    
      if frame == 'WorldMap' then
        -- Check player
        if WorldMapPlayer:IsMouseOver() then
          tooltipText = ColoringUnit(tooltipText, WorldMapPlayer.unit)
        end
      end
      -- Check party
      for i=1, MAX_PARTY_MEMBERS do
        unitButton = _G[frame..'Party'..i]
        if unitButton:IsVisible() and unitButton:IsMouseOver() then
          tooltipText = ColoringUnit(tooltipText, unitButton.unit)
        end
      end
      -- Check Raid
      for i=1, MAX_RAID_MEMBERS do
        unitButton = _G[frame..'Raid'..i]
        if unitButton:IsVisible() and unitButton:IsMouseOver() then
          tooltipText = ColoringUnit(tooltipText, unitButton.unit)
        end
      end
      tooltip:SetText(tooltipText)
      tooltip:Show()
    end
    
    do -- WorldMap
      OnLoad('WorldMap')
      hooksecurefunc('WorldMapUnit_Update', OnUpdate)
      hooksecurefunc('WorldMapUnit_OnEnter', function(self)
        OnEnter(self, 'WorldMap')
      end)
    end
    
    do -- BattlefieldMinimap
      local f = CreateFrame('Frame')
      f:RegisterEvent('ADDON_LOADED')
      f:SetScript('OnEvent', function(self, event, addon)
        if addon ~= 'Blizzard_BattlefieldMinimap' then return end
        OnLoad('BattlefieldMinimap')
        hooksecurefunc('BattlefieldMinimap_OnUpdate', OnUpdate)
        hooksecurefunc('BattlefieldMinimapUnit_OnEnter', function(self)
          OnEnter(self, 'BattlefieldMinimap')
        end)
      end)
    end
    - - - Updated - - -

    Обновил код в посте. Переписал фикс вышеуказанных проблем в адекватный вид.

  2. 1 пользователь сказал cпасибо Artur91425 за это полезное сообщение:

    HA1DEKS (14.06.2021)

Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
  •