public override float DoEditInterface(PawnFilterListing list) { float rectHeight = RowHeight * 2 + this.filterPartListHeight; Rect rect = list.GetPawnFilterPartRect(this, rectHeight); // Logic gate type list. Rect gateTypeRect = new Rect(rect.x, rect.y, rect.width, RowHeight); if (Widgets.ButtonText(gateTypeRect, this.logicGateType.ToString())) { FloatMenuUtility.MakeMenu((LogicGateType[])Enum.GetValues(typeof(LogicGateType)), type => type.ToString(), type => () => this.logicGateType = type); } // Add part button. Rect addPartButtonRect = new Rect(rect.x, rect.y + gateTypeRect.height, rect.width, RowHeight); if (Widgets.ButtonText(addPartButtonRect, "Add part")) { FloatMenuUtility.MakeMenu(PawnFilter.allFilterParts, def => def.label, def => () => { PawnFilterPart part = (PawnFilterPart)Activator.CreateInstance(def.partClass); part.def = def; this.innerFilter.parts.Add(part); }); } // Build filter field. Rect filterFieldRect = new Rect(rect.x, rect.y + gateTypeRect.height + addPartButtonRect.height, rect.width, this.filterPartListHeight).Rounded(); Widgets.DrawMenuSection(filterFieldRect); filterFieldRect = filterFieldRect.GetInnerRect(); // Draw filter parts. this.filterPartListHeight = filterPartListHeightBuffer; PawnFilterListing filterPartList = new PawnFilterListing() { ColumnWidth = filterFieldRect.width }; filterPartList.Begin(filterFieldRect); List <PawnFilterPart> partsToRemove = new List <PawnFilterPart>(); // Remove parts that should be removed here in order to avoid modifying enumerable during foreach. foreach (PawnFilterPart part in this.innerFilter.parts) { if (part.toRemove) { partsToRemove.Add(part); } else { this.filterPartListHeight += part.DoEditInterface(filterPartList) + RowHeight + PawnFilterListing.gapSize; } } foreach (PawnFilterPart part in partsToRemove) { _ = this.innerFilter.parts.Remove(part); } filterPartList.End(); return(rectHeight); }
public override float DoEditInterface(PawnFilterListing list) { Rect rect = list.GetPawnFilterPartRect(this, RowHeight * 2); // Add skill chooser button. Rect buttonRect = new Rect(rect.x, rect.y, rect.width, rect.height / 2); if (Widgets.ButtonText(buttonRect, this.skill.LabelCap)) { // Fill dropdown. List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (SkillDef def in PawnFilter.allSkills) { options.Add(new FloatMenuOption(def.LabelCap, () => this.skill = def)); } Find.WindowStack.Add(new FloatMenu(options)); } // Add level input field. Rect textFieldRect = new Rect(rect.x, rect.y + buttonRect.height, rect.width, rect.height / 2); Widgets.TextFieldNumeric(textFieldRect, ref this.level, ref this.buffer); return(RowHeight * 2); }
public override float DoEditInterface(PawnFilterListing list) { Rect rect = list.GetPawnFilterPartRect(this, RowHeight * 2); // Add skill chooser button. Rect skillButtonRect = new Rect(rect.x, rect.y, rect.width, rect.height / 2); if (Widgets.ButtonText(skillButtonRect, this.skill.LabelCap)) { // Fill dropdown. List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (SkillDef def in PawnFilter.allSkills) { options.Add(new FloatMenuOption(def.LabelCap, () => this.skill = def)); } Find.WindowStack.Add(new FloatMenu(options)); } // Add passion chooser button. Rect passionButtonRect = new Rect(rect.x, rect.y + skillButtonRect.height, rect.width, rect.height / 2); if (Widgets.ButtonText(passionButtonRect, this.passionLevel.ToString().CapitalizeFirst())) { // Fill dropdown. List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (Passion passionLevel in Enum.GetValues(typeof(Passion))) { options.Add(new FloatMenuOption(passionLevel.ToString().CapitalizeFirst(), () => this.passionLevel = passionLevel)); } Find.WindowStack.Add(new FloatMenu(options)); } return(RowHeight * 2); }
public override float DoEditInterface(PawnFilterListing list) { Rect rect = list.GetPawnFilterPartRect(this, RowHeight * 2); // Trait list. Rect traitRect = new Rect(rect.x, rect.y, rect.width, rect.height / 2); if (Widgets.ButtonText(traitRect, this.trait.defName.CapitalizeFirst())) { // Fill trait dropdown when button is pressed. List <FloatMenuOption> traitOptions = new List <FloatMenuOption>(); foreach (TraitDef def in PawnFilter.allTraits) { traitOptions.Add(new FloatMenuOption(def.defName.CapitalizeFirst(), () => this.SelectTrait(def))); } Find.WindowStack.Add(new FloatMenu(traitOptions)); } // Degree list. Rect degreeRect = new Rect(rect.x, rect.y + traitRect.height, rect.width, rect.height / 2); if (Widgets.ButtonText(degreeRect, this.trait.DataAtDegree(this.degree).LabelCap)) { // Fill degree dropdown when button is pressed. List <FloatMenuOption> degreeOptions = new List <FloatMenuOption>(); foreach (TraitDegreeData data in this.trait.degreeDatas) { degreeOptions.Add(new FloatMenuOption(data.LabelCap, () => this.degree = data.degree)); } Find.WindowStack.Add(new FloatMenu(degreeOptions)); } return(RowHeight * 2); }
public override float DoEditInterface(PawnFilterListing list) { Rect rect = list.GetPawnFilterPartRect(this, RowHeight); Widgets.IntRange(rect, random.Next(0x0, 0xFFFFF), ref this.range, 14); return(RowHeight); }
public override float DoEditInterface(PawnFilterListing list) { Rect rect = list.GetPawnFilterPartRect(this, RowHeight * 2); // Skill count input field. Rect skillCountRect = new Rect(rect.x, rect.y, rect.width, rect.height / 2); Widgets.TextFieldNumeric(skillCountRect, ref this.skillCount, ref this.skillCountBuffer); // Skill level input field. Rect skillLevelRect = new Rect(rect.x, rect.y + skillCountRect.height, rect.width, rect.height / 2); Widgets.TextFieldNumeric(skillLevelRect, ref this.skillLevel, ref this.skillLevelBuffer); return(RowHeight * 2); }