Skip to content

Commit

Permalink
Added functions for creating a custom condition.
Browse files Browse the repository at this point in the history
TODO:
  - Help
  - Import/Export
  - Add & Duplicate should select new entry
  - Fixed update() call on add causing an error.
  - Custom functions filter in condition list.
  • Loading branch information
corporategoth committed Sep 11, 2022
1 parent 79ebe6b commit 86e2614
Show file tree
Hide file tree
Showing 10 changed files with 1,745 additions and 6 deletions.
1,263 changes: 1,263 additions & 0 deletions LibsAugment/FAIAP.lua

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ L["Bottom Center"] = true
L["Left Center"] = true
L["Right Center"] = true

L["Select Icon"] = true
L["Key"] = true
L["Edit Condition"] = true
L["Description"] = true
L["Validity Function"] = true
L["Evaluation Function"] = true
L["Print Function"] = true
L["Widget Function"] = true
L["Help Function"] = true

L["Warrior"] = true
L["Paladin"] = true
L["Hunter"] = true
Expand Down
5 changes: 4 additions & 1 deletion Options/conditional.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ local cleanArray, deepcopy, wrap, HideOnEscape = addon.cleanArray, addon.deepcop
local evaluateArray, evaluateSingle, printArray, printSingle, validateArray, validateSingle, usefulArray, usefulSingle

local conditions = {}

local special = {}
special["DELETE"] = { desc = DELETE, icon = "Interface\\Icons\\Trade_Engineering" }
special["AND"] = { desc = L["AND"], icon = "Interface\\Icons\\Spell_ChargePositive" }
Expand Down Expand Up @@ -631,6 +630,10 @@ function addon:RegisterCondition(tag, array)
conditions[tag] = array
end

function addon:UnregisterCondition(tag)
conditions[tag] = nil
end

function addon:EditCondition(index, spec, value, callback)
local funcs = {
print = addon.printCondition,
Expand Down
85 changes: 82 additions & 3 deletions Options/conditions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local L = LibStub("AceLocale-3.0"):GetLocale("RotationMaster")
local AceGUI = LibStub("AceGUI-3.0")

local color, table, pairs, ipairs = color, table, pairs, ipairs
local wrap, HideOnEscape = addon.wrap, addon.HideOnEscape
local wrap, HideOnEscape, deepcopy= addon.wrap, addon.HideOnEscape, addon.deepcopy

local special = {}
special["DELETE"] = { desc = DELETE, icon = "Interface\\Icons\\Trade_Engineering" }
Expand Down Expand Up @@ -364,6 +364,13 @@ end
local function layout_bottom_window(frame, group, selected, update)
local profile = addon.db.profile

local function spacer(rs)
local rv = AceGUI:Create("Label")
rv:SetUserData("cell", { rowspan = rs })
rv:SetFullWidth(true)
return rv
end

frame:ReleaseChildren()
frame:PauseLayout()

Expand All @@ -375,7 +382,7 @@ local function layout_bottom_window(frame, group, selected, update)
local grid = AceGUI:Create("SimpleGroup")
grid:SetFullWidth(true)
grid:SetLayout("Table")
grid:SetUserData("table", { columns = { 200, 50, 320 } })
grid:SetUserData("table", { columns = { 180, 50, 40, 30, 30, 20, 230 } })
frame:AddChild(grid)

local switch = AceGUI:Create("CheckBox")
Expand All @@ -398,6 +405,7 @@ local function layout_bottom_window(frame, group, selected, update)

local directional = AceGUI:Create("Directional")
directional:SetDisabled(group == "ALL" or not selected)
directional:DisableCenter(true)
directional:SetUserData("cell", { rowspan = 2 })
directional:SetCallback("OnClick", function(_, _, _, direction)
local current_conds = addon:listConditions(group)
Expand Down Expand Up @@ -478,6 +486,40 @@ local function layout_bottom_window(frame, group, selected, update)
end)
grid:AddChild(directional)

grid:AddChild(spacer(2))

local add = AceGUI:Create("Icon")
add:SetImageSize(28, 28)
add:SetUserData("cell", { alignV = "bottom" })
add:SetImage("Interface\\Minimap\\UI-Minimap-ZoomInButton-Up")
add:SetCallback("OnClick", function()
addon:condition_edit_box(function()
update()
end)
end)
addon.AddTooltip(add, ADD)
grid:AddChild(add)

local edit = AceGUI:Create("Icon")
edit:SetImageSize(28, 28)
edit:SetUserData("cell", { alignV = "bottom" })
if not selected or addon.db.global.custom_conditions[selected] == nil then
edit:SetImage("Interface\\AddOns\\RotationMaster\\textures\\UI-FriendsList-Large-Disabled")
edit:SetDisabled(true)
else
edit:SetImage("Interface\\FriendsFrame\\UI-FriendsList-Large-Up")
edit:SetDisabled(false)
end
edit:SetCallback("OnClick", function()
addon:condition_edit_box(function()
update()
end, selected, addon.db.global.custom_conditions[selected])
end)
addon.AddTooltip(edit, EDIT)
grid:AddChild(edit)

grid:AddChild(spacer(2))

local group_sel = {}
local group_sel_order = {}
for _, v in pairs(profile.condition_groups) do
Expand Down Expand Up @@ -556,6 +598,43 @@ local function layout_bottom_window(frame, group, selected, update)
end)
grid:AddChild(hidden)

local delete = AceGUI:Create("Icon")
delete:SetImageSize(28, 28)
delete:SetUserData("cell", { alignV = "top" })
if not selected or addon.db.global.custom_conditions[selected] == nil then
delete:SetImage("Interface\\Buttons\\UI-Panel-MinimizeButton-Disabled")
delete:SetDisabled(true)
else
delete:SetImage("Interface\\Buttons\\UI-Panel-MinimizeButton-Up")
delete:SetDisabled(false)
end
delete:SetCallback("OnClick", function()
addon:UnregisterCondition(selected)
addon.db.global.custom_conditions[selected] = nil
update()
end)
addon.AddTooltip(delete, DELETE)
grid:AddChild(delete)

local duplicate = AceGUI:Create("Icon")
duplicate:SetImageSize(28, 28)
duplicate:SetUserData("cell", { alignV = "bottom" })
if not selected or addon.db.global.custom_conditions[selected] == nil then
duplicate:SetImage("Interface\\AddOns\\RotationMaster\\textures\\UI-ChatIcon-Maximize-Disabled")
duplicate:SetDisabled(true)
else
duplicate:SetImage("Interface\\ChatFrame\\UI-ChatIcon-Maximize-Up")
duplicate:SetDisabled(false)
end
duplicate:SetCallback("OnClick", function()
local newkey = selected .. "_" .. date("%Y%m%d%H%M%S")
addon.db.global.custom_conditions[newkey] = deepcopy(addon.db.global.custom_conditions[selected])
addon:register_custom_condition(newkey, addon.db.global.custom_conditions[newkey])
update()
end)
addon.AddTooltip(duplicate, L["Duplicate"])
grid:AddChild(duplicate)

local tag = AceGUI:Create("Label")
tag:SetFullWidth(true)
tag:SetText(selected)
Expand All @@ -579,7 +658,7 @@ local function display_condition_group(frame, group, update)
local scrollwin = AceGUI:Create("ScrollFrame")
scrollwin:SetLayout("List")
scrollwin:SetFullWidth(true)
scrollwin:SetHeight(375)
scrollwin:SetHeight(365)
frame:AddChild(scrollwin)

local bottomwin = AceGUI:Create("SimpleGroup")
Expand Down
Loading

0 comments on commit 86e2614

Please sign in to comment.