public DialogEditFixedTiles(int tiles) : this() { Grid = new DrawingAreaGrid() { Tiles = tiles }; VBox.PackEnd(Grid, true, true, 6); Grid.Show(); }
public DialogEditFixedTiles(int tiles) : this() { Grid = new DrawingAreaGrid() { Tiles = tiles }; VBox.PackEnd(Grid, true, true, 6); Grid.Show(); }
public DialogNewGame() { this.Build(); // ==================== // Pixel Initialization // ==================== pixelGrid.CenterGridHorizontally = false; pixelGrid.HeightRequest = 150; tablePixel.Add(pixelGrid); var pixelGridChild = (Gtk.Table.TableChild)tablePixel[pixelGrid]; pixelGridChild.LeftAttach = 1; pixelGridChild.RightAttach = 3; pixelGridChild.TopAttach = 3; pixelGridChild.BottomAttach = 4; pixelGrid.Tiles = 12; pixelGrid.Show(); // ======================= // Flatland Initialization // ======================= treeViewFlatlandTeams.Model = flatlandTeamStore; treeViewFlatlandTeams.AppendColumn("Team", new CellRendererText(), delegate(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) { var teamIndex = (int)model.GetValue(iter, 0); ((CellRendererText)cell).Text = ((char)(((int)'A') + teamIndex)).ToString(); } ); // Set up "Color" column var themeModel = new ListStore(typeof(string)); foreach (var colorName in Enum.GetNames(typeof(ThemeColor)).OrderBy(x => x)) { themeModel.AppendValues(colorName); } var colorColumnRenderer = new CellRendererCombo() { Model = themeModel, TextColumn = 0, Editable = true, HasEntry = false, }; colorColumnRenderer.Edited += delegate(object ds, EditedArgs de) { TreeIter iter; if (flatlandTeamStore.GetIterFromString(out iter, de.Path)) { flatlandTeamStore.SetValue(iter, 1, de.NewText); } }; treeViewFlatlandTeams.AppendColumn("Color", colorColumnRenderer, "text", 1); treeViewFlatlandTeams.Columns[1].MinWidth = 100; // Set up "Kind" column var kindModel = new ListStore(typeof(string)); kindModel.AppendValues("Normal"); kindModel.AppendValues("Predator"); kindModel.AppendValues("Prey"); var kindColumnRenderer = new CellRendererCombo() { Model = kindModel, TextColumn = 0, Editable = true, HasEntry = false }; kindColumnRenderer.Edited += delegate(object ds, EditedArgs de) { TreeIter iter; if (flatlandTeamStore.GetIterFromString(out iter, de.Path)) { flatlandTeamStore.SetValue(iter, 2, de.NewText); } }; treeViewFlatlandTeams.AppendColumn("Kind", kindColumnRenderer, "text", 2); treeViewFlatlandTeams.Columns[2].MinWidth = 100; // Set up "Move Delay" column var moveDelayColumnRenderer = new CellRendererSpin(); moveDelayColumnRenderer.Editable = true; moveDelayColumnRenderer.Adjustment = new Adjustment(3, 1, 9999, 1, 5, 1); moveDelayColumnRenderer.Edited += delegate(object ds, EditedArgs de) { TreeIter iter; if (flatlandTeamStore.GetIterFromString(out iter, de.Path)) { flatlandTeamStore.SetValue(iter, 3, Convert.ToInt32(de.NewText)); } }; treeViewFlatlandTeams.AppendColumn("Move Delay", moveDelayColumnRenderer, "text", 3); // Set up "Wrap" column var wrapColumnRenderer = new CellRendererToggle() { Activatable = true }; wrapColumnRenderer.Toggled += delegate(object ds, ToggledArgs de) { TreeIter iter; if (flatlandTeamStore.GetIterFromString(out iter, de.Path)) { flatlandTeamStore.SetValue(iter, 4, !Convert.ToBoolean(flatlandTeamStore.GetValue(iter, 4))); } }; treeViewFlatlandTeams.AppendColumn("Wrap", wrapColumnRenderer, "active", 4); // Set up "Scoring" column var scoringModel = new ListStore(typeof(string)); scoringModel.AppendValues("None"); scoringModel.AppendValues("Selfish"); scoringModel.AppendValues("Communal"); var scoringColumnRenderer = new CellRendererCombo() { Model = scoringModel, TextColumn = 0, Editable = true, HasEntry = false }; scoringColumnRenderer.Edited += delegate(object ds, EditedArgs de) { TreeIter iter; if (flatlandTeamStore.GetIterFromString(out iter, de.Path)) { flatlandTeamStore.SetValue(iter, 5, de.NewText); } }; treeViewFlatlandTeams.AppendColumn("Scoring", scoringColumnRenderer, "text", 5); treeViewFlatlandTeams.Columns[2].MinWidth = 100; // Add default team flatlandTeamStore.AppendValues(0, "Black", "Normal", 3, false, "None"); // ====================== // Forager Initialization // ====================== treeViewForagerProbabilities.Model = foragerProbabilityStore; treeViewForagerProbabilities.AppendColumn("Plot", new CellRendererText(), "text", 0); // Probability column var probabilityColumnRenderer = new CellRendererSpin(); probabilityColumnRenderer.Editable = true; probabilityColumnRenderer.Adjustment = new Adjustment(1, 0, 100, 1, 5, 1); probabilityColumnRenderer.Edited += delegate(object ds, EditedArgs de) { TreeIter iter; if (foragerProbabilityStore.GetIterFromString(out iter, de.Path)) { var setIndex = comboBoxForagerProbabilitySet.Active; var plotNumber = (int)foragerProbabilityStore.GetValue(iter, 0); var newProbability = Convert.ToInt32(de.NewText); foragerProbabilities[setIndex][plotNumber - 1] = newProbability; foragerProbabilityStore.SetValue(iter, 1, newProbability); } }; treeViewForagerProbabilities.AppendColumn("Probability", probabilityColumnRenderer, "text", 1); // Add default probability set foragerProbabilities.Add(GetDefaultForagerProbabilitySet()); comboBoxForagerProbabilitySet.AppendText("1"); comboBoxForagerProbabilitySet.Active = 0; }