Ejemplo n.º 1
0
        public Screen_TechTree(Base parent)
            : base(parent)
        {
            Gwen.Control.Button buttonOK = new Gwen.Control.Button(this);
            buttonOK.Text = "Back";
            buttonOK.Font = Program.fontButtonLabels;
            buttonOK.SetBounds(500, 500, 50, 50);
            buttonOK.Clicked += onButtonOKClick;

            Tech.Inint();
            SetSize(parent.Width, parent.Height);

            label      = new Gwen.Control.Label(this);
            label.Text = "Tech_Tree Probe";
            label.SetPosition(Program.percentW(85), Program.percentH(85));
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;

            img = new Gwen.Control.ImagePanel(this);


            updateDrawing();

            img.SetPosition(Program.percentW(0), Program.percentH(0));
            img.SetSize(Program.percentW(80), Program.percentH(80));
            //img.Clicked += new GwenEventHandler<ClickedEventArgs>(img_Clicked);
            img.MouseMoved += new GwenEventHandler <MovedEventArgs>(img_MouseMoved);
            img.MouseDown  += new GwenEventHandler <ClickedEventArgs>(img_MouseDown);
            img.MouseUp    += new GwenEventHandler <ClickedEventArgs>(img_MouseUp);
        }
Ejemplo n.º 2
0
        public ScreenSolarSystem(Base parent)
            : base(parent)
        {
            SetSize(parent.Width, parent.Height);

            Gwen.Control.Label label = new Gwen.Control.Label(this);
            label.Text = "Solar System";
            label.SetPosition(30, 30);
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;


            Gwen.Control.Button buttonOK = new Gwen.Control.Button(this);
            buttonOK.Text = "OK";
            buttonOK.Font = Program.fontButtonLabels;
            buttonOK.SetBounds(300, 500, 200, 50);
            buttonOK.Clicked += onButtonOKClick;


            Gwen.Control.Button buttonPlanet = new Gwen.Control.Button(this);
            buttonPlanet.Text = "Planet";
            buttonPlanet.Font = Program.fontButtonLabels;
            buttonPlanet.SetBounds(550, 500, 200, 50);
            buttonPlanet.Clicked += onButtonPlanetClick;
        }
Ejemplo n.º 3
0
        public TextureRefBox(Base parent, FSTextureReference Texture)
            : base(parent)
        {
            this.Texture = Texture;
            this.SetSize(160, 75);

            TextureName = new Label(this);
            TextureName.AutoSizeToContents = true;
            TextureName.SetPosition(10, 0);

            Defined = new LabeledCheckBox(this);
            Defined.Text = "Defined";
            Defined.SetPosition(10, 20);
            Defined.CheckChanged += new GwenEventHandler<EventArgs>(Defined_CheckChanged);

            panel = new GLImpTexturePanel(this);
            panel.SetSize(50, 50);
            panel.SetPosition(85, 0);
            panel.Clicked += delegate(Base sender, ClickedEventArgs args) {
                OpenTextureWindow otw = new OpenTextureWindow(SetTexture);
                otw.Show();
            };

            RefreshAll();
        }
Ejemplo n.º 4
0
        public ScreenPlanet(Base parent)
            : base(parent)
        {
            SetSize(parent.Width, parent.Height);

            Gwen.Control.Label label = new Gwen.Control.Label(this);
            label.Text = "Planet";
            label.SetPosition(30, 30);
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;

            int width;
            int height;

            Gwen.Control.WindowControl settingsWindow = new Gwen.Control.WindowControl(this);
            settingsWindow.Width             = parent.Width / 2;
            settingsWindow.Height            = parent.Height / 2;
            settingsWindow.SetPosition(width = parent.Width / 2 - settingsWindow.Width / 2, height = parent.Height / 2 - settingsWindow.Height / 2);

            Gwen.Control.Button buttonBack = new Gwen.Control.Button(settingsWindow);
            buttonBack.Text = "Back";
            buttonBack.Font = Program.fontButtonLabels;
            buttonBack.SetBounds(width / 100 * 8, height / 100 * 8, width / 3, height / 3);
            buttonBack.Clicked += onButtonBackClick;
        }
