public void Initialize()
        {
            Players.Clear();

            PlayerBrowsingGeneralMenu = null;

            foreach (var panel in Panels.Values)
                panel.Visible = false;

            GeneralMenu.Initialize();

            CelestialBodiesPathPreviews.CelestialBodies = CelestialBodies;
            CelestialBodiesPathPreviews.Initialize();
        }
        public void DoPlayerConnected(EditorPlayer p)
        {
            EditorGUIPlayer player = new EditorGUIPlayer(Simulator, p.Color);

            player.GeneralMenu = GeneralMenu;

            Players.Add(p, player);
        }
        public void DoPlayerChanged(EditorPlayer p)
        {
            var player = Players[p];

            // Change general menu
            if (PlayerBrowsingGeneralMenu == null || (player == PlayerBrowsingGeneralMenu &&
                player.SelectedGeneralMenu != p.ActualSelection.GeneralMenuChoice))
            {
                if (PlayerBrowsingGeneralMenu == null)
                    PlayerBrowsingGeneralMenu = player;

                if (player == PlayerBrowsingGeneralMenu)
                    GeneralMenu.DoMenuChanged(player.SelectedGeneralMenu, p.ActualSelection.GeneralMenuChoice, p.Color);

                if (player == PlayerBrowsingGeneralMenu && p.ActualSelection.GeneralMenuChoice == EditorGeneralMenuChoice.None)
                    PlayerBrowsingGeneralMenu = null;
            }

            // update actual selection
            player.SelectedGeneralMenu = p.ActualSelection.GeneralMenuChoice;
            player.GeneralMenuSubMenuIndex = p.ActualSelection.GeneralMenuSubMenuIndex;
            player.CelestialBodyMenu.Menu.SelectedIndex = p.ActualSelection.CelestialBodyChoice;

            if (p.SimPlayer.ActualSelection.TurretToPlace != null)
                return;

            // synchronize celestial body menu
            if (p.SimPlayer.ActualSelection.CelestialBody != null && player.CelestialBodyMenu.CelestialBody != p.SimPlayer.ActualSelection.CelestialBody)
            {
                player.CelestialBodyMenu.CelestialBody = p.SimPlayer.ActualSelection.CelestialBody;
                player.CelestialBodyMenu.SyncData();
                player.CelestialBodyMenu.Visible = true;
            }

            else if (p.SimPlayer.ActualSelection.CelestialBody == null)
            {
                player.CelestialBodyMenu.CelestialBody = null;
                player.CelestialBodyMenu.Visible = false;
            }

            player.CelestialBodyMenu.Visible = p.SimPlayer.ActualSelection.EditingState == EditorEditingState.None;
        }