Could not test all, but already committing. It works in SP and fixes the completed task issue.

This commit is contained in:
FlightControl_Master 2018-03-09 12:36:53 +01:00
parent bf9d6cbd75
commit 778ab58eee
2 changed files with 69 additions and 26 deletions

View File

@ -11,10 +11,10 @@
-- @module TaskInfo -- @module TaskInfo
--- @type TASKINFO --- @type TASKINFO
-- @extends Core.Set#SET_BASE -- @extends Core.Base#BASE
--- ---
-- # TASKINFO class, extends @{Set#SET} -- # TASKINFO class, extends @{Base#BASE}
-- --
-- ## The TASKINFO class implements the methods to contain information and display information of a task. -- ## The TASKINFO class implements the methods to contain information and display information of a task.
-- --
@ -37,9 +37,13 @@ TASKINFO.Detail = ""
-- @return #TASKINFO self -- @return #TASKINFO self
function TASKINFO:New( Task ) function TASKINFO:New( Task )
local self = BASE:Inherit( self, SET_BASE:New() ) -- Core.Set#SET local self = BASE:Inherit( self, BASE:New() ) -- Core.Base#BASE
self.Task = Task self.Task = Task
self.VolatileInfo = SET_BASE:New()
self.PersistentInfo = SET_BASE:New()
self.Info = self.VolatileInfo
return self return self
end end
@ -51,9 +55,13 @@ end
-- @param Data The data of the info. -- @param Data The data of the info.
-- @param #number Order The display order, which is a number from 0 to 100. -- @param #number Order The display order, which is a number from 0 to 100.
-- @param #TASKINFO.Detail Detail The detail Level. -- @param #TASKINFO.Detail Detail The detail Level.
-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports.
-- @return #TASKINFO self -- @return #TASKINFO self
function TASKINFO:AddInfo( Key, Data, Order, Detail ) function TASKINFO:AddInfo( Key, Data, Order, Detail, Keep )
self:Add( Key, { Data = Data, Order = Order, Detail = Detail } ) self.VolatileInfo:Add( Key, { Data = Data, Order = Order, Detail = Detail } )
if Keep == true then
self.PersistentInfo:Add( Key, { Data = Data, Order = Order, Detail = Detail } )
end
return self return self
end end
@ -75,7 +83,7 @@ end
-- @param #string The info key. -- @param #string The info key.
-- @return Data The data of the info. -- @return Data The data of the info.
function TASKINFO:GetData( Key ) function TASKINFO:GetData( Key )
local Object = self:Get( Key ) local Object = self.Info:Get( Key )
return Object.Data return Object.Data
end end
@ -86,9 +94,10 @@ end
-- @param #string Text The text. -- @param #string Text The text.
-- @param #number Order The display order, which is a number from 0 to 100. -- @param #number Order The display order, which is a number from 0 to 100.
-- @param #TASKINFO.Detail Detail The detail Level. -- @param #TASKINFO.Detail Detail The detail Level.
-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports.
-- @return #TASKINFO self -- @return #TASKINFO self
function TASKINFO:AddText( Key, Text, Order, Detail ) function TASKINFO:AddText( Key, Text, Order, Detail, Keep )
self:AddInfo( Key, Text, Order, Detail ) self:AddInfo( Key, Text, Order, Detail, Keep )
return self return self
end end
@ -97,9 +106,10 @@ end
-- @param #TASKINFO self -- @param #TASKINFO self
-- @param #number Order The display order, which is a number from 0 to 100. -- @param #number Order The display order, which is a number from 0 to 100.
-- @param #TASKINFO.Detail Detail The detail Level. -- @param #TASKINFO.Detail Detail The detail Level.
-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports.
-- @return #TASKINFO self -- @return #TASKINFO self
function TASKINFO:AddTaskName( Order, Detail ) function TASKINFO:AddTaskName( Order, Detail, Keep )
self:AddInfo( "TaskName", self.Task:GetName(), Order, Detail ) self:AddInfo( "TaskName", self.Task:GetName(), Order, Detail, Keep )
return self return self
end end
@ -111,34 +121,48 @@ end
-- @param Core.Point#COORDINATE Coordinate -- @param Core.Point#COORDINATE Coordinate
-- @param #number Order The display order, which is a number from 0 to 100. -- @param #number Order The display order, which is a number from 0 to 100.
-- @param #TASKINFO.Detail Detail The detail Level. -- @param #TASKINFO.Detail Detail The detail Level.
-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports.
-- @return #TASKINFO self -- @return #TASKINFO self
function TASKINFO:AddCoordinate( Coordinate, Order, Detail ) function TASKINFO:AddCoordinate( Coordinate, Order, Detail, Keep )
self:AddInfo( "Coordinate", Coordinate, Order, Detail ) self:AddInfo( "Coordinate", Coordinate, Order, Detail, Keep )
return self return self
end end
--- Add Threat. --- Add Threat.
-- @param #TASKINFO self -- @param #TASKINFO self
-- @param #string ThreatText The text of the Threat. -- @param #string ThreatText The text of the Threat.
-- @param #string ThreatLevel The level of the Threat. -- @param #string ThreatLevel The level of the Threat.
-- @param #number Order The display order, which is a number from 0 to 100. -- @param #number Order The display order, which is a number from 0 to 100.
-- @param #TASKINFO.Detail Detail The detail Level. -- @param #TASKINFO.Detail Detail The detail Level.
-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports.
-- @return #TASKINFO self -- @return #TASKINFO self
function TASKINFO:AddThreat( ThreatText, ThreatLevel, Order, Detail ) function TASKINFO:AddThreat( ThreatText, ThreatLevel, Order, Detail, Keep )
self:AddInfo( "Threat", ThreatText .. " [" .. string.rep( "", ThreatLevel ) .. string.rep( "", 10 - ThreatLevel ) .. "]", Order, Detail ) self:AddInfo( "Threat", ThreatText .. " [" .. string.rep( "", ThreatLevel ) .. string.rep( "", 10 - ThreatLevel ) .. "]", Order, Detail, Keep )
return self return self
end end
--- Get Threat.
-- @param #TASKINFO self
-- @return #string The threat
function TASKINFO:GetThreat()
self:GetInfo( "Threat" )
return self
end
--- Add the Target count. --- Add the Target count.
-- @param #TASKINFO self -- @param #TASKINFO self
-- @param #number TargetCount The amount of targets. -- @param #number TargetCount The amount of targets.
-- @param #number Order The display order, which is a number from 0 to 100. -- @param #number Order The display order, which is a number from 0 to 100.
-- @param #TASKINFO.Detail Detail The detail Level. -- @param #TASKINFO.Detail Detail The detail Level.
-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports.
-- @return #TASKINFO self -- @return #TASKINFO self
function TASKINFO:AddTargetCount( TargetCount, Order, Detail ) function TASKINFO:AddTargetCount( TargetCount, Order, Detail, Keep )
self:AddInfo( "Counting", string.format( "%d", TargetCount ), Order, Detail ) self:AddInfo( "Counting", string.format( "%d", TargetCount ), Order, Detail, Keep )
return self return self
end end
@ -148,20 +172,33 @@ end
-- @param #string TargetTypes The text containing the target types. -- @param #string TargetTypes The text containing the target types.
-- @param #number Order The display order, which is a number from 0 to 100. -- @param #number Order The display order, which is a number from 0 to 100.
-- @param #TASKINFO.Detail Detail The detail Level. -- @param #TASKINFO.Detail Detail The detail Level.
-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports.
-- @return #TASKINFO self -- @return #TASKINFO self
function TASKINFO:AddTargets( TargetCount, TargetTypes, Order, Detail ) function TASKINFO:AddTargets( TargetCount, TargetTypes, Order, Detail, Keep )
self:AddInfo( "Targets", string.format( "%d of %s", TargetCount, TargetTypes ), Order, Detail ) self:AddInfo( "Targets", string.format( "%d of %s", TargetCount, TargetTypes ), Order, Detail, Keep )
return self return self
end end
--- Get Targets.
-- @param #TASKINFO self
-- @return #string The targets
function TASKINFO:GetTargets()
self:GetInfo( "Targets" )
return self
end
--- Add the QFE at a Coordinate. --- Add the QFE at a Coordinate.
-- @param #TASKINFO self -- @param #TASKINFO self
-- @param Core.Point#COORDINATE Coordinate -- @param Core.Point#COORDINATE Coordinate
-- @param #number Order The display order, which is a number from 0 to 100. -- @param #number Order The display order, which is a number from 0 to 100.
-- @param #TASKINFO.Detail Detail The detail Level. -- @param #TASKINFO.Detail Detail The detail Level.
-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports.
-- @return #TASKINFO self -- @return #TASKINFO self
function TASKINFO:AddQFEAtCoordinate( Coordinate, Order, Detail ) function TASKINFO:AddQFEAtCoordinate( Coordinate, Order, Detail, Keep )
self:AddInfo( "QFE", Coordinate, Order, Detail ) self:AddInfo( "QFE", Coordinate, Order, Detail, Keep )
return self return self
end end
@ -170,9 +207,10 @@ end
-- @param Core.Point#COORDINATE Coordinate -- @param Core.Point#COORDINATE Coordinate
-- @param #number Order The display order, which is a number from 0 to 100. -- @param #number Order The display order, which is a number from 0 to 100.
-- @param #TASKINFO.Detail Detail The detail Level. -- @param #TASKINFO.Detail Detail The detail Level.
-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports.
-- @return #TASKINFO self -- @return #TASKINFO self
function TASKINFO:AddTemperatureAtCoordinate( Coordinate, Order, Detail ) function TASKINFO:AddTemperatureAtCoordinate( Coordinate, Order, Detail, Keep )
self:AddInfo( "Temperature", Coordinate, Order, Detail ) self:AddInfo( "Temperature", Coordinate, Order, Detail, Keep )
return self return self
end end
@ -181,9 +219,10 @@ end
-- @param Core.Point#COORDINATE Coordinate -- @param Core.Point#COORDINATE Coordinate
-- @param #number Order The display order, which is a number from 0 to 100. -- @param #number Order The display order, which is a number from 0 to 100.
-- @param #TASKINFO.Detail Detail The detail Level. -- @param #TASKINFO.Detail Detail The detail Level.
-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports.
-- @return #TASKINFO self -- @return #TASKINFO self
function TASKINFO:AddWindAtCoordinate( Coordinate, Order, Detail ) function TASKINFO:AddWindAtCoordinate( Coordinate, Order, Detail, Keep )
self:AddInfo( "Wind", Coordinate, Order, Detail ) self:AddInfo( "Wind", Coordinate, Order, Detail, Keep )
return self return self
end end
@ -199,7 +238,11 @@ function TASKINFO:Report( Report, Detail, ReportGroup )
local Line = 0 local Line = 0
local LineReport = REPORT:New() local LineReport = REPORT:New()
for Key, Data in UTILS.spairs( self.Set, function( t, a, b ) return t[a].Order < t[b].Order end ) do if not self.Task:IsStatePlanned() and not self.Task:IsStateAssigned() then
self.Info = self.PersistentInfo
end
for Key, Data in UTILS.spairs( self.Info.Set, function( t, a, b ) return t[a].Order < t[b].Order end ) do
self:E( { Key = Key, Detail = Detail, Data = Data } ) self:E( { Key = Key, Detail = Detail, Data = Data } )

View File

@ -289,7 +289,7 @@ do -- TASK_A2G
--- Return the relative distance to the target vicinity from the player, in order to sort the targets in the reports per distance from the threats. --- Return the relative distance to the target vicinity from the player, in order to sort the targets in the reports per distance from the threats.
-- @param #TASK_A2G self -- @param #TASK_A2G self
function TASK_A2G:ReportOrder( ReportGroup ) function TASK_A2G:ReportOrder( ReportGroup )
local Coordinate = self:GetData( "Coordinate" ) local Coordinate = self.TaskInfo:GetData( "Coordinate" )
local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate ) local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate )
return Distance return Distance