레퍼런스 › 함수 레퍼런스 › Conditions

Conditions.common.Widget_SpellWidget

공개

호출 방법

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

addon을 통해 바로 쓸 수 있으며, 의존성이 필요 없습니다.

하는 일

사용자 조건 위젯용으로 제안, 검증, 주문 링크 지원이 있는 주문 입력을 만듭니다. 선택한 값의 저장은 갱신 콜백이 담당하며, 반환된 위젯을 콜백 부모에 추가하세요.

인수

이름유형하는 일
selfRMAddonRotation Master 애드온 인스턴스 (콜론 호출에서는 암묵적).
specnumber주문 제안 확인에 쓰는 전문화 범위.
editboxstring주문 제안에 쓰이는 Spec_EditBox 같은 참조 입력 종류.
valuetablespell, ranked, disabled 필드를 담은 조건 값 레코드. 그 자리에서 갱신됩니다.
nametoidfunction입력한 주문 이름을 ID로 대응시키는 확인기.
isvalidfunction제안된 주문 값을 검증하는 조건식.
updatefunction확정된 주문 값을 받는 콜백.

반환값

1RMConditionGroup동작 아이콘, 참조 입력, 선택적인 등급 컨트롤을 담은 주문 필드 그룹.

버전

기본 제공 도우미는 모든 버전에 등록됩니다. 다른 점은 읽는 게임 API이며, API가 없으면 도우미는 대체 동작을 하거나 이유와 함께 nil을 반환합니다.

  • 해당 버전에서 사용할 수 없음 (이유는 툴팁에 표시)
  • Blizzard의 지원 중단 대체 함수가 켜져 있을 때만
게임 APIClassic EraTBC AnniversaryClassic progressionForeverRetail
GameTooltipClassic EraTBC AnniversaryClassic progressionForeverRetail

애드온에서 호출하는 방식

외 19개: 소환수 주문 사용 가능 (widget), 소환수 주문 충전 (widget), 소환수 주문 재사용 대기시간 (widget), 소환수 주문 시전 기록 (widget), 소환수 주문 시전 기록 시간 (widget), 소환수 주문 사거리 내 (widget), 소환수 주문 충전 시간 (widget), 주문 활성 또는 대기 중 (widget), 주문 자동 반복 활성 (widget), 주문 사용 가능 (widget), 주문 충전 (widget), 주문 재사용 대기시간 (widget), 주문 발동 반짝임 (widget), 주문 시전 기록 (widget), 주문 시전 기록 시간 (widget), 주문 사거리 내 (widget), 주문 충전 시간 (widget), 특정 토템 있음 (widget), 특정 토템 남은 시간 (widget)

의존성

소스

Conditions/common.lua, 82번째 줄. 게임에서는 읽기 전용이며, 복제하면 편집 가능한 사본이 생깁니다.

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

함수 레퍼런스(으)로 돌아가기