Esempio n. 1
0
        Base ConstructFindGame()
        {
            Base FindGame = new Base(MainCanvas.GetCanvas());
            FindGame.SetSize(300, 300);

            Label EnterIP = new Label(FindGame);
            EnterIP.AutoSizeToContents = true;
            EnterIP.SetText("Enter an IP:");
            EnterIP.SetPosition(10, 10);

            TextBox IPAddress = new TextBox(FindGame);
            IPAddress.SetText("127.0.0.1");
            IPAddress.SetPosition(10, 40);
            IPAddress.SetSize(260, 20);

            TextBox Port = new TextBox(FindGame);
            Port.SetText("54987");
            Port.SetPosition(10, 70);
            Port.SetSize(260, 20);

            Button Connect = new Button(FindGame);
            Connect.SetText("Connect");
            Connect.SetPosition(10, 200);
            Connect.SetSize(200, 20);
            Connect.Clicked += delegate(Base sender, ClickedEventArgs args) {
                Program.Connect(IPAddress.Text, Int32.Parse(Port.Text));
                MainMenu.Hide();
                FindGame.Hide();

                Connecting.Show();
            };

            Button Back = new Button(FindGame);
            Back.SetText("Back");
            Back.SetPosition(10, 225);
            Back.SetSize(200, 20);
            Back.Clicked += delegate(Base sender, ClickedEventArgs args) {
                Mode = MenuMode.MainMenu;
                MainMenu.Show();
                FindGame.Hide();
            };

            return FindGame;
        }
