Commit 1740c38f authored by Caedis's avatar Caedis

Merge branch 'development' into master

parents 9ab93365 e5a365d7
### Version 2.1.2 [ October/15th/2020 ]
### Version 2.1.3 [ October/16th/2020 ]
**New Additions:**
[Volume] Ability to select output audio device
**Bug Fixes:**
**Misc. Changes:**
[Volume] Reworked
[Time Played] Throttled the OnUpdate function and delayed the /played call to piggyback in case another addon calls it.
\ No newline at end of file
[Volume] Made more granually event driven
......@@ -5,7 +5,7 @@ local DT = E:GetModule('DataTexts')
local select = select
local format, join = string.format, string.join
local ceil = math.ceil
local strform = string.format
local format = string.format
local tonumber = tonumber
local tostring = tostring
......@@ -16,6 +16,10 @@ local IsShiftKeyDown = IsShiftKeyDown
local SOUND = SOUND
local ShowOptionsPanel = ShowOptionsPanel
local Sound_GameSystem_GetOutputDriverNameByIndex = Sound_GameSystem_GetOutputDriverNameByIndex
local Sound_GameSystem_GetNumOutputDrivers = Sound_GameSystem_GetNumOutputDrivers
local Sound_GameSystem_RestartSoundSystem = Sound_GameSystem_RestartSoundSystem
local displayString = ''
local volumeCVars =
......@@ -31,7 +35,12 @@ local volumeCVars =
local activeVolumeIndex = 1
local activeVolume = volumeCVars[activeVolumeIndex]
local menu = {
[1] = {text = 'Volume Stream', isTitle = true, notCheckable = true}
[1] = {text = 'Select Volume Stream', isTitle = true, notCheckable = true},
[7] = {text = 'Output Audio Device', isTitle = true, notCheckable = true}
}
local toggleMenu = {
[1] = {text = 'Toggle Volume Stream', isTitle = true, notCheckable = true},
[7] = {text = 'Output Audio Device', isTitle = true, notCheckable = true}
}
local function GetStatusColor(vol, text)
......@@ -39,7 +48,7 @@ local function GetStatusColor(vol, text)
text = vol.Name
end
return strform('|cFF%s%s|r',(getCV(vol.CVs.Volume) == '0' or not vol.Enabled) and 'FF0000' or '00FF00', text)
return format('|cFF%s%s|r',(getCV(vol.CVs.Volume) == '0' or not vol.Enabled) and 'FF0000' or '00FF00', text)
end
local function OnEnter(self)
......@@ -47,18 +56,23 @@ local function OnEnter(self)
DT:SetupTooltip(self)
DT.tooltip:ClearLines()
DT.tooltip:AddLine('Volume Streams')
DT.tooltip:AddLine(' ')
local audioDev = Sound_GameSystem_GetOutputDriverNameByIndex(getCV('Sound_OutputDriverIndex'))
--DT.tooltip:AddLine(format('|cffFFFFFFActive Output Audio Device|r: %s', audioDev))
DT.tooltip:AddLine('|cffFFFFFFActive Output Audio Device|r')
DT.tooltip:AddLine(audioDev)
DT.tooltip:AddLine(' ')
DT.tooltip:AddLine('|cffFFFFFFVolume Streams|r')
for _,vol in ipairs(volumeCVars) do
DT.tooltip:AddDoubleLine(vol.Name, GetStatusColor(vol, strform('%.f', getCV(vol.CVs.Volume) * 100) .. '%'))
DT.tooltip:AddDoubleLine(vol.Name, GetStatusColor(vol, format('%.f', getCV(vol.CVs.Volume) * 100) .. '%'))
end
DT.tooltip:AddLine(' ')
DT.tooltip:AddLine('|cffFFFFFFLeft Click:|r Select Volume Stream')
DT.tooltip:AddLine('|cffFFFFFFRight Click:|r Toggle Volume Stream')
DT.tooltip:AddLine('|cffFFFFFFBoth:|r Select Output Audio Device')
DT.tooltip:AddLine('|cffFFFFFFShift + Left Click:|r Open System Audio Panel')
DT.tooltip:Show()
......@@ -89,30 +103,64 @@ local function OnEvent(self, event, ...)
vol = 0
end
setCV(activeVolume.CVs.Volume, vol)
OnEvent(self, nil)
setCV(activeVolume.CVs.Volume, vol, 'EDT_VOLUME_CHANGED')
end)
OnEvent(self, 'CVAR_UPDATE', 'EDT_VOLUME_TEXT_CHANGE')
OnEvent(self, 'CVAR_UPDATE', 'EDT_VOLUME_STREAM_TOGGLE')
OnEvent(self, 'CVAR_UPDATE', 'EDT_OUTPUT_SOUND_DEVICE_CHANGED')
OnEvent(self, 'CVAR_UPDATE', 'EDT_VOLUME_CHANGED', getCV(activeVolume.CVs.Volume))
end
for i = 1, #volumeCVars do
volumeCVars[i].Enabled = getCV(volumeCVars[i].CVs.Enabled) == '1'
menu[i+1]={
text = volumeCVars[i].Name,
checked = i == activeVolumeIndex,
func = function(slf)
activeVolumeIndex = i;
OnEvent(self, nil);
end
}
end
if event == 'CVAR_UPDATE' then
local cvar_name, value = ...
if cvar_name == 'EDT_VOLUME_CHANGED' then
self.text:SetText(activeVolume.Name..': '..GetStatusColor(activeVolume, format('%.f', value * 100) .. '%'))
elseif cvar_name == 'EDT_VOLUME_TEXT_CHANGE' then
for i = 1, #volumeCVars do
menu[i+1]={
text = volumeCVars[i].Name,
checked = i == activeVolumeIndex,
func = function(slf)
activeVolumeIndex = i;
OnEvent(self, 'CVAR_UPDATE', 'EDT_VOLUME_TEXT_CHANGE');
OnEvent(self, 'CVAR_UPDATE', 'EDT_VOLUME_CHANGED', getCV(volumeCVars[i].CVs.Volume));
end
}
end
elseif cvar_name == 'EDT_VOLUME_STREAM_TOGGLE' then
for i = 1, #volumeCVars do
volumeCVars[i].Enabled = getCV(volumeCVars[i].CVs.Enabled) == '1'
toggleMenu[i + 1] = {
text = volumeCVars[i].Name,
checked = getCV(volumeCVars[i].CVs.Enabled) == '1',
func = function(slf)
setCV(
volumeCVars[i].CVs.Enabled,
(not volumeCVars[i].Enabled) and '1' or '0',
'EDT_VOLUME_STREAM_TOGGLE')
OnEvent(self, 'CVAR_UPDATE', 'EDT_VOLUME_CHANGED', getCV(activeVolume.CVs.Volume));
end
}
end
self.text:SetText(activeVolume.Name..': '..GetStatusColor(activeVolume, strform('%.f', getCV(activeVolume.CVs.Volume) * 100) .. '%'))
elseif cvar_name == 'EDT_OUTPUT_SOUND_DEVICE_CHANGED' then
local numDevices = Sound_GameSystem_GetNumOutputDrivers()
local activeIndex = tonumber(getCV('Sound_OutputDriverIndex'))
for i = 0, numDevices -1 do
local item = {
text = Sound_GameSystem_GetOutputDriverNameByIndex(i),
checked = i == activeIndex,
func = function(slf) setCV('Sound_OutputDriverIndex', i, 'EDT_OUTPUT_SOUND_DEVICE_CHANGED'); Sound_GameSystem_RestartSoundSystem(); end
}
menu[7 + i + 1] = item
toggleMenu[7 + i + 1] = item
end
end
end
end
......@@ -125,29 +173,11 @@ local function OnClick(self, button)
return
end
menu[1].text = 'Select Volume Stream'
for i = 2, #menu do
menu[i].checked = i - 1 == activeVolumeIndex
menu[i].func = function(slf)
activeVolumeIndex = i - 1;
OnEvent(self, nil);
end
end
DT:SetEasyMenuAnchor(DT.EasyMenu, self)
_G.EasyMenu(menu, DT.EasyMenu, nil, nil, nil, 'MENU')
elseif button == 'RightButton' then
menu[1].text = 'Toggle Volume Stream'
for i = 2, #menu do
menu[i].checked = volumeCVars[i - 1].Enabled
menu[i].func = function(slf)
setCV(volumeCVars[i - 1].CVs.Enabled, (not volumeCVars[i - 1].Enabled) and '1' or '0');
OnEvent(self, nil);
end
end
elseif button == 'RightButton' then
DT:SetEasyMenuAnchor(DT.EasyMenu, self)
_G.EasyMenu(menu, DT.EasyMenu, nil, nil, nil, 'MENU')
_G.EasyMenu(toggleMenu, DT.EasyMenu, nil, nil, nil, 'MENU')
end
end
......
......@@ -3,7 +3,7 @@
## Author: Caedis
## URL: https://www.curseforge.com/wow/addons/elvui_extradatatexts
## URL: https://www.tukui.org/addons.php?id=66
## Version: 2.1.2
## Version: 2.1.3
## RequiredDeps: ElvUI
## DefaultState: Enabled
## LoadOnDemand: 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment