private void DrawVehicleSelect(Rect rect) { Text.Anchor = TextAnchor.MiddleLeft; Rect viewRect = new Rect(0f, rect.yMin, rect.width - ButtonPadding * 2, rect.yMax); Widgets.BeginScrollView(rect, ref scrollPosition, viewRect, true); float num = scrollPosition.y - 30f; float num2 = scrollPosition.y + rect.height; float num3 = 30f; for (int i = 0; i < availableVehicles.Count; i++) { VehiclePawn vehicle = availableVehicles[i]; Rect iconRect = new Rect(5f, num3 + 5f, 30f, 30f); Rect rowRect = new Rect(iconRect.x, iconRect.y, rect.width, 30f); if (i % 2 == 1) { Widgets.DrawLightHighlight(rowRect); } rowRect.x = iconRect.width + 10f; if (vehicle.VehicleDef.properties.generateThingIcon) { Rect texCoords = new Rect(0, 0, 1, 1); Vector2 texProportions = vehicle.VehicleDef.graphicData.drawSize; float x = texProportions.x; texProportions.x = texProportions.y; texProportions.y = x; Widgets.DrawTextureFitted(iconRect, VehicleTex.VehicleTexture(vehicle.VehicleDef, Rot8.East), GenUI.IconDrawScale(vehicle.VehicleDef), texProportions, texCoords, 0, vehicle.VehicleGraphic.MatAt(Rot8.East, vehicle.pattern)); } else { Widgets.ButtonImageFitted(iconRect, VehicleTex.CachedTextureIcons[vehicle.VehicleDef]); } Widgets.Label(rowRect, vehicle.LabelShortCap); bool flag = storedVehicles.Contains(vehicle); Vector2 checkposition = new Vector2(rect.width - iconRect.width * 1.5f, rowRect.y + 5f); Widgets.Checkbox(checkposition, ref flag); if (flag && !storedVehicles.Contains(vehicle)) { storedVehicles.Add(vehicle); } else if (!flag && storedVehicles.Contains(vehicle)) { storedVehicles.Remove(vehicle); } num3 += rowRect.height; } Widgets.EndScrollView(); Text.Anchor = TextAnchor.UpperLeft; }
public static bool Prefix() { if (!Main.Instance.ShouldAllowDragToReorder()) { return(true); } var selectedThing = Find.Selector.SingleSelectedThing; var billGiver = selectedThing as IBillGiver; if (billGiver == null) { return(true); } if (!(selectedThing is Building_WorkTable) && !Main.Instance.IsOfTypeRimFactoryBuilding(selectedThing)) { return(true); } ReorderableGroup = ReorderableWidget.NewGroup( (from, to) => ReorderBillInStack(billGiver.BillStack, from, to), ReorderableDirection.Vertical); var winSize = (Vector2)WinSizeGetter.GetValue(null); var pasteX = (float)PasteXGetter.GetValue(null); var pasteY = (float)PasteYGetter.GetValue(null); var buttonWidth = (float)PasteSizeGetter.GetValue(null); _vanillaPasteRect = new Rect(winSize.x - pasteX, pasteY, buttonWidth, buttonWidth); if (!(selectedThing is Building_WorkTable workTable)) { return(true); } var billCopyPasteHandler = Main.Instance.BillCopyPasteHandler; if (!billCopyPasteHandler.CanPasteInto(workTable)) { return(true); } if (Widgets.ButtonImageFitted(_vanillaPasteRect, Resources.PasteButton, Color.white)) { billCopyPasteHandler.DoPasteInto(workTable, false); } return(true); }
public static void SearchBar(Rect rect, float gap, ref string input) { var searchRect = new Rect(rect) { height = 28f }; var searchField = searchRect.LeftPartPixels(searchRect.width - 28f - 1f - gap); var clearBtn = searchRect.RightPartPixels(28f + 1f); InputField("Search", searchField, ref input); Text.Anchor = TextAnchor.MiddleLeft; if (Widgets.ButtonImageFitted(clearBtn, Widgets.CheckboxOffTex)) { input = ""; } }
public static void Postfix(ref Rect rect) { if (!(Find.Selector.SingleSelectedThing is Building_WorkTable workTable)) { return; } var gap = 4f; var buttonWidth = (float)PasteSizeGetter.GetValue(null); var buttonRect = new Rect(_vanillaPasteRect); buttonRect.xMin -= buttonWidth + gap; buttonRect.xMax -= buttonWidth + gap; var billCopyPasteHandler = Main.Instance.BillCopyPasteHandler; if (workTable.BillStack != null && workTable.BillStack.Count > 0) { if (Widgets.ButtonImageFitted(buttonRect, Resources.CopyButton, Color.white)) { billCopyPasteHandler.DoCopy(workTable); SoundDefOf.Tick_Low.PlayOneShotOnCamera(); } TooltipHandler.TipRegion(buttonRect, "IW.CopyAllTip".Translate()); buttonRect.xMin -= buttonWidth + gap; buttonRect.xMax -= buttonWidth + gap; } if (!billCopyPasteHandler.CanPasteInto(workTable)) { return; } var rectPaste = new Rect(_vanillaPasteRect); if (Widgets.ButtonImageFitted(rectPaste, Resources.PasteButton, Color.white)) { billCopyPasteHandler.DoPasteInto(workTable, false); } if (Widgets.ButtonImageFitted(buttonRect, Resources.Link, Color.white)) { billCopyPasteHandler.DoPasteInto(workTable, true); } TooltipHandler.TipRegion(buttonRect, "IW.PasteLinkTip".Translate()); }
public void Draw(Rect rect) { if (GUIController.CurrentProfiler == null) { return; } var c = new Rect(rect.x, rect.y, 20, 20); if (doSettings) { c.height = 30; DrawSettings(this, ref rect); } if (Mouse.IsOver(rect) && Event.current.isScrollWheel && (Input.mouseScrollDelta.y > 0f || Input.mouseScrollDelta.y < 0f)) { entryCount = Mathf.Clamp(entryCount - (int)(Input.mouseScrollDelta.y * 100), 100, 2000); } var stub = Vector2.right; Widgets.BeginScrollView(rect, ref stub, rect, false); var count = SetupArrays(); GraphDrawer.DrawGraph(this, rect, count); Widgets.EndScrollView(); if (!doSettings) { if (Widgets.ButtonImageFitted(c, Textures.Gear)) { doSettings = !doSettings; } c.x = c.xMax; if (Widgets.ButtonImageFitted(c, TexButton.SpeedButtonTextures[Analyzer.CurrentlyPaused ? 1 : 0])) { Analyzer.CurrentlyPaused = !Analyzer.CurrentlyPaused; GUIController.CurrentEntry.SetActive(!Analyzer.CurrentlyPaused); } } }
public static void DoGraph(Rect position) { ResetRange++; if (ResetRange >= 500) { ResetRange = 0; WindowMax = 0; } Text.Font = GameFont.Small; var settings = position.TopPartPixels(30f); position = position.BottomPartPixels(position.height - 30f); Widgets.DrawBoxSolid(position, Analyzer.Settings.GraphCol); GUI.color = Color.grey; Widgets.DrawBox(position, 2); GUI.color = Color.white; if (!Analyzer.Profiles.ContainsKey(key)) { return; } var prof = Analyzer.Profiles[key]; if (prof.History.times.Length <= 0) { return; } var mescou = prof.History.times.Length; if (mescou > entryCount) { mescou = entryCount; } var gap = position.width / mescou; var car = settings.RightPartPixels(200f); car.x -= 15; entryCount = (int)Widgets.HorizontalSlider(car, entryCount, 10, 2000, true, string.Intern($"{entryCount} Entries")); car = new Rect(car.xMax + 5, car.y + 2, 10, 10); Widgets.DrawBoxSolid(car, Analyzer.Settings.LineCol); if (Widgets.ButtonInvisible(car, true)) { if (Find.WindowStack.WindowOfType <colourPicker>() != null) { Find.WindowStack.RemoveWindowsOfType(typeof(colourPicker)); } else { var cp = new colourPicker { Setcol = () => Analyzer.Settings.LineCol = colourPicker.CurrentCol }; cp.SetColor(Analyzer.Settings.LineCol); Find.WindowStack.Add(cp); } } car.y += 12; Widgets.DrawBoxSolid(car, Analyzer.Settings.GraphCol); if (Widgets.ButtonInvisible(car, true)) { if (Find.WindowStack.WindowOfType <colourPicker>() != null) { Find.WindowStack.RemoveWindowsOfType(typeof(colourPicker)); } else { var cp = new colourPicker { Setcol = () => Analyzer.Settings.GraphCol = colourPicker.CurrentCol }; cp.SetColor(Analyzer.Settings.GraphCol); Find.WindowStack.Add(cp); } } if (Analyzer.Settings.AdvancedMode) { var memr = settings.LeftPartPixels(20f); if (Widgets.ButtonImageFitted(memr, mem, ShowMem ? Color.white : Color.grey)) { ShowMem = !ShowMem; } GUI.color = Color.white; TooltipHandler.TipRegion(memr, "Toggle garbage tracking, approximation of total garbage produced by the selected log"); memr.x = memr.xMax; memr.width = 300f; if (ShowMem) { Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(memr, totalBytesStr); } } Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(settings, hoverValStr); Text.Anchor = TextAnchor.UpperLeft; maxBytes = 0; minBytes = 0; var LastMax = max; max = 0; GUI.BeginGroup(position); position = position.AtZero(); for (var i = 0; i < mescou; i++) { var bytes = prof.History.mem[i]; var TM = prof.History.times[i]; if (i == 0) { minBytes = bytes; maxBytes = bytes; max = TM; } if (bytes < minBytes) { minBytes = bytes; } if (bytes > maxBytes) { maxBytes = bytes; } if (TM > max) { max = TM; } } if (max > WindowMax) { WindowMax = (float)max; } var DoHover = false; for (var i = 0; i < mescou; i++) { var bytes = prof.History.mem[i]; var TM = prof.History.times[i]; var y = GenMath.LerpDoubleClamped(0, WindowMax, position.height, position.y, (float)TM); var MEMy = GenMath.LerpDoubleClamped(minBytes, maxBytes, position.height, position.y, bytes); var screenPoint = new Vector2(position.xMax - gap * i, y); var MEMscreenPoint = new Vector2(position.xMax - gap * i, MEMy); if (i != 0) { Widgets.DrawLine(last, screenPoint, Analyzer.Settings.LineCol, 1f); if (ShowMem) { Widgets.DrawLine(lastMEM, MEMscreenPoint, Color.grey, 2f); } var vag = new Rect(screenPoint.x - gap / 2f, position.y, gap, position.height); //if (Widgets.ButtonInvisible(vag)) //{ // Log.Warning(prof.History.stack[i]); // Find.WindowStack.Windows.Add(new StackWindow { stkRef = prof.History.stack[i] }); //} if (Mouse.IsOver(vag)) { DoHover = true; if (i != hoverVal) { hoverVal = i; hoverValStr = $"{TM} {prof.History.hits[i]} calls"; } SimpleCurveDrawer.DrawPoint(screenPoint); } } last = screenPoint; lastMEM = MEMscreenPoint; } if (LastMax != max) { MaxStr = $"Max {max}ms"; } if (LASTtotalBytesStr < prof.BytesUsed) { LASTtotalBytesStr = prof.BytesUsed; totalBytesStr = $"Mem {(long)(prof.BytesUsed / (long)1024)} Kb"; } var LogMaxY = GenMath.LerpDoubleClamped(0, WindowMax, position.height, position.y, (float)max); var crunt = position; crunt.y = LogMaxY; Widgets.Label(crunt, MaxStr); Widgets.DrawLine(new Vector2(position.x, LogMaxY), new Vector2(position.xMax, LogMaxY), Color.red, 1f); last = Vector2.zero; GUI.EndGroup(); }
public override void DoWindowContents(Rect inRect) { // Step 1 - Gather and set relevent information. float col1, col2; // Step 2 - Draw the title of the window. Text.Font = GameFont.Medium; string title = $"{WINDOW_TITLE_LOC_STRING.Translate()} - {pawn.Name.ToStringShort} ({pawn.def.LabelCap})"; float titleHeight = Text.CalcHeight(title, inRect.width); Widgets.Label(new Rect(inRect.x, inRect.y, inRect.width, Text.CalcHeight(title, inRect.width)), title); Text.Font = GameFont.Small; col1 = col2 = titleHeight; // Step 3 - Determine vewing areas for body part list and description. float drawableWidth = (inRect.width - PREVIEW_SIZE.x - 2 * SPACER_SIZE) / 2; float drawableHeight = inRect.height - titleHeight - Math.Max(APPLY_BUTTON_SIZE.y, Math.Max(RESET_BUTTON_SIZE.y, CANCEL_BUTTON_SIZE.y)) - 2 * SPACER_SIZE; Rect partListOutRect = new Rect(inRect.x, titleHeight, drawableWidth, drawableHeight); Rect partListViewRect = new Rect(partListOutRect.x, partListOutRect.y, partListScrollSize.x, partListScrollSize.y); Rect previewRect = new Rect(inRect.x + SPACER_SIZE + drawableWidth, titleHeight, PREVIEW_SIZE.x, PREVIEW_SIZE.y); // Step 4 - Draw the body part list, selection buttons and edit buttons. DrawPartsList(partListOutRect, partListViewRect, ref col1, titleHeight); // Step 5 - Draw the preview area... if (recachePreview || previewImage == null) { SetPawnPreview(); } GUI.DrawTexture(previewRect, previewImage); col2 += previewRect.height; // Then the preview Buttons... float rotCWHorPos = previewRect.x + previewRect.width / 2 - TOGGLE_CLOTHES_BUTTON_SIZE.x / 2 - ROTATE_CW_BUTTON_SIZE.x - SPACER_SIZE; float toggleClothingHorPos = previewRect.x + previewRect.width / 2 - TOGGLE_CLOTHES_BUTTON_SIZE.x / 2; float rotCCWHorPos = previewRect.x + previewRect.width / 2 + TOGGLE_CLOTHES_BUTTON_SIZE.x / 2 + SPACER_SIZE; Rect rotCWRect = new Rect(rotCWHorPos, col2, ROTATE_CW_BUTTON_SIZE.x, ROTATE_CW_BUTTON_SIZE.y); Rect toggleClothesRect = new Rect(toggleClothingHorPos, col2, TOGGLE_CLOTHES_BUTTON_SIZE.x, TOGGLE_CLOTHES_BUTTON_SIZE.y); Rect rotCCWRect = new Rect(rotCCWHorPos, col2, ROTATE_CCW_BUTTON_SIZE.x, ROTATE_CCW_BUTTON_SIZE.y); col2 += SPACER_SIZE; if (Widgets.ButtonImageFitted(rotCWRect, ButtonTexturesPM.rotCW, Color.white, GenUI.MouseoverColor)) { previewRot.Rotate(RotationDirection.Clockwise); SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(); recachePreview = true; } TooltipHandler.TipRegionByKey(rotCWRect, ROTATE_CW_LOC_STRING); if (Widgets.ButtonImageFitted(toggleClothesRect, ButtonTexturesPM.toggleClothes, Color.white, GenUI.MouseoverColor)) { toggleClothesEnabled = !toggleClothesEnabled; (toggleClothesEnabled ? SoundDefOf.Checkbox_TurnedOn : SoundDefOf.Checkbox_TurnedOff).PlayOneShotOnCamera(); recachePreview = true; } TooltipHandler.TipRegionByKey(toggleClothesRect, TOGGLE_CLOTHES_LOC_STRING); if (Widgets.ButtonImageFitted(rotCCWRect, ButtonTexturesPM.rotCCW, Color.white, GenUI.MouseoverColor)) { previewRot.Rotate(RotationDirection.Counterclockwise); SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(); recachePreview = true; } TooltipHandler.TipRegionByKey(rotCCWRect, ROTATE_CCW_LOC_STRING); col2 += Math.Max(TOGGLE_CLOTHES_BUTTON_SIZE.y, Math.Max(ROTATE_CW_BUTTON_SIZE.y, ROTATE_CCW_BUTTON_SIZE.y)); // Then the crown and body type selectors... // Head [Type] <-- box that shows selection list. // Body [Type] (Need to include these in the reset function.) // Then the Aspect selection list... // Remember this needs scrolling, Brennen. // Then finally the parts list toggles. string skinSyncText = SKIN_SYNC_LOC_STRING.Translate(); Rect skinSyncRect = new Rect(inRect.x + SPACER_SIZE + drawableWidth, col2, PREVIEW_SIZE.x, Text.CalcHeight(skinSyncText, PREVIEW_SIZE.x)); Widgets.CheckboxLabeled(skinSyncRect, skinSyncText, ref skinSync); col2 += skinSyncRect.height; string symmetryToggleText = DO_SYMMETRY_LOC_STRING.Translate(); Rect symmetryToggleRect = new Rect(inRect.x + SPACER_SIZE + drawableWidth, col2, PREVIEW_SIZE.x, Text.CalcHeight(symmetryToggleText, PREVIEW_SIZE.x)); Widgets.CheckboxLabeled(symmetryToggleRect, symmetryToggleText, ref doSymmetry); // Step 6 - Draw description box. DrawDescriptionBoxes(new Rect(inRect.x + 2 * SPACER_SIZE + PREVIEW_SIZE.x + partListOutRect.width, titleHeight, drawableWidth, drawableHeight)); // Step 7 - Draw the apply, reset and cancel buttons. float buttonVertPos = titleHeight + drawableHeight + SPACER_SIZE; float applyHorPos = inRect.width / 2 - APPLY_BUTTON_SIZE.x - RESET_BUTTON_SIZE.x / 2 - SPACER_SIZE; float resetHorPos = inRect.width / 2 - RESET_BUTTON_SIZE.x / 2; float cancelHorPos = inRect.width / 2 + RESET_BUTTON_SIZE.x / 2 + SPACER_SIZE; if (Widgets.ButtonText(new Rect(applyHorPos, buttonVertPos, APPLY_BUTTON_SIZE.x, APPLY_BUTTON_SIZE.y), APPLY_BUTTON_LOC_STRING.Translate())) { OnAcceptKeyPressed(); } if (Widgets.ButtonText(new Rect(resetHorPos, buttonVertPos, RESET_BUTTON_SIZE.x, RESET_BUTTON_SIZE.y), RESET_BUTTON_LOC_STRING.Translate())) { SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null); ResetPawnHealth(); recachePreview = true; } if (Widgets.ButtonText(new Rect(cancelHorPos, buttonVertPos, CANCEL_BUTTON_SIZE.x, CANCEL_BUTTON_SIZE.y), CANCEL_BUTTON_LOC_STRING.Translate())) { OnCancelKeyPressed(); } }
private void DrawRightRect(Rect rightOutRect) { rightOutRect.yMin += 32f; Widgets.DrawMenuSection(rightOutRect); List <TabRecord> list = new List <TabRecord>(); foreach (ResearchTabDef allDef in DefDatabase <ResearchTabDef> .AllDefs) { ResearchTabDef localTabDef = allDef; list.Add(new TabRecord(localTabDef.LabelCap, delegate { CurTab = localTabDef; }, CurTab == localTabDef)); } TabDrawer.DrawTabs(rightOutRect, list); if (Prefs.DevMode) { Rect rect = rightOutRect; rect.yMax = rect.yMin + 20f; rect.xMin = rect.xMax - 80f; Rect butRect = rect.RightPartPixels(30f); rect = rect.LeftPartPixels(rect.width - 30f); Widgets.CheckboxLabeled(rect, "Edit", ref editMode); if (Widgets.ButtonImageFitted(butRect, TexButton.Copy)) { StringBuilder stringBuilder = new StringBuilder(); foreach (ResearchProjectDef item in from def in DefDatabase <ResearchProjectDef> .AllDefsListForReading where def.Debug_IsPositionModified() select def) { stringBuilder.AppendLine(item.defName); stringBuilder.AppendLine(string.Format(" <researchViewX>{0}</researchViewX>", item.ResearchViewX.ToString("F2"))); stringBuilder.AppendLine(string.Format(" <researchViewY>{0}</researchViewY>", item.ResearchViewY.ToString("F2"))); stringBuilder.AppendLine(); } GUIUtility.systemCopyBuffer = stringBuilder.ToString(); Messages.Message("Modified data copied to clipboard.", MessageTypeDefOf.SituationResolved, historical: false); } } else { editMode = false; } Rect outRect = rightOutRect.ContractedBy(10f); Rect rect2 = new Rect(0f, 0f, rightViewWidth, rightViewHeight); Rect rect3 = rect2.ContractedBy(10f); rect2.width = rightViewWidth; rect3 = rect2.ContractedBy(10f); Vector2 start = default(Vector2); Vector2 end = default(Vector2); Widgets.ScrollHorizontal(outRect, ref rightScrollPosition, rect2); Widgets.BeginScrollView(outRect, ref rightScrollPosition, rect2); GUI.BeginGroup(rect3); List <ResearchProjectDef> allDefsListForReading = DefDatabase <ResearchProjectDef> .AllDefsListForReading; for (int i = 0; i < 2; i++) { for (int j = 0; j < allDefsListForReading.Count; j++) { ResearchProjectDef researchProjectDef = allDefsListForReading[j]; if (researchProjectDef.tab == CurTab) { start.x = PosX(researchProjectDef); start.y = PosY(researchProjectDef) + 25f; for (int k = 0; k < researchProjectDef.prerequisites.CountAllowNull(); k++) { ResearchProjectDef researchProjectDef2 = researchProjectDef.prerequisites[k]; if (researchProjectDef2 != null && researchProjectDef2.tab == CurTab) { end.x = PosX(researchProjectDef2) + 140f; end.y = PosY(researchProjectDef2) + 25f; if (selectedProject == researchProjectDef || selectedProject == researchProjectDef2) { if (i == 1) { Widgets.DrawLine(start, end, TexUI.HighlightLineResearchColor, 4f); } } else if (i == 0) { Widgets.DrawLine(start, end, TexUI.DefaultLineResearchColor, 2f); } } } } } } for (int l = 0; l < allDefsListForReading.Count; l++) { ResearchProjectDef researchProjectDef3 = allDefsListForReading[l]; if (researchProjectDef3.tab == CurTab) { Rect source = new Rect(PosX(researchProjectDef3), PosY(researchProjectDef3), 140f, 50f); string label = GetLabel(researchProjectDef3); Rect rect4 = new Rect(source); Color textColor = Widgets.NormalOptionColor; Color color = default(Color); Color color2 = default(Color); bool flag = !researchProjectDef3.IsFinished && !researchProjectDef3.CanStartNow; if (researchProjectDef3 == Find.ResearchManager.currentProj) { color = TexUI.ActiveResearchColor; } else if (researchProjectDef3.IsFinished) { color = TexUI.FinishedResearchColor; } else if (flag) { color = TexUI.LockedResearchColor; } else if (researchProjectDef3.CanStartNow) { color = TexUI.AvailResearchColor; } if (selectedProject == researchProjectDef3) { color += TexUI.HighlightBgResearchColor; color2 = TexUI.HighlightBorderResearchColor; } else { color2 = TexUI.DefaultBorderResearchColor; } if (flag) { textColor = ProjectWithMissingPrerequisiteLabelColor; } for (int m = 0; m < researchProjectDef3.prerequisites.CountAllowNull(); m++) { ResearchProjectDef researchProjectDef4 = researchProjectDef3.prerequisites[m]; if (researchProjectDef4 != null && selectedProject == researchProjectDef4) { color2 = TexUI.HighlightLineResearchColor; } } if (requiredByThisFound) { for (int n = 0; n < researchProjectDef3.requiredByThis.CountAllowNull(); n++) { ResearchProjectDef researchProjectDef5 = researchProjectDef3.requiredByThis[n]; if (selectedProject == researchProjectDef5) { color2 = TexUI.HighlightLineResearchColor; } } } if (Widgets.CustomButtonText(ref rect4, label, color, textColor, color2, cacheHeight: true)) { SoundDefOf.Click.PlayOneShotOnCamera(); selectedProject = researchProjectDef3; } if (editMode && Mouse.IsOver(rect4) && Input.GetMouseButtonDown(0)) { draggingTab = researchProjectDef3; } } } GUI.EndGroup(); Widgets.EndScrollView(); if (!Input.GetMouseButton(0)) { draggingTab = null; } if (draggingTab != null && !Input.GetMouseButtonDown(0) && Event.current.type == EventType.Layout) { ResearchProjectDef researchProjectDef6 = draggingTab; Vector2 delta = Event.current.delta; float x = PixelsToCoordX(delta.x); Vector2 delta2 = Event.current.delta; researchProjectDef6.Debug_ApplyPositionDelta(new Vector2(x, PixelsToCoordY(delta2.y))); } }
protected override void FillTab() { PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed); Rect rect = new Rect(ITab_Bills2.WinSize.x - ITab_Bills2.PasteX, ITab_Bills2.PasteY, ITab_Bills2.PasteSize, ITab_Bills2.PasteSize); if (BillUtility.Clipboard == null) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect, TexButton.Paste, 1f); GUI.color = Color.white; TooltipHandler.TipRegionByKey(rect, "PasteBillTip"); } else if (!this.SelTable.def.AllRecipes.Contains(BillUtility.Clipboard.recipe) || !BillUtility.Clipboard.recipe.AvailableNow) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect, TexButton.Paste, 1f); GUI.color = Color.white; TooltipHandler.TipRegionByKey(rect, "ClipboardBillNotAvailableHere"); } else if (this.SelTable.billStack.Count >= 15) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect, TexButton.Paste, 1f); GUI.color = Color.white; if (Mouse.IsOver(rect)) { TooltipHandler.TipRegion(rect, "PasteBillTip".Translate() + " (" + "PasteBillTip_LimitReached".Translate() + ")"); } } else { if (Widgets.ButtonImageFitted(rect, TexButton.Paste, Color.white)) { Bill bill = BillUtility.Clipboard.Clone(); bill.InitializeAfterClone(); this.SelTable.billStack.AddBill(bill); SoundDefOf.Tick_Low.PlayOneShotOnCamera(null); } TooltipHandler.TipRegionByKey(rect, "PasteBillTip"); } Rect rect2 = new Rect(0f, 0f, ITab_Bills2.WinSize.x, ITab_Bills2.WinSize.y).ContractedBy(10f); Func <List <FloatMenuOption> > recipeOptionsMaker = delegate { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (var recipe in this.SelTable.AllRecipes) { if (recipe.AvailableNow) { bool deletable = this.SelTable.IsRemovable(recipe); list.Add(new FloatMenuOption(recipe.LabelCap, delegate { if (!this.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col))) { Bill.CreateNoPawnsWithSkillDialog(recipe); } Bill bill2 = this.SelTable.MakeNewBill(recipe); this.SelTable.billStack.AddBill(bill2); if (recipe.conceptLearned != null) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total); } if (TutorSystem.TutorialMode) { TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap.Resolve()); } }, MenuOptionPriority.Default, null, null, deletable ? 58f : 29f, (Rect r) => { if (deletable) { if (Widgets.ButtonImage(new Rect(r.x + 34f, r.y + (r.height - 24f), 24f, 24f), RS.DeleteX)) { this.SelTable.RemoveRecipe(recipe); return(true); } } return(Widgets.InfoCardButton(r.x + 5f, r.y + (r.height - 24f) / 2f, recipe)); }, null)); } } if (!list.Any <FloatMenuOption>()) { list.Add(new FloatMenuOption("NoneBrackets".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } return(list); }; this.mouseoverBill = this.SelTable.billStack.DoListing(rect2, recipeOptionsMaker, ref this.scrollPosition, ref this.viewHeight); }
public void DrawTagEditor(Rect r) { _ = r.PopRightPartPixels(Margin); var topRect = r.TopPartPixels(22f); if (Widgets.ButtonText(topRect.LeftPart(0.33f), "SelectTag")) { var floatOpts = LoadoutManager.OptionPerTag(tag => $"{tag.name}", tag => curTag = tag); if (floatOpts.Count == 0) { Messages.Message(new Message("NoTagsYetWarning", MessageTypeDefOf.RejectInput)); } else { Find.WindowStack.Add(new FloatMenu(floatOpts)); } } topRect.AdjHorzBy(topRect.width * 0.33f); if (Widgets.ButtonText(topRect.LeftHalf(), "CreateNewTag")) { curTag = new Tag(string.Empty); LoadoutManager.AddTag(curTag); } if (Widgets.ButtonText(topRect.RightHalf(), "DeleteTag")) { var floatOpts = LoadoutManager.OptionPerTag(tag => $"{tag.name}", LoadoutManager.RemoveTag); if (floatOpts.Count == 0) { Messages.Message(new Message("NoTagsYetWarning", MessageTypeDefOf.RejectInput)); } else { Find.WindowStack.Add(new FloatMenu(floatOpts)); } } r.AdjVertBy(ModGUIUtility.DEFAULT_HEIGHT); if (curTag == null) { return; } Widgets.ListSeparator(ref r.m_YMin, r.width, "Modify".Translate() + " " + curTag.name); // [ Tag Name ] [ Edit Name ] var rect = r.PopTopPartPixels(ModGUIUtility.DEFAULT_HEIGHT); ModGUIUtility.InputField(rect, "ChangeTagName".Translate(), ref curTag.name); curTag.name ??= " "; var viewRect = new Rect(r.x, r.y, rect.width - 16f, (curTag.requiredItems.Count * ModGUIUtility.SPACED_HEIGHT * 2)); Widgets.BeginScrollView(r, ref curItemScroll, viewRect); var visibilityRect = r; visibilityRect.y += curItemScroll.y; var baseRect = viewRect; List <Item> toRemove = new List <Item>(); // List each item in the currently required items // [ Info ] [ Icon ] [ Name ] [ Edit Filter ] [ Edit Quantity ] [ Remove ] foreach (var item in curTag.requiredItems) { var def = item.Def; var itemRect = baseRect.PopTopPartPixels(ModGUIUtility.SPACED_HEIGHT * 2); if (!itemRect.Overlaps(visibilityRect)) { continue; } // Info Rect infoRect = itemRect.PopLeftPartPixels(GenUI.SmallIconSize); if (Widgets.ButtonImageFitted(infoRect.ContractedBy(1f), TexButton.Info)) { Thing thing = Utility.MakeThingWithoutID(def, item.RandomStuff, item.RandomQuality); Find.WindowStack.Add(new Dialog_InfoCard(thing)); } // Icon var iconRect = itemRect.PopLeftPartPixels(ModGUIUtility.SPACED_HEIGHT * 2); if (item.Quantity > 1) { ModGUIUtility.FittedDefIconCount(iconRect, def, item.RandomStuff, item.Quantity); } else { Widgets.DefIcon(iconRect, def, item.RandomStuff); } TooltipHandler.TipRegion(iconRect, item.Def.DescriptionDetailed); // Remove var removeButton = itemRect.PopRightPartPixels(ModGUIUtility.SPACED_HEIGHT * 1.5f); if (Widgets.ButtonImageFitted(removeButton.ContractedBy(1f), TexButton.DeleteX)) { toRemove.Add(item); } TooltipHandler.TipRegion(removeButton, "RemoveItemFromTag".Translate()); // Copy, Paste var copyPasteButton = itemRect.PopRightPartPixels(ModGUIUtility.SPACED_HEIGHT * 3); ModGUIUtility.DraggableCopyPaste(copyPasteButton, ref item.filter, Filter.CopyFrom); TooltipHandler.TipRegion(copyPasteButton, "CopyPasteExplain".Translate()); // Edit var constrainButton = itemRect.PopRightPartPixels(ModGUIUtility.SPACED_HEIGHT * 1.5f); if (Widgets.ButtonImageFitted(constrainButton.ContractedBy(1f), Textures.EditTex)) { Find.WindowStack.Add(new Dialog_ItemSpecifier(item.Filter)); } TooltipHandler.TipRegion(constrainButton, Strings.SpecifyElementsToolTip); var quantityFieldRect = itemRect.PopRightPartPixels(ModGUIUtility.SPACED_HEIGHT * 2f); item.quantityStr ??= item.Quantity.ToString(); ModGUIUtility.InputField(quantityFieldRect.ContractedBy(0, quantityFieldRect.height / 4.0f), "QuantityField" + item.Def.defName, ref item.quantityStr); if (item.quantityStr == "") { item.SetQuantity(0); } else { try { item.SetQuantity(int.Parse(item.quantityStr)); } catch (Exception e) { Log.ErrorOnce($"Invalid numeric string {item.quantityStr}: " + e.Message, item.quantityStr.GetHashCode()); } } TooltipHandler.TipRegion(quantityFieldRect, Strings.EditQuantity); // Name Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(itemRect, item.Label); Text.Anchor = TextAnchor.UpperLeft; } Widgets.EndScrollView(); foreach (var item in toRemove) { curTag.requiredItems.Remove(item); } }
protected override void FillTab() { if (this.SelThing is Building_ShellfishTrap trap) { float y = 20; Rect label1 = new Rect(xLeft, y, width, 32f).ContractedBy(4f); y += 32; Rect storage = new Rect(xLeft, y, width, 40f); y += 60; Rect label2 = new Rect(xLeft, y, width, 32f).ContractedBy(4f); y += 32; Rect slider = new Rect(xLeft, y, width, 32f).ContractedBy(4f); Rect rectPaste = new Rect(size.x - PasteX, PasteY, PasteSize, PasteSize); Rect rectCopy = new Rect(size.x - CopyX, CopyY, CopySize, CopySize); if (HasCopy) { if (Widgets.ButtonImageFitted(rectPaste, ResourceBank.Paste, Color.white)) { trap.StoreMode = StoreModeCopy; trap.OpenFrequency = OpenDelayCopy; SoundDefOf.Tick_Low.PlayOneShotOnCamera(); } } else { GUI.color = Color.gray; Widgets.DrawTextureFitted(rectPaste, ResourceBank.Paste, 1f); GUI.color = Color.white; } TooltipHandler.TipRegionByKey(rectPaste, ResourceBank.Strings.PasteTip); if (Widgets.ButtonImageFitted(rectCopy, ResourceBank.Copy, Color.white)) { HasCopy = true; StoreModeCopy = trap.StoreMode; OpenDelayCopy = trap.OpenFrequency; SoundDefOf.Tick_Low.PlayOneShotOnCamera(); } TooltipHandler.TipRegionByKey(rectCopy, ResourceBank.Strings.CopyTip); Text.Font = GameFont.Small; //stockpile setting Widgets.Label(label1, StockpileString.Translate()); Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.Begin(storage); Listing_Standard listing_Standard2 = listing_Standard.BeginSection(StoreModeSubdialogHeight); string text = trap.StoreMode.LabelCap; if (listing_Standard2.ButtonText(text)) { Text.Font = GameFont.Small; List <FloatMenuOption> list = new List <FloatMenuOption>(); list.Add(new FloatMenuOption(BillStoreModeDefOf.BestStockpile.LabelCap, delegate { trap.StoreMode = BillStoreModeDefOf.BestStockpile; })); list.Add(new FloatMenuOption(BillStoreModeDefOf.DropOnFloor.LabelCap, delegate { trap.StoreMode = BillStoreModeDefOf.DropOnFloor; })); Find.WindowStack.Add(new FloatMenu(list)); } Text.Font = GameFont.Small; listing_Standard.EndSection(listing_Standard2); listing_Standard.End(); Text.Font = GameFont.Small; //delay setting Widgets.Label(label2, ResourceBank.Strings.UnloadFrequency.Translate()); Text.Font = GameFont.Small; trap.OpenFrequency = Widgets.FrequencyHorizontalSlider(slider, trap.OpenFrequency, 0.1f, 25f, roundToInt: true); } else { DrawTabNothing(); } }
protected override void FillTab() { float pasteX = (float)PasteXField.GetValue(null); float pasteY = (float)PasteYField.GetValue(null); float pasteSize = (float)PasteSizeField.GetValue(null); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed); Rect rect = new Rect(WinSize.x - pasteX, pasteY, pasteSize, pasteSize); if (BillUtility.Clipboard == null) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect, Textures.Paste, 1f); GUI.color = Color.white; TooltipHandler.TipRegion(rect, "PasteBillTip".Translate()); } else if (!SelAssembler.GetAllRecipes().Contains(BillUtility.Clipboard.recipe) || !BillUtility.Clipboard.recipe.AvailableNow) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect, Textures.Paste, 1f); GUI.color = Color.white; TooltipHandler.TipRegion(rect, "ClipboardBillNotAvailableHere".Translate()); } else if (SelAssembler.BillStack.Count >= 15) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect, Textures.Paste, 1f); GUI.color = Color.white; TooltipHandler.TipRegion(rect, "PasteBillTip".Translate() + " (" + "PasteBillTip_LimitReached".Translate() + ")"); } else { if (Widgets.ButtonImageFitted(rect, Textures.Paste, Color.white)) { Bill bill = BillUtility.Clipboard.Clone(); bill.InitializeAfterClone(); SelAssembler.BillStack.AddBill(bill); SoundDefOf.Tick_Low.PlayOneShotOnCamera(null); } TooltipHandler.TipRegion(rect, "PasteBillTip".Translate()); } Rect rect2 = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f); Func <List <FloatMenuOption> > recipeOptionsMaker = delegate() { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (RecipeDef recipe in SelAssembler.GetAllRecipes()) { if (recipe.AvailableNow) { list.Add(new FloatMenuOption(recipe.LabelCap, delegate() { if (!SelAssembler.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col))) { Bill.CreateNoPawnsWithSkillDialog(recipe); } Bill bill2 = recipe.MakeNewBill(); SelAssembler.BillStack.AddBill(bill2); if (recipe.conceptLearned != null) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total); } }, MenuOptionPriority.Default, null, null, 29f, (Rect r) => Widgets.InfoCardButton(r.x + 5f, r.y + (r.height - 24f) / 2f, recipe), null)); } } if (!list.Any()) { list.Add(new FloatMenuOption("NoneBrackets".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } return(list); }; mouseoverBill = SelAssembler.BillStack.DoListing(rect2, recipeOptionsMaker, ref scrollPosition, ref viewHeight); // //Rect rect = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f); //Func<List<FloatMenuOption>> recipeOptionsMaker = delegate //{ // List<FloatMenuOption> list = new List<FloatMenuOption>(); // foreach (RecipeDef recipe in SelAssembler.GetAllRecipes()) // { // if (recipe.AvailableNow) // { // list.Add(new FloatMenuOption(recipe.LabelCap, delegate // { // Bill bill = recipe.MakeNewBill(); // SelAssembler.BillStack.AddBill(bill); // }, MenuOptionPriority.Default, null, null, 29f, (Rect r) => Widgets.InfoCardButton(r.x + 5f, r.y + (r.height - 24f) / 2f, recipe), null)); // } // } // if (list.Count == 0) // { // list.Add(new FloatMenuOption("NoneBrackets".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); // } // return list; //}; //mouseoverBill = SelAssembler.BillStack.DoListing(rect, recipeOptionsMaker, ref this.scrollPosition, ref this.viewHeight); }
protected override void FillTab() { PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed); Rect rect2 = new Rect(WinSize.x - PasteX, PasteY, PasteSize, PasteSize); if (BillUtility.Clipboard == null) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f); GUI.color = Color.white; TooltipHandler.TipRegionByKey(rect2, "PasteBillTip"); } else if (!SelTable.def.AllRecipes.Contains(BillUtility.Clipboard.recipe) || !BillUtility.Clipboard.recipe.AvailableNow || !BillUtility.Clipboard.recipe.AvailableOnNow(SelTable)) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f); GUI.color = Color.white; TooltipHandler.TipRegionByKey(rect2, "ClipboardBillNotAvailableHere"); } else if (SelTable.billStack.Count >= 15) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f); GUI.color = Color.white; if (Mouse.IsOver(rect2)) { TooltipHandler.TipRegion(rect2, "PasteBillTip".Translate() + " (" + "PasteBillTip_LimitReached".Translate() + ")"); } } else { if (Widgets.ButtonImageFitted(rect2, TexButton.Paste, Color.white)) { Bill bill = BillUtility.Clipboard.Clone(); bill.InitializeAfterClone(); SelTable.billStack.AddBill(bill); SoundDefOf.Tick_Low.PlayOneShotOnCamera(); } TooltipHandler.TipRegionByKey(rect2, "PasteBillTip"); } Rect rect3 = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f); Func <List <FloatMenuOption> > recipeOptionsMaker = delegate { List <FloatMenuOption> list = new List <FloatMenuOption>(); ITab_Bills tab_Bills = default(ITab_Bills); RecipeDef recipe = default(RecipeDef); for (int i = 0; i < SelTable.def.AllRecipes.Count; i++) { tab_Bills = this; if (SelTable.def.AllRecipes[i].AvailableNow && SelTable.def.AllRecipes[i].AvailableOnNow(SelTable)) { recipe = SelTable.def.AllRecipes[i]; list.Add(new FloatMenuOption(recipe.LabelCap, delegate { if (!tab_Bills.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col))) { Bill.CreateNoPawnsWithSkillDialog(recipe); } Bill bill2 = recipe.MakeNewBill(); tab_Bills.SelTable.billStack.AddBill(bill2); if (recipe.conceptLearned != null) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total); } if (TutorSystem.TutorialMode) { TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap.Resolve()); } }, recipe.ProducedThingDef, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe))); } } if (!list.Any()) { list.Add(new FloatMenuOption("NoneBrackets".Translate(), null)); } return(list); }; mouseoverBill = SelTable.billStack.DoListing(rect3, recipeOptionsMaker, ref scrollPosition, ref viewHeight); }
private static void DrawSettings(Panel_Graph instance, ref Rect position) { void CheckNewRow(ref Rect box, ref Rect position) { if (box.xMax > position.xMax) { position.AdjustVerticallyBy(box.height); box.y += box.height; box.x = position.x; } } var currentHeight = 32; var box = position.TopPartPixels(currentHeight).LeftPartPixels(20f); position.AdjustVerticallyBy(currentHeight); Text.Anchor = TextAnchor.MiddleCenter; if (Widgets.ButtonImageFitted(box, Textures.Menu)) { doSettings = !doSettings; } box.ShiftX(5); if (Widgets.ButtonImageFitted(box, TexButton.SpeedButtonTextures[Analyzer.CurrentlyPaused ? 1 : 0])) { Analyzer.CurrentlyPaused = !Analyzer.CurrentlyPaused; GUIController.CurrentEntry.SetActive(!Analyzer.CurrentlyPaused); } box.ShiftX(5); var str = "Times"; box.width = 20 + str.GetWidthCached(); instance.times.visible = ToggleColCombo(box, str, instance.times.visible, Settings.timeColour, () => Settings.timeColour = colourPicker.CurrentCol); box.ShiftX(5); str = "Calls"; box.width = 20 + str.GetWidthCached(); instance.calls.visible = ToggleColCombo(box, str, instance.calls.visible, Settings.callsColour, () => Settings.callsColour = colourPicker.CurrentCol); box.ShiftX(5); str = "Background"; box.width = 20 + str.GetWidthCached(); ToggleColCombo(box, str, true, Settings.GraphCol, () => Settings.GraphCol = colourPicker.CurrentCol); box.ShiftX(5); void jammydodger(ref Rect p, string s, ref bool r) { box.width = 20 + s.GetWidthCached(); CheckNewRow(ref box, ref p); r = DrawButton(box, s, r); box.ShiftX(5); } jammydodger(ref position, "Axis", ref GraphSettings.showAxis); jammydodger(ref position, "Grid", ref GraphSettings.showGrid); jammydodger(ref position, "Max", ref GraphSettings.showMax); Text.Anchor = TextAnchor.UpperLeft; box.width = 100; CheckNewRow(ref box, ref position); instance.entryCount = (int)Widgets.HorizontalSlider(box.BottomPartPixels(30f), instance.entryCount, 10, 2000, true, string.Intern($"{instance.entryCount} Entries")); box.ShiftX(5); Text.Anchor = TextAnchor.MiddleCenter; Text.Font = GameFont.Tiny; str = $"Aliasing:{(GraphSettings.lineAliasing == 0 ? "none" : GraphSettings.lineAliasing.ToString())}"; box.width = str.GetWidthCached() + 10; CheckNewRow(ref box, ref position); if (Widgets.ButtonText(box, str, false)) { GraphSettings.lineAliasing = GraphSettings.lineAliasing switch { 7.5f => 12.5f, 12.5f => 0.0f, 0.0f => 5.0f, 5.0f => 7.5f, _ => 0.0f }; } box.ShiftX(5); DubGUI.ResetFont(); }
private void DrawDay(Rect rect, int dayNumber) { ScheduledDay day = TaskManager.ScheduledDays.FirstOrDefault(x => x.DayNumber == dayNumber); Widgets.DrawBox(rect); Rect firstLine = rect.ContractedBy(6); firstLine.height = 20; Widgets.Label(firstLine, dayNumber.ToString()); Rect copy = new Rect(firstLine); copy.width = 20; copy.x += copy.width; if (Widgets.ButtonImageFitted(copy, GraphicsCache.Copy, Color.white)) { ActivityTaskUtility.Clipboard = day; SoundDefOf.Tick_High.PlayOneShotOnCamera((Map)null); } TooltipHandler.TipRegionByKey(copy, "CopyBillTip"); Rect paste = new Rect(copy); paste.x += paste.width; if (ActivityTaskUtility.Clipboard == null) { GUI.color = Color.gray; Widgets.DrawTextureFitted(paste, (Texture)GraphicsCache.Paste, 1f); GUI.color = Color.white; TooltipHandler.TipRegionByKey(paste, "PasteBillTip"); } else { if (Widgets.ButtonImageFitted(paste, GraphicsCache.Paste, Color.white)) { ScheduledDay clip = ActivityTaskUtility.Clipboard; foreach (var task in clip.Tasks) { day.Add(task); } SoundDefOf.Tick_Low.PlayOneShotOnCamera((Map)null); } TooltipHandler.TipRegionByKey(paste, "PasteBillTip"); } if (day != null) { DrawDayInterFace(new Rect(rect.x + 6, rect.y + 30f, rect.width, rect.height * .75f), day); } Rect touchable = new Rect(rect); touchable.y += 30; touchable.height -= 30; if (Mouse.IsOver(touchable)) { //Widgets.DrawBox(rect, 3); Widgets.DrawBox(touchable, 3); if (Input.GetMouseButtonDown(0)) { if (day == null) { TaskManager.AddDay(dayNumber); } var options = GetFloatMenuOptions(day); if (!options.NullOrEmpty()) { Find.WindowStack.Add((Window) new Dialog_ScheduleDayConfig(day, GetFloatMenuOptions(day))); } } } }
protected override void FillTab() { if (this.SelThing is Building_FishingSpot spot) { float y = 20; Rect label1 = new Rect(xLeft, y, width, 32f).ContractedBy(4f); y += 32; Rect slider1 = new Rect(xLeft, y, width, 32f).ContractedBy(4f); y += 60; Rect label2 = new Rect(xLeft, y, width, 32f).ContractedBy(4f); y += 32; Rect slider2 = new Rect(xLeft, y, width, 32f).ContractedBy(4f); Rect rectPaste = new Rect(size.x - PasteX, PasteY, PasteSize, PasteSize); Rect rectCopy = new Rect(size.x - CopyX, CopyY, CopySize, CopySize); if (HasCopy) { if (Widgets.ButtonImageFitted(rectPaste, ResourceBank.Paste, Color.white)) { spot.FishingDuration = FishingDurationCopy; spot.FishingFrequency = FishingFrequencyCopy; SoundDefOf.Tick_Low.PlayOneShotOnCamera(); } } else { GUI.color = Color.gray; Widgets.DrawTextureFitted(rectPaste, ResourceBank.Paste, 1f); GUI.color = Color.white; } TooltipHandler.TipRegionByKey(rectPaste, ResourceBank.Strings.PasteTip); if (Widgets.ButtonImageFitted(rectCopy, ResourceBank.Copy, Color.white)) { HasCopy = true; FishingDurationCopy = spot.FishingDuration; FishingFrequencyCopy = spot.FishingFrequency; SoundDefOf.Tick_Low.PlayOneShotOnCamera(); } TooltipHandler.TipRegionByKey(rectCopy, ResourceBank.Strings.CopyTip); //duration setting Text.Font = GameFont.Small; Widgets.Label(label1, ResourceBank.Strings.FishingDuration.Translate()); Text.Font = GameFont.Small; spot.FishingDuration = Widgets.HorizontalSlider(slider1, spot.FishingDuration, 1f, 24f, true, (int)spot.FishingDuration == 1 ? Period1Hour.Translate() : PeriodHours.Translate(spot.FishingDuration.ToString("0.0"))); //delay setting Text.Font = GameFont.Small; Widgets.Label(label2, ResourceBank.Strings.FishingFrequency.Translate()); Text.Font = GameFont.Small; spot.FishingFrequency = Widgets.FrequencyHorizontalSlider(slider2, spot.FishingFrequency, 0.1f, 25f, roundToInt: true); } else { DrawTabNothing(); } }
public virtual void Draw(Rect maxBounds) { const int PADDING = 5; float topHeight = 128 + PADDING; // Background if (Background != null) { GUI.color = Color.white * 0.45f; var coords = CalculateUVCoords(maxBounds, new Rect(0, 0, Background.width, Background.height)); GUI.DrawTextureWithTexCoords(maxBounds, Background, coords, true); GUI.color = Color.white; } // Icon. bool drawnIcon = Icon != null; if (drawnIcon) { // Draws icon and opens zoom view window if clicked. if (Widgets.ButtonImageFitted(new Rect(maxBounds.x + PADDING, maxBounds.y + PADDING, 128, 128), Icon, Color.white, Color.white * 0.8f)) { Find.WindowStack?.Add(new UI_ImageInspector(Icon)); } } // Title. if (Title != null) { Text.Font = GameFont.Medium; float x = !drawnIcon ? maxBounds.x + PADDING : maxBounds.x + PADDING + 128 + PADDING; float w = !drawnIcon ? maxBounds.width - PADDING * 2 : maxBounds.width - PADDING * 2 - 128; string toDraw = Title; if (IsSpoiler) { toDraw += $" <color=#FF6D71><i>[{"Wiki.Spoiler".Translate().CapitalizeFirst()}]</i></color>"; } Widgets.Label(new Rect(x, maxBounds.y + PADDING, w, 34), toDraw); } // Short description. if(ShortDescription != null) { Text.Font = GameFont.Small; float x = !drawnIcon ? maxBounds.x + PADDING : maxBounds.x + PADDING + 128 + PADDING; float y = Title == null ? maxBounds.y + PADDING : maxBounds.y + PADDING * 2 + 34; float w = !drawnIcon ? maxBounds.width - PADDING * 2 : maxBounds.width - PADDING * 3 - 128; float h = (maxBounds.y + PADDING + 128) - y; Widgets.LabelScrollable(new Rect(x, y, w, h), ShortDescription, ref descScroll, false, true, true); } // Info card button. if (Def != null) { float infoCardX = maxBounds.xMax - Widgets.InfoCardButtonSize - 5; float infoCardY = maxBounds.y + PADDING; Widgets.InfoCardButton(infoCardX, infoCardY, Def); } // Move down to 'real wiki' part. Text.Font = GameFont.Small; maxBounds.y += topHeight; maxBounds.height -= topHeight; // Draw horizontal line separating wiki from description/icon. Widgets.DrawLineHorizontal(maxBounds.x, maxBounds.y, maxBounds.width); // Scroll view stuff. var whereToDraw = maxBounds; whereToDraw = whereToDraw.GetInner(PADDING); Widgets.BeginScrollView(whereToDraw, ref scroll, new Rect(maxBounds.x + PADDING, maxBounds.y + PADDING, maxBounds.width - 25 - PADDING * 2, lastHeight)); lastHeight = 0; // Draw elements. Rect pos = whereToDraw; pos.width -= 18; foreach (var element in Elements) { if (element == null) continue; try { var size = element.Draw(pos); pos.y += size.y + 10; lastHeight += size.y + 10; } catch (Exception e) { Log.Error($"In-game wiki exception when drawing element: {e}"); } } Widgets.EndScrollView(); }
public override void DoWindowContents(Rect inRect) { // Step 1 - Gather and set relevent information. float col1, col2, col3; List <MutationDef> allMutations = DefDatabase <MutationDef> .AllDefs.ToList(); List <BodyPartRecord> mutableParts = pawn.RaceProps.body.AllParts.Where(m => DefDatabase <MutationDef> .AllDefs.SelectMany(n => n.parts).Distinct().Contains(m.def)).ToList(); List <Hediff_AddedMutation> pawnMutations = pawn.health.hediffSet.hediffs.Where(m => m.def.GetType() == typeof(MutationDef)).Cast <Hediff_AddedMutation>().ToList(); // Step 2 - Draw the title of the window. Text.Font = GameFont.Medium; string title = $"{WINDOW_TITLE_LOC_STRING.Translate()} - {pawn.Name.ToStringShort} ({pawn.def.LabelCap})"; float titleHeight = Text.CalcHeight(title, inRect.width); Widgets.Label(new Rect(inRect.x, inRect.y, inRect.width, Text.CalcHeight(title, inRect.width)), title); Text.Font = GameFont.Small; col1 = col2 = col3 = titleHeight; // Step 3 - Determine vewing areas for body part list and description. float drawableWidth = (inRect.width - PREVIEW_SIZE.x - 2 * SPACER_SIZE) / 2; float drawableHeight = inRect.height - titleHeight - Math.Max(APPLY_BUTTON_SIZE.y, Math.Max(RESET_BUTTON_SIZE.y, CANCEL_BUTTON_SIZE.y)) - 2 * SPACER_SIZE; Rect partListOutRect = new Rect(inRect.x, titleHeight, drawableWidth, drawableHeight); Rect partListViewRect = new Rect(partListOutRect.x, partListOutRect.y, partListScrollSize.x, partListScrollSize.y - titleHeight); Rect previewRect = new Rect(inRect.x + SPACER_SIZE + drawableWidth, titleHeight, PREVIEW_SIZE.x, PREVIEW_SIZE.y); Rect descriptionOutRect = new Rect(inRect.x + 2 * SPACER_SIZE + PREVIEW_SIZE.x, titleHeight, drawableWidth, drawableHeight); Rect descriptiontViewRect = new Rect(descriptionOutRect.x, descriptionOutRect.y, descriptionOutRect.width - 16f, descriptionOutRect.height); // Step 4 - Draw the body part list, selection buttons and edit buttons. string editButtonText = EDIT_PARAMS_LOC_STRING.Translate(); float editButtonWidth = Text.CalcSize(editButtonText).x + BUTTON_HORIZONTAL_PADDING; Widgets.BeginScrollView(partListOutRect, ref partListScrollPos, partListViewRect); if (doSymmetry) { List <BodyPartDef> uniqueMutablePartDefs = mutableParts.Select(m => m.def).Distinct().ToList(); foreach (BodyPartDef part in uniqueMutablePartDefs) { List <Hediff_AddedMutation> mutationsOnPart = pawnMutations.Where(m => m.Part.def == part).ToList(); string text = part.LabelCap; float textHeight = Text.CalcHeight(text, partListViewRect.width); Widgets.Label(new Rect(0f, col1, partListViewRect.width, textHeight), text); col1 += textHeight; foreach (MutationLayer layer in Enum.GetValues(typeof(MutationLayer))) { List <MutationDef> applicableMutations = allMutations.Where(m => m.parts.Contains(part) && m.comps.Find(n => n.GetType() == typeof(RemoveFromPartCompProperties)).ChangeType <RemoveFromPartCompProperties>().layer == layer).ToList(); if (!applicableMutations.NullOrEmpty()) { List <Hediff_AddedMutation> mutationsOnLayer = mutationsOnPart.Where(m => m.TryGetComp <RemoveFromPartComp>().Layer == layer).ToList(); string buttonText = $"{layer}: {(mutationsOnLayer.NullOrEmpty() ? NO_MUTATIONS_LOC_STRING.Translate().ToString() : string.Join(", ", mutationsOnLayer.Select(m => m.LabelCap).Distinct()))}"; float buttonHeight = Text.CalcHeight(buttonText, partListViewRect.width); if (Widgets.ButtonText(new Rect(0f, col1, partListViewRect.width - editButtonWidth, buttonHeight), buttonText)) { List <FloatMenuOption> options = new List <FloatMenuOption>(); Action removeAction = delegate() { if (!mutationsOnLayer.NullOrEmpty()) { foreach (Hediff_AddedMutation hediff in mutationsOnLayer) { pawn.health.RemoveHediff(hediff); } } forceRecachePreview = true; }; options.Add(new FloatMenuOption(NO_MUTATIONS_LOC_STRING.Translate(), removeAction)); foreach (MutationDef mutationDef in applicableMutations) { Action action = delegate() { if (!mutationsOnLayer.NullOrEmpty()) { foreach (Hediff_AddedMutation hediff in mutationsOnLayer) { pawn.health.RemoveHediff(hediff); } } foreach (BodyPartRecord bpr in pawn.RaceProps.body.AllParts.Where(m => m.def == part)) { MutationUtilities.AddMutation(pawn, mutationDef, bpr); } forceRecachePreview = true; }; options.Add(new FloatMenuOption(mutationDef.LabelCap, action)); } Find.WindowStack.Add(new FloatMenu(options)); } if (Widgets.ButtonText(new Rect(partListViewRect.width - editButtonWidth, col1, editButtonWidth, buttonHeight), editButtonText)) { // Edit the paramaters of the relevant mutations, such as current stage, if it's halted, etc. (Check for full list of what can be modified later) } col1 += buttonHeight; } } } } else { foreach (BodyPartRecord part in mutableParts) { string text = part.LabelCap; float textHeight = Text.CalcHeight(text, partListViewRect.width); Widgets.Label(new Rect(0f, col1, partListViewRect.width, textHeight), text); col1 += textHeight; foreach (MutationLayer layer in Enum.GetValues(typeof(MutationLayer))) { List <MutationDef> applicableMutations = allMutations.Where(m => m.parts.Contains(part.def) && m.comps.Find(n => n.GetType() == typeof(RemoveFromPartCompProperties)).ChangeType <RemoveFromPartCompProperties>().layer == layer).ToList(); if (!applicableMutations.NullOrEmpty()) { Hediff_AddedMutation mutationOnPartAndLayer = pawnMutations.Find(m => m.TryGetComp <Hediffs.RemoveFromPartComp>().Layer == layer && m.Part == part); string buttonText = $"{layer}: {(mutationOnPartAndLayer == null ? NO_MUTATIONS_LOC_STRING.Translate().ToString() : mutationOnPartAndLayer.LabelCap)}"; float buttonHeight = Text.CalcHeight(buttonText, partListViewRect.width); if (Widgets.ButtonText(new Rect(0f, col1, partListViewRect.width - editButtonWidth, buttonHeight), buttonText)) { List <FloatMenuOption> options = new List <FloatMenuOption>(); Action removeAction = delegate() { if (mutationOnPartAndLayer != null) { pawn.health.RemoveHediff(mutationOnPartAndLayer); } forceRecachePreview = true; }; options.Add(new FloatMenuOption(NO_MUTATIONS_LOC_STRING.Translate(), removeAction)); foreach (MutationDef mutationDef in applicableMutations) { Action action = delegate() { if (mutationOnPartAndLayer != null) { pawn.health.RemoveHediff(mutationOnPartAndLayer); } MutationUtilities.AddMutation(pawn, mutationDef, part); forceRecachePreview = true; }; options.Add(new FloatMenuOption(mutationDef.LabelCap, action)); } Find.WindowStack.Add(new FloatMenu(options)); } if (Widgets.ButtonText(new Rect(partListViewRect.width - editButtonWidth, col1, editButtonWidth, buttonHeight), editButtonText)) { // Edit the paramaters of the mutation on the current part and layer, such as its current stage, if it's halted, etc. (Check for full list of what can be modified later) } col1 += buttonHeight; } } } } if (Event.current.type == EventType.Layout) { partListScrollSize.x = partListOutRect.width - 16f; partListScrollSize.y = col1; } Widgets.EndScrollView(); // Step 5 - Draw the preview area then rotation and clothes buttons then symmetry toggle. if (forceRecachePreview || previewImage == null) { setPawnPreview(); } GUI.DrawTexture(previewRect, previewImage); col2 += previewRect.height; float rotCWHorPos = previewRect.x + previewRect.width / 2 - TOGGLE_CLOTHES_BUTTON_SIZE.x / 2 - ROTATE_CW_BUTTON_SIZE.x - SPACER_SIZE; float toggleClothingHorPos = previewRect.x + previewRect.width / 2 - TOGGLE_CLOTHES_BUTTON_SIZE.x / 2; float rotCCWHorPos = previewRect.x + previewRect.width / 2 + TOGGLE_CLOTHES_BUTTON_SIZE.x / 2 + SPACER_SIZE; col2 += SPACER_SIZE; if (Widgets.ButtonImageFitted(new Rect(rotCWHorPos, col2, ROTATE_CW_BUTTON_SIZE.x, ROTATE_CW_BUTTON_SIZE.y), ButtonTexturesPM.rotCW, Color.white, Color.blue)) { previewRot.Rotate(RotationDirection.Clockwise); SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(); forceRecachePreview = true; } if (Widgets.ButtonImageFitted(new Rect(toggleClothingHorPos, col2, TOGGLE_CLOTHES_BUTTON_SIZE.x, TOGGLE_CLOTHES_BUTTON_SIZE.y), ButtonTexturesPM.toggleClothes, Color.white, Color.blue)) { toggleClothesEnabled = !toggleClothesEnabled; (toggleClothesEnabled ? SoundDefOf.Checkbox_TurnedOn : SoundDefOf.Checkbox_TurnedOff).PlayOneShotOnCamera(); forceRecachePreview = true; } if (Widgets.ButtonImageFitted(new Rect(rotCCWHorPos, col2, ROTATE_CCW_BUTTON_SIZE.x, ROTATE_CCW_BUTTON_SIZE.y), ButtonTexturesPM.rotCCW, Color.white, Color.blue)) { previewRot.Rotate(RotationDirection.Counterclockwise); SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(); forceRecachePreview = true; } col2 += Math.Max(TOGGLE_CLOTHES_BUTTON_SIZE.y, Math.Max(ROTATE_CW_BUTTON_SIZE.y, ROTATE_CCW_BUTTON_SIZE.y)); string toggleText = DO_SYMMETRY_LOC_STRING.Translate(); float toggleTextHeight = Text.CalcHeight(toggleText, PREVIEW_SIZE.x); Widgets.CheckboxLabeled(new Rect(inRect.x + SPACER_SIZE + drawableWidth, col2, PREVIEW_SIZE.x, toggleTextHeight), DO_SYMMETRY_LOC_STRING.Translate(), ref doSymmetry); col2 += toggleTextHeight; // Step 6 - Draw description box. // Step 7 - Draw the apply, reset and cancel buttons. float buttonVertPos = titleHeight + drawableHeight + SPACER_SIZE; float applyHorPos = inRect.width / 2 - APPLY_BUTTON_SIZE.x - RESET_BUTTON_SIZE.x / 2 - SPACER_SIZE; float resetHorPos = inRect.width / 2 - RESET_BUTTON_SIZE.x / 2; float cancelHorPos = inRect.width / 2 + RESET_BUTTON_SIZE.x / 2 + SPACER_SIZE; if (Widgets.ButtonText(new Rect(applyHorPos, buttonVertPos, APPLY_BUTTON_SIZE.x, APPLY_BUTTON_SIZE.y), APPLY_BUTTON_LOC_STRING.Translate())) { OnAcceptKeyPressed(); } if (Widgets.ButtonText(new Rect(resetHorPos, buttonVertPos, RESET_BUTTON_SIZE.x, RESET_BUTTON_SIZE.y), RESET_BUTTON_LOC_STRING.Translate())) { SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null); ResetPawnHealth(); forceRecachePreview = true; } if (Widgets.ButtonText(new Rect(cancelHorPos, buttonVertPos, CANCEL_BUTTON_SIZE.x, CANCEL_BUTTON_SIZE.y), CANCEL_BUTTON_LOC_STRING.Translate())) { OnCancelKeyPressed(); } }
private static void DrawSettings(Panel_Graph instance, ref Rect position) { void CheckNewRow(ref Rect box, ref Rect position) { if (box.xMax > position.xMax) { position.AdjustVerticallyBy(box.height); box.y += box.height; box.x = position.x; } } var currentHeight = 32; var box = position.TopPartPixels(currentHeight).LeftPartPixels(20f); position.AdjustVerticallyBy(currentHeight); Text.Anchor = TextAnchor.MiddleCenter; if (Widgets.ButtonImageFitted(box, Textures.Gear)) { doSettings = !doSettings; } box.ShiftX(5); if (Widgets.ButtonImageFitted(box, TexButton.SpeedButtonTextures[Analyzer.CurrentlyPaused ? 1 : 0])) { Analyzer.CurrentlyPaused = !Analyzer.CurrentlyPaused; GUIController.CurrentEntry.SetActive(!Analyzer.CurrentlyPaused); } box.ShiftX(5); var str = "Times"; box.width = 20 + str.GetWidthCached(); instance.times.visible = ToggleColCombo(box, str, instance.times.visible, Settings.timeColour, () => Settings.timeColour = colourPicker.CurrentCol); box.ShiftX(5); str = "Calls"; box.width = 20 + str.GetWidthCached(); instance.calls.visible = ToggleColCombo(box, str, instance.calls.visible, Settings.callsColour, () => Settings.callsColour = colourPicker.CurrentCol); box.ShiftX(5); str = "Background"; box.width = 20 + str.GetWidthCached(); ToggleColCombo(box, str, true, Settings.GraphCol, () => Settings.GraphCol = colourPicker.CurrentCol); box.ShiftX(5); void jammydodger(ref Rect p, string s, ref bool r, string h) { box.width = 20 + s.GetWidthCached(); CheckNewRow(ref box, ref p); r = DrawButton(box, s, r); if (h != null && Mouse.IsOver(box)) { TooltipHandler.TipRegion(box, h); } box.ShiftX(5); } jammydodger(ref position, "Axis", ref GraphSettings.showAxis, null); jammydodger(ref position, "Grid", ref GraphSettings.showGrid, "Grid will only show when the axis is also active"); jammydodger(ref position, "Max", ref GraphSettings.showMax, null); Text.Anchor = TextAnchor.UpperLeft; box.width = 100; CheckNewRow(ref box, ref position); instance.entryCount = (int)Widgets.HorizontalSlider(box.BottomPartPixels(30f), instance.entryCount, 10, 2000, true, string.Intern($"{instance.entryCount} Entries")); }
public override void DoWindowContents(Rect inRect) { var innerRect = inRect; innerRect.y += 8f; innerRect.height -= 16f; GizmoListRect = innerRect.AtZero(); GizmoListRect.y += scrollPosition.y; // Scrollable List var scrollRect = new Rect(innerRect); scrollRect.y += 3f; scrollRect.x += 8f; scrollRect.height -= 49f; scrollRect.width -= 16f; var viewRect = new Rect(0.0f, 0.0f, scrollRect.width, RecipesScrollHeight); Widgets.BeginScrollView(scrollRect, ref scrollPosition, viewRect); GUI.BeginGroup(viewRect); for (var i = 0; i < thingList.Count; i++) { var viewElement = new Rect(0.0f, boxHeight * i, inRect.width, boxHeight); if (!viewElement.Overlaps(GizmoListRect)) { continue; } if (rows[i] == null) { try { var index = pawn.Map.cellIndices.CellToIndex(cpos.ToIntVec3()); var listArray = (List <Thing>[])thingListTG.GetValue(pawn.Map.thingGrid); var origList = new List <Thing>(listArray[index]); listArray[index] = new List <Thing> { thingList[i] }; rows[i] = new DSGUI_ListItem(pawn, thingList[i], cpos, boxHeight); listArray[index] = origList; } catch (Exception ex) { var rect5 = scrollRect.ContractedBy(-4f); Widgets.Label(rect5, "Oops, something went wrong!"); Log.Warning(ex.ToString()); } } if (searchString.NullOrEmpty()) { rows[i].DoDraw(viewRect, i); } else { if (!(rows[i].label.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0)) { continue; } rows[i].DoDraw(viewRect, i); } } RecipesScrollHeight = boxHeight * thingList.Count; GUI.EndGroup(); Widgets.EndScrollView(); Widgets.DrawBox(scrollRect); // Search var searchRect = new Rect(innerRect); searchRect.y += scrollRect.height + 16f; searchRect.x += 8f; searchRect.height = 28f; searchRect.width -= 40f + searchClearPadding; // 16f for padding of 8f on each side + 28f for the clear button DSGUI.Elements.InputField("Search", searchRect, ref searchString); searchRect.x = searchRect.width + 6f + searchClearPadding; searchRect.width = 28f; Text.Anchor = TextAnchor.MiddleLeft; if (Widgets.ButtonImageFitted(searchRect, Widgets.CheckboxOffTex)) { searchString = ""; } Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.UpperLeft; }
public override void DoWindowContents(Rect inRect) { GUI.BeginGroup(inRect); #region Appearance Tab Widgets.DrawMenuSection(UIConstants.rtAppearanceTab); GUI.BeginGroup(UIConstants.rtAppearanceTab.ContractedBy(UIConstants.groupMargin)); { Text.Font = GameFont.Medium; Widgets.Label(new Rect(0f, 0f, 200f, 40f), "PN_BILL_WINDOW_TAB_APPEARANCE_TITLE".Translate()); Text.Font = GameFont.Small; Rect innerRect = UIConstants.rtAppearanceTab.ContractedBy(UIConstants.groupMargin); TooltipHandler.TipRegion(new Rect(0f, 40f, innerRect.width, innerRect.height - 40f), "PN_BILL_WINDOW_TAB_APPEARANCE_TOOLTIP".Translate()); GUI.BeginGroup(new Rect(0f, 40f, innerRect.width, innerRect.height - 40f)); Rect[] rectPortraits = new Rect[] { new Rect(UIConstants.distanceAppearanceGap, 0f, UIConstants.pawnPortraitSize.x, UIConstants.pawnPortraitSize.y), new Rect(UIConstants.distanceAppearanceGap, UIConstants.pawnPortraitSize.y + 12f, UIConstants.pawnPortraitSize.x, UIConstants.pawnPortraitSize.y), new Rect(innerRect.width - UIConstants.pawnPortraitSize.x - UIConstants.distanceAppearanceGap, 0f, UIConstants.pawnPortraitSize.x, UIConstants.pawnPortraitSize.y), new Rect(innerRect.width - UIConstants.pawnPortraitSize.x - UIConstants.distanceAppearanceGap, UIConstants.pawnPortraitSize.y + 12f, UIConstants.pawnPortraitSize.x, UIConstants.pawnPortraitSize.y), }; for (int i = 0; i < rectPortraits.Length; ++i) { if (i < _samplePawnDrawers.Length) { _samplePawnDrawers[i].Draw(rectPortraits[i]); } } GUI.EndGroup(); Rect rect = new Rect(10f, 130f, 230f, 220f); if (Widgets.ButtonText(new Rect(150f, 324f, 100f, 36f), "Randomize".Translate())) { SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(); for (int i = 0; i < _samplePawnDrawers.Length; ++i) { _samplePawnDrawers[i].RerollAndUpdateTexture(); } } } GUI.EndGroup(); #endregion #region Specialization Tab Widgets.DrawMenuSection(UIConstants.rtSpecializationTab); GUI.BeginGroup(UIConstants.rtSpecializationTab.ContractedBy(UIConstants.groupMargin)); { Text.Font = GameFont.Medium; Widgets.Label(new Rect(0f, 0f, 200f, 40f), "PN_BILL_WINDOW_TAB_SPECIALIZATION_TITLE".Translate()); Text.Font = GameFont.Small; // Combat float combatButtonLeft = 0f; if (Widgets.ButtonImageFitted(new Rect(combatButtonLeft, 35f, UIConstants.specializationButtonSize, UIConstants.specializationButtonSize), AutomataRaceDefOf.PN_Specialization_Combat.UIIcon)) { SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(); billWorker.selectedSpecialization = AutomataRaceDefOf.PN_Specialization_Combat; } TooltipHandler.TipRegion(new Rect(combatButtonLeft, 35f, UIConstants.specializationButtonSize, UIConstants.specializationButtonSize), AutomataRaceDefOf.PN_Specialization_Combat.tooltip); if (billWorker.selectedSpecialization == AutomataRaceDefOf.PN_Specialization_Combat) { GUI.DrawTexture(new Rect(combatButtonLeft + 26f, 81f, 32f, 32f), Widgets.CheckboxOnTex); } // Engineer float engineerButtonLeft = combatButtonLeft + UIConstants.specializationButtonSize + UIConstants.specializationButtonGap; if (Widgets.ButtonImageFitted(new Rect(engineerButtonLeft, 35f, UIConstants.specializationButtonSize, UIConstants.specializationButtonSize), AutomataRaceDefOf.PN_Specialization_Engineer.UIIcon)) { SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(); billWorker.selectedSpecialization = AutomataRaceDefOf.PN_Specialization_Engineer; } TooltipHandler.TipRegion(new Rect(engineerButtonLeft, 35f, UIConstants.specializationButtonSize, UIConstants.specializationButtonSize), AutomataRaceDefOf.PN_Specialization_Engineer.tooltip); if (billWorker.selectedSpecialization == AutomataRaceDefOf.PN_Specialization_Engineer) { GUI.DrawTexture(new Rect(engineerButtonLeft + 26f, 81f, 32f, 32f), Widgets.CheckboxOnTex); } // Domestic float domesticButtonLeft = engineerButtonLeft + UIConstants.specializationButtonSize + UIConstants.specializationButtonGap; if (Widgets.ButtonImageFitted(new Rect(domesticButtonLeft, 35f, UIConstants.specializationButtonSize, UIConstants.specializationButtonSize), AutomataRaceDefOf.PN_Specialization_Domestic.UIIcon)) { SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(); billWorker.selectedSpecialization = AutomataRaceDefOf.PN_Specialization_Domestic; } TooltipHandler.TipRegion(new Rect(domesticButtonLeft, 35f, UIConstants.specializationButtonSize, UIConstants.specializationButtonSize), AutomataRaceDefOf.PN_Specialization_Domestic.tooltip); if (billWorker.selectedSpecialization == AutomataRaceDefOf.PN_Specialization_Domestic) { GUI.DrawTexture(new Rect(domesticButtonLeft + 26f, 81f, 32f, 32f), Widgets.CheckboxOnTex); } } GUI.EndGroup(); #endregion #region Material Tab Widgets.DrawMenuSection(UIConstants.rtMaterialTab); GUI.BeginGroup(UIConstants.rtMaterialTab.ContractedBy(UIConstants.groupMargin)); { Text.Font = GameFont.Medium; Widgets.Label(new Rect(0f, 0f, 200f, 40f), "PN_BILL_WINDOW_TAB_MATERIAL_TITLE".Translate()); Text.Font = GameFont.Small; TooltipHandler.TipRegion(new Rect(0f, UIConstants.baseMaterialY, UIConstants.rtMaterialTab.width, 40f), "PN_BILL_WINDOW_TAB_MATERIAL_BASE_MATERIAL_TOOLTIP".Translate()); GUI.DrawTexture(new Rect(5f, UIConstants.baseMaterialY, 32f, 32f), billWorker.baseMaterial.uiIcon); Widgets.Label(new Rect(47f, UIConstants.baseMaterialY + 5f, 50f, 30f), $"x{billWorker.baseMaterialCount * (billWorker.baseMaterial.smallVolume ? 10 : 1)}"); if (Widgets.ButtonText(new Rect(130f, UIConstants.baseMaterialY - 3f, 125f, 35f), billWorker.baseMaterial.LabelCap)) { Find.WindowStack.Add(new FloatMenu(_baseMaterialThings.Select(x => new FloatMenuOption(x.LabelCap, () => { billWorker.baseMaterial = x; })).ToList())); } TooltipHandler.TipRegion(new Rect(0f, UIConstants.componentIndustrialY, UIConstants.rtMaterialTab.width, 40f), ThingDefOf.ComponentIndustrial.LabelCap + "\n\n" + "PN_BILL_WINDOW_TAB_MATERIAL_COMPONENT_TOOLTIP".Translate()); GUI.DrawTexture(new Rect(5f, UIConstants.componentIndustrialY, 32f, 32f), ThingDefOf.ComponentIndustrial.uiIcon); Widgets.Label(new Rect(47f, UIConstants.componentIndustrialY + 3f, 50f, 30f), $"x{billWorker.ComponentIndustrialCount}"); billWorker.ComponentIndustrialCount = (int)Widgets.HorizontalSlider(new Rect(110f, UIConstants.componentIndustrialY, 150f, 38f), billWorker.ComponentIndustrialCount, 0f, 20f, middleAlignment: true, leftAlignedLabel: "0", rightAlignedLabel: "20", roundTo: 0); TooltipHandler.TipRegion(new Rect(0f, UIConstants.componentSpacerY, UIConstants.rtMaterialTab.width, 40f), ThingDefOf.ComponentSpacer.LabelCap + "\n\n" + "PN_BILL_WINDOW_TAB_MATERIAL_COMPONENT_TOOLTIP".Translate()); GUI.DrawTexture(new Rect(5f, UIConstants.componentSpacerY, 32f, 32f), ThingDefOf.ComponentSpacer.uiIcon); Widgets.Label(new Rect(47f, UIConstants.componentSpacerY + 3f, 50f, 30f), $"x{billWorker.ComponentSpacerCount}"); billWorker.ComponentSpacerCount = (int)Widgets.HorizontalSlider(new Rect(110f, UIConstants.componentSpacerY, 150f, 38f), billWorker.ComponentSpacerCount, 0f, 20f, middleAlignment: true, leftAlignedLabel: "0", rightAlignedLabel: "20", roundTo: 0); TooltipHandler.TipRegion(new Rect(0f, UIConstants.aiPersonaCoreY, UIConstants.rtMaterialTab.width, 40f), ThingDefOf.AIPersonaCore.LabelCap + "\n\n" + "PN_BILL_WINDOW_TAB_MATERIAL_AICORE_TOOLTIP".Translate()); GUI.DrawTexture(new Rect(5f, UIConstants.aiPersonaCoreY, 32f, 32f), ThingDefOf.AIPersonaCore.uiIcon); Widgets.Label(new Rect(47f, UIConstants.aiPersonaCoreY + 3f, 50f, 30f), $"x{(billWorker.useAIPersonaCore ? 1 : 0)}"); Widgets.Checkbox(new Vector2(170f, UIConstants.aiPersonaCoreY + 2.5f), ref billWorker.useAIPersonaCore); } GUI.EndGroup(); #endregion #region Expected Tab GUI.BeginGroup(UIConstants.rtExpectedTab); { Text.Font = GameFont.Medium; Widgets.Label(new Rect(10f, 10f, 200f, 40f), "PN_BILL_WINDOW_TAB_SUMMARY_TITLE".Translate()); Text.Font = GameFont.Small; Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.MiddleRight; Widgets.Label(new Rect(UIConstants.rtExpectedTab.width - 200f, 0f, 200f, 40f), $"{"PN_BILL_WINDOW_TAB_SUMMARY_REQUIRED_SKILL".Translate()}: { AutomataBillService.CalcCraftingSkillRequirement(billWorker.recipe, billWorker.Score) }"); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; Rect innerRect = new Rect(5f, 45f, UIConstants.rtExpectedTab.width - 10f, UIConstants.rtExpectedTab.height - 45f); GUI.BeginGroup(innerRect); { float width = innerRect.width / 7f; Widgets.DrawLineHorizontal(0f, 30f, innerRect.width); Dictionary <QualityCategory, float> probability = AutomataQualityService.GetProductProbability(billWorker.Score); for (byte i = 0; i < 7; ++i) { DrawQualityProbabilitySection(probability, (QualityCategory)i, new Rect(i * width, 0f, width, innerRect.height)); } } GUI.EndGroup(); } GUI.EndGroup(); #endregion #region Buttons Tab GUI.BeginGroup(UIConstants.rtButtonTab); if (Widgets.ButtonText(new Rect(150f, 0f, 110f, 40f), "PN_BILL_WINDOW_TAB_SUMMARY_BTN_CANCEL".Translate())) { Close(true); } Color defaultColor = GUI.color; GUI.color = CheckAllRequirements() ? defaultColor : Color.grey; if (Widgets.ButtonText(new Rect(312f, 0f, 110f, 40f), "PN_BILL_WINDOW_TAB_SUMMARY_BTN_ADD_BILL".Translate())) { TryAddBill(); } GUI.color = defaultColor; GUI.EndGroup(); #endregion GUI.EndGroup(); }
private void DrawDefList(Rect r, IReadOnlyList <ThingDef> defList) { var itms = curTag.requiredItems.Select(it => it.Def).ToHashSet(); List <ThingDef> defs = defList.Where(t => !itms.Contains(t)).ToList(); if (defFilter != string.Empty) { var filter = defFilter.ToLower(); var acceptedLayers = DefDatabase <ApparelLayerDef> .AllDefsListForReading .Where(l => l.LabelCap.ToString().ToLower().Contains(filter)); defs.RemoveAll(td => { if (td.IsApparel) { if (td.apparel.layers.Intersect(acceptedLayers).Any()) { return(false); } } return(!td.LabelCap.ToString().ToLowerInvariant().Contains(filter)); }); } ModGUIUtility.InputField(r.PopTopPartPixels(ModGUIUtility.SPACED_HEIGHT).ContractedBy(2f), "Def List Filter", ref defFilter); var viewRect = new Rect(r.x, r.y, r.width - 16f, (defs.Count * ModGUIUtility.DEFAULT_HEIGHT)); Widgets.BeginScrollView(r, ref curScroll, viewRect); GUI.BeginGroup(viewRect); var rect = new Rect(0, 0, viewRect.width, ModGUIUtility.DEFAULT_HEIGHT); var viewFrustum = r.AtZero(); viewFrustum.y += curScroll.y; for (int i = 0; i < defs.Count; i++) { if (!rect.Overlaps(viewFrustum)) { rect.y += ModGUIUtility.DEFAULT_HEIGHT; continue; } var descRect = rect.LeftPart(0.85f); var def = defs[i]; Widgets.DefIcon(descRect.LeftPart(.15f), def); Widgets.Label(descRect.RightPart(.85f), def.LabelCap); TooltipHandler.TipRegion(rect, def.DescriptionDetailed); if (Widgets.ButtonInvisible(descRect)) { AddDefToTag(def); } if (Widgets.ButtonImageFitted(rect.RightPart(0.15f).ContractedBy(2f), TexButton.Info)) { var stuff = def.MadeFromStuff ? GenStuff.AllowedStuffsFor(def).First() : null; Thing thing = Utility.MakeThingWithoutID(def, stuff, QualityCategory.Normal); Find.WindowStack.Add(new Dialog_InfoCard(thing)); } if (i % 2 == 0) { Widgets.DrawLightHighlight(rect); } Widgets.DrawHighlightIfMouseover(rect); rect.y += ModGUIUtility.DEFAULT_HEIGHT; } GUI.EndGroup(); Widgets.EndScrollView(); }
/// <summary> /// Does the window contents. /// </summary> /// <param name="inRect">The in rect.</param> public override void DoWindowContents(Rect inRect) { // Draw the window title. Text.Font = GameFont.Medium; string titleLabel = $"{WINDOW_TITLE_LOC_STRING.Translate()} - {pawn.Name.ToStringShort} ({pawn.def.LabelCap})"; float titleHeight = Text.CalcHeight(titleLabel, inRect.width); Rect titleRect = new Rect(inRect.x, inRect.y, inRect.width, titleHeight); Widgets.Label(titleRect, titleLabel); Text.Font = GameFont.Small; // Determine draw areas for parts list and descriptions. float columnWidth = (inRect.width - PREVIEW_SIZE.x) / 2 - SPACER_SIZE; float columnHeight = inRect.height - titleHeight - Math.Max(APPLY_BUTTON_SIZE.y, Math.Max(RESET_BUTTON_SIZE.y, CANCEL_BUTTON_SIZE.y)) - 2 * SPACER_SIZE; // Draw parts list as the left column. This displays all mutable parts and the mutations currently applied to them. Rect partListOutRect = new Rect(inRect.x, titleHeight + SPACER_SIZE, columnWidth, columnHeight); Rect partListViewRect = new Rect(partListOutRect.x, partListOutRect.y, partListScrollSize.x, partListScrollSize.y); DrawPartsList(partListOutRect, partListViewRect); // Draw the preview area, mode toggle buttons, body/crown type selection and aspect selection in the middle column (Might need to outsource these to a helper function). // First the preview... float curY = titleHeight + SPACER_SIZE; Rect previewRect = new Rect(columnWidth + SPACER_SIZE, curY, PREVIEW_SIZE.x, PREVIEW_SIZE.y); if (recachePreview || previewImage == null) { SetPawnPreview(); } GUI.DrawTexture(previewRect, previewImage); curY += previewRect.height; // Then the preview buttons... float rotCWHorPos = previewRect.x + previewRect.width / 2 - TOGGLE_CLOTHES_BUTTON_SIZE.x / 2 - ROTATE_CW_BUTTON_SIZE.x - SPACER_SIZE; float toggleClothingHorPos = previewRect.x + previewRect.width / 2 - TOGGLE_CLOTHES_BUTTON_SIZE.x / 2; float rotCCWHorPos = previewRect.x + previewRect.width / 2 + TOGGLE_CLOTHES_BUTTON_SIZE.x / 2 + SPACER_SIZE; Rect rotCWRect = new Rect(rotCWHorPos, curY, ROTATE_CW_BUTTON_SIZE.x, ROTATE_CW_BUTTON_SIZE.y); Rect toggleClothesRect = new Rect(toggleClothingHorPos, curY, TOGGLE_CLOTHES_BUTTON_SIZE.x, TOGGLE_CLOTHES_BUTTON_SIZE.y); Rect rotCCWRect = new Rect(rotCCWHorPos, curY, ROTATE_CCW_BUTTON_SIZE.x, ROTATE_CCW_BUTTON_SIZE.y); curY += SPACER_SIZE; if (Widgets.ButtonImageFitted(rotCWRect, ButtonTexturesPM.rotCW, Color.white, GenUI.MouseoverColor)) { previewRot.Rotate(RotationDirection.Clockwise); SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(); recachePreview = true; } TooltipHandler.TipRegionByKey(rotCWRect, ROTATE_CW_LOC_STRING); if (Widgets.ButtonImageFitted(toggleClothesRect, ButtonTexturesPM.toggleClothes, Color.white, GenUI.MouseoverColor)) { toggleClothesEnabled = !toggleClothesEnabled; (toggleClothesEnabled ? SoundDefOf.Checkbox_TurnedOn : SoundDefOf.Checkbox_TurnedOff).PlayOneShotOnCamera(); recachePreview = true; } TooltipHandler.TipRegionByKey(toggleClothesRect, TOGGLE_CLOTHES_LOC_STRING); if (Widgets.ButtonImageFitted(rotCCWRect, ButtonTexturesPM.rotCCW, Color.white, GenUI.MouseoverColor)) { previewRot.Rotate(RotationDirection.Counterclockwise); SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(); recachePreview = true; } TooltipHandler.TipRegionByKey(rotCCWRect, ROTATE_CCW_LOC_STRING); curY += Math.Max(TOGGLE_CLOTHES_BUTTON_SIZE.y, Math.Max(ROTATE_CW_BUTTON_SIZE.y, ROTATE_CCW_BUTTON_SIZE.y)); // Then the crown and body type selectors... Rect crownLabelRect = new Rect(previewRect.x, curY, previewRect.width / 3, Text.CalcHeight(CROWN_LABEL_LOC_STRING.Translate(), previewRect.width / 3)); Rect crownButtonRect = new Rect(previewRect.x + previewRect.width / 3, curY, previewRect.width * 2 / 3, Text.CalcHeight(pawn.GetComp <AlienPartGenerator.AlienComp>().crownType.Replace('_', ' '), previewRect.width * 2 / 3)); Widgets.Label(crownLabelRect, CROWN_LABEL_LOC_STRING.Translate()); if (Widgets.ButtonText(crownButtonRect, pawn.GetComp <AlienPartGenerator.AlienComp>().crownType.Replace('_', ' '))) { List <FloatMenuOption> options = new List <FloatMenuOption>(); ThingDef_AlienRace pawnDef = pawn.def as ThingDef_AlienRace; foreach (string crownType in pawnDef.alienRace.generalSettings.alienPartGenerator.aliencrowntypes) { void changeHeadType() { pawn.GetComp <AlienPartGenerator.AlienComp>().crownType = crownType; recachePreview = true; } options.Add(new FloatMenuOption(crownType.Replace('_', ' '), changeHeadType)); } Find.WindowStack.Add(new FloatMenu(options)); } curY += Math.Max(crownLabelRect.height, crownButtonRect.height); Rect bodyLabelRect = new Rect(previewRect.x, curY, previewRect.width / 3, Text.CalcHeight(BODY_LABEL_LOC_STRING.Translate(), previewRect.width / 3)); Rect bodyButtonRect = new Rect(previewRect.x + previewRect.width / 3, curY, previewRect.width * 2 / 3, Text.CalcHeight(pawn.story.bodyType.defName, previewRect.width * 2 / 3)); Widgets.Label(bodyLabelRect, BODY_LABEL_LOC_STRING.Translate()); if (Widgets.ButtonText(bodyButtonRect, pawn.story.bodyType.defName)) { List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (BodyTypeDef bodyType in DefDatabase <BodyTypeDef> .AllDefs) { void changeBodyType() { pawn.story.bodyType = bodyType; recachePreview = true; } options.Add(new FloatMenuOption(bodyType.defName, changeBodyType)); } Find.WindowStack.Add(new FloatMenu(options)); } curY += Math.Max(bodyLabelRect.height, bodyButtonRect.height); // Then the parts list toggles... string skinSyncText = SKIN_SYNC_LOC_STRING.Translate(); Rect skinSyncRect = new Rect(columnWidth + SPACER_SIZE, curY, PREVIEW_SIZE.x, Text.CalcHeight(skinSyncText, PREVIEW_SIZE.x)); Widgets.CheckboxLabeled(skinSyncRect, skinSyncText, ref skinSync); curY += skinSyncRect.height; string symmetryToggleText = DO_SYMMETRY_LOC_STRING.Translate(); Rect symmetryToggleRect = new Rect(columnWidth + SPACER_SIZE, curY, PREVIEW_SIZE.x, Text.CalcHeight(symmetryToggleText, PREVIEW_SIZE.x)); Widgets.CheckboxLabeled(symmetryToggleRect, symmetryToggleText, ref doSymmetry); curY += symmetryToggleRect.height; // Then finally the Aspect selection list. // Remember this needs scrolling, Brennen. // Draw the right column, consisting of the modification summary (top box) and the currently hovered over mutation description (bottom box). DrawDescriptionBoxes(new Rect(inRect.width - columnWidth, titleHeight + SPACER_SIZE, columnWidth, columnHeight)); // Draw the apply, reset and cancel buttons. float buttonVertPos = inRect.height - Math.Max(APPLY_BUTTON_SIZE.y, Math.Max(RESET_BUTTON_SIZE.y, CANCEL_BUTTON_SIZE.y)); float applyHorPos = inRect.width / 2 - APPLY_BUTTON_SIZE.x - RESET_BUTTON_SIZE.x / 2 - SPACER_SIZE; float resetHorPos = inRect.width / 2 - RESET_BUTTON_SIZE.x / 2; float cancelHorPos = inRect.width / 2 + RESET_BUTTON_SIZE.x / 2 + SPACER_SIZE; if (Widgets.ButtonText(new Rect(applyHorPos, buttonVertPos, APPLY_BUTTON_SIZE.x, APPLY_BUTTON_SIZE.y), APPLY_BUTTON_LOC_STRING.Translate())) { OnAcceptKeyPressed(); } if (Widgets.ButtonText(new Rect(resetHorPos, buttonVertPos, RESET_BUTTON_SIZE.x, RESET_BUTTON_SIZE.y), RESET_BUTTON_LOC_STRING.Translate())) { SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null); Reset(); } if (Widgets.ButtonText(new Rect(cancelHorPos, buttonVertPos, CANCEL_BUTTON_SIZE.x, CANCEL_BUTTON_SIZE.y), CANCEL_BUTTON_LOC_STRING.Translate())) { OnCancelKeyPressed(); } }
private void DrawRightRect(Rect rightOutRect) { rightOutRect.yMin += 32f; Widgets.DrawMenuSection(rightOutRect); TabDrawer.DrawTabs(rightOutRect, tabs); if (Prefs.DevMode) { Rect rect = rightOutRect; rect.yMax = rect.yMin + 20f; rect.xMin = rect.xMax - 80f; Rect butRect = rect.RightPartPixels(30f); rect = rect.LeftPartPixels(rect.width - 30f); Widgets.CheckboxLabeled(rect, "Edit", ref editMode); if (Widgets.ButtonImageFitted(butRect, TexButton.Copy)) { StringBuilder stringBuilder = new StringBuilder(); foreach (ResearchProjectDef item in DefDatabase <ResearchProjectDef> .AllDefsListForReading.Where((ResearchProjectDef def) => def.Debug_IsPositionModified())) { stringBuilder.AppendLine(item.defName); stringBuilder.AppendLine(string.Format(" <researchViewX>{0}</researchViewX>", item.ResearchViewX.ToString("F2"))); stringBuilder.AppendLine(string.Format(" <researchViewY>{0}</researchViewY>", item.ResearchViewY.ToString("F2"))); stringBuilder.AppendLine(); } GUIUtility.systemCopyBuffer = stringBuilder.ToString(); Messages.Message("Modified data copied to clipboard.", MessageTypeDefOf.SituationResolved, historical: false); } } else { editMode = false; } bool flag = false; Rect outRect = rightOutRect.ContractedBy(10f); Rect rect2 = new Rect(0f, 0f, rightViewWidth, rightViewHeight); rect2.ContractedBy(10f); rect2.width = rightViewWidth; Rect position = rect2.ContractedBy(10f); Vector2 start = default(Vector2); Vector2 end = default(Vector2); Widgets.ScrollHorizontal(outRect, ref rightScrollPosition, rect2); Widgets.BeginScrollView(outRect, ref rightScrollPosition, rect2); GUI.BeginGroup(position); List <ResearchProjectDef> allDefsListForReading = DefDatabase <ResearchProjectDef> .AllDefsListForReading; for (int i = 0; i < 2; i++) { for (int j = 0; j < allDefsListForReading.Count; j++) { ResearchProjectDef researchProjectDef = allDefsListForReading[j]; if (researchProjectDef.tab != CurTab) { continue; } start.x = PosX(researchProjectDef); start.y = PosY(researchProjectDef) + 25f; for (int k = 0; k < researchProjectDef.prerequisites.CountAllowNull(); k++) { ResearchProjectDef researchProjectDef2 = researchProjectDef.prerequisites[k]; if (researchProjectDef2 == null || researchProjectDef2.tab != CurTab) { continue; } end.x = PosX(researchProjectDef2) + 140f; end.y = PosY(researchProjectDef2) + 25f; if (selectedProject == researchProjectDef || selectedProject == researchProjectDef2) { if (i == 1) { Widgets.DrawLine(start, end, TexUI.HighlightLineResearchColor, 4f); } } else if (i == 0) { Widgets.DrawLine(start, end, TexUI.DefaultLineResearchColor, 2f); } } } } Rect other = new Rect(rightScrollPosition.x, rightScrollPosition.y, outRect.width, outRect.height).ExpandedBy(10f); for (int l = 0; l < allDefsListForReading.Count; l++) { ResearchProjectDef researchProjectDef3 = allDefsListForReading[l]; if (researchProjectDef3.tab != CurTab) { continue; } Rect source = new Rect(PosX(researchProjectDef3), PosY(researchProjectDef3), 140f, 50f); Rect rect3 = new Rect(source); string label = GetLabel(researchProjectDef3); Widgets.LabelCacheHeight(ref rect3, GetLabelWithNewlineCached(label)); if (!rect3.Overlaps(other)) { continue; } Color color = Widgets.NormalOptionColor; Color bgColor = default(Color); Color color2 = default(Color); bool flag2 = !researchProjectDef3.IsFinished && !researchProjectDef3.CanStartNow; if (researchProjectDef3 == Find.ResearchManager.currentProj) { bgColor = TexUI.ActiveResearchColor; } else if (researchProjectDef3.IsFinished) { bgColor = TexUI.FinishedResearchColor; } else if (flag2) { bgColor = TexUI.LockedResearchColor; } else if (researchProjectDef3.CanStartNow) { bgColor = TexUI.AvailResearchColor; } if (editMode && draggingTabs.Contains(researchProjectDef3)) { color2 = Color.yellow; } else if (selectedProject == researchProjectDef3) { bgColor += TexUI.HighlightBgResearchColor; color2 = TexUI.HighlightBorderResearchColor; } else { color2 = TexUI.DefaultBorderResearchColor; } if (flag2) { color = ProjectWithMissingPrerequisiteLabelColor; } if (selectedProject != null) { if ((researchProjectDef3.prerequisites != null && researchProjectDef3.prerequisites.Contains(selectedProject)) || (researchProjectDef3.hiddenPrerequisites != null && researchProjectDef3.hiddenPrerequisites.Contains(selectedProject))) { color2 = TexUI.HighlightLineResearchColor; } if (!researchProjectDef3.IsFinished && ((selectedProject.prerequisites != null && selectedProject.prerequisites.Contains(researchProjectDef3)) || (selectedProject.hiddenPrerequisites != null && selectedProject.hiddenPrerequisites.Contains(researchProjectDef3)))) { color2 = TexUI.DependencyOutlineResearchColor; } } if (requiredByThisFound) { for (int m = 0; m < researchProjectDef3.requiredByThis.CountAllowNull(); m++) { ResearchProjectDef researchProjectDef4 = researchProjectDef3.requiredByThis[m]; if (selectedProject == researchProjectDef4) { color2 = TexUI.HighlightLineResearchColor; } } } Rect rect4 = rect3; Widgets.LabelCacheHeight(ref rect4, " "); if (Widgets.CustomButtonText(ref rect3, "", bgColor, color, color2)) { SoundDefOf.Click.PlayOneShotOnCamera(); selectedProject = researchProjectDef3; } rect4.y = rect3.y + rect3.height - rect4.height; Rect rect5 = rect4; rect5.x += 10f; rect5.width = rect5.width / 2f - 10f; Rect rect6 = rect5; rect6.x += rect5.width; TextAnchor anchor = Text.Anchor; Color color3 = GUI.color; GUI.color = color; Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(rect3, label); GUI.color = color; Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rect5, researchProjectDef3.CostApparent.ToString()); if (researchProjectDef3.techprintCount > 0) { GUI.color = (researchProjectDef3.TechprintRequirementMet ? FulfilledPrerequisiteColor : MissingPrerequisiteColor); Text.Anchor = TextAnchor.MiddleRight; Widgets.Label(rect6, GetTechprintsInfoCached(researchProjectDef3.TechprintsApplied, researchProjectDef3.techprintCount)); } GUI.color = color3; Text.Anchor = anchor; if (!editMode || !Mouse.IsOver(rect3) || !Input.GetMouseButtonDown(0)) { continue; } flag = true; if (Input.GetKey(KeyCode.LeftShift)) { if (!draggingTabs.Contains(researchProjectDef3)) { draggingTabs.Add(researchProjectDef3); } } else if (!Input.GetKey(KeyCode.LeftControl) && !draggingTabs.Contains(researchProjectDef3)) { draggingTabs.Clear(); draggingTabs.Add(researchProjectDef3); } if (Input.GetKey(KeyCode.LeftControl) && draggingTabs.Contains(researchProjectDef3)) { draggingTabs.Remove(researchProjectDef3); } } GUI.EndGroup(); Widgets.EndScrollView(); if (!editMode) { return; } if (!flag && Input.GetMouseButtonDown(0)) { draggingTabs.Clear(); } if (draggingTabs.NullOrEmpty()) { return; } if (Input.GetMouseButtonUp(0)) { for (int n = 0; n < draggingTabs.Count; n++) { draggingTabs[n].Debug_SnapPositionData(); } } else if (Input.GetMouseButton(0) && !Input.GetMouseButtonDown(0) && Event.current.type == EventType.Layout) { for (int num = 0; num < draggingTabs.Count; num++) { draggingTabs[num].Debug_ApplyPositionDelta(new Vector2(PixelsToCoordX(Event.current.delta.x), PixelsToCoordY(Event.current.delta.y))); } } }
public Rect DoInterface(float x, float y, float width, int index) { Rect rect = new Rect(x, y, width, 53f); float num = 0f; if (!this.StatusString.NullOrEmpty()) { num = Mathf.Max(17f, this.StatusLineMinHeight); } rect.height += num; Color white = Color.white; if (!this.ShouldDoNow()) { white = new Color(1f, 0.7f, 0.7f, 0.7f); } GUI.color = white; Text.Font = GameFont.Small; if (index % 2 == 0) { Widgets.DrawAltRect(rect); } GUI.BeginGroup(rect); Rect rect2 = new Rect(0f, 0f, 24f, 24f); if (this.billStack.IndexOf(this) > 0) { if (Widgets.ButtonImage(rect2, TexButton.ReorderUp, white)) { this.billStack.Reorder(this, -1); SoundDefOf.Tick_High.PlayOneShotOnCamera(null); } TooltipHandler.TipRegion(rect2, "ReorderBillUpTip".Translate()); } if (this.billStack.IndexOf(this) < this.billStack.Count - 1) { Rect rect3 = new Rect(0f, 24f, 24f, 24f); if (Widgets.ButtonImage(rect3, TexButton.ReorderDown, white)) { this.billStack.Reorder(this, 1); SoundDefOf.Tick_Low.PlayOneShotOnCamera(null); } TooltipHandler.TipRegion(rect3, "ReorderBillDownTip".Translate()); } Rect rect4 = new Rect(28f, 0f, rect.width - 48f - 20f, rect.height + 5f); Widgets.Label(rect4, this.LabelCap); this.DoConfigInterface(rect.AtZero(), white); Rect rect5 = new Rect(rect.width - 24f, 0f, 24f, 24f); if (Widgets.ButtonImage(rect5, TexButton.DeleteX, white, white * GenUI.SubtleMouseoverColor)) { this.billStack.Delete(this); SoundDefOf.Click.PlayOneShotOnCamera(null); } TooltipHandler.TipRegion(rect5, "DeleteBillTip".Translate()); Rect rect7; if (this.CanCopy) { Rect rect6 = new Rect(rect5); rect6.x -= rect6.width + 4f; if (Widgets.ButtonImageFitted(rect6, TexButton.Copy, white)) { BillUtility.Clipboard = this.Clone(); SoundDefOf.Tick_High.PlayOneShotOnCamera(null); } TooltipHandler.TipRegion(rect6, "CopyBillTip".Translate()); rect7 = new Rect(rect6); } else { rect7 = new Rect(rect5); } rect7.x -= rect7.width + 4f; if (Widgets.ButtonImage(rect7, TexButton.Suspend, white)) { this.suspended = !this.suspended; SoundDefOf.Click.PlayOneShotOnCamera(null); } TooltipHandler.TipRegion(rect7, "SuspendBillTip".Translate()); if (!this.StatusString.NullOrEmpty()) { Text.Font = GameFont.Tiny; Rect rect8 = new Rect(24f, rect.height - num, rect.width - 24f, num); Widgets.Label(rect8, this.StatusString); this.DoStatusLineInterface(rect8); } GUI.EndGroup(); if (this.suspended) { Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Rect rect9 = new Rect(rect.x + rect.width / 2f - 70f, rect.y + rect.height / 2f - 20f, 140f, 40f); GUI.DrawTexture(rect9, TexUI.GrayTextBG); Widgets.Label(rect9, "SuspendedCaps".Translate()); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; } Text.Font = GameFont.Small; GUI.color = Color.white; return(rect); }
public void DrawTags(Rect rect) { var tags = selectedUnit.loadout.tags.ToList(); DrawHeaderButtons(ref rect, tags); rect.AdjVertBy(GenUI.GapTiny); ModGUIUtility.ListSeperator(ref rect, "AppliedTags".Translate()); tagsHeight = tags.Sum(tag => GenUI.ListSpacing * Mathf.Max(1, (Mathf.CeilToInt(tag.requiredItems.Count / 4.0f)))); var viewRect = new Rect(rect.x, rect.y, rect.width - 16f, tagsHeight); Widgets.BeginScrollView(rect, ref tagScroll, viewRect); foreach (var tag in tags) { var tagIdx = tags.FindIndex(t => t == tag); var tagHeight = GenUI.ListSpacing * Mathf.Max(1, (Mathf.CeilToInt(tag.requiredItems.Count / 4.0f))); var tagRect = viewRect.PopTopPartPixels(tagHeight); var editButtonRect = tagRect.PopRightPartPixels(GenUI.ListSpacing).TopPartPixels(GenUI.ListSpacing); if (Widgets.ButtonImageFitted(editButtonRect, Textures.EditTex)) { Find.WindowStack.Add(new Dialog_TagEditor(tag)); } TooltipHandler.TipRegion(editButtonRect, $"Edit {tag.name}"); /*if (Widgets.ButtonImageFitted(tagRect.PopRightPartPixels(GenUI.ListSpacing).TopPartPixels(GenUI.ListSpacing), TexButton.DeleteX)) { * selectedUnit.loadout.tags.Remove(tag); * * if ( LoadoutManager.PawnsWithTags.TryGetValue(tag, out var pList)) * { * pList.pawns.Remove(pawn); * } * * var loadoutItems = tag.ThingsAcceptedInList(pawn.InventoryAndEquipment().ToList()).ToList(); * selectedUnit.loadout.itemsToRemove.AddRange(loadoutItems.ToList()); * }*/ if (tagIdx != 0) { if (Widgets.ButtonImageFitted(tagRect.PopRightPartPixels(GenUI.ListSpacing).TopPartPixels(GenUI.ListSpacing), TexButton.ReorderUp)) { var tmp = selectedUnit.loadout.tags[tagIdx - 1]; selectedUnit.loadout.tags[tagIdx - 1] = tag; selectedUnit.loadout.tags[tagIdx] = tmp; } } else { tagRect.PopRightPartPixels(GenUI.ListSpacing); } if (tagIdx != tags.Count - 1) { if (Widgets.ButtonImageFitted(tagRect.PopRightPartPixels(GenUI.ListSpacing).TopPartPixels(GenUI.ListSpacing), TexButton.ReorderDown)) { var tmp = selectedUnit.loadout.tags[tagIdx + 1]; selectedUnit.loadout.tags[tagIdx + 1] = tag; selectedUnit.loadout.tags[tagIdx] = tmp; } } else { tagRect.PopRightPartPixels(GenUI.ListSpacing); } Widgets.DrawBoxSolid(tagRect.PopLeftPartPixels(10.0f), Panel_ShowCoverage.GetColorForTagAtIndex(tagIdx)); tagRect.AdjHorzBy(3f); Widgets.Label(tagRect.PopLeftPartPixels(tag.name.GetWidthCached() + 10f), tag.name); var y = tagRect.y; // draw required items in blocks of 4 for (int i = 0; i < tag.requiredItems.Count; i += 4) { for (int j = 0; j < 4; j++) { var drawRect = new Rect(tagRect.x + GenUI.ListSpacing * j, y + (i / 4.0f) * GenUI.ListSpacing, GenUI.ListSpacing, GenUI.ListSpacing); var idx = i + j; if (idx >= tag.requiredItems.Count) { break; } var item = tag.requiredItems[idx]; if (item.Quantity > 1) { ModGUIUtility.FittedDefIconCount(drawRect, item.Def, item.RandomStuff, item.Quantity); } else { Widgets.DefIcon(drawRect, item.Def, item.RandomStuff); } TooltipHandler.TipRegion(drawRect, item.Def.LabelCap); } } } Widgets.EndScrollView(); }