Skip to content

Commit

Permalink
+ Added options to move/resize the swing timer around, very basic tho…
Browse files Browse the repository at this point in the history
…ugh. Lots of work still needed before real people can actually use it properly
  • Loading branch information
harrand committed May 13, 2023
1 parent ce06560 commit 912e22d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
42 changes: 40 additions & 2 deletions src/hst_frame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ hst_ui_state.swing = nil
hst_ui_state.swing_background = nil
hst.ui = hst_ui_state or {}

local function get_dimensions()
local w = GetScreenWidth() * UIParent:GetEffectiveScale()
local h = GetScreenHeight() * UIParent:GetEffectiveScale()
return w, h
end

local function make_slider(parent, title, x, y, value_changed_func, min, max, initial_val, tooltip)
local sl = CreateFrame("Slider", title, parent, "OptionsSliderTemplate")
sl:SetMinMaxValues(min, max)
sl:SetValue(min + max / 2)
sl:SetPoint("TOPLEFT", x, y)
sl:SetScript("OnValueChanged", function(self, value)
value_changed_func(self, value)
end)
local label = sl:CreateFontString(nil, "OVERLAY", "GameFontNormal")
label:SetPoint("BOTTOM", sl, "TOP", 0, 5)
label:SetText(title)
end

local function make_checkbox(parent, title, x, y, on_click_func, initial_val, tooltip)
local cb = CreateFrame("CheckButton", title, parent, "InterfaceOptionsCheckButtonTemplate")
cb:SetPoint("TOPLEFT", x, y)
Expand All @@ -33,7 +52,6 @@ end

local function impl_hst_options_menu(panel)
local swing_timer_visible = make_checkbox(panel, "Swing Timer Visible", 16, -16, function(self, value)
print('eee')
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 @@ -44,7 +62,27 @@ local function impl_hst_options_menu(panel)
else
print('CSAA Mode Disabled')
end
end, hst.settings.allow_csaa_override, "If enabled, the swing timer will be coloured red if the next crusading strike will generate a Holy Power. Default: false")
end, hst.settings.allow_csaa_override, "If enabled, the swing timer will be coloured red if the next crusading strike will generate a Holy Power. Default: true")

local dx, dy = get_dimensions()
local p, _, _, px, py = hst.ui.main_frame:GetPoint()
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.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.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.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.ui.main_frame:SetHeight(value)
end, 0, 500, h, "Y Coordinate of the swing timer UI element")
end

hst.create_frame = function()
Expand Down
2 changes: 1 addition & 1 deletion src/hst_settings.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local an, hst = ...

local hst_db_t = {}
hst_db_t.allow_csaa_override = false
hst_db_t.allow_csaa_override = true

hst.load_settings = function()
-- todo: implement
Expand Down
4 changes: 2 additions & 2 deletions src/hst_swing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ hst.impl_on_combat_event = function(self, event, ...)
if(table_contains(melee_spells, spell_id) or evt_t == "SWING_DAMAGE") then
swing_start_time = GetTime()
if(most_recent_swing_timestamp + 0.1 < timestamp) then
print('swing detected')
--print('swing detected')
most_recent_swing_timestamp = timestamp
last_csaa_procced_hopo = false
end
end
if(hst.settings.allow_csaa_override and spell_id == 406834) then-- csaa but with a hopo
print('hopo generated')
--print('hopo generated')
last_csaa_procced_hopo = true
end
end
Expand Down

0 comments on commit 912e22d

Please sign in to comment.