Ejemplo n.º 5
0
        public Screen_GameScreen(Base parent)
            : base(parent)
        {
            SetSize(parent.Width, parent.Height);

            label      = new Gwen.Control.Label(this);
            label.Text = "GAME!!!";
            label.SetPosition(Program.percentW(5), Program.percentH(5));
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;

            img = new Gwen.Control.ImagePanel(this);


            galaxyImage = new Bitmap(Program.percentW(100), Program.percentH(80), PixelFormat.Format32bppArgb);
            DrawControl = new DrawController(galaxyImage);

            updateDrawing();

            img.SetPosition(Program.percentW(0), Program.percentH(20));
            img.SetSize(Program.percentW(100), Program.percentH(80));
            //img.Clicked += new GwenEventHandler<ClickedEventArgs>(img_Clicked);
            img.MouseMoved += new GwenEventHandler <MovedEventArgs>(img_MouseMoved);
            img.MouseDown  += new GwenEventHandler <ClickedEventArgs>(img_MouseDown);
            img.MouseUp    += new GwenEventHandler <ClickedEventArgs>(img_MouseUp);

            Gwen.Control.Button buttonTech = new Gwen.Control.Button(this);
            buttonTech.Text = "Tech Tree";
            buttonTech.Font = Program.fontButtonLabels;
            buttonTech.SetBounds(Program.percentW(80), Program.percentH(84), Program.percentW(20), Program.percentH(8));
            buttonTech.Clicked += onButtonTechClick;

            Gwen.Control.Button buttonMenu = new Gwen.Control.Button(this);
            buttonMenu.Text = "Menu";
            buttonMenu.Font = Program.fontButtonLabels;
            buttonMenu.SetBounds(Program.percentW(0), Program.percentH(0), Program.percentW(13), Program.percentH(8));
            buttonMenu.Clicked += onButtonMenuClick;

            Gwen.Control.Button buttonSolarSystem = new Gwen.Control.Button(this);
            buttonSolarSystem.Text = "Solar System";
            buttonSolarSystem.Font = Program.fontButtonLabels;
            buttonSolarSystem.SetBounds(Program.percentW(0), Program.percentH(92), Program.percentW(19), Program.percentH(8));
            buttonSolarSystem.Clicked += onSolarSystemClick;

            Gwen.Control.Button buttonStep = new Gwen.Control.Button(this);
            buttonStep.Text = "Step";
            buttonStep.Font = Program.fontButtonLabels;
            buttonStep.SetBounds(Program.percentW(90), Program.percentH(92), Program.percentW(10), Program.percentH(8));
            buttonStep.Clicked += onSolarSystemClick;

            buttonCombat      = new Gwen.Control.Button(this);
            buttonCombat.Text = "Combat";
            buttonCombat.Font = Program.fontButtonLabels;
            buttonCombat.SetBounds(Program.percentW(19), Program.percentH(92), Program.percentW(18), Program.percentH(8));
            buttonCombat.Clicked += onCombatClick;
        }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
0
        public ConnectingWindow()
            : base(MainCanvas.GetCanvas())
        {
            this.SetSize(400, 100);
            this.IsClosable = false;
            this.DisableResizing();
            this.ClampMovement = true;
            Label message = new Label(this);
            message.Text = "Downloading Content";
            message.AutoSizeToContents = true;
            message.SetPosition(10, 10);

            bar = new ProgressBar(this);
            bar.SetPosition(10, 40);
            bar.SetSize(300, 20);
            bar.IsHorizontal = true;
            bar.AutoLabel = true;
        }
Ejemplo n.º 8
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;
        }
