From 4dc468e9029991abcfbf2a62deb5578a4ec2eabc Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Fri, 8 Sep 2017 20:12:15 +0200 Subject: [PATCH] In progress * Markers * BR menu on designate always in A2G --- Moose Development/Moose/Core/Point.lua | 113 ++++++++++++------ .../Moose/Functional/Designate.lua | 4 +- Moose Development/Moose/Tasking/Task.lua | 33 ++++- 3 files changed, 107 insertions(+), 43 deletions(-) diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 7f9b04620..1f5b26f39 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -798,6 +798,78 @@ do -- COORDINATE end + --- Provides a coordinate string of the point, based on the A2G coordinate format system. + -- @param #COORDINATE self + -- @param Wrapper.Controllable#CONTROLLABLE Controllable + -- @param Core.Settings#SETTINGS Settings + -- @return #string The coordinate Text in the configured coordinate system. + function COORDINATE:ToStringA2G( Controllable, Settings ) -- R2.2 + + self:F( { Controllable = Controllable and Controllable:GetName() } ) + + local Settings = Settings or ( Controllable and _DATABASE:GetPlayerSettings( Controllable:GetPlayerName() ) ) or _SETTINGS + + if Settings:IsA2G_BR() then + -- If no Controllable is given to calculate the BR from, then MGRS will be used!!! + if Controllable then + local Coordinate = Controllable:GetCoordinate() + return Controllable and self:ToStringBR( Coordinate, Settings ) or self:ToStringMGRS( Settings ) + else + return self:ToStringMGRS( Settings ) + end + end + if Settings:IsA2G_LL_DMS() then + return self:ToStringLLDMS( Settings ) + end + if Settings:IsA2G_LL_DDM() then + return self:ToStringLLDDM( Settings ) + end + if Settings:IsA2G_MGRS() then + return self:ToStringMGRS( Settings ) + end + + return nil + + end + + + --- Provides a coordinate string of the point, based on the A2A coordinate format system. + -- @param #COORDINATE self + -- @param Wrapper.Controllable#CONTROLLABLE Controllable + -- @param Core.Settings#SETTINGS Settings + -- @return #string The coordinate Text in the configured coordinate system. + function COORDINATE:ToStringA2A( Controllable, Settings ) -- R2.2 + + self:F( { Controllable = Controllable and Controllable:GetName() } ) + + local Settings = Settings or ( Controllable and _DATABASE:GetPlayerSettings( Controllable:GetPlayerName() ) ) or _SETTINGS + + if Settings:IsA2A_BRAA() then + if Controllable then + local Coordinate = Controllable:GetCoordinate() + return self:ToStringBRA( Coordinate, Settings ) + else + return self:ToStringMGRS( Settings ) + end + end + if Settings:IsA2A_BULLS() then + local Coalition = Controllable:GetCoalition() + return self:ToStringBULLS( Coalition, Settings ) + end + if Settings:IsA2A_LL_DMS() then + return self:ToStringLLDMS( Settings ) + end + if Settings:IsA2A_LL_DDM() then + return self:ToStringLLDDM( Settings ) + end + if Settings:IsA2A_MGRS() then + return self:ToStringMGRS( Settings ) + end + + return nil + + end + --- Provides a coordinate string of the point, based on a coordinate format system: -- * Uses default settings in COORDINATE. -- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default. @@ -837,46 +909,9 @@ do -- COORDINATE if ModeA2A then - if Settings:IsA2A_BRAA() then - if Controllable then - local Coordinate = Controllable:GetCoordinate() - return self:ToStringBRA( Coordinate, Settings ) - else - return self:ToStringMGRS( Settings ) - end - end - if Settings:IsA2A_BULLS() then - local Coalition = Controllable:GetCoalition() - return self:ToStringBULLS( Coalition, Settings ) - end - if Settings:IsA2A_LL_DMS() then - return self:ToStringLLDMS( Settings ) - end - if Settings:IsA2A_LL_DDM() then - return self:ToStringLLDDM( Settings ) - end - if Settings:IsA2A_MGRS() then - return self:ToStringMGRS( Settings ) - end + return self:ToStringA2A( Controllable, Settings ) else - if Settings:IsA2G_BR() then - -- If no Controllable is given to calculate the BR from, then MGRS will be used!!! - if Controllable then - local Coordinate = Controllable:GetCoordinate() - return Controllable and self:ToStringBR( Coordinate, Settings ) or self:ToStringMGRS( Settings ) - else - return self:ToStringMGRS( Settings ) - end - end - if Settings:IsA2G_LL_DMS() then - return self:ToStringLLDMS( Settings ) - end - if Settings:IsA2G_LL_DDM() then - return self:ToStringLLDDM( Settings ) - end - if Settings:IsA2G_MGRS() then - return self:ToStringMGRS( Settings ) - end + return self:ToStringA2G( Controllable, Settings ) end return nil diff --git a/Moose Development/Moose/Functional/Designate.lua b/Moose Development/Moose/Functional/Designate.lua index a70f12f7e..7775f78eb 100644 --- a/Moose Development/Moose/Functional/Designate.lua +++ b/Moose Development/Moose/Functional/Designate.lua @@ -853,7 +853,7 @@ do -- DESIGNATE local Coord = self.Detection:GetDetectedItemCoordinate( DesignateIndex ) local ID = self.Detection:GetDetectedItemID( DesignateIndex ) - local MenuText = ID .. ", " .. Coord:ToString( AttackGroup ) + local MenuText = ID .. ", " .. Coord:ToStringA2G( AttackGroup ) if Designating == "" then MenuText = "(-) " .. MenuText @@ -862,7 +862,7 @@ do -- DESIGNATE for LaserCode, MenuText in pairs( self.MenuLaserCodes ) do MENU_GROUP_COMMAND:New( AttackGroup, string.format( MenuText, LaserCode ), DetectedMenu, self.MenuLaseCode, self, DesignateIndex, 60, LaserCode ):SetTime( MenuTime ):SetTag( self.DesignateName ) end - MENU_GROUP_COMMAND:New( AttackGroup, "Lase targets", DetectedMenu, self.MenuLaseOn, self, DesignateIndex, 60 ):SetTime( MenuTime ):SetTag( self.DesignateName ) + MENU_GROUP_COMMAND:New( AttackGroup, "Lase with random laser code(s)", DetectedMenu, self.MenuLaseOn, self, DesignateIndex, 60 ):SetTime( MenuTime ):SetTag( self.DesignateName ) MENU_GROUP_COMMAND:New( AttackGroup, "Smoke red", DetectedMenu, self.MenuSmoke, self, DesignateIndex, SMOKECOLOR.Red ):SetTime( MenuTime ):SetTag( self.DesignateName ) MENU_GROUP_COMMAND:New( AttackGroup, "Smoke blue", DetectedMenu, self.MenuSmoke, self, DesignateIndex, SMOKECOLOR.Blue ):SetTime( MenuTime ):SetTag( self.DesignateName ) MENU_GROUP_COMMAND:New( AttackGroup, "Smoke green", DetectedMenu, self.MenuSmoke, self, DesignateIndex, SMOKECOLOR.Green ):SetTime( MenuTime ):SetTag( self.DesignateName ) diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 89c0e0bcd..72ba33fab 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -746,7 +746,8 @@ function TASK:SetPlannedMenuForGroup( TaskGroup, MenuTime ) if not Mission:IsGroupAssigned( TaskGroup ) then self:F( { "Replacing Join Task menu" } ) - local JoinTaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Join Task" ), TaskTypeMenu, self.MenuAssignToGroup, self, TaskGroup ):SetTime( MenuTime ):SetTag( "Tasking" ):SetRemoveParent( true ) + local JoinTaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Join Task" ), TaskTypeMenu, self.MenuAssignToGroup, self, TaskGroup ):SetTime( MenuTime ):SetTag( "Tasking" ):SetRemoveParent( true ) + local MarkTaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Mark Task on Map" ), TaskTypeMenu, self.MenuMarkToGroup, self, TaskGroup ):SetTime( MenuTime ):SetTag( "Tasking" ):SetRemoveParent( true ) end return self @@ -854,11 +855,28 @@ end -- @param Wrapper.Group#GROUP TaskGroup function TASK:MenuAssignToGroup( TaskGroup ) - self:E( "Assigned menu selected") + self:E( "Join Task menu selected") self:AssignToGroup( TaskGroup ) end +--- @param #TASK self +-- @param Wrapper.Group#GROUP TaskGroup +function TASK:MenuMarkToGroup( TaskGroup ) + + self:E( "Mark Task menu selected") + + self:UpdateTaskInfo() + + local Coordinate = self:GetInfo( "Coordinates" ) -- Core.Point#COORDINATE + local Briefing = self:GetTaskBriefing() + local GroupID = TaskGroup:GetID() + + self:F( { Coordinate = Coordinate:GetVec3(), Briefing = Briefing, GroupID = GroupID } ) + + trigger.action.markToGroup( 1, Briefing, Coordinate:GetVec3(), GroupID ) +end + --- Report the task status. -- @param #TASK self function TASK:MenuTaskStatus( TaskGroup ) @@ -1033,6 +1051,17 @@ function TASK:SetInfo( TaskInfo, TaskInfoText, TaskInfoOrder ) self.TaskInfo[TaskInfo].TaskInfoOrder = TaskInfoOrder end +--- Gets the Information of the Task +-- @param #TASK self +-- @param #string TaskInfo The key and title of the task information. +-- @return #string TaskInfoText The Task info text. +function TASK:GetInfo( TaskInfo ) + + self.TaskInfo = self.TaskInfo or {} + self.TaskInfo[TaskInfo] = self.TaskInfo[TaskInfo] or {} + return self.TaskInfo[TaskInfo].TaskInfoText +end + --- Gets the Type of the Task -- @param #TASK self -- @return #string TaskType