Skip to content

Commit

Permalink
* Saved variables now kinda seems to work properly. Delay initialisat…
Browse files Browse the repository at this point in the history
…ion of everything till the saved vars are loaded basically. Not ideal but works
  • Loading branch information
harrand committed May 13, 2023
1 parent 481753b commit 15450b6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
1 change: 1 addition & 0 deletions HarrandSwingTimer.toc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Notes: Modern swing timer for Dragonflight, with a focus on Crusading Strikes (CSAA)
## Version: 0.2.0
## IconTexture: 135891
## SavedVariablesPerCharacter: hst_db_t

src/hst_settings.lua
src/hst_swing.lua
Expand Down
12 changes: 9 additions & 3 deletions src/hst_frame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ local function make_checkbox(parent, title, x, y, on_click_func, initial_val, to
end

local function impl_hst_options_menu(panel)
local swing_timer_visible = make_checkbox(panel, "Swing Timer Visible", 16, -16, function(self, value)
local swing_timer_visible_checkbox = make_checkbox(panel, "Swing Timer Visible", 16, -16, function(self, value)
hst.settings.swing_timer_visible = value
hst.ui.main_frame:SetShown(value)
end, hst.ui.main_frame:IsShown(), "Controls whether the swing timer is visible or not. Default: true")
local csaa_mode_checkbox = make_checkbox(panel, "CSAA Mode", 16, -40, function(self, value)
Expand All @@ -69,18 +70,22 @@ local function impl_hst_options_menu(panel)
local w = hst.ui.main_frame:GetWidth()
local h = hst.ui.main_frame:GetHeight()
local slider_x = make_slider(panel, "X Position", 16, -84, function(ui, value)
hst.settings.swingx = value
hst.ui.main_frame:SetPoint(p, hst.ui.main_frame:GetParent(), p, value, py)
end, -dx/2, dx/2, px, "X Coordinate of the swing timer UI element")

local slider_y = make_slider(panel, "Y Position", 16, -128, function(ui, value)
hst.settings.swingy = value
hst.ui.main_frame:SetPoint(p, hst.ui.main_frame:GetParent(), p, px, value)
end, -dy/2, dy, py, "Y Coordinate of the swing timer UI element")

local slider_w = make_slider(panel, "Width", 16, -172, function(ui, value)
hst.settings.swingw = value
hst.ui.main_frame:SetWidth(value)
end, 0, 500, w, "X Coordinate of the swing timer UI element")

local slider_h = make_slider(panel, "Y Position", 16, -216, function(ui, value)
hst.settings.swingh = value
hst.ui.main_frame:SetHeight(value)
end, 0, 500, h, "Y Coordinate of the swing timer UI element")
end
Expand All @@ -97,8 +102,9 @@ hst.create_frame = function()
-- and then a frame to actually represent the swing timer.
do
hst.ui.main_frame = CreateFrame("Frame", "HarrandSwingTimer Frame", UIParent)
hst.ui.main_frame:SetSize(200, 20)
hst.ui.main_frame:SetPoint("CENTER", 0, -310)
hst.ui.main_frame:SetSize(hst.settings.swingw, hst.settings.swingh)
hst.ui.main_frame:SetPoint("CENTER", hst.settings.swingx, hst.settings.swingy)
hst.ui.main_frame:SetShown(hst.settings.swing_timer_visible)
hst.ui.swing = CreateFrame("StatusBar", nil, hst.ui.main_frame)
hst.ui.swing_background = CreateFrame("Frame", nil, hst.ui.main_frame)
hst.ui.swing_background:SetAllPoints(hst.ui.main_frame)
Expand Down
10 changes: 8 additions & 2 deletions src/hst_main.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
local an, hst = ...

hst.create_frame()
hst.load_settings()
local f = CreateFrame("Frame")
f:RegisterEvent('ADDON_LOADED')
f:SetScript("OnEvent", function(self, event, arg1)
if(event == 'ADDON_LOADED' and arg1 == an) then
hst.load_settings()
hst.create_frame()
end
end)
9 changes: 7 additions & 2 deletions src/hst_settings.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
local an, hst = ...

local hst_db_t = {}
hst_db_t.allow_csaa_override = true
hst_db_t = hst_db_t or {}
hst_db_t.allow_csaa_override = false
hst_db_t.swing_timer_visible = true
hst_db_t.swingx = 0
hst_db_t.swingy = -310
hst_db_t.swingw = 200
hst_db_t.swingh = 20

hst.load_settings = function()
-- todo: implement
Expand Down

0 comments on commit 15450b6

Please sign in to comment.