Ejemplo n.º 9
0
        public PackageEditor(Package package)
            : base(DevelopmentMenu.Instance)
        {
            this.Resource = package;
            this.SetPosition((int)MouseManager.GetMousePositionWindows().X, (int)MouseManager.GetMousePositionWindows().Y);

            Label lblName = new Label(this);
            lblName.AutoSizeToContents = true;
            lblName.Text = "Name";
            lblName.SetPosition(10, 10);

            TextBox tbName = new TextBox(this);
            tbName.SetPosition(50, 10);
            tbName.SetSize(150, 20);
            tbName.Text = Resource.Name;
            tbName.TextChanged += tbName_TextChanged;

            this.SetSize(220, 80);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        public Screen_MainMenu(Base parent) : base(parent)
        {
            SetSize(parent.Width, parent.Height);

            Gwen.Control.Label label = new Gwen.Control.Label(this);
            label.Text = "GalaxyConquest";
            label.SetPosition(70, 30);
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;


            Gwen.Control.Button buttonNewGame = new Gwen.Control.Button(this);
            buttonNewGame.Text = "New game";
            buttonNewGame.Font = Program.fontButtonLabels;
            buttonNewGame.SetBounds(300, 200, 200, 50);
            buttonNewGame.Pressed += onButtonNewGameClick;

            Gwen.Control.Button buttonLoadGame = new Gwen.Control.Button(this);
            buttonLoadGame.Text = "Load game";
            buttonLoadGame.Disable();
            buttonLoadGame.Font = Program.fontButtonLabels;
            buttonLoadGame.SetBounds(300, 260, 200, 50);

            Gwen.Control.Button buttonSettings = new Gwen.Control.Button(this);
            buttonSettings.Text = "Settings";
            buttonSettings.Font = Program.fontButtonLabels;
            buttonSettings.SetBounds(300, 320, 200, 50);
            buttonSettings.Pressed += onButtonSettingsClick;

            Gwen.Control.Button buttonCredits = new Gwen.Control.Button(this);
            buttonCredits.Text = "Credits";
            buttonCredits.Font = Program.fontButtonLabels;
            buttonCredits.SetBounds(300, 380, 200, 50);

            Gwen.Control.Button buttonQuit = new Gwen.Control.Button(this);
            buttonQuit.Text = "Quit";
            buttonQuit.Font = Program.fontButtonLabels;
            buttonQuit.SetBounds(300, 440, 200, 50);
            buttonQuit.Pressed += onButtonQuitClick;
        }
Ejemplo n.º 12
0
        public Screen_NewGame(Base parent)
            : base(parent)
        {
            SetSize(parent.Width, parent.Height);


            label      = new Gwen.Control.Label(this);
            label.Text = "New game";
            label.SetPosition(Program.percentW(5), Program.percentH(5));
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;

            Gwen.Control.Button buttonBack = new Gwen.Control.Button(this);
            buttonBack.Text = "Back";
            buttonBack.Font = Program.fontButtonLabels;
            buttonBack.SetBounds(Program.percentW(5), Program.percentH(87), Program.percentW(18), Program.percentH(8));
            buttonBack.Clicked += onButtonBackClick;

            Gwen.Control.Button buttonNewGame = new Gwen.Control.Button(this);
            buttonNewGame.Text = "New game";
            buttonNewGame.Font = Program.fontButtonLabels;
            buttonNewGame.SetBounds(Program.percentW(77), Program.percentH(87), Program.percentW(18), Program.percentH(8));
            buttonNewGame.Clicked += onButtonNewGameClick;

            imageGalaxyType       = new Gwen.Control.ImagePanel(this);
            imageGalaxyType.Image = Properties.Resources.icon_newgame_spiral;
            imageGalaxyType.SetBounds(Program.percentW(20), Program.percentH(20), Program.percentW(25), Program.percentH(25));

            Gwen.Control.Button buttonGalaxyTypeLeft = new Gwen.Control.Button(this);
            buttonGalaxyTypeLeft.Text = "<";
            buttonGalaxyTypeLeft.SetBounds(Program.percentW(20), Program.percentH(40), Program.percentW(5), Program.percentH(5));
            buttonGalaxyTypeLeft.Clicked += onButtonGalaxyTypeLeftClick;

            Gwen.Control.Button buttonGalaxyTypeRight = new Gwen.Control.Button(this);
            buttonGalaxyTypeRight.Text = ">";
            buttonGalaxyTypeRight.SetBounds(Program.percentW(40), Program.percentH(40), Program.percentW(5), Program.percentH(5));
            buttonGalaxyTypeRight.Clicked += onButtonGalaxyTypeRightClick;
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
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);
            }
        }
