Download
(11 Kb)
Download
Updated: 03/20/23 04:03 PM
Addon for:
LibAddonMenu-2.0.
Pictures
File Info
Compatibility:
Scribes of Fate (8.3.5)
Firesong (8.2.5)
Lost Depths (8.1.5)
High Isle (8.0.0)
Updated:03/20/23 04:03 PM
Created:04/18/22 06:37 PM
Monthly downloads:4,673
Total downloads:119,495
Favorites:86
MD5:
LibAddonMenu - SoundSlider widget  Popular! (More than 5000 hits)
Version: 5
by: Baertram [More]
LibAddonMenu - SoundSlider widget

A SoundSlider widget for the library LibAddonMenu.
Just install it in addition to LibAddonMenu-2.0 (release 33 or newer is needed!) and use the new widget type "soundslider" in your addon'
settings panel.

Add to your manifest txt file:
Code:
## DependsOn: LibAddonMenuSoundSlider
This widget is based on a slider and will provide a string (default, using internal sound names) or number (index, may change in the future if new sounds are added by ZOs) way to save the selected sound.
Clicking the slider's slide button or entering a number (index) into the slider's editbox will play the selected sound (can be disabled).
The name of the selected sound will be shown at the slider's label and at the tooltip as seperate new line (can be disabled).

