public TutorialMenu (Application application, Base parent) { this.application = application; this.parent = parent; window = new WindowControl (parent); window.DisableResizing(); window.Title = Localizer.Instance.GetValueForName("tutorial"); window.IsMoveable = false; window.Hide(); window.Height = parent.Height - (int) (parent.Height * 0.35); window.Y = (int) (parent.Height * 0.35) - 20; window.Width = parent.Width - 320; window.X = 280; scrollFrame = new ScrollControl (window); scrollFrame.AutoHideBars = true; scrollFrame.EnableScroll (false, true); scrollFrame.Width = window.Width - 12; scrollFrame.Height = window.Height - 32; updateTutorialText(Localizer.Instance.GetValueForName("tutorial_text")); ValidMessages = new[] { (int) MessageId.WindowResize, (int) MessageId.UpdateLocale }; application.MessageManager += this; }
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; }
public ColorPickers(Base parent) : base(parent) { /* RGB Picker */ { ColorPicker rgbPicker = new ColorPicker(this); rgbPicker.SetPosition(10, 10); rgbPicker.ColorChanged += ColorChanged; } /* HSVColorPicker */ { HSVColorPicker hsvPicker = new HSVColorPicker(this); hsvPicker.SetPosition(300, 10); hsvPicker.ColorChanged += ColorChanged; } /* HSVColorPicker in Window */ { Control.WindowControl Window = new WindowControl(this); Window.SetSize(300, 300); Window.Hide(); HSVColorPicker hsvPicker = new HSVColorPicker(Window); hsvPicker.SetPosition(10, 10); hsvPicker.ColorChanged += ColorChanged; Control.Button OpenWindow = new Control.Button(this); OpenWindow.SetPosition(10, 200); OpenWindow.SetSize(200, 20); OpenWindow.Text = "Open Window"; OpenWindow.Clicked += delegate(Base sender, ClickedEventArgs args) { Window.Show(); }; } }
public void Initialize() { WindowControl rightpanel = new WindowControl(MainCanvas.Instance); rightpanel.Dock = Gwen.Pos.Right; rightpanel.Width = (GraphicsManager.WindowWidth / 2) - 20; rightpanel.IsClosable = false; rightpanel.DisableResizing(); Base dummy = new Base(MainCanvas.Instance); dummy.Dock = Gwen.Pos.Fill; bottompanel = new WindowControl(dummy); bottompanel.Dock = Gwen.Pos.Bottom; bottompanel.Height = (GraphicsManager.WindowHeight / 2) - 20; bottompanel.IsClosable = false; bottompanel.DisableResizing(); Gameview = new Camera3D(); Gameview.Layer = 1; Gameview.FieldOfView = 60; Gameview.EnableViewport(10, 10, GraphicsManager.WindowWidth / 2, GraphicsManager.WindowHeight / 2); Gameview.OnRender += GameRender; if (GameInfo.Me.IsServer) { ScriptManager.Initialize(); foreach (var p in GameInfo.Players.Values){ InitializePlayer(p); } } }
public override void InitUi(Canvas canvas) { var window = new WindowControl(canvas, "Menu principal"); window.DisableResizing(); window.IsClosable = false; window.SetSize(200, 125); window.SetPosition(Game.GetWindowSize().X / 2 - window.Width / 2, Game.GetWindowSize().Y / 2 - window.Height / 2); var playButton = new Button(window); playButton.SetText("Jouer !"); playButton.Clicked += (sender, arguments) => ShowSelectLevelUi(canvas); var settingsButton = new Button(window); settingsButton.SetText("Options"); Align.PlaceDownLeft(settingsButton, playButton, 10); var exitButton = new Button(window); exitButton.SetText("Quitter"); exitButton.Clicked += (sender, arguments) => { Game.Close(); }; Align.PlaceDownLeft(exitButton, settingsButton, 10); Align.CenterHorizontally(playButton); Align.CenterHorizontally(settingsButton); Align.CenterHorizontally(exitButton); }
public PauseMenu (Application app, CompositorColorCorrectionNode colorCorrectionNode, Base parent, Action onContinue, Action onPause) { this.onContinue = onContinue; this.onPause = onPause; this.colorCorrectionNode = colorCorrectionNode; this.application = app; this.parent = parent; settings = new SettingsMenu (app, parent, colorCorrectionNode); window = new WindowControl (parent, Localizer.Instance.GetValueForName("pause")); window.DisableResizing(); window.IsMoveable = false; window.OnClose += (sender, arguments) => Hide(); window.Width = BUTTON_WIDTH + 20; window.Hide(); continueButton = new Button (window); continueButton.Text = Localizer.Instance.GetValueForName("back_to_game"); continueButton.Width = BUTTON_WIDTH; continueButton.X = 10; continueButton.Y = 10; continueButton.Clicked += (sender, arguments) => Hide(); settingsButton = new Button (window); settingsButton.Text = Localizer.Instance.GetValueForName("settings"); settingsButton.Width = BUTTON_WIDTH; settingsButton.X = 10; settingsButton.Y = 10 + continueButton.Y + continueButton.Height; settingsButton.Clicked += (sender, arguments) => settings.Show(); exitButton = new Button (window); exitButton.Text = Localizer.Instance.GetValueForName("quit_game"); exitButton.Width = BUTTON_WIDTH; exitButton.X = 10; exitButton.Y = 10 + settingsButton.Y + settingsButton.Height; exitButton.Clicked += (sender, arguments) => application.Window.Close (); window.Height += exitButton.Y + exitButton.Height + 10; window.X = (parent.Width - window.Width) / 2; window.Y = (parent.Height - window.Height) / 2; ValidMessages = new int[] { (int) MessageId.WindowResize, (int) MessageId.UpdateLocale, (int) MessageId.Input }; app.MessageManager += this; }
private void EndCombat(int win) { Gwen.Control.WindowControl windowEnd = new Gwen.Control.WindowControl(this); windowEnd.Width = this.Width / 2; windowEnd.Height = this.Height / 2; windowEnd.SetPosition(this.Width / 2 - windowEnd.Width / 2, this.Height / 2 - windowEnd.Height / 2); Gwen.Control.Label labelWin = new Gwen.Control.Label(windowEnd); labelWin.Text = "Win Player " + win.ToString(); labelWin.Font = Program.fontLogo; labelWin.SetBounds(windowEnd.Width / 2 - labelWin.Width / 2, windowEnd.Height / 2 - labelWin.Height, windowEnd.Width, windowEnd.Height * 15 / 100); Gwen.Control.Button buttonOK = new Gwen.Control.Button(windowEnd); buttonOK.Text = "OK"; buttonOK.Font = Program.fontButtonLabels; buttonOK.SetBounds(windowEnd.Width / 2 - buttonOK.Width / 2, windowEnd.Height * 70 / 100, windowEnd.Width * 25 / 100, windowEnd.Height * 15 / 100); buttonOK.Clicked += onOKClick; windowEnd.IsClosable = false; }
private void CreateEscapeWindow() { EscapeWindow = new WindowControl(MainCanvas.GetCanvas()); EscapeWindow.SetPosition(10, 10); EscapeWindow.SetSize(200, 200); Button Close = new Button(EscapeWindow); Close.SetPosition(10, 10); Close.SetText("Continue"); Close.Clicked += delegate(Base sender, ClickedEventArgs args) { EscapeWindow.Hide(); Game.LockMouse = true; }; Button Quit = new Button(EscapeWindow); Quit.SetPosition(10, 40); Quit.SetText("Quit"); Quit.Clicked += delegate(Base sender, ClickedEventArgs args) { MainCanvas.Dispose(); Environment.Exit(0); }; }
private void onButtonMenuClick(Base control, EventArgs args) { if (!menuOpenned) { menuOpenned = true; Gwen.Control.WindowControl menuWindow = new Gwen.Control.WindowControl(this); menuWindow.Width = Program.percentW(50); menuWindow.Height = Program.percentH(50); menuWindow.SetPosition(Program.percentW(25), Program.percentH(20)); Gwen.Control.Button buttonNewGame = new Gwen.Control.Button(menuWindow); buttonNewGame.Text = "New game"; buttonNewGame.Font = Program.fontButtonLabels; buttonNewGame.SetBounds(Program.percentW(12), Program.percentH(0), 200, 50); buttonNewGame.Pressed += onButtonNewGameClick; Gwen.Control.Button buttonLoadGame = new Gwen.Control.Button(menuWindow); buttonLoadGame.Text = "Load game"; buttonLoadGame.Disable(); buttonLoadGame.Font = Program.fontButtonLabels; buttonLoadGame.SetBounds(Program.percentW(12), Program.percentH(10), 200, 50); Gwen.Control.Button buttonSaveGame = new Gwen.Control.Button(menuWindow); buttonSaveGame.Text = "Save Game"; buttonSaveGame.Disable(); buttonSaveGame.Font = Program.fontButtonLabels; buttonSaveGame.SetBounds(Program.percentW(12), Program.percentH(20), 200, 50); Gwen.Control.Button buttonQuit = new Gwen.Control.Button(menuWindow); buttonQuit.Text = "Quit"; buttonQuit.Font = Program.fontButtonLabels; buttonQuit.SetBounds(Program.percentW(12), Program.percentH(30), 200, 50); buttonQuit.Pressed += onButtonQuitClick; } }
private void ShowSelectLevelUi(Canvas canvas) { var window = new WindowControl(canvas, "Choisir un niveau", true); window.DisableResizing(); window.SetSize(300, 400); window.SetPosition(Game.GetWindowSize().X /2 - window.Width / 2, Game.GetWindowSize().Y / 2 - window.Height / 2); var listLevel = new ListBox(window); listLevel.SetSize(window.Width / 2, window.Height - 40); if (Directory.Exists(_levelsPath)) { foreach (var file in Directory.EnumerateFiles(_levelsPath)) { var fileInfo = new FileInfo(file); if (fileInfo.Extension.Equals(".mtrlvl")) { listLevel.AddRow(fileInfo.Name.Remove(fileInfo.Name.LastIndexOf('.')), fileInfo.Name, file); } } } var widthButton = window.Width - listLevel.Width - 30; var playButton = new Button(window); playButton.SetText("Jouer"); playButton.SetPosition(listLevel.Width + 10, 0); playButton.SetSize(widthButton, playButton.Height); playButton.Clicked += (sender, arguments) => { LoadLevel(listLevel, canvas, false); }; var deleteLevelButton = new Button(window); deleteLevelButton.SetText("Supprimer"); deleteLevelButton.SetSize(widthButton, deleteLevelButton.Height); deleteLevelButton.Clicked += (sender, arguments) => { if (listLevel.SelectedRowIndex == -1) new MessageBox(canvas, "Aucun niveau n'a été sélectionné !", "Erreur !").Show(); else { var path = listLevel.SelectedRow.UserData.ToString(); try { File.Delete(path); listLevel.RemoveRow(listLevel.SelectedRowIndex); listLevel.SelectedRow = null; Log.WriteInfo("Le niveau : " + path + " a été supprimé !"); } catch (IOException e) { new MessageBox(canvas, "Impossible de supprimer le niveau sélectionné ! Erreur : " + e.Message, "Erreur !").Show(); } } }; Align.PlaceDownLeft(deleteLevelButton, playButton, 10); var editLevelButton = new Button(window); editLevelButton.SetText("Editer le niveau"); editLevelButton.SetSize(widthButton, editLevelButton.Height); editLevelButton.Clicked += (sender, arguments) => { LoadLevel(listLevel, canvas, true); }; Align.PlaceDownLeft(editLevelButton, deleteLevelButton, 10); var newLevelButton = new Button(window); newLevelButton.SetText("Nouveau niveau"); newLevelButton.SetSize(widthButton, newLevelButton.Height); Align.PlaceDownLeft(newLevelButton, editLevelButton, 10); }
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; }
/// <summary> /// Initializes a new instance of the <see cref="CloseButton"/> class. /// </summary> /// <param name="parent">Parent control.</param> /// <param name="owner">Window that owns this button.</param> public CloseButton(ControlBase parent, WindowControl owner) : base(parent) { m_Window = owner; }
public SettingsMenu (Application app, Base parent, CompositorColorCorrectionNode colorCorrectionNode) { this.application = app; this.parent = parent; this.colorCorrectionNode = colorCorrectionNode; window = new WindowControl (parent); window.DisableResizing(); window.Title = Localizer.Instance.GetValueForName("settings"); window.Hide(); float gamma = (float) ConfigManager.Instance["freezing_archer"].GetDouble("general", "gamma"); colorCorrectionNode.Gamma = gamma; string language = ConfigManager.Instance["freezing_archer"].GetString("general", "language"); Localizer.Instance.CurrentLocale = (LocaleEnum) Enum.Parse(typeof (LocaleEnum), language); languageLabel = new Label (window); languageLabel.AutoSizeToContents = true; languageLabel.Y = 10; languageLabel.Text = Localizer.Instance.GetValueForName("language"); languageDropdown = new ComboBox (window); languageDropdown.Width = CONTROL_WIDTH; languageDropdown.Y = 10; foreach (var lang in Localizer.Instance.Locales) { var item = languageDropdown.AddItem(Localizer.Instance.GetValueForName(lang.Key.ToString()), lang.Key.ToString()); item.AutoSizeToContents = false; item.Width = CONTROL_WIDTH; } languageDropdown.SelectByText(Localizer.Instance.GetValueForName(Localizer.Instance.CurrentLocale.ToString())); languageDropdown.ItemSelected += handleSelect; gammaSlider = new HorizontalSlider (window); gammaSlider.SnapToNotches = false; gammaSlider.Min = 0; gammaSlider.Max = 3; gammaSlider.Value = gamma; gammaSlider.ValueChanged += (sender, arguments) => { var slider = sender as HorizontalSlider; ConfigManager.Instance["freezing_archer"].SetDouble("general", "gamma", slider.Value); if (slider != null) this.colorCorrectionNode.Gamma = slider.Value; }; gammaSlider.Width = CONTROL_WIDTH; gammaSlider.Height = 20; gammaSlider.Y = 10 + languageDropdown.Y + languageDropdown.Height; gammaLabel = new Label (window); gammaLabel.AutoSizeToContents = true; gammaLabel.Y = 10 + languageLabel.Y + languageLabel.Height; gammaLabel.Text = Localizer.Instance.GetValueForName("gamma"); int max_width = languageLabel.Width > gammaLabel.Width ? languageLabel.Width : gammaLabel.Width; languageLabel.X = 10 + max_width - languageLabel.Width; gammaLabel.X = 10 + max_width - gammaLabel.Width; languageDropdown.X = 10 + max_width + 5; gammaSlider.X = 10 + max_width + 5; window.Width = 40 + max_width + CONTROL_WIDTH; resetButton = new Button (window); resetButton.Text = Localizer.Instance.GetValueForName("reset"); resetButton.Width = (window.Width / 2) - 20; resetButton.X = 10; resetButton.Y = gammaSlider.Y + gammaSlider.Height + 10; resetButton.Clicked += (sender, arguments) => { var general = ConfigManager.DefaultConfig.B.FirstOrDefault (a => a.Key == "general"); var gamma_pair = general.Value.FirstOrDefault(a => a.Key == "gamma"); float _gamma = (float) gamma_pair.Value.Double; gammaSlider.Value = _gamma; colorCorrectionNode.Gamma = _gamma; var language_pair = general.Value.FirstOrDefault(a => a.Key == "language"); string lang = language_pair.Value.String; Localizer.Instance.CurrentLocale = (LocaleEnum) Enum.Parse(typeof (LocaleEnum), lang); }; saveButton = new Button (window); saveButton.Text = Localizer.Instance.GetValueForName("save"); saveButton.Width = (window.Width / 2) - 20; saveButton.X = resetButton.X + resetButton.Width + 10; saveButton.Y = gammaSlider.Y + gammaSlider.Height + 10; saveButton.Clicked += (sender, arguments) => ConfigManager.Instance.SaveAll(); window.Height += languageDropdown.Height + gammaSlider.Height + 50; window.X = (parent.Width - window.Width) / 2; window.Y = (parent.Height - window.Height) / 2; ValidMessages = new[] { (int) MessageId.UpdateLocale }; application.MessageManager += this; }
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(); }
public void Init(Base parent, Inventory inventory) { this.inventory = inventory; Item_Text = new Gwen.ControlInternal.Text (parent); Item_Text.Font = new Gwen.Font (application.RendererContext.GwenRenderer); Item_Text.Y = 5; Item_Text.Font.Size = 15; spaces = new InventorySpace[inventory.Size.X, inventory.Size.Y]; barItems = new List<InventoryBarButton>(); canvasFrame = new InventoryBackground(parent, inventory, this); canvasFrame.Width = parent.Width; canvasFrame.Height = parent.Height; window = new WindowControl (canvasFrame, Localizer.Instance.GetValueForName("inventory")); window.DisableResizing (); window.IsMoveable = false; window.OnClose += (sender, arguments) => application.Window.CaptureMouse (); itemGridFrame = new Base (window); itemGridFrame.SetSize ((BoxSize + 1) * inventory.Size.X, (BoxSize + 1) * inventory.Size.Y); bla_unfug_crosshair = new ImagePanel (canvasFrame); bla_unfug_crosshair.SetSize (16, 16); bla_unfug_crosshair.ImageName = "Content/crosshair.png"; bla_unfug_crosshair.SetPosition ((canvasFrame.Width / 2.0f) - (bla_unfug_crosshair.Width / 2.0f), (canvasFrame.Height / 2.0f) - (bla_unfug_crosshair.Width / 2.0f)); bla_unfug_crosshair.BringToFront (); itemInfoFrame = new Base (window); itemInfoFrame.SetSize (infoFrameSize, itemGridFrame.Height); itemGridFrame.X += itemInfoFrame.Width + 4; toolbarFrame = new Base(window); toolbarFrame.Width = itemGridFrame.Width + itemInfoFrame.Width; toolbarFrame.Height = toolbarFrameSize; toolbarFrame.Y = itemGridFrame.Height - 4; dropBtn = new Button(toolbarFrame); dropBtn.AutoSizeToContents = true; dropBtn.Padding = btnPadding; dropBtn.Text = Localizer.Instance.GetValueForName("drop"); dropBtn.X = toolbarFrame.Width - dropBtn.Width; dropBtn.Y = (toolbarFrameSize - dropBtn.Height) / 2; dropBtn.IsDisabled = true; dropBtn.Clicked += (sender, arguments) => { if (dropBtn.IsDisabled) return; if (toggledBtn != null) { dropItem(toggledBtn, toggledBtn.Item, inventory); } }; useBtn = new Button(toolbarFrame); useBtn.AutoSizeToContents = true; useBtn.Padding = btnPadding; useBtn.Text = Localizer.Instance.GetValueForName("use"); useBtn.X = dropBtn.X - useBtn.Width - 8; useBtn.Y = (toolbarFrameSize - useBtn.Height) / 2; useBtn.IsDisabled = true; useBtn.Clicked += (sender, arguments) => { if (useBtn.IsDisabled) return; if (toggledBtn != null) { if (MessageCreated != null) MessageCreated(new ItemUseMessage(player, GameState.Scene, toggledBtn.Item, ItemUsage.Eatable)); } }; rotateBtn = new Button(toolbarFrame); rotateBtn.AutoSizeToContents = true; rotateBtn.Padding = btnPadding; rotateBtn.Text = Localizer.Instance.GetValueForName("rotate"); rotateBtn.X = useBtn.X - rotateBtn.Width - 8; rotateBtn.Y = (toolbarFrameSize - rotateBtn.Height) / 2; rotateBtn.IsDisabled = true; rotateBtn.Clicked += (sender, argument) => { if (rotateBtn.IsDisabled) return; var pos = inventory.GetPositionOfItem(toggledBtn.Item); var item = inventory.TakeOut(pos); var prev_orientation = item.Orientation; item.Orientation = item.Orientation == Orientation.Horizontal ? Orientation.Vertical : Orientation.Horizontal; if (!inventory.Insert(item, pos)) { item.Orientation = prev_orientation; if (!inventory.Insert(item, pos)) { Logger.Log.AddLogEntry(LogLevel.Error, "InventoryGUI", "Lost an inventory item while rotating!"); toggledBtn.DelayedDelete(); toggledBtn = null; return; } } toggledBtn.UpdateSize(); }; inventoryBar = new TextBox(canvasFrame); inventoryBar.Disable(); inventoryBar.KeyboardInputEnabled = false; inventoryBar.Height = barBoxSize + 2; inventoryBar.Width = barBoxSize * inventory.InventoryBar.Length + 1; inventoryBar.Y = canvasFrame.Height - inventoryBar.Height; inventoryBar.X = (canvasFrame.Width - inventoryBar.Width) / 2; barSpaces = new InventoryBarSpace[inventory.InventoryBar.Length]; for (int i = 0; i < inventory.InventoryBar.Length; i++) { barSpaces[i] = new InventoryBarSpace(inventoryBar, MessageProvider, inventory, this, barItems, barBoxSize); barSpaces[i].X = i * barBoxSize; barSpaces[i].Y = 1; barSpaces[i].Width = barBoxSize + 1; barSpaces[i].Height = barBoxSize + 1; barSpaces[i].DrawDebugOutlines = false; if (i == inventory.ActiveBarPosition) { barSpaces[i].DrawDebugOutlines = true; barSpaces[i].Children.ForEach(c => c.DrawDebugOutlines = false); } } window.SetSize (itemGridFrame.Width + itemInfoFrame.Width + 16, itemGridFrame.Height + toolbarFrameSize + 28); window.SetPosition ((canvasFrame.Width - window.Width) / 2, (canvasFrame.Height - window.Height - inventoryBar.Height) / 2); window.Hide(); int w = 0, h = 0; for (int y = 0; y < inventory.Size.Y; y++) { for (int x = 0; x < inventory.Size.X; x++) { spaces [x, y] = new InventorySpace (itemGridFrame, BoxSize, inventory); spaces [x, y].X = w; spaces [x, y].Y = h; spaces [x, y].Width = BoxSize + 1; spaces [x, y].Height = BoxSize + 1; w += BoxSize; } h += BoxSize; w = 0; } imagePanel = new ImagePanel(itemInfoFrame); imagePanel.Width = infoFrameSize; imagePanelHeight = itemGridFrame.Height / 3; imagePanel.Hide(); items = new List<InventoryButton>(); inventory.Items.ForEach((item, position) => { AddItem(item, position); }); }
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(); }
private void ShowAddScriptInfoWindow(Canvas canvas) { var windowAddScriptInfo = new WindowControl(canvas, "Script", false); windowAddScriptInfo.DisableResizing(); }
private void ShowAddScriptWindow(Canvas canvas) { var windowAddScript = new WindowControl(canvas, "Ajouter un script", true); windowAddScript.DisableResizing(); windowAddScript.SetSize(200, 300); windowAddScript.SetPosition(Game.GetWindowSize().X / 2 - windowAddScript.Width / 2, Game.GetWindowSize().Y / 2 - windowAddScript.Height / 2); }