Ejemplo n.º 16
0
        public Screen_Settings(Base parent)
            : base(parent)
        {
            SetSize(parent.Width, parent.Height);

            Gwen.Control.Label label = new Gwen.Control.Label(this);
            label.Text = "Settings";
            label.SetPosition(30, 30);
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;

            Gwen.Control.WindowControl settingsWindow = new Gwen.Control.WindowControl(this);
            settingsWindow.Width  = parent.Width / 2;
            settingsWindow.Height = parent.Height / 2;
            settingsWindow.SetPosition(parent.Width / 2 - settingsWindow.Width / 2, parent.Height / 2 - settingsWindow.Height / 2);

            Gwen.Control.Label musicLabel = new Gwen.Control.Label(settingsWindow);
            musicLabel.Text = "Music:";
            musicLabel.SetPosition(parent.Width / 10, parent.Height / 10);
            musicLabel.TextColor = Color.FromArgb(255, 0, 0, 0);
            musicLabel.Font      = Program.fontText;

            Gwen.Control.HorizontalSlider musicSlider = new Gwen.Control.HorizontalSlider(settingsWindow);
            musicSlider.SetPosition(parent.Width / 5, parent.Height / 10);
            musicSlider.SetSize(parent.Width / 10, musicLabel.Height);

            Gwen.Control.Label sfxLabel = new Gwen.Control.Label(settingsWindow);
            sfxLabel.Text = "SFX:";
            sfxLabel.SetPosition(parent.Width / 10, musicLabel.Y + musicLabel.Height);
            sfxLabel.TextColor = Color.FromArgb(255, 0, 0, 0);
            sfxLabel.Font      = Program.fontText;

            Gwen.Control.CheckBox sfxCheckBox = new Gwen.Control.CheckBox(settingsWindow);
            sfxCheckBox.SetPosition(parent.Width / 5, musicLabel.Y + musicLabel.Height);

            Gwen.Control.Label fpsLabel = new Gwen.Control.Label(settingsWindow);
            fpsLabel.Text = "FPS Limit:";
            fpsLabel.SetPosition(parent.Width / 10, sfxLabel.Y + sfxLabel.Height);
            fpsLabel.TextColor = Color.FromArgb(255, 0, 0, 0);
            fpsLabel.Font      = Program.fontText;

            Gwen.Control.HorizontalSlider fpsSlider = new Gwen.Control.HorizontalSlider(settingsWindow);
            fpsSlider.SetPosition(parent.Width / 5, sfxLabel.Y + sfxLabel.Height);
            fpsSlider.SetSize(parent.Width / 10, sfxLabel.Height);

            Gwen.Control.Label resolutionLabel = new Gwen.Control.Label(settingsWindow);
            resolutionLabel.Text = "Resolution:";
            resolutionLabel.SetPosition(parent.Width / 10, fpsLabel.Y + fpsLabel.Height);
            resolutionLabel.TextColor = Color.FromArgb(255, 0, 0, 0);
            resolutionLabel.Font      = Program.fontText;

            Gwen.Control.ComboBox resolution = new ComboBox(settingsWindow);
            resolution.AddItem("800x600");
            resolution.AddItem("1024x768");
            resolution.SetPosition(parent.Width / 5, fpsLabel.Y + fpsLabel.Height);
            resolution.SetSize(parent.Width / 10, resolutionLabel.Height);

            Gwen.Control.Label fullScreenLabel = new Gwen.Control.Label(settingsWindow);
            fullScreenLabel.Text = "Full screen:";
            fullScreenLabel.SetPosition(parent.Width / 10, resolutionLabel.Y + resolutionLabel.Height);
            fullScreenLabel.TextColor = Color.FromArgb(255, 0, 0, 0);
            fullScreenLabel.Font      = Program.fontText;

            Gwen.Control.CheckBox fullScreenCheckBox = new Gwen.Control.CheckBox(settingsWindow);
            fullScreenCheckBox.SetPosition(parent.Width / 5, resolutionLabel.Y + resolutionLabel.Height);
            if (fullScreen == true)
            {
                fullScreenCheckBox.Toggle();
            }
            fullScreenCheckBox.Checked   += fullScreenEnable;
            fullScreenCheckBox.UnChecked += fullScreenDisable;

            Gwen.Control.Button buttonOK = new Gwen.Control.Button(this);
            buttonOK.Text = "OK";
            buttonOK.Font = Program.fontButtonLabels;
            buttonOK.SetBounds(550, 500, 200, 50);
            buttonOK.Clicked += onButtonOKClick;
        }
