forked from neun0eil/wow-action-bar-profiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUISave.lua
116 lines (92 loc) · 3.25 KB
/
GUISave.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
local addonName, addon = ...
local L = LibStub("AceLocale-3.0"):GetLocale(addonName)
local frame = PaperDollActionBarProfilesSaveDialog
function frame:SaveDialogOptions()
return table.s2k_values({
{ "Actions", "actions" },
{ "EmptySlots", "empty_slots" },
{ "Talents", "talents" },
{ "PvPTalents", "pvp_talents" },
{ "Macros", "macros" },
{ "PetActions", "pet_actions" },
{ "Bindings", "bindings" },
}, true)
end
function frame:OnInitialize()
self.ProfileNameText:SetText(L.gui_profile_name)
self.ProfileOptionsText:SetText(L.gui_profile_options)
local option, lang
for option, lang in self:SaveDialogOptions() do
_G[self:GetName() .. "Option" .. option .. "Text"]:SetText(" " .. L["option_" .. lang])
end
end
function frame:OnOkayClick()
local name = strtrim(self.EditBox:GetText())
local options = {}
local option
for option in self:SaveDialogOptions() do
options["skip" .. option] = not self["Option" .. option]:GetChecked() or nil
end
if self.name then
if name ~= self.name then
if addon:GetProfiles(name) then
UIErrorsFrame:AddMessage(L.error_exists, 1.0, 0.1, 0.1, 1.0)
return
end
addon:RenameProfile(self.name, name, true)
-- hack: update selection
PaperDollActionBarProfilesPane.selected = name
end
addon:UpdateProfileOptions(name, options)
else
if addon:GetProfiles(name) then
if not addon:ShowPopup("CONFIRM_OVERWRITE_ACTION_BAR_PROFILE", name, nil, { name = name, options = options, hide = self }) then
UIErrorsFrame:AddMessage(ERR_CLIENT_LOCKED_OUT, 1.0, 0.1, 0.1, 1.0)
end
return
end
addon:SaveProfile(name, options)
end
self:Hide()
end
function frame:OnCancelClick()
self:Hide()
end
function frame:Update()
if strtrim(self.EditBox:GetText()) ~= "" then
self.Okay:Enable()
else
self.Okay:Disable()
end
end
function frame:SetProfile(name)
self.name = nil
self.EditBox:SetText("")
local option
for option in self:SaveDialogOptions() do
self["Option" .. option]:SetChecked(true)
self["Option" .. option]:Enable()
_G[self:GetName() .. "Option" .. option .. "Text"]:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b)
end
if not name then
if not HasPetSpells() then
self.OptionPetActions:Disable()
_G[self:GetName() .. "OptionPetActionsText"]:SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b)
end
else
self.name = name
self.EditBox:SetText(name)
self.EditBox:HighlightText(0)
local profile = addon:GetProfiles(name)
if profile then
for option in self:SaveDialogOptions() do
self["Option" .. option]:SetChecked(not profile["skip" .. option])
end
if not profile.petActions then
self.OptionPetActions:Disable()
_G[self:GetName() .. "OptionPetActionsText"]:SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b)
end
end
end
self:Update()
end