Exemplo n.º 1
0
        /// <summary>
        /// Create a blank frame.
        /// </summary>
        public Frame()
        {
            this.Rectangle = Rectangle.Empty;
            this.Texture   = null;
            this.Color     = Color.White;

            this.Children = new List <Frame>();

            this.UID = GUIManager.Add(this);
        }
Exemplo n.º 2
0
        public override void InitialiseLevel()
        {
            IncrementalItemCount = 0;

            base.InitialiseLevel();

            //Set up the GUI For the Sandbox

            //Add Tab Pages
            tabControl = new vxTabControl(vxEngine,
                                          vxEngine.GraphicsDevice.Viewport.Width - 100,
                                          vxEngine.GraphicsDevice.Viewport.Height - 50,
                                          new Vector2(50, 48),
                                          vxGUIItemOrientation.Left);
            GUIManager.Add(tabControl);

            propertiesTabControl = new vxTabControl(vxEngine,
                                                    300,
                                                    vxEngine.GraphicsDevice.Viewport.Height - 50,
                                                    new Vector2(-50, 48),
                                                    vxGUIItemOrientation.Right);
            GUIManager.Add(propertiesTabControl);

            vxTabPage properties = new vxTabPage(vxEngine, propertiesTabControl, "Properties");

            propertiesTabControl.AddItem(properties);


            //Set up The Scroll Panel which will hold all Properties
            PropertiesControl = new vxScrollPanel(new Vector2(0, 0),
                                                  properties.Width - 50, properties.Height - 10);
            properties.AddItem(PropertiesControl);


            //Sets The Outof sifht Position
            OutofSight = Vector3.One * 100000;


            #region Setup Top Toolbar

            toolbar = new vxToolbar(new Vector2(0, 0))
            {
                Height   = 48,
                PaddingX = 0,
                PaddingY = 0,
            };

            //Texture2D Texture_Splitter = vxEngine.EngineContentManager.Load<Texture2D>("Textures/sandbox/toolbar_icons/Toolbar_Seperator");

            GUIManager.Add(toolbar);

            //Test Buttons
            vxToolbarButton RunGameToolbarItem = new vxToolbarButton(vxEngine, vxEngine.EngineContentManager, "Textures/sandbox/tlbr/test/test_run");
            //vxToolbarButton StopGameToolbarItem = new vxToolbarButton(vxEngine, vxEngine.EngineContentManager, "Textures/sandbox/tlbr/test/test_stop");

            //Create Toolbar Items
            vxToolbarButton NewFileToolbarItem    = new vxToolbarButton(vxEngine, vxEngine.EngineContentManager, "Textures/sandbox/tlbr/file/file_new");
            vxToolbarButton OpenFileToolbarItem   = new vxToolbarButton(vxEngine, vxEngine.EngineContentManager, "Textures/sandbox/tlbr/file/file_open");
            vxToolbarButton SaveFileToolbarItem   = new vxToolbarButton(vxEngine, vxEngine.EngineContentManager, "Textures/sandbox/tlbr/file/file_save");
            vxToolbarButton SaveAsFileToolbarItem = new vxToolbarButton(vxEngine, vxEngine.EngineContentManager, "Textures/sandbox/tlbr/file/file_saveas");

            vxToolbarButton ImportToolbarItem     = new vxToolbarButton(vxEngine, vxEngine.EngineContentManager, "Textures/sandbox/tlbr/io/io_import");
            vxToolbarButton ExportFileToolbarItem = new vxToolbarButton(vxEngine, vxEngine.EngineContentManager, "Textures/sandbox/tlbr/io/io_export");


            AddItemModeToolbarItem = new vxToolbarButton(vxEngine, vxEngine.EngineContentManager, "Textures/sandbox/tlbr/sel/sel_addItem")
            {
                IsTogglable = true,
            };
            SelectItemModeToolbarItem = new vxToolbarButton(vxEngine, vxEngine.EngineContentManager, "Textures/sandbox/tlbr/sel/sel_selItem")
            {
                IsTogglable = true,
            };

            //Setup Events
            NewFileToolbarItem.Clicked    += new EventHandler <vxGuiItemClickEventArgs>(Event_NewFileToolbarItem_Clicked);
            OpenFileToolbarItem.Clicked   += new EventHandler <vxGuiItemClickEventArgs>(Event_OpenFileToolbarItem_Clicked);
            SaveFileToolbarItem.Clicked   += new EventHandler <vxGuiItemClickEventArgs>(Event_SaveFileToolbarItem_Clicked);
            SaveAsFileToolbarItem.Clicked += new EventHandler <vxGuiItemClickEventArgs>(Event_SaveAsFileToolbarItem_Clicked);

            ExportFileToolbarItem.Clicked += new EventHandler <vxGuiItemClickEventArgs>(ExportFileToolbarItem_Clicked);

            RunGameToolbarItem.Clicked += new EventHandler <vxGuiItemClickEventArgs>(RunGameToolbarItem_Clicked);
            //StopGameToolbarItem.Clicked += new EventHandler<vxGuiItemClickEventArgs>(StopGameToolbarItem_Clicked);

            AddItemModeToolbarItem.Clicked    += AddItemModeToolbarItem_Clicked;
            SelectItemModeToolbarItem.Clicked += SelectItemModeToolbarItem_Clicked;
            //Add Toolbar Items
            toolbar.AddItem(NewFileToolbarItem);
            toolbar.AddItem(OpenFileToolbarItem);
            toolbar.AddItem(SaveFileToolbarItem);
            toolbar.AddItem(SaveAsFileToolbarItem);

            toolbar.AddItem(new vxToolbarSpliter(vxEngine, 5));

            toolbar.AddItem(ImportToolbarItem);
            toolbar.AddItem(ExportFileToolbarItem);

            toolbar.AddItem(new vxToolbarSpliter(vxEngine, 5));

            toolbar.AddItem(RunGameToolbarItem);
            //toolbar.AddItem(StopGameToolbarItem);

            toolbar.AddItem(new vxToolbarSpliter(vxEngine, 5));

            toolbar.AddItem(AddItemModeToolbarItem);
            toolbar.AddItem(SelectItemModeToolbarItem);
            #endregion

            //Set Initial State
            SelectItemModeToolbarItem.ToggleState = true;
            MouseClickState = vxEnumSanboxMouseClickState.SelectItem;
        }
        void KeyDownFunction(KeyEventArgs args)
        {
            if (args.Key == Keys.Enter)
            {
                Window window = new Window(this, gui);
                window.Width  = 320;
                window.Height = 380;
                window.Close += new CloseHandler(WindowCloseFunction);

                string text = "Test Window " + windowNumber;
                window.TitleText = text;
                windowNumber++;

                ComboBox comboBox = new ComboBox(this, gui);
                comboBox.IsEditable = true;
                comboBox.ZOrder     = 1.0f;
                comboBox.X          = 20;
                comboBox.Y          = 54;

                for (int i = 0; i < 3; i++)
                {
                    comboBox.AddEntry("Test");
                }

                window.Add(comboBox);

                RadioButton radio1 = new RadioButton(this, gui);
                radio1.X    = 0;
                radio1.Y    = 0;
                radio1.Text = "Radio Test 1";

                RadioButton radio2 = new RadioButton(this, gui);
                radio2.X    = 0;
                radio2.Y    = 16;
                radio2.Text = "Radio Test 2";

                RadioButton radio3 = new RadioButton(this, gui);
                radio3.X    = 0;
                radio3.Y    = 32;
                radio3.Text = "Radio Test 3";

                RadioGroup group = new RadioGroup(this, gui);
                group.X      = 20;
                group.Y      = 89;
                group.Width  = 200;
                group.Height = 48;
                group.ZOrder = 1.0f;
                group.Add(radio1);
                group.Add(radio2);
                group.Add(radio3);

                window.Add(group);

                ListBox listBox = new ListBox(this, gui);
                listBox.X      = 20;
                listBox.Y      = 144;
                listBox.ZOrder = 1.0f;

                for (int i = 0; i < 15; i++)
                {
                    listBox.AddEntry("List Box Test " + (i + 1));
                }

                window.Add(listBox);

                MenuBar    menuBar = new MenuBar(this, gui);
                MenuButton item1   = new MenuButton(this, gui);
                item1.Text = "File";
                menuBar.Add(item1);
                MenuButton item2 = new MenuButton(this, gui);
                item2.Text      = "Edit";
                item2.IsEnabled = false;
                item2.IsEnabled = true;
                menuBar.Add(item2);

                MenuButton fileItem1 = new MenuButton(this, gui);
                fileItem1.Text       = "New";
                fileItem1.IconSource = new Rectangle(1, 189, 14, 14);
                fileItem1.IsEnabled  = false;
                item1.Add(fileItem1);
                MenuSeparator fileItem2 = new MenuSeparator(this, gui);
                item1.Add(fileItem2);
                MenuButton fileItem3 = new MenuButton(this, gui);
                fileItem3.Text       = "Close";
                fileItem3.IconSource = new Rectangle(16, 189, 15, 13);
                item1.Add(fileItem3);

                MenuButton item4 = new MenuButton(this, gui);
                item4.Text      = "Community";
                item4.IsEnabled = true;
                item2.Add(item4);
                MenuSeparator sep2 = new MenuSeparator(this, gui);
                item2.Add(sep2);
                MenuButton item5 = new MenuButton(this, gui);
                item5.Text = "Next Test";
                item4.Add(item5);
                MenuButton item6 = new MenuButton(this, gui);
                item6.Text            = "The Next Level!";
                item6.ShowMarginImage = false;
                item2.Add(item6);
                MenuButton item7 = new MenuButton(this, gui);
                item7.Text = "Booyeah ;-)";
                item6.Add(item7);
                window.Add(menuBar);

                gui.Add(window);

                MessageBox dialog = new MessageBox(this, gui, "Message box asking user a question.", "Message Box", MessageBoxButtons.Yes_No_Cancel, MessageBoxType.Question);
                dialog.Show(false);

                if (before == 1)
                {
                    gui.ApplySkin(skin, true, true);
                }

                before++;
            }
            else if (args.Key == Keys.A)
            {
                SkinnedComponent skin = new SkinnedComponent(this, gui);
            }
        }
