Skip to content

Commit a375638

Browse files
authored
Add sound preview button (#138)
1 parent 21b539b commit a375638

File tree

2 files changed

+55
-6
lines changed

2 files changed

+55
-6
lines changed

config.lua

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,48 @@ local function InitializeSettings()
203203
end
204204
end
205205

206-
-- Create dropdown button
206+
-- sound preview button
207+
if not frame.previewButton then
208+
frame.previewButton = CreateFrame("Button", nil, frame)
209+
frame.previewButton:SetSize(20, 20)
210+
frame.previewButton:SetPoint("LEFT", frame, "CENTER", -74, 0)
211+
frame.previewButton:SetHeight(26)
212+
213+
local previewIcon = frame.previewButton:CreateTexture(nil, "ARTWORK")
214+
previewIcon:SetAllPoints()
215+
previewIcon:SetTexture("Interface\\Common\\VoiceChat-Speaker")
216+
previewIcon:SetVertexColor(0.8, 0.8, 0.8)
217+
218+
frame.previewButton:SetScript("OnEnter", function(control)
219+
previewIcon:SetVertexColor(1, 1, 1)
220+
GameTooltip:SetOwner(control, "ANCHOR_TOP")
221+
GameTooltip:SetText(L["Preview Sound"])
222+
GameTooltip:Show()
223+
end)
224+
225+
frame.previewButton:SetScript("OnLeave", function(control)
226+
previewIcon:SetVertexColor(0.8, 0.8, 0.8)
227+
GameTooltip:Hide()
228+
end)
229+
230+
-- Play current sound on click
231+
frame.previewButton:SetScript("OnClick", function(control)
232+
local media = LibStub("LibSharedMedia-3.0")
233+
local currentSound = GetSoundValue()
234+
local soundFile = media:Fetch("sound", currentSound)
235+
if soundFile then
236+
if addon.db.useMaster then
237+
PlaySoundFile(soundFile, "Master")
238+
else
239+
PlaySoundFile(soundFile)
240+
end
241+
end
242+
end)
243+
end
244+
207245
if not frame.soundDropdown then
208246
frame.soundDropdown = CreateFrame("DropdownButton", nil, frame, "WowStyle1DropdownTemplate")
209-
frame.soundDropdown:SetPoint("LEFT", frame, "CENTER", -48, 0)
247+
frame.soundDropdown:SetPoint("LEFT", frame.previewButton, "RIGHT", 5, 0)
210248
frame.soundDropdown:SetPoint("RIGHT", frame, "RIGHT", -20, 0)
211249
frame.soundDropdown:SetHeight(26)
212250

@@ -216,8 +254,8 @@ local function InitializeSettings()
216254

217255
local sounds = LibStub("LibSharedMedia-3.0"):List("sound")
218256
for _, sound in next, sounds do
219-
local function OnSelection(sound)
220-
SetSoundValue(sound)
257+
local function OnSelection(soundValue)
258+
SetSoundValue(soundValue)
221259
UpdateDropdownText()
222260
end
223261
rootDescription:CreateRadio(sound, IsSoundSelected, OnSelection, sound)
@@ -279,8 +317,8 @@ local function InitializeSettings()
279317
nil -- gameDataFunc
280318
)
281319

282-
local layout = SettingsPanel:GetLayout(category)
283-
layout:AddInitializer(wipeButtonInitializer)
320+
local addonLayout = SettingsPanel:GetLayout(category)
321+
addonLayout:AddInitializer(wipeButtonInitializer)
284322

285323
Settings.RegisterAddOnCategory(category)
286324
end

