Exemple #1
0
 public void OnUpdate(EventArgs e)
 {
     if ((DateTime.UtcNow - LastCheck).TotalSeconds >= 1)
     {
         GuiSkin.Text = Utils.GetTitle(false);
         GuiSkin.Invalidate();
     }
 }
Exemple #2
0
        protected override void Initialize()
        {
            base.Initialize();
            this.spriteBatch  = new SpriteBatch(this.GraphicsDevice);
            this.Window.Title = "Paladin Rescue Team";

            Resolution resolution = Utilities.GetSupportedResolutions().Last();


            // Init call mandated by Auxiliary library.
            Root.Init(this, this.spriteBatch, this.graphics, resolution);
            Root.BeforeLastDraw = () =>
            {
                UX.Clear();
                Tooltip.Clear();
            };
            Writer.SpriteBatch = this.spriteBatch;


            if (this.ImmediatelyFullscreenize)
            {
                Root.SetResolution(Utilities.GetSupportedResolutions().FindLast(m => true));
                Root.IsFullscreen = true;
            }


            Assets.LoadAll(Content);
            SFX.Load(Content);



            Primitives.Fonts.Add(FontFamily.Small,
                                 new FontGroup(Assets.FontLittle, Assets.FontLittleItalic, Assets.FontLittleBold,
                                               Assets.FontLittleBoldItalic));
            Primitives.Fonts.Add(FontFamily.Normal,
                                 new FontGroup(Assets.FontNormal, Assets.FontNormal, Assets.FontNormalBold, Assets.FontNormalBold));
            Primitives.Fonts.Add(FontFamily.Big,
                                 new FontGroup(Assets.FontBig, Assets.FontBig, Assets.FontBigBold, Assets.FontBigBold));


            // Make the buttons orange.
            GuiSkin mainSkin = GuiSkin.DefaultSkin;

            mainSkin.Font = Assets.FontNormal;
            mainSkin.InnerBorderThickness         = 1;
            mainSkin.OuterBorderThickness         = 1;
            mainSkin.GreyBackgroundColor          = Color.DarkOrange;
            mainSkin.GreyBackgroundColorMouseOver = Color.Orange;
            mainSkin.InnerBorderColor             = Color.Red;
            mainSkin.InnerBorderColorMouseOver    = Color.Red;
            mainSkin.InnerBorderColorMousePressed = Color.DarkRed;

            Root.Display_DisplayFpsCounter      = false;
            Root.Display_DisplayFpsCounterWhere = new Vector2(5, 55);
            // Go to main menu.
            Root.PushPhase(new MainMenuPhase());
        }
Exemple #3
0
        private void Gui_Load(object sender, EventArgs e)
        {
            bool HackyWorkAround = true;

            TextBox_Input.ForeColor = System.Drawing.Color.FromArgb(Convert.ToByte(TShock.Config.BroadcastRGB[0]), Convert.ToByte(TShock.Config.BroadcastRGB[1]), Convert.ToByte(TShock.Config.BroadcastRGB[2]));

            Action <string> WriteToTextbox = (s) =>
            {
                bool HasConsoleCleared = false;
                if (s.Length > 0)
                {
                    if (s == ": ")
                    {
                        return;
                    }

                    if ((int)s[s.Length - 1] == 52) //Clear console
                    {
                        TextBoxConsoleOutput.MainThreadInvoke(() =>
                        {
                            HasConsoleCleared = true;
                            if (HackyWorkAround)
                            {
                                HackyWorkAround = false;
                                TextBoxConsoleOutput.AppendText(string.Empty);
                                return;
                            }
                            TextBoxConsoleOutput.Clear();
                        });
                        GuiSkin.Text = Console.Title;
                        GuiSkin.Invalidate();
                    }
                    TextBoxConsoleOutput.MainThreadInvoke(() =>
                    {
                        TextBoxConsoleOutput.Append(s, Console.ForegroundColor);
                        if (HasConsoleCleared)
                        {
                            TextBoxConsoleOutput.Append(string.Empty);
                        }
                    });
                }
            };

            main.ConsoleInput = new TaskReader(Console.In);
            Console.SetOut(new TaskWriter(Console.Out, WriteToTextbox));                        //Redirect console output to RichTextBox
            Console.SetIn(main.ConsoleInput);                                                   //Redirect console input to textbox

            ListBoxUsernames.ListBoxSkin.MouseDoubleClick += ListBoxUsernames_MouseDoubleClick; //Add here because the designer removes the code (because of the .ListBX).
            pictureBox1.MouseDown  += new MouseEventHandler(pictureBox1_MouseDown);
            pictureBox1.MouseUp    += new MouseEventHandler(pictureBox1_MouseUp);
            pictureBox1.MouseMove  += new MouseEventHandler(pictureBox1_MouseMove);
            pictureBox1.MouseWheel += new MouseEventHandler(pictureBox1_MouseWheel);
            pictureBox1.SizeMode    = PictureBoxSizeMode.Zoom;
        }
