Referencia › Referencia de funciones › Conditions

Conditions.common.Widget_SpellWidget

pública

Llamar como

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

Disponible directamente a través de addon; no hace falta ninguna dependencia.

Qué hace

Crea una entrada de hechizo con sugerencias, validación y compatibilidad con enlaces de hechizo para los widgets de condiciones personalizadas. El callback de actualización se encarga de guardar el valor elegido; añade el widget devuelto al padre del callback.

Argumentos

NombreTipoQué hace
selfRMAddonInstancia del addon Rotation Master (implícita en las llamadas con dos puntos).
specnumberÁmbito de especialización usado para resolver las sugerencias de hechizos.
editboxstringTipo de entrada de referencia, como Spec_EditBox, usado para las sugerencias de hechizos.
valuetableRegistro de valores de la condición con los campos spell, ranked y disabled; se actualiza en el sitio.
nametoidfunctionResolutor que asigna un nombre de hechizo escrito a su ID.
isvalidfunctionPredicado que valida el valor de hechizo propuesto.
updatefunctionCallback que recibe el valor de hechizo confirmado.

Retornos

1RMConditionGroupGrupo de campos de hechizo con un icono de acción, una entrada de referencia y un control de rango opcional.

Ediciones

Las funciones auxiliares integradas se registran en todas las ediciones. Lo que cambia es la API del juego que leen; donde falta alguna, la función auxiliar recurre a una alternativa o devuelve nil con un motivo.

  • No disponible en esa edición (el motivo aparece en la información emergente)
  • Solo mientras estén activas las alternativas de Blizzard para API obsoletas
API del juegoClassic EraTBC AnniversaryClassic ProgressionForeverRetail
GameTooltipClassic EraTBC AnniversaryClassic ProgressionForeverRetail

Cómo la llama el addon

y 19 más: Hechizo de mascota disponible (widget), Cargas del hechizo de mascota (widget), Tiempo de reutilización del hechizo de mascota (widget), Historial de lanzamientos de mascota (widget), Tiempo del historial de lanzamientos de mascota (widget), Hechizo de mascota al alcance (widget), Tiempo de recarga del hechizo de mascota (widget), Hechizo activo o pendiente (widget), Repetición automática de hechizo activa (widget), Hechizo disponible (widget), Cargas del hechizo (widget), Tiempo de reutilización del hechizo (widget), Destello de activación del hechizo (widget), Historial de lanzamientos (widget), Tiempo del historial de lanzamientos (widget), Hechizo al alcance (widget), Tiempo de recarga del hechizo (widget), Tótem concreto presente (widget), Tiempo restante de un tótem concreto (widget)

Dependencias

Código fuente

Conditions/common.lua, línea 82. Solo lectura en el juego; Duplicar crea una copia editable.

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

Volver a Referencia de funciones