Beispiel #1
0
        /// <summary>
        /// Add a submenu to this dropdown menu
        /// </summary>
        /// <param name="submenu">Submenu to add</param>
        /// <param name="title">Button title</param>
        public void AddSubMenu(GI_DropdownSubmenu submenu, string title)
        {
            int width = _gameInterface.DropdownButtonWidth;
            int height = _gameInterface.DropdownButtonHeight;
            int x = _objs.Count * width;
            int y = Top;

            GI_DropdownButton button = new GI_DropdownButton(_gameInterface, _texture, width, height, x, y, title);
            _objs.Add(button);

            submenu.Visible = false;

            button.Clicked += delegate()
            {
                if (submenu.Visible)
                    submenu.Close();
                else
                {
                    if (_openSubmenu != null)
                        _openSubmenu.Close();

                    submenu.Open();
                    _openSubmenu = submenu;
                }
            };

            submenu.Position = new Vector2(
                button.Left,
                Bottom);
        }
Beispiel #2
0
        public override bool Update(GameTime gameTime)
        {
            // Only update if base updates
            if (base.Update(gameTime))
            {
                // If we click outside the menu, close any menu that may be open
                if (Controller.GetOneLeftClickDown() && !_hovering)
                    if (_openSubmenu != null)
                    {
                        _openSubmenu.Close();
                        _openSubmenu = null;
                    }

                // This updated, so return true
                return true;
            }

            // This did not update, so return false
            return false;
        }
Beispiel #3
0
 /// <summary>
 /// Common constructor code
 /// All constructors should call this method
 /// </summary>
 private void Construct()
 {
     _openSubmenu = null;
 }
        private void LoadInterface(Texture2D texture)
        {
            GI_DropdownMenu mainmenu = new GI_DropdownMenu(this, texture);
            _objs.Add(mainmenu);

            // ---------- File submenu ----------
            GI_DropdownSubmenu file = new GI_DropdownSubmenu(this, texture);
            _objs.Add(file);

            file.AddButton(() => { Console.WriteLine("New level placeholder button"); }, "New");
            file.AddButton(() => { _screen.GameLevel.SaveLevel("poopies"); }, "Save");
            file.AddButton(() => { Console.WriteLine("save as button"); }, "Save As");
            file.AddButton(() => { Console.WriteLine("Open file placeholder button"); }, "Open");

            mainmenu.AddSubMenu(file, "File");

            // ---------- Tools submenu ----------
            GI_DropdownSubmenu tools = new GI_DropdownSubmenu(this, texture);
            _objs.Add(tools);

            tools.AddButton(() => { _screen.GameLevel.MainLayer.TileSystem.CurrentTool = TileSystem.Tool.elevate; }, "Elevate");
            tools.AddButton(() => { _screen.GameLevel.MainLayer.TileSystem.CurrentTool = TileSystem.Tool.smooth; }, "Smooth");
            tools.AddButton(() => { _screen.GameLevel.MainLayer.TileSystem.CurrentTool = TileSystem.Tool.zeroelevation; }, "Zero Elevation");

            mainmenu.AddSubMenu(tools, "Tools");

            // ========== WINDOWS SUBMENU START ==========
            GI_DropdownSubmenu windows = new GI_DropdownSubmenu(this, texture);
            _objs.Add(windows);

            // ----- Content Browser -----
            GI_Window contentBrowser = new GI_Window(this, texture, _initialWindowWidth, _initialWindowHeight, 200, 200, "Content Browser");
            windows.AddButtonForObj(contentBrowser, "Content Browser");
            _objs.Add(contentBrowser);

            contentBrowser.MainCell.Split(true, 0.6f);
            contentBrowser.MainCell.Child2.Split(false, 0.7f);

            GI_WindowCell contentCell   = contentBrowser.MainCell.Child1;
            GI_WindowCell infoCell      = contentBrowser.MainCell.Child2.Child1;
            GI_WindowCell fileCell      = contentBrowser.MainCell.Child2.Child2;

            // Info cell
            Vector2 selectorSize = new Vector2(100, 140);
            Vector2 selectorPosition;
            selectorPosition.X = (infoCell.Left + (infoCell.Width / 2)) - (selectorSize.X / 2);
            selectorPosition.Y = infoCell.Top + 10;
            GI_WindowCellObj selectionIndicator = new GI_WindowCellObj(this, texture, (int)selectorSize.X, (int)selectorSize.Y, (int)selectorPosition.X, (int)selectorPosition.Y, infoCell);

            Vector2 textFieldSize = new Vector2(120, 16);
            GI_TextField textfieldRefernceID = new GI_TextField(this, texture, (int)textFieldSize.X, (int)textFieldSize.Y, infoCell.Left + (infoCell.Width / 2), infoCell.Bottom - 100, infoCell, "Reference ID:");
            GI_TextField textfieldTextureName = new GI_TextField(this, texture, (int)textFieldSize.X, (int)textFieldSize.Y, infoCell.Left + (infoCell.Width / 2), textfieldRefernceID.Bottom + 10, infoCell, "Texture Name:");

            // Content cell
            Dictionary<short, CL_ObjType> content = _screen.ContentLib.GetLoadedFile("tiletypes");
            int i = 0;
            foreach (KeyValuePair<short, CL_ObjType> element in content)
            {
                CL_ObjType tile = new CL_ObjType(element.Value.ReferenceID, element.Value.Texture);
                GI_ContentButton button = new GI_ContentButton(this, 50, 70, contentCell.Left + (i * 60), contentCell.Top, tile);
                contentCell.AddObject(button);
                button.Clicked += delegate()
                {
                    _screen.GameLevel.MainLayer.TileSystem.CurrentTileReference = tile.ReferenceID;
                    selectionIndicator.Texture = tile.Texture;
                    textfieldRefernceID.Text = "" + tile.ReferenceID;
                    textfieldTextureName.Text = tile.Texture.ToString();
                };
                i++;
            }

            // ----- Another Window -----

            mainmenu.AddSubMenu(windows, "Windows");
            // ========== WINDOWS SUBMENU END ==========
        }