You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

226 lines
8.4 KiB

5 years ago
-------------------------------------------------------------------------------
---------------------------------- NAMESPACE ----------------------------------
-------------------------------------------------------------------------------
local ADDON_NAME, ns = ...
local L = ns.locale
-------------------------------------------------------------------------------
--------------------------- UIDROPDOWNMENU_ADDSLIDER --------------------------
-------------------------------------------------------------------------------
4 years ago
local function UIDropDownMenu_AddSlider(info, level)
local function format(v)
5 years ago
if info.percentage then return FormatPercentage(v, true) end
4 years ago
return string.format('%.2f', v)
5 years ago
end
info.frame.Label:SetText(info.text)
info.frame.Value:SetText(format(info.value))
info.frame.Slider:SetMinMaxValues(info.min, info.max)
info.frame.Slider:SetMinMaxValues(info.min, info.max)
info.frame.Slider:SetValueStep(info.step)
4 years ago
info.frame.Slider:SetAccessorFunction(function() return info.value end)
info.frame.Slider:SetMutatorFunction(function(v)
5 years ago
info.frame.Value:SetText(format(v))
info.func(v)
end)
info.frame.Slider:UpdateVisibleState()
4 years ago
UIDropDownMenu_AddButton({customFrame = info.frame}, level)
5 years ago
end
-------------------------------------------------------------------------------
---------------------------- WORLD MAP BUTTON MIXIN ---------------------------
-------------------------------------------------------------------------------
local WorldMapOptionsButtonMixin = {}
4 years ago
_G[ADDON_NAME .. 'WorldMapOptionsButtonMixin'] = WorldMapOptionsButtonMixin
5 years ago
function WorldMapOptionsButtonMixin:OnLoad()
4 years ago
UIDropDownMenu_SetInitializeFunction(self.DropDown,
function(dropdown, level)
dropdown:GetParent():InitializeDropDown(level)
end)
UIDropDownMenu_SetDisplayMode(self.DropDown, 'MENU')
self.GroupDesc = CreateFrame('Frame', ADDON_NAME .. 'GroupMenuSliderOption',
nil, ADDON_NAME .. 'TextMenuOptionTemplate')
self.AlphaOption = CreateFrame('Frame',
ADDON_NAME .. 'AlphaMenuSliderOption', nil,
ADDON_NAME .. 'SliderMenuOptionTemplate')
self.ScaleOption = CreateFrame('Frame',
ADDON_NAME .. 'ScaleMenuSliderOption', nil,
ADDON_NAME .. 'SliderMenuOptionTemplate')
5 years ago
end
function WorldMapOptionsButtonMixin:OnMouseDown(button)
4 years ago
self.Icon:SetPoint('TOPLEFT', 8, -8)
5 years ago
local xOffset = WorldMapFrame.isMaximized and 30 or 0
4 years ago
self.DropDown.point = WorldMapFrame.isMaximized and 'TOPRIGHT' or 'TOPLEFT'
5 years ago
ToggleDropDownMenu(1, nil, self.DropDown, self, xOffset, -5)
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
end
function WorldMapOptionsButtonMixin:OnMouseUp()
4 years ago
self.Icon:SetPoint('TOPLEFT', self, 'TOPLEFT', 6, -6)
5 years ago
end
function WorldMapOptionsButtonMixin:OnEnter()
4 years ago
GameTooltip:SetOwner(self, 'ANCHOR_RIGHT')
5 years ago
GameTooltip_SetTitle(GameTooltip, ns.plugin_name)
4 years ago
GameTooltip_AddNormalLine(GameTooltip, L['map_button_text'])
5 years ago
GameTooltip:Show()
end
function WorldMapOptionsButtonMixin:Refresh()
local enabled = ns:GetOpt('show_worldmap_button')
local map = ns.maps[self:GetParent():GetMapID() or 0]
4 years ago
if enabled and map and map:HasEnabledGroups() then
self:Show()
else
self:Hide()
end
5 years ago
end
function WorldMapOptionsButtonMixin:InitializeDropDown(level)
local map, icon, iconLink = ns.maps[self:GetParent():GetMapID()]
if level == 1 then
UIDropDownMenu_AddButton({
isTitle = true,
notCheckable = true,
text = WORLD_MAP_FILTER_TITLE
})
for i, group in ipairs(map.groups) do
if group:IsEnabled() and group:HasEnabledNodes(map) then
icon = group.icon
if group.name == 'misc' then
-- find an icon from the misc nodes in the map
for coord, node in pairs(map.nodes) do
if node.group == group then
icon = node.icon
break
end
end
end
if type(icon) == 'number' then
4 years ago
iconLink = ns.GetIconLink(icon, 12, 1, 0) .. ' '
5 years ago
else
iconLink = ns.GetIconLink(icon, 16)
end
UIDropDownMenu_AddButton({
4 years ago
text = iconLink .. ' ' .. ns.RenderLinks(group.label, true),
5 years ago
isNotRadio = true,
keepShownOnClick = true,
hasArrow = true,
value = group,
checked = group:GetDisplay(map.id),
arg1 = group,
4 years ago
func = function(button, group)
5 years ago
group:SetDisplay(button.checked, map.id)
end
})
end
end
UIDropDownMenu_AddSeparator()
UIDropDownMenu_AddButton({
4 years ago
text = L['options_reward_types'],
5 years ago
isNotRadio = true,
notCheckable = true,
keepShownOnClick = true,
hasArrow = true,
value = 'rewards'
})
UIDropDownMenu_AddButton({
4 years ago
text = L['options_show_completed_nodes'],
5 years ago
isNotRadio = true,
keepShownOnClick = true,
checked = ns:GetOpt('show_completed_nodes'),
4 years ago
func = function(button, option)
5 years ago
ns:SetOpt('show_completed_nodes', button.checked)
end
})
UIDropDownMenu_AddButton({
4 years ago
text = L['options_toggle_hide_done_rare'],
5 years ago
isNotRadio = true,
keepShownOnClick = true,
checked = ns:GetOpt('hide_done_rares'),
4 years ago
func = function(button, option)
5 years ago
ns:SetOpt('hide_done_rares', button.checked)
end
})
UIDropDownMenu_AddButton({
4 years ago
text = L['options_toggle_use_char_achieves'],
5 years ago
isNotRadio = true,
keepShownOnClick = true,
checked = ns:GetOpt('use_char_achieves'),
4 years ago
func = function(button, option)
5 years ago
ns:SetOpt('use_char_achieves', button.checked)
end
})
UIDropDownMenu_AddSeparator()
UIDropDownMenu_AddButton({
4 years ago
text = L['options_open_settings_panel'],
5 years ago
isNotRadio = true,
notCheckable = true,
disabled = not map.settings,
4 years ago
func = function(button, option)
5 years ago
InterfaceOptionsFrame_Show()
InterfaceOptionsFrame_OpenToCategory('HandyNotes')
4 years ago
LibStub('AceConfigDialog-3.0'):SelectGroup('HandyNotes',
'plugins', ADDON_NAME, 'ZonesTab', 'Zone_' .. map.id)
5 years ago
end
})
elseif level == 2 then
if UIDROPDOWNMENU_MENU_VALUE == 'rewards' then
4 years ago
for i, type in ipairs({
'mount', 'pet', 'toy', 'transmog', 'all_transmog'
}) do
5 years ago
UIDropDownMenu_AddButton({
4 years ago
text = L['options_' .. type .. '_rewards'],
5 years ago
isNotRadio = true,
keepShownOnClick = true,
4 years ago
checked = ns:GetOpt('show_' .. type .. '_rewards'),
func = function(button, option)
ns:SetOpt('show_' .. type .. '_rewards', button.checked)
5 years ago
end
}, 2)
end
else
-- Get correct map ID to query/set options for
local group = UIDROPDOWNMENU_MENU_VALUE
self.GroupDesc.Text:SetText(ns.RenderLinks(group.desc))
4 years ago
UIDropDownMenu_AddButton({customFrame = self.GroupDesc}, 2)
UIDropDownMenu_AddButton({notClickable = true, notCheckable = true},
2)
5 years ago
UIDropDownMenu_AddSlider({
4 years ago
text = L['options_opacity'],
min = 0,
max = 1,
step = 0.01,
5 years ago
value = group:GetAlpha(map.id),
frame = self.AlphaOption,
percentage = true,
4 years ago
func = function(v) group:SetAlpha(v, map.id) end
5 years ago
}, 2)
UIDropDownMenu_AddSlider({
4 years ago
text = L['options_scale'],
min = 0.3,
max = 3,
step = 0.05,
5 years ago
value = group:GetScale(map.id),
frame = self.ScaleOption,
4 years ago
func = function(v) group:SetScale(v, map.id) end
5 years ago
}, 2)
end
end
4 years ago
end