public override void DoWindowContents(Rect inRect) { try { const int NAME_WIDTH = 100; const int CHECKBOX_WIDTH = 100; const int HEIGHT = 35; const int X_BUFFER = 10; const int Y_BUFFER = 5; //bool useInApparelLookup = this.Dresser.UseInApparelLookup; //Widgets.CheckboxLabeled(new Rect(0, 0, 300, HEIGHT), "ChangeDresser.UseAsApparelSource".Translate(), ref useInApparelLookup); //this.Dresser.UseInApparelLookup = useInApparelLookup; if (Widgets.ButtonText(new Rect(/*450*/ 0, 0, 150, HEIGHT), "ChangeDresser.ManageOutfits".Translate())) { Find.WindowStack.Add(new Dialog_ManageOutfits(null /*Current.Game.outfitDatabase.DefaultOutfit*/)); } List <Outfit> allOutfits = Current.Game.outfitDatabase.AllOutfits; int y = 50 + HEIGHT + Y_BUFFER; GUI.BeginScrollView( new Rect(0, y, inRect.width - 32, HEIGHT * 2 + Y_BUFFER * 3), this.scrollPosition, new Rect(0, y, NAME_WIDTH + X_BUFFER + ((CHECKBOX_WIDTH + X_BUFFER) * allOutfits.Count), HEIGHT * 2 + Y_BUFFER * 3), GUIStyle.none, GUIStyle.none); // Header - Lists the Outfit names int x = NAME_WIDTH + X_BUFFER; //y = 0; foreach (Outfit o in allOutfits) { //Widgets.Label(new Rect(x, y, NAME_WIDTH, HEIGHT), "Pawns".Translate()); //x += CHECKBOX_WIDTH + X_BUFFER; Widgets.Label(new Rect(x, y, CHECKBOX_WIDTH, HEIGHT), o.label); x += CHECKBOX_WIDTH + X_BUFFER; } y += HEIGHT + Y_BUFFER; // Use For Battle row x = 0; Widgets.Label(new Rect(x, y, NAME_WIDTH, HEIGHT), "ChangeDresser.UseForBattle".Translate()); x += NAME_WIDTH + X_BUFFER; foreach (Outfit o in allOutfits) { bool use = WorldComp.OutfitsForBattle.Contains(o); bool useNoChange = use; Widgets.Checkbox(x + 10, y, ref use); x += CHECKBOX_WIDTH + X_BUFFER; if (use != useNoChange) { if (use) { WorldComp.OutfitsForBattle.Add(o); } else { bool removed = WorldComp.OutfitsForBattle.Remove(o); } foreach (PawnOutfitTracker po in WorldComp.PawnOutfits.Values) { po.UpdateOutfitType(o, (use) ? OutfitType.Battle : OutfitType.Civilian); } } } y += HEIGHT + Y_BUFFER * 2; Widgets.DrawLineHorizontal(NAME_WIDTH + X_BUFFER, y - 4, NAME_WIDTH + X_BUFFER + ((CHECKBOX_WIDTH + X_BUFFER) * allOutfits.Count)); GUI.EndScrollView(); // Pawn Names GUI.BeginScrollView( new Rect(0, y, NAME_WIDTH, inRect.height - y - 82), this.scrollPosition, new Rect(0, y, NAME_WIDTH, (HEIGHT + Y_BUFFER) * WorldComp.PawnOutfits.Values.Count), GUIStyle.none, GUIStyle.none); x = 0; int py = y; foreach (PawnOutfitTracker po in WorldComp.PawnOutfits.Values) { Widgets.Label(new Rect(x, py, NAME_WIDTH, HEIGHT), po.Pawn.Name.ToStringShort); py += HEIGHT + Y_BUFFER; } Widgets.DrawLineVertical(NAME_WIDTH + 2, y, (HEIGHT + Y_BUFFER) * WorldComp.PawnOutfits.Values.Count); GUI.EndScrollView(); int mainScrollXMin = NAME_WIDTH + X_BUFFER + 4; this.scrollPosition = GUI.BeginScrollView( new Rect(mainScrollXMin, y, inRect.width - mainScrollXMin, inRect.height - y - 50), this.scrollPosition, new Rect(0, y, NAME_WIDTH + X_BUFFER + ((CHECKBOX_WIDTH + X_BUFFER) * allOutfits.Count) - mainScrollXMin, (HEIGHT + Y_BUFFER) * WorldComp.PawnOutfits.Values.Count)); // Table of pawns and assigned outfits foreach (PawnOutfitTracker po in WorldComp.PawnOutfits.Values) { x = 0; foreach (Outfit o in allOutfits) { bool assign = po.Contains(o); bool assignNoChange = assign; Widgets.Checkbox(x + 10, y, ref assign); x += CHECKBOX_WIDTH + X_BUFFER; if (assign != assignNoChange) { this.HandleOutfitAssign(assign, o, po); } /* * bool assign = WorldComp.OutfitsForBattle.Contains(o); * Widgets.Checkbox(x + 10, y, ref assign); * if (Widgets.ButtonInvisible(new Rect(x + 5, y + 5, CHECKBOX_WIDTH - 5, HEIGHT - 5))) * { * this.HandleOutfitAssign(!WorldComp.OutfitsForBattle.Contains(o), o, po); * } */ } y += HEIGHT + Y_BUFFER; } GUI.EndScrollView(); } catch (Exception e) { Log.Error(e.GetType() + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace); } }
public void DoContent(Rect rect) { // layout: settings | trees // draw background Widgets.DrawMenuSection(rect); // rects var optionsColumnRect = new Rect( rect.xMin, rect.yMin, rect.width * 3 / 5f, rect.height - Margin - ButtonSize.y); var treesColumnRect = new Rect( optionsColumnRect.xMax, rect.yMin, rect.width * 2 / 5f, rect.height - Margin - ButtonSize.y); var buttonRect = new Rect( rect.xMax - ButtonSize.x, rect.yMax - ButtonSize.y, ButtonSize.x - Margin, ButtonSize.y - Margin); Vector2 position; float width; Widgets_Section.BeginSectionColumn(optionsColumnRect, "Forestry.Options", out position, out width); Widgets_Section.Section(ref position, width, DrawJobType, "FMF.JobType".Translate()); if (_selected.Type == ManagerJob_Forestry.ForestryJobType.ClearArea) { Widgets_Section.Section(ref position, width, DrawClearArea, "FMF.JobType.ClearArea".Translate()); } if (_selected.Type == ManagerJob_Forestry.ForestryJobType.Logging) { Widgets_Section.Section(ref position, width, DrawThreshold, "FM.Threshold".Translate()); Widgets_Section.Section(ref position, width, DrawAreaRestriction, "FMF.LoggingArea".Translate()); Widgets_Section.Section(ref position, width, DrawAllowSaplings); } Widgets_Section.EndSectionColumn("Forestry.Options", position); Widgets_Section.BeginSectionColumn(treesColumnRect, "Forestry.Trees", out position, out width); Widgets_Section.Section(ref position, width, DrawTreeShortcuts, "FMF.Trees".Translate()); Widgets_Section.Section(ref position, width, DrawTreeList); Widgets_Section.EndSectionColumn("Forestry.Trees", position); // do the button if (!_selected.Managed) { if (Widgets.ButtonText(buttonRect, "FM.Manage".Translate())) { // activate job, add it to the stack _selected.Managed = true; manager.JobStack.Add(_selected); // refresh source list Refresh(); } } else { if (Widgets.ButtonText(buttonRect, "FM.Delete".Translate())) { // inactivate job, remove from the stack. manager.JobStack.Delete(_selected); // remove content from UI _selected = null; // refresh source list Refresh(); } } }
private float DrawFollowSection(Vector2 pos, float width) { var start = pos; var rowRect = new Rect(pos.x, pos.y, width, ListEntryHeight); var buttonRect = new Rect( rowRect.xMax * 3 / 4, 0f, width * 1 / 4, ListEntryHeight * 2 / 3) .CenteredOnYIn(rowRect); // master selection Label(rowRect, "FM.Livestock.MasterDefault".Translate(), "FM.Livestock.MasterDefault.Tip".Translate(), TextAnchor.MiddleLeft, margin: Margin); if (Widgets.ButtonText(buttonRect, GetMasterLabel())) { var options = new List <FloatMenuOption>(); // modes foreach (var _mode in GetMasterModes.Where(mm => (mm & MasterMode.All) == mm)) { options.Add(new FloatMenuOption($"FM.Livestock.MasterMode.{_mode}".Translate(), () => _selectedCurrent.Masters = _mode)); } // specific pawns foreach (var pawn in _selectedCurrent.Trigger.pawnKind.GetMasterOptions(manager, MasterMode.All)) { options.Add(new FloatMenuOption("FM.Livestock.Master".Translate(pawn.LabelShort, pawn.skills.AverageOfRelevantSkillsFor(WorkTypeDefOf.Handling)), () => { _selectedCurrent.Master = pawn; _selectedCurrent.Masters = MasterMode.Specific; })); } Find.WindowStack.Add(new FloatMenu(options)); } // respect bonds? rowRect.y += ListEntryHeight; if (_selectedCurrent.Masters != MasterMode.Default && _selectedCurrent.Masters != MasterMode.Specific) { DrawToggle(rowRect, "FM.Livestock.RespectBonds".Translate(), "FM.Livestock.RespectBonds.Tip".Translate(), ref _selectedCurrent.RespectBonds); } else { Label(rowRect, "FM.Livestock.RespectBonds".Translate(), "FM.Livestock.RespectBonds.DisabledBecauseMastersNotSet".Translate(), color: Color.grey, margin: Margin); } // default follow rowRect.y += ListEntryHeight; DrawToggle(rowRect, "FM.Livestock.Follow".Translate(), "FM.Livestock.Follow.Tip".Translate(), ref _selectedCurrent.SetFollow); if (_selectedCurrent.SetFollow) { rowRect.y += ListEntryHeight; var followRect = rowRect; followRect.width /= 2f; DrawToggle(followRect, "FM.Livestock.FollowDrafted".Translate(), "FM.Livestock.FollowDrafted.Tip".Translate(), ref _selectedCurrent.FollowDrafted, font: GameFont.Tiny); followRect.x += followRect.width; DrawToggle(followRect, "FM.Livestock.FollowFieldwork".Translate(), "FM.Livestock.FollowFieldwork.Tip".Translate(), ref _selectedCurrent.FollowFieldwork, font: GameFont.Tiny); } // follow when training rowRect.y += ListEntryHeight; TooltipHandler.TipRegion(rowRect, "FM.Livestock.FollowTraining.Tip".Translate()); DrawToggle(rowRect, "FM.Livestock.FollowTraining".Translate(), "FM.Livestock.FollowTraining.Tip".Translate(), ref _selectedCurrent.FollowTraining); // master selection if (_selectedCurrent.FollowTraining) { rowRect.y += ListEntryHeight; Label(rowRect, "FM.Livestock.MasterTraining".Translate(), "FM.Livestock.MasterTraining.Tip".Translate(), TextAnchor.MiddleLeft, margin: Margin); buttonRect = buttonRect.CenteredOnYIn(rowRect); if (Widgets.ButtonText(buttonRect, GetTrainerLabel())) { var options = new List <FloatMenuOption>(); // modes foreach (var _mode in GetMasterModes.Where(mm => (mm & MasterMode.Trainers) == mm)) { options.Add(new FloatMenuOption($"FM.Livestock.MasterMode.{_mode}".Translate(), () => _selectedCurrent.Trainers = _mode)); } // specific pawns foreach (var pawn in _selectedCurrent.Trigger.pawnKind.GetTrainers(manager, MasterMode.Trainers)) { options.Add(new FloatMenuOption( "FM.Livestock.Master".Translate(pawn.LabelShort, pawn.skills.AverageOfRelevantSkillsFor(WorkTypeDefOf.Handling)), () => { _selectedCurrent.Trainer = pawn; _selectedCurrent.Trainers = MasterMode.Specific; })); } Find.WindowStack.Add(new FloatMenu(options)); } } return(rowRect.yMax - start.y); }
public override void DoWindowContents(Rect inRect) { if (searchQuery != lastSearch) { GetTradeables(); } GUI.BeginGroup(inRect); Rect rect2 = new Rect(inRect.width - 590f, 0f, 590f, 58f); GameFont old = Text.Font; Text.Font = GameFont.Medium; Widgets.Label(rect2, "Store Items"); Text.Font = old; Rect searchBar = new Rect(0f, 30f, 300f, 26f); searchQuery = Widgets.TextEntryLabeled(searchBar, "Search:", searchQuery); Rect resetButton = new Rect(inRect.width - 150f, 0f, 100f, 26f); if (Widgets.ButtonText(resetButton, "Reset Items")) { Store_ItemEditor.ResetItemsToDefault(); GetTradeables(false); } Rect sortLabel = new Rect(inRect.width - 470f, 32f, 100f, 24f); Rect sortButton = new Rect(inRect.width - 370f, 28f, 100f, 28f); Color defaultColor = GUI.color; GUI.color = ColorLibrary.Grey; Widgets.Label(sortLabel, "Sort items by:"); GUI.color = defaultColor; if (Widgets.ButtonText(sortButton, "category")) { if (ascending) { ascending = false; cachedTradeables = cachedTradeables.OrderBy(s => s.FirstThingCategory.LabelCap).ToList(); } else { ascending = true; cachedTradeables = cachedTradeables.OrderByDescending(s => s.FirstThingCategory.LabelCap).ToList(); } GetTradeablesPrices(); } sortButton.x += 110f; if (Widgets.ButtonText(sortButton, "price")) { if (ascending) { ascending = false; cachedTradeables = cachedTradeables.OrderBy(s => s.BaseMarketValue).ToList(); } else { ascending = true; cachedTradeables = cachedTradeables.OrderByDescending(s => s.BaseMarketValue).ToList(); } GetTradeablesPrices(); } sortButton.x += 110f; if (Widgets.ButtonText(sortButton, "name")) { if (ascending) { ascending = false; cachedTradeables = cachedTradeables.OrderBy(s => s.LabelCap).ToList(); } else { ascending = true; cachedTradeables = cachedTradeables.OrderByDescending(s => s.LabelCap).ToList(); } GetTradeablesPrices(); } Rect mainRect = new Rect(0f, 58f, inRect.width, inRect.height - 58f - 38f - 20f); this.FillMainRect(mainRect); GUI.EndGroup(); }
public override void DoWindowContents(Rect inRect) { Vector2 vector = new Vector2(inRect.width - 16, 36); Vector2 vector2 = new Vector2(100, vector.y - 6); inRect.height -= 45; List <FileInfo> list = ColonistFiles.AllFiles.ToList <FileInfo>(); float num = vector.y + 3; float height = (float)list.Count * num; Rect viewRect = new Rect(0, 0, inRect.width - 16, height); Rect outRect = new Rect(inRect.AtZero()); outRect.height -= this.bottomAreaHeight; Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect); float num2 = 0; int num3 = 0; foreach (FileInfo current in list) { Rect rect = new Rect(0, num2, vector.x, vector.y); if (num3 % 2 == 0) { GUI.DrawTexture(rect, Textures.TextureAlternateRow); } Rect innerRect = new Rect(rect.x + 3, rect.y + 3, rect.width - 6, rect.height - 6); GUI.BeginGroup(innerRect); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(current.Name); GUI.color = ManualSaveTextColor; Rect rect2 = new Rect(15, 0, innerRect.width, innerRect.height); Text.Anchor = TextAnchor.MiddleLeft; Text.Font = GameFont.Small; Widgets.Label(rect2, fileNameWithoutExtension); GUI.color = Color.white; Rect rect3 = new Rect(250, 0, innerRect.width, innerRect.height); Text.Font = GameFont.Tiny; GUI.color = new Color(1, 1, 1, 0.5f); Widgets.Label(rect3, current.LastWriteTime.ToString("g")); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; float num4 = vector.x - 6 - vector2.x - vector2.y; Rect butRect = new Rect(num4, 0, vector2.x, vector2.y); if (Widgets.ButtonText(butRect, this.interactButLabel, true, false, true)) { this.DoMapEntryInteraction(Path.GetFileNameWithoutExtension(current.Name)); } Rect rect4 = new Rect(num4 + vector2.x + 5, 0, vector2.y, vector2.y); if (Widgets.ButtonImage(rect4, Textures.TextureDeleteX)) { FileInfo localFile = current; Find.UIRoot.windows.Add(new Dialog_Confirm("EdB.PC.Dialog.PawnPreset.ConfirmDelete".Translate(new object[] { localFile.Name }), delegate { localFile.Delete(); }, true, null, true)); } TooltipHandler.TipRegion(rect4, "EdB.PC.Dialog.PawnPreset.DeleteTooltip".Translate()); GUI.EndGroup(); num2 += vector.y + 3; num3++; } Widgets.EndScrollView(); this.DoSpecialSaveLoadGUI(inRect.AtZero()); }
// draws the header with the name of the mod private void DrawModEntryHeader(ModEntry entry, float width, ref float curY) { if (entry.ModName.NullOrEmpty()) { return; } var entryTitleRect = new Rect(0f, curY, width, ModEntryLabelHeight); var mouseOverTitle = Mouse.IsOver(entryTitleRect); if (mouseOverTitle) { Widgets.DrawHighlight(entryTitleRect); } var labelRect = entryTitleRect.ContractedBy(ModEntryLabelPadding); Text.Font = GameFont.Medium; Widgets.Label(labelRect, entry.ModName); Text.Font = GameFont.Small; var entryButtonsTopRight = new Vector2(width, curY); var activateButtonWidth = DrawActivateEntryButton(entryButtonsTopRight); DrawFloatMenuButton(new Vector2(entryButtonsTopRight.x - activateButtonWidth, entryButtonsTopRight.y)); curY += ModEntryLabelHeight; var color = GUI.color; GUI.color = ModEntryLineColor; Widgets.DrawLineHorizontal(0f, curY, width); GUI.color = color; curY += ModEntryLabelPadding; float DrawActivateEntryButton(Vector2 topRight) { if (entry.SettingsPack == null || !entry.SettingsPack.AlwaysExpandEntry) { var isExpanded = expandedModEntries.Contains(entry); CachedLabel buttonLabel; var isVanillaEntry = entry.SettingsPack == null; float toggleButtonWidth; if (isVanillaEntry) { buttonLabel = labelShowVanillaSettings; toggleButtonWidth = labelShowVanillaSettings.Size.x + ModEntryExpandButtonPadding; } else { buttonLabel = isExpanded ? labelCollapseModEntry : labelExpandModEntry; toggleButtonWidth = expandableToggleButtonWidth; } var buttonRect = new Rect(topRight.x - (toggleButtonWidth + ModEntryLabelPadding), topRight.y + (ModEntryLabelHeight - ModEntryShowSettingsButtonHeight) / 2f, toggleButtonWidth, ModEntryShowSettingsButtonHeight); if (Widgets.ButtonText(buttonRect, buttonLabel)) { if (isVanillaEntry) { Find.WindowStack.Add(new Dialog_VanillaModSettings(entry.VanillaMod)); } else { if (isExpanded) { expandedModEntries.Remove(entry); } else { expandedModEntries.Add(entry); } } } return(topRight.x - buttonRect.x); } return(0f); } void DrawFloatMenuButton(Vector2 topRight) { if (!mouseOverTitle) { return; } var buttonTopRight = new Vector2(topRight.x - ModEntryLabelPadding, topRight.y + (ModEntryLabelHeight - ModSettingsWidgets.HoverMenuHeight) / 2f); var hasExtraMenuEntries = entry.SettingsPack?.ContextMenuEntries != null; if (ModSettingsWidgets.DrawHoverMenuButton( buttonTopRight, entry.HasContextMenuEntries, hasExtraMenuEntries)) { OpenModEntryContextMenu(); } void OpenModEntryContextMenu() { var resetOptionLabel = entry.SettingsPack.CanBeReset ? "HugsLib_settings_resetMod".Translate(entry.ModName) : null; ModSettingsWidgets.OpenExtensibleContextMenu(resetOptionLabel, OnResetOptionSelected, OnAnyOptionSelected, entry.SettingsPack.ContextMenuEntries); } void OnResetOptionSelected() { ShowResetPrompt("HugsLib_settings_resetMod_prompt".Translate(entry.ModName), entry.SettingsPack.Handles); } void OnAnyOptionSelected() { foreach (var handle in entry.SettingsPack.Handles) { ResetHandleControlInfo(handle); } } } }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Small; Rect outRect = new Rect(inRect); outRect.yMin += 20f; outRect.yMax -= 40f; outRect.width -= 16f; Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, (float)this.assignable.AssigningCandidates.Count <Pawn>() * 35f + 100f); Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect, true); try { float num = 0f; bool flag = false; foreach (Pawn current in this.assignable.AssignedPawns) { flag = true; Rect rect = new Rect(0f, num, viewRect.width * 0.6f, 32f); Widgets.Label(rect, current.LabelCap); rect.x = rect.xMax; rect.width = viewRect.width * 0.4f; if (Widgets.ButtonText(rect, "BuildingUnassign".Translate(), true, false, true)) { this.assignable.TryUnassignPawn(current); SoundDefOf.Click.PlayOneShotOnCamera(null); return; } num += 35f; } if (flag) { num += 15f; } foreach (Pawn current2 in this.assignable.AssigningCandidates) { if (!this.assignable.AssignedPawns.Contains(current2)) { Rect rect2 = new Rect(0f, num, viewRect.width * 0.6f, 32f); Widgets.Label(rect2, current2.LabelCap); rect2.x = rect2.xMax; rect2.width = viewRect.width * 0.4f; string label = (!this.assignable.AssignedAnything(current2)) ? "BuildingAssign".Translate() : "BuildingReassign".Translate(); if (Widgets.ButtonText(rect2, label, true, false, true)) { this.assignable.TryAssignPawn(current2); if (this.assignable.MaxAssignedPawnsCount == 1) { this.Close(true); } else { SoundDefOf.Click.PlayOneShotOnCamera(null); } break; } num += 35f; } } } finally { Widgets.EndScrollView(); } }
public override void DoEditInterface(Listing_ScenEdit listing) { Rect rect = listing.GetScenPartRect(this, RowHeight * 8 + 31f); Rect[] a = rect.SplitRows(5, 4); Rect[] rows = a[0].SplitRows(RowHeight, RowHeight, RowHeight, 31f, RowHeight); Rect[] r_kind = rows[0].SplitCols(1, 2); Rect[] r_thing = rows[1].SplitCols(1, 2); Rect[] r_stuff = rows[2].SplitCols(1, 2); Rect[] r_amount = rows[3].SplitCols(1, 2); Rect r_equip = rows[4]; // Text.Anchor = TextAnchor.MiddleRight; Widgets.Label(r_kind[0], R.String.MSP_ThingKind.CapitalizeFirst()); // Text.Anchor = TextAnchor.UpperLeft; if (Widgets.ButtonText(r_kind[1], thingKind.Translate())) { FloatMenuUtility.MakeMenu(Extensions.GetEnumValues <ThingKind>(), Extensions.Translate, (k) => () => { thingKind = k; thing = GetThings().RandomElement(); if (thing.MadeFromStuff) { stuff = GetStuffsForThing().RandomElement(); } }); } // Text.Anchor = TextAnchor.MiddleRight; Widgets.Label(r_thing[0], R.String.MSP_Thing.CapitalizeFirst()); // Text.Anchor = TextAnchor.UpperLeft; if (Widgets.ButtonText(r_thing[1], thing.LabelCap)) { FloatMenuUtility.MakeMenu(GetThings(), (t) => t.LabelCap, (t) => () => { thing = t; if (t.MadeFromStuff) { stuff = GenStuff.DefaultStuffFor(thing); } else { stuff = null; } }); } // Text.Anchor = TextAnchor.MiddleRight; Widgets.Label(r_stuff[0], R.String.MSP_Stuff.CapitalizeFirst()); // Text.Anchor = TextAnchor.UpperLeft; if (thing.MadeFromStuff && Widgets.ButtonText(r_stuff[1], stuff.LabelCap)) { FloatMenuUtility.MakeMenu(GetStuffsForThing(), (s) => s.LabelCap, (s) => () => { stuff = s; }); } if (amount.max > thing.stackLimit) { amount.max = thing.stackLimit; } if (amount.min > amount.max) { amount.min = amount.max; } if (amount.min != 1 && amount.max != 1) { equip = false; } // Text.Anchor = TextAnchor.MiddleRight; Widgets.Label(r_amount[0], R.String.MSP_Amount.CapitalizeFirst()); // Text.Anchor = TextAnchor.UpperLeft; if (thing.stackLimit == 1) { // Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(r_amount[1], thing.stackLimit.ToStringCached()); // Text.Anchor = TextAnchor.UpperLeft; } else { Widgets.IntRange(r_amount[1], listing.CurHeight.GetHashCode(), ref amount, 1, thing.stackLimit); } if (thingKind == ThingKind.Aparrel || thingKind == ThingKind.Weapon) { bool oldValue = equip; Widgets.CheckboxLabeled(r_equip, R.String.MSP_Equip.CapitalizeFirst(), ref equip); if (!oldValue && equip) { amount.min = amount.max = 1; } } DoContextEditInterface(a[1]); }
public void DoContent(Rect rect) { // layout: settings | animals // draw background Widgets.DrawMenuSection(rect); // rects var optionsColumnRect = new Rect( rect.xMin, rect.yMin, rect.width * 3 / 5f, rect.height - Margin - ButtonSize.y); var animalsColumnRect = new Rect( optionsColumnRect.xMax, rect.yMin, rect.width * 2 / 5f, rect.height - Margin - ButtonSize.y); var buttonRect = new Rect( rect.xMax - ButtonSize.x, rect.yMax - ButtonSize.y, ButtonSize.x - Margin, ButtonSize.y - Margin); Vector2 position; float width; // options Widgets_Section.BeginSectionColumn(optionsColumnRect, "Hunting.Options", out position, out width); Widgets_Section.Section(ref position, width, DrawThresholdSettings, "FM.Threshold".Translate()); Widgets_Section.Section(ref position, width, DrawUnforbidCorpses); Widgets_Section.Section(ref position, width, DrawHuntingGrounds, "FM.Hunting.AreaRestriction".Translate()); Widgets_Section.EndSectionColumn("Hunting.Options", position); // animals Widgets_Section.BeginSectionColumn(animalsColumnRect, "Hunting.Animals", out position, out width); var refreshRect = new Rect( position.x + width - SmallIconSize - 2 * Margin, position.y + Margin, SmallIconSize, SmallIconSize); if (Widgets.ButtonImage(refreshRect, Resources.Refresh, Color.grey)) { _selected.RefreshAllowedAnimals(); } Widgets_Section.Section(ref position, width, DrawAnimalShortcuts, "FMH.Animals".Translate()); Widgets_Section.Section(ref position, width, DrawAnimalList); Widgets_Section.EndSectionColumn("Hunting.Animals", position); // do the button if (!_selected.Managed) { if (Widgets.ButtonText(buttonRect, "FM.Manage".Translate())) { // activate job, add it to the stack _selected.Managed = true; Manager.For(manager).JobStack.Add(_selected); // refresh source list Refresh(); } } else { if (Widgets.ButtonText(buttonRect, "FM.Delete".Translate())) { // inactivate job, remove from the stack. Manager.For(manager).JobStack.Delete(_selected); // remove content from UI _selected = null; // refresh source list Refresh(); } } }
public override void DoWindowContents(Rect inRect) { if (Comp == null || Comp.parent.DestroyedOrNull() || !Comp.parent.Spawned || Comp.Type == WirelessType.None) { Core.Warn("Pylon was destroyed or invalid, closing config window."); Close(); return; } Text.Font = GameFont.Medium; const float h = 28; const float p = 6; float x = inRect.x; float y = inRect.y; bool isSending = Comp.Type == WirelessType.Transmitter; string channelName = Comp.Channel?.Name ?? "None"; bool canChangeMode = Comp.Props.canSendPower; string txt = isSending ? "RF.Pylon.Sending".Translate() : "RF.Pylon.Requesting".Translate(); if (Widgets.ButtonText(new Rect(x, y, 150, h), txt, active: canChangeMode)) { Comp.SwitchType(isSending ? WirelessType.Receiver : WirelessType.Transmitter); } x += 150 + p; bool canChange = Comp.Props.fixedPowerLevel == null; int amount = Comp.TargetWatts; GUI.enabled = canChange; Widgets.IntEntry(new Rect(x, y, 290, h), ref amount, ref wattsBuffer, 10); GUI.enabled = true; Comp.TargetWatts = Mathf.Clamp(amount, 0, Comp.Props.maxPower); wattsBuffer = Comp.TargetWatts.ToString(); x += 290 + p; txt = "RF.Pylon.On".Translate(); var size = Text.CalcSize(txt); Widgets.Label(new Rect(x, y, size.x, h), txt); x += size.x + p; if (Widgets.ButtonText(new Rect(x, y, 200, h), channelName)) { var options = new List <FloatMenuOption>(); if (Comp.Manager != null) { foreach (var item in Comp.Manager.GetAvailableChannels(Comp)) { var op = new FloatMenuOption(item.Name, () => { Comp.SwitchToChannel(item); }); options.Add(op); } } if (Comp.Channel != null) { options.Add(new FloatMenuOption("RF.Pylon.EmptyChannel".Translate(), () => { Comp.SwitchToChannel(null); })); } options.Add(new FloatMenuOption("RF.Pylon.CreateNewChannel".Translate(), () => { if (tempWindow != null) { return; } Find.WindowStack.Add(tempWindow = new NewChannelWindow() { Manager = Comp.Manager, CreateNewChannel = name => { Core.Log($"User created new channel '{name}'"); int id = Comp.Manager.CreateNewChannel(name); var newChannel = Comp.Manager.TryGetChannel(id); if (newChannel == null) { Core.Error("Create new channel, but TryGetChannel returned null!? Why?"); } Comp.SwitchToChannel(newChannel); }, OnClose = () => { tempWindow = null; } }); })); Find.WindowStack.Add(new FloatMenu(options)); } var channel = Comp.Channel; if (channel == null || channel.Destroyed) { return; } Text.Font = GameFont.Small; x = 0; y += h + 10; int input = (int)channel.TotalInputWatts; int requested = (int)channel.TotalRequestedWatts; int balanceInt = input - requested; string balance = balanceInt > 0 ? $"<color=green>+{balanceInt}W</color>" : balanceInt < 0 ? $"<color=red>{balanceInt}W</color>" : "0W"; Widgets.Label(new Rect(x, y, inRect.width, inRect.height - y), $"{"RF.Pylon.ChannelInfoHeader".Translate(channel.Name)}\n" + $"{"RF.Pylon.ChannelInfoInput".Translate(channel.ActiveTransmitterCount, input)}\n" + $"{"RF.Pylon.ChannelInfoOutput".Translate(channel.ActiveReceiversCount, requested)}\n" + $"{"RF.Pylon.ChannelInfoBalance".Translate(balance)}" + (channel.UnsatisfiedReceivers > 0 ? "\n" + (string)"RF.Pylon.ChannelInfoUnsatisfied".Translate(channel.UnsatisfiedReceivers) : "")); }
public static bool CustomDrawer_Enumlist(SettingHandle handle, Rect controlRect, string[] enumNames, float[] forcedWidths, ExpansionMode expansionMode, Color background) { drawBackground(controlRect, background); if (enumNames == null) { return(false); } if (enumNames.Length != forcedWidths.Length) { return(false); } if (expansionMode == ExpansionMode.Horizontal) { throw new NotImplementedException("Horizontal scrolling not yet implemented."); } float buttonWidth = controlRect.width; int forcedButtons = 0; for (int i = 0; i < forcedWidths.Length; i++) { if (forcedWidths[i] != 0f) { forcedButtons++; buttonWidth -= forcedWidths[i]; } } if (forcedButtons != enumNames.Length) { buttonWidth /= (float)(enumNames.Length - forcedButtons); } float position = controlRect.position.x; bool changed = false; for (int i = 0; i < enumNames.Length; i++) { float width = (forcedWidths[i] == 0f) ? buttonWidth : forcedWidths[i]; Rect buttonRect = new Rect(controlRect); buttonRect.position = new Vector2(position, buttonRect.position.y); buttonRect.width = width; //buttonRect = buttonRect.ContractedBy(2f); bool interacted = false; bool selected = handle.StringValue.Equals(enumNames[i]); string label = (handle.EnumStringPrefix + enumNames[i]).Translate(); if (expansionMode == ExpansionMode.Vertical) { float height = Text.CalcHeight(label, width); if (handle.CustomDrawerHeight < height) { handle.CustomDrawerHeight = height; } } Color activeColor = GUI.color; if (selected) { GUI.color = SelectedOptionColor; } interacted = Widgets.ButtonText(buttonRect, label); if (selected) { GUI.color = activeColor; } if (interacted) { handle.StringValue = enumNames[i]; changed = true; } position += width; } return(changed); }
public override void DoSettingsWindowContents(Rect inRect) { base.DoSettingsWindowContents(inRect); if (menuSettings) { Rect topRect = inRect.TopPart(0.05f); if (Widgets.ButtonText(topRect.RightPart(0.95f).LeftPart(0.18f), "settings_settings_desc".Translate())) { menuSettings = false; } topRect.y += 32; Text.Font = GameFont.Medium; if (searchTerm.NullOrEmpty()) { GUI.color = Color.gray; Widgets.Label(topRect.RightPart(0.95f).LeftPart(0.95f), "settings_searchbyname_desc".Translate()); GUI.color = Color.white; } searchTerm = Widgets.TextField(topRect.RightPart(0.95f).LeftPart(0.95f), searchTerm); Rect labelRect = inRect.TopPart(0.1f).BottomHalf(); Rect bottomRect = inRect.BottomPart(0.9f); topRect.y += 32; Widgets.Label(topRect.RightPart(0.95f).LeftPart(0.425f), "settings_labelleft_desc".Translate()); Widgets.Label(topRect.RightPart(0.45f).LeftPart(0.95f), "settings_labelright_desc".Translate()); bottomRect.y += 32; bottomRect.height -= 32; List <ThingDef> disabledDefList = new List <ThingDef>(); if (settings.disabledDefList != null && settings.disabledDefList.Any()) { disabledDefList = StringToDefList(settings.disabledDefList); } #region leftSide List <ThingDef> leftList = new List <ThingDef>(); Rect leftRect = bottomRect.LeftHalf().RightPart(0.9f).LeftPart(0.9f); GUI.BeginGroup(leftRect, new GUIStyle(GUI.skin.box)); List <ThingDef> found = new List <ThingDef>(); found = DefDatabase <ThingDef> .AllDefs.Where(x => FilteredTarget(x) && !settings.disabledDefList.Contains(x.defName)).OrderBy(x => x.defName).ToList(); float num = 3f; Widgets.BeginScrollView(leftRect.AtZero(), ref leftScrollPosition, new Rect(0f, 0f, leftRect.width / 10 * 9, found.Count() * 32f)); if (!found.NullOrEmpty()) { foreach (ThingDef def in found) { if ((!searchTerm.NullOrEmpty() && def.defName.IndexOf(searchTerm, StringComparison.OrdinalIgnoreCase) >= 0) || searchTerm.NullOrEmpty()) { leftList.Add(def); Rect rowRect = new Rect(5, num, leftRect.width - 6, 30); Widgets.DrawHighlightIfMouseover(rowRect); if (def == leftSelectedDef) { Widgets.DrawHighlightSelected(rowRect); } Widgets.Label(rowRect, def.defName); if (Widgets.ButtonInvisible(rowRect)) { leftSelectedDef = def; rightSelectedDef = null; } num += 32f; } } } Widgets.EndScrollView(); GUI.EndGroup(); #endregion #region rightSide List <ThingDef> rightList = new List <ThingDef>(); Rect rightRect = bottomRect.RightHalf().RightPart(0.9f).LeftPart(0.9f); GUI.BeginGroup(rightRect, GUI.skin.box); num = 6f; Widgets.BeginScrollView(rightRect.AtZero(), ref rightScrollPosition, new Rect(0f, 0f, rightRect.width / 5 * 4, disabledDefList.Count * 32f)); if (!disabledDefList.NullOrEmpty()) { foreach (ThingDef def in disabledDefList) { if ((!searchTerm.NullOrEmpty() && def.defName.IndexOf(searchTerm, StringComparison.OrdinalIgnoreCase) >= 0) || searchTerm.NullOrEmpty()) { rightList.Add(def); Rect rowRect = new Rect(5, num, leftRect.width - 6, 30); Widgets.DrawHighlightIfMouseover(rowRect); if (def == rightSelectedDef) { Widgets.DrawHighlightSelected(rowRect); } Widgets.Label(rowRect, def.defName); if (Widgets.ButtonInvisible(rowRect)) { rightSelectedDef = def; leftSelectedDef = null; } num += 32f; } } } Widgets.EndScrollView(); GUI.EndGroup(); #endregion #region buttons if (Widgets.ButtonImage(bottomRect.BottomPart(0.67f).TopPart(0.17f).RightPart(0.525f).LeftPart(0.1f), TexUI.ArrowTexRight) && leftSelectedDef != null) { settings.disabledDefList.Add(leftSelectedDef.defName); settings.disabledDefList = settings.disabledDefList.OrderBy(x => x).ToList(); bool leftSelectChanged = false; int leftListCount = leftList.Count; if (leftListCount > 0) { for (int i = 0; i < leftListCount; i++) { if (leftList[i] == DefDatabase <ThingDef> .GetNamed(leftSelectedDef.defName)) { if ((leftListCount - 1) > i) { leftSelectedDef = leftList[i + 1]; leftSelectChanged = true; break; } } } } leftList.Clear(); if (!leftSelectChanged) { leftSelectedDef = null; } } if (Widgets.ButtonImage(bottomRect.BottomPart(0.47f).TopPart(0.23f).RightPart(0.525f).LeftPart(0.1f), TexUI.ArrowTexLeft) && rightSelectedDef != null) { settings.disabledDefList.Remove(rightSelectedDef.defName); bool rightSelectChanged = false; int rightListCount = rightList.Count; if (rightListCount > 0) { for (int i = 0; i < rightListCount; i++) { if (rightList[i] == DefDatabase <ThingDef> .GetNamed(rightSelectedDef.defName)) { if ((rightListCount - 1) > i) { rightSelectedDef = rightList[i + 1]; rightSelectChanged = true; break; } } } } rightList.Clear(); if (!rightSelectChanged) { rightSelectedDef = null; } } #endregion settings.Write(); } else { Rect topRect = inRect.TopPart(0.05f); if (ButtonText(topRect.RightPart(0.95f).LeftPart(0.18f), "settings_targeting_desc".Translate())) { menuSettings = true; } topRect.y += 72; CheckboxLabeled(topRect.RightPart(0.95f).LeftPart(0.425f), "settings_notification_desc".Translate(), ref settings.showNotifications, "settings_notification_tip".Translate()); CheckboxLabeled(topRect.RightPart(0.475f).LeftPart(0.9f), "settings_allowharvestjob_desc".Translate(), ref settings.allowHarvestJob, "settings_allowharvestjob_tip".Translate()); topRect.y += 32; CheckboxLabeled(topRect.RightPart(0.95f).LeftPart(0.425f), "settings_allowhivemapgen_desc".Translate(), ref settings.allowHiveMapGen, "settings_allowhivemapgen_tip".Translate()); CheckboxLabeled(topRect.RightPart(0.475f).LeftPart(0.9f), "settings_allowsapperjob_desc".Translate(), ref settings.allowSapperJob, "settings_allowsapperjob_tip".Translate()); topRect.y += 32; CheckboxLabeled(topRect.RightPart(0.95f).LeftPart(0.425f), "settings_allowhivespawncolony_desc".Translate(), ref settings.allowHiveSpawnColony, "settings_allowhivespawncolony_tip".Translate()); CheckboxLabeled(topRect.RightPart(0.475f).LeftPart(0.9f), "settings_allowhuntingjob_desc".Translate(), ref settings.allowHuntingJob, "settings_allowhuntingjob_tip".Translate()); topRect.y += 32; CheckboxLabeled(topRect.RightPart(0.95f).LeftPart(0.425f), "settings_spawnadditionalinsects_desc".Translate(), ref settings.spawnAdditionalInsects, "settings_spawnadditionalinsects_tip".Translate()); topRect.y += 32; Label(topRect.RightPart(0.95f).LeftPart(0.95f), "settings_maxparampointsinf_desc".Translate() + settings.maxParamPointsInf, "settings_maxparampointsinf_tip".Translate()); settings.maxParamPointsInf = (int)HorizontalSlider(topRect.RightPart(0.575f).LeftPart(0.9f), settings.maxParamPointsInf, 200f, 1000f, 50f); topRect.y += 32; Label(topRect.RightPart(0.95f).LeftPart(0.95f), "settings_maxparampointsdeep_desc".Translate() + settings.maxParamPointsDeep, "settings_maxparampointsdeep_tip".Translate()); settings.maxParamPointsDeep = (int)HorizontalSlider(topRect.RightPart(0.575f).LeftPart(0.9f), settings.maxParamPointsDeep, 200f, 1000f, 50f); topRect.y += 32; Label(topRect.RightPart(0.95f).LeftPart(0.95f), "settings_maxmapgenhives_desc".Translate() + settings.maxMapGenHives, "settings_maxmapgenhives_tip".Translate()); settings.maxMapGenHives = (int)HorizontalSlider(topRect.RightPart(0.575f).LeftPart(0.9f), settings.maxMapGenHives, 1f, 5f, 1f); topRect.y += 32; Label(topRect.RightPart(0.95f).LeftPart(0.95f), "settings_maxinsectsmap_desc".Translate() + settings.maxInsectsMap, "settings_maxinsectsmap_tip".Translate()); settings.maxInsectsMap = (int)HorizontalSlider(topRect.RightPart(0.575f).LeftPart(0.9f), settings.maxInsectsMap, 40f, 400f, 10f); topRect.y += 32; Label(topRect.RightPart(0.95f).LeftPart(0.95f), "settings_maxinsectshive_desc".Translate() + settings.maxInsectsHive, "settings_maxinsectshive_tip".Translate()); settings.maxInsectsHive = (int)HorizontalSlider(topRect.RightPart(0.575f).LeftPart(0.9f), settings.maxInsectsHive, 10f, 100f, 10f); topRect.y += 32; Label(topRect.RightPart(0.95f).LeftPart(0.95f), "settings_maxqueens_desc".Translate() + settings.maxQueens, "settings_maxqueens_tip".Translate()); settings.maxQueens = (int)HorizontalSlider(topRect.RightPart(0.575f).LeftPart(0.9f), settings.maxQueens, 1f, 20f, 1f); topRect.y += 32; Label(topRect.RightPart(0.95f).LeftPart(0.95f), "settings_hiveaggression_desc".Translate() + (int)Math.Round(settings.hiveAggression * 100f) + "%", "settings_hiveaggression_tip".Translate()); settings.hiveAggression = HorizontalSlider(topRect.RightPart(0.575f).LeftPart(0.9f), settings.hiveAggression, 0f, 1f, 0.1f); topRect.y += 32; Label(topRect.RightPart(0.95f).LeftPart(0.95f), "settings_hivedistance_desc".Translate() + settings.hiveDistFromColony, "settings_hivedistance_tip".Translate()); settings.hiveDistFromColony = (int)HorizontalSlider(topRect.RightPart(0.575f).LeftPart(0.9f), settings.hiveDistFromColony, 1f, 10f, 1f); topRect.y += 32; Label(topRect.RightPart(0.95f).LeftPart(0.95f), "settings_foodstorage_desc".Translate() + settings.foodStorage, "settings_foodstorage_tip".Translate()); settings.foodStorage = (int)HorizontalSlider(topRect.RightPart(0.575f).LeftPart(0.9f), settings.foodStorage, 0f, 500f, 50f); topRect.y += 32; Label(topRect.RightPart(0.95f).LeftPart(0.95f), "settings_egglayingrate_desc".Translate() + settings.eggLayingRate + "settings_days_desc".Translate(), "settings_egglayingrate_tip".Translate()); settings.eggLayingRate = HorizontalSlider(topRect.RightPart(0.575f).LeftPart(0.9f), settings.eggLayingRate, 0f, 10f, 0.25f); topRect.y += 32; Label(topRect.RightPart(0.95f).LeftPart(0.95f), "settings_egghatchingrate_desc".Translate() + settings.eggHatchingRate + "settings_days_desc".Translate(), "settings_egghatchingrate_tip".Translate()); settings.eggHatchingRate = HorizontalSlider(topRect.RightPart(0.575f).LeftPart(0.9f), settings.eggHatchingRate, 0f, 10f, 0.25f); } }
public static bool ButtonText(Rect rect, string label) { bool result = Widgets.ButtonText(rect, label, true, false, true); return(result); }
public override void DoWindowContents(Rect inRect) { var rect = new Rect(inRect); var anchor = Text.Anchor; var font = Text.Font; Text.Anchor = TextAnchor.MiddleLeft; Text.Font = GameFont.Medium; Widgets.Label(new Rect(rect.x, rect.y, rect.width, 40f), hireable.GetCallLabel()); Text.Font = GameFont.Small; rect.yMin += 40f; Widgets.Label(new Rect(rect.x, rect.y, rect.width, 20f), "VEF.AvailableSilver".Translate(availableSilver.ToStringMoney())); rect.yMin += 30f; foreach (var def in hireable) { DoHireableFaction(ref rect, def); } var breakDownRect = rect.TakeTopPart(100f); breakDownRect.xMin += 115f; Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; var infoRect = breakDownRect.TopPartPixels(20f); Widgets.Label(infoRect.LeftHalf(), "VEF.Breakdown".Translate()); Text.Anchor = TextAnchor.MiddleCenter; Text.Font = GameFont.Tiny; Widgets.Label(infoRect.RightHalf(), "VEF.LongTerm".Translate().Colorize(ColoredText.SubtleGrayColor)); Text.Font = GameFont.Small; infoRect.y += 20f; Widgets.DrawLightHighlight(infoRect); Widgets.Label(infoRect.LeftHalf(), "VEF.DayAmount".Translate()); UIUtility.DrawCountAdjuster(ref daysAmount, infoRect.RightHalf(), ref daysAmountBuffer, 0, 60, false, null, Mathf.Max(Mathf.FloorToInt(Mathf.Pow(availableSilver / (riskMultiplier + 1f) / CostPawns(), 1f / 0.8f)), 1)); infoRect.y += 20f; Widgets.DrawHighlight(infoRect); Widgets.Label(infoRect.LeftHalf(), "VEF.Cost".Translate()); Widgets.Label(infoRect.RightHalf(), CostBase.ToStringMoney()); infoRect.y += 20f; Widgets.DrawLightHighlight(infoRect); Widgets.Label(infoRect.LeftHalf(), "VEF.RiskMult".Translate()); Widgets.Label(infoRect.RightHalf(), riskMultiplier.ToStringPercent()); infoRect.y += 20f; Widgets.DrawHighlight(infoRect); Widgets.Label(infoRect.LeftHalf(), "VEF.TotalPrice".Translate()); Widgets.Label(infoRect.RightHalf(), CostFinal.ToStringMoney()); if (Widgets.ButtonText(rect.TakeLeftPart(120f).BottomPartPixels(40f), "Cancel".Translate())) { OnCancelKeyPressed(); } if (Widgets.ButtonText(rect.TakeRightPart(120f).BottomPartPixels(40f), "Confirm".Translate())) { if (CostFinal > availableSilver) { Messages.Message("NotEnoughSilver".Translate(), MessageTypeDefOf.RejectInput); } else { OnAcceptKeyPressed(); } } Text.Font = GameFont.Tiny; Widgets.Label(rect.ContractedBy(30f, 0f), "VEF.HiringDesc".Translate(hireable.Key).Colorize(ColoredText.SubtleGrayColor)); Text.Anchor = anchor; Text.Font = font; }
protected void DoSubRow(Rect rect, string key, HybridExtensionExposable extension, List <string> removeelements) { bool isPawnKind = false; int value = (int)extension.hybridInfo.TryGetValue(key); string valuestr = value.ToString(); string label = null; label = DefDatabase <ThingDef> .GetNamedSilentFail(key)?.label; if (label == null) { label = DefDatabase <PawnKindDef> .GetNamedSilentFail(key)?.label ?? "Undefined"; isPawnKind = true; } Rect buttonRect = new Rect(rect.xMax - 90f, rect.y, 80f, rect.height); if (Widgets.ButtonText(buttonRect, "Delete")) { removeelements.Add(key); } buttonRect.x -= 80f; if (!isPawnKind) { if (Widgets.ButtonText(buttonRect, "PawnKind")) { List <FloatMenuOption> list = new List <FloatMenuOption>(); if (!VariousDefOf.AllKinds.NullOrEmpty()) { foreach (PawnKindDef def in VariousDefOf.AllKinds) { if (def.race.defName == key) { if (extension.hybridInfo.ContainsKey(def.defName)) { continue; } else { list.Add(new FloatMenuOption(def.label, delegate { extension.hybridInfo.Add(def.defName, 1.0f); })); } } } } if (!list.NullOrEmpty()) { Find.WindowStack.Add(new FloatMenu(list)); } else { SoundDefOf.ClickReject.PlayOneShotOnCamera(); } } buttonRect.x -= 80f; } else { Widgets.Label(buttonRect, " PawnKind"); buttonRect.x -= 80f; } label += ": " + key; Widgets.Label(rect, " - " + label); Widgets.TextFieldNumeric(buttonRect, ref value, ref valuestr, 0, 9999999); extension.hybridInfo.SetOrAdd(key, value); buttonRect.x -= 80f; Widgets.Label(buttonRect, String.Format("{0,0:P2}", value / totalWeight)); Widgets.DrawHighlightIfMouseover(rect); TooltipHandler.TipRegion(rect, Translations.CustomHybrid_Tooltip(info.GetDef?.label ?? "Undefined", extension.GetDef?.label ?? "Undefined", label, String.Format("{0,0:0.########%}", value / totalWeight))); }
public override void DoWindowContents(Rect rect) { Text.Font = GameFont.Small; bool flag = false; if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return) { flag = true; Event.current.Use(); } Rect rect2; if (!useSecondName) { Widgets.Label(new Rect(0f, 0f, rect.width, rect.height), nameMessageKey.Translate(suggestingPawn.LabelShort, suggestingPawn).CapitalizeFirst()); if (nameGenerator != null && Widgets.ButtonText(new Rect(rect.width / 2f + 90f, 80f, rect.width / 2f - 90f, 35f), "Randomize".Translate())) { curName = nameGenerator(); } curName = Widgets.TextField(new Rect(0f, 80f, rect.width / 2f + 70f, 35f), curName); rect2 = new Rect(rect.width / 2f + 90f, rect.height - 35f, rect.width / 2f - 90f, 35f); } else { float num = 0f; string text = nameMessageKey.Translate(suggestingPawn.LabelShort, suggestingPawn).CapitalizeFirst(); Widgets.Label(new Rect(0f, num, rect.width, rect.height), text); num += Text.CalcHeight(text, rect.width) + 10f; if (nameGenerator != null && Widgets.ButtonText(new Rect(rect.width / 2f + 90f, num, rect.width / 2f - 90f, 35f), "Randomize".Translate())) { curName = nameGenerator(); } curName = Widgets.TextField(new Rect(0f, num, rect.width / 2f + 70f, 35f), curName); num += 60f; text = secondNameMessageKey.Translate(suggestingPawn.LabelShort, suggestingPawn); Widgets.Label(new Rect(0f, num, rect.width, rect.height), text); num += Text.CalcHeight(text, rect.width) + 10f; if (secondNameGenerator != null && Widgets.ButtonText(new Rect(rect.width / 2f + 90f, num, rect.width / 2f - 90f, 35f), "Randomize".Translate())) { curSecondName = secondNameGenerator(); } curSecondName = Widgets.TextField(new Rect(0f, num, rect.width / 2f + 70f, 35f), curSecondName); num += 45f; float num2 = rect.width / 2f - 90f; rect2 = new Rect(rect.width / 2f - num2 / 2f, rect.height - 35f, num2, 35f); } if (!(Widgets.ButtonText(rect2, "OK".Translate()) | flag)) { return; } if (IsValidName(curName) && (!useSecondName || IsValidSecondName(curSecondName))) { if (useSecondName) { Named(curName); NamedSecond(curSecondName); Messages.Message(gainedNameMessageKey.Translate(curName, curSecondName), MessageTypeDefOf.TaskCompletion, historical: false); } else { Named(curName); Messages.Message(gainedNameMessageKey.Translate(curName), MessageTypeDefOf.TaskCompletion, historical: false); } Find.WindowStack.TryRemove(this); } else { Messages.Message(invalidNameMessageKey.Translate(), MessageTypeDefOf.RejectInput, historical: false); } Event.current.Use(); }
public override void DoWindowContents(Rect inRect) { // set up rects // pickers & sliders Rect pickerRect = new Rect(inRect.xMin, inRect.yMin, pickerSize, pickerSize); Rect hueRect = new Rect(pickerRect.xMax + _margin, inRect.yMin, sliderWidth, pickerSize); Rect alphaRect = new Rect(hueRect.xMax + _margin, inRect.yMin, sliderWidth, pickerSize); // previews Rect previewRect = new Rect(alphaRect.xMax + _margin, inRect.yMin, previewSize, previewSize); Rect previewOldRect = new Rect(previewRect.xMax, inRect.yMin, previewSize, previewSize); // buttons and textfields Rect okRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - _fieldHeight, previewSize * 2, _fieldHeight); Rect applyRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - 2 * _fieldHeight - _margin, previewSize - _margin / 2, _fieldHeight); Rect cancelRect = new Rect(applyRect.xMax + _margin, applyRect.yMin, previewSize - _margin / 2, _fieldHeight); Rect hexRect = new Rect(alphaRect.xMax + _margin, inRect.yMax - 3 * _fieldHeight - 2 * _margin, previewSize * 2, _fieldHeight); // move ok/cancel buttons for the simple view with buttons if (!_preview && !_autoApply) { cancelRect = new Rect(inRect.xMin, pickerRect.yMax + _margin, (pickerSize - _margin) / 2, _fieldHeight); okRect = cancelRect; okRect.x += (pickerSize + _margin) / 2; } // draw transparency backgrounds GUI.DrawTexture(pickerRect, PickerAlphaBG); GUI.DrawTexture(alphaRect, SliderAlphaBG); if (_preview) { GUI.DrawTexture(previewRect, PreviewAlphaBG); GUI.DrawTexture(previewOldRect, PreviewAlphaBG); } // draw picker foregrounds GUI.DrawTexture(pickerRect, ColorPickerBG); GUI.DrawTexture(hueRect, HuePickerBG); GUI.DrawTexture(alphaRect, AlphaPickerBG); if (_preview) { GUI.DrawTexture(previewRect, TempPreviewBG); GUI.DrawTexture(previewOldRect, PreviewBG); } // draw slider handles Rect hueHandleRect = new Rect(hueRect.xMin - 3f, hueRect.yMin + _huePosition - handleSize / 2, sliderWidth + 6f, handleSize); Rect pickerHandleRect = new Rect(pickerRect.xMin + _pickerPosition.x - handleSize / 2, pickerRect.yMin + _pickerPosition.y - handleSize / 2, handleSize, handleSize); Rect alphaHandleRect = new Rect(alphaRect.xMin - 3f, alphaRect.yMin + _alphaPosition - handleSize / 2, sliderWidth + 6f, handleSize); GUI.DrawTexture(hueHandleRect, TempPreviewBG); GUI.DrawTexture(pickerHandleRect, TempPreviewBG); GUI.DrawTexture(alphaHandleRect, TempPreviewBG); // border on slider handles GUI.color = Color.gray; Widgets.DrawBox(hueHandleRect); Widgets.DrawBox(pickerHandleRect); Widgets.DrawBox(alphaHandleRect); GUI.color = Color.white; #region UI interactions // reset active control on mouseup if (Input.GetMouseButtonUp(0)) { _activeControl = controls.none; } // colorpicker interaction if (Mouse.IsOver(pickerRect)) { if (Input.GetMouseButtonDown(0)) { _activeControl = controls.colorPicker; } if (_activeControl == controls.colorPicker) { Vector2 MousePosition = Event.current.mousePosition; Vector2 PositionInRect = MousePosition - new Vector2(pickerRect.xMin, pickerRect.yMin); PickerAction(PositionInRect); } } // hue picker interaction if (Mouse.IsOver(hueRect)) { if (Input.GetMouseButtonDown(0)) { _activeControl = controls.huePicker; } if (Event.current.type == EventType.ScrollWheel) { H -= Event.current.delta.y * UnitsPerPixel; _huePosition = Mathf.Clamp(_huePosition + Event.current.delta.y, 0f, pickerSize); Event.current.Use(); } if (_activeControl == controls.huePicker) { float MousePosition = Event.current.mousePosition.y; float PositionInRect = MousePosition - hueRect.yMin; HueAction(PositionInRect); } } // alpha picker interaction if (Mouse.IsOver(alphaRect)) { if (Input.GetMouseButtonDown(0)) { _activeControl = controls.alphaPicker; } if (Event.current.type == EventType.ScrollWheel) { A -= Event.current.delta.y * UnitsPerPixel; _alphaPosition = Mathf.Clamp(_alphaPosition + Event.current.delta.y, 0f, pickerSize); Event.current.Use(); } if (_activeControl == controls.alphaPicker) { float MousePosition = Event.current.mousePosition.y; float PositionInRect = MousePosition - alphaRect.yMin; AlphaAction(PositionInRect); } } if (!_autoApply) { // buttons and text field // for some reason scrolling sometimes changes text size Text.Font = GameFont.Small; if (Widgets.ButtonText(okRect, "OK")) { Apply(); this.Close(); } if (Widgets.ButtonText(applyRect, "Apply")) { Apply(); SetColor(); } if (Widgets.ButtonText(cancelRect, "Cancel")) { this.Close(); } } if (_preview) { if (_hexIn != _hexOut) { if (ColorHelper.TryHexToRGB(_hexIn, ref tempColor)) { Notify_RGBUpdated(); } else { GUI.color = Color.red; } } _hexIn = Widgets.TextField(hexRect, _hexIn); } GUI.color = Color.white; #endregion UI interactions }
private void DrawLeftRect(Rect leftOutRect) { Rect position = leftOutRect; GUI.BeginGroup(position); if (this.selectedProject != null) { Rect outRect = new Rect(0f, 0f, position.width, 500f); Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, this.leftScrollViewHeight); Widgets.BeginScrollView(outRect, ref this.leftScrollPosition, viewRect, true); float num = 0f; Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Rect rect = new Rect(0f, num, viewRect.width, 50f); Widgets.LabelCacheHeight(ref rect, this.selectedProject.LabelCap, true, false); GenUI.ResetLabelAlign(); Text.Font = GameFont.Small; num += rect.height; Rect rect2 = new Rect(0f, num, viewRect.width, 0f); Widgets.LabelCacheHeight(ref rect2, this.selectedProject.description, true, false); num += rect2.height + 10f; string text = string.Concat(new string[] { "ProjectTechLevel".Translate().CapitalizeFirst(), ": ", this.selectedProject.techLevel.ToStringHuman().CapitalizeFirst(), "\n", "YourTechLevel".Translate().CapitalizeFirst(), ": ", Faction.OfPlayer.def.techLevel.ToStringHuman().CapitalizeFirst() }); float num2 = this.selectedProject.CostFactor(Faction.OfPlayer.def.techLevel); if (num2 != 1f) { string text2 = text; text = string.Concat(new string[] { text2, "\n\n", "ResearchCostMultiplier".Translate().CapitalizeFirst(), ": ", num2.ToStringPercent(), "\n", "ResearchCostComparison".Translate(new object[] { this.selectedProject.baseCost.ToString("F0"), this.selectedProject.CostApparent.ToString("F0") }) }); } Rect rect3 = new Rect(0f, num, viewRect.width, 0f); Widgets.LabelCacheHeight(ref rect3, text, true, false); num = rect3.yMax + 10f; Rect rect4 = new Rect(0f, num, viewRect.width, 500f); float num3 = this.DrawResearchPrereqs(this.selectedProject, rect4); if (num3 > 0f) { num += num3 + 15f; } Rect rect5 = new Rect(0f, num, viewRect.width, 500f); num += this.DrawResearchBenchRequirements(this.selectedProject, rect5); num += 3f; this.leftScrollViewHeight = num; Widgets.EndScrollView(); bool flag = Prefs.DevMode && this.selectedProject != Find.ResearchManager.currentProj && !this.selectedProject.IsFinished; Rect rect6 = new Rect(0f, 0f, 90f, 50f); if (flag) { rect6.x = (outRect.width - (rect6.width * 2f + 20f)) / 2f; } else { rect6.x = (outRect.width - rect6.width) / 2f; } rect6.y = outRect.y + outRect.height + 20f; if (this.selectedProject.IsFinished) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "Finished".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (this.selectedProject == Find.ResearchManager.currentProj) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "InProgress".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (!this.selectedProject.CanStartNow) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "Locked".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (Widgets.ButtonText(rect6, "Research".Translate(), true, false, true)) { SoundDefOf.ResearchStart.PlayOneShotOnCamera(null); Find.ResearchManager.currentProj = this.selectedProject; TutorSystem.Notify_Event("StartResearchProject"); } if (flag) { Rect rect7 = rect6; rect7.x += rect7.width + 20f; if (Widgets.ButtonText(rect7, "Debug Insta-finish", true, false, true)) { Find.ResearchManager.currentProj = this.selectedProject; Find.ResearchManager.InstantFinish(this.selectedProject, false); } } Rect rect8 = new Rect(15f, rect6.y + rect6.height + 20f, position.width - 30f, 35f); Widgets.FillableBar(rect8, this.selectedProject.ProgressPercent, MainTabWindow_Research.ResearchBarFillTex, MainTabWindow_Research.ResearchBarBGTex, true); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect8, this.selectedProject.ProgressApparent.ToString("F0") + " / " + this.selectedProject.CostApparent.ToString("F0")); Text.Anchor = TextAnchor.UpperLeft; } GUI.EndGroup(); }
public override void DoWindowContents(Rect inRect) { var windowButtonSize = CloseButSize; var contentRect = new Rect(0, 0, inRect.width, inRect.height - (windowButtonSize.y + 10f)).ContractedBy(10f); GUI.BeginGroup(contentRect); var titleRect = new Rect(0f, 0f, contentRect.width, TitleLabelHeight); Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleCenter); Widgets.Label(titleRect, "HugsLib_settings_windowTitle".Translate()); GenUI.ResetLabelAlign(); Text.Font = GameFont.Small; if (listedMods.Count > 0) { var scrollViewVisible = new Rect(0f, titleRect.height, contentRect.width, contentRect.height - titleRect.height); var scrollBarVisible = totalContentHeight > scrollViewVisible.height; var scrollViewTotal = new Rect(0f, 0f, scrollViewVisible.width - (scrollBarVisible ? ScrollBarWidthMargin : 0), totalContentHeight); Widgets.BeginScrollView(scrollViewVisible, ref scrollPosition, scrollViewTotal); var curY = 0f; for (int i = 0; i < listedMods.Count; i++) { var entry = listedMods[i]; if (!entry.Visible) { continue; } currentlyDrawnEntry = entry.ModName; DrawModEntryHeader(entry, scrollViewTotal.width, ref curY); if ((entry.SettingsPack != null && entry.SettingsPack.AlwaysExpandEntry) || expandedModEntries.Contains(entry)) { for (int j = 0; j < entry.Handles.Count; j++) { var handle = entry.Handles[j]; if (handle.VisibilityPredicate != null) { try { if (!handle.VisibilityPredicate()) { continue; } } catch (Exception e) { HugsLibController.Logger.ReportException(e, currentlyDrawnEntry, true, "SettingsHandle.VisibilityPredicate"); } } DrawHandleEntry(handle, scrollViewTotal, ref curY, scrollViewVisible.height); } } currentlyDrawnEntry = null; } Widgets.EndScrollView(); totalContentHeight = curY; } else { Widgets.Label(new Rect(0, titleRect.height, contentRect.width, titleRect.height), "HugsLib_settings_noSettings".Translate()); } GUI.EndGroup(); Text.Font = GameFont.Small; var resetButtonRect = new Rect(0, inRect.height - windowButtonSize.y, windowButtonSize.x, windowButtonSize.y); if (Widgets.ButtonText(resetButtonRect, "HugsLib_settings_resetAll".Translate())) { ShowResetPrompt("HugsLib_settings_resetAll_prompt".Translate(), HugsLibController.SettingsManager.ModSettingsPacks.SelectMany(p => p.Handles)); } var closeButtonRect = new Rect(inRect.width - windowButtonSize.x, inRect.height - windowButtonSize.y, windowButtonSize.x, windowButtonSize.y); if (closingScheduled) { closingScheduled = false; Close(); } if (Widgets.ButtonText(closeButtonRect, "CloseButton".Translate())) { GUI.FocusControl(null); // unfocus, so that a focused text field may commit its value closingScheduled = true; } }
protected override void FillTab() { var pawnSave = SelPawnForGear.GetSaveablePawn(); // Outfit + Status button var rectStatus = new Rect(20f, 15f, 380f, ButtonHeight); var outfitRect = new Rect(rectStatus.x, rectStatus.y, (392f / 3) - Margin, ButtonHeight); var outfitEditRect = new Rect(outfitRect.xMax + Margin, outfitRect.y, outfitRect.width, ButtonHeight); var outfitJobRect = new Rect(outfitEditRect.xMax + Margin, outfitRect.y, outfitRect.width, ButtonHeight); // select outfit if (Widgets.ButtonText(outfitRect, SelPawnForGear.outfits.CurrentOutfit.label)) { var options = new List <FloatMenuOption>(); foreach (var current in Current.Game.outfitDatabase.AllOutfits) { var localOut = current; options.Add( new FloatMenuOption( localOut.label, delegate { SelPawnForGear.outfits.CurrentOutfit = localOut; })); } var window = new FloatMenu(options, "SelectOutfit".Translate()); Find.WindowStack.Add(window); } // edit outfit if (Widgets.ButtonText( outfitEditRect, "OutfitterEditOutfit".Translate() + " ...")) //"OutfitterEditOutfit".Translate() + " " + SelPawnForGear.outfits.CurrentOutfit.label + " ...")) { Find.WindowStack.Add(new Dialog_ManageOutfits(SelPawnForGear.outfits.CurrentOutfit)); } // job outfit if (Widgets.ButtonText( outfitJobRect, pawnSave.MainJob == MainJob.Anything ? "MainJob".Translate() : "PreferedGear".Translate() + " " + pawnSave.MainJob.ToString() .Replace("00", " - ") .Replace("_", " "))) { var options = new List <FloatMenuOption>(); foreach (MainJob mainJob in Enum.GetValues(typeof(MainJob))) { options.Add( new FloatMenuOption( mainJob.ToString().Replace("00", " - ").Replace("_", " "), delegate { pawnSave.MainJob = mainJob; pawnSave.ForceStatUpdate = true; SelPawnForGear.mindState.Notify_OutfitChanged(); if (SelPawnForGear.jobs.curJob != null && SelPawnForGear.jobs.IsCurrentJobPlayerInterruptible()) { SelPawnForGear.jobs.EndCurrentJob(JobCondition .InterruptForced); } })); } var window = new FloatMenu(options, "MainJob".Translate()); Find.WindowStack.Add(window); } // Status checkboxes var rectCheckboxes = new Rect(rectStatus.x, rectStatus.yMax + Margin, rectStatus.width, 72f); var check1 = new Rect(rectCheckboxes.x, rectCheckboxes.y, rectCheckboxes.width, 24f); var check2 = new Rect(rectCheckboxes.x, check1.yMax, rectCheckboxes.width, 24f); var check3 = new Rect(rectCheckboxes.x, check2.yMax, rectCheckboxes.width, 24f); var pawnSaveAddWorkStats = pawnSave.AddWorkStats; var pawnSaveAddIndividualStats = pawnSave.AddIndividualStats; var pawnSaveAddPersonalStats = pawnSave.AddPersonalStats; Widgets.CheckboxLabeled(check1, "AddWorkStats".Translate(), ref pawnSaveAddWorkStats); Widgets.CheckboxLabeled(check2, "AddIndividualStats".Translate(), ref pawnSaveAddIndividualStats); Widgets.CheckboxLabeled(check3, "AddPersonalStats".Translate(), ref pawnSaveAddPersonalStats); if (GUI.changed) { pawnSave.AddWorkStats = pawnSaveAddWorkStats; pawnSave.AddIndividualStats = pawnSaveAddIndividualStats; pawnSave.AddPersonalStats = pawnSaveAddPersonalStats; pawnSave.ForceStatUpdate = true; } // main canvas var canvas = new Rect(20f, rectCheckboxes.yMax, 392f, size.y - rectCheckboxes.yMax - 20f); GUI.BeginGroup(canvas); var cur = Vector2.zero; DrawTemperatureStats(pawnSave, ref cur, canvas); cur.y += Margin; DrawApparelStats(cur, canvas); GUI.EndGroup(); DrawApparelList(); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; }
private void DrawItemRow(Rect rect, ThingDef thing, int index) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Color white = GUI.color; if (tradeablesPrices[index] < 1) { GUI.color = ColorLibrary.Grey; } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float num = rect.width; Rect rect1 = new Rect(num - 100f, 0f, 100f, rect.height); rect1 = rect1.Rounded(); int newPrice = tradeablesPrices[index]; string label = newPrice.ToString(); rect1.xMax -= 5f; rect1.xMin += 5f; if (Text.Anchor == TextAnchor.MiddleLeft) { rect1.xMax += 300f; } if (Text.Anchor == TextAnchor.MiddleRight) { rect1.xMin -= 300f; } Rect rect2 = new Rect(num - 560f, 0f, 240f, rect.height); if (newPrice > 0) { if (Widgets.ButtonText(rect1, "Disable")) { newPrice = -10; tradeablesPrices[index] = newPrice; } tradeablesPrices[index] = newPrice; } if (newPrice > 0) { Widgets.IntEntry(rect2, ref newPrice, ref label, 50); tradeablesPrices[index] = newPrice; } else { if (Widgets.ButtonText(rect2, "Reset")) { newPrice = Convert.ToInt32(thing.BaseMarketValue * 10 / 6); if (newPrice < 1) { newPrice = 1; } tradeablesPrices[index] = newPrice; } } Rect categoryLabel = new Rect(num - 300, 0f, 200f, rect.height); Widgets.Label(categoryLabel, thing.FirstThingCategory.LabelCap); Rect rect3 = new Rect(0f, 0f, 27f, 27f); Widgets.ThingIcon(rect3, thing); Widgets.InfoCardButton(40f, 0f, thing); Text.Anchor = TextAnchor.MiddleLeft; Rect rect4 = new Rect(80f, 0f, rect.width - 80f, rect.height); Text.WordWrap = false; GUI.color = Color.white; Widgets.Label(rect4, thing.LabelCap); Text.WordWrap = true; GenUI.ResetLabelAlign(); GUI.EndGroup(); GUI.color = white; }
private void DoBottomButtons(Rect rect) { double num = rect.width / 2.0; Vector2 bottomButtonSize = this.BottomButtonSize; double x2 = num - bottomButtonSize.x / 2.0; double y = rect.height - 55.0; Vector2 bottomButtonSize2 = this.BottomButtonSize; float x3 = bottomButtonSize2.x; Vector2 bottomButtonSize3 = this.BottomButtonSize; Rect rect2 = new Rect((float)x2, (float)y, x3, bottomButtonSize3.y); if (Widgets.ButtonText(rect2, "AcceptButton".Translate(), true, false, true)) { if (this.reform) { if (this.TryReformCaravan()) { SoundDefOf.TickHigh.PlayOneShotOnCamera(null); this.Close(false); } } else { List <string> list = new List <string>(); Pair <float, float> daysWorthOfFood = this.DaysWorthOfFood; if (daysWorthOfFood.First < 5.0) { list.Add((!(daysWorthOfFood.First < 0.10000000149011612)) ? "DaysWorthOfFoodWarningDialog".Translate(daysWorthOfFood.First.ToString("0.#")) : "DaysWorthOfFoodWarningDialog_NoFood".Translate()); } else if (this.MostFoodWillRotSoon) { list.Add("CaravanFoodWillRotSoonWarningDialog".Translate()); } if (!TransferableUtility.GetPawnsFromTransferables(this.transferables).Any((Pawn pawn) => CaravanUtility.IsOwner(pawn, Faction.OfPlayer) && !pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)) { list.Add("CaravanIncapableOfSocial".Translate()); } if (list.Count > 0) { if (this.CheckForErrors(TransferableUtility.GetPawnsFromTransferables(this.transferables))) { string text = string.Concat((from str in list select str + "\n\n").ToArray()) + "CaravanAreYouSure".Translate(); Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(text, delegate { if (this.TryFormAndSendCaravan()) { this.Close(false); } }, false, null)); } } else if (this.TryFormAndSendCaravan()) { SoundDefOf.TickHigh.PlayOneShotOnCamera(null); this.Close(false); } } } double num2 = rect2.x - 10.0; Vector2 bottomButtonSize4 = this.BottomButtonSize; double x4 = num2 - bottomButtonSize4.x; float y2 = rect2.y; Vector2 bottomButtonSize5 = this.BottomButtonSize; float x5 = bottomButtonSize5.x; Vector2 bottomButtonSize6 = this.BottomButtonSize; Rect rect3 = new Rect((float)x4, y2, x5, bottomButtonSize6.y); if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true)) { SoundDefOf.TickLow.PlayOneShotOnCamera(null); this.CalculateAndRecacheTransferables(); } double x6 = rect2.xMax + 10.0; float y3 = rect2.y; Vector2 bottomButtonSize7 = this.BottomButtonSize; float x7 = bottomButtonSize7.x; Vector2 bottomButtonSize8 = this.BottomButtonSize; Rect rect4 = new Rect((float)x6, y3, x7, bottomButtonSize8.y); if (Widgets.ButtonText(rect4, (!this.cancellingWillAbandon) ? "CancelButton".Translate() : "AbandonButton".Translate(), true, false, true)) { this.Close(true); } if (this.showEstTimeToDestinationButton) { float width = rect.width; Vector2 bottomButtonSize9 = this.BottomButtonSize; float x8 = width - bottomButtonSize9.x; float y4 = rect2.y; Vector2 bottomButtonSize10 = this.BottomButtonSize; float x9 = bottomButtonSize10.x; Vector2 bottomButtonSize11 = this.BottomButtonSize; Rect rect5 = new Rect(x8, y4, x9, bottomButtonSize11.y); if (Widgets.ButtonText(rect5, "EstimatedTimeToDestinationButton".Translate(), true, false, true)) { List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables); if (!pawnsFromTransferables.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed)) { Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageTypeDefOf.RejectInput); } else { Find.WorldRoutePlanner.Start(this); } } } if (Prefs.DevMode) { float width2 = 200f; Vector2 bottomButtonSize12 = this.BottomButtonSize; float num3 = (float)(bottomButtonSize12.y / 2.0); Rect rect6 = new Rect(0f, (float)(rect.height - 55.0), width2, num3); if (Widgets.ButtonText(rect6, "Dev: Send instantly", true, false, true) && this.DebugTryFormCaravanInstantly()) { SoundDefOf.TickHigh.PlayOneShotOnCamera(null); this.Close(false); } Rect rect7 = new Rect(0f, (float)(rect.height - 55.0 + num3), width2, num3); if (Widgets.ButtonText(rect7, "Dev: Select everything", true, false, true)) { SoundDefOf.TickHigh.PlayOneShotOnCamera(null); this.SetToSendEverything(); } } }
public override void DoWindowContents(Rect inRect) { float num = 0f; Rect rect = new Rect(0f, 0f, 150f, 35f); num += 150f; if (Widgets.ButtonText(rect, "SelectDrugPolicy".Translate())) { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (DrugPolicy allPolicy in Current.Game.drugPolicyDatabase.AllPolicies) { DrugPolicy localAssignedDrugs = allPolicy; list.Add(new FloatMenuOption(localAssignedDrugs.label, delegate { SelectedPolicy = localAssignedDrugs; })); } Find.WindowStack.Add(new FloatMenu(list)); } num += 10f; Rect rect2 = new Rect(num, 0f, 150f, 35f); num += 150f; if (Widgets.ButtonText(rect2, "NewDrugPolicy".Translate())) { SelectedPolicy = Current.Game.drugPolicyDatabase.MakeNewDrugPolicy(); } num += 10f; Rect rect3 = new Rect(num, 0f, 150f, 35f); num += 150f; if (Widgets.ButtonText(rect3, "DeleteDrugPolicy".Translate())) { List <FloatMenuOption> list2 = new List <FloatMenuOption>(); foreach (DrugPolicy allPolicy2 in Current.Game.drugPolicyDatabase.AllPolicies) { DrugPolicy localAssignedDrugs2 = allPolicy2; list2.Add(new FloatMenuOption(localAssignedDrugs2.label, delegate { AcceptanceReport acceptanceReport = Current.Game.drugPolicyDatabase.TryDelete(localAssignedDrugs2); if (!acceptanceReport.Accepted) { Messages.Message(acceptanceReport.Reason, MessageTypeDefOf.RejectInput, historical: false); } else if (localAssignedDrugs2 == SelectedPolicy) { SelectedPolicy = null; } })); } Find.WindowStack.Add(new FloatMenu(list2)); } float width = inRect.width; float num2 = inRect.height - 40f; Vector2 closeButSize = CloseButSize; Rect rect4 = new Rect(0f, 40f, width, num2 - closeButSize.y).ContractedBy(10f); if (SelectedPolicy == null) { GUI.color = Color.grey; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect4, "NoDrugPolicySelected".Translate()); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; } else { GUI.BeginGroup(rect4); Rect rect5 = new Rect(0f, 0f, 200f, 30f); DoNameInputRect(rect5, ref SelectedPolicy.label); Rect rect6 = new Rect(0f, 40f, rect4.width, rect4.height - 45f - 10f); DoPolicyConfigArea(rect6); GUI.EndGroup(); } }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(new Rect(0, 0, inRect.width, 40), $"{"MpDesynced".Translate()}\n{text}"); Text.Anchor = TextAnchor.UpperLeft; float buttonWidth = 120 * 5 + 10 * 4; var buttonRect = new Rect((inRect.width - buttonWidth) / 2, 40, buttonWidth, 35); GUI.BeginGroup(buttonRect); float x = 0; if (Widgets.ButtonText(new Rect(x, 0, 120, 35), "MpTryResync".Translate())) { Multiplayer.session.resyncing = true; TickPatch.SkipTo( toTickUntil: true, onFinish: () => { Multiplayer.session.resyncing = false; Multiplayer.Client.Send(Packets.Client_WorldReady); }, cancelButtonKey: "Quit", onCancel: GenScene.GoToMainMenu ); Multiplayer.session.desynced = false; ClientJoiningState.ReloadGame(OnMainThread.cachedMapData.Keys.ToList(), false); } x += 120 + 10; //REHOST if (Widgets.ButtonText(new Rect(x, 0, 120, 35), "MpTryRehost".Translate())) { Rehost(); } x += 120 + 10; //REHOST if (Widgets.ButtonText(new Rect(x, 0, 120, 35), "Save".Translate())) { Find.WindowStack.Add(new Dialog_SaveReplay()); } x += 120 + 10; if (Widgets.ButtonText(new Rect(x, 0, 120, 35), "MpChatButton".Translate())) { Find.WindowStack.Add(new ChatWindow() { closeOnClickedOutside = true, absorbInputAroundWindow = true }); } x += 120 + 10; if (Widgets.ButtonText(new Rect(x, 0, 120, 35), "Quit".Translate())) { MainMenuPatch.AskQuitToMainMenu(); } GUI.EndGroup(); }
private static void DrawButtonColumn(Rect rect, float availWidth) { if (Widgets.ButtonText(rect.TopPartPixels(Text.LineHeight), " + ")) { var widthMinusGrabBars = availWidth - (18 * panels.Count); var avWidth = widthMinusGrabBars / (panels.Count + 1.0f); var increment = avWidth / panels.Count; increment = Mathf.Round(increment); for (int i = 0; i < panels.Count; i++) { var panel = panels[i]; panel.width -= increment; panel.xStart += increment * (panels.Count - i); } if (panels.Count >= 1) { panels[0].xStart += 18; panels[0].width -= 18; panels.Insert(0, new BottomRowPanel(RowName.Graph, 0, panels[0].xStart - 18)); } else { panels.Add(new BottomRowPanel(RowName.Graph, 0, availWidth)); } } rect.AdjustVerticallyBy(Text.LineHeight); if (Widgets.ButtonText(rect.TopPartPixels(Text.LineHeight), " - ")) { if (panels.Count == 1) { return; } var delta = panels[0].width + 18; var increment = delta / (panels.Count - 1.0f); for (int i = 0; i < panels.Count; i++) { var panel = panels[i]; panel.width += increment; panel.xStart -= (increment * (panels.Count - i)); } if (panels.Count == 2) { panels[1].xStart = 0; panels[1].width = availWidth; } else if (panels.Count > 2) { panels[1].xStart = 0; panels[1].width = panels[2].xStart - 18; } panels.RemoveAt(0); } }
protected void DoMainContents(Rect inRect) { Rect labelRect = new Rect(inRect.xMin, inRect.yMin, 300, 24); Rect buttonRect = new Rect(inRect.xMax - 120, 0, 100, 30); Widgets.Label(labelRect, Translations.CustomHybrid_Title(info.GetDef?.label ?? "Undefined")); Widgets.DrawLineHorizontal(inRect.x, labelRect.yMax, inRect.width); if (Widgets.ButtonText(buttonRect, "Add")) { if (!raceList.NullOrEmpty()) { Find.WindowStack.Add(new FloatMenu(raceList)); } } if (!removeList.EnumerableNullOrEmpty()) { buttonRect.x -= 100; if (Widgets.ButtonText(buttonRect, "Undo")) { var element = removeList.Last(); info.hybridExtension.Add(element); removeList.Remove(element); } foreach (HybridExtensionExposable element in removeList) { info.hybridExtension.Remove(element); } } float additionalHeight = 0f; if (!info.hybridExtension.NullOrEmpty()) { foreach (HybridExtensionExposable e in info.hybridExtension) { additionalHeight += (e.hybridInfo?.Count() ?? 1) * rowH; } } Rect outRect = new Rect(inRect.x, inRect.y + 30f, inRect.width, inRect.height - 30f); Rect mainRect = new Rect(inRect.x, inRect.y + 30f, inRect.width - 30f, rowH * (info.hybridExtension?.Count() ?? 1) + additionalHeight); Listing_Standard listmain = new Listing_Standard(); listmain.BeginScrollView(outRect, ref scroll, ref mainRect); listmain.Begin(mainRect); if (!info.hybridExtension.NullOrEmpty()) { foreach (HybridExtensionExposable extension in info.hybridExtension) { DoRow(listmain.GetRect(rowH + rowH * (extension.hybridInfo?.Count() ?? 1)), extension); } } listmain.EndScrollView(ref mainRect); listmain.End(); }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Small; Rect outRect = new Rect(inRect); outRect.yMin += 20f; outRect.yMax -= 40f; outRect.width -= 16f; Rect viewRect = new Rect(0.0f, 0.0f, outRect.width - 16f, (float)(ReligionExtensions.GetReligionManager().AllReligions.Count() * 35.0 + 100.0)); Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect, true); try { float y = 0.0f; bool flag = false; if (assignable.AssignedReligion != null) { flag = true; Rect rect = new Rect(0.0f, y, viewRect.width * 0.6f, 32f); Widgets.Label(rect, assignable.AssignedReligion.Label); rect.x = rect.xMax; rect.width = viewRect.width * 0.4f; if (Widgets.ButtonText(rect, "BuildingUnassign".Translate(), true, false, true)) { if (assignable.AssignedBuildings.Count() != 0) { Messages.Message("ReligiousBuilgingAssigner_BuildingWasUnassigned".Translate(), MessageTypeDefOf.NeutralEvent); } this.assignable.TryUnassignReligion(); SoundDefOf.Click.PlayOneShotOnCamera((Map)null); return; } y += 35f; } if (flag) { y += 15f; } foreach (Religion assigningCandidate in ReligionExtensions.GetReligionManager().AllReligions) { if (assigningCandidate != assignable.AssignedReligion && assigningCandidate.GetSettings <ReligionSettings_AllowedBuildings>(SettingsTagDefOf.AllowedBuildingsTag) != null && assigningCandidate.GetSettings <ReligionSettings_AllowedBuildings>(SettingsTagDefOf.AllowedBuildingsTag).AllowedBuildings.Any(x => x == assignable.def)) { Rect rect = new Rect(0.0f, y, viewRect.width * 0.6f, 32f); Widgets.Label(rect, assigningCandidate.Label); rect.x = rect.xMax; rect.width = viewRect.width * 0.4f; if (Widgets.ButtonText(rect, "BuildingAssign".Translate(), true, false, true)) { this.assignable.TryAssignReligion(assigningCandidate); SoundDefOf.Click.PlayOneShotOnCamera((Map)null); break; } y += 35f; } } } finally { Widgets.EndScrollView(); } }
protected void DoRow(Rect rect, HybridExtensionExposable extension) { Rect mainRect = new Rect(rect.x, rect.y, rect.width, rowH); Rect subRect = new Rect(rect.x, rect.y + rowH, rect.width, rect.height - rowH); Rect buttonRect = new Rect(rect.xMax - 90f, rect.y, 80f, rowH); Widgets.Label(mainRect, extension.GetDef?.label ?? "Undefined"); if (Widgets.ButtonText(buttonRect, "Delete")) { removeList.Add(extension); } buttonRect.x -= 80f; if (Widgets.ButtonText(buttonRect, "Add")) { List <FloatMenuOption> list = new List <FloatMenuOption>(); if (!VariousDefOf.AllRaces.NullOrEmpty()) { foreach (ThingDef def in VariousDefOf.AllRaces) { if (def.race != null) { if (extension.hybridInfo.ContainsKey(def.defName)) { continue; } else { list.Add(new FloatMenuOption(def.label, delegate { extension.hybridInfo.Add(def.defName, 1.0f); })); } } } } if (!list.NullOrEmpty()) { list.SortBy(x => x.Label); Find.WindowStack.Add(new FloatMenu(list)); } } buttonRect.x -= 80f; Listing_Standard sublist = new Listing_Standard(); sublist.Begin(subRect); List <string> removeelements = new List <string>(); if (!extension.hybridInfo.EnumerableNullOrEmpty()) { totalWeight = 0; foreach (KeyValuePair <string, float> element in extension.hybridInfo) { totalWeight += element.Value; } List <string> keys = new List <string>(extension.hybridInfo.Keys); foreach (string key in keys) { DoSubRow(sublist.GetRect(rowH), key, extension, removeelements); } } if (!removeelements.NullOrEmpty()) { foreach (string key in removeelements) { extension.hybridInfo.Remove(key); } } sublist.End(); Widgets.DrawHighlightIfMouseover(rect); }
private void DoContent(Rect rect) { // background Widgets.DrawMenuSection(rect); // cop out if nothing is selected. if (_selectedCurrent == null) { Label(rect, "FM.Livestock.SelectPawnKind".Translate(), TextAnchor.MiddleCenter); return; } // rects var optionsColumnRect = new Rect( rect.xMin, rect.yMin, rect.width * 3 / 5f, rect.height - Margin - ButtonSize.y); var animalsColumnRect = new Rect( optionsColumnRect.xMax, rect.yMin, rect.width * 2 / 5f, rect.height - Margin - ButtonSize.y); var buttonRect = new Rect( rect.xMax - ButtonSize.x, rect.yMax - ButtonSize.y, ButtonSize.x - Margin, ButtonSize.y - Margin); Vector2 position; float width; Widgets_Section.BeginSectionColumn(optionsColumnRect, "Livestock.Options", out position, out width); Widgets_Section.Section(ref position, width, DrawTargetCountsSection, "FM.Livestock.TargetCountsHeader".Translate()); Widgets_Section.Section(ref position, width, DrawTamingSection, "FM.Livestock.TamingHeader".Translate()); Widgets_Section.Section(ref position, width, DrawButcherSection, "FM.Livestock.ButcherHeader".Translate()); Widgets_Section.Section(ref position, width, DrawTrainingSection, "FM.Livestock.TrainingHeader".Translate()); Widgets_Section.Section(ref position, width, DrawAreaRestrictionsSection, "FM.Livestock.AreaRestrictionsHeader".Translate()); Widgets_Section.Section(ref position, width, DrawFollowSection, "FM.Livestock.FollowHeader".Translate()); Widgets_Section.EndSectionColumn("Livestock.Options", position); // Start animals list // get our pawnkind Widgets_Section.BeginSectionColumn(animalsColumnRect, "Livestock.Animals", out position, out width); Widgets_Section.Section(ref position, width, DrawTamedAnimalSection, "FM.Livestock.AnimalsHeader".Translate("FML.Tame".Translate(), _selectedCurrent.Trigger.pawnKind.GetLabelPlural()).CapitalizeFirst()); Widgets_Section.Section(ref position, width, DrawWildAnimalSection, "FM.Livestock.AnimalsHeader".Translate("FML.Wild".Translate(), _selectedCurrent.Trigger.pawnKind.GetLabelPlural()).CapitalizeFirst()); Widgets_Section.EndSectionColumn("Livestock.Animals", position); // add / remove to the stack if (_selectedCurrent.Managed) { if (Widgets.ButtonText(buttonRect, "FM.Delete".Translate())) { _selectedCurrent.Delete(); _selectedCurrent = null; _onCurrentTab = false; Refresh(); return; // just skip to the next tick to avoid null reference errors. } TooltipHandler.TipRegion(buttonRect, "FMP.DeleteBillTooltip".Translate()); } else { if (Widgets.ButtonText(buttonRect, "FM.Manage".Translate())) { _selectedCurrent.Managed = true; _onCurrentTab = true; Manager.For(manager).JobStack.Add(_selectedCurrent); Refresh(); } TooltipHandler.TipRegion(buttonRect, "FMP.ManageBillTooltip".Translate()); } }
public void DrawButtons(int x, int y, int length, int size, int set) { Text.Anchor = TextAnchor.MiddleCenter; Text.Font = GameFont.Tiny; if (set == 1) { for (int i = 0; i < buttons.Count(); i++) { if (Widgets.ButtonText(new Rect(x, y + ((size + 10) * i), length, size), buttons[i])) { //If click a button button if (buttons[i] == "UpgradeTown".Translate()) { //if click upgrade town button Find.WindowStack.Add(new SettlementUpgradeWindowFc(settlement)); //Log.Message(buttons[i]); } if (buttons[i] == "AreYouSureRemove".Translate()) { //if click to delete colony Find.WindowStack.TryRemove(this); FactionColonies.removePlayerSettlement(settlement); } if (buttons[i] == "DeleteSettlement".Translate()) { //if click town log button //Log.Message(buttons[i]); buttons[i] = "AreYouSureRemove".Translate(); } if (buttons[i] == "FCSpecialActions".Translate()) { List <FloatMenuOption> list = new List <FloatMenuOption>(); //Add to all list.Add(new FloatMenuOption("GoToLocation".Translate(), delegate { Find.WindowStack.TryRemove(this); settlement.goTo(); })); if (factionfc.hasPolicy(FCPolicyDefOf.authoritarian)) { list.Add(new FloatMenuOption("FCBuyLoyalty".Translate(), delegate { Find.WindowStack.Add(new FCWindow_Pay_Silver(settlement)); })); } if (factionfc.hasPolicy(FCPolicyDefOf.egalitarian)) { list.Add(new FloatMenuOption("FCGiveTaxBreak".Translate(), delegate { if (settlement.trait_Egalitarian_TaxBreak_Enabled == false) { Find.WindowStack.Add(new FCWindow_Confirm_TaxBreak(settlement)); } else { Messages.Message( "FCAlreadyGivingTaxBreak".Translate(Math.Round( (settlement.trait_Egalitarian_TaxBreak_Tick + GenDate.TicksPerDay * 10 - Find.TickManager.TicksGame) / (double)GenDate.TicksPerDay, 1)), MessageTypeDefOf.RejectInput); } })); } if (list.Count() == 0) { list.Add(new FloatMenuOption("No special actions to take", delegate { })); } Find.WindowStack.Add(new FloatMenu(list)); } if (buttons[i] == "PrisonersMenu".Translate()) { Find.WindowStack.Add(new FCPrisonerMenu(settlement)); //put prisoner window here. } if (buttons[i] == "Military".Translate()) { List <FloatMenuOption> list = new List <FloatMenuOption>(); list.Add(new FloatMenuOption( "ToggleAutoDefend".Translate(settlement.autoDefend.ToString()), delegate { settlement.autoDefend = !settlement.autoDefend; })); if (settlement.isUnderAttack) { FCEvent evt = MilitaryUtilFC.returnMilitaryEventByLocation(settlement.mapLocation); list.Add(new FloatMenuOption( "SettlementDefendingInformation".Translate( evt.militaryForceDefending.homeSettlement.name, evt.militaryForceDefending.militaryLevel), null, MenuOptionPriority.High)); list.Add(new FloatMenuOption("ChangeDefendingForce".Translate(), delegate { List <FloatMenuOption> settlementList = new List <FloatMenuOption>(); SettlementFC homeSettlement = settlement; settlementList.Add(new FloatMenuOption( "ResetToHomeSettlement".Translate(homeSettlement.settlementMilitaryLevel), delegate { MilitaryUtilFC.changeDefendingMilitaryForce(evt, homeSettlement); }, MenuOptionPriority.High)); foreach (SettlementFC settlement in Find.World.GetComponent <FactionFC>().settlements ) { if (settlement.isMilitaryValid() && settlement != homeSettlement) { //if military is valid to use. settlementList.Add(new FloatMenuOption( settlement.name + " " + "ShortMilitary".Translate() + " " + settlement.settlementMilitaryLevel + " - " + "FCAvailable".Translate() + ": " + (!settlement.isMilitaryBusySilent()).ToString(), delegate { if (settlement.isMilitaryBusy()) { //military is busy } else { MilitaryUtilFC.changeDefendingMilitaryForce(evt, settlement); } } )); } } if (settlementList.Count == 0) { settlementList.Add(new FloatMenuOption("NoValidMilitaries".Translate(), null)); } FloatMenu floatMenu2 = new FloatMenu(settlementList) { vanishIfMouseDistant = true }; Find.WindowStack.Add(floatMenu2); //set to raid settlement here })); FloatMenu floatMenu = new FloatMenu(list) { vanishIfMouseDistant = true }; Find.WindowStack.Add(floatMenu); } else { list.Add(new FloatMenuOption("SettlementNotBeingAttacked".Translate(), null)); FloatMenu menu = new FloatMenu(list); Find.WindowStack.Add(menu); } } } } } //set two buttons }