locales.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ L["Send bugs"] = "Send bugs"
3939
L["Sent by %s (%s)"] = "Sent by %s (%s)"
4040
L["Small"] = "Small"
4141
L["Sound"] = "Sound"
42+
L["Preview Sound"] = "Preview Sound"
4243
L["There's a bug in your soup!"] = "There's a bug in your soup!"
4344
L["Throttle at excessive amount"] = "Throttle at excessive amount"
4445
L["throttleDesc"] = "Sometimes addons can generate hundreds of bugs per second, which can lock up the game. Enabling this option will throttle bug grabbing, preventing lockup when this happens."
@@ -95,6 +96,7 @@ if locale == "deDE" then
9596
L["Sent by %s (%s)"] = "Gesendet von %s (%s)"
9697
L["Small"] = "Klein"
9798
L["Sound"] = "Sound"
99+
L["Preview Sound"] = "Sound-Vorschau"
98100
L["There's a bug in your soup!"] = "Du hast einen Fehler entdeckt!"
99101
L["Throttle at excessive amount"] = "Bei Übermaß temporär drosseln"
100102
L["throttleDesc"] = "Manchmal können Addons hunderte von Fehlern pro Sekunde generieren, was wiederum das Spiel einfrieren lassen kann. Das Aktivieren dieser Option drosselt die Fehleraufzeichnung und verhindert das Einfrieren des Spiels."
@@ -149,6 +151,7 @@ elseif locale == "esES" then
149151
L["Sent by %s (%s)"] = "Enviado por %s (%s)"
150152
L["Small"] = "Pequeño"
151153
L["Sound"] = "Sonido"
154+
L["Preview Sound"] = "Vista previa de sonido"
152155
L["There's a bug in your soup!"] = "Ha ocurrido un error!"
153156
L["Throttle at excessive amount"] = "Limitar en cantidad excesiva"
154157
L["throttleDesc"] = "A veces accesorios puede generar cientos de errores por segundo, lo que puede bloquear el juego. Al habilitar esta opción, se limitará la captura de errores, evitando el bloqueo cuando esto ocurre."
@@ -203,6 +206,7 @@ elseif locale == "esMX" then
203206
L["Sent by %s (%s)"] = "Enviado por %s (%s)"
204207
L["Small"] = "Pequeño"
205208
L["Sound"] = "Sonido"
209+
L["Preview Sound"] = "Vista previa de sonido"
206210
L["There's a bug in your soup!"] = "Ha ocurrido un error!"
207211
L["Throttle at excessive amount"] = "Limitar en cantidad excesiva"
208212
L["throttleDesc"] = "A veces accesorios puede generar cientos de errores por segundo, lo que puede bloquear el juego. Al habilitar esta opción, se limitará la captura de errores, evitando el bloqueo cuando esto ocurre."
@@ -257,6 +261,7 @@ elseif locale == "frFR" then
257261
L["Sent by %s (%s)"] = "Envoyé par %s (%s)"
258262
L["Small"] = "Petite"
259263
L["Sound"] = "Son"
264+
L["Preview Sound"] = "Prévisualiser le son"
260265
L["There's a bug in your soup!"] = "Il y a un bug dans ta soupe !"
261266
L["Throttle at excessive amount"] = "Limiter en cas de quantité excessive"
262267
L["throttleDesc"] = "Parfois, les AddOns peuvent générer des centaines de bugs par seconde, ce qui peut faire planter le jeu. Activer cette option limite la capture des bugs pour éviter cela."
@@ -311,6 +316,7 @@ elseif locale == "koKR" then
311316
L["Sent by %s (%s)"] = "%s님에게 보냄 (%s)"
312317
L["Small"] = "작게"
313318
L["Sound"] = "소리"
319+
L["Preview Sound"] = "소리 미리듣기"
314320
L["There's a bug in your soup!"] = "수프에 벌레가 있습니다!"
315321
L["Throttle at excessive amount"] = "과도한 양의 스로틀"
316322
L["throttleDesc"] = "때로는 애드온이 초당 수백 개의 버그를 생성하여 게임이 잠금 상태가 될 수 있습니다. 이 옵션을 활성화하면 버그 수집을 스로틀링하여 이러한 상황이 발생했을 때 게임이 잠기는 것을 방지할 수 있습니다."
@@ -365,6 +371,7 @@ elseif locale == "ruRU" then
365371
L["Sent by %s (%s)"] = "Отправлено от %s (%s)"
366372
L["Small"] = "Маленький"
367373
L["Sound"] = "Звук"
374+
L["Preview Sound"] = "Прослушать звук"
368375
L["There's a bug in your soup!"] = "У тебя муха в супе!"
369376
L["Throttle at excessive amount"] = "Притормаживать при спаме багов"
370377
L["throttleDesc"] = "Иногда аддоны могут генерировать сотни багов в секунду, что может заблокировать игру. Включение этой опции позволит прерывать перехват ошибок, если будет слишком большой поток."
@@ -419,6 +426,7 @@ elseif locale == "zhCN" then
419426
L["Sent by %s (%s)"] = "%s发送(%s)"
420427
L["Small"] = ""
421428
L["Sound"] = "音效"
429+
L["Preview Sound"] = "试听音效"
422430
L["There's a bug in your soup!"] = "这里有一个恶心的错误!"
423431
L["Throttle at excessive amount"] = "过度错误数量过滤"
424432
L["throttleDesc"] = "一些插件可能每秒生成成百个错误,从而影响了正常游戏。启用此选项,将会截流错误,防止发生影响正常游戏。"
@@ -473,6 +481,7 @@ elseif locale == "zhTW" then
473481
L["Sent by %s (%s)"] = "由%s傳送(%s)"
474482
L["Small"] = ""
475483
L["Sound"] = "音效"
484+
L["Preview Sound"] = "試聽音效"
476485
L["There's a bug in your soup!"] = "在你的湯裡有一隻臭蟲啊!"
477486
L["Throttle at excessive amount"] = "調節錯誤數量"
478487
L["throttleDesc"] = "有時插件可能每秒產生上百個錯誤,進而影響遊戲。啟用此設定,將會扼殺錯誤,防止發生影響遊戲。"
@@ -527,6 +536,7 @@ elseif locale == "ptBR" then
527536
L["Sent by %s (%s)"] = "Enviado por %s (%s)"
528537
L["Small"] = "Pequeno"
529538
L["Sound"] = "Som"
539+
L["Preview Sound"] = "Pré-visualizar som"
530540
L["There's a bug in your soup!"] = "Tem um inseto (falha) em sua sopa!"
531541
L["Throttle at excessive amount"] = "Suprimir quando em grande quantidade"
532542
L["throttleDesc"] = "Algumas vezes addons podem gerar centenas de falhas por segundo, o que pode travar o jogo. Ao habilitar essa opção acontecerá uma regulação na captura de falhas, prevenindo travamentos quando isso acontecer."
@@ -581,6 +591,7 @@ elseif locale == "itIT" then
581591
L["Sent by %s (%s)"] = "Inviato da %s (%s)"
582592
L["Small"] = "Piccolo"
583593
L["Sound"] = "Suono"
594+
L["Preview Sound"] = "Anteprima suono"
584595
L["There's a bug in your soup!"] = "Un bug è stato rilevato!"
585596
L["Throttle at excessive amount"] = "Blocca ad una quantità eccessiva"
586597
L["throttleDesc"] = "Alcune volte gli addon possono generare centinaia di bug al secondo, cosa che può bloccare il gioco. Abilitare questa opzione bloccherà la cattura dei bug, in modo da impedire il blocco del gioco."

0 commit comments

Comments
 (0)