Ejemplo n.º 1
0
        private void SymmetryMode_Clicked(UIActionGroupManager obj)
        {
            if (!obj.Current.Action.IsInActionGroup(obj.ActionGroup))
            {
                obj.Current.Action.AddActionToAnActionGroup(obj.ActionGroup);
            }
            else
            {
                obj.Current.Action.RemoveActionToAnActionGroup(obj.ActionGroup);
            }

            if (obj.SymmetryMode == UIActionGroupManager.SymmetryType.All)
            {
                foreach (BaseAction ba in BaseActionFilter.FromParts(obj.Current.Action.listParent.part.symmetryCounterparts))
                {
                    if (ba.name == obj.Current.Action.name)
                    {
                        if (!ba.IsInActionGroup(obj.ActionGroup))
                        {
                            ba.AddActionToAnActionGroup(obj.ActionGroup);
                        }
                        else
                        {
                            ba.RemoveActionToAnActionGroup(obj.ActionGroup);
                        }
                    }
                }
            }

            actionGroupList.Find(
                (e) =>
            {
                return(!e.IsSymmetrySelector && !e.Isfolder && e.Events[UIActionGroupManager.EVENTNAME].active);
            }).UpdateName();
        }
Ejemplo n.º 2
0
        private void Folder_Clicked(UIActionGroupManager obj)
        {
            if (IsActionGroupsVisible)
            {
                foreach (UIActionGroupManager item in actionGroupList)
                {
                    item.Events[UIActionGroupManager.EVENTNAME].guiActive = item.Isfolder;
                    item.Events[UIActionGroupManager.EVENTNAME].active    = item.Isfolder;
                }

                IsActionGroupsVisible = false;
                IsSymmetryModeVisible = false;

                currentFolder      = null;
                currentActionGroup = null;
            }
            else
            {
                int index, max;
                if (obj.Type == UIActionGroupManager.FolderType.General)
                {
                    index = 2;
                    max   = 9;
                }
                else
                {
                    index = 9;
                    max   = 19;
                }

                currentFolder = obj;

                actionGroupList[(obj.Type == UIActionGroupManager.FolderType.General) ? 1 : 0].Events[UIActionGroupManager.EVENTNAME].guiActive = false;
                actionGroupList[(obj.Type == UIActionGroupManager.FolderType.General) ? 1 : 0].Events[UIActionGroupManager.EVENTNAME].active    = false;

                for (; index < max; index++)
                {
                    actionGroupList[index].Events[UIActionGroupManager.EVENTNAME].guiActive = true;
                    actionGroupList[index].Events[UIActionGroupManager.EVENTNAME].active    = true;

                    actionGroupList[index].UpdateName();
                }

                IsActionGroupsVisible = true;
            }
        }
Ejemplo n.º 3
0
        private void ActionGroup_Clicked(UIActionGroupManager obj)
        {
            if (obj.Current.Action.listParent.part.symmetryCounterparts.Count > 0)
            {
                if (!IsSymmetryModeVisible)
                {
                    currentActionGroup = obj;

                    actionGroupList.ForEach(
                        (e) =>
                    {
                        // Hide all action groups
                        if (!e.Isfolder && !e.IsSymmetrySelector && e != obj)
                        {
                            e.Events[UIActionGroupManager.EVENTNAME].guiActive = false;
                            e.Events[UIActionGroupManager.EVENTNAME].active    = false;
                        }

                        // Show Symmetry selector
                        if (e.IsSymmetrySelector)
                        {
                            e.Events[UIActionGroupManager.EVENTNAME].guiActive = true;
                            e.Events[UIActionGroupManager.EVENTNAME].active    = true;

                            e.ActionGroup = obj.ActionGroup;
                        }
                    });

                    IsSymmetryModeVisible = true;
                }
                else
                {
                    actionGroupList.ForEach(
                        (e) =>
                    {
                        if (!e.Isfolder && !e.IsSymmetrySelector)
                        {
                            if (currentFolder.Type == UIActionGroupManager.FolderType.General)
                            {
                                e.Events[UIActionGroupManager.EVENTNAME].guiActive = !e.ActionGroup.ToString().Contains("Custom");
                                e.Events[UIActionGroupManager.EVENTNAME].active    = !e.ActionGroup.ToString().Contains("Custom");
                            }
                            else
                            {
                                e.Events[UIActionGroupManager.EVENTNAME].guiActive = e.ActionGroup.ToString().Contains("Custom");
                                e.Events[UIActionGroupManager.EVENTNAME].active    = e.ActionGroup.ToString().Contains("Custom");
                            }
                        }


                        if (e.IsSymmetrySelector)
                        {
                            e.Events[UIActionGroupManager.EVENTNAME].guiActive = false;
                            e.Events[UIActionGroupManager.EVENTNAME].active    = false;

                            e.ActionGroup = KSPActionGroup.None;
                        }
                    });

                    IsSymmetryModeVisible = false;
                    currentActionGroup    = null;
                }
            }
            else
            {
                if (!obj.Current.Action.IsInActionGroup(obj.ActionGroup))
                {
                    obj.Current.Action.AddActionToAnActionGroup(obj.ActionGroup);
                }
                else
                {
                    obj.Current.Action.RemoveActionToAnActionGroup(obj.ActionGroup);
                }

                obj.UpdateName();
            }
        }
