mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge remote-tracking branch 'origin/master' into develop
This commit is contained in:
commit
504e56e827
@ -170,10 +170,11 @@ end
|
||||
--- Adds a Unit based on the Unit Name in the DATABASE.
|
||||
-- @param #DATABASE self
|
||||
-- @param #string DCSUnitName Unit name.
|
||||
-- @param #boolean force
|
||||
-- @return Wrapper.Unit#UNIT The added unit.
|
||||
function DATABASE:AddUnit( DCSUnitName )
|
||||
function DATABASE:AddUnit( DCSUnitName, force )
|
||||
|
||||
if not self.UNITS[DCSUnitName] then
|
||||
if not self.UNITS[DCSUnitName] or force == true then
|
||||
-- Debug info.
|
||||
self:T( { "Add UNIT:", DCSUnitName } )
|
||||
|
||||
@ -832,15 +833,25 @@ end
|
||||
function DATABASE:FindGroup( GroupName )
|
||||
|
||||
local GroupFound = self.GROUPS[GroupName]
|
||||
|
||||
if GroupFound == nil and GroupName ~= nil then
|
||||
-- see if the group exists in the API, maybe a dynamic slot
|
||||
self:_RegisterDynamicGroup(GroupName)
|
||||
return self.GROUPS[GroupName]
|
||||
end
|
||||
|
||||
return GroupFound
|
||||
end
|
||||
|
||||
|
||||
--- Adds a GROUP based on the GroupName in the DATABASE.
|
||||
-- @param #DATABASE self
|
||||
function DATABASE:AddGroup( GroupName )
|
||||
-- @param #string GroupName
|
||||
-- @param #boolean force
|
||||
-- @return Wrapper.Group#GROUP The Group
|
||||
function DATABASE:AddGroup( GroupName, force )
|
||||
|
||||
if not self.GROUPS[GroupName] then
|
||||
if not self.GROUPS[GroupName] or force == true then
|
||||
self:T( { "Add GROUP:", GroupName } )
|
||||
self.GROUPS[GroupName] = GROUP:Register( GroupName )
|
||||
end
|
||||
@ -1346,6 +1357,36 @@ function DATABASE:_RegisterPlayers()
|
||||
return self
|
||||
end
|
||||
|
||||
--- Private method that registers a single dynamic slot Group and Units within in the mission.
|
||||
-- @param #DATABASE self
|
||||
-- @return #DATABASE self
|
||||
function DATABASE:_RegisterDynamicGroup(Groupname)
|
||||
local DCSGroup = Group.getByName(Groupname)
|
||||
if DCSGroup:isExist() then
|
||||
|
||||
-- Group name.
|
||||
local DCSGroupName = DCSGroup:getName()
|
||||
|
||||
-- Add group.
|
||||
self:I(string.format("Register Group: %s", tostring(DCSGroupName)))
|
||||
self:AddGroup( DCSGroupName, true )
|
||||
|
||||
-- Loop over units in group.
|
||||
for DCSUnitId, DCSUnit in pairs( DCSGroup:getUnits() ) do
|
||||
|
||||
-- Get unit name.
|
||||
local DCSUnitName = DCSUnit:getName()
|
||||
|
||||
-- Add unit.
|
||||
self:I(string.format("Register Unit: %s", tostring(DCSUnitName)))
|
||||
self:AddUnit( DCSUnitName, true )
|
||||
|
||||
end
|
||||
else
|
||||
self:E({"Group does not exist: ", DCSGroup})
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
--- Private method that registers all Groups and Units within in the mission.
|
||||
-- @param #DATABASE self
|
||||
@ -1519,8 +1560,8 @@ function DATABASE:_EventOnBirth( Event )
|
||||
|
||||
if Event.IniObjectCategory == Object.Category.UNIT then
|
||||
|
||||
Event.IniUnit = self:FindUnit( Event.IniDCSUnitName )
|
||||
Event.IniGroup = self:FindGroup( Event.IniDCSGroupName )
|
||||
Event.IniUnit = self:FindUnit( Event.IniDCSUnitName )
|
||||
|
||||
-- Client
|
||||
local client=self.CLIENTS[Event.IniDCSUnitName] --Wrapper.Client#CLIENT
|
||||
@ -1550,12 +1591,17 @@ function DATABASE:_EventOnBirth( Event )
|
||||
self:AddPlayer( Event.IniUnitName, PlayerName )
|
||||
end
|
||||
|
||||
local function SetPlayerSettings(self,PlayerName,IniUnit)
|
||||
-- Player settings.
|
||||
local Settings = SETTINGS:Set( PlayerName )
|
||||
Settings:SetPlayerMenu(Event.IniUnit)
|
||||
|
||||
--Settings:SetPlayerMenu(Event.IniUnit)
|
||||
Settings:SetPlayerMenu(IniUnit)
|
||||
-- Create an event.
|
||||
self:CreateEventPlayerEnterAircraft(Event.IniUnit)
|
||||
self:CreateEventPlayerEnterAircraft(IniUnit)
|
||||
--self:CreateEventPlayerEnterAircraft(Event.IniUnit)
|
||||
end
|
||||
|
||||
self:ScheduleOnce(1,SetPlayerSettings,self,PlayerName,Event.IniUnit)
|
||||
|
||||
end
|
||||
|
||||
@ -1719,6 +1765,7 @@ function DATABASE:_EventOnPlayerLeaveUnit( Event )
|
||||
local client=self.CLIENTS[Event.IniDCSUnitName] --Wrapper.Client#CLIENT
|
||||
if client then
|
||||
client:RemovePlayer(PlayerName)
|
||||
--self.PLAYERSETTINGS[PlayerName] = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -738,7 +738,7 @@ do -- SETTINGS
|
||||
|
||||
local PlayerGroup = PlayerUnit:GetGroup()
|
||||
local PlayerName = PlayerUnit:GetPlayerName()
|
||||
local PlayerNames = PlayerGroup:GetPlayerNames()
|
||||
--local PlayerNames = PlayerGroup:GetPlayerNames()
|
||||
|
||||
local PlayerMenu = MENU_GROUP:New( PlayerGroup, 'Settings "' .. PlayerName .. '"' )
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user