private void DrawStoneTypesSelection() { DrawEntryHeader("StoneTypesHere".Translate(), backgroundColor: ColorLibrary.RoyalPurple); var selectedStoneDefs = _gameData.GodModeData.SelectedStoneDefs; var orderedStoneDefs = _gameData.GodModeData.OrderedStoneDefs; // Reset button: reset all entries to Off state if (ListingStandard.ButtonText("Reset")) { _gameData.GodModeData.ResetSelectedStoneDefs(); } // re-orderable list group var reorderableGroup = ReorderableWidget.NewGroup(delegate(int from, int to) { orderedStoneDefs.ReorderElements(from, to); SoundDefOf.Tick_High.PlayOneShotOnCamera(); }, ReorderableDirection.Vertical); var maxNumStones = (InRect.height - ListingStandard.CurHeight - DefaultGapLineHeight - DefaultElementHeight - 15f) / DefaultElementHeight; var maxHeight = maxNumStones * DefaultElementHeight; var height = Mathf.Min(selectedStoneDefs.Count * DefaultElementHeight, maxHeight); // stone types, standard selection var inLs = ListingStandard.BeginScrollView(height, selectedStoneDefs.Count * DefaultElementHeight, ref _scrollPosStoneSelection, DefaultScrollableViewShrinkWidth); foreach (var currentOrderedStoneDef in orderedStoneDefs) { var itemRect = inLs.GetRect(DefaultElementHeight); var tmpState = selectedStoneDefs[currentOrderedStoneDef]; var selected = currentOrderedStoneDef == _selectedStoneDef; if (Widgets.CheckboxLabeledSelectable(itemRect, currentOrderedStoneDef.LabelCap, ref selected, ref tmpState)) { _selectedStoneDef = currentOrderedStoneDef; } // if the state changed, update the item with the new state if (tmpState != selectedStoneDefs[currentOrderedStoneDef]) { selectedStoneDefs[currentOrderedStoneDef] = tmpState; } ReorderableWidget.Reorderable(reorderableGroup, itemRect); if (!string.IsNullOrEmpty(currentOrderedStoneDef.description)) { TooltipHandler.TipRegion(itemRect, currentOrderedStoneDef.description); } } ListingStandard.EndScrollView(inLs); }
public bool CheckboxLabeledSelectable(string label, ref bool selected, ref bool checkOn) { float lineHeight = Text.LineHeight; bool result = Widgets.CheckboxLabeledSelectable(GetRect(lineHeight), label, ref selected, ref checkOn); Gap(verticalSpacing); return(result); }
public bool CustomButtonTextSelectable(string label, ref bool selected, ref bool checkOn) { float lineHeight = Text.LineHeight; Rect rect = base.GetRect(lineHeight); bool result = Widgets.CheckboxLabeledSelectable(rect, label, ref selected, ref checkOn); base.Gap(this.verticalSpacing); return(result); }
private void DoModRow(Rect r, ModMetaData mod, int index, int reorderableGroup) { bool active = mod.Active; Action clickAction = null; if (mod.Source == ContentSource.SteamWorkshop) { clickAction = delegate { SteamUtility.OpenWorkshopPage(mod.GetPublishedFileId()); }; } ContentSourceUtility.DrawContentSource(r, mod.Source, clickAction); r.xMin += 28f; bool selected = mod == selectedMod; Rect rect = r; if (mod.enabled) { string text = ""; if (active) { text += "DragToReorder".Translate() + ".\n"; } if (!mod.VersionCompatible) { GUI.color = Color.yellow; if (!text.NullOrEmpty()) { text += "\n"; } text = ((!mod.MadeForNewerVersion) ? ((string)(text + "ModNotMadeForThisVersion".Translate())) : ((string)(text + "ModNotMadeForThisVersion_Newer".Translate()))); } if (active && !modWarningsCached.NullOrEmpty() && !modWarningsCached[index].NullOrEmpty()) { GUI.color = Color.red; if (!text.NullOrEmpty()) { text += "\n"; } text += modWarningsCached[index]; } GUI.color = FilteredColor(GUI.color, mod.Name); if (!text.NullOrEmpty()) { TooltipHandler.TipRegion(rect, new TipSignal(text, mod.GetHashCode() * 3311)); } float num = rect.width - 24f; if (active) { GUI.DrawTexture(new Rect(rect.xMax - 48f + 2f, rect.y, 24f, 24f), TexButton.DragHash); num -= 24f; } Text.Font = GameFont.Small; string label = mod.Name.Truncate(num, truncatedModNamesCache); bool checkOn = active; if (Widgets.CheckboxLabeledSelectable(rect, label, ref selected, ref checkOn)) { selectedMod = mod; RecacheSelectedModRequirements(); } if (active && !checkOn && mod.IsCoreMod) { ModMetaData coreMod = mod; Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmDisableCoreMod".Translate(), delegate { coreMod.Active = false; truncatedModNamesCache.Clear(); })); } else { if (!active && checkOn) { foreach (ModMetaData item in ModsConfig.ActiveModsInLoadOrder) { if (item.PackageIdNonUnique.Equals(mod.PackageIdNonUnique, StringComparison.InvariantCultureIgnoreCase)) { Find.WindowStack.Add(new Dialog_MessageBox("MessageModWithPackageIdAlreadyEnabled".Translate(mod.PackageIdPlayerFacing, item.Name))); return; } } } if (checkOn != active) { mod.Active = checkOn; } truncatedModNamesCache.Clear(); } } else { GUI.color = FilteredColor(Color.gray, mod.Name); Widgets.Label(rect, mod.Name); } GUI.color = Color.white; }
private void DoModRow(Listing_Standard listing, ModMetaData mod, int index, int reorderableGroup) { Rect rect = listing.GetRect(26f); if (mod.Active) { ReorderableWidget.Reorderable(reorderableGroup, rect, false); } Action clickAction = null; if (mod.Source == ContentSource.SteamWorkshop) { clickAction = delegate { SteamUtility.OpenWorkshopPage(mod.GetPublishedFileId()); }; } ContentSourceUtility.DrawContentSource(rect, mod.Source, clickAction); rect.xMin += 28f; bool flag = mod == this.selectedMod; bool active = mod.Active; Rect rect2 = rect; if (mod.enabled) { string text = string.Empty; if (mod.Active) { text = text + "DragToReorder".Translate() + ".\n\n"; } if (!mod.VersionCompatible) { GUI.color = Color.red; if (mod.MadeForNewerVersion) { text += "ModNotMadeForThisVersion_Newer".Translate(); } else { text += "ModNotMadeForThisVersion".Translate(); } } GUI.color = this.FilteredColor(GUI.color, mod.Name); if (!text.NullOrEmpty()) { TooltipHandler.TipRegion(rect2, new TipSignal(text, mod.GetHashCode() * 3311)); } float num = rect2.width - 24f; if (mod.Active) { Rect position = new Rect(rect2.xMax - 48f + 2f, rect2.y, 24f, 24f); GUI.DrawTexture(position, TexButton.DragHash); num -= 24f; } Text.Font = GameFont.Small; string label = mod.Name.Truncate(num, this.truncatedModNamesCache); if (Widgets.CheckboxLabeledSelectable(rect2, label, ref flag, ref active)) { this.selectedMod = mod; } if (mod.Active && !active && mod.IsCoreMod) { ModMetaData coreMod = mod; Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmDisableCoreMod".Translate(), delegate { coreMod.Active = false; this.truncatedModNamesCache.Clear(); }, false, null)); } else { mod.Active = active; this.truncatedModNamesCache.Clear(); } } else { GUI.color = this.FilteredColor(Color.gray, mod.Name); Widgets.Label(rect2, mod.Name); } GUI.color = Color.white; }
private static void DoModRow(Listing_Standard listing, ModMetaDataEnhanced mod, int index, int reorderableGroup = -1) { Rect rect = listing.GetRect(26f); if (mod.Active && !SearchInProgress) { ReorderableWidget.Reorderable(reorderableGroup, rect); } Action clickAction = null; if (mod.Source == ContentSource.SteamWorkshop) { clickAction = CreateModRowActionSteam(mod); } else { clickAction = CreateModRowActionLocal(mod); } ContentSourceUtility.DrawContentSource(rect, mod.Source, clickAction); rect.xMin += 28f; bool active = mod.Active; bool isSelected = mod.OriginalMetaData == selectedMod.OriginalMetaData; Rect rect2 = rect; if (mod.Enabled && RenameInProgress == false) { string text = string.Empty; if (mod.Active) { text = text + "DragToReorder".Translate() + ".\n\n"; } if (!text.NullOrEmpty()) { TooltipHandler.TipRegion(rect2, new TipSignal(text, mod.GetHashCode() * 3311)); } Color origColor = GUI.color; GUI.color = mod.TextColor; if (Widgets.CheckboxLabeledSelectable(rect2, mod.Name, ref isSelected, ref active)) { selectedMod = mod; } GUI.color = origColor; if (mod.Active && reorderableGroup >= 0) { Rect texRect = new Rect(rect2.xMax - 48f + 2f, rect2.y, 24f, 24f); GUI.DrawTexture(texRect, Textures.DragHash); } if (mod.HasNotifications) { Color notifColour = Color.gray; string tooltipString = string.Empty; foreach (NotificationBase notification in mod.Notifications) { if (notification.MessageType == NotificationType.Error) { notifColour = Color.red; } else if (notification.MessageType == NotificationType.Warning && notifColour != Color.red) { notifColour = Color.yellow; } tooltipString += notification.MessageText + "\n\n"; } Text.Anchor = TextAnchor.MiddleCenter; Text.Font = GameFont.Medium; GUI.color = notifColour; Rect dupRect = new Rect(rect2.xMax - 72f + 2f, rect.y, 24f, 24f); Widgets.Label(dupRect, "!"); TooltipHandler.ClearTooltipsFrom(dupRect); TooltipHandler.TipRegion(dupRect, tooltipString.Trim()); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; GUI.color = Color.white; } if (mod.Active && !active && mod.Name == ModContentPack.CoreModIdentifier) { ModMetaData coreMod = mod.OriginalMetaData; Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmDisableCoreMod".Translate(), delegate { coreMod.Active = false; truncatedModNamesCache.Clear(); }, false, null)); } else { mod.Active = active; truncatedModNamesCache.Clear(); } } else if (RenameInProgress == true && isSelected) { renameBuf = Widgets.TextField(rect2, renameBuf); } else { GUI.color = Color.gray; Widgets.Label(rect2, mod.Name); } GUI.color = Color.white; }