public CodeEditor(CodeFile resource) : base(DevelopmentMenu.Instance) { this.Title = "Code Editor"; this.Resource = resource; this.SetSize(600, 400); this.SetPosition((int)MouseManager.GetMousePositionWindows().X, (int)MouseManager.GetMousePositionWindows().Y); CodeArea = new MultilineTextBox(this); CodeArea.AcceptTabs = true; CodeArea.SetSize(400, 400); CodeArea.Text = Resource.Source; CodeArea.Font = new Gwen.Font(MainCanvas.Renderer, "Consolas"); CodeArea.Dock = Gwen.Pos.Fill; CodeArea.TextChanged +=new GwenEventHandler<EventArgs>(CodeArea_TextChanged); TopBar = new Base(this); TopBar.Dock = Gwen.Pos.Top; TopBar.SetSize(0, 25); { Run = new Button(TopBar); Run.Text = "Run"; Run.Clicked += new GwenEventHandler<ClickedEventArgs>(Run_Clicked); } ErrorList = new ListBox(this); ErrorList.Dock = Gwen.Pos.Bottom; ErrorList.Height = 50; }
public ConfigurationManager() : base(DevelopmentMenu.Instance) { this.Title = "Configuration Manager"; this.SetSize(400, 200); Configs = new ListBox(this); Configs.Dock = Gwen.Pos.Fill; RefreshUI(); }
public void Init() { this.Name = "Dungeon #" + rand.Next(100); this.Distance = rand.Next(50) + 1; this.Level = rand.Next(11); herobox = new ListBox(this); herobox.SetPosition(0, 0); herobox.Dock = Gwen.Pos.Fill; }
public TestingDisplay() : base(MainCanvas.GetCanvas()) { this.Dock = Gwen.Pos.Left; this.Width = 300; this.IsClosable = false; lb = new ListBox(this); lb.SetPosition(10, 10); lb.SetSize(265, 400); Initialize(); lb.SelectedRowIndex = 0; }
private void InitializeUI() { settings = NavMeshGenerationSettings.Default; areaSettings = new AreaIdGenerationSettings(); DockBase dock = new DockBase(gwenCanvas); dock.Dock = Pos.Fill; dock.SetSize(Width, Height); dock.RightDock.Width = 280; dock.BottomDock.Height = 150; statusBar = new StatusBar(gwenCanvas); Label genTime = new Label(statusBar); genTime.Name = "GenTime"; genTime.Text = "Generation Time: 0ms"; genTime.Dock = Pos.Left; LabeledCheckBox catchCheckBox = new LabeledCheckBox(statusBar); catchCheckBox.Text = "Intercept and log exceptions"; catchCheckBox.Dock = Pos.Right; catchCheckBox.CheckChanged += (s, e) => interceptExceptions = catchCheckBox.IsChecked; catchCheckBox.IsChecked = true; Base genBase = new Base(dock); dock.RightDock.TabControl.AddPage("NavMesh Generation", genBase); Button generateButton = new Button(genBase); generateButton.Text = "Generate!"; generateButton.Height = 30; generateButton.Dock = Pos.Top; generateButton.Released += (s, e) => GenerateNavMesh(); GroupBox displaySettings = new GroupBox(genBase); displaySettings.Text = "Display"; displaySettings.Dock = Pos.Top; displaySettings.Height = 60; Base levelCheckBase = new Base(displaySettings); levelCheckBase.Dock = Pos.Top; Label levelCheckLabel = new Label(levelCheckBase); levelCheckLabel.Text = "Level"; levelCheckLabel.Dock = Pos.Left; CheckBox levelCheckBox = new CheckBox(levelCheckBase); levelCheckBox.Dock = Pos.Right; levelCheckBox.Checked += (s, e) => displayLevel = true; levelCheckBox.UnChecked += (s, e) => displayLevel = false; levelCheckBox.IsChecked = true; levelCheckBase.SizeToChildren(); Base displayModeBase = new Base(displaySettings); displayModeBase.Dock = Pos.Top; displayModeBase.Padding = new Padding(0, 4, 0, 0); Label displayModeLabel = new Label(displayModeBase); displayModeLabel.Text = "Generation Step"; displayModeLabel.Dock = Pos.Left; displayModeLabel.Padding = new Padding(0, 0, 4, 0); ComboBox displayModes = new ComboBox(displayModeBase); displayModes.Dock = Pos.Top; displayModes.AddItem("None", "", DisplayMode.None); displayModes.AddItem("Heightfield", "", DisplayMode.Heightfield); displayModes.AddItem("Compact Heightfield", "", DisplayMode.CompactHeightfield); displayModes.AddItem("Distance Field", "", DisplayMode.DistanceField); displayModes.AddItem("Regions", "", DisplayMode.Regions); displayModes.AddItem("Contours", "", DisplayMode.Contours); displayModes.AddItem("Polygon Mesh", "", DisplayMode.PolyMesh); displayModes.AddItem("Polygon Mesh Detail", "", DisplayMode.PolyMeshDetail); displayModes.AddItem("NavMesh", "", DisplayMode.NavMesh); displayModes.AddItem("Pathfinding", "", DisplayMode.Pathfinding); displayModes.ItemSelected += (s, e) => displayMode = (DisplayMode)e.SelectedItem.UserData; displayModes.SelectByUserData(DisplayMode.PolyMeshDetail); displayModeBase.SizeToChildren(); displayModeBase.Height += 4; //accounts for the padding, GWEN.NET should do this const int leftMax = 125; const int rightMax = 20; GroupBox areaSetting = new GroupBox(genBase); areaSetting.Text = "Area"; areaSetting.Dock = Pos.Top; areaSetting.Height = 90; var levelTris = level.GetTriangles(); BBox3 bounds = TriangleEnumerable.FromTriangle(levelTris, 0, levelTris.Length).GetBoundingBox(); Base maxTriSlope = CreateSliderOption(areaSetting, "Max Tri Slope:", 0.0001f, 3.14f, 3.14f, "N2", leftMax, rightMax, v => areaSettings.MaxTriSlope = v); Base minLevelHeight = CreateSliderOption(areaSetting, "Min Height:", bounds.Min.Y, bounds.Max.Y, bounds.Min.Y, "N0", leftMax, rightMax, v => areaSettings.MinLevelHeight = v); Base maxLevelHeight = CreateSliderOption(areaSetting, "Max Height:", bounds.Min.Y, bounds.Max.Y, bounds.Max.Y, "N0", leftMax, rightMax, v => areaSettings.MaxLevelHeight = v); GroupBox rsSettings = new GroupBox(genBase); rsSettings.Text = "Rasterization"; rsSettings.Dock = Pos.Top; rsSettings.Height = 90; Base cellSizeSetting = CreateSliderOption(rsSettings, "Cell Size:", 0.1f, 2.0f, 0.3f, "N2", leftMax, rightMax, v => settings.CellSize = v); Base cellHeightSetting = CreateSliderOption(rsSettings, "Cell Height:", 0.1f, 2f, 0.2f, "N2", leftMax, rightMax, v => settings.CellHeight = v); GroupBox agentSettings = new GroupBox(genBase); agentSettings.Text = "Agent"; agentSettings.Dock = Pos.Top; agentSettings.Height = 115; Base maxSlopeSetting = CreateSliderOption(agentSettings, "Max Climb:", 0.1f, 5.0f, 0.9f, "N0", leftMax, rightMax, v => settings.MaxClimb = v); Base maxHeightSetting = CreateSliderOption(agentSettings, "Height:", 0.1f, 5.0f, 2.0f, "N0", leftMax, rightMax, v => settings.AgentHeight = v); Base erodeRadius = CreateSliderOption(agentSettings, "Radius:", 0.0f, 5.0f, 0.6f, "N1", leftMax, rightMax, v => { settings.AgentRadius = v; agentCylinder.Radius = v; }); Base addRemoveAgent = CreateAddRemoveButton(agentSettings, "Count", leftMax, rightMax, 0, MAX_AGENTS, () => { numActiveAgents++; GenerateCrowd(); }, () => { numActiveAgents--; GenerateCrowd(); }); GroupBox regionSettings = new GroupBox(genBase); regionSettings.Text = "Region"; regionSettings.Dock = Pos.Top; regionSettings.Height = 65; Base minRegionSize = CreateSliderOption(regionSettings, "Min Region Size:", 0f, 150f, 8f, "N0", leftMax, rightMax, v => settings.MinRegionSize = (int)Math.Round(v)); Base mrgRegionSize = CreateSliderOption(regionSettings, "Merged Region Size:", 0f, 150f, 20f, "N0", leftMax, rightMax, v => settings.MergedRegionSize = (int)Math.Round(v)); GroupBox navMeshSettings = new GroupBox(genBase); navMeshSettings.Text = "NavMesh"; navMeshSettings.Dock = Pos.Top; navMeshSettings.Height = 90; Base maxEdgeLength = CreateSliderOption(navMeshSettings, "Max Edge Length:", 0f, 50f, 12f, "N0", leftMax, rightMax, v => settings.MaxEdgeLength = (int)Math.Round(v)); Base maxEdgeErr = CreateSliderOption(navMeshSettings, "Max Edge Error:", 0f, 3f, 1.8f, "N1", leftMax, rightMax, v => settings.MaxEdgeError = v); Base vertsPerPoly = CreateSliderOption(navMeshSettings, "Verts Per Poly:", 3f, 12f, 6f, "N0", leftMax, rightMax, v => settings.VertsPerPoly = (int)Math.Round(v)); GroupBox navMeshDetailSettings = new GroupBox(genBase); navMeshDetailSettings.Text = "NavMeshDetail"; navMeshDetailSettings.Dock = Pos.Top; navMeshDetailSettings.Height = 65; Base sampleDistance = CreateSliderOption(navMeshDetailSettings, "Sample Distance:", 0f, 16f, 6f, "N0", leftMax, rightMax, v => settings.SampleDistance = (int)Math.Round(v)); Base maxSampleError = CreateSliderOption(navMeshDetailSettings, "Max Sample Error:", 0f, 16f, 1f, "N0", leftMax, rightMax, v => settings.MaxSampleError = (int)Math.Round(v)); Base logBase = new Base(dock); dock.BottomDock.TabControl.AddPage("Log", logBase); ListBox logBox = new ListBox(logBase); logBox.Dock = Pos.Fill; logBox.AllowMultiSelect = false; logBox.EnableScroll(true, true); Console.SetOut(new GwenTextWriter(logBox)); }
private void LoadLevel(ListBox listLevel, Canvas canvas, bool editorMode) { if (listLevel.SelectedRowIndex == -1) new MessageBox(canvas, "Aucun niveau n'a été sélectionné !", "Erreur !").Show(); else { var path = listLevel.SelectedRow.UserData as string; if (File.Exists(path)) { try { var level = LevelManager.LoadLevel(Game, new FileInfo(path)); if (editorMode) Game.LoadScene(new EditorScene(Game, level)); else Game.LoadScene(new GameScene(Game, level)); } catch (Exception e) { Log.WriteError(e.Message); } } else { Log.WriteError("Le niveau sélectionné n'existe pas !"); } } }
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 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(); }
/// <summary> /// Initializes a new instance of the <see cref="GwenTextWriter"/> class. /// </summary> /// <param name="outputBox"></param> public GwenTextWriter(ListBox outputBox) { this.outputBox = outputBox; }