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

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

Показано с 1 по 2 из 2
  1. #1
    Активист
    Регистрация
    22.11.2012
    Сообщений
    69
    Поблагодарил(а)
    39
    Получено благодарностей: 31 (сообщений: 30).
    Репутация: 31

    Question Отображение иконки заклинания на стандартном кастбаре

    Приветствую.
    Собственно, из заголовка: подскажите пожалуйста, как добавить иконку к дефолтному кастбару игрока?
    Без аддонов, желательно скриптом, который потом можно будет вставить в свой миниаддон.

  2. #2
    Активист
    Регистрация
    22.11.2012
    Сообщений
    69
    Поблагодарил(а)
    39
    Получено благодарностей: 31 (сообщений: 30).
    Репутация: 31
    Уберете лишнее:
    Код:
    CastingBarFrame:ClearAllPoints()
    CastingBarFrame:SetPoint("CENTER", UIParent, "CENTER", 0, -290)
    CastingBarFrame.SetPoint = function()end
    local fcb = CreateFrame("Frame", nil, UIParent)
    fcb:SetSize(36, 36)
    fcb:SetPoint("RIGHT", CastingBarFrame, "LEFT", -5, 7)
    local icon = fcb:CreateTexture(nil, "OVERLAY")
    icon:SetAllPoints()
    icon:SetTexture(nil)
    local timerText = fcb:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    timerText:SetPoint("LEFT", CastingBarFrame, "RIGHT", 5, 2)
    timerText:SetTextColor(1, 1, 1)
    timerText:SetFont("Fonts\\FRIZQT__.TTF", 13, "OUTLINE")
    timerText:Hide()
    fcb.casting = false
    fcb.castType = nil
    fcb.castStartTime = 0
    fcb.castEndTime = 0
    fcb.castDuration = 0
    fcb.updateElapsed = 0
    local function UpdateCastTime(self, elapsed)
    	self.updateElapsed = self.updateElapsed + elapsed
    	if self.updateElapsed < 0.05 then return end
    	self.updateElapsed = 0
    	if self.casting and self.castStartTime and self.castDuration > 0 then
    		local elapsedTime = math.min(((GetTime() * 1000) - self.castStartTime) / 1000, self.castDuration / 1000)
    		local totalTime = self.castDuration / 1000
    		timerText:SetText(string.format("%.1f / %.1f", elapsedTime, totalTime))
    	else
    		timerText:SetText("")
    	end
    end
    local function OnCastEvent(self, event, unit)
    	if unit ~= "player" then return end
    	if event == "UNIT_SPELLCAST_START" or event == "UNIT_SPELLCAST_CHANNEL_START" then
    		local spell, _, _, _, startTime, endTime
    		if event == "UNIT_SPELLCAST_START" then
    			spell, _, _, _, startTime, endTime = UnitCastingInfo("player")
    			self.castType = "cast"
    		else
    			spell, _, _, _, startTime, endTime = UnitChannelInfo("player")
    			self.castType = "channel"
    		end
    		if spell and startTime and endTime then
    			icon:SetTexture(GetSpellTexture(spell))
    			self.casting = true
    			self.castStartTime = startTime
    			self.castEndTime = endTime
    			self.castDuration = endTime - startTime
    			timerText:Show()
    			fcb:Show()
    			self:SetScript("OnUpdate", UpdateCastTime)
    		end
    	elseif event == "UNIT_SPELLCAST_DELAYED" or event == "UNIT_SPELLCAST_CHANNEL_UPDATE" then
    		local startTime, endTime
    		if self.castType == "cast" then
    			_, _, _, _, startTime, endTime = UnitCastingInfo("player")
    		elseif self.castType == "channel" then
    			_, _, _, _, startTime, endTime = UnitChannelInfo("player")
    		else
    			return
    		end
    		if startTime and endTime then
    			self.castStartTime = startTime
    			self.castEndTime = endTime
    			self.castDuration = endTime - startTime
    		end
    	elseif event == "UNIT_SPELLCAST_STOP"
    		or event == "UNIT_SPELLCAST_FAILED"
    		or event == "UNIT_SPELLCAST_INTERRUPTED"
    		or event == "UNIT_SPELLCAST_CHANNEL_STOP"
    	then
    		icon:SetTexture(nil)
    		timerText:Hide()
    		fcb:Hide()
    		self.casting = false
    		self:SetScript("OnUpdate", nil)
    	end
    end
    for _,eventName in ipairs({"UNIT_SPELLCAST_START","UNIT_SPELLCAST_CHANNEL_START","UNIT_SPELLCAST_STOP","UNIT_SPELLCAST_FAILED","UNIT_SPELLCAST_INTERRUPTED","UNIT_SPELLCAST_CHANNEL_STOP","UNIT_SPELLCAST_DELAYED","UNIT_SPELLCAST_CHANNEL_UPDATE",})do fcb:RegisterEvent(eventName)end
    fcb:SetScript("OnEvent", OnCastEvent)
    fcb:Hide()
    local function CreateCastTimeText(castbar)
    	if not castbar then return nil end
    	if castbar.castTimeText then return castbar.castTimeText end
    	local text = castbar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    	text:SetPoint("LEFT", castbar, "RIGHT", 3, 2)
    	text:SetTextColor(1, 1, 1)
    	text:SetFont("Fonts\\FRIZQT__.TTF", 11, "OUTLINE")
    	text:SetText("")
    	return text
    end
    local targetBarText = CreateCastTimeText(TargetFrameSpellBar)
    local focusBarText = CreateCastTimeText(FocusFrameSpellBar)
    TargetFrameSpellBar:SetScale(1.125)
    TargetFrameSpellBar:ClearAllPoints()
    TargetFrameSpellBar:SetPoint("CENTER", UIParent, "CENTER", 0, -220)
    TargetFrameSpellBar.SetPoint = function()end
    FocusFrameSpellBar:SetPoint("BOTTOM", FocusFrame, "TOP", -15, -7)
    FocusFrameSpellBar.SetPoint = function()end
    local updater = CreateFrame("Frame")
    updater.elapsed = 0
    updater:SetScript("OnUpdate", function(self, elapsed)
    	self.elapsed = self.elapsed + elapsed
    	if self.elapsed < 0.05 then return end
    	self.elapsed = 0
    	local function UpdateUnitCastTime(unit, text)
    		if not text then return end
    		local spell, _, _, _, startTime, endTime = UnitCastingInfo(unit)
    		if not spell then spell, _, _, _, startTime, endTime = UnitChannelInfo(unit)end
    		if spell and startTime and endTime then local current = math.min((GetTime()*1000 - startTime) / 1000, (endTime - startTime) / 1000)local max = (endTime - startTime) / 1000 text:SetText(string.format("%.1f / %.1f", current, max))else text:SetText("")end
    	end
    	UpdateUnitCastTime("target", targetBarText)UpdateUnitCastTime("focus", focusBarText)
    end)

Похожие темы

  1. Пропали иконки в личном кабинете
    от Onedalz в разделе Личный кабинет (logon, tbc, legion, bfa, sl)
    Ответов: 4
    Последнее сообщение: 15.04.2022, 20:30
  2. Расовые иконки способностей для арена123
    от Zikiprundoxx в разделе Аддоны
    Ответов: 0
    Последнее сообщение: 17.06.2021, 22:43
  3. [Исправлено после ближайшего обновления] Период цветения (иконка)
    от Bearon в разделе Исправлено Legion
    Ответов: 2
    Последнее сообщение: 23.06.2018, 17:05
  4. Ответов: 25
    Последнее сообщение: 20.10.2017, 20:56
  5. Пропали иконки в Личном кабинете!
    от Endragonar в разделе Архив технического раздела
    Ответов: 12
    Последнее сообщение: 28.10.2013, 23:43

Ваши права

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