Progress designing system settings

This commit is contained in:
FlightControl 2017-05-20 08:48:57 +02:00
parent 264cf69a6f
commit 13449cc9ee
9 changed files with 924 additions and 722 deletions

View File

@ -154,29 +154,21 @@ do -- ACT_ROUTE
--- Get the routing text to be displayed.
-- The route mode determines the text displayed.
-- @param #ACT_ROUTE self
-- @param Core.Point#COORDINATE FromCoordinate
-- @return #string
function ACT_ROUTE:GetRouteText( FromCoordinate )
local RouteText = ""
if self.Coordinate and self.RouteMode == "B" then
RouteText = "Route to " .. FromCoordinate:GetBRText( self.Coordinate ) .. " km."
if self.Coordinate then
RouteText = "Route to " .. self.Coordinate:ToString( FromCoordinate )
end
if self.Coordinate and self.RouteMode == "C" then
RouteText = "Route to " .. self.Coordinate:ToString()
end
if self.Zone and self.RouteMode == "B" then
local Coordinate = self.Zone:GetCoordinate()
RouteText = "Route to zone bearing " .. FromCoordinate:GetBRText( Coordinate ) .. " km."
if self.Zone then
RouteText = "Route to " .. self.Zone:GetCoordinate():ToString( FromCoordinate )
end
if self.Zone and self.RouteMode == "C" then
local Coordinate = self.Zone:GetCoordinate()
RouteText = "Route to zone at " .. Coordinate:ToString()
end
return RouteText
end
@ -438,10 +430,7 @@ do -- ACT_ROUTE_ZONE
-- @param #string To
function ACT_ROUTE_ZONE:onafterReport( ProcessUnit, From, Event, To )
local ZoneVec2 = self.Zone:GetVec2()
local ZoneCoordinate = COORDINATE:New( ZoneVec2.x, ZoneVec2.y )
local TaskUnitVec2 = ProcessUnit:GetVec2()
local TaskUnitCoordinate = COORDINATE:New( TaskUnitVec2.x, TaskUnitVec2.y )
local TaskUnitCoordinate = ProcessUnit:GetCoordinate()
local RouteText = self:GetRouteText( TaskUnitCoordinate )
self:Message( RouteText )
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,228 @@
--- **Core** - **SETTINGS** classe defines the format settings management for measurement.
--
-- ![Banner Image](..\Presentations\SETTINGS\Dia1.JPG)
--
-- ====
--
-- # Demo Missions
--
-- ### [SETTINGS Demo Missions source code]()
--
-- ### [SETTINGS Demo Missions, only for beta testers]()
--
-- ### [ALL Demo Missions pack of the last release](https://github.com/FlightControl-Master/MOOSE_MISSIONS/releases)
--
-- ====
--
-- # YouTube Channel
--
-- ### [SETTINGS YouTube Channel]()
--
-- ===
--
-- ### Authors:
--
-- * FlightControl : Design & Programming
--
-- ### Contributions:
--
-- @module Settings
--- @type SETTINGS
-- @field #number LL_Accuracy
-- @field #boolean LL_DMS
-- @field #number MGRS_Accuracy
-- @field #string A2GSystem
-- @field #string A2ASystem
-- @extends Core.Base#BASE
--- # SETTINGS class, extends @{Base#BASE}
--
-- @field #SETTINGS
SETTINGS = {
ClassName = "SETTINGS",
LL_Accuracy = 2,
LL_DMS = true,
MGRS_Accuracy = 5,
A2GSystem = "MGRS",
A2ASystem = "BRA",
}
do -- SETTINGS
--- SETTINGS constructor.
-- @param #SETTINGS self
-- @return #SETTINGS
function SETTINGS:New()
local self = BASE:Inherit( self, BASE:New() ) -- #SETTINGS
self:SetMetric() -- Defaults
self:SetA2G_MGRS() -- Defaults
self:SetA2A_BRA() -- Defaults
return self
end
--- Sets the SETTINGS metric.
-- @param #SETTINGS self
function SETTINGS:SetMetric()
self.Metric = true
end
--- Gets if the SETTINGS is metric.
-- @param #SETTINGS self
-- @return #boolean true if metric.
function SETTINGS:IsMetric()
return self.Metric == true
end
--- Sets the SETTINGS imperial.
-- @param #SETTINGS self
function SETTINGS:SetImperial()
self.Metric = false
end
--- Gets if the SETTINGS is imperial.
-- @param #SETTINGS self
-- @return #boolean true if imperial.
function SETTINGS:IsImperial()
return self.Metric == false
end
--- Sets A2G LL
-- @param #SETTINGS self
-- @return #SETTINGS
function SETTINGS:SetA2G_LL()
self.A2GSystem = "LL"
end
--- Is LL
-- @param #SETTINGS self
-- @return #boolean true if LL
function SETTINGS:IsA2G_LL()
return self.A2GSystem == "LL"
end
--- Sets A2G MGRS
-- @param #SETTINGS self
-- @return #SETTINGS
function SETTINGS:SetA2G_MGRS()
self.A2GSystem = "MGRS"
end
--- Is MGRS
-- @param #SETTINGS self
-- @return #boolean true if MGRS
function SETTINGS:IsA2G_MGRS()
return self.A2GSystem == "MGRS"
end
--- Sets A2A BRA
-- @param #SETTINGS self
-- @return #SETTINGS
function SETTINGS:SetA2A_BRA()
self.A2ASystem = "BRA"
end
--- Is BRA
-- @param #SETTINGS self
-- @return #boolean true if BRA
function SETTINGS:IsA2A_BRA()
return self.A2ASystem == "BRA"
end
--- Sets A2A BULLS
-- @param #SETTINGS self
-- @return #SETTINGS
function SETTINGS:SetA2A_BULLS()
self.A2ASystem = "BULLS"
end
--- Is BULLS
-- @param #SETTINGS self
-- @return #boolean true if BULLS
function SETTINGS:IsA2A_BULLS()
return self.A2ASystem == "BULLS"
end
--- @param #SETTINGS self
-- @return #SETTINGS
function SETTINGS:SettingsMenu( RootMenu )
if self.SystemMenu then
self.SystemMenu:Remove()
self.SystemMenu = nil
end
self.SystemMenu = MENU_MISSION:New( "Coordinate Settings" )
local A2GCoordinateMenu = MENU_MISSION:New( "A2G Coordinate System", self.SystemMenu )
if self:IsA2GLL() then
MENU_MISSION_COMMAND:New( "Activate MGRS", A2GCoordinateMenu, self.A2GMenuSystem, self, "MGRS" )
MENU_MISSION_COMMAND:New( "LL Accuracy 1", A2GCoordinateMenu, self.MenuLL_Accuracy, self, 1 )
MENU_MISSION_COMMAND:New( "LL Accuracy 2", A2GCoordinateMenu, self.MenuLL_Accuracy, self, 2 )
MENU_MISSION_COMMAND:New( "LL Accuracy 3", A2GCoordinateMenu, self.MenuLL_Accuracy, self, 3 )
MENU_MISSION_COMMAND:New( "LL Decimal On", A2GCoordinateMenu, self.MenuLL_DMS, self, true )
MENU_MISSION_COMMAND:New( "LL Decimal Off", A2GCoordinateMenu, self.MenuLL_DMS, self, false )
end
if self:IsA2GMGRS() then
MENU_MISSION_COMMAND:New( "Activate LL", A2GCoordinateMenu, self.A2GMenuSystem, self, "LL" )
MENU_MISSION_COMMAND:New( "MGRS Accuracy 1", A2GCoordinateMenu, self.MenuMGRS_Accuracy, self, 1 )
MENU_MISSION_COMMAND:New( "MGRS Accuracy 2", A2GCoordinateMenu, self.MenuMGRS_Accuracy, self, 2 )
MENU_MISSION_COMMAND:New( "MGRS Accuracy 3", A2GCoordinateMenu, self.MenuMGRS_Accuracy, self, 3 )
MENU_MISSION_COMMAND:New( "MGRS Accuracy 4", A2GCoordinateMenu, self.MenuMGRS_Accuracy, self, 4 )
MENU_MISSION_COMMAND:New( "MGRS Accuracy 5", A2GCoordinateMenu, self.MenuMGRS_Accuracy, self, 5 )
end
local A2ACoordinateMenu = MENU_MISSION:New( "A2A Coordinate System", self.SystemMenu )
if self:IsA2ABULLS() then
MENU_MISSION_COMMAND:New( "Activate BRA", A2GCoordinateMenu, self.A2AMenuSystem, self, "BRA" )
end
if self:IsA2ABRA() then
MENU_MISSION_COMMAND:New( "Activate BULLS", A2GCoordinateMenu, self.A2AMenuSystem, self, "BULLS" )
end
return self
end
--- @param #SETTINGS self
function SETTINGS:A2GMenuSystem( A2GSystem )
self.A2GSystem = A2GSystem
self:CoordinateMenu()
end
--- @param #SETTINGS self
function SETTINGS:A2AMenuSystem( A2ASystem )
self.A2ASystem = A2ASystem
self:CoordinateMenu()
end
--- @param #SETTINGS self
function SETTINGS:MenuLL_Accuracy( LL_Accuracy )
self.LL_Accuracy = LL_Accuracy
self:CoordinateMenu()
end
--- @param #SETTINGS self
function SETTINGS:MenuLL_DMS( LL_DMS )
self.LL_DMS = LL_DMS
self:CoordinateMenu()
end
--- @param #SETTINGS self
function SETTINGS:MenuMGRS_Accuracy( MGRS_Accuracy )
self.MGRS_Accuracy = MGRS_Accuracy
self:CoordinateMenu()
end
end