Exemplo n.º 4
0
        protected override bool initGUI()
        {
            _guiMgr = new GUIManager(_screenMgr);
            _screenMgr.Components.Add(_guiMgr);
            _guiMgr.Initialize();

            #region Shorthand GUI item creation
            // Create a MenuItem
            Func <UIComponent, String, MenuItem> create_mi =
                (UIComponent parent, String text) =>
            {
                MenuItem mi = new MenuItem(_screenMgr, _guiMgr);
                mi.Text = text;

                if (parent is MenuBar)
                {
                    (parent as MenuBar).Add(mi);
                }
                else if (parent is MenuItem)
                {
                    (parent as MenuItem).Add(mi);
                }

                return(mi);
            };

            // Create a TextButton
            Func <UIComponent, String, int, int, int, int, TextButton> create_btn =
                (UIComponent parent, String text, int w, int h, int x, int y) =>
            {
                TextButton btn = new TextButton(_screenMgr, _guiMgr);

                btn.Text   = text;
                btn.Width  = w;
                btn.Height = h;
                btn.X      = x;
                btn.Y      = y;

                if (parent is Dialog)
                {
                    (parent as Dialog).Add(btn);
                }
                else if (parent is Window)
                {
                    (parent as Window).Add(btn);
                }

                return(btn);
            };

            // Create a Dialog
            Func <String, int, int, int, int, Dialog> create_dialog =
                (String text, int w, int h, int x, int y) =>
            {
                Dialog dialog = new Dialog(_screenMgr, _guiMgr);
                _guiMgr.Add(dialog);

                dialog.TitleText      = text;
                dialog.Width          = w;
                dialog.Height         = h;
                dialog.X              = x;
                dialog.Y              = y;
                dialog.HasCloseButton = false;

                int bwidth  = 50;
                int bheight = 20;
                int bxoffs  = 10;
                int byoffs  = dialog.Height - 60;

                // Ok button
                TextButton btnOk = create_btn(
                    dialog, "Ok", bwidth, bheight, bxoffs, byoffs);
                btnOk.Click += delegate(UIComponent sender)
                {
                    dialog.DialogResult = DialogResult.OK;
                    dialog.CloseWindow();
                };

                // Cancel button
                TextButton btnCancel = create_btn(
                    dialog, "Cancel", bwidth, bheight, bxoffs * 2 + bwidth, byoffs);
                btnCancel.Click += delegate(UIComponent sender)
                {
                    dialog.DialogResult = DialogResult.Cancel;
                    dialog.CloseWindow();
                };

                return(dialog);
            };

            // Create a text box
            Func <UIComponent, String, int, int, int, TextBox> create_textbox =
                (UIComponent parent, String text, int w, int x, int y) =>
            {
                TextBox textBox = new TextBox(_screenMgr, _guiMgr);

                textBox.Width = w;
                textBox.X     = x;
                textBox.Y     = y;

                Label label = new Label(_screenMgr, _guiMgr);
                label.Text   = text;
                label.Width  = 100;
                label.Height = 50;
                label.X      = x - label.Width;
                label.Y      = y + 5;

                if (parent is Dialog)
                {
                    (parent as Dialog).Add(textBox);
                    (parent as Dialog).Add(label);
                }

                return(textBox);
            };
            #endregion

            {   // Main menu bar
                MenuBar menuBar = new MenuBar(_screenMgr, _guiMgr);
                _guiMgr.Add(menuBar);
                //-----------------------------------------------------------------
                {   // File
                    MenuItem fileButton = create_mi(menuBar, "File");
                    //-------------------------------------------------------------
                    {   // New
                        MenuItem newButton = create_mi(fileButton, "New");
                        newButton.Click += delegate(UIComponent sender)
                        {
                            Dialog  d    = create_dialog("New", 300, 200, 100, 100);
                            TextBox rows = create_textbox(d, "Rows", 50, 150, 10);
                            TextBox cols = create_textbox(d, "Cols", 50, 150, 40);
                            TextBox tile = create_textbox(d, "Tile", 100, 150, 70);

                            d.Close += delegate(UIComponent dsender)
                            {
                                switch (d.DialogResult)
                                {
                                case DialogResult.Cancel:
                                    return;

                                case DialogResult.OK:
                                    int numRows = Convert.ToInt32(rows.Text);
                                    int numCols = Convert.ToInt32(cols.Text);
                                    _gameLevelMgr.newLevel(numRows, numCols, tile.Text);
                                    return;
                                }
                            };
                        };
                    }

                    //-------------------------------------------------------------
                    {   // Save as
                        MenuItem saveAsButton = create_mi(fileButton, "Save as");
                        saveAsButton.Click += delegate(UIComponent sender)
                        {
                            Dialog  d    = create_dialog("Save as", 300, 200, 100, 100);
                            TextBox file = create_textbox(d, "Path", 200, 100, 50);

                            d.Close += delegate(UIComponent dsender)
                            {
                                switch (d.DialogResult)
                                {
                                case DialogResult.Cancel:
                                    return;

                                case DialogResult.OK:
                                    _gameLevelMgr.saveLevel(LEVEL_DIRECTORY + file.Text);
                                    return;
                                }
                            };
                        };
                    }
                    //-------------------------------------------------------------
                    {   // Load
                        MenuItem loadButton = create_mi(fileButton, "Load");
                        loadButton.Click += delegate(UIComponent sender)
                        {
                            Dialog  d    = create_dialog("Load", 300, 200, 100, 100);
                            TextBox file = create_textbox(d, "File", 200, 100, 50);

                            d.Close += delegate(UIComponent dsender)
                            {
                                switch (d.DialogResult)
                                {
                                case DialogResult.Cancel:
                                    return;

                                case DialogResult.OK:
                                    _gameLevelMgr.loadLevel("levels\\" + file.Text);
                                    return;
                                }
                            };
                        };
                    }
                    //-------------------------------------------------------------
                    {   // Quit to menu
                        MenuItem quitButton = create_mi(fileButton, "Quit to menu");
                        quitButton.Click += delegate(UIComponent sender)
                        {
                        };
                    }
                }
                //-----------------------------------------------------------------
                {   // Windows
                    MenuItem windows = create_mi(menuBar, "Windows");

                    Func <String, int, int, int, int, Window> create_win =
                        (String text, int w, int h, int x, int y) =>
                    {
                        Window win = new Window(_screenMgr, _guiMgr);
                        _guiMgr.Add(win);
                        win.Width     = w;
                        win.Height    = h;
                        win.X         = x;
                        win.Y         = y;
                        win.TitleText = text;

                        return(win);
                    };

                    //-------------------------------------------------------------
                    {   // Tile browser
                        MenuItem tbrowser = create_mi(windows, "Tile Browser");
                        tbrowser.Click += delegate(UIComponent sender)
                        {
                            Window tbwin = create_win("Tile Browser", 300, 500, 400, 100);
                            //-----------------------------------------------------
                            {   // Tile buttons
                                TextButton stoneButton = create_btn(tbwin, "Stone", 60, 30, 10, 10);
                                stoneButton.Click += delegate(UIComponent bsender)
                                {
                                    Drawable tdrwble = _gameContentMgr.loadDrawable("tile_stone");
                                    foreach (GameTile tile in _selection)
                                    {
                                        tile.Entity.Drawable = tdrwble;
                                    }
                                };
                                TextButton grassButton = create_btn(tbwin, "Grass", 60, 30, 10, 50);
                                grassButton.Click += delegate(UIComponent bsender)
                                {
                                    Drawable tdrwble = _gameContentMgr.loadDrawable("tile_grass");
                                    foreach (GameTile tile in _selection)
                                    {
                                        tile.Entity.Drawable = tdrwble;
                                    }
                                };
                                TextButton rockButton = create_btn(tbwin, "Rock", 60, 30, 10, 90);
                                rockButton.Click += delegate(UIComponent bsender)
                                {
                                    Drawable tdrwble = _gameContentMgr.loadDrawable("tile_rock");
                                    foreach (GameTile tile in _selection)
                                    {
                                        tile.Entity.Drawable = tdrwble;
                                    }
                                };
                                TextButton sandButton = create_btn(tbwin, "Sand", 60, 30, 10, 130);
                                sandButton.Click += delegate(UIComponent bsender)
                                {
                                    Drawable tdrwble = _gameContentMgr.loadDrawable("tile_sand");
                                    foreach (GameTile tile in _selection)
                                    {
                                        tile.Entity.Drawable = tdrwble;
                                    }
                                };
                                TextButton stoneSandButton = create_btn(tbwin, "S-Sand", 60, 30, 10, 170);
                                stoneSandButton.Click += delegate(UIComponent bsender)
                                {
                                    Drawable tdrwble = _gameContentMgr.loadDrawable("tile_stonesand");
                                    foreach (GameTile tile in _selection)
                                    {
                                        tile.Entity.Drawable = tdrwble;
                                    }
                                };
                            }
                        };
                    }
                    //-------------------------------------------------------------
                    {   // Character browser
                        MenuItem chrbrowser = create_mi(windows, "Character Browser");
                        chrbrowser.Click += delegate(UIComponent sender)
                        {
                            Window chrbwin = create_win("Character Browser", 300, 500, 400, 100);
                        };
                    }
                    //-------------------------------------------------------------
                    {   // Object browser
                        MenuItem itembrowser = create_mi(windows, "Item Browser");
                        itembrowser.Click += delegate(UIComponent sender)
                        {
                            Window ibwin = create_win("Item Browser", 300, 500, 400, 100);
                            //-----------------------------------------------------
                            {   // Item buttons
                                TextButton tree1btn = create_btn(ibwin, "Tree1", 60, 30, 10, 10);
                                tree1btn.Click += delegate(UIComponent bsender)
                                {
                                    foreach (GameTile tile in _selection)
                                    {
                                        GameObject tree = _gameLevelMgr.createGameObject <GameObject>("tree" + _gameLevelMgr.GameObjectCount, "tree1");
                                        tile.Node.attachChildNode(tree.Node);
                                        tree.Node.translateTo(tile.Node.PositionIsometric);
                                    }
                                };
                            }
                        };
                    }
                }
                //-----------------------------------------------------------------
                {   // Tool bar
                    Window toolBar = new Window(_screenMgr, _guiMgr);
                    _guiMgr.Add(toolBar);

                    toolBar.HasCloseButton = false;
                    toolBar.Width          = _screenMgr.GraphicsDevice.Viewport.Width;
                    toolBar.Height         = 60;
                    toolBar.Y         = menuBar.Y + menuBar.Height;
                    toolBar.Resizable = false;
                    toolBar.HasFullWindowMovableArea = false;
                    toolBar.TitleBarHeight           = 4;

                    int btncount, btnx, btny, btnw, btnh;
                    btncount = 0;
                    btnx     = 8;
                    btny     = 4;
                    btnw     = 60;
                    btnh     = 24;
                    //-------------------------------------------------------------
                    {   // Deselect
                        TextButton noneButton = create_btn(toolBar, "None",
                                                           btnw, btnh, ((btnx + btnw) * btncount++), btny);
                        noneButton.Click += delegate(UIComponent sender)
                        {
                            Tool = EditorTool.TOOL_NONE;
                        };
                    }
                    //-------------------------------------------------------------
                    {   // Select
                        TextButton selectButton = create_btn(toolBar, "Select",
                                                             btnw, btnh, ((btnx + btnw) * btncount++), btny);
                        selectButton.Click += delegate(UIComponent sender)
                        {
                            Tool = EditorTool.TOOL_SELECT;
                        };
                    }
                    //-------------------------------------------------------------
                    {   // Zero
                        TextButton zeroButton = create_btn(toolBar, "Zero",
                                                           btnw, btnh, ((btnx + btnw) * btncount++), btny);
                        zeroButton.Click += delegate(UIComponent sender)
                        {
                            batchElevation(0.0f);
                        };
                    }
                    //-------------------------------------------------------------
                    {   // Elevate
                        TextButton elevateButton = create_btn(toolBar, "Elevate",
                                                              btnw, btnh, ((btnx + btnw) * btncount++), btny);
                        elevateButton.Click += delegate(UIComponent sender)
                        {
                            Tool = EditorTool.TOOL_ELEVATE;
                        };
                    }
                    //-------------------------------------------------------------
                    {   // Activate
                        TextButton activateButton = create_btn(toolBar, "Activate",
                                                               btnw, btnh, ((btnx + btnw) * btncount++), btny);
                        activateButton.Click += delegate(UIComponent sender)
                        {
                            batchActivate(true);
                        };
                    }
                    //-------------------------------------------------------------
                    {   // Deactivate
                        TextButton deactivateButton = create_btn(toolBar, "Deact",
                                                                 btnw, btnh, ((btnx + btnw) * btncount++), btny);
                        deactivateButton.Click += delegate(UIComponent sender)
                        {
                            batchActivate(false);
                        };
                    }
                }
            }

            return(base.initGUI());
        }