This commit is contained in:
Applevangelist 2024-06-30 15:57:09 +02:00
parent b6ac1e86e4
commit 9479b338c5
5 changed files with 22 additions and 38 deletions

View File

@ -177,40 +177,22 @@ end
--
-- -- Send the 2 messages created with the @{New} method to the Client Group.
-- -- Note that the Message of MessageClient2 is overwriting the Message of MessageClient1.
-- ClientGroup = Group.getByName( "ClientGroup" )
-- Client = CLIENT:FindByName("NameOfClientUnit")
--
-- MessageClient1 = MESSAGE:New( "Congratulations, you've just hit a target", "Score", 25, "Score" ):ToClient( ClientGroup )
-- MessageClient2 = MESSAGE:New( "Congratulations, you've just killed a target", "Score", 25, "Score" ):ToClient( ClientGroup )
-- MessageClient1 = MESSAGE:New( "Congratulations, you've just hit a target", "Score", 25, "Score" ):ToClient( Client )
-- MessageClient2 = MESSAGE:New( "Congratulations, you've just killed a target", "Score", 25, "Score" ):ToClient( Client )
-- or
-- MESSAGE:New( "Congratulations, you've just hit a target", "Score", 25 ):ToClient( ClientGroup )
-- MESSAGE:New( "Congratulations, you've just killed a target", "Score", 25 ):ToClient( ClientGroup )
-- MESSAGE:New( "Congratulations, you've just hit a target", "Score", 25 ):ToClient( Client )
-- MESSAGE:New( "Congratulations, you've just killed a target", "Score", 25 ):ToClient( Client )
-- or
-- MessageClient1 = MESSAGE:New( "Congratulations, you've just hit a target", "Score", 25 )
-- MessageClient2 = MESSAGE:New( "Congratulations, you've just killed a target", "Score", 25 )
-- MessageClient1:ToClient( ClientGroup )
-- MessageClient2:ToClient( ClientGroup )
-- MessageClient1:ToClient( Client )
-- MessageClient2:ToClient( Client )
--
function MESSAGE:ToClient( Client, Settings )
self:F( Client )
if Client and Client:GetClientGroupID() then
if self.MessageType then
local Settings = Settings or ( Client and _DATABASE:GetPlayerSettings( Client:GetPlayerName() ) ) or _SETTINGS -- Core.Settings#SETTINGS
self.MessageDuration = Settings:GetMessageTime( self.MessageType )
self.MessageCategory = "" -- self.MessageType .. ": "
end
local Unit = Client:GetClient()
if self.MessageDuration ~= 0 then
local ClientGroupID = Client:GetClientGroupID()
self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration )
--trigger.action.outTextForGroup( ClientGroupID, self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration , self.ClearScreen)
trigger.action.outTextForUnit( Unit:GetID(), self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration , self.ClearScreen)
end
end
self:ToUnit(Client,Settings)
return self
end
@ -257,6 +239,7 @@ function MESSAGE:ToUnit( Unit, Settings )
if self.MessageDuration ~= 0 then
self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration )
local ID = Unit:GetID()
trigger.action.outTextForUnit( Unit:GetID(), self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration, self.ClearScreen )
end
end

View File

@ -2916,7 +2916,7 @@ function ATIS:onafterReport( From, Event, To, Text )
self:T( "SRS TTS: " .. text )
-- Play text-to-speech report.
local duration = STTS.getSpeechTime(text,0.95)
local duration = MSRS.getSpeechTime(text,0.95)
self.msrsQ:NewTransmission(text,duration,self.msrs,nil,2)
--self.msrs:PlayText( text )
self.SRSText = text

View File

@ -1626,7 +1626,7 @@ function AWACS:_NewRadioEntry(TextTTS, TextScreen,GID,IsGroup,ToScreen,IsNew,Fro
RadioEntry.TextScreen = TextScreen or TextTTS
RadioEntry.GroupID = GID
RadioEntry.ToScreen = ToScreen
RadioEntry.Duration = STTS.getSpeechTime(TextTTS,0.95,false) or 8
RadioEntry.Duration = MSRS.getSpeechTime(TextTTS,0.95,false) or 8
RadioEntry.FromAI = FromAI
RadioEntry.IsGroup = IsGroup
if Tactical then

View File

@ -356,7 +356,7 @@ do -- Text-To-Speech
local self=BASE:Inherit(self, BASE:New()) -- #SOUNDTEXT
self:SetText(Text)
self:SetDuration(Duration or STTS.getSpeechTime(Text))
self:SetDuration(Duration or MSRS.getSpeechTime(Text))
--self:SetGender()
--self:SetCulture()

View File

@ -482,6 +482,15 @@ UTILS.BasicSerialize = function(s)
end
end
--- Counts the number of elements in a table.
-- @param #table T Table to count
-- @return #int Number of elements in the table
function UTILS.TableLength(T)
local count = 0
for _ in pairs(T or {}) do count = count + 1 end
return count
end
--- Print a table to log in a nice format
-- @param #table table The table to print
-- @param #number indent Number of indents
@ -496,7 +505,7 @@ function UTILS.PrintTableToLog(table, indent, noprint)
if not indent then indent = 0 end
for k, v in pairs(table) do
if string.find(k," ") then k='"'..k..'"'end
if type(v) == "table" then
if type(v) == "table" and UTILS.TableLength(v) > 0 then
if not noprint then
env.info(string.rep(" ", indent) .. tostring(k) .. " = {")
end
@ -3676,14 +3685,6 @@ function table.index_of(table, element)
return nil
end
--- Counts the number of elements in a table.
-- @param #table T Table to count
-- @return #int Number of elements in the table
function table.length(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
--- Slices a table between two indices, much like Python's my_list[2:-1]
-- @param #table tbl Table to slice