public static bool ButtonImage(Rect butRect, Texture2D tex, bool doMouseoverSound = false, TipSignal?tipSignal = null, Rect?texRect = null) { Texture2D atlas = ExtraWidgets.ButtonBGAtlas; if (Mouse.IsOver(butRect)) { atlas = ExtraWidgets.ButtonBGAtlasMouseover; if (Input.GetMouseButton(0)) { atlas = ExtraWidgets.ButtonBGAtlasClick; } } var result = Widgets.ButtonImage(butRect, atlas); if (doMouseoverSound) { MouseoverSounds.DoRegion(butRect); } GUI.DrawTexture(texRect ?? butRect, tex); if (tipSignal != null) { TooltipHandler.TipRegion(butRect, tipSignal.Value); } return(result); }
public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth, GizmoRenderParms parms) { var rect = new Rect(topLeft.x, topLeft.y, 75f, 75f); var isMouseOver = false; if (Mouse.IsOver(rect)) { isMouseOver = true; GUI.color = GenUI.MouseoverColor; } var badTex = icon; if (badTex == null) { badTex = BaseContent.BadTex; } GUI.DrawTexture(rect, BGTex); MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command); GUI.color = defaultIconColor; Widgets.DrawTextureFitted(new Rect(rect), badTex, iconDrawScale * 0.85f, iconProportions, iconTexCoords); GUI.color = Color.white; var isUsed = false; //Rect rectFil = new Rect(topLeft.x, topLeft.y, this.Width, this.Width); var keyCode = hotKey?.MainKey ?? KeyCode.None; if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode)) { var rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f); Widgets.Label(rect2, keyCode.ToStringReadable()); GizmoGridDrawer.drawnHotKeys.Add(keyCode); if (hotKey is { KeyDownEvent : true })
private static bool DrawIconForWeapon(ThingDef weapon, KeyValuePair <String, WeaponRecord> item, Rect contentRect, Vector2 iconOffset, int buttonID) { var iconTex = weapon.uiIcon; Graphic g = weapon.graphicData.Graphic; Color color = getColor(weapon); Color colorTwo = getColor(weapon); Graphic g2 = weapon.graphicData.Graphic.GetColoredVersion(g.Shader, color, colorTwo); var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize); if (!contentRect.Contains(iconRect)) { return(false); } string label = weapon.label; TooltipHandler.TipRegion(iconRect, label); MouseoverSounds.DoRegion(iconRect, SoundDefOf.MouseoverCommand); if (Mouse.IsOver(iconRect)) { GUI.color = iconMouseOverColor; GUI.DrawTexture(iconRect, ContentFinder <Texture2D> .Get("square", true)); } else if (item.Value.isException == true) { GUI.color = iconMouseOverColor; GUI.DrawTexture(iconRect, ContentFinder <Texture2D> .Get("square", true)); } else { GUI.color = iconBaseColor; GUI.DrawTexture(iconRect, ContentFinder <Texture2D> .Get("square", true)); } Texture resolvedIcon; if (!weapon.uiIconPath.NullOrEmpty()) { resolvedIcon = weapon.uiIcon; } else { resolvedIcon = g2.MatSingle.mainTexture; } GUI.color = color; GUI.DrawTexture(iconRect, resolvedIcon); GUI.color = Color.white; if (Widgets.ButtonInvisible(iconRect, true)) { Event.current.button = buttonID; return(true); } else { return(false); } }
private static void Postfix(WidgetRow row, bool worldView) { if (worldView) { return; } var mouseOverRect = new Rect(row.FinalX - WidgetRow.IconSize, row.FinalY, WidgetRow.IconSize, WidgetRow.IconSize); MouseoverSounds.DoRegion(mouseOverRect, SoundDefOf.Mouseover_ButtonToggle); if (Mouse.IsOver(mouseOverRect)) { Find.CurrentMap.GetCleaningManager().MarkAllForDraw(); } if (!row.ButtonIcon(TextureLoader.priorityWindowButton, "OpenCleaningPriorityDialog".Translate())) { return; } if (!Find.WindowStack.IsOpen <Dialog_CleaningPriority>()) { Find.WindowStack.Add(new Dialog_CleaningPriority(Find.CurrentMap)); } else { Find.WindowStack.TryRemove(typeof(Dialog_CleaningPriority)); } }
private static void DoTimeAssignment(Rect rect, TimetableBool table, int hour) { if (table == null) { Log.Error("Table must not be null."); return; } rect = rect.ContractedBy(1f); bool mouseButton = Input.GetMouseButton(0); bool assignment = table.GetAssignment(hour); GUI.DrawTexture(rect, table.GetTexture(assignment)); if (!mouseButton) { MouseoverSounds.DoRegion(rect); } if (!Mouse.IsOver(rect)) { return; } if (!mouseButton) { lastAssignmentValue = !assignment; } Widgets.DrawBox(rect, 2); if (mouseButton && assignment != lastAssignmentValue) { SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(); table.SetAssignment(hour, lastAssignmentValue); } }
private static bool DrawTileForPawn(KeyValuePair <String, Record> pawn, Rect contentRect, Vector2 iconOffset, int buttonID, float tileHeight) { var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, contentRect.width, tileHeight); MouseoverSounds.DoRegion(iconRect, SoundDefOf.Mouseover_Command); Color save = GUI.color; if (Mouse.IsOver(iconRect)) { GUI.color = iconMouseOverColor; } else if (pawn.Value.isSelected == true) { GUI.color = selectedBackground; } else { GUI.color = notSelectedBackground; } GUI.DrawTexture(iconRect, TexUI.FastFillTex); GUI.color = save; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(iconRect, (!pawn.Value.label.NullOrEmpty() ? pawn.Value.label : pawn.Key)); Text.Anchor = TextAnchor.UpperLeft; if (Widgets.ButtonInvisible(iconRect, true)) { Event.current.button = buttonID; return(true); } else { return(false); } }
static bool KeyGroupButton(Rect rect, string keyGroup, List <FloatMenuOption> floatMenuList, Color textColor) { MouseoverSounds.DoRegion(rect); //Texture2D atlas = Widgets.ButtonSubtleAtlas; Texture2D atlas = TexUI.HighlightTex; Color color = GUI.color; GUI.color = textColor; if (Mouse.IsOver(rect)) { Widgets.DrawAtlas(rect, atlas); } TextAnchor anchor = Text.Anchor; Text.Anchor = TextAnchor.MiddleRight; Widgets.Label(rect, keyGroup); Text.Anchor = anchor; GUI.color = color; Widgets.DraggableResult result = (!Widgets.ButtonInvisible(rect, false)) ? Widgets.DraggableResult.Idle : Widgets.DraggableResult.Pressed; return(result == Widgets.DraggableResult.Pressed || result == Widgets.DraggableResult.DraggedThenPressed); }
private void DoTimeAssignment(Rect rect, int hour) { rect = rect.ContractedBy(1f); bool mouseButton = Input.GetMouseButton(0); TimeAssignmentDef assignment = this.colonistGroup.pawns.First().timetable.GetAssignment(hour); GUI.DrawTexture(rect, assignment.ColorTexture); if (!mouseButton) { MouseoverSounds.DoRegion(rect); } if (!Mouse.IsOver(rect)) { return; } if (mouseButton && assignment != TimeAssignmentSelector.selectedAssignment && TimeAssignmentSelector.selectedAssignment != null) { SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(); foreach (var p in this.colonistGroup.pawns) { p.timetable.SetAssignment(hour, TimeAssignmentSelector.selectedAssignment); } } }
public bool DoGUI_BG(Rect rect) { bool mouseIsOver = false; if (Mouse.IsOver(rect)) { mouseIsOver = true; GUI.color = GenUI.MouseoverColor; } var badTex = gizmo.icon; if (badTex == null) { badTex = BaseContent.BadTex; } GUI.DrawTexture(rect, Command.BGTex); MouseoverSounds.DoRegion(rect, SoundDefOf.MouseoverCommand); GUI.color = gizmo.IconDrawColor; Widgets.DrawTextureFitted(new Rect(rect), badTex, gizmo.iconDrawScale * 0.85f, gizmo.iconProportions, gizmo.iconTexCoords); GUI.color = Color.white; return(mouseIsOver); }
private static bool DrawTileForAnimal(KeyValuePair <String, AnimalRecord> Animal, Rect contentRect, Vector2 iconOffset, int buttonID) { var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, contentRect.width, rowHeight); MouseoverSounds.DoRegion(iconRect, SoundDefOf.MouseoverCommand); Color save = GUI.color; if (Mouse.IsOver(iconRect)) { GUI.color = iconMouseOverColor; } else if (Animal.Value.isException == true) { GUI.color = exceptionBackground; } else { GUI.color = background; } GUI.DrawTexture(iconRect, TexUI.FastFillTex); GUI.color = save; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(iconRect, Animal.Key); Text.Anchor = TextAnchor.UpperLeft; if (Widgets.ButtonInvisible(iconRect, true)) { Event.current.button = buttonID; return(true); } else { return(false); } }
public void statCheckbox(Vector2 topLeft, ref bool checkOn, float size, bool paintable, PawnLvComp pawnlvcomp) { Rect rect = new Rect(topLeft.x, topLeft.y, size, size); GUI.DrawTexture(image: (!checkOn) ? (CheckboxOffTex) : (CheckboxOnTex), position: new Rect(topLeft.x, topLeft.y, size, size)); DraggableResult draggableResult = ButtonInvisibleDraggable(rect); MouseoverSounds.DoRegion(rect); bool flag = false; if (draggableResult == DraggableResult.Pressed) { checkOn = !checkOn; flag = true; //pawnlvcomp.AGLauto = false; pawnlvcomp.CHAauto = false; pawnlvcomp.CONauto = false; pawnlvcomp.DEXauto = false; pawnlvcomp.INTauto = false; pawnlvcomp.STRauto = false; } if (flag) { if (checkOn) { SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(); } else { SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(); } } }
private void DoScenarioListEntry(Rect rect, Scenario scen) { bool flag = this.curScen == scen; Widgets.DrawOptionBackground(rect, flag); MouseoverSounds.DoRegion(rect); Rect rect2 = rect.ContractedBy(4f); Text.Font = GameFont.Small; Rect rect3 = rect2; rect3.height = Text.CalcHeight(scen.name, rect3.width); Widgets.Label(rect3, scen.name); Text.Font = GameFont.Tiny; Rect rect4 = rect2; rect4.yMin = rect3.yMax; Widgets.Label(rect4, scen.GetSummary()); if (scen.enabled) { WidgetRow widgetRow = new WidgetRow(rect.xMax, rect.y, UIDirection.LeftThenDown, 99999f, 4f); if (scen.Category == ScenarioCategory.CustomLocal && widgetRow.ButtonIcon(TexButton.DeleteX, "Delete".Translate(), new Color?(GenUI.SubtleMouseoverColor))) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmDelete".Translate(scen.File.Name), delegate { scen.File.Delete(); ScenarioLister.MarkDirty(); }, true, null)); } if (scen.Category == ScenarioCategory.SteamWorkshop && widgetRow.ButtonIcon(TexButton.DeleteX, "Unsubscribe".Translate(), new Color?(GenUI.SubtleMouseoverColor))) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUnsubscribe".Translate(scen.File.Name), delegate { scen.enabled = false; if (this.curScen == scen) { this.curScen = null; this.EnsureValidSelection(); } Workshop.Unsubscribe(scen); }, true, null)); } if (scen.GetPublishedFileId() != PublishedFileId_t.Invalid) { if (widgetRow.ButtonIcon(ContentSource.SteamWorkshop.GetIcon(), "WorkshopPage".Translate(), null)) { SteamUtility.OpenWorkshopPage(scen.GetPublishedFileId()); } if (scen.CanToUploadToWorkshop()) { widgetRow.Icon(Page_SelectScenario.CanUploadIcon, "CanBeUpdatedOnWorkshop".Translate()); } } if (!flag && Widgets.ButtonInvisible(rect, false)) { this.curScen = scen; SoundDefOf.Click.PlayOneShotOnCamera(null); } } }
public static void MedicalCareSetter(Rect rect, ref MedicalCareCategory medCare) { Rect rect2 = new Rect(rect.x, rect.y, rect.width / 5f, rect.height); for (int i = 0; i < 5; i++) { MedicalCareCategory mc = (MedicalCareCategory)i; Widgets.DrawHighlightIfMouseover(rect2); MouseoverSounds.DoRegion(rect2); GUI.DrawTexture(rect2, careTextures[i]); Widgets.DraggableResult draggableResult = Widgets.ButtonInvisibleDraggable(rect2); if (draggableResult == Widgets.DraggableResult.Dragged) { medicalCarePainting = true; } if ((medicalCarePainting && Mouse.IsOver(rect2) && medCare != mc) || draggableResult.AnyPressed()) { medCare = mc; SoundDefOf.Tick_High.PlayOneShotOnCamera(); } if (medCare == mc) { Widgets.DrawBox(rect2, 3); } if (Mouse.IsOver(rect2)) { TooltipHandler.TipRegion(rect2, () => mc.GetLabel(), 632165 + i * 17); } rect2.x += rect2.width; } if (!Input.GetMouseButton(0)) { medicalCarePainting = false; } }
private void DoTimeAssignment(Rect rect, Pawn p, int hour) { rect = rect.ContractedBy(1f); bool mouseButton = Input.GetMouseButton(0); TimeAssignmentDef assignment = p.timetable.GetAssignment(hour); GUI.DrawTexture(rect, assignment.ColorTexture); if (!mouseButton) { MouseoverSounds.DoRegion(rect); } if (!Mouse.IsOver(rect)) { return; } Widgets.DrawBox(rect, 2); if (mouseButton && assignment != TimeAssignmentSelector.selectedAssignment && TimeAssignmentSelector.selectedAssignment != null) { SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(); p.timetable.SetAssignment(hour, TimeAssignmentSelector.selectedAssignment); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeAssignments, KnowledgeAmount.SmallInteraction); if (TimeAssignmentSelector.selectedAssignment == TimeAssignmentDefOf.Meditate) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.MeditationSchedule, KnowledgeAmount.Total); } } }
public static bool ButtonImageOn(Rect rect, Texture2D tex, bool doMouseoverSound = true) { var atlas = ButtonBgAtlas; if (Mouse.IsOver(rect)) { atlas = ButtonBgAtlasMouseover; if (Input.GetMouseButton(0)) { atlas = ButtonBgAtlasClick; } } Widgets.DrawAtlas(rect, atlas); if (doMouseoverSound) { MouseoverSounds.DoRegion(rect); } GUI.DrawTexture(rect.ScaledBy(0.75f), (Texture)tex); return(Widgets.ButtonInvisible(rect, false)); }
public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth) { Text.Font = GameFont.Tiny; Rect rect = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f); bool flag = false; if (Mouse.IsOver(rect)) { flag = true; if (!disabled) { GUI.color = GenUI.MouseoverColor; } } MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command); Material material = disabled ? TexUI.GrayscaleGUI : null; GenUI.DrawTextureWithMaterial(rect, BGTexture, material); DrawIcon(rect, material); bool flag2 = false; KeyCode keyCode = (hotKey != null) ? hotKey.MainKey : KeyCode.None; if (keyCode != 0 && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode)) { Widgets.Label(new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f), keyCode.ToStringReadable()); GizmoGridDrawer.drawnHotKeys.Add(keyCode); if (hotKey.KeyDownEvent) { flag2 = true; Event.current.Use(); } } if (Widgets.ButtonInvisible(rect)) { flag2 = true; } string labelCap = LabelCap; if (!labelCap.NullOrEmpty()) { float num = Text.CalcHeight(labelCap, rect.width); Rect rect2 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num); GUI.DrawTexture(rect2, TexUI.GrayTextBG); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(rect2, labelCap); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; } GUI.color = Color.white; if (Mouse.IsOver(rect) && DoTooltip) { TipSignal tip = Desc; if (disabled && !disabledReason.NullOrEmpty()) { ref string text = ref tip.text; text += "\n\n" + "DisabledCommand".Translate() + ": " + disabledReason; } TooltipHandler.TipRegion(rect, tip); }
public static bool DrawIconForWeapon(ThingDefStuffDefPair weapon, Rect contentRect, Vector2 iconOffset, int buttonID, bool isBackground = false) { var iconTex = weapon.thing.uiIcon; Graphic g = weapon.thing.graphicData.Graphic; Color color = weapon.getDrawColor(); Color colorTwo = weapon.getDrawColorTwo(); Graphic g2 = weapon.thing.graphicData.Graphic.GetColoredVersion(g.Shader, color, colorTwo); var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize); if (!contentRect.Contains(iconRect)) { return(false); } if (!isBackground) { string label = weapon.getLabelCap(); TooltipHandler.TipRegion(iconRect, label); MouseoverSounds.DoRegion(iconRect, SoundDefOf.Mouseover_Command); if (Mouse.IsOver(iconRect)) { GUI.color = iconMouseOverColor; GUI.DrawTexture(iconRect, TextureResources.drawPocket); //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconMouseOverColor); } else { GUI.color = iconBaseColor; GUI.DrawTexture(iconRect, TextureResources.drawPocket); //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconBaseColor); } } Texture resolvedIcon; if (!weapon.thing.uiIconPath.NullOrEmpty()) { resolvedIcon = weapon.thing.uiIcon; } else { resolvedIcon = g2.MatSingle.mainTexture; } GUI.color = color; GUI.DrawTexture(iconRect, resolvedIcon); GUI.color = Color.white; if (!isBackground) { if (Widgets.ButtonInvisible(iconRect, true)) { Event.current.button = buttonID; return(true); } } return(false); }
private bool DrawIconForWeapon(GoldfishModule pawnMemory, Thing weapon, Rect contentRect, Vector2 iconOffset) { var iconTex = weapon.def.uiIcon; Color color = weapon.DrawColor; var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize); //var iconColor = iconBaseColor; TooltipHandler.TipRegion(iconRect, string.Format("DrawSidearm_gizmoTooltip".Translate(), weapon.LabelShort)); MouseoverSounds.DoRegion(iconRect, SoundDefOf.MouseoverCommand); Texture2D drawPocket; if (pawnMemory.IsCurrentPrimary(weapon.def.defName)) { drawPocket = TextureResources.drawPocketPrimary; } else { drawPocket = TextureResources.drawPocket; } if (Mouse.IsOver(iconRect)) { GUI.color = iconMouseOverColor; GUI.DrawTexture(iconRect, drawPocket); //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconMouseOverColor); } else { GUI.color = iconBaseColor; GUI.DrawTexture(iconRect, drawPocket); //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconBaseColor); } Texture resolvedIcon; if (!weapon.def.uiIconPath.NullOrEmpty()) { resolvedIcon = weapon.def.uiIcon; } else { resolvedIcon = weapon.Graphic.ExtractInnerGraphicFor(weapon).MatSingle.mainTexture; } GUI.color = weapon.DrawColor; GUI.DrawTexture(iconRect, resolvedIcon); GUI.color = Color.white; if (Widgets.ButtonInvisible(iconRect, true)) { return(true); } else { return(false); } }
private static bool CustomInfoCardButtonWorker(Rect rect) { MouseoverSounds.DoRegion(rect); TooltipHandler.TipRegionByKey(rect, "DefInfoTip"); bool result = Widgets.ButtonImage(rect, Textures.InfoButtonNarrow, GUI.color, true); UIHighlighter.HighlightOpportunity(rect, "InfoCard"); return(result); }
public virtual void UIRootUpdate() { ScreenshotTaker.Update(); DragSliderManager.DragSlidersUpdate(); windows.WindowsUpdate(); MouseoverSounds.ResolveFrame(); UIHighlighter.UIHighlighterUpdate(); Messages.Update(); }
public override GizmoResult GizmoOnGUI(Vector2 topLeft) { var gizmoRect = new Rect(topLeft.x, topLeft.y, GizmoSize, GizmoSize); var contentRect = gizmoRect.ContractedBy(ContentPadding); Widgets.DrawWindowBackground(gizmoRect); var interacted = false; if (iconTextures != null) { for (int i = 0; i < iconTextures.Length; i++) { var iconTex = iconTextures[i]; var iconOffset = new Vector2(); switch (i) { case 1: iconOffset = new Vector2(IconSize, 0); break; case 2: iconOffset = new Vector2(0, IconSize); break; case 3: iconOffset = new Vector2(IconSize, IconSize); break; } var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, contentRect.width / 2f, contentRect.height / 2f); var iconColor = iconBaseColor; TooltipHandler.TipRegion(iconRect, string.Format(defaultDesc, i + 1)); MouseoverSounds.DoRegion(iconRect, SoundDefOf.MouseoverCommand); if (Mouse.IsOver(iconRect)) { iconColor += iconMouseOverAdd; } if (Widgets.ButtonInvisible(iconRect, true)) { Event.current.button = i; interacted = true; } Graphics.DrawTexture(iconRect, iconTex, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconColor); } } DrawHotKeyLabel(gizmoRect); if (hotKey != null && hotKey.KeyDownEvent) { interacted = true; Event.current.button = -1; Event.current.Use(); } DrawGizmoLabel(defaultLabel, gizmoRect); return(interacted ? new GizmoResult(GizmoState.Interacted, Event.current) : new GizmoResult(GizmoState.Clear)); }
public void DoFoodHeader(Rect rect) { MouseoverSounds.DoRegion(rect); if (Widgets.ButtonText(new Rect(rect.x, rect.y + (rect.height - 65f), Mathf.Min(rect.width, 360f), 32f), "ManageFoodRestrictions".Translate())) { var window = new Dialog_ManageFoodRestrictions(null); Find.WindowStack.Add(window); } }
public override void DoHeader(Rect rect, PawnTable table) { base.DoHeader(rect, table); MouseoverSounds.DoRegion(rect); if (Widgets.ButtonText(new Rect(rect.x, rect.y + (rect.height - 65f), Mathf.Min(rect.width, 360f), 32f), "ManageFoodRestrictions".Translate())) { Find.WindowStack.Add(new Dialog_ManageFoodRestrictions(null)); } }
public override GizmoResult GizmoOnGUI(Vector2 topLeft) { var gizmoRect = new Rect(topLeft.x, topLeft.y, Width, Width); Widgets.DrawWindowBackground(gizmoRect); Texture2D gizmoTex; string gizmoLabel; string gizmoMouseover; bool isTradeStockpile = QOLTweaksPack.savedData.StockpileIsTradeStockpile(parentZone); if (isTradeStockpile) { gizmoTex = TextureResources.tradeStockpileOn; gizmoLabel = "TradeStockpileOn_label".Translate(); gizmoMouseover = "TradeStockpileOn_mouseOver".Translate(); } else { gizmoTex = TextureResources.tradeStockpileOff; gizmoLabel = "TradeStockpileOff_label".Translate(); gizmoMouseover = "TradeStockpileOff_mouseOver".Translate(); } GUI.DrawTexture(gizmoRect, gizmoTex); // Log.Warning(gizmoRect.ToString()); TooltipHandler.TipRegion(gizmoRect, gizmoMouseover); MouseoverSounds.DoRegion(gizmoRect, SoundDefOf.MouseoverCommand); WidgetsExtensions.DrawGizmoLabel(gizmoLabel, gizmoRect); bool interacted; if (Widgets.ButtonInvisible(gizmoRect, true)) { if (isTradeStockpile) { QOLTweaksPack.savedData.RemoveTradeStockpile(parentZone); } else { QOLTweaksPack.savedData.AddTradeStockpile(parentZone); } interacted = true; } else { interacted = false; } return(interacted ? new GizmoResult(GizmoState.Interacted, Event.current) : new GizmoResult(GizmoState.Clear)); }
public void DoWorkHeader(Rect rect, WorkTypeDef workType) { Text.Font = GameFont.Small; Rect labelRect = GetLabelRect(rect); MouseoverSounds.DoRegion(labelRect); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(labelRect, workType.labelShort); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; }
public static bool Button(Rect rect, string label, bool drawBackground, bool doMouseoverSound, bool active) { var anchor = Text.Anchor; var color = GUI.color; if (drawBackground) { var atlas = TextureButtonBGAtlas; if (Mouse.IsOver(rect)) { atlas = TextureButtonBGAtlasMouseover; if (Input.GetMouseButton(0)) { atlas = TextureButtonBGAtlasClick; } } Widgets.DrawAtlas(rect, atlas); var indicator = new Rect(rect.xMax - 21, rect.MiddleY() - 4, 11, 8); GUI.DrawTexture(indicator, TextureDropdownIndicator); } if (doMouseoverSound) { MouseoverSounds.DoRegion(rect); } if (!drawBackground) { GUI.color = new Color(0.8f, 0.85f, 1f); if (Mouse.IsOver(rect)) { GUI.color = Widgets.MouseoverOptionColor; } } if (drawBackground) { Text.Anchor = TextAnchor.MiddleCenter; } else { Text.Anchor = TextAnchor.MiddleLeft; } var textRect = new Rect(rect.x, rect.y, rect.width - 12, rect.height); Widgets.Label(textRect, label); Text.Anchor = anchor; GUI.color = color; return(active && Widgets.ButtonInvisible(rect, false)); }
public void DoDrugPolicyHeader(Rect rect) { MouseoverSounds.DoRegion(rect); Rect rect2 = new Rect(rect.x, rect.y + (rect.height - 65f), Mathf.Min(rect.width, 360f), 32f); if (Widgets.ButtonText(rect2, "ManageDrugPolicies".Translate())) { var window = new Dialog_ManageDrugPolicies(null); Find.WindowStack.Add(window); } UIHighlighter.HighlightOpportunity(rect2, "ManageDrugPolicies"); UIHighlighter.HighlightOpportunity(rect2, "ButtonAssignDrugs"); }
public override void DoHeader(Rect rect, PawnTable table) { base.DoHeader(rect, table); MouseoverSounds.DoRegion(rect); Rect rect2 = new Rect(rect.x, rect.y + (rect.height - 65f), Mathf.Min(rect.width, 360f), 32f); if (Widgets.ButtonText(rect2, "ManageOutfits".Translate())) { Find.WindowStack.Add(new Dialog_ManageOutfits(null)); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Outfits, KnowledgeAmount.Total); } UIHighlighter.HighlightOpportunity(rect2, "ManageOutfits"); }
public override void DoHeader(Rect rect, PawnTable table) { base.DoHeader(rect, table); MouseoverSounds.DoRegion(rect); Rect rect2 = new Rect(rect.x, rect.y + (rect.height - 65f), Mathf.Min(rect.width, 360f), 32f); if (Widgets.ButtonText(rect2, "ManageDrugPolicies".Translate())) { Find.WindowStack.Add(new Dialog_ManageDrugPolicies(null)); } UIHighlighter.HighlightOpportunity(rect2, "ManageDrugPolicies"); UIHighlighter.HighlightOpportunity(rect2, "ButtonAssignDrugs"); }
private static bool DrawIconForItem(ThingDef item, Rect contentRect, Vector2 iconOffset, int buttonID) { var iconTex = item.uiIcon; Graphic g = item.graphicData.Graphic; Color color = getColor(item); Color colorTwo = getColor(item); Graphic g2 = item.graphicData.Graphic.GetColoredVersion(g.Shader, color, colorTwo); var iconRect = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, IconSize, IconSize); string label = item.label; TooltipHandler.TipRegion(iconRect, label); MouseoverSounds.DoRegion(iconRect, SoundDefOf.MouseoverCommand); if (Mouse.IsOver(iconRect)) { GUI.color = iconMouseOverColor; GUI.DrawTexture(iconRect, TextureResources.drawPocket); //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconMouseOverColor); } else { GUI.color = iconBaseColor; GUI.DrawTexture(iconRect, TextureResources.drawPocket); //Graphics.DrawTexture(iconRect, TextureResources.drawPocket, new Rect(0, 0, 1f, 1f), 0, 0, 0, 0, iconBaseColor); } Texture resolvedIcon; if (!item.uiIconPath.NullOrEmpty()) { resolvedIcon = item.uiIcon; } else { resolvedIcon = g2.MatSingle.mainTexture; } GUI.color = color; GUI.DrawTexture(iconRect, resolvedIcon); GUI.color = Color.white; if (Widgets.ButtonInvisible(iconRect, true)) { Event.current.button = buttonID; return(true); } else { return(false); } }