Referência › Referência de funções › Conditions

Conditions.common.Widget_SpellWidget

pública

Chame como

addon:Widget_SpellWidget(spec, editbox, value, nametoid, isvalid, update)

Disponível diretamente por meio de addon; nenhuma dependência é necessária.

O que faz

Cria uma entrada de feitiço com sugestões, validação e suporte a links de feitiço para widgets de condições personalizadas. O callback de atualização é responsável por salvar o valor escolhido; adicione o widget retornado ao pai do callback.

Argumentos

NomeTipoO que faz
selfRMAddonInstância do addon Rotation Master (implícita nas chamadas com dois-pontos).
specnumberEscopo de especialização usado para resolver sugestões de feitiços.
editboxstringTipo de entrada de referência, como Spec_EditBox, usado para sugestões de feitiços.
valuetableRegistro de valores da condição com os campos spell, ranked e disabled; atualizado no próprio lugar.
nametoidfunctionResolvedor que mapeia um nome de feitiço digitado para o ID dele.
isvalidfunctionPredicado que valida o valor de feitiço proposto.
updatefunctionCallback que recebe o valor de feitiço confirmado.

Retornos

1RMConditionGroupGrupo de campos de feitiço contendo um ícone de ação, uma entrada de referência e um controle de grau opcional.

Edições

As funções auxiliares integradas são registradas em todas as edições. O que muda é a API do jogo que elas leem; quando uma está ausente, a função auxiliar recorre a uma alternativa ou retorna nil com um motivo.

  • Indisponível nessa edição (o motivo está na dica)
  • Só enquanto as alternativas da Blizzard para APIs obsoletas estiverem ativas
API do jogoClassic EraTBC AnniversaryClassic ProgressionForeverRetail
GameTooltipClassic EraTBC AnniversaryClassic ProgressionForeverRetail

Como o addon a chama

e mais 19: Feitiço de ajudante disponível (widget), Cargas do feitiço de ajudante (widget), Tempo de recarga do feitiço de ajudante (widget), Histórico de lançamentos do ajudante (widget), Tempo do histórico de lançamentos do ajudante (widget), Feitiço de ajudante ao alcance (widget), Tempo de recarga de cargas do feitiço de ajudante (widget), Feitiço ativo ou pendente (widget), Repetição automática de feitiço ativa (widget), Feitiço disponível (widget), Cargas do feitiço (widget), Tempo de recarga do feitiço (widget), Brilho de ativação da magia (widget), Histórico de lançamentos (widget), Tempo do histórico de lançamentos (widget), Feitiço ao alcance (widget), Tempo de recarga de cargas do feitiço (widget), Totem específico presente (widget), Tempo restante de um totem específico (widget)

Dependências

Código-fonte

Conditions/common.lua, linha 82. Somente leitura no jogo; Duplicar cria uma cópia editável.

Conditions.common.Widget_SpellWidget(self, spec, editbox, value, nametoid, isvalid, update)
    local spell_group = addon:CreateConditionGroup()
    spell_group:SetLayout('RM-SpellField')
    local rankChoice

    local spell = addon:CreateSpellEditBox(editbox,value.spell)
    local initialSpell=type(value.spell)=="string" and SpellData:GetSpellId(value.spell) or value.spell
    local spellIcon = addon:CreateSpellActionIcon(spec == (BOOKTYPE_PET or "pet") and "pet" or "spell",initialSpell,isvalid)
    spellIcon:SetWidth(44)
    spellIcon:SetHeight(44)
    spellIcon:SetText(value.spell)
    spellIcon:SetCallback("OnEnterPressed", function(_, _, v)
        v = tonumber(v)
        if v and isvalid(v) then
            value.spell = v
            spellIcon:SetText(v)
            spell:SetText(SpellData:SpellName(value.spell, not value.ranked))
            if GameTooltip:IsOwned(spellIcon.frame) and GameTooltip:IsVisible() then
                GameTooltip:SetHyperlink("spell:" .. v)
            end
        else
            value.spell = nil
            spellIcon:SetText(nil)
            spell:SetText(nil)
            if GameTooltip:IsOwned(spellIcon.frame) and GameTooltip:IsVisible() then
                GameTooltip:Hide()
            end
        end
        update()
    end)
    spellIcon:SetCallback("OnEnter", function()
        if value.spell then
            GameTooltip:SetOwner(spellIcon.frame, "ANCHOR_BOTTOMRIGHT", 3)
            GameTooltip:SetHyperlink("spell:" .. value.spell)
        end
    end)
    spellIcon:SetCallback("OnLeave", function()
        if GameTooltip:IsOwned(spellIcon.frame) then
            GameTooltip:Hide()
        end
    end)
    spellIcon:SetDisabled(value.disabled)
    spell_group:AddChild(spellIcon)

    if addon:ClientHasSpellRanks() and spec ~= (BOOKTYPE_PET or "pet") then
        local nr_button = addon:CreateConditionCheckBox()
        nr_button:SetLabel(L["Use this exact spell rank"])
        nr_button.button.tooltip = RANK_TIP
        nr_button:SetValue(value.ranked or false)
        nr_button:SetCallback("OnValueChanged", function(_, _, val)
            value.ranked = val
            spell:SetUserData("norank", not val)
            spell:SetText(value.spell and SpellData:SpellName(value.spell, not value.ranked))
            update()
        end)
        nr_button:SetDisabled(value.disabled)
        rankChoice=nr_button
    end

    spell:SetFullWidth(true)
    spell:SetLabel('')
    spell:SetText(value.spell and SpellData:SpellName(value.spell, not value.ranked))
    spell:SetUserData("norank", not value.ranked)
    spell:SetUserData("spec", spec)
    spell:SetCallback("OnEnterPressed", function(_, _, v)
        if not addon.isint(v) then
            v = nametoid(v)
        else
            v = tonumber(v)
        end
        if isvalid(v) then
            value.spell = v
            spell:SetText(SpellData:SpellName(value.spell, not value.ranked))
        else
            value.spell = nil
            spell:SetText(nil)
        end
        spellIcon:SetText(value.spell)
        update()
    end)
    spell:SetDisabled(value.disabled)
    spell_group:AddChild(spell)
    if rankChoice then
        rankChoice.frame.GetFontString=function() return rankChoice.button:GetFontString() end
        spell_group:AddChild(rankChoice)
    end

    return spell_group

Voltar para Referência de funções