/// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            this.minimised = false;
            base.Initialize();

            GUIButton btn = new GUIButton(Game, new Vector2(10, 10), "rewind", "<<");

            btn.Initialize();
            AddComponent(btn);

            btn = new GUIButton(Game, new Vector2(40, 10), "pause", "| |");
            btn.Initialize();
            AddComponent(btn);

            btn = new GUIButton(Game, new Vector2(65, 10), "play", " > ");
            btn.Initialize();
            AddComponent(btn);

            GUICheckbox cb = new GUICheckbox(Game, new Vector2(10, 50), "debugdraw", "Debug Draw");

            cb.Initialize();
            AddComponent(cb);

            GUILabel lbl = new GUILabel(Game, new Vector2(10, 80), "status", "Status: Paused");

            lbl.Initialize();
            AddComponent(lbl);
        }
예제 #2
0
        /// <summary>
        /// Adds a new button to the GUI
        /// </summary>
        /// <param name="location">Screen location of the top left corner</param>
        /// <param name="name">Name of the component</param>
        /// <param name="caption">Caption to be displayed on the button</param>
        public GUIButton AddButton(Vector2 location, string name, string caption)
        {
            GUIButton b = new GUIButton(Game, location, name, caption);

            b.Initialize();
            components.Add(b);
            return(b);
        }
예제 #3
0
        /// <summary>
        /// Adds a new button to the GUI with an associated event handler
        /// </summary>
        /// <param name="location">Screen location of the top left corner</param>
        /// <param name="name">Name of the component</param>
        /// <param name="caption">Caption to be displayed on the button</param>
        public GUIButton AddButton(Vector2 location, string name, string caption, GUIButton.MouseClickHandler OnMouseClick)
        {
            GUIButton b = new GUIButton(Game, location, name, caption);

            b.Initialize();
            b.OnMouseClick += OnMouseClick;
            components.Add(b);
            return(b);
        }
예제 #4
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            this.minimised = true;
            base.Initialize();
            GUILabel label = new GUILabel(Game, new Vector2(10, 10), "texturename", "Texture : " + Art.Name);

            label.Initialize();
            AddComponent(label);

            GUILabel depthlabel = new GUILabel(Game, new Vector2(10, 30), "depth", "Depth : ");

            depthlabel.Initialize();
            AddComponent(depthlabel);

            //GUIEditBox depthEdit = new GUIEditBox(Game, new Vector2(70, 30), "depth_edit", 3, Art.ScreenDepth.ToString());
            //depthEdit.Initialize();
            //AddComponent(depthEdit);

            // Depth Options
            List <GUIListBoxItem> depthItems = new List <GUIListBoxItem>();

            depthItems.Add(new GUIListBoxItem(Game, "0", "Static Background"));
            depthItems.Add(new GUIListBoxItem(Game, "0.1", "Far Background"));
            depthItems.Add(new GUIListBoxItem(Game, "0.449", "Background"));
            depthItems.Add(new GUIListBoxItem(Game, "0.5", "Midground"));
            depthItems.Add(new GUIListBoxItem(Game, "0.501", "Foreground"));
            depthItems.Add(new GUIListBoxItem(Game, "0.9", "Far Foreground"));
            depthItems.Add(new GUIListBoxItem(Game, "1", "Static Foreground"));

            GUIListBox depthEdit = new GUIListBox(Game, new Vector2(80, 30), "depth_edit", depthItems);

            depthEdit.Initialize();

            // Setting current item
            string currentDepth = Art.ScreenDepth.ToString();

            depthEdit.SetItem(currentDepth);

            AddComponent(depthEdit);

            //GUIEditBox edit = new GUIEditBox(Game, new Vector2(100, 10), "edtOpen", 300, "");
            //edit.Initialize();
            //AddComponent(edit);
            GUIButton ok = new GUIButton(Game, new Vector2(100, 400), "okbutton", "Apply");

            ok.Initialize();
            ok.OnMouseClick += new GUIButton.MouseClickHandler(OkMouseClick);
            ok.Location.X   -= ok.Bounds.Width / 2;
            AddComponent(ok);
            GUIButton cancel = new GUIButton(Game, new Vector2(150, 400), "cancelbutton", "Cancel");

            cancel.Initialize();
            cancel.OnMouseClick += new GUIButton.MouseClickHandler(CancelMouseClick);
            cancel.Location.X   -= cancel.Bounds.Width / 2;
            AddComponent(cancel);
        }
