Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Simple Sound module tibia 13 Qt #1098

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 175 additions & 27 deletions modules/client_options/data_options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,34 +58,13 @@ return {
enableAudio = {
value = true,
action = function(value, options, controller, panels, extraWidgets)
if g_sounds then
g_sounds.setAudioEnabled(value)
end

if value then
extraWidgets.audioButton:setIcon('/images/topbuttons/button_mute_up')
setOption("soundMaster", 100)
else
extraWidgets.audioButton:setIcon('/images/topbuttons/button_mute_pressed')
setOption("soundMaster", 1)
end
end
},
enableMusicSound = {
value = true,
action = function(value, options, controller, panels, extraWidgets)
if g_sounds then
g_sounds.getChannel(SoundChannels.Music):setEnabled(value)
end
end
},
musicSoundVolume = {
value = 100,
action = function(value, options, controller, panels, extraWidgets)
if g_sounds then
g_sounds.getChannel(SoundChannels.Music):setGain(value / 100)
end
panels.soundPanel:recursiveGetChildById('musicSoundVolume'):setText(tr('Music volume: %d', value))
end
},
enableLights = {
value = true,
action = function(value, options, controller, panels, extraWidgets)
Expand Down Expand Up @@ -381,16 +360,20 @@ return {
value = 0,
action = function(value, options, controller, panels, extraWidgets)
local bar = modules.game_healthcircle.optionPanel:recursiveGetChildById('distFromCenScrollbar')
bar:setText(tr('Distance: %s', bar:recursiveGetChildById('valueBar'):getValue()))
modules.game_healthcircle.setDistanceFromCenter(bar:recursiveGetChildById('valueBar'):getValue())
if bar then
bar:setText(tr('Distance: %s', bar:recursiveGetChildById('valueBar'):getValue()))
modules.game_healthcircle.setDistanceFromCenter(bar:recursiveGetChildById('valueBar'):getValue())
end
end
},
opacityScrollbar = {
value = 0,
action = function(value, options, controller, panels, extraWidgets)
local bar = modules.game_healthcircle.optionPanel:recursiveGetChildById('opacityScrollbar')
bar:setText(tr('Opacity: %s', bar:recursiveGetChildById('valueBar'):getValue() / 100))
modules.game_healthcircle.setCircleOpacity(bar:recursiveGetChildById('valueBar'):getValue() / 100)
if bar then
bar:setText(tr('Opacity: %s', bar:recursiveGetChildById('valueBar'):getValue() / 100))
modules.game_healthcircle.setCircleOpacity(bar:recursiveGetChildById('valueBar'):getValue() / 100)
end
end
},
profile = {
Expand Down Expand Up @@ -470,4 +453,169 @@ return {
listKeybindsComboBox(value)
end
},
-- TODO move to \modules\game_sound\game_sound.lua
battleSoundOwnBattlesubChannelsSpells = {
value = true,
action = function(value, options, controller, panels, extraWidgets)
if value then
panels.battleSoundsPanel:recursiveGetChildById("panelOwnBattleSubChannels"):enable()

else
panels.battleSoundsPanel:recursiveGetChildById("panelOwnBattleSubChannels"):disable()

end
end
},
battleSoundOwnBattleSubChannelsAttack = true,
battleSoundOwnBattleSoundSubChannelsHealing = true,
battleSoundOwnBattleSoundSubChannelsSupport = true,
battleSoundOwnBattleSoundSubChannelsWeapons = true,
battleSoundOtherPlayersSubChannelsSpells = {
value = true,
action = function(value, options, controller, panels, extraWidgets)
if value then
panels.battleSoundsPanel:recursiveGetChildById("panelOtherPlayersSubChannels"):enable()

else
panels.battleSoundsPanel:recursiveGetChildById("panelOtherPlayersSubChannels"):disable()

end
end
},
battleSoundOtherPlayersSubChannelsAttack = true,
battleSoundOtherPlayersSubChannelsHealing = true,
battleSoundOtherPlayersSubChannelsSupport = true,
battleSoundOtherPlayersSubChannelsWeapons = true,
battleSoundCreatureSubChannelsNoises = true,
battleSoundCreatureSubChannelsNoisesDeath = true,
battleSoundCreatureSubChannelsAttacksAndSpells = true,
soundAnthem = true,
soundFoodAndBeverages = true,
soundMoveItem = true,
soundUIsubChannelsInteractions = true,
soundUIsubChannelsJoinLeaveParty = true,
soundUIsubChannelsVipLoginLogout = true,
soundNotificationUIInteractions = true,
soundNotificationsubChannelsParty = true,
soundNotificationsubChannelsGuild = true,
soundNotificationsubChannelsLocalChat = true,
soundNotificationsubChannelsPrivateMessages = true,
soundNotificationsubChannelsNPC = true,
soundNotificationsubChannelsGlobal = true,
soundNotificationsubChannelsTeamFinder = true,
soundNotificationsubChannelsRaidAnnuncements = true,
soundNotificationsubChannelsSystemAnnouncements = true,
battleSoundOwnBattle = {
value = 100,
action = function(value, options, controller, panels, extraWidgets)
panels.battleSoundsPanel:recursiveGetChildById('battleSoundOwnBattle'):setText(tr(
'Own Battle Sounds: %d %%', value))
end
},
battleSoundOtherPlayers = {
value = 100,
action = function(value, options, controller, panels, extraWidgets)
panels.battleSoundsPanel:recursiveGetChildById('battleSoundOtherPlayers'):setText(tr(
'Others Players: %d %%', value))
end
},
battleSoundCreature = {
value = 100,
action = function(value, options, controller, panels, extraWidgets)
panels.battleSoundsPanel:recursiveGetChildById('battleSoundCreature'):setText(tr('Creature: %d %%', value))
end
},
soundUI = {
value = 100,
action = function(value, options, controller, panels, extraWidgets)
panels.iuSoundPanel:recursiveGetChildById('soundUI'):setText(tr('UI Volumen: %d %%', value))
end
},
soundMaster = {
value = 100,
aux = true,
action = function(value, options, controller, panels, extraWidgets)
if not g_sounds then
return
end
local soundMasterWidget = panels.soundPanel:recursiveGetChildById('soundMaster')
soundMasterWidget:setText(string.format('Master Volume: %d %%', value))
for channelName, channelId in pairs(SoundChannels) do
g_sounds.getChannel(channelId):setGain(value / 100)
end
local shouldDisable = value <= 1
local hasChanged = shouldDisable ~= (options.soundMaster.aux or false)
if not hasChanged then
return
end
options.soundMaster.aux = shouldDisable
if shouldDisable then
g_sounds.setAudioEnabled(false)
extraWidgets.audioButton:setIcon('/images/topbuttons/button_mute_pressed')
else
g_sounds.setAudioEnabled(true)
extraWidgets.audioButton:setIcon('/images/topbuttons/button_mute_up')
end
local function togglePanel(panel)
if not panel then
return
end
local infoPanel = panel:recursiveGetChildById('info')
local children = panel:getChildren()
for _, widget in ipairs(children) do
if widget:getStyle().__class ~= "UILabel" then
widget:setEnabled(not shouldDisable)
end
end
infoPanel:setVisible(shouldDisable)
infoPanel:setHeight(shouldDisable and 30 or 0)
end
togglePanel(panels.battleSoundsPanel)
togglePanel(panels.iuSoundPanel)
end
},
soundMusic = {
value = 100,
aux = true,
event = nil,
action = function(value, options, controller, panels, extraWidgets)
panels.soundPanel:recursiveGetChildById('soundMusic'):setText(tr('Music Volume: %d %%', value))
if not g_sounds then
return
end
g_sounds.getChannel(SoundChannels.Music):setGain(value / 100)
local shouldBeDisabled = value <= 1
if shouldBeDisabled ~= (not options.soundMusic.aux) then
options.soundMusic.aux = not shouldBeDisabled
if options.soundMusic.event ~= nil then
removeEvent(options.soundMusic.event)
end
options.soundMusic.event = scheduleEvent(function()
if shouldBeDisabled then
g_sounds.getChannel(SoundChannels.Music):setEnabled(false)
else
g_sounds.getChannel(SoundChannels.Music):setEnabled(true)
end
end, 100)
end
end
},
soundAmbience = {
value = 100,
action = function(value, options, controller, panels, extraWidgets)
panels.soundPanel:recursiveGetChildById('soundAmbience'):setText(tr('Ambience Volumen: %d %%', value))
end
},
soundItems = {
value = 100,
action = function(value, options, controller, panels, extraWidgets)
panels.soundPanel:recursiveGetChildById('soundItems'):setText(tr('Item Volume: %d %%', value))
end
},
soundEventVolume = {
value = 100,
action = function(value, options, controller, panels, extraWidgets)
panels.soundPanel:recursiveGetChildById('soundEventVolume'):setText(tr('Event Volume: %d %%', value))
end
}
}
19 changes: 12 additions & 7 deletions modules/client_options/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ panels = {
interface = nil,
misc = nil,
miscHelp = nil,
keybindsPanel = nil
keybindsPanel = nil,
battleSoundsPanel = nil,
iuSoundPanel = nil,

}
-- LuaFormatter off
local buttons = { {
Expand Down Expand Up @@ -43,14 +46,14 @@ local buttons = { {
}, {
text = "Sound",
icon = "/images/icons/icon_sound",
open = "soundPanel"
--[[ subCategories = {{
open = "soundPanel",
subCategories = {{
text = "Battle Sounds",
open = "Battle_Sounds"
open = "battleSoundsPanel"
}, {
text = "UI Sounds",
open = "UI_Sounds"
}} ]]
open = "iuSoundPanel"
}}
}, {
text = "Misc.",
icon = "/images/icons/icon_misc",
Expand Down Expand Up @@ -207,7 +210,9 @@ function controller:onInit()
panels.interfaceConsole = g_ui.loadUI('styles/interface/console', controller.ui.optionsTabContent)
panels.interfaceHUD = g_ui.loadUI('styles/interface/HUD', controller.ui.optionsTabContent)

panels.soundPanel = g_ui.loadUI('styles/sound/audio', controller.ui.optionsTabContent)
panels.soundPanel = g_ui.loadUI('styles/sound/sound', controller.ui.optionsTabContent)
panels.battleSoundsPanel = g_ui.loadUI('styles/sound/battleSounds', controller.ui.optionsTabContent)
panels.iuSoundPanel = g_ui.loadUI('styles/sound/uiSounds', controller.ui.optionsTabContent)

panels.misc = g_ui.loadUI('styles/misc/misc', controller.ui.optionsTabContent)
panels.miscHelp = g_ui.loadUI('styles/misc/help', controller.ui.optionsTabContent)
Expand Down
36 changes: 0 additions & 36 deletions modules/client_options/styles/sound/audio.otui

This file was deleted.

Loading
Loading