public override IList <PieceRequest> PickPiece(IPieceRequester peer, BitField available, IReadOnlyList <IPieceRequester> otherPeers, int count, int startIndex, int endIndex) { PieceRequest request; IList <PieceRequest> bundle; if (HighPriorityPieceIndex >= startIndex && HighPriorityPieceIndex <= endIndex) { var start = HighPriorityPieceIndex; var end = Math.Min(endIndex, HighPriorityPieceIndex + HighPriorityCount - 1); if ((request = BasePicker.ContinueAnyExisting(peer, start, end)) != null) { return new[] { request } } ; if ((bundle = base.PickPiece(peer, available, otherPeers, count, start, end)) != null) { return(bundle); } } if (endIndex < HighPriorityPieceIndex) { return(null); } var lowPriorityEndIndex = Math.Min(HighPriorityPieceIndex + LowPriorityCount, endIndex); if ((bundle = LowPriorityPicker.PickPiece(peer, available, otherPeers, count, HighPriorityPieceIndex, lowPriorityEndIndex)) != null) { return(bundle); } return(LowPriorityPicker.PickPiece(peer, available, otherPeers, count, HighPriorityPieceIndex, endIndex)); }
protected BasePickerField(ExporterWindow window, BasePicker picker = null, GUIStyle style = null) { Window = window; Picker = picker ?? DefaultPicker(); Picker.OptionGenerator = GenerateOptions; Picker.SelectionHandler += SelectionMade; Picker.SelectionHandler += entry => window.Repaint(); }
public override void Deactivate() { base.Deactivate(); if (state != States.Inactive && pendingState != States.Inactive) { pendingState = States.Inactive; this.composedObjectPending = null; BokuGame.objectListDirty = true; for (int i = 0; i < Count; ++i) { GroupData groupData = this[i] as GroupData; if (groupData != null) { UiSelector uiSelector = groupData.selectorGroup as UiSelector; if (uiSelector != null) { uiSelector.Deactivate(); } } } if (typePicker != null) { typePicker.OnGetType = holdOnGet; typePicker.OnSetType = holdOnSet; typePicker.OnPickType = holdOnPick; typePicker.Active = false; typePicker.Hidden = true; typePicker.UseAltOverlay = false; typePicker = null; } HelpOverlay.Pop(); } } // end of Deactivate()
//private void ListItemTapped(object sender, ItemTappedEventArgs e) //{ // var listView = sender as ListView; // ToppingDisplayItem selectedItem = listView.SelectedItem as ToppingDisplayItem; // int indexOfItemSelected = selectedItem.SelectionIndex; // //Can't change ListView directly - must change underlying data. Get this data by the index. // ToppingDisplayItem thisSelection = ToppingsPageModel.ToppingSelectionsList[indexOfItemSelected]; // if (thisSelection.ListTopping.ToppingName == ToppingName.HalfMajor) // { // ProcessHalfMajorToppingSelection(thisSelection); // } // else // { // thisSelection.ListItemIsSelected = !thisSelection.ListItemIsSelected; // if (thisSelection.ListItemIsSelected) // { // thisSelection.ListTopping.SequenceSelected = ToppingsPageModel.ThisPizza.Toppings.CurrentToppings.Count + 1; // ToppingsPageModel.ThisPizza.Toppings.AddTopping(thisSelection.ListTopping); // thisSelection.SelectionColor = Xamarin.Forms.Color.CornflowerBlue; // thisSelection.ButtonWSelected = true; // } // else // { // thisSelection.ListTopping.SequenceSelected = 0; // ToppingsPageModel.ThisPizza.Toppings.RemoveTopping(thisSelection.ListTopping.ToppingName); // thisSelection.SelectionColor = Xamarin.Forms.Color.Black; // thisSelection.ButtonASelected = false; // thisSelection.ButtonBSelected = false; // thisSelection.ButtonWSelected = false; // } // } //} ////For selection or deselection of the Half Major topping. //private void ProcessHalfMajorToppingSelection(ToppingDisplayItem halfMajorSelection) //{ // if (halfMajorSelection.ListItemIsSelected) //If selected, toggle to unselect... // { // ToppingsPageModel.ThisPizza.Toppings.RemoveToppings(new List<ToppingName> // { // ToppingName.Mushrooms, // ToppingName.BlackOlives, // ToppingName.GreenPeppers, // ToppingName.Onion, // ToppingName.Pepperoni, // ToppingName.Sausage // }); // foreach (var toppingSelection in ToppingsPageModel.ToppingSelectionsList) // { // if (toppingSelection.ListTopping.ToppingName == ToppingName.Mushrooms || // toppingSelection.ListTopping.ToppingName == ToppingName.GreenPeppers || // toppingSelection.ListTopping.ToppingName == ToppingName.Onion || // toppingSelection.ListTopping.ToppingName == ToppingName.Pepperoni || // toppingSelection.ListTopping.ToppingName == ToppingName.Sausage || // toppingSelection.ListTopping.ToppingName == ToppingName.BlackOlives) // { // toppingSelection.ButtonWSelected = false; // toppingSelection.ButtonASelected = false; // toppingSelection.ButtonBSelected = false; // toppingSelection.ListItemIsSelected = false; // } // } // halfMajorSelection.ListItemIsSelected = false; // halfMajorSelection.ButtonWSelected = false; // halfMajorSelection.ButtonASelected = false; // halfMajorSelection.ButtonBSelected = false; // } // else // { // ToppingsPageModel.SelectMajorToppings(halfMajorSelection.ListTopping.ToppingWholeHalf); // ToppingsPageModel.ThisPizza.Toppings.AddMajorToppingsToHalf(ToppingWholeHalf.HalfA); // halfMajorSelection.ListItemIsSelected = true; // halfMajorSelection.ButtonASelected = true; // } // halfMajorSelection.ListItemIsSelected = !halfMajorSelection.ListItemIsSelected; //} private void BasePickerTapped(object sender, EventArgs e) { BasePicker.Focus(); }
protected ClassPickerField(ExporterWindow window, BasePicker picker = null, GUIStyle style = null) : base(window, picker, style) { }
public override void Activate() { if (state != States.Active) { pendingState = States.Active; BokuGame.objectListDirty = true; Editor editor = InGame.inGame.Editor; if (editor.Active) { HelpOverlay.Push(@"PieSelectorProgrammingNoSelection"); } else { HelpOverlay.Push(@"PieSelectorAddItemNoSelection"); } if (SelectWater || SetWater) { WaterPicker waterPicker = InGame.inGame.shared.ToolBox.WaterPicker; holdOnGet = waterPicker.OnGetType; holdOnSet = waterPicker.OnSetType; holdOnPick = waterPicker.OnPickType; waterPicker.OnGetType = OnGetWater; waterPicker.OnSetType = OnSetWater; waterPicker.OnPickType = OnPickWater; typePicker = waterPicker; if (SetWater) { lastWaterIndex = RootData.SetWaterTypeIndex; } else { lastWaterIndex = RootData.WaterType; } if (lastWaterIndex < 0) { lastWaterIndex = Water.CurrentType; } } else { MaterialPicker matPicker = InGame.inGame.shared.ToolBox.MaterialPicker; holdOnGet = matPicker.OnGetType; holdOnSet = matPicker.OnSetType; holdOnPick = matPicker.OnPickType; matPicker.OnGetType = OnGetTerrain; matPicker.OnSetType = OnSetTerrain; matPicker.OnPickType = OnPickTerrain; matPicker.UseAltOverlay = true; typePicker = matPicker; ushort rootDataMatIdx = (ushort)RootData.MaterialType; if (TerrainMaterial.IsValid(rootDataMatIdx, false, false)) { lastTerrainIndex = rootDataMatIdx; } else if (!TerrainMaterial.IsValid(lastTerrainIndex, false, false)) { lastTerrainIndex = Terrain.CurrentMaterialIndex; } } typePicker.Active = true; typePicker.Hidden = false; } }
public PreloadPickerField(ExporterWindow window, BasePicker picker = null, GUIStyle style = null) : base(window, picker, style) { }