diff --git a/TaosGroupTools/Defaults.lua b/TaosGroupTools/Defaults.lua index 139f5d8..b60814c 100644 --- a/TaosGroupTools/Defaults.lua +++ b/TaosGroupTools/Defaults.lua @@ -17,6 +17,7 @@ TGT_DEFAULTS = -- Group Ultimate settings ["OnlyAva"] = false, ["VisibleOffset"] = 2, + ["Sound"] = { 1, "No Sound" }, ["Style"] = 3, -- Positioning ["PosX"] = 0, diff --git a/TaosGroupTools/TaosGroupTools.lua b/TaosGroupTools/TaosGroupTools.lua index 46a1bd2..244e53a 100644 --- a/TaosGroupTools/TaosGroupTools.lua +++ b/TaosGroupTools/TaosGroupTools.lua @@ -15,8 +15,8 @@ local ISMOCKED = false local LOG_NAME = "TGT-DebugLogger" local LOG_COMMAND = "/tgtlogs" -local TRACE_ACTIVE = true -local DEBUG_ACTIVE = true +local TRACE_ACTIVE = false +local DEBUG_ACTIVE = false local ERROR_ACTIVE = true local DIRECT_PRINT = true local CATCH_LUA_ERRORS = false diff --git a/TaosGroupTools/i18n/de.lua b/TaosGroupTools/i18n/de.lua index cc555cf..020c4cb 100644 --- a/TaosGroupTools/i18n/de.lua +++ b/TaosGroupTools/i18n/de.lua @@ -23,6 +23,9 @@ local strings = { TGT_OPTIONS_VISIBLE_OFF_TOOLTIP = "Wähle den gewünschten Wert ab welcher Gruppengröße das UI angezeigt werden soll.", TGT_OPTIONS_SWIMLANE_SCALE_LABEL = "Skalierung auswählen.", TGT_OPTIONS_SWIMLANE_SCALE_TOOLTIP = "Wähle den gewünschten Skalierungswert, um die Schwimbahn-Listen zu skalieren. Standard ist 1.", + TGT_OPTIONS_SOUND_LABEL = "Sound bei Ultimate gebrauch.", + TGT_OPTIONS_SOUND_TOOLTIP = "Wähle den gewünschten Sound aus der gespielt werden soll, wenn ein anderer Spieler sein Ultimate aktiviert. Sounds, die nicht in der Liste sind können über /setultimatesound <SOUND> gesetzt werden. Für eine Liste aller SOUND ID's siehe https://wiki.esoui.com/Sounds", + TGT_OPTIONS_NO_SOUND_LABEL = "Kein Sound", TGT_DESCRIPTIONS_NEGATE = "Magienegation Ultimates der Zauberer Klasse", TGT_DESCRIPTIONS_ATRO = "Atronach Ultimates der Zauberer Klasse", TGT_DESCRIPTIONS_OVER = "Überladung Ultimates der Zauberer Klasse", diff --git a/TaosGroupTools/i18n/en.lua b/TaosGroupTools/i18n/en.lua index 78c2fc1..da8f925 100644 --- a/TaosGroupTools/i18n/en.lua +++ b/TaosGroupTools/i18n/en.lua @@ -23,6 +23,9 @@ local strings = { TGT_OPTIONS_VISIBLE_OFF_TOOLTIP = "Choose your value of group size for visibility of UI.", TGT_OPTIONS_SWIMLANE_SCALE_LABEL = "Choose scaling.", TGT_OPTIONS_SWIMLANE_SCALE_TOOLTIP = "Choose your scaling value to set up the scaling of Swimlane-Lists. Default is 1.", + TGT_OPTIONS_SOUND_LABEL = "Sound on Ultimate use.", + TGT_OPTIONS_SOUND_TOOLTIP = "Choose your favorite sound, which should played if someone used his ultimate. If you want play another sounds you can choose your sound via /setultimatesound <SOUND>. For a list of all sounds see https://wiki.esoui.com/Sounds", + TGT_OPTIONS_NO_SOUND_LABEL = "No Sound", TGT_DESCRIPTIONS_NEGATE = "Negate ultimates from Sorcerer class", TGT_DESCRIPTIONS_ATRO = "Atronach ultimates from Sorcerer class", TGT_DESCRIPTIONS_OVER = "Overload ultimates from Sorcerer class", diff --git a/TaosGroupTools/i18n/fr.lua b/TaosGroupTools/i18n/fr.lua index c7f82de..c87930b 100644 --- a/TaosGroupTools/i18n/fr.lua +++ b/TaosGroupTools/i18n/fr.lua @@ -23,6 +23,9 @@ local strings = { TGT_OPTIONS_VISIBLE_OFF_TOOLTIP = "Choose your value of group size for visibility of UI.", TGT_OPTIONS_SWIMLANE_SCALE_LABEL = "Choose scaling.", TGT_OPTIONS_SWIMLANE_SCALE_TOOLTIP = "Choose your scaling value to set up the scaling of Swimlane-Lists. Default is 1.", + TGT_OPTIONS_SOUND_LABEL = "Sound on Ultimate use.", + TGT_OPTIONS_SOUND_TOOLTIP = "Choose your favorite sound, which should played if someone used his ultimate. If you want play another sounds you can choose your sound via /setultimatesound <SOUND>. For a list of all sounds see https://wiki.esoui.com/Sounds", + TGT_OPTIONS_NO_SOUND_LABEL = "No Sound", TGT_DESCRIPTIONS_NEGATE = "Negate ultimates from Sorcerer class", TGT_DESCRIPTIONS_ATRO = "Atronach ultimates from Sorcerer class", TGT_DESCRIPTIONS_OVER = "Overload ultimates from Sorcerer class", diff --git a/TaosGroupTools/logic/CommandsHandler.lua b/TaosGroupTools/logic/CommandsHandler.lua index 4f3d023..d4f2f35 100644 --- a/TaosGroupTools/logic/CommandsHandler.lua +++ b/TaosGroupTools/logic/CommandsHandler.lua @@ -22,6 +22,23 @@ TGT_CommandsHandler.__index = TGT_CommandsHandler TGT_CommandsHandler.Name = "TGT-CommandsHandler" --[[ + Called on /tgt command +]]-- +function TGT_CommandsHandler.GetAllCommands() + if (LOG_ACTIVE) then + _logger:logTrace("TGT_CommandsHandler.GetAllCommands") + end + + d("Commands active:") + d("/tgt - Gets all available commands") + d("/setgroupultimatestyle <STYLEID> - Sets the style (0 = SimpleList, 1 = SwimlaneList).") + d("/setultimatesound <SOUND> - Sets SOUND value, see https://wiki.esoui.com/Sounds") + d("/setultimateid <GROUPNAME> - Sets the static ultimate group; See /getultimategroups to get group names.") + d("/setswimlaneid <SWIMLANE> <GROUPNAME> - Sets the ultimate group of swimlane (1-6); See /getultimategroups to get group name.") + d("/getultimategroups - Gets all ultimate group names") +end + +--[[ Called on /setgroupultimatestyle command ]]-- function TGT_CommandsHandler.SetGroupUltimateStyleCommand(style) @@ -38,6 +55,23 @@ function TGT_CommandsHandler.SetGroupUltimateStyleCommand(style) end --[[ + Called on /setultimatesound command +]]-- +function TGT_CommandsHandler.SetUltimateSoundCommand(sound) + if (LOG_ACTIVE) then + _logger:logTrace("TGT_CommandsHandler.SetUltimateSoundCommand") + _logger:logDebug("sound", sound) + end + + if (sound ~= "") then + PlaySound(SOUNDS[sound]) + TGT_SettingsHandler.SetSoundSettings(99, sound) + else + d("Invalid sound: " .. tostring(sound)) + end +end + +--[[ Called on /setultimateid command ]]-- function TGT_CommandsHandler.SetUltimateIdCommand(groupName) @@ -115,17 +149,15 @@ end function TGT_CommandsHandler.Initialize(logger) if (LOG_ACTIVE) then logger:logTrace("TGT_CommandsHandler.Initialize") - logger:logDebug("Commands active:") - logger:logDebug("/setgroupultimatestyle <STYLEID> - Sets the style (0 = SimpleList, 1 = SwimlaneList).") - logger:logDebug("/setultimateid <GROUPNAME> - Sets the static ultimate group; See /getultimategroups to get group names.") - logger:logDebug("/setswimlaneid <SWIMLANE> <GROUPNAME> - Sets the ultimate group of swimlane (1-6); See /getultimategroups to get group name.") - logger:logDebug("/getultimategroups - Gets all ultimate group names") + TGT_CommandsHandler.GetAllCommands() end _logger = logger -- Define commands + SLASH_COMMANDS["/tgt"] = TGT_CommandsHandler.GetAllCommands SLASH_COMMANDS["/setgroupultimatestyle"] = TGT_CommandsHandler.SetGroupUltimateStyleCommand + SLASH_COMMANDS["/setultimatesound"] = TGT_CommandsHandler.SetUltimateSoundCommand SLASH_COMMANDS["/setultimateid"] = TGT_CommandsHandler.SetUltimateIdCommand SLASH_COMMANDS["/setswimlaneid"] = TGT_CommandsHandler.SetSwimlaneIdCommand SLASH_COMMANDS["/getultimategroups"] = TGT_CommandsHandler.GetUltimateGroupsCommand diff --git a/TaosGroupTools/logic/SettingsHandler.lua b/TaosGroupTools/logic/SettingsHandler.lua index 0ce7444..a6001b6 100644 --- a/TaosGroupTools/logic/SettingsHandler.lua +++ b/TaosGroupTools/logic/SettingsHandler.lua @@ -58,6 +58,18 @@ function TGT_SettingsHandler.SetStyleSettings(style) end --[[ + Sets SetSoundSettings +]]-- +function TGT_SettingsHandler.SetSoundSettings(index, sound) + if (LOG_ACTIVE) then + _logger:logTrace("TGT_SettingsHandler.SetSoundSettings") + _logger:logDebug("index, sound", index, sound) + end + + TGT_SettingsHandler.SavedVariables.Sound = { index, sound } +end + +--[[ Sets StaticUltimateIDSettings and fires TGT_STATIC_ULTIMATE_ID_CHANGED callbacks ]]-- function TGT_SettingsHandler.SetStaticUltimateIDSettings(staticUltimateID) diff --git a/TaosGroupTools/ui/SettingsWindow.lua b/TaosGroupTools/ui/SettingsWindow.lua index 7f98b35..16f6769 100644 --- a/TaosGroupTools/ui/SettingsWindow.lua +++ b/TaosGroupTools/ui/SettingsWindow.lua @@ -32,7 +32,23 @@ function TGT_SettingsWindow.AddGroupUltimateOptions() [2] = GetString(TGT_OPTIONS_STYLE_SWIM), [3] = GetString(TGT_OPTIONS_STYLE_SHORT_SWIM), } - + + local soundChoices = { + [1] = GetString(TGT_OPTIONS_NO_SOUND_LABEL), + [2] = "DUEL_ACCEPTED", + [3] = "ABILITY_ULTIMATE_READY", + [4] = "ACHIEVEMENT_AWARDED", + [5] = "DUEL_BOUNDARY_WARNING", + [6] = "BATTLEGROUND_CAPTURE_FLAG_TAKEN_OWN_TEAM", + [7] = "CHAMPION_POINT_GAINED", + [8] = "DUEL_WON", + [9] = "GENERAL_ALERT_ERROR", + [10] = "LEVEL_UP", + } +-- for sound,description in pairs(SOUNDS) do +-- soundChoices[#soundChoices + 1] = sound +-- end + local optionsData = { -- Submenu Group Ultimate Options { type = "submenu", @@ -66,6 +82,27 @@ function TGT_SettingsWindow.AddGroupUltimateOptions() end, default = TGT_DEFAULTS.IsSortingActive }, + -- Sounds + { type = "dropdown", + name = GetString(TGT_OPTIONS_SOUND_LABEL), + tooltip = GetString(TGT_OPTIONS_SOUND_TOOLTIP), + choices = soundChoices, + getFunc = + function() + return soundChoices[TGT_SettingsHandler.SavedVariables.Sound[1]] + end, + setFunc = + function(value) + for index, name in ipairs(soundChoices) do + if (name == value) then + if (index > 1) then PlaySound(SOUNDS[value]) end + TGT_SettingsHandler.SetSoundSettings(index, value) + break + end + end + end, + default = soundChoices[TGT_DEFAULTS.Sound[1]] + }, -- Style { type = "dropdown", name = GetString(TGT_OPTIONS_STYLE_LABEL), diff --git a/TaosGroupTools/ui/groupultimate/CompactSwimlaneList.lua b/TaosGroupTools/ui/groupultimate/CompactSwimlaneList.lua index bf1112b..7b8acf0 100644 --- a/TaosGroupTools/ui/groupultimate/CompactSwimlaneList.lua +++ b/TaosGroupTools/ui/groupultimate/CompactSwimlaneList.lua @@ -115,12 +115,21 @@ function TGT_CompactSwimlaneList.UpdatePlayer(player) if (swimLane) then local row = TGT_CompactSwimlaneList.GetSwimLaneRow(swimLane, player.PlayerName) + local updateNeeded = true -- Update timestamp if (row ~= nil) then for i,swimlanePlayer in ipairs(swimLane.Players) do if (swimlanePlayer.PlayerName == player.PlayerName) then swimlanePlayer.LastMapPingTimestamp = GetTimeStamp() + + updateNeeded = swimlanePlayer.IsPlayerDead ~= player.IsPlayerDead or swimlanePlayer.RelativeUltimate ~= player.RelativeUltimate + + if (swimlanePlayer.RelativeUltimate > player.RelativeUltimate) then + local sound = TGT_SettingsHandler.SavedVariables.Sound + if (sound[1] > 1) then PlaySound(SOUNDS[sound[2]]) end + end + swimlanePlayer.IsPlayerDead = player.IsPlayerDead swimlanePlayer.RelativeUltimate = player.RelativeUltimate break @@ -148,7 +157,7 @@ function TGT_CompactSwimlaneList.UpdatePlayer(player) end -- Only update if player in a row - if (row ~= nil) then + if (row ~= nil and updateNeeded) then if (TGT_SettingsHandler.SavedVariables.IsSortingActive) then -- Sort swimlane with all players TGT_CompactSwimlaneList.SortSwimlane(swimLane) diff --git a/TaosGroupTools/ui/groupultimate/SimpleList.lua b/TaosGroupTools/ui/groupultimate/SimpleList.lua index e308310..71932c5 100644 --- a/TaosGroupTools/ui/groupultimate/SimpleList.lua +++ b/TaosGroupTools/ui/groupultimate/SimpleList.lua @@ -138,11 +138,21 @@ function TGT_SimpleList.UpdatePlayer(player) end end + local updateNeeded = true + -- Update timestamp if (row ~= nil) then for i,listPlayer in ipairs(_players) do if (listPlayer.PlayerName == player.PlayerName) then listPlayer.LastMapPingTimestamp = GetTimeStamp() + + updateNeeded = listPlayer.IsPlayerDead ~= player.IsPlayerDead or listPlayer.RelativeUltimate ~= player.RelativeUltimate + + if (listPlayer.RelativeUltimate > player.RelativeUltimate) then + local sound = TGT_SettingsHandler.SavedVariables.Sound + if (sound[1] > 1) then PlaySound(SOUNDS[sound[2]]) end + end + listPlayer.IsPlayerDead = player.IsPlayerDead listPlayer.RelativeUltimate = player.RelativeUltimate break @@ -170,7 +180,7 @@ function TGT_SimpleList.UpdatePlayer(player) end -- Only update if player in a row - if (row ~= nil) then + if (row ~= nil and updateNeeded) then -- Directly update row with player, sorting will be triggered on RefreshList TGT_SimpleList.UpdateListRow(row, player) end diff --git a/TaosGroupTools/ui/groupultimate/SwimlaneList.lua b/TaosGroupTools/ui/groupultimate/SwimlaneList.lua index 9cab5ef..02aad0e 100644 --- a/TaosGroupTools/ui/groupultimate/SwimlaneList.lua +++ b/TaosGroupTools/ui/groupultimate/SwimlaneList.lua @@ -115,12 +115,21 @@ function TGT_SwimlaneList.UpdatePlayer(player) if (swimLane) then local row = TGT_SwimlaneList.GetSwimLaneRow(swimLane, player.PlayerName) + local updateNeeded = true -- Update player if (row ~= nil) then for i,swimlanePlayer in ipairs(swimLane.Players) do if (swimlanePlayer.PlayerName == player.PlayerName) then swimlanePlayer.LastMapPingTimestamp = GetTimeStamp() + + updateNeeded = swimlanePlayer.IsPlayerDead ~= player.IsPlayerDead or swimlanePlayer.RelativeUltimate ~= player.RelativeUltimate + + if (swimlanePlayer.RelativeUltimate > player.RelativeUltimate) then + local sound = TGT_SettingsHandler.SavedVariables.Sound + if (sound[1] > 1) then PlaySound(SOUNDS[sound[2]]) end + end + swimlanePlayer.IsPlayerDead = player.IsPlayerDead swimlanePlayer.RelativeUltimate = player.RelativeUltimate break @@ -148,7 +157,7 @@ function TGT_SwimlaneList.UpdatePlayer(player) end -- Only update if player in a row - if (row ~= nil) then + if (row ~= nil and updateNeeded) then if (TGT_SettingsHandler.SavedVariables.IsSortingActive) then -- Sort swimlane with all players TGT_SwimlaneList.SortSwimlane(swimLane)