Skip to content

Commit

Permalink
track the visibility of the static window between sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
mynian committed Feb 5, 2021
1 parent 1b77d3e commit 0e95592
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions HonorTrack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ end
hthonorgoal = 0
local hthonorgained = 0
htgoalset = false
htvisible = true

--function to set the visibitity state when logging in based on what the user had previously Set
local function SetState(self)
if htvisible == true then
Addon:Show()
else
Addon:Hide()
end
end


-- Function to set the goal amount based on input from the slash command
local function UpdateGoal(self)
Expand All @@ -110,12 +121,16 @@ function SlashCmdList.HONORTRACK(msg, editBox)
if string.lower(command) == 'show' then
--Show it
Addon:Show();
--Set the visible variable to save between sessions
htvisible = true
--Let the user know it worked and how to hide it.
print("Honor Track: Showing tracker. You can hide the tracker with /honortrack hide")
--Hide the frame command check
elseif string.lower(command) == 'hide' then
--Hide it
Addon:Hide();
--set the variable
htvisible = false
--Let the user know it worked and how to show it.
print("Honor Track: Hiding tracker. You can show the tracker again with /honortrack show")
--Set the goal command check. This makes sure the user input only numbers and errors if they didn't
Expand Down Expand Up @@ -259,8 +274,10 @@ end
function dataobj:OnClick()
if Addon:IsShown() then
Addon:Hide()
htvisible = false
else
Addon:Show()
htvisible = true
end
end

Expand Down Expand Up @@ -294,6 +311,7 @@ Addon:SetScript("OnUpdate", OnUpdate)
function events:PLAYER_ENTERING_WORLD(...)
UpdateHonor(self)
UpdateGoal(self)
SetState(self)
end

--Tell the client that we want to run these functions when the player's honor amount updates
Expand Down
4 changes: 2 additions & 2 deletions HonorTrack.toc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Interface: 90002
## Title: Honor Track
## Notes: Shows your current honor info and allows you to set a goal
## Version: 2.1.2
## SavedVariablesPerCharacter: hthonorgoal, htgoalset
## Version: 3.0.0
## SavedVariablesPerCharacter: hthonorgoal, htgoalset, htvisible

LibStub.lua
CallbackHandler-1.0.lua
Expand Down

0 comments on commit 0e95592

Please sign in to comment.