From 7afe13ac72d987cc553a77d253a302ffd63854fc Mon Sep 17 00:00:00 2001 From: Vollmer Date: Mon, 9 Sep 2024 12:16:42 +0200 Subject: [PATCH] move Edit Mode button to Unit Frames tab --- Core/SlashCommands.lua | 1 + Locales/enUS.lua | 3 +++ Menu/Menu.lua | 29 ++++++++++++++++++----------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Core/SlashCommands.lua b/Core/SlashCommands.lua index e69a55b..bb2956a 100644 --- a/Core/SlashCommands.lua +++ b/Core/SlashCommands.lua @@ -25,6 +25,7 @@ function SlashCmdList.CUF(msg, editbox) CUF:Print("Available commands:" .. "\n" .. "/cuf test - toggle test mode" .. "\n" .. "/cuf dev - toggle debug mode" .. "\n" .. + "/cuf edit - toggle edit mode" .. "\n" .. "/cuf restore - restore a backup" ) end diff --git a/Locales/enUS.lua b/Locales/enUS.lua index 0251747..062816c 100644 --- a/Locales/enUS.lua +++ b/Locales/enUS.lua @@ -154,6 +154,9 @@ L.SameSizeAsHealthBar = "Same Size As Health Bar" L.EditingLayout = "Editing Layout" L.MirrorPlayer = "Mirror Player" L.Positioning = "Positioning" +L.EditMode = "Edit Mode" +L.ToggleEditMode = "Toggle Edit Mode" +L.EditModeButtonTooltip = "Edit mode allows you to position the Unit Frames." -- Custom Formats L.ValidTags = "Valid Tags" diff --git a/Menu/Menu.lua b/Menu/Menu.lua index 9138d06..02a3e85 100644 --- a/Menu/Menu.lua +++ b/Menu/Menu.lua @@ -91,10 +91,12 @@ end function menu:ShowLayoutTitle() self.layoutTitleFrame:Show() self:SetLayoutTitle() + self.editModeButton:Show() end function menu:HideLayoutTitle() self.layoutTitleFrame:Hide() + self.editModeButton:Hide() end ------------------------------------------------- @@ -210,7 +212,7 @@ function menu:CreateMenu() ---@class CellCombatFrame self.window = CUF:CreateFrame("CUF_Menu", optionsFrame, self.baseWidth, 300) - self.window:SetPoint("TOPRIGHT", CellLayoutsPreviewButton, "BOTTOMRIGHT", 0, -self.inset - 20) + self.window:SetPoint("TOPRIGHT", CellLayoutsPreviewButton, "BOTTOMRIGHT", 0, -self.inset) -- mask F:ApplyCombatProtectionToFrame(self.window) @@ -230,16 +232,6 @@ function menu:CreateMenu() titleFrame:SetHeight(title:GetStringHeight() + pad * 2) titleFrame:SetWidth(title:GetStringWidth() + pad * 2) - local previewModeButton = Cell:CreateButton(titleFrame, L["Edit Mode"], "accent", - { 80, 20 }) - previewModeButton:SetPoint("BOTTOMLEFT", titleFrame, "BOTTOMRIGHT", -1, 0) - previewModeButton:SetScript("OnClick", function() - CUF.uFuncs:EditMode() - end) - previewModeButton:SetScript("OnHide", function() - CUF.uFuncs:EditMode(false) - end) - -- Title local layoutTitleFrame = CUF:CreateFrame(nil, titleFrame, 160, 10, false, true) layoutTitleFrame:SetPoint("BOTTOMLEFT", titleFrame, "TOPLEFT", 0, -1) @@ -267,6 +259,21 @@ function menu:CreateMenu() self:InitTabs() + local editModeButton = Cell:CreateButton(self.tabPane, L.EditMode, "accent", + { 100, 25 }) + editModeButton:SetPoint("TOPLEFT", self.tabPane, "BOTTOMLEFT", 0, 0) + CUF:SetTooltips(editModeButton, "ANCHOR_TOPLEFT", 0, 3, L.ToggleEditMode, + L.EditModeButtonTooltip) + + editModeButton:SetScript("OnClick", function() + CUF.uFuncs:EditMode() + end) + editModeButton:SetScript("OnHide", function() + CUF.uFuncs:EditMode(false) + end) + self.editModeButton = editModeButton + self.editModeButton:Hide() + hooksecurefunc(optionsFrame, "Hide", function() self:HideMenu() end)