public StartScreenControl()
        {
            Size = new Vector2(600, 420);
            LargeWindow = true;
            objectives.Dock = System.Windows.Forms.DockStyle.Left;
            objectives.Size = new Vector2(300, 0);

            options.AddChild(weaponsControl);
            weaponsControl.AddChild(new Label
            {
                Text = Locale.Resource.MapSelectedWeapons,
                Size = new Vector2(0, 30),
                TextAnchor = global::Graphics.Orientation.TopLeft,
                Dock = System.Windows.Forms.DockStyle.Top,
                Font = new Font
                {
                    SystemFont = Fonts.LargeSystemFont,
                    Color = System.Drawing.Color.Gold
                },
                Background = null,
                Clickable = false
            });
            weaponsControl.AddChild(meleeWeaponsContainer);
            weaponsControl.AddChild(rangedWeaponsContainer);

            var meleeWeapons = Enum.GetValues(typeof(MeleeWeapons));
            for (int i = 1; i < meleeWeapons.Length; i++)
            {
                MeleeWeapons wp = (MeleeWeapons)meleeWeapons.GetValue(i);
                var w = new Checkbox
                {
                    Text = "",
                    Background = null,
                    UnCheckedGraphic = new ImageGraphic
                    {
                        Texture = new TextureFromFile("Interface/Common/" + WeaponsInfo.GetIconBaseName(wp) + "GameIconOff1.png") { DontScale = true },
                        SizeMode = SizeMode.AutoAdjust,
                        Position = new Vector3(-12, -11, 0)
                    },
                    CheckedGraphic = new ImageGraphic
                    {
                        Texture = new TextureFromFile("Interface/Common/" + WeaponsInfo.GetIconBaseName(wp) + "GameIconOn1.png") { DontScale = true },
                        SizeMode = SizeMode.AutoAdjust,
                        Position = new Vector3(-12, -11, 0)
                    },
                    UnCheckedHoverGraphic = new ImageGraphic
                    {
                        Texture = new TextureFromFile("Interface/Common/" + WeaponsInfo.GetIconBaseName(wp) + "GameIconSelected1.png") { DontScale = true },
                        SizeMode = SizeMode.AutoAdjust,
                        Position = new Vector3(-12, -11, 0)
                    },
                    Size = new Vector2(100, 25),
                    Margin = new System.Windows.Forms.Padding(5)
                };
                Program.Instance.Tooltip.SetToolTip(w, Util.GetLocaleResourceString(wp) + "\n\n" + WeaponsInfo.GetDescription(wp));
                w.Click += new EventHandler((e, o) => { SelectedMeleeWeapon = wp; });
                meleeWeaponsContainer.AddChild(w);
                meleeCheckboxes.Add(wp, w);
            }

            var bullets = Enum.GetValues(typeof(RangedWeapons));
            for (int i = 1; i < bullets.Length; i++)
            {
                RangedWeapons wp = (RangedWeapons)bullets.GetValue(i);
                if (wp == RangedWeapons.Fire) continue;
                var w = new Checkbox
                {
                    Text = "",
                    Background = null,
                    UnCheckedGraphic = new ImageGraphic
                    {
                        Texture = new TextureFromFile("Interface/Common/" + WeaponsInfo.GetIconBaseName(wp) + "GameIconOff1.png") { DontScale = true },
                        SizeMode = SizeMode.AutoAdjust,
                        Position = new Vector3(-12, -11, 0)
                    },
                    CheckedGraphic = new ImageGraphic
                    {
                        Texture = new TextureFromFile("Interface/Common/" + WeaponsInfo.GetIconBaseName(wp) + "GameIconOn1.png") { DontScale = true },
                        SizeMode = SizeMode.AutoAdjust,
                        Position = new Vector3(-12, -11, 0)
                    },
                    UnCheckedHoverGraphic = new ImageGraphic
                    {
                        Texture = new TextureFromFile("Interface/Common/" + WeaponsInfo.GetIconBaseName(wp) + "GameIconSelected1.png") { DontScale = true },
                        SizeMode = SizeMode.AutoAdjust,
                        Position = new Vector3(-12, -11, 0)
                    },
                    Size = new Vector2(100, 25),
                    Margin = new System.Windows.Forms.Padding(5)
                };
                Program.Instance.Tooltip.SetToolTip(w, Util.GetLocaleResourceString(wp) + "\n\n" + WeaponsInfo.GetDescription(wp));
                w.Click += new EventHandler((e, o) => { SelectedRangedWeapon = wp; });
                rangedWeaponsContainer.AddChild(w);
                bulletCheckboxes.Add(wp, w);
            }

            //innerControl.AddChild(new Control
            //{
            //    Background = new StretchingImageGraphic
            //    {
            //        Texture = new TextureConcretizer
            //        {
            //            TextureDescription = new Graphics.Software.Textures.SingleColorTexture(System.Drawing.Color.FromArgb(50, 255, 255, 255))
            //        },
            //        SizeMode = SizeMode.AutoAdjust,
            //    },
            //    Dock = System.Windows.Forms.DockStyle.Left,
            //    Size = new Vector2(1, 1)
            //});
            innerControl.AddChild(options);

            bottomBar.AddChild(startButton);
            startButton.Click += new EventHandler(startButton_Click);
            bottomBar.AddChild(quitButton);
            quitButton.Click += new EventHandler(quitButton_Click);

            ButtonBase optionsButton = new StoneButton
            {
                Anchor = Graphics.Orientation.Left,
                Position = new Vector2(20 + quitButton.Size.X, 0),
                Text = Locale.Resource.GenOptions
            };
            optionsButton.Click += new EventHandler(optionsButton_Click);
            bottomBar.AddChild(optionsButton);
        }
        public override void Init()
        {
            Content.ContentPath = "Data";

            InterfaceScene = new Graphics.Interface.InterfaceScene(this);

            InterfaceScene.Add(new Graphics.Interface.TextBox
            {
                Size = new Vector2(100, 20),
                Text = "TopRight",
                Anchor = Orientation.TopRight
            });

            InterfaceScene.Add(new Graphics.Interface.TextBox
            {
                Size = new Vector2(100, 20),
                Text = "BottomLeft",
                Anchor = Orientation.BottomLeft
            });

            InterfaceScene.Add(new Graphics.Interface.TextBox
            {
                Size = new Vector2(100, 20),
                Text = "BottomRight",
                Anchor = Orientation.BottomRight
            });

            InterfaceScene.Add(new Graphics.Interface.Button
            {
                Size = new Vector2(100, 20),
                Text = "Button",
                Anchor = Orientation.Center
            });

            InterfaceScene.Add(cb = new Graphics.Interface.Checkbox
            {
                Size = new Vector2(100, 20),
                Text = "Checkbox",
                Anchor = Orientation.Center,
                Position = new Vector2(0, 40)
            });

            InterfaceScene.Add(pb = new Graphics.Interface.ProgressBar
            {
                Size = new Vector2(100, 100),
                Text = "Button",
                Anchor = Orientation.Bottom,
                MaxValue = 100,
                Value = 50,
                ProgressGraphic = new ImageGraphic
                {
                    Texture = new TextureFromFile("cornellbox3.png"),
                        //new TextureConcretizer { TextureDescription = new Graphics.Software.Textures.SingleColorTexture(Color.Red) },
                    TextureAnchor = Orientation.BottomLeft
                },
                ProgressOrientation = Graphics.Interface.ProgressOrientation.BottomToTop
            });

            InterfaceScene.Add(dpb = new Graphics.Interface.DeltaProgressBar
            {
                Size = new Vector2(140, 10),
                Anchor = Orientation.Center,
                MaxValue = 100,
                Value = 70,
                Position = new Vector2(0, -30),
                ProgressOrientation = Graphics.Interface.ProgressOrientation.LeftToRight
            });

            Button bb;
            InterfaceScene.Add(bb = new Button
            {
                Size = new Vector2(50, 20),
                Text = "-",
                Anchor = Orientation.Center,
                Position = new Vector2(-30, -60)
            });
            bb.Click += (sender, ea) => { dpb.Value = Common.Math.Clamp(dpb.Value - 20, 0, 100); };
            InterfaceScene.Add(bb = new Button
            {
                Size = new Vector2(50, 20),
                Text = "+",
                Anchor = Orientation.Center,
                Position = new Vector2(30, -60)
            });
            bb.Click += (sender, ea) => { dpb.Value = Common.Math.Clamp(dpb.Value + 20, 0, 100); };

            InterfaceScene.Add(new Graphics.Interface.Console
            {
                Anchor = Orientation.Bottom,
                Position = new Vector2(0, 100),
                Size = new Vector2(400, 100)
            });

            var f = new Graphics.Interface.Form
            {
                Size = new Vector2(300, 300)
            };
            InterfaceScene.Add(f);
            b = new Graphics.Interface.Button
            {
                Size = new Vector2(100, 20),
                Text = "TopLeft",
                Anchor = Orientation.TopLeft
            };
            f.AddChild(b);
            Control checker;
            InterfaceScene.Add(checker = new Control
            {
                Background = new ImageGraphic
                {
                    Size = new Vector2(100, 100),
                    Texture = new TextureFromFile("checker.png")
                },
                Size = new Vector2(100, 100),
                Position = new Vector2(10, 30),
                Anchor = Orientation.TopRight,
                Clickable = true,
                PickingLocalBounding = new Common.Bounding.Chain
                {
                    Boundings = new object[]
                    {
                        new BoundingBox(Vector3.Zero, new Vector3(1, 1, 0)),
                        new MetaBoundingImageGraphic
                        {
                            Graphic = new ImageGraphic
                            {
                                Size = new Vector2(100, 100),
                                Texture = new TextureFromFile("checker.png")
                            },
                        }
                    },
                    Shallow = true
                }
            });
            InterfaceScene.Add(popupContainer);
            InterfaceScene.Add(new Form
            {
                Anchor = Orientation.Right,
                Size = new Vector2(100, 100),
                ControlBox = true
            });

            tt = new Graphics.Interface.ToolTip();
            tt.SetToolTip(pb, "This is a progress bar");
            tt.SetToolTip(checker, "Checker");
            InterfaceScene.Add(tt);

            if (Direct3DVersion == Direct3DVersion.Direct3D10)
                InterfaceRenderer = new Graphics.Interface.InterfaceRenderer10(Device10)
                { Scene = InterfaceScene };
            else
                InterfaceRenderer = new Graphics.Interface.InterfaceRenderer9(Device9)
                { Scene = InterfaceScene, StateManager = new Device9StateManager(Device9) };
            InterfaceRenderer.Initialize(this);
            InputHandler = Manager = new Graphics.Interface.InterfaceManager { Scene = InterfaceScene };
            //bvr = new BoundingVolumesRenderer
            //{
            //    View = this,
            //    StateManager = sm
            //};
        }