View File

@ -1308,7 +1308,7 @@ do -- DETECTION_BASE
--- Get the COORDINATE of a detection item using a given numeric index.
-- @param #DETECTION_BASE self
-- @param #number Index
-- @return Core.Point#COORDINATE Coordinate
-- @return Core.Point#COORDINATE
function DETECTION_BASE:GetDetectedItemCoordinate( Index )
-- If the Zone is set, return the coordinate of the Zone.
@ -1317,14 +1317,15 @@ do -- DETECTION_BASE
local DetectedZone = self:GetDetectedItemZone( Index )
if DetectedZone then
local Coordinate = DetectedZone:GetCoordinate()
local Coordinate = DetectedZone:GetPointVec2()
Coordinate:SetHeading(FirstUnit:GetHeading())
Coordinate:SetAlt( FirstUnit:GetAltitude() )
return Coordinate
end
-- If no Zone is set, return the coordinate of the first unit in the Set
if FirstUnit then
local Coordinate = FirstUnit:GetCoordinate()
local Coordinate = FirstUnit:GetPointVec3()
FirstUnit:SetHeading(FirstUnit:GetHeading())
return Coordinate
end

View File

@ -9,4 +9,5 @@ _SCHEDULEDISPATCHER = SCHEDULEDISPATCHER:New() -- Core.Timer#SCHEDULEDISPATCHER
--- Declare the main database object, which is used internally by the MOOSE classes.
_DATABASE = DATABASE:New() -- Database#DATABASE
--COORDINATE:CoordinateMenu()
_SETTINGS = SETTINGS:New()
_SETTINGS:SettingsMenu(nil)