Exemple #4
0
        public SelectDemoScreen(GuiSkin skin, IDictionary <string, DemoBase> demos, Action <string> loadDemo, Action exitGameAction)
            : base(skin)
        {
            _demos    = demos;
            _loadDemo = loadDemo;
            //var button = Skin.Create<GuiButton>("white-button", c =>
            //{
            //    c.Position = new Vector2(670, 430);
            //    c.Size = new Size2(120, 42);
            //    c.Text = "Next Demo";
            //});
            //var canvas = new GuiCanvas
            //{
            //    Controls = { button }
            //};

            //Controls.Add(canvas);
            //button.Clicked += (sender, args) => onNextDemo();

            var dialog = Skin.Create <GuiDialog>("dialog");
            var grid   = new GuiUniformGrid {
                Columns = 3
            };

            foreach (var demo in _demos.Values.OrderBy(i => i.Name))
            {
                var button = Skin.Create <GuiButton>("white-button", c =>
                {
                    c.Text     = demo.Name;
                    c.Margin   = new Thickness(4);
                    c.Clicked += (sender, args) => LoadDemo(demo);
                });
                grid.Controls.Add(button);
            }

            // Close button
            var atlas             = skin.TextureAtlases[0];
            var closeButtonRegion = atlas?.GetRegion("buttonRound_close");

            if (closeButtonRegion != null)
            {
                var closeButton = Skin.Create <GuiButton>("white-button", c =>
                {
                    c.IconRegion = closeButtonRegion;
                    c.Margin     = new Thickness(4);
                    c.Clicked   += (sender, args) => exitGameAction();
                });
                grid.Controls.Add(closeButton);
            }

            dialog.Controls.Add(grid);
            Controls.Add(dialog);
            //DialogDemo();
        }
Exemple #5
0
 public void ServerLeave(LeaveEventArgs e)
 {
     ListBoxUsernames.MainThreadInvoke(() =>
     {
         ListBoxUsernames.Clear();
         ListBoxUsernames.AddRange((from tsplr in TShock.Players where tsplr != null && tsplr.Index != e.Who orderby tsplr.Name select tsplr.Name).ToArray());
     });
     if (TShock.Utils.ActivePlayers() == 1)
     {
         GuiSkin.Text = Utils.GetTitle(true);
         GuiSkin.Invalidate();
     }
 }
