Exemplo n.º 1
0
        void OnContextMenu_ItemClicked(MyGuiControlContextMenu sender, MyGuiControlContextMenu.EventArgs eventArgs)
        {
            var actionItem = (ContextMenuFavoriteActionItem)eventArgs.UserData;
            var server     = actionItem.Server;

            if (server != null)
            {
                switch (actionItem._Action)
                {
                case ContextMenuFavoriteAction.Add:
                    UInt32 unixTimestamp = (UInt32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                    SteamAPI.Instance.AddFavoriteGame(server.AppID, System.Net.IPAddressExtensions.ToIPv4NetworkOrder(server.NetAdr.Address), (UInt16)server.NetAdr.Port, (UInt16)server.NetAdr.Port, FavoriteEnum.Favorite, unixTimestamp);
                    break;

                case ContextMenuFavoriteAction.Remove:
                    SteamAPI.Instance.RemoveFavoriteGame(server.AppID, System.Net.IPAddressExtensions.ToIPv4NetworkOrder(server.NetAdr.Address), (UInt16)server.NetAdr.Port, (UInt16)server.NetAdr.Port, FavoriteEnum.Favorite);

                    m_gamesTable.RemoveSelectedRow();
                    m_favoritesPage.Text = new StringBuilder().Append(MyTexts.Get(MyCommonTexts.JoinGame_TabTitle_Favorites).ToString()).Append(" (").Append(m_gamesTable.RowsCount).Append(")");
                    break;

                default:
                    throw new InvalidBranchException();
                    break;
                }
            }
        }
        private void RecreateControls(bool contructor)
        {
            m_toolbarItemsGrid = new MyGuiControlGrid()
            {
                OriginAlign  = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
                VisualStyle  = MyGuiControlGridStyleEnum.Toolbar,
                ColumnsCount = MyToolbarComponent.CurrentToolbar.SlotCount + 1,
                RowsCount    = 1
            };
            m_toolbarItemsGrid.ItemDoubleClicked             += grid_ItemDoubleClicked;
            m_toolbarItemsGrid.ItemClickedWithoutDoubleClick += grid_ItemClicked;

            m_selectedItemLabel = new MyGuiControlLabel();
            m_colorVariantPanel = new MyGuiControlPanel(size: new Vector2(0.1f, 0.025f));
            m_colorVariantPanel.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;

            m_contextMenu             = new MyGuiControlContextMenu();
            m_contextMenu.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            m_contextMenu.Deactivate();
            m_contextMenu.ItemClicked += contextMenu_ItemClicked;

            Elements.Add(m_colorVariantPanel);
            Elements.Add(m_selectedItemLabel);
            Elements.Add(m_toolbarItemsGrid);
            Elements.Add(m_contextMenu);

            m_colorVariantPanel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_selectedItemLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_toolbarItemsGrid.OriginAlign  = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_contextMenu.OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;

            RefreshInternals();
        }
Exemplo n.º 3
0
        public override void RecreateControls(bool constructor)
        {
            //This is probably very wrong!
            m_screenScale = (MyGuiManager.GetHudSize().X / MyGuiManager.GetHudSize().Y) / MyGuiConstants.SAFE_ASPECT_RATIO;

            m_size = new Vector2(m_screenScale, 0.5f);

            base.RecreateControls(constructor);
            Vector4 consoleTextColor = new Vector4(1, 1, 0, 1);
            float   consoleTextScale = 1f;

            m_commandLine = new MyGuiControlTextbox
                            (
                position: new Vector2(0, 0.25f),
                textColor: consoleTextColor
                            );

            m_commandLine.Position    -= new Vector2(0, m_commandLine.Size.Y + m_margin.Y / 2);
            m_commandLine.Size         = new Vector2(m_screenScale, m_commandLine.Size.Y) - 2 * m_margin;
            m_commandLine.ColorMask    = new Vector4(0, 0, 0, 0.5f);
            m_commandLine.VisualStyle  = MyGuiControlTextboxStyleEnum.Debug;
            m_commandLine.TextChanged += commandLine_TextChanged;
            m_commandLine.Name         = "CommandLine";


            m_autoComplete              = new MyGuiControlContextMenu();
            m_autoComplete.ItemClicked += autoComplete_ItemClicked;
            m_autoComplete.Deactivate();
            m_autoComplete.OriginAlign             = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_autoComplete.ColorMask               = new Vector4(0, 0, 0, .5f);
            m_autoComplete.AllowKeyboardNavigation = true;
            m_autoComplete.Name = "AutoComplete";

            m_displayScreen = new MyGuiControlMultilineText
                              (
                position: new Vector2(-0.5f * m_screenScale, -0.25f) + m_margin,
                size: new Vector2(m_screenScale, 0.5f - m_commandLine.Size.Y) - 2 * m_margin,
                font: Common.MyFontEnum.Debug,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                selectable: true
                              );

            m_displayScreen.TextColor   = Color.Yellow;
            m_displayScreen.TextScale   = consoleTextScale;
            m_displayScreen.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_displayScreen.Text        = MyConsole.DisplayScreen;
            m_displayScreen.ColorMask   = new Vector4(0, 0, 0, .5f);
            m_displayScreen.Name        = "DisplayScreen";

            Controls.Add(m_displayScreen);
            Controls.Add(m_commandLine);
            Controls.Add(m_autoComplete);
        }
Exemplo n.º 4
0
        private void RecreateControls(bool contructor)
        {
            m_toolbarItemsGrid = new MyGuiControlGrid()
            {
                OriginAlign  = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
                VisualStyle  = MyGuiControlGridStyleEnum.Toolbar,
                ColumnsCount = MyToolbarComponent.CurrentToolbar.SlotCount + 1,
                RowsCount    = 1
            };
            m_toolbarItemsGrid.ItemDoubleClicked             += grid_ItemDoubleClicked;
            m_toolbarItemsGrid.ItemClickedWithoutDoubleClick += grid_ItemClicked;

            m_selectedItemLabel = new MyGuiControlLabel();
            m_colorVariantPanel = new MyGuiControlPanel(size: new Vector2(0.1f, 0.025f));
            m_colorVariantPanel.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;

            //grid size image (left from toolbar)
            m_gridSize             = new MyGuiControlImage(size: m_toolbarItemsGrid.ItemSize * 0.6f);
            m_gridSize.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_gridSize.SetTexture(MyGuiConstants.TEXTURE_ICON_LARGE_BLOCK);
            m_gridSize.Visible           = false;
            m_gridSize.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
            Elements.Add(m_gridSize);

            //grid size label (above grid size image)
            m_gridSizeLabel                   = new MyGuiControlLabel();
            m_gridSizeLabel.Text              = "";
            m_gridSizeLabel.Visible           = false;
            m_gridSizeLabel.Size              = new Vector2(m_toolbarItemsGrid.ItemSize.X * 3f, m_toolbarItemsGrid.ItemSize.Y / 2f);
            m_gridSizeLabel.OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_gridSizeLabel.BackgroundTexture = null;
            m_gridSizeLabel.TextScale         = 0.75f;
            Elements.Add(m_gridSizeLabel);

            m_contextMenu             = new MyGuiControlContextMenu();
            m_contextMenu.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            m_contextMenu.Deactivate();
            m_contextMenu.ItemClicked += contextMenu_ItemClicked;

            Elements.Add(m_colorVariantPanel);
            Elements.Add(m_selectedItemLabel);
            Elements.Add(m_toolbarItemsGrid);
            Elements.Add(m_contextMenu);

            m_colorVariantPanel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_selectedItemLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_toolbarItemsGrid.OriginAlign  = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_contextMenu.OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;

            RefreshInternals();
        }
Exemplo n.º 5
0
 public override bool OpenContextMenu(MyGuiControlContextMenu menu)
 {
     menu.Clear();
     menu.AddItem(new StringBuilder("Remove"));
     menu.AddItem(new StringBuilder("Load data file"));
     if (FolderSettings.DebugBuild)
     {
         menu.AddItem(new StringBuilder("Switch to release build"));
     }
     else
     {
         menu.AddItem(new StringBuilder("Switch to debug build"));
     }
     return(true);
 }
Exemplo n.º 6
0
        private void contextMenu_ItemClicked(MyGuiControlContextMenu sender, MyGuiControlContextMenu.EventArgs args)
        {
            int idx     = args.ItemIndex;
            var toolbar = MyToolbarComponent.CurrentToolbar;

            Debug.Assert(toolbar != null);
            if (toolbar == null)
            {
                return;
            }

            int slot = toolbar.IndexToSlot(m_contextMenuItemIndex);

            if (toolbar.IsValidSlot(slot))
            {
                var item = toolbar.GetSlotItem(slot);
                Debug.Assert(item is MyToolbarItemActions);
                var actionsItem = item as MyToolbarItemActions;
                if (item != null)
                {
                    //"Remove from toolbar" index (usually the last one)
                    if (idx < 0 || idx >= actionsItem.PossibleActions(ShownToolbar.ToolbarType).Count)
                    {
                        RemoveToolbarItem(slot);
                    }
                    else
                    {
                        //First updates the action
                        actionsItem.ActionId = (string)args.UserData;

                        //Removes all items equal to the one you're adding
                        for (int i = 0; i < MyToolbarComponent.CurrentToolbar.SlotCount; ++i)
                        {
                            var cur = toolbar.GetSlotItem(i);
                            if (cur != null && cur.Equals(actionsItem))
                            {
                                MyToolbarComponent.CurrentToolbar.SetItemAtSlot(i, null);
                            }
                        }

                        //And then put it to the slot
                        MyToolbarComponent.CurrentToolbar.SetItemAtSlot(slot, actionsItem);
                    }
                }
            }

            m_contextMenuItemIndex = -1;
        }
Exemplo n.º 7
0
 public void autoComplete_ItemClicked(MyGuiControlContextMenu sender, MyGuiControlContextMenu.EventArgs args)
 {
     m_commandLine.Text += (string)m_autoComplete.Items[args.ItemIndex].UserData;
     m_commandLine.MoveCarriageToEnd();
     FocusedControl = m_commandLine;
 }
Exemplo n.º 8
0
 public virtual bool OpenContextMenu(MyGuiControlContextMenu menu)
 {
     return(false);
 }
Exemplo n.º 9
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);
        }