void WriteChanges() { LevelManager.WriteProjectiles(Projectiles); }
public void SetProjectile(string selectedStr) { GtkHelpers.FlushAllDeferredEvents(); Destroyed += ProjectileEditLayout_Destroyed; if (null != Layout) { Layout.Hide(); Layout.Destroy(); Layout = null; } Projectiles = LevelManager.GetProjectiles(); Projectile = null; for (int i = 0; i < Projectiles.Count; i++) { if (Projectiles[i].Name == selectedStr) { Projectile = Projectiles[i]; } } if (Projectile == null) { throw new Exception("Could not find Projectile " + selectedStr); } Layout = new VBox(false, 0); AddWithViewport(Layout); HBox field = GtkHelpers.TextEntryField("Projectile Name", Projectile.Name, Name_Changed, true); Layout.PackStart(field, false, false, 0); field.Show(); field = GtkHelpers.TextEntryField("Asset", Projectile.Asset, Asset_Changed, true); Layout.PackStart(field, false, false, 0); field.Show(); field = GtkHelpers.TextEntryField("Impact Asset", Projectile.ImpactAsset, ImpactAsset_Changed, true); Layout.PackStart(field, false, false, 0); field.Show(); field = GtkHelpers.TextEntryField("AirSpeed", Projectile.AirSpeed.ToString(), AirSpeed_Changed, true, GtkHelpers.ValueType.Float); Layout.PackStart(field, false, false, 0); field.Show(); EffectsTree = new TreeView(); Layout.PackStart(EffectsTree, false, false, 0); EffectsTree.Show(); ComboBoxText comboBox = new ComboBoxText(); foreach (string name in Enum.GetNames(typeof(ProjectileEffectType))) { comboBox.AppendText(name); } comboBox.Active = 0; TreeViewColumn typeCoumn = new TreeViewColumn(); TreeViewColumn impactColumn = new TreeViewColumn(); TreeViewColumn durationColumn = new TreeViewColumn(); TreeViewColumn radiusColumn = new TreeViewColumn(); CellRendererText durationCellRenderer = new CellRendererText(); durationCellRenderer.Editable = true; durationCellRenderer.Edited += DurationCell_Edited; CellRendererText impactCellRenderer = new CellRendererText(); impactCellRenderer.Editable = true; impactCellRenderer.Edited += ImpactCell_Edited; CellRendererText radiusCellRenderer = new CellRendererText(); radiusCellRenderer.Editable = true; radiusCellRenderer.Edited += RadiusCellRenderer_Edited; CellRendererCombo comboCellRenderer = new CellRendererCombo(); comboCellRenderer.Editable = true; comboCellRenderer.Edited += ComboCellRenderer_Edited; comboCellRenderer.TextColumn = 0; comboCellRenderer.HasEntry = false; typeCoumn.PackStart(comboCellRenderer, true); typeCoumn.Title = "Type"; typeCoumn.AddAttribute(comboCellRenderer, "text", 1); EffectsTree.AppendColumn(typeCoumn); durationColumn.PackStart(durationCellRenderer, true); durationColumn.Title = "Duration"; durationColumn.AddAttribute(durationCellRenderer, "text", 2); EffectsTree.AppendColumn(durationColumn); impactColumn.PackStart(impactCellRenderer, true); impactColumn.Title = "Impact"; impactColumn.AddAttribute(impactCellRenderer, "text", 3); EffectsTree.AppendColumn(impactColumn); radiusColumn.PackStart(radiusCellRenderer, true); radiusColumn.Title = "Radius"; radiusColumn.AddAttribute(radiusCellRenderer, "text", 4); EffectsTree.AppendColumn(radiusColumn); EffectsModel = new ListStore(typeof(int), typeof(string), typeof(float), typeof(float), typeof(float)); EffectsTree.Model = EffectsModel; EffectsTree.Selection.Mode = SelectionMode.Single; PopulateTreeWithEffects(); field = new HBox(false, 5); Layout.PackStart(field, false, false, 0); field.Show(); Button b = new Button("+"); b.Clicked += NewEffect_Clicked; b.Show(); field.PackStart(b, false, false, 0); b = new Button("-"); b.Clicked += RemoveEffect_Clicked; b.Show(); field.PackStart(b, false, false, 0); Show(); ShowAll(); }