From 97d8be69acf23485f70f52144713e6e27903188c Mon Sep 17 00:00:00 2001 From: Adrian Klingen Date: Sat, 3 Aug 2024 11:14:55 +0200 Subject: [PATCH 1/5] Add addon version to export options --- .gitignore | 1 + ExportStructures/Character.lua | 3 ++- ExportStructures/EquipmentSpec.lua | 2 +- UI.lua | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8f5fd87 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.history diff --git a/ExportStructures/Character.lua b/ExportStructures/Character.lua index 670be2d..f0629cd 100644 --- a/ExportStructures/Character.lua +++ b/ExportStructures/Character.lua @@ -4,6 +4,7 @@ local Env = select(2, ...) -- The metatable for a Character. local CharacterMeta = { + version = "", unit = "", name = "", realm = "", @@ -33,6 +34,7 @@ function CharacterMeta:SetUnit(unit) local name, realm = UnitFullName(unit) local _, englishClass, _, englishRace = GetPlayerInfoByGUID(UnitGUID(unit)) + self.version = Env.VERSION self.unit = unit self.name = name self.realm = realm @@ -45,7 +47,6 @@ end ---Fill remaining data needed for export. function CharacterMeta:FillForExport() assert(self.unit, "Unit was not yet set!") - self.talents = Env.CreateTalentString() self.professions = Env.CreateProfessionEntry() diff --git a/ExportStructures/EquipmentSpec.lua b/ExportStructures/EquipmentSpec.lua index b3c17b0..e71b38c 100644 --- a/ExportStructures/EquipmentSpec.lua +++ b/ExportStructures/EquipmentSpec.lua @@ -103,7 +103,7 @@ end -- Create a new EquipmentSpec table. local function CreateEquipmentSpec() local items = setmetatable({}, EquipmentSpecItemsMeta) - local equipment = setmetatable({ items = items }, EquipmentSpecMeta) + local equipment = setmetatable({ items = items, version = Env.VERSION }, EquipmentSpecMeta) return equipment end diff --git a/UI.lua b/UI.lua index 56f42b8..9e96c2f 100644 --- a/UI.lua +++ b/UI.lua @@ -43,7 +43,7 @@ function UI:CreateMainWindow(classIsSupported, simLink) local frame = AceGUI:Create("Frame") frame:SetCallback("OnClose", OnClose) - frame:SetTitle("WowSimsExporter V" .. Env.VERSION .. "") + frame:SetTitle("WowSimsExporter " .. Env.VERSION .. "") frame:SetStatusText("Click 'Generate Data' to generate exportable data") frame:SetLayout("Flow") _frame = frame From 0c57b510365d1dda95d20c8a5f4c94fa6e728205 Mon Sep 17 00:00:00 2001 From: Adrian Klingen Date: Sat, 3 Aug 2024 11:20:25 +0200 Subject: [PATCH 2/5] Remove floating version v --- WowSimsExporter.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WowSimsExporter.lua b/WowSimsExporter.lua index a2f9f37..0f02022 100644 --- a/WowSimsExporter.lua +++ b/WowSimsExporter.lua @@ -43,7 +43,7 @@ function WowSimsExporter:OnInitialize() self:RegisterChatCommand("wowsimsexporter", "OpenWindow") self:RegisterChatCommand("wsexporter", "OpenWindow") - self:Print(addonName .. " v" .. Env.VERSION .. " Initialized. use /wse For Window.") + self:Print(addonName .. " " .. Env.VERSION .. " Initialized. use /wse For Window.") if not Env.IS_CLIENT_SUPPORTED then self:Print("WARNING: Sim does not support your game version! Supported versions are:\n" .. From 58679760ff214683783b2b2c223dd8416bac007f Mon Sep 17 00:00:00 2001 From: Adrian Klingen Date: Sat, 3 Aug 2024 11:54:28 +0200 Subject: [PATCH 3/5] Add close on Escape --- UI.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/UI.lua b/UI.lua index 9e96c2f..81e22c3 100644 --- a/UI.lua +++ b/UI.lua @@ -46,6 +46,13 @@ function UI:CreateMainWindow(classIsSupported, simLink) frame:SetTitle("WowSimsExporter " .. Env.VERSION .. "") frame:SetStatusText("Click 'Generate Data' to generate exportable data") frame:SetLayout("Flow") + + -- Add the frame as a global variable under the name `WowSimsExporter` + _G["WowSimsExporter"] = frame.frame + -- Register the global variable `WowSimsExporter` as a "special frame" + -- so that it is closed when the escape key is pressed. + tinsert(UISpecialFrames, "WowSimsExporter") + _frame = frame local icon = AceGUI:Create("Icon") @@ -108,6 +115,9 @@ into the provided box and click "Import" jsonbox:SetFullWidth(true) jsonbox:SetFullHeight(true) jsonbox:DisableButton(true) + jsonbox.editBox:SetScript("OnEscapePressed", function(self) + OnClose(frame) + end) frame:AddChild(jsonbox) _jsonbox = jsonbox From 0513461633c7c69fce9419d13780bcb7fa7f4d53 Mon Sep 17 00:00:00 2001 From: Adrian Klingen Date: Sat, 3 Aug 2024 13:12:28 +0200 Subject: [PATCH 4/5] 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 5/5] 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)