<Ui xmlns="http://www.blizzard.com/wow/ui/">
	<Script file="Mog.lua"/>
	<Script file="AppearanceTooltip.lua"/>
	<!--Script file="TransmogCleanup.lua"/-->
	<Script file="TransmogHeadsUp.lua"/>
    <Script file="MogPartialSets.lua"/>
    <Button name="MogPartialSets_FilterButton" inherits="UIMenuButtonStretchTemplate" text="FILTER" hidden="true">
        <Size x="93" y="22"/>

        <Layers>
            <Layer level="ARTWORK">
                <Texture parentKey="Icon" file="Interface\ChatFrame\ChatFrameExpandArrow">
                    <Size x="10" y="12"/>

                    <Anchors>
                        <Anchor point="RIGHT" relativeKey="$parent.Right" x="-5"/>
                    </Anchors>
                </Texture>
            </Layer>
        </Layers>

        <Scripts>
            <OnClick>
                PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
                MogPartialSets_Filter:SetShown(not MogPartialSets_Filter:IsShown())
            </OnClick>
        </Scripts>
    </Button>

    <Frame name="MogPartialSets_FilterRowTemplate" virtual="true">
        <Size x="160" y="23"/>

        <Layers>
            <Layer>
                <FontString parentKey="Title" inherits="GameFontHighlightSmall" wordwrap="false">
                    <Size x="0" y="10"/>

                    <Anchors>
                        <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="25" y="-6"/>
                    </Anchors>
                </FontString>
            </Layer>
        </Layers>

        <Scripts>
            <OnLoad>
                self.Title:SetText(self.label)
            </OnLoad>
        </Scripts>
    </Frame>

    <CheckButton name="MogPartialSets_FilterCheckboxTemplate" inherits="UICheckButtonTemplate" virtual="true">
        <Size x="24" y="24"/>

        <HitRectInsets>
            <AbsInset left="0" right="-130" top="0" bottom="0"/>
        </HitRectInsets>

        <Anchors>
            <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="0" y="0"/>
        </Anchors>

        <Scripts>
            <OnShow>
                self:SetChecked(MogPartialSetsAddon.config.db[self.configKey])
            </OnShow>
            <OnClick>
                MogPartialSetsAddon.config.db[self.configKey] = self:GetChecked()
                MogPartialSetsAddon.ui.filter.onChange()
            </OnClick>
        </Scripts>
    </CheckButton>

    <Frame name="MogPartialSets_FilterSlotTemplate" virtual="true">
        <Size x="149" y="23"/>

        <Layers>
            <Layer>
                <FontString parentKey="Title" inherits="GameFontHighlightSmall" wordwrap="false">
                    <Size x="0" y="10"/>

                    <Anchors>
                        <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="0" y="-6"/>
                    </Anchors>
                </FontString>

                <Texture parentKey="Divider" atlas="Options_HorizontalDivider" hidden="true">
                    <Size>
                        <AbsDimension x="160" y="1"/>
                    </Size>

                    <Anchors>
                        <Anchor point="TOPLEFT" x="0" y="-20"/>
                    </Anchors>
                </Texture>
            </Layer>
        </Layers>

        <Scripts>
            <OnLoad>self.Title:SetText(self.label)</OnLoad>
            <OnEnter>self.Divider:Show()</OnEnter>
            <OnLeave>self.Divider:Hide()</OnLeave>
        </Scripts>

        <Frames>
            <CheckButton parentKey="Ignored" inherits="UICheckButtonTemplate">
                <Size x="18" y="18"/>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="70" y="-2"/>
                </Anchors>

                <Scripts>
                    <OnShow>
                        self:SetChecked(MogPartialSetsAddon.config.isIgnoredSlot(self:GetParent().slot))
                    </OnShow>
                    <OnClick>
                        local slot = self:GetParent().slot

                        if self:GetChecked() then
                            MogPartialSetsAddon.config.setIgnoredSlot(slot, true)
                            MogPartialSetsAddon.config.setHiddenSlot(slot, false)
                            self:GetParent().Hidden:SetChecked(false)
                        else
                            MogPartialSetsAddon.config.setIgnoredSlot(slot, false)
                        end

                        MogPartialSetsAddon.ui.filter.onChange()
                    </OnClick>
                    <OnEnter>self:GetParent().Divider:Show()</OnEnter>
                    <OnLeave>self:GetParent().Divider:Hide()</OnLeave>
                </Scripts>
            </CheckButton>

            <CheckButton parentKey="Hidden" inherits="UICheckButtonTemplate">
                <Size x="18" y="18"/>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="120" y="-2"/>
                </Anchors>

                <Scripts>
                    <OnShow>
                        self:SetChecked(MogPartialSetsAddon.config.isHiddenSlot(self:GetParent().slot))
                    </OnShow>
                    <OnClick>
                        local slot = self:GetParent().slot

                        if self:GetChecked() then
                            MogPartialSetsAddon.config.setHiddenSlot(slot, true)
                            MogPartialSetsAddon.config.setIgnoredSlot(slot, false)
                            self:GetParent().Ignored:SetChecked(false)
                        else
                            MogPartialSetsAddon.config.setHiddenSlot(slot, false)
                        end

                        MogPartialSetsAddon.ui.filter.onChange()
                    </OnClick>
                    <OnEnter>self:GetParent().Divider:Show()</OnEnter>
                    <OnLeave>self:GetParent().Divider:Hide()</OnLeave>
                </Scripts>
            </CheckButton>
        </Frames>
    </Frame>

    <Frame name="MogPartialSets_Filter" hidden="true" frameStrata="DIALOG" inherits="TooltipBackdropTemplate" enableMouse="true">
        <Size x="185" y="400"/>

        <Anchors>
            <Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="MogPartialSets_FilterButton" x="-10" y="-5"/>
        </Anchors>

        <KeyValues>
            <KeyValue key="backdropColor" value="BLACK_FONT_COLOR" type="global"/>
            <KeyValue key="backdropColorAlpha" value="0.9" type="number"/>
            <KeyValue key="backdropBorderColor" value="TOOLTIP_DEFAULT_COLOR" type="global"/>
        </KeyValues>

        <Layers>
            <Layer>
                <FontString inherits="GameFontHighlightSmall" wordwrap="false" text="装备部位">
                    <Size>
                        <AbsDimension x="0" y="10"/>
                    </Size>

                    <Anchors>
                        <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="18" y="-130"/>
                    </Anchors>
                </FontString>

                <Texture atlas="Options_HorizontalDivider">
                    <Size>
                        <AbsDimension x="160" y="1"/>
                    </Size>

                    <Anchors>
                        <Anchor point="TOPLEFT" x="12" y="-143"/>
                    </Anchors>
                </Texture>

                <FontString inherits="GameFontNormalGraySmall" wordwrap="false" text="部位">
                    <Size>
                        <AbsDimension x="0" y="10"/>
                    </Size>

                    <Anchors>
                        <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="18" y="-149"/>
                    </Anchors>
                </FontString>

                <FontString inherits="GameFontNormalGraySmall" wordwrap="false" justifyH="CENTER" text="忽略">
                    <Size>
                        <AbsDimension x="50" y="10"/>
                    </Size>

                    <Anchors>
                        <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="72" y="-149"/>
                    </Anchors>
                </FontString>

                <FontString inherits="GameFontNormalGraySmall" wordwrap="false" justifyH="CENTER" text="隐藏">
                    <Size>
                        <AbsDimension x="50" y="10"/>
                    </Size>

                    <Anchors>
                        <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="122" y="-149"/>
                    </Anchors>
                </FontString>
            </Layer>
        </Layers>

        <Scripts>
            <OnShow>
                -- anchor relative to the filter button but make sure it is not offscreen
                local xOffscreenOffset = math.max(0, MogPartialSets_FilterButton:GetRight() + self:GetWidth() - GetScreenWidth())

                local xOffset = -10 - xOffscreenOffset
                local yOffset = -5

                if xOffscreenOffset > 10 then
                    yOffset = yOffset - 15
                end

                self:ClearAllPoints()
                self:SetPoint('TOPLEFT', MogPartialSets_FilterButton, 'TOPRIGHT', xOffset, yOffset)

                -- update states on show
                MogPartialSetsAddon.ui.filter.updateStates()
            </OnShow>
        </Scripts>

        <Frames>
            <Frame parentKey="ShowExtraSetsToggle" inherits="MogPartialSets_FilterRowTemplate">
                <KeyValues>
                    <KeyValue key="label" value="显示额外套装"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="12" y="-10"/>
                </Anchors>

                <Frames>
                    <CheckButton inherits="MogPartialSets_FilterCheckboxTemplate">
                        <KeyValues>
                            <KeyValue key="configKey" value="showExtraSets"/>
                        </KeyValues>
                    </CheckButton>
                </Frames>
            </Frame>

            <Frame parentKey="OnlyFavoriteToggle" inherits="MogPartialSets_FilterRowTemplate">
                <KeyValues>
                    <KeyValue key="label" value="仅显示收藏套装"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="12" y="-32"/>
                </Anchors>

                <Frames>
                    <CheckButton inherits="MogPartialSets_FilterCheckboxTemplate">
                        <KeyValues>
                            <KeyValue key="configKey" value="onlyFavorite"/>
                        </KeyValues>
                    </CheckButton>
                </Frames>
            </Frame>

            <Frame parentKey="FavoriteVariantsToggle" inherits="MogPartialSets_FilterRowTemplate">
                <KeyValues>
                    <KeyValue key="label" value="显示套装换色版"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="12" y="-54"/>
                </Anchors>

                <Frames>
                    <CheckButton inherits="MogPartialSets_FilterCheckboxTemplate">
                        <KeyValues>
                            <KeyValue key="configKey" value="favoriteVariants"/>
                        </KeyValues>
                    </CheckButton>
                </Frames>
            </Frame>

            <Frame parentKey="UseHiddenIfMissingToggle" inherits="MogPartialSets_FilterRowTemplate">
                <KeyValues>
                    <KeyValue key="label" value="隐藏缺失部件"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="12" y="-76"/>
                </Anchors>

                <Frames>
                    <CheckButton inherits="MogPartialSets_FilterCheckboxTemplate">
                        <KeyValues>
                            <KeyValue key="configKey" value="useHiddenIfMissing"/>
                        </KeyValues>
                    </CheckButton>
                </Frames>
            </Frame>

            <Frame parentKey="HideItemsNotInSetToggle" inherits="MogPartialSets_FilterRowTemplate">
                <KeyValues>
                    <KeyValue key="label" value="hide items not in set"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="12" y="-98"/>
                </Anchors>

                <Frames>
                    <CheckButton inherits="MogPartialSets_FilterCheckboxTemplate">
                        <KeyValues>
                            <KeyValue key="configKey" value="hideItemsNotInSet"/>
                        </KeyValues>
                    </CheckButton>
                </Frames>
            </Frame>

            <Frame parentKey="MaxMissingPieces" inherits="MogPartialSets_FilterRowTemplate">
                <KeyValues>
                    <KeyValue key="label" value="最大缺失部件"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="12" y="-98"/>
                </Anchors>

                <Frames>
                    <EditBox name="$parentMaxMissingPiecesEditBox" inherits="InputBoxTemplate" autoFocus="false" letters="1" numeric="true">
                        <Size>
                            <AbsDimension x="13" y="20"/>
                        </Size>

                        <Anchors>
                            <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="8" y="0"/>
                        </Anchors>

                        <Scripts>
                            <OnShow>self:SetText(tostring(MogPartialSetsAddon.config.db.maxMissingPieces))</OnShow>
                            <OnEscapePressed>self:ClearFocus()</OnEscapePressed>
                            <OnEnterPressed>self:ClearFocus()</OnEnterPressed>
                            <OnTextChanged>
                                local maxMissingPieces = tonumber(self:GetText())

                                if maxMissingPieces ~= nil then
                                    MogPartialSetsAddon.config.db.maxMissingPieces = maxMissingPieces
                                    MogPartialSetsAddon.ui.filter.onChange()
                                end
                            </OnTextChanged>
                        </Scripts>
                    </EditBox>
                </Frames>
            </Frame>

            <Frame parentKey="HeadSlot" inherits="MogPartialSets_FilterSlotTemplate">
                <KeyValues>
                    <KeyValue key="label" value="头部"/>
                    <KeyValue key="slot" value="INVSLOT_HEAD" type="global"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="18" y="-162"/>
                </Anchors>
            </Frame>

            <Frame parentKey="ShoulderSlot" inherits="MogPartialSets_FilterSlotTemplate">
                <KeyValues>
                    <KeyValue key="label" value="肩部"/>
                    <KeyValue key="slot" value="INVSLOT_SHOULDER" type="global"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="18" y="-184"/>
                </Anchors>
            </Frame>

            <Frame parentKey="CloakSlot" inherits="MogPartialSets_FilterSlotTemplate">
                <KeyValues>
                    <KeyValue key="label" value="披风"/>
                    <KeyValue key="slot" value="INVSLOT_BACK" type="global"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="18" y="-206"/>
                </Anchors>
            </Frame>

            <Frame parentKey="ChestSlot" inherits="MogPartialSets_FilterSlotTemplate">
                <KeyValues>
                    <KeyValue key="label" value="胸部"/>
                    <KeyValue key="slot" value="INVSLOT_CHEST" type="global"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="18" y="-228"/>
                </Anchors>
            </Frame>

            <Frame parentKey="WristSlot" inherits="MogPartialSets_FilterSlotTemplate">
                <KeyValues>
                    <KeyValue key="label" value="手腕"/>
                    <KeyValue key="slot" value="INVSLOT_WRIST" type="global"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="18" y="-250"/>
                </Anchors>
            </Frame>

            <Frame parentKey="HandsSlot" inherits="MogPartialSets_FilterSlotTemplate">
                <KeyValues>
                    <KeyValue key="label" value="手部"/>
                    <KeyValue key="slot" value="INVSLOT_HAND" type="global"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="18" y="-272"/>
                </Anchors>
            </Frame>

            <Frame parentKey="WaistSlot" inherits="MogPartialSets_FilterSlotTemplate">
                <KeyValues>
                    <KeyValue key="label" value="腰部"/>
                    <KeyValue key="slot" value="INVSLOT_WAIST" type="global"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="18" y="-294"/>
                </Anchors>
            </Frame>

            <Frame parentKey="LegsSlot" inherits="MogPartialSets_FilterSlotTemplate">
                <KeyValues>
                    <KeyValue key="label" value="腿部"/>
                    <KeyValue key="slot" value="INVSLOT_LEGS" type="global"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="18" y="-316"/>
                </Anchors>
            </Frame>

            <Frame parentKey="FeetSlot" inherits="MogPartialSets_FilterSlotTemplate">
                <KeyValues>
                    <KeyValue key="label" value="足部"/>
                    <KeyValue key="slot" value="INVSLOT_FEET" type="global"/>
                </KeyValues>

                <Anchors>
                    <Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="18" y="-338"/>
                </Anchors>
            </Frame>

            <Button parentKey="OkButton" inherits="UIPanelButtonTemplate" text="确定">
                <Size x="78" y="20"/>
                <Anchors>
                    <Anchor point="BOTTOMLEFT" relativePoint="BOTTOMLEFT" x="12" y="10"/>
                </Anchors>
                <Scripts>
                    <OnClick>MogPartialSetsAddon.ui.filter.hide()</OnClick>
                </Scripts>
            </Button>

            <Button parentKey="RefreshButton" inherits="UIPanelButtonTemplate" text="刷新">
                <Size x="78" y="20"/>
                <Anchors>
                    <Anchor point="BOTTOMLEFT" relativePoint="BOTTOMLEFT" x="94" y="10"/>
                </Anchors>
                <Scripts>
                    <OnClick>MogPartialSetsAddon.ui.filter.onRefreshClicked()</OnClick>
                </Scripts>
            </Button>
        </Frames>
    </Frame>
	<!--Frame name="AppearanceNameFrameTemplate" virtual="true">
		<Anchors>
			<Anchor point="TOPLEFT" relativePoint="TOPLEFT" x="0" y="0"/>
			<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMRIGHT" x="0" y="0"/>
		</Anchors>
		<Layers>
			<Layer level="OVERLAY">
				<FontString inherits="GameFontNormal" justifyV="BOTTOM" justifyH="LEFT" wordwrap="true" parentKey="name" text="Loading...">
					<Color r="1" g="1" b="1"/>
					<Anchors>
						<Anchor point="BOTTOMLEFT" relativePoint="BOTTOMLEFT" x="3" y="3"/>
						<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMRIGHT" x="-3" y="3"/>
					</Anchors>
				</FontString>	
			</Layer>
		</Layers>
	</Frame>
<Script file="AppearanceName.lua"/-->
</Ui>