Exemple #6
0
        protected override void LoadContent()
        {
            ViewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480);

            var skin        = GuiSkin.FromFile(Content, @"Raw/adventure-gui-skin.json");
            var guiRenderer = new GuiSpriteBatchRenderer(GraphicsDevice, ViewportAdapter.GetScaleMatrix);

            _guiSystem = new GuiSystem(ViewportAdapter, guiRenderer)
            {
                Screens = { new SelectDemoScreen(skin, _demos, LoadDemo) }
            };

            //LoadDemo(_demoIndex);
        }
        protected override void Initialize()
        {
            base.Initialize();
            this.spriteBatch  = new SpriteBatch(this.GraphicsDevice);
            this.Window.Title = "Existential Risk Prevention Authority";

            Resolution resolution = new Resolution(DEFAULTWIDTH, DEFAULTHEIGHT);
            bool       fullscreen = false;


            // Init call mandated by Auxiliary library.
            Root.Init(this, this.spriteBatch, this.graphics, resolution, fullscreen);


            if (this.ImmediatelyFullscreenize)
            {
                Root.SetResolution(Utilities.GetSupportedResolutions().FindLast(m => true));
                Root.IsFullscreen = true;
            }


            Assets.LoadAll(Content);


            Primitives.Fonts.Add(FontFamily.Small,
                                 new FontGroup(Assets.FontLittle, Assets.FontLittleItalic, Assets.FontLittleBold,
                                               Assets.FontLittleBoldItalic));
            Primitives.Fonts.Add(FontFamily.Normal,
                                 new FontGroup(Assets.FontNormal, Assets.FontNormal, Assets.FontNormalBold, Assets.FontNormalBold));
            Primitives.Fonts.Add(FontFamily.Big,
                                 new FontGroup(Assets.FontBig, Assets.FontBig, Assets.FontBigBold, Assets.FontBigBold));


            // Make the buttons orange.
            GuiSkin mainSkin = GuiSkin.DefaultSkin;

            mainSkin.Font = Assets.FontNormal;
            mainSkin.InnerBorderThickness         = 1;
            mainSkin.OuterBorderThickness         = 1;
            mainSkin.GreyBackgroundColor          = Color.LightBlue;
            mainSkin.GreyBackgroundColorMouseOver = Color.Azure;

            /*
             * mainSkin.InnerBorderColor = Color.Red;
             * mainSkin.InnerBorderColorMouseOver = Color.Red;
             * mainSkin.InnerBorderColorMousePressed = Color.DarkRed;*/

            // Go to main menu.
            Root.PushPhase(new MainPhase());
        }
        protected GuiControl(GuiSkin skin)
        {
            Skin      = skin;
            Color     = Color.White;
            TextColor = Color.White;
            IsEnabled = true;
            IsVisible = true;
            Controls  = new GuiControlCollection(this);
            Origin    = Vector2.Zero;

            var style = skin?.GetStyle(GetType());

            style?.Apply(this);
        }
        protected override void LoadContent()
        {
            var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480);

            _camera = new OrthographicCamera(viewportAdapter);

            var skin        = GuiSkin.FromFile(Content, @"Raw/adventure-gui-skin.json");
            var guiRenderer = new GuiSpriteBatchRenderer(GraphicsDevice, _camera.GetViewMatrix);

            _guiSystem = new GuiSystem(viewportAdapter, guiRenderer)
            {
                Screens = { new GuiLayoutScreen(skin, GraphicsDevice) }
            };
        }
        public BindingScreen(GuiSkin skin, ViewModel viewModel)
            : base(skin)
        {
            var button = new GuiButton(skin);

            Controls.Add(button);

            button.SetBinding(nameof(GuiButton.Text), nameof(viewModel.Name));
            button.Clicked += (sender, args) =>
            {
                viewModel.Name = "alliestrasza";
            };

            BindingContext = viewModel;
        }
Exemple #11
0
        protected override void LoadContent()
        {
            IsMouseVisible = false;

            // _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, _graphicsDeviceManager.PreferredBackBufferWidth, _graphicsDeviceManager.PreferredBackBufferHeight);
            _viewportAdapter = new WindowViewportAdapter(Window, GraphicsDevice);

            _skin = GuiSkin.FromFile(Content, @"Content/adventure-gui-skin.json", typeof(MyPanel));
            var guiRenderer = new GuiSpriteBatchRenderer(GraphicsDevice, _viewportAdapter.GetScaleMatrix);

            var viewModel = new ViewModel();

            LoadGuiButtonScreen();

            //_screen = GuiScreen.FromFile(Content, "Content/test-addition-screen.json", typeof(MyPanel));
            //Window.ClientSizeChanged += OnClientSizeChanged;

            //_screen = GuiScreen.FromFile(Content, "Content/adventure-gui-screen.json", typeof(MyPanel));

            //var listBox = _screen.FindControl<GuiListBox>("Listbox");
            //listBox.Items.Add(new { Name = "Hello World 1" });
            //listBox.Items.Add(new { Name = "Hello World 2" });
            //listBox.Items.Add(new { Name = "Hello World 3" });
            //listBox.Items.Add(new { Name = "Hello World 4" });

            //var comboBox = _screen.FindControl<GuiComboBox>("ComboBox");
            //comboBox.Items.Add(new { Name = "Hello World 1" });
            //comboBox.Items.Add(new { Name = "Hello World 2" });
            //comboBox.Items.Add(new { Name = "Hello World 3" });
            //comboBox.Items.Add(new { Name = "Hello World 4" });

            //var submit = _screen.FindControl<GuiSubmit>("FormSubmit");
            //submit.SetBinding(nameof(GuiButton.Text), nameof(viewModel.Name));
            //submit.Clicked += OnFormSubmitClicked;
            //submit.Clicked += (s, e) => { viewModel.Name = viewModel.Name == "Change" ? "Alistrasza" : "Change"; };

            _screen.BindingContext = viewModel;

            _guiSystem = new GuiSystem(_viewportAdapter, guiRenderer)
            {
                Screens =
                {
                    _screen
                    // new BindingScreen(_skin, viewModel)
                }
            };
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader.ValueType == typeof(string))
            {
                var assetName = (string)reader.Value;

                // TODO: Load this using the ContentManager instead.
                using (var stream = TitleContainer.OpenStream(assetName))
                {
                    var skin = GuiSkin.FromStream(_contentManager, stream);
                    _skinService.Skin = skin;
                    return(skin);
                }
            }

            throw new InvalidOperationException($"{nameof(GuiSkinJsonConverter)} can only convert from a string");
        }