View File

@ -1403,9 +1403,10 @@ function TASK:ReportDetails( TaskGroup ) --R2.1 fixed report. Now nicely formatt
elseif type(TaskInfo) == "table" then
if TaskInfoID == "Coordinates" then
local FromCoordinate = TaskGroup:GetUnit(1):GetCoordinate()
local ToCoordinate = TaskInfo -- Core.Point#COORDINATE
Report:Add( TaskInfoIDText )
Report:AddIndent( TaskInfo:ToStringBRAA( FromCoordinate ) .. ", " .. TaskInfo:ToStringAspect( FromCoordinate ) )
Report:AddIndent( TaskInfo:ToStringBULLS( TaskGroup:GetCoalition() ) )
Report:AddIndent( ToCoordinate:ToStringBRAA( FromCoordinate ) .. ", " .. TaskInfo:ToStringAspect( FromCoordinate ) )
Report:AddIndent( ToCoordinate:ToStringBULLS( TaskGroup:GetCoalition() ) )
else
end
end

View File

@ -72,7 +72,7 @@ do -- TASK_A2A_DISPATCHER
self.Mission = Mission
self.Detection:FilterCategories( Unit.Category.AIRPLANE, Unit.Category.HELICOPTER )
self.Detection:InitDetectRadar( true )
--self.Detection:InitDetectRadar( true )
self.Detection:SetDetectionInterval( 30 )
self:AddTransition( "Started", "Assign", "Started" )
@ -190,7 +190,11 @@ do -- TASK_A2A_DISPATCHER
local DetectedItemsCount = DetectedSet:Count()
local DetectedItemsTypes = DetectedSet:GetTypeNames()
Task:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ) )
Task:SetInfo( "Coordinates", Detection:GetDetectedItemCoordinate( DetectedIndex ) )
local Coordinate = Detection:GetDetectedItemCoordinate( DetectedIndex )
Coordinate:SetModeA2A()
Task:SetInfo( "Coordinates", Coordinate )
Task:SetInfo( "Object", DetectedSet:GetFirst() )
Mission:AddTask( Task )
else

View File

@ -5,6 +5,7 @@ Core/Base.lua
Core/Scheduler.lua
Core/ScheduleDispatcher.lua
Core/Event.lua
Core/Settings.lua
Core/Menu.lua
Core/Zone.lua
Core/Database.lua

View File

@ -1,5 +1,5 @@
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
env.info( 'Moose Generation Timestamp: 20170517_1856' )
env.info( 'Moose Generation Timestamp: 20170520_0827' )
local base = _G
@ -27,6 +27,7 @@ __Moose.Include( 'Core/Base.lua' )
__Moose.Include( 'Core/Scheduler.lua' )
__Moose.Include( 'Core/ScheduleDispatcher.lua' )
__Moose.Include( 'Core/Event.lua' )
__Moose.Include( 'Core/Settings.lua' )
__Moose.Include( 'Core/Menu.lua' )
__Moose.Include( 'Core/Zone.lua' )
__Moose.Include( 'Core/Database.lua' )