Skip to content

Commit

Permalink
feat: Add emjay mode.
Browse files Browse the repository at this point in the history
chore: refactor mode selector to be easier to generate from the modes object
  • Loading branch information
IronSinew committed Apr 20, 2023
1 parent c654d7c commit cda531c
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 18 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 1.2.1
* Add EmJay mode

#### 1.2.0
* Add DNC mode and supporting clips
* Allow toggling between Wowen Wilson and DNC modes
Expand Down
2 changes: 1 addition & 1 deletion CritWow.toc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Interface: 30401
## Title: CritWow
## Author: IronSinew
## Version: 1.2.0
## Version: 1.2.1
## SavedVariables: CritWowDB

main.lua
44 changes: 27 additions & 17 deletions main.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
local playerGUID = UnitGUID("player")
local lastCritTime = time()
local debounceMax = 5
local debounceFactor = 10

CritWow = {
modes = {
Expand All @@ -14,6 +16,12 @@ CritWow = {
name = "DNC",
dncChance = 92,
soundPath = "Interface\\AddOns\\CritWow\\sounds\\dnc\\"
},
mj = {
id = "mj",
name = "EmJay",
count = 14,
soundPath = "Interface\\AddOns\\CritWow\\sounds\\mj\\"
}
},
defaults = {
Expand All @@ -26,15 +34,20 @@ CritWow = {
function CritWow:PlaySound()
local path = self.modes.wowenWilson.soundPath
local fileName = ""
local soundMode = CritWowDB.mode

if CritWowDB.mode == "dnc" then
if soundMmode == self.modes.dnc.id then
path = self.modes.dnc.soundPath

if math.random(1, 100) <= self.modes.dnc.dncChance then
fileName = "dnc.mp3"
else
fileName = "igc.mp3"
end
elseif soundMode == self.modes.mj.id then
path = self.modes.mj.soundPath

fileName = tostring(math.random(1, self.modes.mj.count)) .. ".mp3"
else
fileName = tostring(math.random(1, self.modes.wowenWilson.count)) .. ".mp3"
end
Expand All @@ -48,7 +61,7 @@ function CritWow:SetDebounceSliderText()
debounceTitle = "Once per " .. self.db.debounce .. "s"
end

getglobal("CritWowDebounceSpeedSlider").Text:SetText("Wows: " .. debounceTitle);
getglobal("CritWowDebounceSpeedSlider").Text:SetText("Clips: " .. debounceTitle);
end

local f = CreateFrame("Frame")
Expand Down Expand Up @@ -97,17 +110,17 @@ function f:InitializeOptions()
-- Debounce slider
local debounceSlider = CreateFrame("Slider", "CritWowDebounceSpeedSlider", self.panel, "OptionsSliderTemplate")
debounceSlider:SetPoint("TOPLEFT", 20, -70)
debounceSlider:SetMinMaxValues(0, 30)
debounceSlider:SetValueStep(2)
debounceSlider:SetMinMaxValues(0, debounceMax * debounceFactor)
debounceSlider:SetValueStep(debounceFactor / 5)
debounceSlider:SetObeyStepOnDrag(true)
debounceSlider:SetValue(CritWowDB.debounce * 10)
debounceSlider:SetValue(CritWowDB.debounce * debounceFactor)
getglobal(debounceSlider:GetName() .. "Low"):SetText("Unl");
getglobal(debounceSlider:GetName() .. "High"):SetText("Every 3");
getglobal(debounceSlider:GetName() .. "High"):SetText(debounceMax);

CritWow:SetDebounceSliderText()
debounceSlider.tooltipText = "Speed of Wows"
debounceSlider.tooltipText = "Frequency of Sounds"
debounceSlider:HookScript("OnValueChanged", function(_)
CritWowDB.debounce = _:GetValue() / 10
CritWowDB.debounce = _:GetValue() / debounceFactor

CritWow:SetDebounceSliderText()
end)
Expand All @@ -130,17 +143,14 @@ function f:InitializeOptions()

UIDropDownMenu_Initialize(dropDown, function(self, level, menuList)
local selectOption = UIDropDownMenu_CreateInfo()
selectOption.text = CritWow.modes.wowenWilson.name
selectOption.arg1 = CritWow.modes.wowenWilson.id
selectOption.checked = CritWowDB.mode == CritWow.modes.wowenWilson.id
selectOption.func = self.SetValue
UIDropDownMenu_AddButton(selectOption)

selectOption.text = CritWow.modes.dnc.name
selectOption.arg1 = CritWow.modes.dnc.id
selectOption.checked = CritWowDB.mode == CritWow.modes.dnc.id
UIDropDownMenu_AddButton(selectOption)

for _, val in pairs(CritWow.modes) do
selectOption.text = val.name
selectOption.arg1 = val.id
selectOption.checked = CritWowDB.mode == val.id
UIDropDownMenu_AddButton(selectOption)
end
end)

function dropDown:SetValue(newValue)
Expand Down
Binary file added sounds/mj/1.mp3
Binary file not shown.
Binary file added sounds/mj/10.mp3
Binary file not shown.
Binary file added sounds/mj/11.mp3
Binary file not shown.
Binary file added sounds/mj/12.mp3
Binary file not shown.
Binary file added sounds/mj/13.mp3
Binary file not shown.
Binary file added sounds/mj/14.mp3
Binary file not shown.
Binary file added sounds/mj/2.mp3
Binary file not shown.
Binary file added sounds/mj/3.mp3
Binary file not shown.
Binary file added sounds/mj/4.mp3
Binary file not shown.
Binary file added sounds/mj/5.mp3
Binary file not shown.
Binary file added sounds/mj/6.mp3
Binary file not shown.
Binary file added sounds/mj/7.mp3
Binary file not shown.
Binary file added sounds/mj/8.mp3
Binary file not shown.
Binary file added sounds/mj/9.mp3
Binary file not shown.

0 comments on commit cda531c

Please sign in to comment.