Esempio n. 2
0
        public void Initialize()
        {
            Status = new Label(MainCanvas.Instance);
            Status.SetPosition(10, 10);
            Status.SetText("Waiting for opponent...");
            Status.MakeColorBright();

            Button cancel = new Button(MainCanvas.Instance);
            cancel.SetText("Cancel");
            cancel.SetPosition(10, 40);
            cancel.Clicked += delegate(Base sender, ClickedEventArgs args) {
                Program.SwitchState(new MainMenu());
            };

            NetPeerConfiguration Configuration = new NetPeerConfiguration("Xanatos");
            Configuration.Port = 54987;
            Configuration.MaximumConnections = 1;
            Program.Connection = new NetServer(Configuration);
            Program.Connection.Start();
            Message.RegisterServer(Program.Connection);
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HSVColorPicker"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public HSVColorPicker(ControlBase parent)
            : base(parent)
        {
            MouseInputEnabled = true;
            SetSize(256, 128);
            //ShouldCacheToTexture = true;

            m_LerpBox = new ColorLerpBox(this);
            m_LerpBox.ColorChanged += ColorBoxChanged;
            m_LerpBox.Dock          = Pos.Left;

            m_ColorSlider = new ColorSlider(this);
            m_ColorSlider.SetPosition(m_LerpBox.Width + 15, 5);
            m_ColorSlider.ColorChanged += ColorSliderChanged;
            m_ColorSlider.Dock          = Pos.Left;

            m_After = new ColorDisplay(this);
            m_After.SetSize(48, 24);
            m_After.SetPosition(m_ColorSlider.X + m_ColorSlider.Width + 15, 5);

            m_Before = new ColorDisplay(this);
            m_Before.SetSize(48, 24);
            m_Before.SetPosition(m_After.X, 28);

            int x = m_Before.X;
            int y = m_Before.Y + 30;

            {
                Label label = new Label(this);
                label.SetText("R:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "RedBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged     += NumericTyped;
            }

            y += 20;

            {
                Label label = new Label(this);
                label.SetText("G:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "GreenBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged     += NumericTyped;
            }

            y += 20;

            {
                Label label = new Label(this);
                label.SetText("B:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "BlueBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged     += NumericTyped;
            }

            SetColor(DefaultColor);
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HSVColorPicker"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public HSVColorPicker(Base parent)
            : base(parent)
        {
            MouseInputEnabled = true;
            SetSize(256, 128);
            //ShouldCacheToTexture = true;

            m_LerpBox = new ColorLerpBox(this);
            m_LerpBox.ColorChanged += ColorBoxChanged;
            m_LerpBox.Dock = Pos.Left;

            m_ColorSlider = new ColorSlider(this);
            m_ColorSlider.SetPosition(m_LerpBox.Width + 15, 5);
            m_ColorSlider.ColorChanged += ColorSliderChanged;
            m_ColorSlider.Dock = Pos.Left;

            m_After = new ColorDisplay(this);
            m_After.SetSize(48, 24);
            m_After.SetPosition(m_ColorSlider.X + m_ColorSlider.Width + 15, 5);

            m_Before = new ColorDisplay(this);
            m_Before.SetSize(48, 24);
            m_Before.SetPosition(m_After.X, 28);

            int x = m_Before.X;
            int y = m_Before.Y + 30;

            {
                Label label = new Label(this);
                label.SetText("R:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "RedBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged += NumericTyped;
            }

            y += 20;

            {
                Label label = new Label(this);
                label.SetText("G:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "GreenBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged += NumericTyped;
            }

            y += 20;

            {
                Label label = new Label(this);
                label.SetText("B:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "BlueBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged += NumericTyped;
            }

            SetColor(DefaultColor);
        }
Esempio n. 5
0
        protected void CreateLabel(String text, TextBlock block, ref int x, ref int y, ref int lineHeight, bool noSplit)
        {
            // Use default font or is one set?
            Font font = Skin.DefaultFont;
            if (block.Font != null)
                font = block.Font;

            // This string is too long for us, split it up.
            Point p = Skin.Renderer.MeasureText(font, text);

            if (lineHeight == -1)
            {
                lineHeight = p.Y;
            }

            if (!noSplit)
            {
                if (x + p.X > Width)
                {
                    SplitLabel(text, font, block, ref x, ref y, ref lineHeight);
                    return;
                }
            }

            // Wrap
            if (x + p.X >= Width)
            {
                CreateNewline(ref x, ref y, lineHeight);
            }

            Label label = new Label(this);
            label.SetText(x == 0 ? text.TrimStart(' ') : text);
            label.TextColor = block.Color;
            label.Font = font;
            label.SizeToContents();
            label.SetPosition(x, y);

            //lineheight = (lineheight + pLabel.Height()) / 2;			

            x += label.Width;

            if (x >= Width)
            {
                CreateNewline(ref x, ref y, lineHeight);
            }
        }
Esempio n. 6
0
        private void setupUi()
        {
            renderer = new Gwen.Renderer.OpenTK();
            Gwen.Skin.Base skin = new Gwen.Skin.TexturedBase(renderer, "DefaultSkin.png");
            canvas = new Canvas(skin);
            canvas.SetSize(Width, Height);

            gwenInput = new Gwen.Input.OpenTK(this);
            gwenInput.Initialize(canvas);

            Mouse.ButtonDown += Mouse_ButtonDown;
            Mouse.ButtonUp += Mouse_ButtonUp;
            Mouse.Move += Mouse_Move;
            Mouse.WheelChanged += Mouse_Wheel;

            canvas.ShouldDrawBackground = true;
            canvas.BackgroundColor = System.Drawing.Color.FromArgb(122, 150, 170, 170);

            // controls
            radioCamera = new RadioButtonGroup(canvas);
            radioCamera.AutoSizeToContents = true;
            radioCamera.SetText("Тип камеры");
            radioCamera.AddOption("Свободная", "free");
            radioCamera.AddOption("Привязанная", "bound");
            radioCamera.SetSelection(0);
            radioCamera.SelectionChanged += radioCamera_SelectionChanged;

            // coord
            GroupBox posGroup = new GroupBox(canvas);
            posGroup.SetText("Позиция камеры");
            posGroup.SizeToChildren();
            posGroup.SetSize(150, 120);
            Gwen.Align.PlaceDownLeft(posGroup, radioCamera, 45);

            labelPosX = new Label(posGroup);
            labelPosY = new Label(posGroup);
            labelPosZ = new Label(posGroup);
            labelPosX.SetText("X: 0.0");
            labelPosY.SetText("Y: 1.0");
            labelPosZ.SetText("Z: 2.0");
            Gwen.Align.PlaceDownLeft(labelPosY, labelPosX, 5);
            Gwen.Align.PlaceDownLeft(labelPosZ, labelPosY, 5);

            // reset button
            Button resetCameraButton = new Gwen.Control.Button(posGroup);
            resetCameraButton.SetText("Сбросить позицию\nкамеры");
            resetCameraButton.Clicked += cameraReset_Clicked;
            resetCameraButton.SizeToContents();
            Gwen.Align.PlaceDownLeft(resetCameraButton, labelPosZ, 5);

            labelSpeed = new Label(canvas);
            Gwen.Align.PlaceDownLeft(labelSpeed, posGroup, 5);

            labelTips = new Label(canvas);
            labelTips.SetText(freeCameraTip + "\n\n" + nodeTransformTip);
            labelTips.SizeToContents();
            Gwen.Align.PlaceDownLeft(labelTips, labelSpeed, 15);

            statusBar = new Gwen.Control.StatusBar(canvas);
            statusBar.Dock = Gwen.Pos.Bottom;
        }
Esempio n. 7
0
        public override void InitUi(Canvas canvas) {
            _canvas = canvas;
            Game.BackgroundColor = Color.Black;

            var windowAction = new WindowControl(canvas, "Options", false);
            windowAction.DisableResizing();
            windowAction.IsClosable = false;
            windowAction.SetSize(200, 150);
            windowAction.SetPosition(0, 0);

            var addScriptButton = new Button(windowAction);
            addScriptButton.SetText("Ajouter un script");
            addScriptButton.Clicked += (sender, arguments) => ShowAddScriptWindow(canvas);
            Align.CenterHorizontally(addScriptButton);


            // Fenêtre sur les informations du script sélectionné 
            _windowInfoScript = new WindowControl(canvas, "Paramètres du script");
            _windowInfoScript.DisableResizing();
            _windowInfoScript.IsClosable = false;
            _windowInfoScript.SetSize(200, 300);
            _windowInfoScript.SetPosition(Game.GetWindowSize().X - _windowInfoScript.Width, 0);

            var labelX = new Label(_windowInfoScript);
            labelX.SetPosition(0, 10);
            labelX.SetText("X :");

            _uiInfoTextBoxPosX = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxPosX.SetSize(100, _uiInfoTextBoxPosX.Height);
            _uiInfoTextBoxPosX.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Position = new Vector2f((int) _uiInfoTextBoxPosX.Value,
                        _selectScript.RectShape.Position.Y);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxPosX, labelX, 10);

            var labelY = new Label(_windowInfoScript);
            labelY.SetText("Y :");
            Align.PlaceDownLeft(labelY, labelX, 10);

            _uiInfoTextBoxPosY = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxPosY.SetSize(100, _uiInfoTextBoxPosY.Height);
            _uiInfoTextBoxPosY.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Position = new Vector2f(_selectScript.RectShape.Position.X,
                        (int) _uiInfoTextBoxPosY.Value);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxPosY, labelY, 10);

            var labelSizeX = new Label(_windowInfoScript);
            labelSizeX.SetText("Largeur :");
            Align.PlaceDownLeft(labelSizeX, labelY, 10);

            _uiInfoTextBoxSizeX = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxSizeX.SetSize(100, _uiInfoTextBoxPosY.Height);
            _uiInfoTextBoxSizeX.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Size = new Vector2f((int)_uiInfoTextBoxSizeX.Value,
                        _selectScript.RectShape.Size.Y);
                    _selectScript.RectShape.Origin = new Vector2f(_selectScript.RectShape.Size.X / 2, _selectScript.RectShape.Size.Y / 2);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxSizeX, labelSizeX, 10);

            var labelSizeY = new Label(_windowInfoScript);
            labelSizeY.SetText("Hauteur :");
            Align.PlaceDownLeft(labelSizeY, labelSizeX, 10);

            _uiInfoTextBoxSizeY = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxSizeY.SetSize(100, _uiInfoTextBoxSizeY.Height);
            _uiInfoTextBoxSizeY.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Size = new Vector2f(_selectScript.RectShape.Size.X,
                        (int)_uiInfoTextBoxSizeY.Value);
                    _selectScript.RectShape.Origin = new Vector2f(_selectScript.RectShape.Size.X / 2, _selectScript.RectShape.Size.Y / 2);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxSizeY, labelSizeY, 10);

            _uiInfoScriptImage = new ImagePanel(_windowInfoScript);
            _uiInfoScriptImage.SetSize(75, 75);
            _uiInfoScriptImage.Hide();

            Align.PlaceDownLeft(_uiInfoScriptImage, _uiInfoTextBoxSizeY, 10);
            Align.CenterHorizontally(_uiInfoScriptImage);

            UnSelect_SelectScript();
        }