Version 0.9.1-rc

- emote detection mixed in other channels
- minimap button and dialog no longer resets active state after profile change
- default entries are no longer shown after example import
- better handling of capture groups and character sets
This commit is contained in:
2020-08-01 01:35:47 +02:00
parent bafb116bb9
commit 45099a9a3b
17 changed files with 326 additions and 163 deletions

View File

@@ -406,24 +406,48 @@ function Grichelde:SetupOptions()
return options, dialog
end
function Grichelde:RefreshOptions(event, _, profileName)
self:DebugPrint("RefreshOptions : event:", event)
function Grichelde:RefreshProfiles(event, _, profileName)
local function replaceReplacements(replacements)
-- do NOT set self.db.profile.replacements = {} it will break defaults
tWipe(self.db.profile.replacements)
-- copy over sorted replacements
for replName, replTable in pairs(replacements) do
self.db.profile.replacements[replName] = replTable
end
self:DebugPrint("RefreshProfiles : reorderReplacements : sorted table")
self:DebugPrint(self.db.profile.replacements)
end
local function addEmptyMappingWithoutRefresh()
self:DebugPrint("RefreshProfiles : addEmptyMappingWithoutRefresh")
self.db.profile.replacements.replacement_10.order = 10
end
self:DebugPrint("RefreshProfiles : event:", event)
--- AceDB will call OnProfileShutdown, OnProfileChanged and OnNewProfile in this order
if (event == "OnNewProfile") then
addEmptyMappingWithoutRefresh()
self:PrefixedPrint(self.L.Profiles_Created, cGreen(self.db:GetCurrentProfile()))
elseif (event == "OnProfileChanged") then
self:PrefixedPrint(self.L.Profiles_Loaded, cGreen(self.db:GetCurrentProfile()))
self:DebugPrint(self.L.Profiles_Loaded, cGreen(self.db:GetCurrentProfile()))
elseif (event == "OnProfileDeleted") then
self:PrefixedPrint(self.L.Profiles_Deleted, cRed(profileName))
elseif (event == "OnProfileCopied") then
self:PrefixedPrint(self.L.Profiles_Copied, cOrange(profileName))
self:DebugPrint(self.L.Profiles_Copied, cOrange(profileName))
elseif (event == "OnProfileReset") then
addEmptyMappingWithoutRefresh()
self:PrefixedPrint(self.L.Profiles_Reset, cOrange(self.db:GetCurrentProfile()))
else
self:DebugPrint("Refreshing Profile %s on options change: %s", self.db:GetCurrentProfile(), event)
end
self:ReorderReplacements()
self:RefreshReplacements(self.db.profile.replacements)
local repls = self:ReorderReplacements()
replaceReplacements(repls)
self:RefreshOptions(repls)
self:RefreshDialog()
self:RefreshMinimap()
end
function Grichelde:ToggleOptions()
@@ -556,19 +580,17 @@ function Grichelde:ImportExample(num)
self.db:SetProfile(profileName)
assert(self.db:GetCurrentProfile() == profileName, "profile was not loaded")
local exampleProfile = self.db.profile
tWipe(exampleProfile.replacements)
tWipe(self.db.profile.replacements)
for replName, replTable in spairs(self.L.Options_Help_Examples[num].replacements) do
self:TracePrint("ImportExample : replacement: %s", replName)
self:TracePrint(replTable)
if (replName ~= nil) and (replTable ~= nil) and (replTable.searchText ~= nil) then
exampleProfile.replacements[replName] = tClone(replTable)
self.db.profile.replacements[replName] = tClone(replTable)
end
end
self:RefreshReplacements(self.db.profile.replacements)
self:RefreshProfiles("ImportExample" .. num)
else
self:ErrorPrint(self.L.Profiles_AlreadyExistsError, profileName)
end
@@ -577,8 +599,8 @@ end
--- Create UI options for the given replacement table (from DB).
--- Usually called with with self.db.profile.replacements
-- @param replacementsTable
function Grichelde:RefreshReplacements(replacementsTable)
self:TracePrint("RefreshReplacements : DB table:")
function Grichelde:RefreshOptions(replacementsTable)
self:TracePrint("RefreshOptions : DB table:")
self:TracePrint(replacementsTable)
-- remove all previous replacements from options (not DB), except header and buttons
@@ -594,9 +616,11 @@ function Grichelde:RefreshReplacements(replacementsTable)
replacements[replName] = self:CreateMapping(toNumber(replNumber))
end
-- self:TracePrint("RefreshReplacements : UI options:")
-- self:TracePrint("RefreshOptions : UI options:")
-- self:TracePrint(replacements)
end
function Grichelde:RefreshDialog()
self.dialog:ConfigTableChanged(nil, self.name)
end
@@ -606,7 +630,7 @@ function Grichelde:AddEmptyMapping()
self:DebugPrint("AddEmptyMapping : old DB entries:")
self:DebugPrint(replacements)
local maxRepl = Grichelde.MAPPING_OFFSET
local maxRepl = Grichelde.MAPPING_OFFSET - 1
for replName, _ in pairs(replacements) do
local num = match(replName, "^replacement_(%d+)")
if (num ~= nil) and (maxRepl < toNumber(num)) then
@@ -622,7 +646,7 @@ function Grichelde:AddEmptyMapping()
self:DebugPrint("AddEmptyMapping : new DB entries:")
self:DebugPrint(replacements)
self:RefreshOptions("AddEmptyMapping " .. newMapping)
self:RefreshProfiles("AddEmptyMapping " .. newMapping)
self.dialog:SelectGroup(self.name, "replacements", newMapping)
end
@@ -651,7 +675,7 @@ function Grichelde:MoveUp(info)
replacements[swapName].order = currentOrder
replacements[currentName].order = currentOrder - 1
self:RefreshOptions("MoveUp " .. currentName)
self:RefreshProfiles("MoveUp " .. currentName)
self:DebugPrint("MoveUp : refresh focus on %s", swapName)
self.dialog:SelectGroup(self.name, "replacements", swapName)
@@ -694,7 +718,7 @@ function Grichelde:MoveDown(info)
replacements[swapName].order = currentOrder
replacements[currentName].order = currentOrder + 1
self:RefreshOptions("MoveDown " .. currentName)
self:RefreshProfiles("MoveDown " .. currentName)
self:DebugPrint("MoveDown : refresh focus on %s", swapName)
self.dialog:SelectGroup(self.name, "replacements", swapName)
@@ -774,7 +798,7 @@ function Grichelde:DeleteMapping(info)
self:DebugPrint("delete option: %s", currentName)
self.db.profile.replacements[currentName] = nil
self:RefreshOptions("DeleteMapping " .. currentName)
self:RefreshProfiles("DeleteMapping " .. currentName)
local _, replNumber = self:SplitOnFirstMatch(currentName, "_")
local newMapping = "replacement_" .. toNumber(replNumber - 1)
@@ -788,5 +812,5 @@ function Grichelde:DeleteAllMappings()
tWipe(self.db.profile.replacements)
self:AddEmptyMapping()
self:RefreshOptions("DeleteAllMappings")
self:RefreshProfiles("DeleteAllMappings")
end