Exemple #13
0
        protected GuiControl(GuiSkin skin)
        {
            Skin      = skin;
            Color     = Color.White;
            TextColor = Color.White;
            IsEnabled = true;
            IsVisible = true;
            Controls  = new GuiControlCollection(this)
            {
                ItemAdded   = x => UpdateRootIsLayoutRequired(),
                ItemRemoved = x => UpdateRootIsLayoutRequired()
            };
            Origin = Vector2.Zero;

            var style = skin?.GetStyle(GetType());

            style?.Apply(this);
        }
Exemple #14
0
        public GuiManager(ContentManager contentManager, GameWindow gameWindow, GraphicsDevice graphicsDevice, string defaultSkinFileName)
        {
            this.contentManager = contentManager;
            this.gameWindow     = gameWindow;
            this.graphicsDevice = graphicsDevice;

            int width  = (int)(DEFAULT_GUI_HEIGHT * graphicsDevice.Viewport.AspectRatio);
            int height = DEFAULT_GUI_HEIGHT;

            viewportAdapter = new BoxingViewportAdapter(gameWindow, graphicsDevice, width, height, width, 0); //Fixed height, any width
            guiCamera       = new Camera2D(viewportAdapter);
            guiRenderer     = new GuiSpriteBatchRenderer(graphicsDevice, guiCamera.GetViewMatrix);
            guiSystem       = new GuiSystem(viewportAdapter, guiRenderer);

            DefaultSkin = GuiSkin.FromFile(contentManager, defaultSkinFileName);

            DefaultSkin.Cursor = null;
        }
Exemple #15
0
        protected override void LoadContent()
        {
            IsMouseVisible = false;

            _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, _graphicsDeviceManager.PreferredBackBufferWidth, _graphicsDeviceManager.PreferredBackBufferHeight);

            var skin        = GuiSkin.FromFile(Content, @"Content/adventure-gui-skin.json", typeof(MyPanel));
            var guiRenderer = new GuiSpriteBatchRenderer(GraphicsDevice, _viewportAdapter.GetScaleMatrix);

            var viewModel = new ViewModel();

            _guiSystem = new GuiSystem(_viewportAdapter, guiRenderer)
            {
                Screens =
                {
                    new BindingScreen(skin, viewModel)
                }
            };
        }
