Exemple #1
0
        internal void Close()
        {
            if (m_grid == null)
            {
                return;
            }
            if (m_infoPage == null)
            {
                return;
            }

            var convertBtn = (MyGuiControlButton)m_infoPage.Controls.GetControlByName("ConvertBtn");

            if (convertBtn != null)
            {
                convertBtn.ButtonClicked -= convertBtn_ButtonClicked;
            }

            m_grid.OnBlockAdded            -= grid_OnBlockAdded;
            m_grid.OnBlockRemoved          -= grid_OnBlockRemoved;
            m_grid.OnPhysicsChanged        -= grid_OnPhysicsChanged;
            m_grid.OnBlockOwnershipChanged -= grid_OnBlockOwnershipChanged;

            m_grid     = null;
            m_infoPage = null;
        }
Exemple #2
0
        internal void Init(Graphics.GUI.MyGuiControlTabPage infoPage, MyCubeGrid grid)
        {
            m_grid     = grid;
            m_infoPage = infoPage;
            Debug.Assert(m_infoPage != null);

            RecreateControls();

            if (grid == null)
            {
                return;
            }
            grid.OnBlockAdded            += grid_OnBlockAdded;
            grid.OnBlockRemoved          += grid_OnBlockRemoved;
            grid.OnPhysicsChanged        += grid_OnPhysicsChanged;
            grid.OnBlockOwnershipChanged += grid_OnBlockOwnershipChanged;

            if (MyFakes.ENABLE_TERMINAL_PROPERTIES)
            {
                var renameShipBtn = (MyGuiControlButton)m_infoPage.Controls.GetControlByName("RenameShipButton");
                if (renameShipBtn != null)
                {
                    renameShipBtn.ButtonClicked += renameBtn_ButtonClicked;
                }
            }

            var convertBtn = (MyGuiControlButton)m_infoPage.Controls.GetControlByName("ConvertBtn");

            if (convertBtn != null)
            {
                convertBtn.ButtonClicked += convertBtn_ButtonClicked;
            }
        }
Exemple #3
0
        void InitLobbyPage()
        {
            InitLobbyTable();

            m_joinButton.ButtonClicked    += OnJoinLobby;
            m_refreshButton.ButtonClicked += OnRefreshLobbiesClick;
            m_showOnlyCompatibleGames.IsCheckedChanged = OnShowCompatibleCheckChanged;
            m_showOnlyWithSameMods.IsCheckedChanged    = OnShowCompatibleCheckChanged;
            m_showOnlyFriends.IsCheckedChanged        += OnShowOnlyFriendsCheckChanged;

            m_searchChangedFunc += LoadPublicLobbies;

            m_lobbyPage = m_selectedPage;
            m_lobbyPage.SetToolTip(MyTexts.GetString(MySpaceTexts.JoinGame_TabTooltip_Lobbies));

            LoadPublicLobbies();
        }
        void InitFavoritesPage()
        {
            InitServersTable();

            m_joinButton.ButtonClicked    += OnJoinServer;
            m_refreshButton.ButtonClicked += OnRefreshFavoritesServersClick;
            m_showOnlyCompatibleGames.IsCheckedChanged = OnFavoritesCheckboxCheckChanged;
            m_showOnlyWithSameMods.IsCheckedChanged    = OnFavoritesCheckboxCheckChanged;
            m_allowedGroups.IsCheckedChanged           = OnFavoritesCheckboxCheckChanged;

            m_searchChangedFunc += RefreshFavoritesGameList;

            m_favoritesPage = m_selectedPage;
            m_favoritesPage.SetToolTip(MyTexts.GetString(MySpaceTexts.JoinGame_TabTooltip_Favorites));


            RefreshFavoritesGameList();
        }
Exemple #5
0
        void InitLANPage()
        {
            InitServersTable();

            m_joinButton.ButtonClicked    += OnJoinServer;
            m_refreshButton.ButtonClicked += OnRefreshLANServersClick;
            m_showOnlyCompatibleGames.IsCheckedChanged = OnLANCheckboxCheckChanged;
            m_showOnlyWithSameMods.IsCheckedChanged    = OnLANCheckboxCheckChanged;
            m_allowedGroups.IsCheckedChanged           = OnLANCheckboxCheckChanged;

            m_searchChangedFunc += RefreshLANGameList;

            m_LANPage = m_selectedPage;
            m_LANPage.SetToolTip(MyTexts.GetString(MyCommonTexts.JoinGame_TabTooltip_LAN));


            RefreshLANGameList();
        }
