Skip to content

Commit 8082b4d

Browse files
authored
Merge pull request #22 from wowsims/feature/add-addon-version-to-export
Add addon version to export options
2 parents 77e26fc + 625c4ea commit 8082b4d

File tree

5 files changed

+31
-4
lines changed

5 files changed

+31
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.history

ExportStructures/Character.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ local Env = select(2, ...)
44

55
-- The metatable for a Character.
66
local CharacterMeta = {
7+
version = "",
78
unit = "",
89
name = "",
910
realm = "",
@@ -33,6 +34,7 @@ function CharacterMeta:SetUnit(unit)
3334
local name, realm = UnitFullName(unit)
3435
local _, englishClass, _, englishRace = GetPlayerInfoByGUID(UnitGUID(unit))
3536

37+
self.version = Env.VERSION
3638
self.unit = unit
3739
self.name = name
3840
self.realm = realm
@@ -45,7 +47,6 @@ end
4547
---Fill remaining data needed for export.
4648
function CharacterMeta:FillForExport()
4749
assert(self.unit, "Unit was not yet set!")
48-
4950
self.talents = Env.CreateTalentString()
5051
self.professions = Env.CreateProfessionEntry()
5152

ExportStructures/EquipmentSpec.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ end
103103
-- Create a new EquipmentSpec table.
104104
local function CreateEquipmentSpec()
105105
local items = setmetatable({}, EquipmentSpecItemsMeta)
106-
local equipment = setmetatable({ items = items }, EquipmentSpecMeta)
106+
local equipment = setmetatable({ items = items, version = Env.VERSION }, EquipmentSpecMeta)
107107
return equipment
108108
end
109109

UI.lua

+25-1
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,16 @@ function UI:CreateMainWindow(classIsSupported, simLink)
4343

4444
local frame = AceGUI:Create("Frame")
4545
frame:SetCallback("OnClose", OnClose)
46-
frame:SetTitle("WowSimsExporter V" .. Env.VERSION .. "")
46+
frame:SetTitle("WowSimsExporter " .. Env.VERSION .. "")
4747
frame:SetStatusText("Click 'Generate Data' to generate exportable data")
4848
frame:SetLayout("Flow")
49+
50+
-- Add the frame as a global variable under the name `WowSimsExporter`
51+
_G["WowSimsExporter"] = frame.frame
52+
-- Register the global variable `WowSimsExporter` as a "special frame"
53+
-- so that it is closed when the escape key is pressed.
54+
tinsert(UISpecialFrames, "WowSimsExporter")
55+
4956
_frame = frame
5057

5158
local icon = AceGUI:Create("Icon")
@@ -108,11 +115,28 @@ into the provided box and click "Import"
108115
jsonbox:SetFullWidth(true)
109116
jsonbox:SetFullHeight(true)
110117
jsonbox:DisableButton(true)
118+
jsonbox.editBox:SetScript("OnEscapePressed", function(self)
119+
OnClose(frame)
120+
end)
111121
frame:AddChild(jsonbox)
112122

113123
_jsonbox = jsonbox
114124
end
115125

126+
---Create a button on the character panel that will call the provided function
127+
---@param onClick fun()
128+
function UI:CreateCharacterPanelButton(onClick)
129+
local openButton = CreateFrame("Button", nil, CharacterFrame, "UIPanelButtonTemplate")
130+
openButton:SetPoint("TOPRIGHT", CharacterFrame, "BOTTOMRIGHT", 0, 0)
131+
openButton:Show()
132+
openButton:SetText("WowSims")
133+
openButton:SetSize(openButton:GetTextWidth() + 15, openButton:GetTextHeight() + 10)
134+
openButton:SetScript("OnClick", openButton:SetScript("OnClick", function(self)
135+
onClick()
136+
end))
137+
openButton:RegisterForClicks("AnyUp")
138+
end
139+
116140
---Sets string in textbox.
117141
---@param outputString string
118142
function UI:SetOutput(outputString)

WowSimsExporter.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ function WowSimsExporter:OnInitialize()
4242
self:RegisterChatCommand("wse", "OpenWindow")
4343
self:RegisterChatCommand("wowsimsexporter", "OpenWindow")
4444
self:RegisterChatCommand("wsexporter", "OpenWindow")
45+
Env.UI:CreateCharacterPanelButton(options.args.openExporterButton.func)
4546

46-
self:Print(addonName .. " v" .. Env.VERSION .. " Initialized. use /wse For Window.")
47+
self:Print(addonName .. " " .. Env.VERSION .. " Initialized. use /wse For Window.")
4748

4849
if not Env.IS_CLIENT_SUPPORTED then
4950
self:Print("WARNING: Sim does not support your game version! Supported versions are:\n" ..

0 commit comments

Comments
 (0)