From 0513461633c7c69fce9419d13780bcb7fa7f4d53 Mon Sep 17 00:00:00 2001 From: Adrian Klingen Date: Sat, 3 Aug 2024 13:12:28 +0200 Subject: [PATCH 1/2] Add button on character panel --- UI.lua | 14 ++++++++++++++ WowSimsExporter.lua | 1 + 2 files changed, 15 insertions(+) diff --git a/UI.lua b/UI.lua index 81e22c3..9bc4da0 100644 --- a/UI.lua +++ b/UI.lua @@ -123,6 +123,20 @@ into the provided box and click "Import" _jsonbox = jsonbox end +---Create a button on the character panel that will call the provided function +---@param onClick fun() +function UI:CreateCharacterPanelButton(onClick) + local openButton = CreateFrame("Button", nil, CharacterFrame, "UIPanelButtonTemplate") + openButton:SetPoint("BOTTOMLEFT", CharacterFrame, 8, 8) + openButton:Show() + openButton:SetText("WowSims") + openButton:SetSize(openButton:GetTextWidth() + 15, openButton:GetTextHeight() + 10) + openButton:SetScript("OnClick", openButton:SetScript("OnClick", function(self) + onClick() + end)) + openButton:RegisterForClicks("AnyUp") +end + ---Sets string in textbox. ---@param outputString string function UI:SetOutput(outputString) diff --git a/WowSimsExporter.lua b/WowSimsExporter.lua index 0f02022..793ec40 100644 --- a/WowSimsExporter.lua +++ b/WowSimsExporter.lua @@ -42,6 +42,7 @@ function WowSimsExporter:OnInitialize() self:RegisterChatCommand("wse", "OpenWindow") self:RegisterChatCommand("wowsimsexporter", "OpenWindow") self:RegisterChatCommand("wsexporter", "OpenWindow") + Env.UI:CreateCharacterPanelButton(options.args.openExporterButton.func) self:Print(addonName .. " " .. Env.VERSION .. " Initialized. use /wse For Window.") From 34a3e57ba8290e2d11ec30fef787f896d78acd0f Mon Sep 17 00:00:00 2001 From: Adrian Klingen Date: Sat, 3 Aug 2024 16:09:24 +0200 Subject: [PATCH 2/2] Fix button positioning --- UI.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UI.lua b/UI.lua index 9bc4da0..c7d4732 100644 --- a/UI.lua +++ b/UI.lua @@ -127,7 +127,7 @@ end ---@param onClick fun() function UI:CreateCharacterPanelButton(onClick) local openButton = CreateFrame("Button", nil, CharacterFrame, "UIPanelButtonTemplate") - openButton:SetPoint("BOTTOMLEFT", CharacterFrame, 8, 8) + openButton:SetPoint("TOPRIGHT", CharacterFrame, "BOTTOMRIGHT", 0, 0) openButton:Show() openButton:SetText("WowSims") openButton:SetSize(openButton:GetTextWidth() + 15, openButton:GetTextHeight() + 10)