Exemple #16
0
        public MyScreen(GuiSkin skin)
            : base(skin)
        {
            Controls.Add(new GuiUniformGrid(Skin)
            {
                Controls =
                {
                    new GuiComboBox(Skin)
                    {
                        Name  = "ComboBox",
                        Items =
                        {
                            new { Name = "one",   Number   = 1 },
                            new { Name = "two",   Number   = 2 },
                            new { Name = "three", Number   = 3 }
                        },
                        SelectedIndex = 0,
                        NameProperty  = "Number"
                    },
                    new GuiListBox(Skin)
                    {
                        Name  = "ListBox",
                        Items =
                        {
                            "one",
                            "two",
                            "three"
                        }
                    }
                }
            });

            var listBox  = FindControl <GuiListBox>("ListBox");
            var comboBox = FindControl <GuiComboBox>("ComboBox");

            comboBox.SelectedIndexChanged += (sender, args) => listBox.SelectedIndex = comboBox.SelectedIndex;
            listBox.SelectedIndexChanged  += (sender, args) => comboBox.SelectedIndex = listBox.SelectedIndex;
        }
        public GuiLayoutScreen(GuiSkin skin, GraphicsDevice graphicsDevice)
            : base(skin)
        {
            _texture = new Texture2D(graphicsDevice, 1, 1);
            _texture.SetData(new[] { new Color(Color.Black, 0.5f) });

            var backgroundRegion = new TextureRegion2D(_texture);

            var uniformGrid = new GuiUniformGrid(skin)
            {
                Text     = "Uniform Grid",
                Controls =
                {
                    new GuiCanvas(skin)
                    {
                        Text     = "Canvas",
                        Controls =
                        {
                            Skin.Create <GuiButton>("white-button", c =>{ c.Text                                                  = "Reasonably long text"; c.Position = new Vector2(0,       0); }),
                            Skin.Create <GuiButton>("white-button", c =>{ c.Text                                                  = "Child 2"; c.Position              = new Vector2(50,     50); }),
                            Skin.Create <GuiButton>("white-button", c =>{ c.Text                                                  = "Child 3"; c.Position              = new Vector2(100,   100); }),
                        }
                    },
                    new GuiStackPanel(skin)
                    {
                        Text        = "Stack Panel (Vertical)",
                        Orientation = GuiOrientation.Vertical,
                        Controls    =
                        {
                            Skin.Create <GuiButton>("white-button", c =>{ c.Text                                                  = "Child 1"; c.HorizontalAlignment   = HorizontalAlignment.Centre; }),
                            Skin.Create <GuiButton>("white-button", c =>{ c.Text                                                  = "Child 2"; c.HorizontalAlignment   = HorizontalAlignment.Right;  }),
                            Skin.Create <GuiButton>("white-button", c =>{ c.Text                                                  = "Child 3"; c.HorizontalAlignment   = HorizontalAlignment.Left;   }),
                            Skin.Create <GuiButton>("white-button", c =>{ c.Text                                                  = "Child 4"; }),
                        }
                    },
                    new GuiStackPanel(skin)
                    {
                        Text        = "Stack Panel (Horizontal)",
                        Orientation = GuiOrientation.Horizontal,
                        Controls    =
                        {
                            Skin.Create <GuiButton>("white-button", c =>{ c.Text                                                  = "Child 1"; c.Width                 =80; c.VerticalAlignment = VerticalAlignment.Centre; }),
                            Skin.Create <GuiButton>("white-button", c =>{ c.Text                                                  = "Child 2"; c.Width                 =80; c.VerticalAlignment = VerticalAlignment.Top;    }),
                            Skin.Create <GuiButton>("white-button", c =>{ c.Text                                                  = "Child 3"; c.Width                 =80; c.VerticalAlignment = VerticalAlignment.Bottom; }),
                            Skin.Create <GuiButton>("white-button", c =>{ c.Text                                                  = "Child 3"; c.Width                 =          80; }),
                        }
                    },
                    new GuiListBox(skin)
                    {
                        Name = "DisplayModesListBox"
                    }
                }
            };

            //var stackPanel = ;
            //stackPanel.PerformLayout();

            Controls.Add(uniformGrid);

            var listBox = FindControl <GuiListBox>("DisplayModesListBox");

            listBox.Items.AddRange(GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Select(i => $"{i.Width}x{i.Height}"));
        }
 public GuiComboBox(GuiSkin skin)
     : base(skin)
 {
 }
Exemple #19
0
 public GuiSubmit(GuiSkin skin)
     : base(skin)
 {
 }
 protected GuiItemsControl(GuiSkin skin)
     : base(skin)
 {
 }
 public GuiImage(GuiSkin skin)
     : base(skin)
 {
 }
Exemple #22
0
 public GuiTextBox(GuiSkin skin, string text = null)
     : base(skin)
 {
     Text = text ?? string.Empty;
 }
 protected GuiLayoutControl(GuiSkin skin)
     : base(skin)
 {
     HorizontalAlignment = HorizontalAlignment.Stretch;
     VerticalAlignment   = VerticalAlignment.Stretch;
 }
Exemple #24
0
 public void OnPostInit(EventArgs e)
 {
     GuiSkin.Text = Utils.GetTitle(false);
     GuiSkin.Invalidate();
 }
 public GuiImage(GuiSkin skin, TextureRegion2D image)
     : base(skin)
 {
     BackgroundRegion = image;
 }
Exemple #26
0
 public GuiCheckBox(GuiSkin skin)
     : base(skin)
 {
 }
 public GuiStackPanel(GuiSkin skin)
     : base(skin)
 {
     HorizontalAlignment = HorizontalAlignment.Centre;
     VerticalAlignment   = VerticalAlignment.Centre;
 }
Exemple #28
0
 public GuiButton(GuiSkin skin)
     : base(skin)
 {
 }
 public GuiListBox(GuiSkin skin)
     : base(skin)
 {
 }
 public LoadingScreen(PocketRogue game, GuiSkin skin) : base(skin)
 {
 }