예제 #5
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();
            // TODO: Add your initialization code here
            batch     = new SpriteBatch(Game.GraphicsDevice);
            font      = Game.Content.Load <SpriteFont>(@"Fonts\Console");
            primBatch = new PrimitiveBatch(Game.GraphicsDevice);

            // Set up visible items
            if (numItems > Items.Count)
            {
                numItems = Items.Count;
            }


            // Initialise the buttons
            foreach (GUIListBoxItem lbi in Items)
            {
                lbi.Initialize();
                lbi.Parent = this;

                if (font.MeasureString(lbi.Name).X > maxWidth)
                {
                    maxWidth = font.MeasureString(lbi.Name).X;
                }
                lbi.OnMouseClick += new GUIListBoxItem.MouseClickHandler(SelectItem);
            }

            maxWidth += 20;

            foreach (GUIListBoxItem lbi in Items)
            {
                lbi.boxDimensions.X = maxWidth;
            }

            // And set the initial locations
            UpdateList();

            components = new List <GUIComponent>();

            // Get width of the listbox
            float boxHeight = (numItems - 1) * Items[0].Bounds.Height;

            // Display Down button
            DownButton = new GUIButton(Game, new Vector2(maxWidth, boxHeight + 20), new Vector2(20, 20), "down", "+");
            DownButton.Initialize();
            DownButton.OnMouseClick += new GUIButton.MouseClickHandler(ScrollDown);
            DownButton.UpdateLocation(DownButton.Location + new Vector2(Location.X, Location.Y));
            components.Add(DownButton);

            // Display Up button
            UpButton = new GUIButton(Game, new Vector2(maxWidth, 20), new Vector2(20, 20), "up", "-");
            UpButton.Initialize();
            UpButton.OnMouseClick += new GUIButton.MouseClickHandler(ScrollUp);
            UpButton.UpdateLocation(UpButton.Location + new Vector2(Location.X, Location.Y));
            components.Add(UpButton);

            // Calculate bar intervals
            barIntervals = ((boxHeight - 20) / Items.Count);

            PosBar = new GUIButton(Game, new Vector2(maxWidth, 40), new Vector2(20, barIntervals * numItems), "bar", "");
            PosBar.BackgroundColor = HighlightColor;
            PosBar.AllowHold       = true;
            PosBar.Initialize();
            PosBar.OnMouseHold += new GUIButton.MouseClickHandler(DragScroll);
            PosBar.UpdateLocation(PosBar.Location + new Vector2(Location.X, Location.Y));
            components.Add(PosBar);

            currentItem = new GUILabel(Game, new Vector2(0, 0), new Vector2(maxWidth, 20), "label", "Select ...");
            currentItem.Initialize();
            currentItem.BackgroundColor = Color.AntiqueWhite;
            currentItem.UpdateLocation(currentItem.Location + new Vector2(Location.X, Location.Y));
            components.Add(currentItem);

            OpenCloseList = new GUIButton(Game, new Vector2(maxWidth, 0), new Vector2(20, 20), "openclose", "+");
            OpenCloseList.Initialize();
            OpenCloseList.OnMouseClick += new GUIButton.MouseClickHandler(OCList);
            OpenCloseList.UpdateLocation(OpenCloseList.Location + new Vector2(Location.X, Location.Y));
            components.Add(OpenCloseList);
        }
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();
            GUILabel label = new GUILabel(Game, new Vector2(10, 10), "lblOpen", "Filename:");

            label.Initialize();
            AddComponent(label);
            //GUIEditBox edit = new GUIEditBox(Game, new Vector2(100, 10), "edtOpen", 300, "");
            //edit.Initialize();
            //AddComponent(edit);
            GUIButton ok = new GUIButton(Game, new Vector2(480, 50), "okbutton", "Ok");

            ok.Initialize();
            ok.OnMouseClick += new GUIButton.MouseClickHandler(OkMouseClick);
            AddComponent(ok);
            GUIButton cancel = new GUIButton(Game, new Vector2(520, 50), "cancelbutton", "Cancel");

            cancel.Initialize();
            cancel.OnMouseClick += new GUIButton.MouseClickHandler(CancelMouseClick);
            AddComponent(cancel);

            GUICheckbox isphys = new GUICheckbox(Game, new Vector2(100, 50), "isphys", "Generate Collision Mesh");

            isphys.Initialize();
            AddComponent(isphys);

            GUILabel bouncylbl = new GUILabel(Game, new Vector2(10, 90), "lblBounce", "Bounciness");

            bouncylbl.Initialize();
            AddComponent(bouncylbl);

            GUIEditBox bouncy = new GUIEditBox(Game, new Vector2(100, 90), "edtBouncy", 50, "500");

            bouncy.Initialize();
            AddComponent(bouncy);

            GUILabel frictionlbl = new GUILabel(Game, new Vector2(10, 120), "lblFriction", "Friction");

            frictionlbl.Initialize();
            AddComponent(frictionlbl);

            GUIEditBox friction = new GUIEditBox(Game, new Vector2(100, 120), "edtFriction", 50, "500");

            friction.Initialize();
            AddComponent(friction);


            // Add List Box
            List <GUIListBoxItem> guiListItems = new List <GUIListBoxItem>();

            string[] filenames = Directory.GetFiles("Content\\LevelArt");

            for (int i = 0; i < filenames.Length; i++)
            {
                string shortName = (string)filenames[i].Substring(17);
                guiListItems.Add(new GUIListBoxItem(Game, filenames[i], shortName));
            }

            fileList = new GUIListBox(Game, new Vector2(100, 10), "list box", guiListItems);
            fileList.Initialize();
            AddComponent(fileList);
        }
