From 6d1385a031168e973c675360b14fa1ffe3ecad6f Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Tue, 12 Sep 2017 11:41:52 +0200 Subject: [PATCH 1/2] Implemented Message Types * Added Message Type Methods * SETTINGS menu has been added with Message Type display times * Modifed the FSM action classes to use the new Message Type methods. --- .../Moose/Actions/Act_Account.lua | 47 +++--- .../Moose/Actions/Act_Assign.lua | 8 +- Moose Development/Moose/Actions/Act_Route.lua | 25 ++-- Moose Development/Moose/Core/Message.lua | 103 +++++++++++-- Moose Development/Moose/Core/Point.lua | 20 +-- Moose Development/Moose/Core/Settings.lua | 135 ++++++++++++++++-- .../Moose/Tasking/CommandCenter.lua | 14 +- Moose Development/Moose/Tasking/Task_A2G.lua | 10 +- .../Moose/Wrapper/Positionable.lua | 39 ++++- 9 files changed, 316 insertions(+), 85 deletions(-) diff --git a/Moose Development/Moose/Actions/Act_Account.lua b/Moose Development/Moose/Actions/Act_Account.lua index b87e0af93..0cc641623 100644 --- a/Moose Development/Moose/Actions/Act_Account.lua +++ b/Moose Development/Moose/Actions/Act_Account.lua @@ -91,7 +91,7 @@ do -- ACT_ACCOUNT --- StateMachine callback function -- @param #ACT_ACCOUNT self - -- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit + -- @param Wrapper.Unit#UNIT ProcessUnit -- @param #string Event -- @param #string From -- @param #string To @@ -107,7 +107,7 @@ do -- ACT_ACCOUNT --- StateMachine callback function -- @param #ACT_ACCOUNT self - -- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit + -- @param Wrapper.Unit#UNIT ProcessUnit -- @param #string Event -- @param #string From -- @param #string To @@ -125,7 +125,7 @@ do -- ACT_ACCOUNT --- StateMachine callback function -- @param #ACT_ACCOUNT self - -- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit + -- @param Wrapper.Unit#UNIT ProcessUnit -- @param #string Event -- @param #string From -- @param #string To @@ -185,30 +185,31 @@ do -- ACT_ACCOUNT_DEADS --- StateMachine callback function -- @param #ACT_ACCOUNT_DEADS self - -- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit + -- @param Wrapper.Unit#UNIT ProcessUnit -- @param #string Event -- @param #string From -- @param #string To function ACT_ACCOUNT_DEADS:onenterReport( ProcessUnit, Task, From, Event, To ) self:E( { ProcessUnit, From, Event, To } ) - self:Message( "Your group with assigned " .. self.TaskName .. " task has " .. Task.TargetSetUnit:GetUnitTypesText() .. " targets left to be destroyed." ) + local MessageText = "Your group with assigned " .. self.TaskName .. " task has " .. Task.TargetSetUnit:GetUnitTypesText() .. " targets left to be destroyed." + self:GetCommandCenter():MessageTypeToGroup( MessageText, ProcessUnit:GetGroup(), MESSAGE.Type.Information ) end --- StateMachine callback function -- @param #ACT_ACCOUNT_DEADS self - -- @param Wrapper.Client#CLIENT ProcessClient + -- @param Wrapper.Unit#UNIT ProcessUnit -- @param Tasking.Task#TASK Task -- @param #string From -- @param #string Event -- @param #string To -- @param Core.Event#EVENTDATA EventData - function ACT_ACCOUNT_DEADS:onafterEvent( ProcessClient, Task, From, Event, To, EventData ) - self:T( { ProcessClient:GetName(), Task:GetName(), From, Event, To, EventData } ) + function ACT_ACCOUNT_DEADS:onafterEvent( ProcessUnit, Task, From, Event, To, EventData ) + self:T( { ProcessUnit:GetName(), Task:GetName(), From, Event, To, EventData } ) if Task.TargetSetUnit:FindUnit( EventData.IniUnitName ) then - local PlayerName = ProcessClient:GetPlayerName() + local PlayerName = ProcessUnit:GetPlayerName() local PlayerHit = self.PlayerHits and self.PlayerHits[EventData.IniUnitName] if PlayerHit == PlayerName then self:Player( EventData ) @@ -220,21 +221,23 @@ do -- ACT_ACCOUNT_DEADS --- StateMachine callback function -- @param #ACT_ACCOUNT_DEADS self - -- @param Wrapper.Client#CLIENT ProcessClient + -- @param Wrapper.Unit#UNIT ProcessUnit -- @param Tasking.Task#TASK Task -- @param #string From -- @param #string Event -- @param #string To -- @param Core.Event#EVENTDATA EventData - function ACT_ACCOUNT_DEADS:onenterAccountForPlayer( ProcessClient, Task, From, Event, To, EventData ) - self:T( { ProcessClient:GetName(), Task:GetName(), From, Event, To, EventData } ) + function ACT_ACCOUNT_DEADS:onenterAccountForPlayer( ProcessUnit, Task, From, Event, To, EventData ) + self:T( { ProcessUnit:GetName(), Task:GetName(), From, Event, To, EventData } ) - local TaskGroup = ProcessClient:GetGroup() + local TaskGroup = ProcessUnit:GetGroup() Task.TargetSetUnit:Remove( EventData.IniUnitName ) - self:Message( "You have destroyed a target.\nYour group assigned with task " .. self.TaskName .. " has\n" .. Task.TargetSetUnit:Count() .. " targets ( " .. Task.TargetSetUnit:GetUnitTypesText() .. " ) left to be destroyed." ) - - local PlayerName = ProcessClient:GetPlayerName() + + local MessageText = "You have destroyed a target.\nYour group assigned with task " .. self.TaskName .. " has\n" .. Task.TargetSetUnit:Count() .. " targets ( " .. Task.TargetSetUnit:GetUnitTypesText() .. " ) left to be destroyed." + self:GetCommandCenter():MessageTypeToGroup( MessageText, ProcessUnit:GetGroup(), MESSAGE.Type.Information ) + + local PlayerName = ProcessUnit:GetPlayerName() Task:AddProgress( PlayerName, "Destroyed " .. EventData.IniTypeName, timer.getTime(), 1 ) if Task.TargetSetUnit:Count() > 0 then @@ -246,18 +249,20 @@ do -- ACT_ACCOUNT_DEADS --- StateMachine callback function -- @param #ACT_ACCOUNT_DEADS self - -- @param Wrapper.Client#CLIENT ProcessClient + -- @param Wrapper.Unit#UNIT ProcessUnit -- @param Tasking.Task#TASK Task -- @param #string From -- @param #string Event -- @param #string To -- @param Core.Event#EVENTDATA EventData - function ACT_ACCOUNT_DEADS:onenterAccountForOther( ProcessClient, Task, From, Event, To, EventData ) - self:T( { ProcessClient:GetName(), Task:GetName(), From, Event, To, EventData } ) + function ACT_ACCOUNT_DEADS:onenterAccountForOther( ProcessUnit, Task, From, Event, To, EventData ) + self:T( { ProcessUnit:GetName(), Task:GetName(), From, Event, To, EventData } ) - local TaskGroup = ProcessClient:GetGroup() + local TaskGroup = ProcessUnit:GetGroup() Task.TargetSetUnit:Remove( EventData.IniUnitName ) - self:Message( "One of the task targets has been destroyed.\nYour group assigned with task " .. self.TaskName .. " has\n" .. Task.TargetSetUnit:Count() .. " targets ( " .. Task.TargetSetUnit:GetUnitTypesText() .. " ) left to be destroyed." ) + + local MessageText = "One of the task targets has been destroyed.\nYour group assigned with task " .. self.TaskName .. " has\n" .. Task.TargetSetUnit:Count() .. " targets ( " .. Task.TargetSetUnit:GetUnitTypesText() .. " ) left to be destroyed." + self:GetCommandCenter():MessageTypeToGroup( MessageText, ProcessUnit:GetGroup(), MESSAGE.Type.Information ) if Task.TargetSetUnit:Count() > 0 then self:__More( 1 ) diff --git a/Moose Development/Moose/Actions/Act_Assign.lua b/Moose Development/Moose/Actions/Act_Assign.lua index e04139698..df82b8172 100644 --- a/Moose Development/Moose/Actions/Act_Assign.lua +++ b/Moose Development/Moose/Actions/Act_Assign.lua @@ -229,14 +229,14 @@ do -- ACT_ASSIGN_MENU_ACCEPT --- StateMachine callback function -- @param #ACT_ASSIGN_MENU_ACCEPT self - -- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit + -- @param Wrapper.Unit#UNIT ProcessUnit -- @param #string Event -- @param #string From -- @param #string To function ACT_ASSIGN_MENU_ACCEPT:onafterStart( ProcessUnit, From, Event, To ) self:E( { ProcessUnit, From, Event, To } ) - self:Message( "Access the radio menu to accept the task. You have 30 seconds or the assignment will be cancelled." ) + self:GetCommandCenter():MessageTypeToGroup( "Access the radio menu to accept the task. You have 30 seconds or the assignment will be cancelled.", ProcessUnit:GetGroup(), MESSAGE.Type.Information ) local ProcessGroup = ProcessUnit:GetGroup() @@ -263,7 +263,7 @@ do -- ACT_ASSIGN_MENU_ACCEPT --- StateMachine callback function -- @param #ACT_ASSIGN_MENU_ACCEPT self - -- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit + -- @param Wrapper.Unit#UNIT ProcessUnit -- @param #string Event -- @param #string From -- @param #string To @@ -275,7 +275,7 @@ do -- ACT_ASSIGN_MENU_ACCEPT --- StateMachine callback function -- @param #ACT_ASSIGN_MENU_ACCEPT self - -- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit + -- @param Wrapper.Unit#UNIT ProcessUnit -- @param #string Event -- @param #string From -- @param #string To diff --git a/Moose Development/Moose/Actions/Act_Route.lua b/Moose Development/Moose/Actions/Act_Route.lua index 7f98b8b1a..4e0527d37 100644 --- a/Moose Development/Moose/Actions/Act_Route.lua +++ b/Moose Development/Moose/Actions/Act_Route.lua @@ -154,7 +154,7 @@ do -- ACT_ROUTE --- Get the routing text to be displayed. -- The route mode determines the text displayed. -- @param #ACT_ROUTE self - -- @param Wrapper.Controllable#CONTROLLABLE Controllable + -- @param Wrapper.Unit#UNIT Controllable -- @return #string function ACT_ROUTE:GetRouteText( Controllable ) @@ -215,7 +215,7 @@ do -- ACT_ROUTE --- StateMachine callback function -- @param #ACT_ROUTE self - -- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit + -- @param Wrapper.Unit#UNIT ProcessUnit -- @param #string Event -- @param #string From -- @param #string To @@ -227,7 +227,7 @@ do -- ACT_ROUTE --- Check if the controllable has arrived. -- @param #ACT_ROUTE self - -- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit + -- @param Wrapper.Unit#UNIT ProcessUnit -- @return #boolean function ACT_ROUTE:onfuncHasArrived( ProcessUnit ) return false @@ -235,7 +235,7 @@ do -- ACT_ROUTE --- StateMachine callback function -- @param #ACT_ROUTE self - -- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit + -- @param Wrapper.Unit#UNIT ProcessUnit -- @param #string Event -- @param #string From -- @param #string To @@ -352,7 +352,7 @@ do -- ACT_ROUTE_POINT --- Method override to check if the controllable has arrived. -- @param #ACT_ROUTE_POINT self - -- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit + -- @param Wrapper.Unit#UNIT ProcessUnit -- @return #boolean function ACT_ROUTE_POINT:onfuncHasArrived( ProcessUnit ) @@ -361,7 +361,7 @@ do -- ACT_ROUTE_POINT if Distance <= self.Range then local RouteText = "You have arrived." - self:Message( RouteText ) + self:GetCommandCenter():MessageTypeToGroup( RouteText, ProcessUnit:GetGroup(), MESSAGE.Type.Information ) return true end end @@ -373,14 +373,15 @@ do -- ACT_ROUTE_POINT --- StateMachine callback function -- @param #ACT_ROUTE_POINT self - -- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit + -- @param Wrapper.Unit#UNIT ProcessUnit -- @param #string Event -- @param #string From -- @param #string To function ACT_ROUTE_POINT:onafterReport( ProcessUnit, From, Event, To ) local RouteText = self:GetRouteText( ProcessUnit ) - self:Message( RouteText ) + + self:GetCommandCenter():MessageTypeToGroup( RouteText, ProcessUnit:GetGroup(), MESSAGE.Type.Update ) end end -- ACT_ROUTE_POINT @@ -445,13 +446,13 @@ do -- ACT_ROUTE_ZONE --- Method override to check if the controllable has arrived. -- @param #ACT_ROUTE self - -- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit + -- @param Wrapper.Unit#UNIT ProcessUnit -- @return #boolean function ACT_ROUTE_ZONE:onfuncHasArrived( ProcessUnit ) if ProcessUnit:IsInZone( self.Zone ) then local RouteText = "You have arrived within the zone." - self:Message( RouteText ) + self:GetCommandCenter():MessageTypeToGroup( RouteText, ProcessUnit:GetGroup(), MESSAGE.Type.Information ) end return ProcessUnit:IsInZone( self.Zone ) @@ -461,7 +462,7 @@ do -- ACT_ROUTE_ZONE --- StateMachine callback function -- @param #ACT_ROUTE_ZONE self - -- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit + -- @param Wrapper.Unit#UNIT ProcessUnit -- @param #string Event -- @param #string From -- @param #string To @@ -469,7 +470,7 @@ do -- ACT_ROUTE_ZONE self:E( { ProcessUnit = ProcessUnit } ) local RouteText = self:GetRouteText( ProcessUnit ) - self:Message( RouteText ) + self:GetCommandCenter():MessageTypeToGroup( RouteText, ProcessUnit:GetGroup(), MESSAGE.Type.Update ) end end -- ACT_ROUTE_ZONE diff --git a/Moose Development/Moose/Core/Message.lua b/Moose Development/Moose/Core/Message.lua index e632f38fc..6b0ac9adb 100644 --- a/Moose Development/Moose/Core/Message.lua +++ b/Moose Development/Moose/Core/Message.lua @@ -53,6 +53,16 @@ MESSAGE = { MessageID = 0, } +--- Message Types +-- @type MESSAGE.Type +MESSAGE.Type = { + Update = "Update", + Information = "Information", + Briefing = "Briefing Report", + Overview = "Overview Report", + Detailed = "Detailed Report" +} + --- Creates a new MESSAGE object. Note that these MESSAGE objects are not yet displayed on the display panel. You must use the functions @{ToClient} or @{ToCoalition} or @{ToAll} to send these Messages to the respective recipients. -- @param self @@ -74,6 +84,9 @@ function MESSAGE:New( MessageText, MessageDuration, MessageCategory ) local self = BASE:Inherit( self, BASE:New() ) self:F( { MessageText, MessageDuration, MessageCategory } ) + + self.MessageType = nil + -- When no MessageCategory is given, we don't show it as a title... if MessageCategory and MessageCategory ~= "" then if MessageCategory:sub(-1) ~= "\n" then @@ -96,6 +109,37 @@ function MESSAGE:New( MessageText, MessageDuration, MessageCategory ) return self end + +--- Creates a new MESSAGE object of a certain type. +-- Note that these MESSAGE objects are not yet displayed on the display panel. +-- You must use the functions @{ToClient} or @{ToCoalition} or @{ToAll} to send these Messages to the respective recipients. +-- The message display times are automatically defined based on the timing settings in the @{Settings} menu. +-- @param self +-- @param #string MessageText is the text of the Message. +-- @param #MESSAGE.Type MessageType The type of the message. +-- @return #MESSAGE +-- @usage +-- MessageAll = MESSAGE:NewType( "To all Players: BLUE has won! Each player of BLUE wins 50 points!", MESSAGE.Type.Information ) +-- MessageRED = MESSAGE:NewType( "To the RED Players: You receive a penalty because you've killed one of your own units", MESSAGE.Type.Information ) +-- MessageClient1 = MESSAGE:NewType( "Congratulations, you've just hit a target", MESSAGE.Type.Update ) +-- MessageClient2 = MESSAGE:NewType( "Congratulations, you've just killed a target", MESSAGE.Type.Update ) +function MESSAGE:NewType( MessageText, MessageType ) + + local self = BASE:Inherit( self, BASE:New() ) + self:F( { MessageText } ) + + self.MessageType = MessageType + + self.MessageTime = timer.getTime() + self.MessageText = MessageText:gsub("^\n","",1):gsub("\n$","",1) + + return self +end + + + + + --- Sends a MESSAGE to a Client Group. Note that the Group needs to be defined within the ME with the skillset "Client" or "Player". -- @param #MESSAGE self -- @param Wrapper.Client#CLIENT Client is the Group of the Client. @@ -115,14 +159,22 @@ end -- MessageClient2 = MESSAGE:New( "Congratulations, you've just killed a target", "Score", 25, "Score" ) -- MessageClient1:ToClient( ClientGroup ) -- MessageClient2:ToClient( ClientGroup ) -function MESSAGE:ToClient( Client ) +function MESSAGE:ToClient( Client, Settings ) self:F( Client ) if Client and Client:GetClientGroupID() 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 ) + 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 + + 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 ) + end end return self @@ -132,13 +184,21 @@ end -- @param #MESSAGE self -- @param Wrapper.Group#GROUP Group is the Group. -- @return #MESSAGE -function MESSAGE:ToGroup( Group ) +function MESSAGE:ToGroup( Group, Settings ) self:F( Group.GroupName ) if Group then + + if self.MessageType then + local Settings = Settings or ( Group and _DATABASE:GetPlayerSettings( Group:GetPlayerName() ) ) or _SETTINGS -- Core.Settings#SETTINGS + self.MessageDuration = Settings:GetMessageTime( self.MessageType ) + self.MessageCategory = self.MessageType .. ": " + end - self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration ) - trigger.action.outTextForGroup( Group:GetID(), self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration ) + if self.MessageDuration ~= 0 then + self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration ) + trigger.action.outTextForGroup( Group:GetID(), self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration ) + end end return self @@ -193,12 +253,20 @@ end -- or -- MessageRED = MESSAGE:New( "To the RED Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" ) -- MessageRED:ToCoalition( coalition.side.RED ) -function MESSAGE:ToCoalition( CoalitionSide ) +function MESSAGE:ToCoalition( CoalitionSide, Settings ) self:F( CoalitionSide ) + if self.MessageType then + local Settings = Settings or _SETTINGS -- Core.Settings#SETTINGS + self.MessageDuration = Settings:GetMessageTime( self.MessageType ) + self.MessageCategory = self.MessageType .. ": " + end + if CoalitionSide then - self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration ) - trigger.action.outTextForCoalition( CoalitionSide, self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration ) + if self.MessageDuration ~= 0 then + self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration ) + trigger.action.outTextForCoalition( CoalitionSide, self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration ) + end end return self @@ -232,8 +300,16 @@ end function MESSAGE:ToAll() self:F() - self:ToCoalition( coalition.side.RED ) - self:ToCoalition( coalition.side.BLUE ) + if self.MessageType then + local Settings = Settings or _SETTINGS -- Core.Settings#SETTINGS + self.MessageDuration = Settings:GetMessageTime( self.MessageType ) + self.MessageCategory = self.MessageType .. ": " + end + + if self.MessageDuration ~= 0 then + self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration ) + trigger.action.outText( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration ) + end return self end @@ -245,8 +321,7 @@ end function MESSAGE:ToAllIf( Condition ) if Condition and Condition == true then - self:ToCoalition( coalition.side.RED ) - self:ToCoalition( coalition.side.BLUE ) + self:ToAll() end return self diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 3206696d5..334d6850f 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -338,17 +338,7 @@ do -- COORDINATE -- @return #string function COORDINATE:GetMovingText( Settings ) - local MovingText = "" - - local Velocity = self:GetVelocity() - - if Velocity == 0 then - MovingText = MovingText .. "stationary " - else - MovingText = MovingText .. "moving at " .. self:GetVelocityText( Settings ) .. " " .. self:GetHeadingText( Settings ) - end - - return MovingText + return self:GetVelocityText( Settings ) .. self:GetHeadingText( Settings ) end @@ -481,12 +471,12 @@ do -- COORDINATE local Settings = Settings or _SETTINGS if Velocity then if Settings:IsMetric() then - return UTILS.MpsToKmph( Velocity ) .. " km/h" + return string.format( " moving at %d km/h", UTILS.MpsToKmph( Velocity ) ) else - return UTILS.MpsToKmph( Velocity ) / 1.852 .. " mph" + return string.format( " moving at %d mi/h", UTILS.MpsToKmph( Velocity ) / 1.852 ) end else - return "" + return " stationary" end end @@ -498,7 +488,7 @@ do -- COORDINATE local Heading = self.Heading local Settings = Settings or _SETTINGS if Heading then - return Heading .. "°" + return string.format( " heading %3.2f °", Heading ) else return "" end diff --git a/Moose Development/Moose/Core/Settings.lua b/Moose Development/Moose/Core/Settings.lua index 2730f4d1c..b584947bc 100644 --- a/Moose Development/Moose/Core/Settings.lua +++ b/Moose Development/Moose/Core/Settings.lua @@ -59,6 +59,11 @@ do -- SETTINGS self:SetA2A_BRAA() -- Defaults self:SetLL_Accuracy( 3 ) -- Defaults self:SetMGRS_Accuracy( 5 ) -- Defaults + self:SetMessageTime( MESSAGE.Type.Briefing, 180 ) + self:SetMessageTime( MESSAGE.Type.Detailed, 60 ) + self:SetMessageTime( MESSAGE.Type.Information, 30 ) + self:SetMessageTime( MESSAGE.Type.Overview, 60 ) + self:SetMessageTime( MESSAGE.Type.Update, 15 ) return self else local Settings = _DATABASE:GetPlayerSettings( PlayerName ) @@ -127,8 +132,23 @@ do -- SETTINGS return self.MGRS_Accuracy or _SETTINGS:GetMGRS_Accuracy() end + --- Sets the SETTINGS Message Display Timing of a MessageType + -- @param #SETTINGS self + -- @param Core.Message#MESSAGE MessageType The type of the message. + -- @param #number MessageTime The display time duration in seconds of the MessageType. + function SETTINGS:SetMessageTime( MessageType, MessageTime ) + self.MessageTypeTimings = self.MessageTypeTimings or {} + self.MessageTypeTimings[MessageType] = MessageTime + end - + + --- Gets the SETTINGS Message Display Timing of a MessageType + -- @param #SETTINGS self + -- @param Core.Message#MESSAGE MessageType The type of the message. + -- @return #number + function SETTINGS:GetMessageTime( MessageType ) + return ( self.MessageTypeTimings and self.MessageTypeTimings[MessageType] ) or _SETTINGS:GetMessageTime( MessageType ) + end --- Sets A2G LL DMS -- @param #SETTINGS self @@ -345,6 +365,46 @@ do -- SETTINGS if self:IsImperial() then MENU_GROUP_COMMAND:New( MenuGroup, "Metric (Kilometers,Meters)", MetricsMenu, self.MenuMWSystem, self, MenuGroup, RootMenu, true ):SetTime( MenuTime ) end + + local MessagesMenu = MENU_GROUP:New( MenuGroup, "Messages and Reports", SettingsMenu ):SetTime( MenuTime ) + + local UpdateMessagesMenu = MENU_GROUP:New( MenuGroup, "Update Messages", MessagesMenu ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "Off", UpdateMessagesMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Update, 0 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "5 seconds", UpdateMessagesMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Update, 5 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "10 seconds", UpdateMessagesMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Update, 10 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "15 seconds", UpdateMessagesMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Update, 15 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "30 seconds", UpdateMessagesMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Update, 30 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "1 minute", UpdateMessagesMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Update, 60 ):SetTime( MenuTime ) + + local InformationMessagesMenu = MENU_GROUP:New( MenuGroup, "Information Messages", MessagesMenu ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "5 seconds", InformationMessagesMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Information, 5 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "10 seconds", InformationMessagesMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Information, 10 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "15 seconds", InformationMessagesMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Information, 15 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "30 seconds", InformationMessagesMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Information, 30 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "1 minute", InformationMessagesMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Information, 60 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "2 minutes", InformationMessagesMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Information, 120 ):SetTime( MenuTime ) + + local BriefingReportsMenu = MENU_GROUP:New( MenuGroup, "Briefing Reports", MessagesMenu ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "15 seconds", BriefingReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Briefing, 15 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "30 seconds", BriefingReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Briefing, 30 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "1 minute", BriefingReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Briefing, 60 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "2 minutes", BriefingReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Briefing, 120 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "3 minutes", BriefingReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Briefing, 180 ):SetTime( MenuTime ) + + local OverviewReportsMenu = MENU_GROUP:New( MenuGroup, "Overview Reports", MessagesMenu ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "15 seconds", OverviewReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Overview, 15 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "30 seconds", OverviewReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Overview, 30 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "1 minute", OverviewReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Overview, 60 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "2 minutes", OverviewReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Overview, 120 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "3 minutes", OverviewReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.Overview, 180 ):SetTime( MenuTime ) + + local DetailedReportsMenu = MENU_GROUP:New( MenuGroup, "Detailed Reports", MessagesMenu ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "15 seconds", DetailedReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.DetailedReportsMenu, 15 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "30 seconds", DetailedReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.DetailedReportsMenu, 30 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "1 minute", DetailedReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.DetailedReportsMenu, 60 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "2 minutes", DetailedReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.DetailedReportsMenu, 120 ):SetTime( MenuTime ) + MENU_GROUP_COMMAND:New( MenuGroup, "3 minutes", DetailedReportsMenu, self.MenuMessageTimingsSystem, self, MenuGroup, RootMenu, MESSAGE.Type.DetailedReportsMenu, 180 ):SetTime( MenuTime ) + SettingsMenu:Remove( MenuTime ) @@ -444,6 +504,47 @@ do -- SETTINGS if self:IsImperial() then MENU_GROUP_COMMAND:New( PlayerGroup, "Metric (Kilometers,Meters)", MetricsMenu, self.MenuGroupMWSystem, self, PlayerUnit, PlayerGroup, PlayerName, true ) end + + + local MessagesMenu = MENU_GROUP:New( PlayerGroup, "Messages and Reports", PlayerMenu ) + + local UpdateMessagesMenu = MENU_GROUP:New( PlayerGroup, "Update Messages", MessagesMenu ) + MENU_GROUP_COMMAND:New( PlayerGroup, "Off", UpdateMessagesMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Update, 0 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "5 seconds", UpdateMessagesMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Update, 5 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "10 seconds", UpdateMessagesMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Update, 10 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "15 seconds", UpdateMessagesMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Update, 15 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "30 seconds", UpdateMessagesMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Update, 30 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "1 minute", UpdateMessagesMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Update, 60 ) + + local InformationMessagesMenu = MENU_GROUP:New( PlayerGroup, "Information Messages", MessagesMenu ) + MENU_GROUP_COMMAND:New( PlayerGroup, "5 seconds", InformationMessagesMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Information, 5 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "10 seconds", InformationMessagesMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Information, 10 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "15 seconds", InformationMessagesMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Information, 15 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "30 seconds", InformationMessagesMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Information, 30 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "1 minute", InformationMessagesMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Information, 60 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "2 minutes", InformationMessagesMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Information, 120 ) + + local BriefingReportsMenu = MENU_GROUP:New( PlayerGroup, "Briefing Reports", MessagesMenu ) + MENU_GROUP_COMMAND:New( PlayerGroup, "15 seconds", BriefingReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Briefing, 15 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "30 seconds", BriefingReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Briefing, 30 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "1 minute", BriefingReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Briefing, 60 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "2 minutes", BriefingReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Briefing, 120 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "3 minutes", BriefingReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Briefing, 180 ) + + local OverviewReportsMenu = MENU_GROUP:New( PlayerGroup, "Overview Reports", MessagesMenu ) + MENU_GROUP_COMMAND:New( PlayerGroup, "15 seconds", OverviewReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Overview, 15 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "30 seconds", OverviewReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Overview, 30 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "1 minute", OverviewReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Overview, 60 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "2 minutes", OverviewReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Overview, 120 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "3 minutes", OverviewReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.Overview, 180 ) + + local DetailedReportsMenu = MENU_GROUP:New( PlayerGroup, "Detailed Reports", MessagesMenu ) + MENU_GROUP_COMMAND:New( PlayerGroup, "15 seconds", DetailedReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.DetailedReportsMenu, 15 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "30 seconds", DetailedReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.DetailedReportsMenu, 30 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "1 minute", DetailedReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.DetailedReportsMenu, 60 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "2 minutes", DetailedReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.DetailedReportsMenu, 120 ) + MENU_GROUP_COMMAND:New( PlayerGroup, "3 minutes", DetailedReportsMenu, self.MenuGroupMessageTimingsSystem, self, PlayerUnit, PlayerGroup, PlayerName, MESSAGE.Type.DetailedReportsMenu, 180 ) + return self end @@ -465,44 +566,50 @@ do -- SETTINGS --- @param #SETTINGS self function SETTINGS:A2GMenuSystem( MenuGroup, RootMenu, A2GSystem ) self.A2GSystem = A2GSystem - MESSAGE:New( string.format("Settings: Default A2G coordinate system set to %s for all players!.", A2GSystem ), 5 ):ToAll() + MESSAGE:New( string.format("Settings: Default A2G coordinate system set to %s for all players!", A2GSystem ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end --- @param #SETTINGS self function SETTINGS:A2AMenuSystem( MenuGroup, RootMenu, A2ASystem ) self.A2ASystem = A2ASystem - MESSAGE:New( string.format("Settings: Default A2A coordinate system set to %s for all players!.", A2ASystem ), 5 ):ToAll() + MESSAGE:New( string.format("Settings: Default A2A coordinate system set to %s for all players!", A2ASystem ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end --- @param #SETTINGS self function SETTINGS:MenuLL_DDM_Accuracy( MenuGroup, RootMenu, LL_Accuracy ) self.LL_Accuracy = LL_Accuracy - MESSAGE:New( string.format("Settings: Default LL accuracy set to %s for all players!.", LL_Accuracy ), 5 ):ToAll() + MESSAGE:New( string.format("Settings: Default LL accuracy set to %s for all players!", LL_Accuracy ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end --- @param #SETTINGS self function SETTINGS:MenuMGRS_Accuracy( MenuGroup, RootMenu, MGRS_Accuracy ) self.MGRS_Accuracy = MGRS_Accuracy - MESSAGE:New( string.format("Settings: Default MGRS accuracy set to %s for all players!.", MGRS_Accuracy ), 5 ):ToAll() + MESSAGE:New( string.format("Settings: Default MGRS accuracy set to %s for all players!", MGRS_Accuracy ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end --- @param #SETTINGS self function SETTINGS:MenuMWSystem( MenuGroup, RootMenu, MW ) self.Metric = MW - MESSAGE:New( string.format("Settings: Default measurement format set to %s for all players!.", MW and "Metric" or "Imperial" ), 5 ):ToAll() + MESSAGE:New( string.format("Settings: Default measurement format set to %s for all players!", MW and "Metric" or "Imperial" ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end + --- @param #SETTINGS self + function SETTINGS:MenuMessageTimingsSystem( MenuGroup, RootMenu, MessageType, MessageTime ) + self:SetMessageTime( MessageType, MessageTime ) + MESSAGE:New( string.format( "Settings: Default message time set for %s to %d.", MessageType, MessageTime ), 5 ):ToAll() + end + do --- @param #SETTINGS self function SETTINGS:MenuGroupA2GSystem( PlayerUnit, PlayerGroup, PlayerName, A2GSystem ) BASE:E( {self, PlayerUnit:GetName(), A2GSystem} ) self.A2GSystem = A2GSystem - MESSAGE:New( string.format("Settings: A2G format set to %s for player %s.", A2GSystem, PlayerName ), 5 ):ToGroup( PlayerGroup ) + MESSAGE:New( string.format( "Settings: A2G format set to %s for player %s.", A2GSystem, PlayerName ), 5 ):ToGroup( PlayerGroup ) self:RemovePlayerMenu(PlayerUnit) self:SetPlayerMenu(PlayerUnit) end @@ -510,7 +617,7 @@ do -- SETTINGS --- @param #SETTINGS self function SETTINGS:MenuGroupA2ASystem( PlayerUnit, PlayerGroup, PlayerName, A2ASystem ) self.A2ASystem = A2ASystem - MESSAGE:New( string.format("Settings: A2A format set to %s for player %s.", A2ASystem, PlayerName ), 5 ):ToGroup( PlayerGroup ) + MESSAGE:New( string.format( "Settings: A2A format set to %s for player %s.", A2ASystem, PlayerName ), 5 ):ToGroup( PlayerGroup ) self:RemovePlayerMenu(PlayerUnit) self:SetPlayerMenu(PlayerUnit) end @@ -518,7 +625,7 @@ do -- SETTINGS --- @param #SETTINGS self function SETTINGS:MenuGroupLL_DDM_AccuracySystem( PlayerUnit, PlayerGroup, PlayerName, LL_Accuracy ) self.LL_Accuracy = LL_Accuracy - MESSAGE:New( string.format("Settings: A2G LL format accuracy set to %d for player %s.", LL_Accuracy, PlayerName ), 5 ):ToGroup( PlayerGroup ) + MESSAGE:New( string.format( "Settings: A2G LL format accuracy set to %d for player %s.", LL_Accuracy, PlayerName ), 5 ):ToGroup( PlayerGroup ) self:RemovePlayerMenu(PlayerUnit) self:SetPlayerMenu(PlayerUnit) end @@ -526,7 +633,7 @@ do -- SETTINGS --- @param #SETTINGS self function SETTINGS:MenuGroupMGRS_AccuracySystem( PlayerUnit, PlayerGroup, PlayerName, MGRS_Accuracy ) self.MGRS_Accuracy = MGRS_Accuracy - MESSAGE:New( string.format("Settings: A2G MGRS format accuracy set to %d for player %s.", MGRS_Accuracy, PlayerName ), 5 ):ToGroup( PlayerGroup ) + MESSAGE:New( string.format( "Settings: A2G MGRS format accuracy set to %d for player %s.", MGRS_Accuracy, PlayerName ), 5 ):ToGroup( PlayerGroup ) self:RemovePlayerMenu(PlayerUnit) self:SetPlayerMenu(PlayerUnit) end @@ -534,10 +641,16 @@ do -- SETTINGS --- @param #SETTINGS self function SETTINGS:MenuGroupMWSystem( PlayerUnit, PlayerGroup, PlayerName, MW ) self.Metric = MW - MESSAGE:New( string.format("Settings: Measurement format set to %s for player %s.", MW and "Metric" or "Imperial", PlayerName ), 5 ):ToGroup( PlayerGroup ) + MESSAGE:New( string.format( "Settings: Measurement format set to %s for player %s.", MW and "Metric" or "Imperial", PlayerName ), 5 ):ToGroup( PlayerGroup ) self:RemovePlayerMenu(PlayerUnit) self:SetPlayerMenu(PlayerUnit) end + + --- @param #SETTINGS self + function SETTINGS:MenuGroupMessageTimingsSystem( PlayerUnit, PlayerGroup, PlayerName, MessageType, MessageTime ) + self:SetMessageTime( MessageType, MessageTime ) + MESSAGE:New( string.format( "Settings: Default message time set for %s to %d.", MessageType, MessageTime ), 5 ):ToGroup( PlayerGroup ) + end end diff --git a/Moose Development/Moose/Tasking/CommandCenter.lua b/Moose Development/Moose/Tasking/CommandCenter.lua index 5fbefd0df..3b38720dc 100644 --- a/Moose Development/Moose/Tasking/CommandCenter.lua +++ b/Moose Development/Moose/Tasking/CommandCenter.lua @@ -358,10 +358,20 @@ end -- @param #COMMANDCENTER self -- @param #string Message -- @param Wrapper.Group#GROUP TaskGroup --- @param #sring Name (optional) The name of the Group used as a prefix for the message to the Group. If not provided, there will be nothing shown. function COMMANDCENTER:MessageToGroup( Message, TaskGroup ) - self:GetPositionable():MessageToGroup( Message , 15, TaskGroup, self:GetName() ) + self:GetPositionable():MessageToGroup( Message, 15, TaskGroup, self:GetName() ) + +end + +--- Send a CC message of a specified type to a GROUP. +-- @param #COMMANDCENTER self +-- @param #string Message +-- @param Wrapper.Group#GROUP TaskGroup +-- @param Core.Message#MESSAGE.MessageType MessageType The type of the message, resulting in automatic time duration and prefix of the message. +function COMMANDCENTER:MessageTypeToGroup( Message, TaskGroup, MessageType ) + + self:GetPositionable():MessageTypeToGroup( Message, MessageType, TaskGroup, self:GetName() ) end diff --git a/Moose Development/Moose/Tasking/Task_A2G.lua b/Moose Development/Moose/Tasking/Task_A2G.lua index 84322d342..8c9a7b5be 100644 --- a/Moose Development/Moose/Tasking/Task_A2G.lua +++ b/Moose Development/Moose/Tasking/Task_A2G.lua @@ -141,9 +141,9 @@ do -- TASK_A2G else local TargetUnit = Task.TargetSetUnit:GetFirst() -- Wrapper.Unit#UNIT if TargetUnit then - local Coordinate = TargetUnit:GetCoordinate() + local Coordinate = TargetUnit:GetPointVec3() self:T( { TargetCoordinate = Coordinate, Coordinate:GetX(), Coordinate:GetY(), Coordinate:GetZ() } ) - Task:SetTargetCoordinate( TargetUnit:GetCoordinate(), TaskUnit ) + Task:SetTargetCoordinate( Coordinate, TaskUnit ) end self:__RouteToTargetPoint( 0.1 ) end @@ -332,7 +332,7 @@ do -- TASK_A2G_SEAD self:SetBriefing( TaskBriefing or "Execute a Suppression of Enemy Air Defenses. " .. - ThreatText .. " targets to be expected. Target is " .. TargetCoord:GetMovingText() .. "." + ThreatText .. " targets to be expected. Target is" .. TargetCoord:GetMovingText() .. "." ) return self @@ -480,7 +480,7 @@ do -- TASK_A2G_BAI self:SetBriefing( TaskBriefing or "Execute a Battlefield Air Interdiction of a group of enemy targets. " .. - ThreatText .. " targets to be expected. Target is " .. TargetCoord:GetMovingText() .. "." + ThreatText .. " targets to be expected. Target is" .. TargetCoord:GetMovingText() .. "." ) return self @@ -630,7 +630,7 @@ do -- TASK_A2G_CAS TaskBriefing or "Execute a Close Air Support for a group of enemy targets. " .. "Beware of friendlies at the vicinity! " .. - ThreatText .. " targets to be expected. Target is " .. TargetCoord:GetMovingText() .. "." + ThreatText .. " targets to be expected. Target is" .. TargetCoord:GetMovingText() .. "." ) diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index 8c6816917..1bde60935 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -442,6 +442,23 @@ function POSITIONABLE:GetMessage( Message, Duration, Name ) --R2.1 changed calls return nil end +--- Returns a message of a specified type with the callsign embedded (if there is one). +-- @param #POSITIONABLE self +-- @param #string Message The message text +-- @param Core.Message#MESSAGE MessageType MessageType The message type. +-- @param #string Name (optional) The Name of the sender. If not provided, the Name is the type of the Positionable. +-- @return Core.Message#MESSAGE +function POSITIONABLE:GetMessageType( Message, MessageType, Name ) -- R2.2 changed callsign and name and using GetMessageText + + local DCSObject = self:GetDCSObject() + if DCSObject then + local MessageText = self:GetMessageText( Message, Name ) + return MESSAGE:NewType( MessageText, MessageType ) + end + + return nil +end + --- Send a message to all coalitions. -- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. -- @param #POSITIONABLE self @@ -557,6 +574,26 @@ function POSITIONABLE:MessageToGroup( Message, Duration, MessageGroup, Name ) return nil end +--- Send a message of a message type to a @{Group}. +-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. +-- @param #POSITIONABLE self +-- @param #string Message The message text +-- @param Core.Message#MESSAGE.Type MessageType The message type that determines the duration. +-- @param Wrapper.Group#GROUP MessageGroup The GROUP object receiving the message. +-- @param #string Name (optional) The Name of the sender. If not provided, the Name is the type of the Positionable. +function POSITIONABLE:MessageTypeToGroup( Message, MessageType, MessageGroup, Name ) + self:F2( { Message, MessageType } ) + + local DCSObject = self:GetDCSObject() + if DCSObject then + if DCSObject:isExist() then + self:GetMessageType( Message, MessageType, Name ):ToGroup( MessageGroup ) + end + end + + return nil +end + --- Send a message to a @{Set#SET_GROUP}. -- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. -- @param #POSITIONABLE self @@ -572,7 +609,7 @@ function POSITIONABLE:MessageToSetGroup( Message, Duration, MessageSetGroup, Nam if DCSObject:isExist() then MessageSetGroup:ForEachGroup( function( MessageGroup ) - self:GetMessage( Message, Duration, Name ):ToGroup( MessageGroup ) + self:GetMessageType( Message, Duration, Name ):ToGroup( MessageGroup ) end ) end From e545af51f3ff935fd5c439e01e7b4d540c8b38ae Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Tue, 12 Sep 2017 12:20:41 +0200 Subject: [PATCH 2/2] Implemented type messages to Coalition --- .../Moose/Tasking/CommandCenter.lua | 14 ++++++++++ Moose Development/Moose/Tasking/Mission.lua | 14 +++++----- Moose Development/Moose/Tasking/Task.lua | 2 +- .../Moose/Wrapper/Positionable.lua | 26 +++++++++++++++++++ 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Tasking/CommandCenter.lua b/Moose Development/Moose/Tasking/CommandCenter.lua index 3b38720dc..c42cea39c 100644 --- a/Moose Development/Moose/Tasking/CommandCenter.lua +++ b/Moose Development/Moose/Tasking/CommandCenter.lua @@ -387,6 +387,20 @@ function COMMANDCENTER:MessageToCoalition( Message ) end +--- Send a CC message of a specified type to the coalition of the CC. +-- @param #COMMANDCENTER self +-- @param #string Message The message. +-- @param Core.Message#MESSAGE.MessageType MessageType The type of the message, resulting in automatic time duration and prefix of the message. +function COMMANDCENTER:MessageTypeToCoalition( Message, MessageType ) + + local CCCoalition = self:GetPositionable():GetCoalition() + --TODO: Fix coalition bug! + + self:GetPositionable():MessageTypeToCoalition( Message, MessageType, CCCoalition ) + +end + + --- Report the status of all MISSIONs to a GROUP. -- Each Mission is listed, with an indication how many Tasks are still to be completed. -- @param #COMMANDCENTER self diff --git a/Moose Development/Moose/Tasking/Mission.lua b/Moose Development/Moose/Tasking/Mission.lua index 8565078f2..57b52983e 100644 --- a/Moose Development/Moose/Tasking/Mission.lua +++ b/Moose Development/Moose/Tasking/Mission.lua @@ -264,14 +264,14 @@ function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefi end --- FSM function for a MISSION +--- FSM function for a MISSION -- @param #MISSION self -- @param #string From -- @param #string Event -- @param #string To function MISSION:onenterCOMPLETED( From, Event, To ) - self:GetCommandCenter():MessageToCoalition( self:GetName() .. " has been completed! Good job guys!" ) + self:GetCommandCenter():MessageTypeToCoalition( self:GetName() .. " has been completed! Good job guys!", MESSAGE.Type.Information ) end --- Gets the mission name. @@ -958,7 +958,7 @@ function MISSION:MenuReportBriefing( ReportGroup ) local Report = self:ReportBriefing() - self:GetCommandCenter():MessageToGroup( Report, ReportGroup ) + self:GetCommandCenter():MessageTypeToGroup( Report, ReportGroup, MESSAGE.Type.Briefing ) end @@ -970,7 +970,7 @@ function MISSION:MenuReportTasksSummary( ReportGroup ) local Report = self:ReportSummary( ReportGroup ) - self:GetCommandCenter():MessageToGroup( Report, ReportGroup ) + self:GetCommandCenter():MessageTypeToGroup( Report, ReportGroup, MESSAGE.Type.Overview ) end @@ -983,7 +983,7 @@ function MISSION:MenuReportTasksPerStatus( ReportGroup, TaskStatus ) local Report = self:ReportOverview( ReportGroup, TaskStatus ) - self:GetCommandCenter():MessageToGroup( Report, ReportGroup ) + self:GetCommandCenter():MessageTypeToGroup( Report, ReportGroup, MESSAGE.Type.Overview ) end @@ -993,7 +993,7 @@ function MISSION:MenuReportPlayersPerTask( ReportGroup ) local Report = self:ReportPlayersPerTask() - self:GetCommandCenter():MessageToGroup( Report, ReportGroup ) + self:GetCommandCenter():MessageTypeToGroup( Report, ReportGroup, MESSAGE.Type.Overview ) end --- @param #MISSION self @@ -1002,7 +1002,7 @@ function MISSION:MenuReportPlayersProgress( ReportGroup ) local Report = self:ReportPlayersProgress() - self:GetCommandCenter():MessageToGroup( Report, ReportGroup ) + self:GetCommandCenter():MessageTypeToGroup( Report, ReportGroup, MESSAGE.Type.Overview ) end diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 7000f09ac..07904d069 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -884,7 +884,7 @@ function TASK:MenuTaskStatus( TaskGroup ) local ReportText = self:ReportDetails( TaskGroup ) self:T( ReportText ) - self:GetMission():GetCommandCenter():MessageToGroup( ReportText, TaskGroup ) + self:GetMission():GetCommandCenter():MessageTypeToGroup( ReportText, TaskGroup, MESSAGE.Type.Detailed ) end diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index 1bde60935..ec24b47ed 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -502,6 +502,32 @@ function POSITIONABLE:MessageToCoalition( Message, Duration, MessageCoalition ) end +--- Send a message to a coalition. +-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. +-- @param #POSITIONABLE self +-- @param #string Message The message text +-- @param Core.Message#MESSAGE.Type MessageType The message type that determines the duration. +-- @param Dcs.DCScoalition#coalition MessageCoalition The Coalition receiving the message. +function POSITIONABLE:MessageTypeToCoalition( Message, MessageType, MessageCoalition ) + self:F2( { Message, MessageType } ) + + local Name = "" + + local DCSObject = self:GetDCSObject() + if DCSObject then + if MessageCoalition == coalition.side.BLUE then + Name = "Blue coalition" + end + if MessageCoalition == coalition.side.RED then + Name = "Red coalition" + end + self:GetMessageType( Message, MessageType, Name ):ToCoalition( MessageCoalition ) + end + + return nil +end + + --- Send a message to the red coalition. -- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. -- @param #POSITIONABLE self