Skip to content

Commit 6ae61bf

Browse files
authored
add an option button and more options (#68)
* add option button * add option to turn clear before import on and off
1 parent 8d010f1 commit 6ae61bf

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

gui.lua

+32-2
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,25 @@ end
5555

5656
local exportEditbox
5757

58+
-- options
59+
do
60+
local b = CreateFrame("Button", nil, f, "GameMenuButtonTemplate")
61+
b:SetWidth(100)
62+
b:SetHeight(25)
63+
b:SetPoint("BOTTOMRIGHT", -145, 15)
64+
b:SetText(OPTIONS)
65+
b:SetScript("OnClick", function()
66+
Settings.OpenToCategory(MySlot.settingcategory.ID)
67+
end)
68+
end
69+
5870
-- close
5971
do
6072
local b = CreateFrame("Button", nil, f, "GameMenuButtonTemplate")
6173
b:SetWidth(100)
6274
b:SetHeight(25)
6375
b:SetPoint("BOTTOMRIGHT", -40, 15)
64-
b:SetText(L["Close"])
76+
b:SetText(CLOSE)
6577
b:SetScript("OnClick", function() f:Hide() end)
6678
end
6779

@@ -396,6 +408,15 @@ do
396408

397409
MySlot:Print(L["Starting backup..."])
398410
local backup = MySlot:Export(actionOpt)
411+
412+
if not backup then
413+
MySlot:Print(L["Backup failed"])
414+
415+
if not forceImport then
416+
return
417+
end
418+
end
419+
399420
table.insert(MyslotExports["backups"], backup)
400421
while #MyslotExports["backups"] > IMPORT_BACKUP_COUNT do
401422
table.remove(MyslotExports["backups"], 1)
@@ -437,6 +458,7 @@ do
437458

438459
tAppendAll(settings, CreateSettingMenu(actionOpt))
439460

461+
local clearbegin = #settings + 1
440462
tAppendAll(settings, {
441463
{
442464
isTitle = true,
@@ -447,6 +469,7 @@ do
447469
tAppendAll(settings, CreateSettingMenu(clearOpt))
448470

449471
table.remove(settings) -- remove pet action bar clearOpt, will support it later
472+
local clearend = #settings
450473

451474
tAppendAll(settings, {
452475
{
@@ -467,8 +490,15 @@ do
467490
}
468491
})
469492

493+
local settingswithoutclear = {}
494+
tAppendAll(settingswithoutclear, settings)
495+
for i = clearend, clearbegin, -1 do
496+
table.remove(settingswithoutclear, i)
497+
end
498+
499+
470500
ba:SetScript("OnClick", function(self, button)
471-
EasyMenu(settings, menuFrame, "cursor", 0 , 0, "MENU");
501+
EasyMenu(MyslotSettings.allowclearonimport and settings or settingswithoutclear, menuFrame, "cursor", 0 , 0, "MENU");
472502
end)
473503
end
474504

options.lua

+14-1
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ RegEvent("ADDON_LOADED", function()
3535
end)
3636
end
3737

38+
MyslotSettings = MyslotSettings or {}
3839

3940
do
40-
MyslotSettings = MyslotSettings or {}
4141
MyslotSettings.minimap = MyslotSettings.minimap or { hide = false }
4242
local config = MyslotSettings.minimap
4343

@@ -99,6 +99,19 @@ RegEvent("ADDON_LOADED", function()
9999
StaticPopup_Show("MYSLOT_CONFIRM_CLEAR", "MACRO", nil, "MACRO")
100100
end)
101101
end
102+
103+
do
104+
local b = CreateFrame("CheckButton", nil, f, "UICheckButtonTemplate")
105+
b:SetPoint("TOPLEFT", f, 15, doffset - 110)
106+
107+
b.text = b:CreateFontString(nil, "OVERLAY", "GameFontNormal")
108+
b.text:SetPoint("LEFT", b, "RIGHT", 0, 1)
109+
b.text:SetText(L["Allow"] .. " " .. "|cffff0000" .. L["CLEAR"] .. "|r" .. " " .. L[" before Import"])
110+
b:SetChecked(MyslotSettings.allowclearonimport)
111+
b:SetScript("OnClick", function()
112+
MyslotSettings.allowclearonimport = b:GetChecked()
113+
end)
114+
end
102115
end)
103116

104117
StaticPopupDialogs["MYSLOT_CONFIRM_CLEAR"] = {

0 commit comments

Comments
 (0)