From 057e52894753beafb2e0dcbb17eff1bee80b05dd Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Thu, 23 Nov 2017 21:00:38 +0100 Subject: [PATCH] Changes --- Moose Development/Moose/Core/Menu.lua | 109 +++++++++++++++++- .../Moose_Static_Loader.lua | 3 + 2 files changed, 110 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Core/Menu.lua b/Moose Development/Moose/Core/Menu.lua index 900a65a5f..3adf00c6f 100644 --- a/Moose Development/Moose/Core/Menu.lua +++ b/Moose Development/Moose/Core/Menu.lua @@ -149,6 +149,32 @@ function MENU_INDEX:ClearGroupMenu( Group, Path ) self.Group[MenuGroupName].Menus[Path] = nil end +function MENU_INDEX:Refresh( Group ) + + for MenuID, Menu in pairs( self.MenuMission.Menus ) do + Menu:Refresh() + end + + for MenuID, Menu in pairs( self.Coalition[coalition.side.BLUE].Menus ) do + Menu:Refresh() + end + + for MenuID, Menu in pairs( self.Coalition[coalition.side.RED].Menus ) do + Menu:Refresh() + end + + local GroupName = Group:GetName() + for MenuID, Menu in pairs( self.Group[GroupName].Menus ) do + Menu:Refresh() + end + +end + + + + + + do -- MENU_BASE @@ -342,12 +368,24 @@ do -- MENU_MISSION local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) ) MENU_INDEX:SetMissionMenu( Path, self ) - self.MenuPath = missionCommands.addSubMenu( MenuText, self.MenuParentPath ) + self.MenuPath = missionCommands.addSubMenu( self.MenuText, self.MenuParentPath ) self:SetParentMenu( self.MenuText, self ) return self end end + + --- Refreshes a radio item for a mission + -- @param #MENU_MISSION self + -- @return #MENU_MISSION + function MENU_MISSION:Refresh() + + do + missionCommands.removeItem( self.MenuPath ) + self.MenuPath = missionCommands.addSubMenu( self.MenuText, self.MenuParentPath ) + end + + end --- Removes the sub menus recursively of this MENU_MISSION. Note that the main menu is kept! -- @param #MENU_MISSION self @@ -432,6 +470,18 @@ do -- MENU_MISSION_COMMAND return self end end + + --- Refreshes a radio item for a mission + -- @param #MENU_MISSION_COMMAND self + -- @return #MENU_MISSION_COMMAND + function MENU_MISSION_COMMAND:Refresh() + + do + missionCommands.removeItem( self.MenuPath ) + missionCommands.addCommand( self.MenuText, self.MenuParentPath, self.MenuCallHandler ) + end + + end --- Removes a radio command item for a coalition -- @param #MENU_MISSION_COMMAND self @@ -540,6 +590,18 @@ do -- MENU_COALITION return self end end + + --- Refreshes a radio item for a coalition + -- @param #MENU_COALITION self + -- @return #MENU_COALITION + function MENU_COALITION:Refresh() + + do + missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath ) + missionCommands.addSubMenuForCoalition( self.Coalition, self.MenuText, self.MenuParentPath ) + end + + end --- Removes the sub menus recursively of this MENU_COALITION. Note that the main menu is kept! -- @param #MENU_COALITION self @@ -627,6 +689,19 @@ do -- MENU_COALITION_COMMAND end end + + + --- Refreshes a radio item for a coalition + -- @param #MENU_COALITION_COMMAND self + -- @return #MENU_COALITION_COMMAND + function MENU_COALITION_COMMAND:Refresh() + + do + missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath ) + missionCommands.addCommandForCoalition( self.Coalition, self.MenuText, self.MenuParentPath, self.MenuCallHandler ) + end + + end --- Removes a radio command item for a coalition -- @param #MENU_COALITION_COMMAND self @@ -740,7 +815,7 @@ do MENU_INDEX:PrepareGroup( Group ) local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText ) - local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path ) + local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path ) if GroupMenu then return GroupMenu @@ -757,6 +832,22 @@ do end end + + --- Refreshes a new radio item for a group and submenus + -- @param #MENU_GROUP self + -- @return #MENU_GROUP + function MENU_GROUP:Refresh() + + do + missionCommands.removeItemForGroup( self.GroupID, self.MenuPath ) + missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath ) + + for MenuText, Menu in pairs( self.Menus or {} ) do + Menu:Refresh() + end + end + + end --- Removes the sub menus recursively of this MENU_GROUP. -- @param #MENU_GROUP self @@ -851,6 +942,18 @@ do end end + + --- Refreshes a radio item for a group + -- @param #MENU_GROUP_COMMAND self + -- @return #MENU_GROUP_COMMAND + function MENU_GROUP_COMMAND:Refresh() + + do + missionCommands.removeItemForGroup( self.GroupID, self.MenuPath ) + missionCommands.addCommandForGroup( self.GroupID, self.MenuText, self.MenuParentPath, self.MenuCallHandler ) + end + + end --- Removes a menu structure for a group. -- @param #MENU_GROUP_COMMAND self @@ -876,6 +979,8 @@ do return self end + + end diff --git a/Moose Mission Setup/Moose Create Static/Moose_Static_Loader.lua b/Moose Mission Setup/Moose Create Static/Moose_Static_Loader.lua index 8b1378917..07a16c79c 100644 --- a/Moose Mission Setup/Moose Create Static/Moose_Static_Loader.lua +++ b/Moose Mission Setup/Moose Create Static/Moose_Static_Loader.lua @@ -1 +1,4 @@ +MOOSE = {} +function MOOSE.Include() +end