public override void AddedToContainer() { base.AddedToContainer(); var builder = new FieldBuilder(); builder.BuildSessionStart(this); var templateNameTextField = builder.AddTextField("Template Name: "); templateNameTextField.Text = template.TemplateName; var panel = new Panel(); panel.Initialize(); builder.AddDrawBoxAsField(panel, DrawBoxAlignment.GetFull()); var guiMethod = template.Creature.GetType().GetMethod("GUI_Edit"); var isReadyFunc = (Func <bool>)guiMethod.Invoke(template.Creature, new object[] { panel }); panel.Width = builder.FieldWidth; Wrap(); var okButton = new ResizableButton(); okButton.Initialize(); AddDrawBox(okButton); okButton.Title = "OK"; okButton.FitToText(); okButton.X = builder.FieldWidth - okButton.Width; okButton.Y = Height + 5; okButton.Click += delegate(object sender) { if (isReadyFunc()) { template.TemplateName = templateNameTextField.Text; Close(); } else { AlertForm.ShowDialogue(Parent, null, "All fields have not been filled out."); } }; builder.BuildSessionEnd(); okButton.Alignment = DrawBoxAlignment.GetRightBottom(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); CanResizeFormVertically = true; }
public override void AddedToContainer() { base.AddedToContainer(); var builder = new FieldBuilder(); builder.BuildSessionStart(this); var templateNameTextField = builder.AddTextField("Template Name: "); var entityTypesComboBox = builder.AddComboBoxField("Entity Type: "); var entityTypeList = Globals.GetAllTypesDeriving(typeof(IEntity), Assembly.GetExecutingAssembly()); //Remove all creature-types var creatureType = typeof(ICreature); foreach (var t in new List <Type>(entityTypeList)) { if (creatureType.IsAssignableFrom(t)) { entityTypeList.Remove(t); } } entityTypesComboBox.Items.AddRange(entityTypeList.Select(s => s.Name)); entityTypesComboBox.Index = 0; builder.AddResizableButtonField("OK", delegate(object sender) { if (entityTypesComboBox.Index == -1) { AlertForm.ShowDialogue(Parent, null, "Select a entity type."); } else { Result = new EntityTemplate(); Result.TemplateName = templateNameTextField.Text; Result.Entity = (IEntity)Activator.CreateInstance(entityTypeList[entityTypesComboBox.Index]); EditEntityTemplateForm.ShowDialogue(Parent, Result); Close(); } }); builder.BuildSessionEnd(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); CanResizeFormVertically = false; }
//Help void setUpHelpMenuItem() { var menuItem = new MenuBar.MenuItem("Help"); MenuBar.MenuItems.Add(menuItem); menuItem.Elements.Add(new MenuBar.MenuItem.MenuElement("About EvoSim", delegate(object sender) { Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; AlertForm.ShowDialogue(Parent, "About", "EvoSim" + "\n" + "Version: " + v.ToString() + "\n" + "Created by: Lukas Kikuchi" + "\n" + "\n" + "Copyright 2011 Lukas Kikuchi"); })); }
public override void AddedToContainer() { base.AddedToContainer(); var builder = new FieldBuilder(); builder.BuildSessionStart(this); var templateNameTextField = builder.AddTextField("Template Name: "); var worldTypesComboBox = builder.AddComboBoxField("World Type: "); var worldTypeList = Globals.GetAllTypesDeriving(typeof(IWorld), Assembly.GetExecutingAssembly()); worldTypesComboBox.Items.AddRange(worldTypeList.Select(s => s.Name)); worldTypesComboBox.Index = 0; builder.AddResizableButtonField("OK", delegate(object sender) { if (worldTypesComboBox.Index == -1) { AlertForm.ShowDialogue(Parent, null, "Select a world type."); } else { Result = new WorldTemplate(); Result.TemplateName = templateNameTextField.Text; Result.World = (IWorld)Activator.CreateInstance(worldTypeList[worldTypesComboBox.Index]); EditWorldTemplateForm.ShowDialogue(Parent, Result); Close(); } }); builder.BuildSessionEnd(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); CanResizeFormVertically = false; }
public override void AddedToContainer() { base.AddedToContainer(); CloseButtonOn = false; var builder = new FieldBuilder(); builder.BuildSessionStart(this); var templateNameTextField = builder.AddTextField("Template Name: "); templateNameTextField.Text = template.TemplateName; Panel panel = new Panel(); panel.Initialize(); builder.AddDrawBoxAsField(panel, DrawBoxAlignment.GetFull()); var isReadyFunc = (Func <bool>)template.World.GetType().InvokeMember("GUI_Edit", BindingFlags.Default | BindingFlags.InvokeMethod, null, null, new object[] { panel, template.World }); builder.AddResizableButtonField("OK", delegate(object sender) { if (isReadyFunc()) { template.TemplateName = templateNameTextField.Text; Close(); } else { AlertForm.ShowDialogue(Parent, null, "All fields have not been filled out."); } }, FieldBuilder.ResizableButtonOrientation.Left); builder.BuildSessionEnd(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); CanResizeFormVertically = false; }
public override void AddedToContainer() { base.AddedToContainer(); var builder = new FieldBuilder(); builder.BuildSessionStart(this); var fileNameTextField = builder.AddBrowseField(FileForm.FileFormTypes.File, FileForm.OperationTypes.Save, "File Directory: ").DrawBox1; var worldTemplatesComboBox = builder.AddComboBoxField("World: "); worldTemplatesComboBox.Items.AddRange(EditorData.WorldTemplates.Select(s => s.TemplateName)); worldTemplatesComboBox.Index = 0; builder.AddResizableButtonField("OK", delegate(object sender) { if (worldTemplatesComboBox.Index == -1) { AlertForm.ShowDialogue(Parent, null, "Choose a world-template"); } else { Result = new Simulation(); Result.World = EditorData.WorldTemplates[worldTemplatesComboBox.Index].World.Clone(); Result.FileName = fileNameTextField.Text; AddDefaultEntityPainters(Result); Close(); } }); builder.BuildSessionEnd(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); CanResizeFormVertically = false; }
public override void AddedToContainer() { base.AddedToContainer(); CloseButtonOn = false; var builder = new FieldBuilder(); builder.BuildSessionStart(this); Panel panel = new Panel(); panel.Initialize(); builder.AddDrawBoxAsField(panel, DrawBoxAlignment.GetFull()); var guiMethod = ann.GetType().GetMethod("GUI_Edit"); var isReadyFunc = (Func <bool>)guiMethod.Invoke(ann, new object[] { panel }); builder.AddResizableButtonField("OK", delegate(object sender) { if (isReadyFunc()) { Close(); } else { AlertForm.ShowDialogue(Parent, null, "All fields have not been filled out."); } }, FieldBuilder.ResizableButtonOrientation.Left); builder.BuildSessionEnd(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); CanResizeFormVertically = false; }
public override void AddedToContainer() { base.AddedToContainer(); CloseButtonOn = false; columnListBox = new ColumnListBox(); columnListBox.Initialize(1); AddDrawBox(columnListBox); columnListBox.SetIntOrStringSort(false); columnListBox.SetColumnName(0, "Name"); columnListBox.Width = 200; columnListBox.Height = 200; columnListBox.ItemDoubleClicked += delegate(object sender, ColumnListBox.ListBoxRow item, int index) { GenomeTemplate template = null; foreach (var g in EditorData.GenomeTemplates) { if (g.TemplateName == (string)item.Values[0]) { template = g; } } string oldName = template.TemplateName; EditGenomeTemplateForm.ShowDialogue(Parent, template, delegate(object _sender) { foreach (var g in EditorData.GenomeTemplates) { if (g.TemplateName == template.TemplateName && g != template) { AlertForm.ShowDialogue(Parent, null, "There is a template with that name already."); template.TemplateName = oldName; } } ReloadListBox(); }); }; ReloadListBox(); var createTemplateButton = new ResizableButton(); createTemplateButton.Initialize(); AddDrawBox(createTemplateButton); createTemplateButton.Title = "Create New Template"; createTemplateButton.FitToText(); Push.ToTheBottomSideOf(createTemplateButton, columnListBox, 3, Push.VerticalAlign.Left); createTemplateButton.Width = 200; createTemplateButton.Click += delegate(object sender) { var newTemplate = new GenomeTemplate(); newTemplate.Genome = new EvoSim.Genes.Genome(); EditGenomeTemplateForm.ShowDialogue(Parent, newTemplate, delegate(object _sender) { bool alreadyExists = false; foreach (var g in EditorData.GenomeTemplates) { if (g.TemplateName == newTemplate.TemplateName) { AlertForm.ShowDialogue(Parent, null, "There is a template with that name already."); alreadyExists = true; } } if (!alreadyExists) { EditorData.GenomeTemplates.Add(newTemplate); } ReloadListBox(); }); }; var deleteTemplateButton = new ResizableButton(); deleteTemplateButton.Initialize(); AddDrawBox(deleteTemplateButton); deleteTemplateButton.Title = "Delete Template"; deleteTemplateButton.FitToText(); Push.ToTheBottomSideOf(deleteTemplateButton, createTemplateButton, 3, Push.VerticalAlign.Left); deleteTemplateButton.Width = 200; deleteTemplateButton.Click += delegate(object sender) { if (columnListBox.SelectedRow != null) { var findName = (string)columnListBox.SelectedRow.Values[0]; foreach (var g in EditorData.GenomeTemplates) { if (g.TemplateName == findName) { EditorData.GenomeTemplates.Remove(g); ReloadListBox(); break; } } } }; var editTemplateButton = new ResizableButton(); editTemplateButton.Initialize(); AddDrawBox(editTemplateButton); editTemplateButton.Title = "Edit Template"; editTemplateButton.FitToText(); Push.ToTheBottomSideOf(editTemplateButton, deleteTemplateButton, 3, Push.VerticalAlign.Left); editTemplateButton.Width = 200; editTemplateButton.Click += delegate(object sender) { if (columnListBox.SelectedRow == null) { return; } GenomeTemplate template = null; foreach (var g in EditorData.GenomeTemplates) { if (g.TemplateName == (string)columnListBox.SelectedRow.Values[0]) { template = g; } } string oldName = template.TemplateName; EditGenomeTemplateForm.ShowDialogue(Parent, template, delegate(object _sender) { foreach (var g in EditorData.GenomeTemplates) { if (g.TemplateName == template.TemplateName && g != template) { AlertForm.ShowDialogue(Parent, null, "There is a template with that name already."); template.TemplateName = oldName; } } ReloadListBox(); }); }; var okButton = new ResizableButton(); okButton.Initialize(); AddDrawBox(okButton); okButton.Title = "OK"; okButton.FitToText(); Push.ToTheBottomSideOf(okButton, editTemplateButton, 3, Push.VerticalAlign.Left); okButton.Width = 200; okButton.Click += delegate(object sender) { EditorData.Save(Globals.EditorDataSaveDir); Close(); }; Wrap(); columnListBox.Alignment = DrawBoxAlignment.GetFull(); createTemplateButton.Alignment = DrawBoxAlignment.GetLeftRightBottom(); deleteTemplateButton.Alignment = DrawBoxAlignment.GetLeftRightBottom(); editTemplateButton.Alignment = DrawBoxAlignment.GetLeftRightBottom(); okButton.Alignment = DrawBoxAlignment.GetLeftRightBottom(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); }
public override void AddedToContainer() { base.AddedToContainer(); CloseButtonOn = false; columnListBox = new ColumnListBox(); columnListBox.Initialize(1); AddDrawBox(columnListBox); columnListBox.SetIntOrStringSort(false); columnListBox.SetColumnName(0, "Name"); columnListBox.Width = 200; columnListBox.Height = 200; columnListBox.ItemDoubleClicked += delegate(object sender, ColumnListBox.ListBoxRow item, int index) { SpawnPoint spawnPoint = null; foreach (var sp in spawnPointList) { if (sp.Name == (string)item.Values[0]) { spawnPoint = sp; } } string oldName = spawnPoint.Name; EditSpawnPointForm.ShowDialogue(Parent, spawnPoint, delegate(object _sender) { foreach (var sp in spawnPointList) { if (sp.Name == spawnPoint.Name && spawnPoint != sp) { AlertForm.ShowDialogue(Parent, null, "There is a spawnpoint with that name already."); spawnPoint.Name = oldName; } } ReloadListBox(); }); }; ReloadListBox(); var createTemplateButton = new ResizableButton(); createTemplateButton.Initialize(); AddDrawBox(createTemplateButton); createTemplateButton.Title = "Create New Spawnpoint"; createTemplateButton.FitToText(); Push.ToTheBottomSideOf(createTemplateButton, columnListBox, 3, Push.VerticalAlign.Left); createTemplateButton.Width = 200; createTemplateButton.Click += delegate(object sender) { var spawnPoint = new SpawnPoint(world); EditSpawnPointForm.ShowDialogue(Parent, spawnPoint, delegate(object _sender) { bool alreadyExists = false; foreach (var sp in spawnPointList) { if (sp.Name == spawnPoint.Name && spawnPoint != sp) { alreadyExists = true; } } if (alreadyExists) { AlertForm.ShowDialogue(Parent, null, "There is a spawnpoint with that name already."); } else { spawnPointList.Add(spawnPoint); } ReloadListBox(); }); }; var deleteTemplateButton = new ResizableButton(); deleteTemplateButton.Initialize(); AddDrawBox(deleteTemplateButton); deleteTemplateButton.Title = "Delete Spawnpoint"; deleteTemplateButton.FitToText(); Push.ToTheBottomSideOf(deleteTemplateButton, createTemplateButton, 3, Push.VerticalAlign.Left); deleteTemplateButton.Width = 200; deleteTemplateButton.Click += delegate(object sender) { if (columnListBox.SelectedRow != null) { var findName = (string)columnListBox.SelectedRow.Values[0]; foreach (var t in EditorData.EntityTemplates) { if (t.TemplateName == findName) { EditorData.EntityTemplates.Remove(t); ReloadListBox(); break; } } } }; var editTemplateButton = new ResizableButton(); editTemplateButton.Initialize(); AddDrawBox(editTemplateButton); editTemplateButton.Title = "Edit Spawnpoint"; editTemplateButton.FitToText(); Push.ToTheBottomSideOf(editTemplateButton, deleteTemplateButton, 3, Push.VerticalAlign.Left); editTemplateButton.Width = 200; editTemplateButton.Click += delegate(object sender) { if (columnListBox.SelectedRow == null) { return; } SpawnPoint spawnPoint = null; foreach (var sp in spawnPointList) { if (sp.Name == (string)columnListBox.SelectedRow.Values[0]) { spawnPoint = sp; } } string oldName = spawnPoint.Name; EditSpawnPointForm.ShowDialogue(Parent, spawnPoint, delegate(object _sender) { foreach (var sp in spawnPointList) { if (sp.Name == spawnPoint.Name && spawnPoint != sp) { AlertForm.ShowDialogue(Parent, null, "There is a spawnpoint with that name already."); spawnPoint.Name = oldName; } } ReloadListBox(); }); }; var okButton = new ResizableButton(); okButton.Initialize(); AddDrawBox(okButton); okButton.Title = "OK"; okButton.FitToText(); Push.ToTheBottomSideOf(okButton, editTemplateButton, 3, Push.VerticalAlign.Left); okButton.Width = 200; okButton.Click += delegate(object sender) { Close(); }; Wrap(); columnListBox.Alignment = DrawBoxAlignment.GetFull(); createTemplateButton.Alignment = DrawBoxAlignment.GetLeftRightBottom(); deleteTemplateButton.Alignment = DrawBoxAlignment.GetLeftRightBottom(); editTemplateButton.Alignment = DrawBoxAlignment.GetLeftRightBottom(); okButton.Alignment = DrawBoxAlignment.GetLeftRightBottom(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); IsClosing += delegate(object sender) { EditorData.Save(Globals.EditorDataSaveDir); }; }
public static void GUI_Edit(Window parent, SinglePointCrossover func) { AlertForm.ShowDialogue(parent, "Alert", "No parameters to change."); }
public static void GUI_Edit(Window parent, BarebonesSigmoid sigmoid) { AlertForm.ShowDialogue(parent, "Alert", "No parameters to change."); }
public static Func <bool> GUI_Edit(SingleSlotBox container, RMP_Chromosome chromosome) { var builder = new FieldBuilder(); builder.BuildSessionStart(container); Dictionary <string, object> valueHolder = new Dictionary <string, object>(); valueHolder.Add("RMP_Chromosome", chromosome); var inhibitoryConnectionChance = builder.AddDoubleField("Inhibitory Connection-Chance: "); inhibitoryConnectionChance.Value = chromosome.InhibitoryConnectionChance; var connectionChance = builder.AddDoubleField("Connection-Chance: "); connectionChance.Value = chromosome.ConnectionChance; var newConnectionsCanForm = builder.AddCheckBoxField("NewConnectionsCanForm: "); newConnectionsCanForm.Checked = chromosome.NewConnectionsCanForm; var connectionsCanDie = builder.AddCheckBoxField("ConnectionsCanDie: "); connectionsCanDie.Checked = chromosome.ConnectionsCanDie; var newNeuronsCanForm = builder.AddCheckBoxField("NewNeuronsCanForm: "); newNeuronsCanForm.Checked = chromosome.NewNeuronsCanForm; var neuronsCanDie = builder.AddCheckBoxField("NeuronsCanDie: "); neuronsCanDie.Checked = chromosome.NeuronsCanDie; Action reloadChromosome = delegate() { chromosome.InhibitoryConnectionChance = inhibitoryConnectionChance.Value; chromosome.ConnectionChance = connectionChance.Value; chromosome.NewConnectionsCanForm = newConnectionsCanForm.Checked; chromosome.ConnectionsCanDie = connectionsCanDie.Checked; chromosome.NewNeuronsCanForm = newNeuronsCanForm.Checked; chromosome.NeuronsCanDie = neuronsCanDie.Checked; }; if (chromosome.MutationGenes.Count == 0) { //Mutation Genes chromosome.MutationGenes.Add(new DoubleGene("NeuronAddChance", 0, 1, 0.1)); chromosome.MutationGenes.Add(new DoubleGene("NeuronRemoveChance", 0, 1, 0.1)); chromosome.MutationGenes.Add(new DoubleGene("MaxNeuronRemoving", 0, 1, 0.1)); chromosome.MutationGenes.Add(new DoubleGene("MaxNeuronAdding", 0, 1, 0.1)); chromosome.MutationGenes.Add(new DoubleGene("ConnectionAddChance", 0, 1, 0.05)); chromosome.MutationGenes.Add(new DoubleGene("ConnectionRemoveChance", 0, 1, 0.05)); } builder.AddResizableButtonField("Edit Mutation Genes", delegate(object sender) { EditDoubleGeneListForm.ShowDialogue(container.Parent, chromosome.MutationGenes); }); var sigmoidTypes = Globals.GetAllTypesDeriving(typeof(SigmoidFunction), Assembly.GetExecutingAssembly()); var sigmoidNames = new List <string>(sigmoidTypes.Select(s => s.Name)); var globalSigmoidComboBox = builder.AddComboBoxField("GlobalSigmoid: ", sigmoidNames); if (chromosome.GlobalSigmoidFunction != null) { var globalSigmoidType = chromosome.GlobalSigmoidFunction.GetType(); foreach (var type in sigmoidTypes) { if (type.IsEquivalentTo(globalSigmoidType)) { globalSigmoidComboBox.Index = sigmoidTypes.IndexOf(type); } } } globalSigmoidComboBox.SelectedItemChanged += delegate(object sender, int newItemIndex, int oldItemIndex) { chromosome.GlobalSigmoidFunction = (SigmoidFunction)Activator.CreateInstance(sigmoidTypes[newItemIndex]); }; var globalSigmoidEditButton = builder.AddResizableButtonField("Edit GlobalSigmoid", delegate(object sender) { if (chromosome.GlobalSigmoidFunction == null) { return; } var sigmoid = chromosome.GlobalSigmoidFunction; sigmoidTypes[globalSigmoidComboBox.Index].InvokeMember("GUI_Edit", BindingFlags.Default | BindingFlags.InvokeMethod, null, null, new object[] { container.Parent, sigmoid }); }); var globalOutputSigmoidComboBox = builder.AddComboBoxField("GlobalOutputSigmoid: ", sigmoidNames); if (chromosome.GlobalOutputSigmoidFunction != null) { var globalOutputSigmoidType = chromosome.GlobalOutputSigmoidFunction.GetType(); foreach (var type in sigmoidTypes) { if (type.IsEquivalentTo(globalOutputSigmoidType)) { globalOutputSigmoidComboBox.Index = sigmoidTypes.IndexOf(type); } } } globalOutputSigmoidComboBox.SelectedItemChanged += delegate(object sender, int newItemIndex, int oldItemIndex) { chromosome.GlobalOutputSigmoidFunction = (SigmoidFunction)Activator.CreateInstance(sigmoidTypes[newItemIndex]); }; var globalOutputSigmoidEditButton = builder.AddResizableButtonField("Edit GlobalOutputSigmoid", delegate(object sender) { if (chromosome.GlobalOutputSigmoidFunction == null) { return; } var sigmoid = chromosome.GlobalOutputSigmoidFunction; sigmoidTypes[globalOutputSigmoidComboBox.Index].InvokeMember("GUI_Edit", BindingFlags.Default | BindingFlags.InvokeMethod, null, null, new object[] { container.Parent, sigmoid }); }); builder.AddResizableButtonField("Randomize", delegate(object sender) { reloadChromosome(); if (chromosome.GlobalSigmoidFunction == null || chromosome.GlobalOutputSigmoidFunction == null) { AlertForm.ShowDialogue(container.Parent, null, "Can't randomize before choosing a sigmoid function."); } else { RandomizeForm.ShowDialogue(container.Parent, chromosome); } }); builder.AddResizableButtonField("Edit Neuron-genes", delegate(object sender) { reloadChromosome(); EditChromosomeNeuronsForm.ShowDialogue(container.Parent, valueHolder); }); container.IsClosing += delegate(object sender) { reloadChromosome(); }; builder.BuildSessionEnd(); return(delegate() { return chromosome.GlobalSigmoidFunction != null && chromosome.GlobalOutputSigmoidFunction != null; }); }