0
@@ -8,7 +8,7 @@ if not ControlFreak then return end
0
local ww = LibStub("WidgetWarlock-Alpha1")
0
-local GAP, EDGEGAP, DROPDOWNOFFSET
= 8, 16, 160
+local GAP, EDGEGAP, DROPDOWNOFFSET
, NUMROWS, ROWHEIGHT = 8, 16, 16, 13, 180
@@ -27,21 +27,18 @@ frame:SetScript("OnShow", function(frame)
0
local currentlabel = ww:SummonFontString(frame, "OVERLAY", "GameFontNormal", "Current profile:", "TOPLEFT", subtitle, "BOTTOMLEFT", -2, -GAP)
0
local current = ww:SummonFontString(frame, "OVERLAY", "GameFontHighlight", ControlFreak.db:GetCurrentProfile(), "LEFT", currentlabel, "RIGHT", 10, 0)
0
- local profiles = ControlFreak.db:GetProfiles()
0
- local selected = CreateFrame("Frame", "ControlFreakProfileMenu", frame, "UIDropDownMenuTemplate")
0
- local loadbutton = ww:SummonButton(frame, "Load", nil, nil, "TOPLEFT", selected, "BOTTOMLEFT", DROPDOWNOFFSET, -GAP/2)
0
- local copybutton = ww:SummonButton(frame, "Copy", nil, nil, "LEFT", loadbutton, "RIGHT", GAP, 0)
0
- local deletebutton = ww:SummonButton(frame, "Delete", nil, nil, "LEFT", copybutton, "RIGHT", GAP, 0)
0
+ local createname = ww:SummonEditBox(frame, 255, "TOPLEFT", currentlabel, "BOTTOMLEFT", GAP - 2, -1)
0
+ local createbutton = ww:SummonButton(frame, "Create", nil, nil, "LEFT", createname, "RIGHT", 5, 0)
0
+ createbutton:Disable()
0
+ createname:SetScript("OnTextChanged", function(frame) if frame:GetText() ~= "" then createbutton:Enable() else createbutton:Disable() end end)
0
- selected:SetPoint("TOPLEFT", currentlabel, "BOTTOMLEFT", -DROPDOWNOFFSET, -GAP)
0
- ControlFreakProfileMenuRight:ClearAllPoints()
0
- ControlFreakProfileMenuRight:SetPoint("TOP", ControlFreakProfileMenuLeft)
0
- ControlFreakProfileMenuRight:SetPoint("RIGHT", frame, -EDGEGAP + DROPDOWNOFFSET, 0)
0
- ControlFreakProfileMenuMiddle:SetPoint("RIGHT", ControlFreakProfileMenuRight, "LEFT")
0
+ local deletebutton = ww:SummonButton(frame, "Delete", nil, nil, "BOTTOMRIGHT", -EDGEGAP, EDGEGAP)
0
+ local copybutton = ww:SummonButton(frame, "Copy", nil, nil, "RIGHT", deletebutton, "LEFT", -GAP, 0)
0
+ local loadbutton = ww:SummonButton(frame, "Load", nil, nil, "RIGHT", copybutton, "LEFT", -GAP, 0)
0
local function ToggleButtons(value)
0
- if
value == ControlFreak.db:GetCurrentProfile() then
0
+ if
not value or value == ControlFreak.db:GetCurrentProfile() then
0
@@ -52,53 +49,79 @@ frame:SetScript("OnShow", function(frame)
0
- local function DropdownClick()
0
- UIDropDownMenu_SetSelectedValue(ControlFreakProfileMenu, this.value)
0
- ToggleButtons(this.value)
0
- local ddt = {func = DropdownClick}
0
- local function DropdownInit()
0
- local current = ControlFreak.db:GetCurrentProfile()
0
- for i,v in ipairs(profiles) do
0
- ddt.disabled = v == current
0
- UIDropDownMenu_AddButton(ddt)
0
+ local offset, selectedprofile, proflies = 0
0
+ local function UpdateRows()
0
+ for i,row in ipairs(rows) do
0
+ local profile = profiles[i + offset]
0
+ row.text:SetText((profile == ControlFreak.db:GetCurrentProfile() and "|cff999999" or "")..profile)
0
+ if profile == ControlFreak.db:GetCurrentProfile() then row:Disable() else row:Enable() end
0
+ row:SetChecked(selectedprofile == profile)
0
- local function selectedOnShow(self)
0
- UIDropDownMenu_Initialize(self, DropdownInit)
0
- UIDropDownMenu_SetSelectedValue(selected, profiles[1])
0
- ToggleButtons(profiles[1])
0
+ local function rowOnClick(self)
0
+ selectedprofile = selectedprofile ~= self.value and self.value or nil
0
+ ToggleButtons(selectedprofile)
0
+ local function OnMouseWheel(f, val)
0
+ if (offset + NUMROWS) > #profiles then offset = #profiles - NUMROWS end
0
+ if offset < 0 then offset = 0 end
0
+ local row = CreateFrame("CheckButton", nil, frame)
0
+ row:SetHeight(ROWHEIGHT)
0
+ if i == 1 then row:SetPoint("TOP", createname, "BOTTOM", 0, -2) else row:SetPoint("TOP", rows[i-1], "BOTTOM", 0, 0) end
0
+ row:SetPoint("LEFT", EDGEGAP, 0)
0
+ row:SetPoint("RIGHT", -EDGEGAP, 0)
0
+ row.text = ww:SummonFontString(row, "OVERLAY", "GameFontWhite", "SAMPLE PROFILE "..i, "LEFT", row, 10, 0)
0
+ row.text:SetPoint("RIGHT", row, -10, 0)
0
+ row.text:SetJustifyH("LEFT")
0
+ local highlight = ww:SummonTextureWithCoords(row, nil, nil, nil, "Interface\\HelpFrame\\HelpFrameButton-Highlight", 0, 1, 0, 0.578125)
0
+ highlight:SetAllPoints()
0
+ row:SetHighlightTexture(highlight)
0
+ row:SetCheckedTexture(highlight)
0
+ row:EnableMouseWheel()
0
+ row:SetScript("OnMouseWheel", OnMouseWheel)
0
+ row:SetScript("OnClick", rowOnClick)
0
- selected:SetScript("OnShow", selectedOnShow)
0
- selectedOnShow(selected)
0
loadbutton:SetScript("OnClick", function()
0
- local profile =
UIDropDownMenu_GetSelectedValue(selected)0
+ local profile =
selectedprofile0
ControlFreak.db:SetProfile(profile)
0
current:SetText(profile)
0
- ToggleButtons(profile)
0
copybutton:SetScript("OnClick", function()
0
ControlFreak.db:ResetProfile()
0
- ControlFreak.db:CopyProfile(
UIDropDownMenu_GetSelectedValue(selected))
0
+ ControlFreak.db:CopyProfile(
selectedprofile)
0
profiles = ControlFreak.db:GetProfiles()
0
deletebutton:SetScript("OnClick", function()
0
- ControlFreak.db:DeleteProfile(UIDropDownMenu_GetSelectedValue(selected))
0
- profiles = ControlFreak.db:GetProfiles()
0
- UIDropDownMenu_SetSelectedValue(selected, profiles[1])
0
- ToggleButtons(profiles[1])
0
+ ControlFreak.db:DeleteProfile(selectedprofile)
0
+ profiles, selectedprofile = ControlFreak.db:GetProfiles(), nil
0
- local createname = ww:SummonEditBox(frame, 187, "TOPLEFT", loadbutton, "BOTTOMLEFT", 8, 1)
0
- local createbutton = ww:SummonButton(frame, "Create", nil, nil, "LEFT", createname, "RIGHT", 5, -1)
0
- createbutton:Disable()
0
- createname:SetScript("OnTextChanged", function(frame) if frame:GetText() ~= "" then createbutton:Enable() else createbutton:Disable() end end)
0
createbutton:SetScript("OnClick", function()
0
local profile = createname:GetText()
0
@@ -110,16 +133,18 @@ frame:SetScript("OnShow", function(frame)
0
createname:ClearFocus()
0
ww:EnslaveTooltip(copybutton, "Copy the selected profile into your current profile.")
0
+ ww:EnslaveTooltip(deletebutton, "Delete the selected profile. Default profiles will reset to their original settings when deleted.")
0
ww:EnslaveTooltip(createbutton, "Duplicate the current profile into a new profile.")
0
local function OnShow(frame)
0
profiles = ControlFreak.db:GetProfiles()
0
frame:SetScript("OnShow", OnShow)
Comments
No one has commented yet.