Provides the following parameters:
Code:
--[[soundSliderData = {
    type = "soundslider",
    name = "My sound slider", -- or string id or function returning a string
    getFunc = function() return db.var end,
    setFunc = function(value) db.var = value doStuff() end,
    autoSelect = false, -- boolean, automatically select everything in the text input field when it gains focus (optional)
    inputLocation = "below", -- or "right", determines where the input field is shown. This should not be used within the addon menu and is for custom sliders (optional)
    saveSoundIndex = false, -- or function returning a boolean (optional) If set to false (default) the internal soundName will be saved. If set to true the selected sound's index will be saved to the SavedVariables (the index might change if sounds get inserted later!).
    showSoundName = true, -- or function returning a boolean (optional) If set to true (default) the selected sound name will be shown at the label of the slider, and at the tooltip too
    playSound = true, -- or function returning a boolean (optional) If set to true (default) the selected sound name will be played via function PlaySound. Will be ignored if table playSoundData is provided!
    playSoundData = {number playCount, number delayInMS, number increaseVolume}, -- table or function returning a table. If this table is provided the chosen sound will be played playCount (default is 1) times after each other, with a delayInMS (default is 0) in milliseconds in between, and each played sound will be played increaseVolume times (directly at the same time) to increase the volume (default is 1, max is 10) (optional)
    showPlaySoundButton = false, --Boolean or function returning a boolean. If true a button control will be shown next to the slider, which will preview the selected sound (based on playSoundData or playSound. If both are nil/false the button won't be shown) (optional)
    noAutomaticSoundPreview = false, --Boolean or function returning a boolean. Only works if showPlaySoundButton is true! If true the automatic sound preview (based on playSoundData or playSound) will be disabled and only the sound preview button is shown (optional)
    readOnly = true, -- boolean, you can use the slider, but you can't insert a value manually (optional)
    tooltip = "Sound slider's tooltip text.", -- or string id or function returning a string (optional)
    width = "full", -- or "half" (optional)
    disabled = function() return db.someBooleanSetting end, --or boolean (optional)
    warning = "May cause permanent awesomeness.", -- or string id or function returning a string (optional)
    requiresReload = false, -- boolean, if set to true, the warning text will contain a notice that changes are only applied after an UI reload and any change to the value will make the "Apply Settings" button appear on the panel which will reload the UI when pressed (optional)
    default = defaults.var, -- default value or function that returns the default value (optional)
    helpUrl = "https://www.esoui.com/portal.php?id=218&a=faq", -- a string URL or a function that returns the string URL (optional)
    reference = "MyAddonSoundSlider" -- unique global reference to control (optional)
} ]]

API functions provided:
Lua Code:
  1. --Global function to convert the soundSlider soundIndex to the internal SOUNDS name (SOUNDS = { [soundName] = sound_internal_name, ... }
  2. --Parameters: soundIndex number
  3. --Returns nilable:internal_sound_name String
  4. function ConvertLAMSoundSliderSoundIndexToName(soundIndex)
  5.  
  6. --Global function to convert the soundSlider soundNameInternal of SOUNDS to the index used in this widget (SOUNDS = { [soundName] = sound_internal_name, ... }
  7. --Parameters: soundNameInternal string
  8. --Returns nilable:widgetsSoundIndex number
  9. function ConvertLAMSoundSliderSoundNameToIndex(soundNameInternal)
  10.  
  11. --Global function to play the sound of an internal_sound_name, or by using the soundIndex of the soundSlider widget.
  12. --The sound will be optionally played "volume" times (1 to 10) to increase the volume.
  13. --The sound will be optionally repeated "repeats" time, with a "repeatDelayMS" delay in milliseconds in between.
  14. --Volume default is 1, repeats default is 1 and repeatsDelayMS default is 0 milliseconds
  15. --Either the soundNameInternal or the soundIndex must be given!
  16. --Parameters: soundNameInternal optional:string, soundIndex optional:number, volume optional:number(1 to 10), repeats optional:number, repeatDelayMS optional:number milliseconds
  17. --Returns nilable:boolean wasPlayed
  18. function PlayLAMSoundSliderSound(soundNameInternal, soundIndex, volume, repeats, repeatDelayMS)

You can use the function like that to get the internal_sound_name which you need to use for the ESO API function PlaySound("internal_sound_name").
This will only work if the soundIndex passed in is a valid number index!

Code:
local internalSoundName = ConvertLAMSoundSliderSoundIndexToName(myAddonName.savedVariablesTable.selectedSoundIndexOfSoundSlider)
if internalSoundName ~= nil then PlaySound(internalSoundName) end
Example usage in a LAM settings panel:
Lua Code:
  1. {
  2. type = 'soundslider',
  3.             name = "My sound slider 1",
  4.             tooltip = "This is a sound slider, number 1",
  5.             playSound = false, --play the sound upon selection (disabled automtically internally as playSoundData table was provided too!)
  6.             playSoundData = {playCount = 2, delayInMS = 500, increaseVolume = 2 }, -- play 2 times with a delay in between of 500ms, making the volume increase by 2 (same sound is played 2 times at the same time)
  7.             showPlaySoundButton = function() return true end,
  8.             noAutomaticSoundPreview = true, --do not play the sound upon selection/change (use the sound preview button to manually play it)
  9.             showSoundName = true, --show the sound name at the slider's label and tooltip
  10.             saveSoundIndex = false, -- save the sound name, not the index (index could change)
  11.             getFunc = function()
  12.                 return myAddon.settings.soundName1
  13.             end,
  14.             setFunc = function(value)
  15.                 myAddon.settings.soundName1 = value
  16.             end,
  17.             default = myAddon.settingsDefault.soundName1,
  18.             reference = "MyAddonSoundSlider1",
  19.         },

GitHub
LibAddonMenu - SoundSlider widget

Documentation
Version 5 - 2023-03-20
Added more API functions

--Global function to convert the soundSlider soundIndex to the internal SOUNDS name (SOUNDS = { [soundName] = sound_internal_name, ... }
--Parameters: soundIndex number
--Returns nilable:internal_sound_name String
function ConvertLAMSoundSliderSoundIndexToName(soundIndex)


--Global function to convert the soundSlider soundNameInternal of SOUNDS to the index used in this widget (SOUNDS = { [soundName] = sound_internal_name, ... }
--Parameters: soundNameInternal string
--Returns nilable:widgetsSoundIndex number
function ConvertLAMSoundSliderSoundNameToIndex(soundNameInternal)


--Global function to play the sound of an internal_sound_name, or by using the soundIndex of the soundSlider widget.
--The sound will be optionally played "volume" times (1 to 10) to increase the volume.
--The sound will be optionally repeated "repeats" time, with a "repeatDelayMS" delay in milliseconds in between.
--Volume default is 1, repeats default is 1 and repeatsDelayMS default is 0 milliseconds
--Either the soundNameInternal or the soundIndex must be given!
--Parameters: soundNameInternal optional:string, soundIndex optional:number, volume optional:number(1 to 10), repeats optional:number, repeatDelayMS optional:number milliseconds
--Returns nilable:boolean wasPlayed
function PlayLAMSoundSliderSound(soundNameInternal, soundIndex, volume, repeats, repeatDelayMS)


Version 4 - 2023-03-03
Added boolean data entry: noAutomaticSoundPreview
noAutomaticSoundPreview = false, --Boolean or function returning a boolean. Only works if showPlaySoundButton is true! If true the automatic sound preview (based on playSoundData or playSound) will be disabled and only the sound preview button is shown (optional)

Version 3 - 2023-03-01
Changed playSound data entry, and added playSoundData data entry:
playSound = true, -- or function returning a boolean (optional) If set to true (default) the selected sound name will be played via function PlaySound. Will be ignored if table playSoundData is provided!
playSoundData = {number playCount, number delayInMS, number increaseVolume}, -- table or function returning a table. If this table is provided the chosen sound will be played playCount (default is 1) times after each other, with a delayInMS (default is 0) in milliseconds in between, and each played sound will be played increaseVolume times (directly at the same time) to increase the volume (default is 1, max is 10) (optional)
showPlaySoundButton = false, --Boolean or function returning a boolean. If true a button control will be shown next to the slider, which will preview the selected sound (based on playSoundData or playSound. If both are nil/false the button won't be shown) (optional)

Version 2 - 2022-04-19
-Removed LAM.soundData debug tables
-Added global function to convert the soundSlider's soundIndex number to the internal_sound_name String which you can use with API function PlaySound("internal_sound_name")

Code:
--Global function to convert the soundSlider soundIndex to the internal SOUNDS name, which you can play via the
--API function PlaySound(internal_sound_name)
--Parameters: soundIndex number of the soundSlider's getFunc.
-->Will only work if the soundSlider's soundSliderData table entry saveSoundIndex == true! Else the getFunc's returned
-->value will be the internal_sound_name String already!
--Returns internal_sound_name String
function ConvertLAMSoundSliderSoundIndexToName(soundIndex)
Archived Files (4)
File Name
Version
Size
Uploader
Date
4
11kB
Baertram
03/03/23 03:25 PM
3
11kB
Baertram
03/02/23 12:35 PM
2
9kB
Baertram
04/19/22 04:13 AM
1
8kB
Baertram
04/18/22 06:37 PM


There have been no comments posted to this file.
Be the first to add one.



Category Jump:

Support AddOn Development!

You have just downloaded by the author . If you like this AddOn why not consider supporting the author? This author has set up a donation account. Donations ensure that authors can continue to develop useful tools for everyone.