Beispiel #3
0
        public override void Init()
        {
            Content.ContentPath = "Data";

            InterfaceScene = new Graphics.Interface.InterfaceScene(this);


            InterfaceScene.Add(new Graphics.Interface.TextBox
            {
                Size   = new Vector2(100, 20),
                Text   = "TopRight",
                Anchor = Orientation.TopRight
            });

            InterfaceScene.Add(new Graphics.Interface.TextBox
            {
                Size   = new Vector2(100, 20),
                Text   = "BottomLeft",
                Anchor = Orientation.BottomLeft
            });

            InterfaceScene.Add(new Graphics.Interface.TextBox
            {
                Size   = new Vector2(100, 20),
                Text   = "BottomRight",
                Anchor = Orientation.BottomRight
            });

            InterfaceScene.Add(new Graphics.Interface.Button
            {
                Size   = new Vector2(100, 20),
                Text   = "Button",
                Anchor = Orientation.Center
            });

            InterfaceScene.Add(cb = new Graphics.Interface.Checkbox
            {
                Size     = new Vector2(100, 20),
                Text     = "Checkbox",
                Anchor   = Orientation.Center,
                Position = new Vector2(0, 40)
            });

            InterfaceScene.Add(pb = new Graphics.Interface.ProgressBar
            {
                Size            = new Vector2(100, 100),
                Text            = "Button",
                Anchor          = Orientation.Bottom,
                MaxValue        = 100,
                Value           = 50,
                ProgressGraphic = new ImageGraphic
                {
                    Texture = new TextureFromFile("cornellbox3.png"),
                    //new TextureConcretizer { TextureDescription = new Graphics.Software.Textures.SingleColorTexture(Color.Red) },
                    TextureAnchor = Orientation.BottomLeft
                },
                ProgressOrientation = Graphics.Interface.ProgressOrientation.BottomToTop
            });

            InterfaceScene.Add(dpb = new Graphics.Interface.DeltaProgressBar
            {
                Size                = new Vector2(140, 10),
                Anchor              = Orientation.Center,
                MaxValue            = 100,
                Value               = 70,
                Position            = new Vector2(0, -30),
                ProgressOrientation = Graphics.Interface.ProgressOrientation.LeftToRight
            });

            Button bb;

            InterfaceScene.Add(bb = new Button
            {
                Size     = new Vector2(50, 20),
                Text     = "-",
                Anchor   = Orientation.Center,
                Position = new Vector2(-30, -60)
            });
            bb.Click += (sender, ea) => { dpb.Value = Common.Math.Clamp(dpb.Value - 20, 0, 100); };
            InterfaceScene.Add(bb = new Button
            {
                Size     = new Vector2(50, 20),
                Text     = "+",
                Anchor   = Orientation.Center,
                Position = new Vector2(30, -60)
            });
            bb.Click += (sender, ea) => { dpb.Value = Common.Math.Clamp(dpb.Value + 20, 0, 100); };

            InterfaceScene.Add(new Graphics.Interface.Console
            {
                Anchor   = Orientation.Bottom,
                Position = new Vector2(0, 100),
                Size     = new Vector2(400, 100)
            });

            var f = new Graphics.Interface.Form
            {
                Size = new Vector2(300, 300)
            };

            InterfaceScene.Add(f);
            b = new Graphics.Interface.Button
            {
                Size   = new Vector2(100, 20),
                Text   = "TopLeft",
                Anchor = Orientation.TopLeft
            };
            f.AddChild(b);
            Control checker;

            InterfaceScene.Add(checker = new Control
            {
                Background = new ImageGraphic
                {
                    Size    = new Vector2(100, 100),
                    Texture = new TextureFromFile("checker.png")
                },
                Size                 = new Vector2(100, 100),
                Position             = new Vector2(10, 30),
                Anchor               = Orientation.TopRight,
                Clickable            = true,
                PickingLocalBounding = new Common.Bounding.Chain
                {
                    Boundings = new object[]
                    {
                        new BoundingBox(Vector3.Zero, new Vector3(1, 1, 0)),
                        new MetaBoundingImageGraphic
                        {
                            Graphic = new ImageGraphic
                            {
                                Size    = new Vector2(100, 100),
                                Texture = new TextureFromFile("checker.png")
                            },
                        }
                    },
                    Shallow = true
                }
            });
            InterfaceScene.Add(popupContainer);
            InterfaceScene.Add(new Form
            {
                Anchor     = Orientation.Right,
                Size       = new Vector2(100, 100),
                ControlBox = true
            });

            tt = new Graphics.Interface.ToolTip();
            tt.SetToolTip(pb, "This is a progress bar");
            tt.SetToolTip(checker, "Checker");
            InterfaceScene.Add(tt);

            if (Direct3DVersion == Direct3DVersion.Direct3D10)
            {
                InterfaceRenderer = new Graphics.Interface.InterfaceRenderer10(Device10)
                {
                    Scene = InterfaceScene
                }
            }
            ;
            else
            {
                InterfaceRenderer = new Graphics.Interface.InterfaceRenderer9(Device9)
                {
                    Scene = InterfaceScene, StateManager = new Device9StateManager(Device9)
                }
            };
            InterfaceRenderer.Initialize(this);
            InputHandler = Manager = new Graphics.Interface.InterfaceManager {
                Scene = InterfaceScene
            };
            //bvr = new BoundingVolumesRenderer
            //{
            //    View = this,
            //    StateManager = sm
            //};
        }

        Graphics.Interface.ToolTip tt;
        Graphics.Interface.Button b;