Ejemplo n.º 4
0
        public UIPartManager(Part p)
        {
            this.Part             = p;
            IsActive              = false;
            IsFolderVisible       = false;
            IsActionGroupsVisible = false;
            IsSymmetryModeVisible = false;

            baseActionList  = new List <UIBaseActionManager>();
            actionGroupList = new List <UIActionGroupManager>();

            if (Part.Modules.Contains("UIBaseActionManager") || Part.Modules.Contains("UIActionGroupManager"))
            {
                //if the part already contains actionManager class, we clean them.

                List <PartModule> toRemove = new List <PartModule>();
                foreach (PartModule item in Part.Modules)
                {
                    if (item is UIBaseActionManager || item is UIActionGroupManager)
                    {
                        toRemove.Add(item);
                    }
                }

                foreach (PartModule mod in toRemove)
                {
                    Part.Modules.Remove(mod);
                }
            }


            //We create our base action list
            foreach (BaseAction ba in BaseActionFilter.FromParts(p))
            {
                //We create the module through AddModule to get the initialization done
                UIBaseActionManager man = Part.AddModule("UIBaseActionManager") as UIBaseActionManager;
                // and we remove it to avoid bloating an eventual save.
                Part.Modules.Remove(man);

                man.Action   = ba;
                man.Origin   = this;
                man.Clicked += BaseAction_Clicked;

                man.Initialize();

                baseActionList.Add(man);
            }

            // and our action group list
            //First two specific uiactionmanager as folder.
            UIActionGroupManager agm = Part.AddModule("UIActionGroupManager") as UIActionGroupManager;

            Part.Modules.Remove(agm);

            agm.Events[UIActionGroupManager.EVENTNAME].guiName = "    AGM : General";
            agm.Origin   = this;
            agm.Isfolder = true;
            agm.Type     = UIActionGroupManager.FolderType.General;
            agm.Clicked += Folder_Clicked;

            actionGroupList.Add(agm);

            agm = Part.AddModule("UIActionGroupManager") as UIActionGroupManager;
            Part.Modules.Remove(agm);

            agm.Events[UIActionGroupManager.EVENTNAME].guiName = "    AGM : Custom";
            agm.Origin   = this;
            agm.Isfolder = true;
            agm.Type     = UIActionGroupManager.FolderType.Custom;
            agm.Clicked += Folder_Clicked;

            actionGroupList.Add(agm);

            //and the rest of action groups
            foreach (KSPActionGroup ag in Enum.GetValues(typeof(KSPActionGroup)))
            {
                if (ag == KSPActionGroup.None)
                {
                    continue;
                }

                agm = Part.AddModule("UIActionGroupManager") as UIActionGroupManager;
                Part.Modules.Remove(agm);

                agm.Origin      = this;
                agm.ActionGroup = ag;
                agm.Clicked    += ActionGroup_Clicked;
                agm.Initialize();

                actionGroupList.Add(agm);
            }

            agm = Part.AddModule("UIActionGroupManager") as UIActionGroupManager;
            Part.Modules.Remove(agm);

            agm.Events[UIActionGroupManager.EVENTNAME].guiName = "        Only this part";
            agm.Origin             = this;
            agm.IsSymmetrySelector = true;
            agm.SymmetryMode       = UIActionGroupManager.SymmetryType.One;
            agm.Clicked           += SymmetryMode_Clicked;

            actionGroupList.Add(agm);

            agm = Part.AddModule("UIActionGroupManager") as UIActionGroupManager;
            Part.Modules.Remove(agm);

            agm.Events[UIActionGroupManager.EVENTNAME].guiName = "        This part and all symmetry counterparts";
            agm.Origin             = this;
            agm.IsSymmetrySelector = true;
            agm.SymmetryMode       = UIActionGroupManager.SymmetryType.All;
            agm.Clicked           += SymmetryMode_Clicked;

            actionGroupList.Add(agm);
        }
        private void SymmetryMode_Clicked(UIActionGroupManager obj)
        {
            if (!obj.Current.Action.IsInActionGroup(obj.ActionGroup))
                obj.Current.Action.AddActionToAnActionGroup(obj.ActionGroup);
            else
                obj.Current.Action.RemoveActionToAnActionGroup(obj.ActionGroup);

            if (obj.SymmetryMode == UIActionGroupManager.SymmetryType.All)
            {
                foreach (BaseAction ba in BaseActionFilter.FromParts(obj.Current.Action.listParent.part.symmetryCounterparts))
                {
                    if (ba.name == obj.Current.Action.name)
                    {
                        if (!ba.IsInActionGroup(obj.ActionGroup))
                            ba.AddActionToAnActionGroup(obj.ActionGroup);
                        else
                            ba.RemoveActionToAnActionGroup(obj.ActionGroup);

                    }
                }
            }

            actionGroupList.Find(
                (e) =>
                {
                    return !e.IsSymmetrySelector && !e.Isfolder && e.Events[UIActionGroupManager.EVENTNAME].active;
                }).UpdateName();
        }
        private void Folder_Clicked(UIActionGroupManager obj)
        {
            if (IsActionGroupsVisible)
            {
                foreach (UIActionGroupManager item in actionGroupList)
                {
                    item.Events[UIActionGroupManager.EVENTNAME].guiActive = item.Isfolder;
                    item.Events[UIActionGroupManager.EVENTNAME].active = item.Isfolder;
                }

                IsActionGroupsVisible = false;
                IsSymmetryModeVisible = false;

                currentFolder = null;
                currentActionGroup = null;
            }
            else
            {
                int index, max;
                if (obj.Type == UIActionGroupManager.FolderType.General)
                {
                    index = 2;
                    max = 9;
                }
                else
                {
                    index = 9;
                    max = 19;
                }

                currentFolder = obj;

                actionGroupList[(obj.Type == UIActionGroupManager.FolderType.General) ? 1 : 0].Events[UIActionGroupManager.EVENTNAME].guiActive = false;
                actionGroupList[(obj.Type == UIActionGroupManager.FolderType.General) ? 1 : 0].Events[UIActionGroupManager.EVENTNAME].active = false;

                for (; index < max; index++)
                {
                    actionGroupList[index].Events[UIActionGroupManager.EVENTNAME].guiActive = true;
                    actionGroupList[index].Events[UIActionGroupManager.EVENTNAME].active = true;

                    actionGroupList[index].UpdateName();
                }

                IsActionGroupsVisible = true;
            }
        }
        private void ActionGroup_Clicked(UIActionGroupManager obj)
        {
            if (obj.Current.Action.listParent.part.symmetryCounterparts.Count > 0)
            {
                if (!IsSymmetryModeVisible)
                {
                    currentActionGroup = obj;

                    actionGroupList.ForEach(
                        (e) =>
                        {
                            // Hide all action groups
                            if (!e.Isfolder && !e.IsSymmetrySelector && e != obj)
                            {
                                e.Events[UIActionGroupManager.EVENTNAME].guiActive = false;
                                e.Events[UIActionGroupManager.EVENTNAME].active = false;
                            }

                            // Show Symmetry selector
                            if (e.IsSymmetrySelector)
                            {
                                e.Events[UIActionGroupManager.EVENTNAME].guiActive = true;
                                e.Events[UIActionGroupManager.EVENTNAME].active = true;

                                e.ActionGroup = obj.ActionGroup;
                            }
                        });

                    IsSymmetryModeVisible = true;
                }
                else
                {

                    actionGroupList.ForEach(
                        (e) =>
                        {
                            if (!e.Isfolder && !e.IsSymmetrySelector)
                            {
                                if (currentFolder.Type == UIActionGroupManager.FolderType.General)
                                {
                                    e.Events[UIActionGroupManager.EVENTNAME].guiActive = !e.ActionGroup.ToString().Contains("Custom");
                                    e.Events[UIActionGroupManager.EVENTNAME].active = !e.ActionGroup.ToString().Contains("Custom");
                                }
                                else
                                {
                                    e.Events[UIActionGroupManager.EVENTNAME].guiActive = e.ActionGroup.ToString().Contains("Custom");
                                    e.Events[UIActionGroupManager.EVENTNAME].active = e.ActionGroup.ToString().Contains("Custom");
                                }
                            }

                            if (e.IsSymmetrySelector)
                            {
                                e.Events[UIActionGroupManager.EVENTNAME].guiActive = false;
                                e.Events[UIActionGroupManager.EVENTNAME].active = false;

                                e.ActionGroup = KSPActionGroup.None;
                            }
                        });

                    IsSymmetryModeVisible = false;
                    currentActionGroup = null;
                }
            }
            else
            {
                if (!obj.Current.Action.IsInActionGroup(obj.ActionGroup))
                    obj.Current.Action.AddActionToAnActionGroup(obj.ActionGroup);
                else
                    obj.Current.Action.RemoveActionToAnActionGroup(obj.ActionGroup);

                obj.UpdateName();
            }
        }