Skip to content

Commit

Permalink
Merge pull request #22 from wowsims/feature/add-addon-version-to-export
Browse files Browse the repository at this point in the history
Add addon version to export options
  • Loading branch information
1337LutZ authored Aug 3, 2024
2 parents 77e26fc + 625c4ea commit 8082b4d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.history
3 changes: 2 additions & 1 deletion ExportStructures/Character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local Env = select(2, ...)

-- The metatable for a Character.
local CharacterMeta = {
version = "",
unit = "",
name = "",
realm = "",
Expand Down Expand Up @@ -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
Expand All @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion ExportStructures/EquipmentSpec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 25 additions & 1 deletion UI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,16 @@ 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")

-- 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")
Expand Down Expand Up @@ -108,11 +115,28 @@ 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
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("TOPRIGHT", CharacterFrame, "BOTTOMRIGHT", 0, 0)
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)
Expand Down
3 changes: 2 additions & 1 deletion WowSimsExporter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ 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 .. " 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" ..
Expand Down

0 comments on commit 8082b4d

Please sign in to comment.