Exemple #6
0
        void InitPageControls(MyGuiControlTabPage page)
        {
            page.Controls.Clear();

            var     origin     = new Vector2(-0.64f, -0.35f);
            Vector2 buttonSize = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui;

            m_gamesTable                  = new MyGuiControlTable();
            m_gamesTable.Position         = origin + new Vector2(buttonSize.X, 0f);
            m_gamesTable.Size             = new Vector2(1465f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, 1f);
            m_gamesTable.OriginAlign      = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_gamesTable.VisibleRowsCount = 16;
            page.Controls.Add(m_gamesTable);


            Vector2 buttonOrigin = origin + new Vector2(0.28f, 0.66f);
            Vector2 buttonDelta  = new Vector2(0.2f, 0.0f);

            int numControls = 0;

            page.Controls.Add(m_joinButton    = MakeButton(buttonOrigin + buttonDelta * numControls++, MyCommonTexts.ScreenMenuButtonJoinWorld, MyCommonTexts.ScreenMenuButtonJoinWorld, null));
            page.Controls.Add(m_refreshButton = MakeButton(buttonOrigin + buttonDelta * numControls++, MyCommonTexts.ScreenLoadSubscribedWorldRefresh, MyCommonTexts.ScreenLoadSubscribedWorldRefresh, null));
            m_joinButton.Enabled = false;

            var checkboxPos   = buttonOrigin + new Vector2(-0.09f, -0.02f) + numControls * buttonDelta;
            var checkBoxDelta = new Vector2(0.0f, 0.04f);

            var blockSearchLabel = new MyGuiControlLabel()
            {
                Position = checkboxPos + new Vector2(0f, -0.04f),
                Size     = new Vector2(0.05f, 0.02f),
                TextEnum = MyCommonTexts.JoinGame_SearchLabel
            };

            page.Controls.Add(blockSearchLabel);

            m_blockSearch = new MyGuiControlTextbox()
            {
                Position = blockSearchLabel.Position + new Vector2(0.255f, 0f),
                Size     = new Vector2(0.27f, 0.02f)
            };
            m_blockSearch.SetToolTip(MyCommonTexts.JoinGame_SearchTooltip);
            m_blockSearch.TextChanged += OnBlockSearchTextChanged;
            page.Controls.Add(m_blockSearch);

            m_blockSearchClear = new MyGuiControlButton()
            {
                Position               = m_blockSearch.Position + new Vector2(0.13f, 0f),
                OriginAlign            = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER,
                VisualStyle            = MyGuiControlButtonStyleEnum.Close,
                ActivateOnMouseRelease = true
            };
            m_blockSearchClear.ButtonClicked += BlockSearchClear_ButtonClicked;
            page.Controls.Add(m_blockSearchClear);

            numControls = 0;

            m_showOnlyCompatibleText = new MyGuiControlButton(
                position: checkboxPos + checkBoxDelta * numControls + new Vector2(buttonSize.Y * 0.5f, 0),
                text: MyTexts.Get(MyCommonTexts.MultiplayerCompatibleVersions),
                toolTip: MyTexts.GetString(MyCommonTexts.MultiplayerCompatibleVersions),
                onButtonClick: OnShowOnlyCompatibleTextClick,
                visualStyle: MyGuiControlButtonStyleEnum.ClickableText,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            page.Controls.Add(m_showOnlyCompatibleText);
            bool compatibleChecked = true;

            if (m_showOnlyCompatibleGames != null)
            {
                compatibleChecked = m_showOnlyCompatibleGames.IsChecked;
            }
            m_showOnlyCompatibleGames           = new MyGuiControlCheckbox(checkboxPos + checkBoxDelta * numControls++, null, null, MySandboxGame.Config.MultiplayerShowCompatible, MyGuiControlCheckboxStyleEnum.Debug, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_showOnlyCompatibleGames.IsChecked = compatibleChecked;
            page.Controls.Add(m_showOnlyCompatibleGames);

            bool showSameMods = true;

            if (m_showOnlyWithSameMods != null)
            {
                showSameMods = m_showOnlyWithSameMods.IsChecked;
            }
            m_showOnlyWithSameMods = new MyGuiControlCheckbox(
                position: checkboxPos + checkBoxDelta * numControls,
                visualStyle: MyGuiControlCheckboxStyleEnum.Debug,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_showOnlyWithSameMods.IsChecked = showSameMods;
            page.Controls.Add(m_showOnlyWithSameMods);

            m_showOnlyWithSameText = new MyGuiControlButton(
                position: checkboxPos + checkBoxDelta * numControls + new Vector2(buttonSize.Y * 0.5f, 0),
                text: MyTexts.Get(MyCommonTexts.MultiplayerJoinSameGameData),
                toolTip: MyTexts.GetString(MyCommonTexts.MultiplayerJoinSameGameData),
                onButtonClick: OnShowOnlySameModsClick,
                visualStyle: MyGuiControlButtonStyleEnum.ClickableText,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            page.Controls.Add(m_showOnlyWithSameText);

            checkboxPos = buttonOrigin + new Vector2(-0.09f, -0.02f) + 3 * buttonDelta;
            numControls = 0;

            bool showOnlyFriends = false;

            if (m_showOnlyFriends != null)
            {
                showOnlyFriends = m_showOnlyFriends.IsChecked;
            }
            m_showOnlyFriends = new MyGuiControlCheckbox(
                position: checkboxPos + checkBoxDelta * numControls + new Vector2(buttonSize.Y * 0.5f, 0),
                visualStyle: MyGuiControlCheckboxStyleEnum.Debug,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_showOnlyFriends.IsChecked = showOnlyFriends;
            page.Controls.Add(m_showOnlyFriends);

            m_showOnlyFriendsText = new MyGuiControlButton(
                position: checkboxPos + checkBoxDelta * numControls++ + new Vector2(buttonSize.Y, 0),
                text: MyTexts.Get(MyCommonTexts.MultiplayerJoinFriendsGames),
                toolTip: MyTexts.GetString(MyCommonTexts.MultiplayerJoinFriendsGames),
                onButtonClick: OnFriendsOnlyTextClick,
                visualStyle: MyGuiControlButtonStyleEnum.ClickableText,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            page.Controls.Add(m_showOnlyFriendsText);

            bool allowedGroups = true;

            if (m_allowedGroups != null)
            {
                allowedGroups = m_allowedGroups.IsChecked;
            }
            m_allowedGroups = new MyGuiControlCheckbox(
                position: checkboxPos + checkBoxDelta * numControls + new Vector2(buttonSize.Y * 0.5f, 0),
                visualStyle: MyGuiControlCheckboxStyleEnum.Debug,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_allowedGroups.IsChecked = allowedGroups;
            page.Controls.Add(m_allowedGroups);

            m_allowedGroupsText = new MyGuiControlButton(
                position: checkboxPos + checkBoxDelta * numControls++ + new Vector2(buttonSize.Y, 0),
                text: MyTexts.Get(MyCommonTexts.MultiplayerJoinAllowedGroups),
                toolTip: MyTexts.GetString(MyCommonTexts.MultiplayerJoinAllowedGroups),
                onButtonClick: OnAllowedGroupsTextClick,
                visualStyle: MyGuiControlButtonStyleEnum.ClickableText,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            page.Controls.Add(m_allowedGroupsText);
        }
Exemple #7
0
        void joinGameTabs_OnPageChanged()
        {
            var serversPage   = (MyGuiControlTabPage)m_joinGameTabs.Controls.GetControlByName("PageServersPanel");
            var lobbiesPage   = (MyGuiControlTabPage)m_joinGameTabs.Controls.GetControlByName("PageLobbiesPanel");
            var favoritesPage = (MyGuiControlTabPage)m_joinGameTabs.Controls.GetControlByName("PageFavoritesPanel");
            var historyPage   = (MyGuiControlTabPage)m_joinGameTabs.Controls.GetControlByName("PageHistoryPanel");
            var LANPage       = (MyGuiControlTabPage)m_joinGameTabs.Controls.GetControlByName("PageLANPanel");
            var friendsPage   = (MyGuiControlTabPage)m_joinGameTabs.Controls.GetControlByName("PageFriendsPanel");

            if (m_selectedPage == serversPage)
            {
                CloseServersPage();
            }
            else if (m_selectedPage == lobbiesPage)
            {
                CloseLobbyPage();
            }
            else if (m_selectedPage == favoritesPage)
            {
                CloseFavoritesPage();
            }
            else if (m_selectedPage == LANPage)
            {
                CloseLANPage();
            }
            else if (m_selectedPage == historyPage)
            {
                CloseHistoryPage();
            }
            else if (m_selectedPage == friendsPage)
            {
                CloseFriendsPage();
            }

            m_selectedPage = m_joinGameTabs.GetTabSubControl(m_joinGameTabs.SelectedPage);

            InitPageControls(m_selectedPage);
            if (m_selectedPage == serversPage)
            {
                InitServersPage();
                m_showOnlyFriends.Enabled     = false;
                m_showOnlyFriendsText.Enabled = false;
            }
            else if (m_selectedPage == lobbiesPage)
            {
                InitLobbyPage();
                m_showOnlyFriends.Enabled     = true;
                m_showOnlyFriendsText.Enabled = true;
            }
            else if (m_selectedPage == favoritesPage)
            {
                InitFavoritesPage();
                m_showOnlyFriends.Enabled     = false;
                m_showOnlyFriendsText.Enabled = false;
            }
            else if (m_selectedPage == historyPage)
            {
                InitHistoryPage();
                m_showOnlyFriends.Enabled     = false;
                m_showOnlyFriendsText.Enabled = false;
            }
            else if (m_selectedPage == LANPage)
            {
                InitLANPage();
                m_showOnlyFriends.Enabled     = false;
                m_showOnlyFriendsText.Enabled = false;
            }
            else if (m_selectedPage == friendsPage)
            {
                InitFriendsPage();
                m_showOnlyFriends.Enabled     = false;
                m_showOnlyFriendsText.Enabled = false;
            }

            if (m_contextMenu != null)
            {
                m_contextMenu.Deactivate();
                m_contextMenu = null;
            }

            m_contextMenu             = new MyGuiControlContextMenu();
            m_contextMenu.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            m_contextMenu.Deactivate();
            m_contextMenu.ItemClicked += OnContextMenu_ItemClicked;
            Controls.Add(m_contextMenu);
        }
 public static TType TabControlByName <TType>(this MyGuiControlTabPage tab, string name)
     where TType : MyGuiControlBase
 {
     return((TType)tab.Controls.GetControlByName(name));
 }