Skip to content

Commit

Permalink
feat: Add dnc mode
Browse files Browse the repository at this point in the history
  • Loading branch information
IronSinew committed Apr 20, 2023
1 parent 3c6fe9d commit c654d7c
Show file tree
Hide file tree
Showing 26 changed files with 94 additions and 13 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#### 1.2.0
* Add DNC mode and supporting clips
* Allow toggling between Wowen Wilson and DNC modes

#### 1.1.2
* Add custom changelog

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.0.3
## Version: 1.2.0
## SavedVariables: CritWowDB

main.lua
93 changes: 81 additions & 12 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,50 @@ local playerGUID = UnitGUID("player")
local lastCritTime = time()

CritWow = {

}

local defaults = {
playsSound = true,
debounce = 1,
modes = {
wowenWilson = {
id = "wowenWilson",
name = "Wowen Wilson",
count = 19,
soundPath = "Interface\\AddOns\\CritWow\\sounds\\wowen_wilson\\"
},
dnc = {
id = "dnc",
name = "DNC",
dncChance = 92,
soundPath = "Interface\\AddOns\\CritWow\\sounds\\dnc\\"
}
},
defaults = {
playsSound = true,
debounce = 1,
mode = "wowenWilson",
}
}

function CritWow:PlaySound()
PlaySoundFile("Interface\\AddOns\\CritWow\\sounds\\" .. tostring(math.random(1, 17)) .. ".mp3", "master")
local path = self.modes.wowenWilson.soundPath
local fileName = ""

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

if math.random(1, 100) <= self.modes.dnc.dncChance then
fileName = "dnc.mp3"
else
fileName = "igc.mp3"
end
else
fileName = tostring(math.random(1, self.modes.wowenWilson.count)) .. ".mp3"
end

PlaySoundFile(path .. fileName, "master")
end

function CritWow:SetDebounceSliderText()
local debounceTitle = "Unlimited"
if CritWowDB.debounce > 0 then
debounceTitle = "Once per " .. CritWowDB.debounce .. "s"
if self.db.debounce > 0 then
debounceTitle = "Once per " .. self.db.debounce .. "s"
end

getglobal("CritWowDebounceSpeedSlider").Text:SetText("Wows: " .. debounceTitle);
Expand All @@ -28,24 +56,36 @@ f:RegisterEvent("ADDON_LOADED")
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
f:SetScript("OnEvent", function(self, event, addOnName)
if event == "ADDON_LOADED" and addOnName == "CritWow" then
self:SetDefaults()
self:InitializeOptions()
end
self:COMBAT_LOG_EVENT_UNFILTERED(CombatLogGetCurrentEventInfo())
end)

function f:SetDefaults()
CritWowDB = CritWowDB or CopyTable(defaults)
function CritWow:SetDefaults()
CritWowDB = CritWowDB or CopyTable(self.defaults)

-- Set any missing config options
for idx, val in pairs(self.defaults) do
if not CritWowDB[idx] then
CritWowDB[idx] = self.defaults[idx]
end
end

self.db = CritWowDB
end

function f:InitializeOptions()
CritWow:SetDefaults()

self.panel = CreateFrame("Frame")
self.panel.name = "Crit Wow"
self.db = CritWowDB

local title = self.panel:CreateFontString("ARTWORK", nil, "GameFontNormalLarge")
title:SetPoint("TOP")
title:SetText("Crit Wow")

-- Play sounds check
local cb = CreateFrame("CheckButton", nil, self.panel, "InterfaceOptionsCheckButtonTemplate")
cb:SetPoint("TOPLEFT", 20, -20)
cb.Text:SetText("Play sounds")
Expand All @@ -54,6 +94,7 @@ function f:InitializeOptions()
end)
cb:SetChecked(CritWowDB.playsSound)

-- Debounce slider
local debounceSlider = CreateFrame("Slider", "CritWowDebounceSpeedSlider", self.panel, "OptionsSliderTemplate")
debounceSlider:SetPoint("TOPLEFT", 20, -70)
debounceSlider:SetMinMaxValues(0, 30)
Expand All @@ -71,6 +112,7 @@ function f:InitializeOptions()
CritWow:SetDebounceSliderText()
end)

-- Play test sound button
local btn = CreateFrame("Button", nil, self.panel, "UIPanelButtonTemplate")
btn:SetPoint("TOPLEFT", cb, 200, -10)
btn:SetText("Play test sound")
Expand All @@ -80,6 +122,33 @@ function f:InitializeOptions()
CritWow:PlaySound()
end)

-- Sound mode dropdown
local dropDown = CreateFrame("FRAME", nil, self.panel, "UIDropDownMenuTemplate")
dropDown:SetPoint("TOPLEFT", btn, -20, -30)
UIDropDownMenu_SetWidth(dropDown, 200)
UIDropDownMenu_SetText(dropDown, "Sound mode: " .. CritWow.modes[self.db.mode].name)

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)

end)

function dropDown:SetValue(newValue)
CritWowDB.mode = newValue
UIDropDownMenu_SetText(dropDown, "Sound mode: " .. CritWow.modes[CritWowDB.mode].name)
CloseDropDownMenus()
end

InterfaceOptions_AddCategory(self.panel)
end

Expand Down
Binary file added sounds/dnc/dnc.mp3
Binary file not shown.
Binary file added sounds/dnc/igc.mp3
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added sounds/wowen_wilson/18.mp3
Binary file not shown.
4 changes: 4 additions & 0 deletions sounds/wowen_wilson/18.mp3Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=https://www.soundboard.com/sb/sound/996265
HostUrl=https://www.soundboard.com/track/download/996265
Binary file added sounds/wowen_wilson/19.mp3
Binary file not shown.
4 changes: 4 additions & 0 deletions sounds/wowen_wilson/19.mp3Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=https://www.soundboard.com/sb/sound/996257
HostUrl=https://www.soundboard.com/track/download/996257
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c654d7c

Please sign in to comment.