Example #1
0
        public static WindowControl Create(ControlBase parent, GLWindow game, string text, string title, bool ok, bool cancel)
        {
            var wc = new WindowControl(parent, title, false);

            wc.MakeModal(true);
            wc.Width = 200;
            RichLabel l = new RichLabel(wc);

            //  Align.StretchHorizontally(l);
            l.Dock  = Pos.Top;
            l.Width = wc.Width;
            l.AddText(text, parent.Skin.Colors.Label.Default, parent.Skin.DefaultFont);
            wc.Layout();
            l.SizeToChildren(false, true);
            wc.Height = 65 + l.Height;
            Align.CenterHorizontally(l);
            if (ok)
            {
                Button btn = new Button(wc);
                btn.Name   = "Okay";
                btn.Text   = "Okay";
                btn.Height = 20;
                btn.Y      = l.Y + l.Height + 10;
                btn.Width  = 100;
                Align.AlignLeft(l);
            }
            if (cancel)
            {
                Button btn = new Button(wc);
                btn.Name = "Cancel";
                btn.Text = "Cancel";
                btn.SizeToContents();
                btn.Height = 20;
                btn.Width  = 70;
                btn.Y      = l.Y + l.Height + 10;
                btn.X      = (wc.Width - 12) - btn.Width;
            }
            wc.Show();
            wc.SetPosition((game.RenderSize.Width / 2) - (wc.Width / 2), (game.RenderSize.Height / 2) - (wc.Height / 2));
            wc.DisableResizing();
            return(wc);
        }
Example #2
0
        public static GameCanvas CreateCanvas(GLWindow game)
        {
            var renderer = new Gwen.Renderer.OpenTK();

            var tx = new Texture(renderer);

            Gwen.Renderer.OpenTK.LoadTextureInternal(tx, GameResources.DefaultSkin);
            var skin    = new TexturedBase(renderer, tx, GameResources.DefaultColors);
            var bmpfont = new Gwen.Renderer.OpenTK.BitmapFont(renderer, "SourceSansPro", 10, 10, GameResources.SourceSansProq,
                                                              new List <System.Drawing.Bitmap> {
                GameResources.SourceSansPro_img
            });

            skin.DefaultFont = bmpfont;
            var canvas = new GameCanvas(skin, game)
            {
                Renderer = renderer
            };

            canvas.SpriteLoading = new Sprite(canvas);
            canvas.SpriteLoading.SetImage(GameResources.loading);
            canvas.SpriteLoading.IsHidden             = true;
            canvas.SpriteLoading.IsTabable            = false;
            canvas.SpriteLoading.KeyboardInputEnabled = false;
            canvas.SpriteLoading.MouseInputEnabled    = false;
            canvas.SpriteLoading.SetSize(32, 32);
            canvas.SpriteLoading.RotationPoint.X = 16;
            canvas.SpriteLoading.RotationPoint.Y = 16;
            canvas.SpriteLoading.SetPosition(canvas.Width - 32, 0);

            var timeslider = new HorizontalIntSlider(canvas)
            {
                X                    = 120,
                Y                    = canvas.Height - 25,
                Width                = canvas.Width - 120 * 2,
                Height               = 25,
                IsTabable            = false,
                IsHidden             = true,
                KeyboardInputEnabled = false,
                Name                 = "timeslider",
            };
            var btnfastfoward = new ImageButton(canvas)
            {
                X                    = timeslider.Right,
                Y                    = canvas.Height - 25,
                Width                = 24,
                Height               = 24,
                IsTabable            = false,
                IsHidden             = true,
                KeyboardInputEnabled = false,
                Name                 = "btnfastforward"
            };

            btnfastfoward.SetImage(GameResources.fast_forward, GameResources.fast_forward_white);
            var btnslowmo = new ImageButton(canvas)
            {
                X                    = timeslider.X - 24,
                Y                    = canvas.Height - 25,
                Width                = 24,
                Height               = 24,
                IsTabable            = false,
                IsHidden             = true,
                KeyboardInputEnabled = false,
                Name                 = "btnslowmo"
            };

            btnslowmo.SetImage(GameResources.rewind, GameResources.rewind_white);
            btnslowmo.Clicked     += (o, e) => { game.PlaybackDown(); };
            btnfastfoward.Clicked += (o, e) => { game.PlaybackUp(); };

            timeslider.ValueChanged += canvas.timeslider_ValueChanged;
            var labelTrackName = new Label(canvas)
            {
                TextColor = System.Drawing.Color.Black,
                Dock      = Pos.Left,
                Margin    = new Margin(5, 0, 0, 0),
                Name      = "trackname"
            };
            Label labeliteration = new Label(canvas);

            labeliteration.Name = "labeliterations";
            labeliteration.Font = new Font(renderer, "Arial", 18);
            labeliteration.SetText("");
            labeliteration.TextColor = Color.Black;
            Align.PlaceDownLeft(labeliteration, labelTrackName);

            var toprightcontainer = new ControlBase(canvas)
            {
                Dock              = Pos.Right,
                Width             = 150,
                Height            = 300,
                MouseInputEnabled = false
            };
            var fps = new Label(toprightcontainer)
            {
                TextColor = Color.Black, Name = "fps"
            };
            var labelppf = new Label(toprightcontainer)
            {
                TextColor = Color.Black, Name = "ppf"
            };
            var labelPlayback = new Label(toprightcontainer)
            {
                TextColor = Color.Black, Name = "labelplayback"
            };
            var flagtime = new Label(canvas)
            {
                TextColor = Color.Black, Name = "flagtime"
            };
            var textheight = renderer.MeasureText(skin.DefaultFont, "@").Y + 3;

            labelppf.SetPosition(0, textheight);
            labelPlayback.SetPosition(0, textheight * 2);

            var vslider = new VerticalSlider(canvas)
            {
                Min = 0.1f, Max = 24f, Value = game.Track.Zoom, IsTabable = false
            };

            vslider.ValueChanged += (o, e) =>
            {
                var slider = (VerticalSlider)o;
                var diff   = slider.Value - game.Track.Zoom;
                game.Zoom(diff, false);
            };
            vslider.SetPosition(0, (int)canvas.Height - 150);
            vslider.Name = "vslider";
            Align.AlignRight(vslider);
            vslider.Height = 125;
            return(canvas);
        }
Example #3
0
 public GameCanvas(SkinBase skin, GLWindow Game) : base(skin)
 {
     game           = Game;
     BoundsChanged += GameCanvas_BoundsChanged;
 }