예제 #7
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            this.minimised = false;
            base.Initialize();
            GUILabel label = new GUILabel(Game, new Vector2(10, 10), "physobjname", "Texture:");

            label.Initialize();
            AddComponent(label);

            // Use Texture
            List <GUIListBoxItem> guiListItems = new List <GUIListBoxItem>();

            string[] filenames = Directory.GetFiles("Content\\LevelArt");

            for (int i = 0; i < filenames.Length; i++)
            {
                string shortName = (string)filenames[i].Substring(17);
                guiListItems.Add(new GUIListBoxItem(Game, filenames[i], shortName));
            }

            fileList = new GUIListBox(Game, new Vector2(10, 30), "list box", guiListItems);
            fileList.Initialize();


            GUILabel weightlbl = new GUILabel(Game, new Vector2(10, 60), "lblMass", "Mass");

            weightlbl.Initialize();
            AddComponent(weightlbl);

            GUIEditBox weight = new GUIEditBox(Game, new Vector2(100, 60), "edtMass", 50, "10");

            weight.Initialize();
            AddComponent(weight);

            GUILabel bouncylbl = new GUILabel(Game, new Vector2(10, 90), "lblBounce", "Bounciness");

            bouncylbl.Initialize();
            AddComponent(bouncylbl);

            GUIEditBox bouncy = new GUIEditBox(Game, new Vector2(100, 90), "edtBouncy", 50, "500");

            bouncy.Initialize();
            AddComponent(bouncy);

            GUILabel frictionlbl = new GUILabel(Game, new Vector2(10, 120), "lblFriction", "Friction");

            frictionlbl.Initialize();
            AddComponent(frictionlbl);

            GUIEditBox friction = new GUIEditBox(Game, new Vector2(100, 120), "edtFriction", 50, "500");

            friction.Initialize();
            AddComponent(friction);

            GUIButton ok = new GUIButton(Game, new Vector2(150, 375), "okbutton", "Apply");

            ok.Initialize();
            ok.OnMouseClick += new GUIButton.MouseClickHandler(OkMouseClick);
            ok.Location.X   -= ok.Bounds.Width / 2;
            AddComponent(ok);
            GUIButton cancel = new GUIButton(Game, new Vector2(200, 375), "cancelbutton", "Cancel");

            cancel.Initialize();
            cancel.OnMouseClick += new GUIButton.MouseClickHandler(CancelMouseClick);
            cancel.Location.X   -= cancel.Bounds.Width / 2;
            AddComponent(cancel);

            AddComponent(fileList);
        }