Ejemplo n.º 17
0
		public static void Main(string[] args) {
			g_testEntries = AllTests.GetTests();
			testCount = g_testEntries.Count();

			testIndex = Math.Max(0, Math.Min(testIndex, testCount - 1));
			testSelection = testIndex;

			entry = g_testEntries[testIndex];
			test = entry.createFcn();

			GraphicsManager.SetWindowState(OpenTK.WindowState.Maximized);
			string title = String.Format("Box2D Version {0}.{1}.{2}", Settings._version.major, Settings._version.minor, Settings._version.revision);
			GraphicsManager.SetTitle(title);

			camera = new Camera2D();
			camera.OnRender += SimulationLoop;

			camera.SetZoom(12);
			camera.CenterOnTarget(true);
			camera.SetLocation(0, 0);

			GraphicsManager.Update += new GraphicsManager.Updater(GraphicsManager_Update);

			WindowControl glui = new WindowControl(MainCanvas.GetCanvas());
			glui.Dock = Gwen.Pos.Left;

			Label text = new Label(glui);
			text.Text = "Tests";
			text.SetPosition(10, 10);

			testList = new ListBox(glui);
			testList.RowSelected += delegate(Base sender, ItemSelectedEventArgs tlargs) {
				testSelection = testList.SelectedRowIndex;
			};
			foreach (TestEntry e in g_testEntries) {
				testList.AddRow(e.name, "", e);
			}
			testList.SelectedRowIndex = testSelection;
			testList.SetPosition(10, 30);
			testList.SetSize(170, 180);

			//glui.add_separator();
			Base SettingsBox = new Base(glui);
			SettingsBox.SetSize(200, 185);
			SettingsBox.SetPosition(0, 250);
			{
				NumericUpDown spinner = new NumericUpDown(SettingsBox);
				spinner.Text = "Vel Iters";
				spinner.Min = 1;
				spinner.Max = 500;
				spinner.ValueChanged += delegate(Base sender, EventArgs vcargs) {
					settings.velocityIterations = (int)spinner.Value;
				};
				spinner.Value = settings.velocityIterations;
				spinner.SetPosition(10, 10);

				NumericUpDown posSpinner = new NumericUpDown(SettingsBox);
				posSpinner.Min = 0;
				posSpinner.Max = 100;
				posSpinner.Text = "Pos Iters";
				posSpinner.ValueChanged += delegate(Base sender, EventArgs psargs) {
					settings.positionIterations = (int)posSpinner.Value;
				};
				posSpinner.Value = settings.positionIterations;
				posSpinner.SetPosition(10, 35);

				NumericUpDown hertzSpinner = new NumericUpDown(SettingsBox);
				hertzSpinner.Text = "Hertz";
				hertzSpinner.Min = 5;
				hertzSpinner.Max = 200;
				hertzSpinner.ValueChanged += delegate(Base sender, EventArgs hargs) {
					settingsHz = hertzSpinner.Value;
				};
				hertzSpinner.Value = settingsHz;
				hertzSpinner.SetPosition(10, 60);

				LabeledCheckBox scb = new LabeledCheckBox(SettingsBox);
				scb.Text = "Sleep";
				scb.CheckChanged += delegate(Base sender, EventArgs argsscb) {
					settings.enableSleep = scb.IsChecked;
				};
				scb.IsChecked = settings.enableSleep;
				scb.SetPosition(10, 85);

				LabeledCheckBox wsu = new LabeledCheckBox(SettingsBox);
				wsu.Text = "Warm Starting";
				wsu.CheckChanged += delegate(Base sender, EventArgs argsscb) {
					settings.enableWarmStarting = wsu.IsChecked;
				};
				wsu.IsChecked = settings.enableWarmStarting;
				wsu.SetPosition(10, 110);

				LabeledCheckBox toi = new LabeledCheckBox(SettingsBox);
				toi.Text = "Time of Impact";
				toi.CheckChanged += delegate(Base sender, EventArgs argsscb) {
					settings.enableContinuous = toi.IsChecked;
				};
				toi.IsChecked = settings.enableContinuous;
				toi.SetPosition(10, 135);

				LabeledCheckBox ssb = new LabeledCheckBox(SettingsBox);
				ssb.Text = "Sub-Stepping";
				ssb.CheckChanged += delegate(Base sender, EventArgs argsscb) {
					settings.enableSubStepping = ssb.IsChecked;
				};
				ssb.IsChecked = settings.enableSubStepping;
				ssb.SetPosition(10, 160);
			}

			Base drawPanel = new Base(glui);
			drawPanel.Dock = Gwen.Pos.Bottom;
			drawPanel.SetSize(200, 225);
			{
				LabeledCheckBox cbShapes = new LabeledCheckBox(drawPanel);
				cbShapes.Text = "Shapes";
				cbShapes.IsChecked = settings.drawShapes;
				cbShapes.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawShapes = cbShapes.IsChecked;
				};
				cbShapes.SetPosition(10, 10);



				//glui.add_checkbox_to_panel(drawPanel, "Joints", &settings.drawJoints);
				LabeledCheckBox cbJoints = new LabeledCheckBox(drawPanel);
				cbJoints.Text = "Joints";
				cbJoints.IsChecked = settings.drawJoints;
				cbJoints.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawJoints = cbJoints.IsChecked;
				};
				cbJoints.SetPosition(10, 30);



				//glui.add_checkbox_to_panel(drawPanel, "AABBs", &settings.drawAABBs);
				LabeledCheckBox cbAABBs = new LabeledCheckBox(drawPanel);
				cbAABBs.Text = "AABBs";
				cbAABBs.IsChecked = settings.drawAABBs;
				cbAABBs.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawAABBs = cbAABBs.IsChecked;
				};
				cbAABBs.SetPosition(10, 50);



				//glui.add_checkbox_to_panel(drawPanel, "Contact Points", &settings.drawContactPoints);
				LabeledCheckBox cbPoints = new LabeledCheckBox(drawPanel);
				cbPoints.Text = "Contact Points";
				cbPoints.IsChecked = settings.drawContactPoints;
				cbPoints.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawContactPoints = cbPoints.IsChecked;
				};
				cbPoints.SetPosition(10, 70);



				//glui.add_checkbox_to_panel(drawPanel, "Contact Normals", &settings.drawContactNormals);
				LabeledCheckBox cbNormals = new LabeledCheckBox(drawPanel);
				cbNormals.Text = "Contact Normals";
				cbNormals.IsChecked = settings.drawContactNormals;
				cbNormals.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawContactNormals = cbNormals.IsChecked;
				};
				cbNormals.SetPosition(10, 90);



				//glui.add_checkbox_to_panel(drawPanel, "Contact Impulses", &settings.drawContactImpulse);
				LabeledCheckBox cbImpulses = new LabeledCheckBox(drawPanel);
				cbImpulses.Text = "Contact Impulses";
				cbImpulses.IsChecked = settings.drawContactImpulse;
				cbImpulses.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawContactImpulse = cbImpulses.IsChecked;
				};
				cbImpulses.SetPosition(10, 110);



				//glui.add_checkbox_to_panel(drawPanel, "Friction Impulses", &settings.drawFrictionImpulse);
				LabeledCheckBox cbFriction = new LabeledCheckBox(drawPanel);
				cbFriction.Text = "Friction Impulses";
				cbFriction.IsChecked = settings.drawFrictionImpulse;
				cbFriction.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawFrictionImpulse = cbFriction.IsChecked;
				};
				cbFriction.SetPosition(10, 130);



				//glui.add_checkbox_to_panel(drawPanel, "Center of Masses", &settings.drawCOMs);
				LabeledCheckBox cbMasses = new LabeledCheckBox(drawPanel);
				cbMasses.Text = "Center of Masses";
				cbMasses.IsChecked = settings.drawCOMs;
				cbMasses.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawCOMs = cbMasses.IsChecked;
				};
				cbMasses.SetPosition(10, 150);



				//glui.add_checkbox_to_panel(drawPanel, "Statistics", &settings.drawStats);
				LabeledCheckBox cbStatistics = new LabeledCheckBox(drawPanel);
				cbStatistics.Text = "Statistics";
				cbStatistics.IsChecked = settings.drawStats;
				cbStatistics.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawStats = cbStatistics.IsChecked;
				};
				cbStatistics.SetPosition(10, 170);



				//glui.add_checkbox_to_panel(drawPanel, "Profile", &settings.drawProfile);
				LabeledCheckBox cbProfile = new LabeledCheckBox(drawPanel);
				cbProfile.Text = "Profile";
				cbProfile.IsChecked = settings.drawProfile;
				cbProfile.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawProfile = cbProfile.IsChecked;
				};
				cbProfile.SetPosition(10, 190);
			}


			Base Buttons = new Base(glui);
			Buttons.Dock = Gwen.Pos.Bottom;
			Buttons.Height = 100;
			{
				Button btnPause = new Button(Buttons);
				btnPause.Text = "Pause";
				btnPause.IsToggle = true;
				btnPause.SetPosition(10, 10);
				btnPause.ToggleState = settings.pause;
				btnPause.Clicked += delegate(Base sender, ClickedEventArgs evargs) {
					settings.pause = btnPause.ToggleState;
				};

				Button btnSS = new Button(Buttons);
				btnSS.Text = "Single Step";
				btnSS.SetPosition(10, 40);
				btnSS.Clicked += delegate(Base sender, ClickedEventArgs evargs) {
					SingleStep();
				};

				Button btnRestart = new Button(Buttons);
				btnRestart.Text = "Restart";
				btnRestart.SetPosition(10, 70);
				btnRestart.Clicked += delegate(Base sender, ClickedEventArgs evargs) {
					Restart();
				};
			}

			glui.SetSize(200, 300);			
			GraphicsManager.Start();
		}
Ejemplo n.º 18
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();
        }