Version 0.7.2-beta

- minimap button

- graphical move arrows

- crash on matches with 0-width
This commit is contained in:
2020-06-08 01:43:23 +02:00
parent 8e179692ee
commit 5b72ad3b78
18 changed files with 872 additions and 118 deletions

View File

@@ -22,7 +22,15 @@ function Grichelde:CreateOptionsUI()
desc = self:Format(self.L.Options_Enabled_Desc, self.L.AddonName),
disabled = false,
},
minimapButton = {
order = 1,
type = "toggle",
name = self.L.Options_Minimap_Button_Name,
desc = self.L.Options_Minimap_Button_Desc,
set = function(info, val) self:ToogleMinimapButton(info, val) end,
get = function(info) return not self.db.profile.minimapButton.hide end,
disabled = false,
},
channels = {
order = 2,
type = "group",
@@ -184,28 +192,28 @@ function Grichelde:CreateMapping(offset)
moveUp = {
order = 10,
type = "execute",
--name = self.L.Options_Mapping_MoveUp_Name,
-- name = self.L.Options_Mapping_MoveUp_Name,
name = "",
desc = self.L.Options_Mapping_MoveUp_Desc,
image = "Interface\\ChatFrame\\UI-ChatIcon-ScrollUp-Up",
width = 0.25,
image = Grichelde.ICONS.MOVE_UP,
width = 0.15,
func = function(info) self:MoveUp(info) end
},
moveDown = {
order = 11,
type = "execute",
--name = self.L.Options_Mapping_MoveDown_Name,
-- name = self.L.Options_Mapping_MoveDown_Name,
name = "",
desc = self.L.Options_Mapping_MoveDown_Desc,
image = "Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up",
width = 0.25,
image = Grichelde.ICONS.MOVE_DOWN,
width = 0.15,
func = function(info) self:MoveDown(info) end
},
spacer = {
order = 18,
type = "description",
name = "",
width = 1,
width = 1.2,
},
delete = {
order = 19,
@@ -221,14 +229,6 @@ function Grichelde:CreateMapping(offset)
}
end
--dropButton:SetWidth(24)
--dropButton:SetHeight(24)
--dropButton:SetPoint("TOPRIGHT", DRight, "TOPRIGHT", -16, -18)
--dropButton:SetNormalTexture([[Interface\ChatFrame\UI-ChatIcon-ScrollDown-Up]])
--dropButton:SetPushedTexture([[Interface\ChatFrame\UI-ChatIcon-ScrollDown-Down]])
--dropButton:SetDisabledTexture([[Interface\ChatFrame\UI-ChatIcon-ScrollDown-Disabled]])
--dropButton:SetHighlightTexture([[Interface\Buttons\UI-Common-MouseHilight]], "ADD")
function Grichelde:SetupOptions()
-- add DB-backed profiles to UI options
local options = self:CreateOptionsUI()
@@ -243,25 +243,6 @@ function Grichelde:SetupOptions()
return options, dialog
end
function Grichelde:IsDisabled(info)
if info.option.type == "group" then
return false
end
return not self.db.profile.enabled
end
function Grichelde:MappingName(info)
-- self:TracePrint("MappingName : info")
-- self:TracePrint(info)
local option = self.db.profile.replacements[info[2]]
if nilOrEmpty(option.searchText) and nilOrEmpty(option.replaceText) then
return self.L.Options_Mapping_EmptyMapping
else
return self:Format(self.L.Options_Mapping_Group_Name, option.searchText or "", option.replaceText or "")
end
end
function Grichelde:RefreshOptions(event)
self:DebugPrint("RefreshOptions : event:", event)
if event == "OnNewProfile" then
@@ -282,6 +263,87 @@ function Grichelde:RefreshOptions(event)
self:RefreshReplacements(self.db.profile.replacements)
end
--- add Minimap button
function Grichelde:MinimapButton()
local function toggleOptionsUI(_, button)
if button == 'LeftButton' then
self:ToggleOptions()
elseif button == 'RightButton' then
self:ToogleMappings()
end
end
local function tooltip(tooltip)
if not tooltip or not tooltip.AddLine then return end
tooltip:SetText(self.L.AddonName,
Grichelde.COLORS.HIGHLIGHT.r, Grichelde.COLORS.HIGHLIGHT.g, Grichelde.COLORS.HIGHLIGHT.b, Grichelde.COLORS.HIGHLIGHT.a
)
tooltip:AddDoubleLine(self.L.Options_Minimap_Tooltip_Options_Left, self.L.Options_Minimap_Tooltip_Options_Right,
Grichelde.COLORS.GREEN.r, Grichelde.COLORS.GREEN.g, Grichelde.COLORS.GREEN.b, Grichelde.COLORS.GREEN.a,
Grichelde.COLORS.NORMAL.r, Grichelde.COLORS.NORMAL.g, Grichelde.COLORS.NORMAL.b, Grichelde.COLORS.NORMAL.a
)
tooltip:AddDoubleLine(self.L.Options_Minimap_Tooltip_Mappings_Left, self.L.Options_Minimap_Tooltip_Mappings_Right,
Grichelde.COLORS.GREEN.r, Grichelde.COLORS.GREEN.g, Grichelde.COLORS.GREEN.b, Grichelde.COLORS.GREEN.a,
Grichelde.COLORS.NORMAL.r, Grichelde.COLORS.NORMAL.g, Grichelde.COLORS.NORMAL.b, Grichelde.COLORS.NORMAL.a
)
end
local ldb = LibStub("LibDataBroker-1.1"):NewDataObject(self.name, {
type = "launcher",
text = self.AddonName,
icon = "Interface\\Icons\\Spell_Holy_Silence",
--icon = ([[Interface\Addons\%s\%s]]):format(self.name, self.name),
OnClick = toggleOptionsUI,
OnRightClick = function() self:ShowMappings() end,
OnTooltipShow = tooltip,
})
local icon = LibStub("LibDBIcon-1.0")
self:DebugPrint("MinimapButton : hidden: ", self.db.profile.minimapButton.hide)
icon:Register(self.name, ldb, self.db.profile.minimapButton)
return ldb, icon
end
function Grichelde:ToggleOptions()
self:DebugPrint("MinimapButton : options open: ", self.dialog.OpenFrames[self.name])
if self.dialog.OpenFrames[self.name] then
self:CloseOptions()
else
self:OpenOptions()
end
end
function Grichelde:OpenOptions()
self.dialog:Open(self.name)
end
function Grichelde:CloseOptions()
self.dialog:Close(self.name)
end
function Grichelde:IsDisabled(info)
if info.option.type == "group" then
return false
end
return not self.db.profile.enabled
end
function Grichelde:MappingName(info)
-- self:TracePrint("MappingName : info")
-- self:TracePrint(info)
local option = self.db.profile.replacements[info[2]]
if nilOrEmpty(option.searchText) and nilOrEmpty(option.replaceText) then
return self.L.Options_Mapping_EmptyMapping
else
return self:Format(self.L.Options_Mapping_Group_Name, option.searchText or "", option.replaceText or "")
end
end
--- Create UI options for rhe given replacement table (from DB).
--- Usually called with with self.db.profile.replacements
-- @param replacementsTable
@@ -440,3 +502,21 @@ function Grichelde:DeleteAllMappings()
self:RefreshOptions("DeleteAllMappings")
end
function Grichelde:ToogleMinimapButton(info, val)
self:TracePrint("ToogleMinimapButton : info")
for i = 0, #info do
self:TracePrint("%d = %s", i, info[i])
end
self.db.profile.minimapButton.hide = not val
self:DebugPrint("ToogleMinimapButton : hidden: ", self.db.profile.minimapButton.hide)
if self.db.profile.minimapButton.hide then
self.icon:Hide(self.name);
else
self.icon:Show(self.name);
end
end