void OnEnable() { Group = GetComponent <CanvasGroup>(); Content = transform.Find("Content").GetComponent <TooltipContent>(); ContentTransform = transform.Find("Content").GetComponent <RectTransform>(); MyTransform = GetComponent <RectTransform>(); }
private void CreateTooltip(Transform parent, PickupDef pickupDefinition, int count) { ItemDef itemDefinition = ItemCatalog.GetItemDef(pickupDefinition.itemIndex); EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDefinition.equipmentIndex); bool isItem = itemDefinition != null; TooltipContent content = new TooltipContent(); content.titleColor = pickupDefinition.darkColor; content.titleToken = isItem ? itemDefinition.nameToken : equipmentDef.nameToken; content.bodyToken = isItem ? itemDefinition.descriptionToken : equipmentDef.descriptionToken; if (isItem && ItemStatsMod.enabled) { CharacterMaster master = PlayerCharacterMasterController.instances[0].master; string stats = ItemStatsMod.GetStats(itemDefinition.itemIndex, count, master); if (stats != null) { content.overrideBodyText = $"{Language.GetString(content.bodyToken)}{stats}"; } } TooltipProvider tooltipProvider = parent.gameObject.AddComponent <TooltipProvider>(); tooltipProvider.SetContent(content); }
private void Awake() { Debug.Assert(Label != null); Debug.Assert(Input != null); tooltipContent = Label.GetComponent <TooltipContent>(); if (!string.IsNullOrEmpty(ParameterType)) { SetType(ParameterType); } SetLabel(Label.text, null); }
private IEnumerator waitEndAnimAndWarn(GameObject link, string newText) { Animation anim = link.GetComponent <Animation>(); while (anim.isPlaying) { yield return(null); } link.GetComponent <Image>().color = new Color(1, 0, 0, 0.75f); TooltipContent tc = link.AddComponent <TooltipContent>(); // not using FYFY for this component tc.text = newText; }
private void Awake() { Debug.Assert(label != null); Debug.Assert(posX != null); Debug.Assert(posY != null); Debug.Assert(posZ != null); Debug.Assert(orX != null); Debug.Assert(orY != null); Debug.Assert(orZ != null); Debug.Assert(orW != null); tooltipContent = label.GetComponent <TooltipContent>(); tooltipContent.tooltipRect = Base.GameManager.Instance.Tooltip; tooltipContent.descriptionText = Base.GameManager.Instance.Text; }
public BaseConfigField(string displayName, string tooltip, Func <T> valueAccessor, Action <T> onValueChanged) : this(displayName, valueAccessor, onValueChanged) { if (string.IsNullOrEmpty(tooltip)) { return; } Tooltip = new TooltipContent { titleColor = Color.black, overrideTitleText = displayName, bodyColor = Color.black, overrideBodyText = tooltip }; }
private static void CreateTooltip(string text, ActionButton btn) { TooltipContent btnTooltip = btn.gameObject.AddComponent <TooltipContent>(); btnTooltip.enabled = true; if (btnTooltip.tooltipRect == null) { btnTooltip.tooltipRect = Base.GameManager.Instance.Tooltip; } if (btnTooltip.descriptionText == null) { btnTooltip.descriptionText = Base.GameManager.Instance.Text; } btnTooltip.description = text; }
private static TooltipContent LogBookControllerOnGetPickupTooltipContent(On.RoR2.UI.LogBook.LogBookController.orig_GetPickupTooltipContent orig, UserProfile userProfile, Entry entry, EntryStatus status) { if (IsCustomItemOrEquipment((PickupIndex)entry.extraData)) { UnlockableDef unlockableDef = UnlockableCatalog.GetUnlockableDef(((PickupIndex)entry.extraData).GetUnlockableName()); TooltipContent result = default; result.titleToken = entry.nameToken; result.titleColor = entry.color; if (unlockableDef != null) { result.overrideBodyText = unlockableDef.getUnlockedString(); } result.bodyToken = "LOGBOOK_CATEGORY_ITEM"; result.bodyColor = ColorCatalog.GetColor(ColorCatalog.ColorIndex.Unlockable); return(result); } return(orig(userProfile, entry, status)); }
private void DrawContent(RenderEnv env, TooltipContent content, Vector2 position, bool adjustToWindow) { Vector2 padding = new Vector2(10, 8); Vector2 preferSize = new Vector2( Math.Max(content.size.X + padding.X * 2, 26), Math.Max(content.size.Y + padding.Y * 2, 26)); if (adjustToWindow) { position.X = Math.Max(0, Math.Min(position.X, env.Camera.Width - preferSize.X)); position.Y = Math.Max(0, Math.Min(position.Y, env.Camera.Height - preferSize.Y)); } env.Sprite.Begin(); var background = UIGraphics.LayoutNinePatch(this.Resource, new Point((int)preferSize.X, (int)preferSize.Y)); foreach (var block in background) { if (block.Rectangle.Width > 0 && block.Rectangle.Height > 0 && block.Texture != null) { var rect = new Rectangle((int)position.X + block.Rectangle.X, (int)position.Y + block.Rectangle.Y, block.Rectangle.Width, block.Rectangle.Height); env.Sprite.Draw(block.Texture, rect, Color.White); } } foreach (var block in content.blocks) { var pos = new Vector2(position.X + padding.X + block.Position.X, position.Y + padding.Y + block.Position.Y); env.Sprite.DrawStringEx(block.Font, block.Text, pos, block.ForeColor); } env.Sprite.End(); }
private void BuffIcon_UpdateIcon(On.RoR2.UI.BuffIcon.orig_UpdateIcon orig, BuffIcon self) { orig(self); var tooltipProvider = self.GetComponent <TooltipProvider>(); if (tooltipProvider != null) { BuffInfo buffInfo = BuffInfoProvider.GetBuffInfoFromIndex(self.buffIndex); string title; string body; Color titleColor = Color.black; Color bodyColor = new Color(0.6f, 0.6f, 0.6f, 1f); if (buffInfo != null) { title = buffInfo.Name; body = buffInfo.Description; titleColor = buffInfo.Color; } else { title = BuffCatalog.GetBuffDef(self.buffIndex)?.name; body = ""; } TooltipContent ttContent = new TooltipContent { titleToken = title, bodyToken = body, titleColor = titleColor, bodyColor = bodyColor }; tooltipProvider.SetContent(ttContent); } }
private void Start() { tooltipContent = GetComponent <TooltipContent>(); toggle = GetComponent <Toggle>(); }
public void SetContent(TooltipContent content) { _nameObject.GetComponent <Text> ().text = content.name; _descriptionObject.GetComponent <Text> ().text = content.description; }
public BooleanConfigField(string displayName, TooltipContent tooltip, Func <bool> valueAccessor, Action <bool> onValueChanged) : base(displayName, tooltip, valueAccessor, onValueChanged) { }
public BaseConfigField(string displayName, TooltipContent tooltip, Func <T> valueAccessor, Action <T> onValueChanged) : this(displayName, valueAccessor, onValueChanged) { Tooltip = tooltip; }
private void DrawContent(RenderEnv env, TooltipContent content, Vector2 position, bool adjustToWindow) { Vector2 padding = new Vector2(10, 8); Vector2 preferSize = new Vector2( Math.Max(content.size.X + padding.X * 2, 26), Math.Max(content.size.Y + padding.Y * 2, 26)); if (adjustToWindow) { position.X = Math.Max(0, Math.Min(position.X, env.Camera.Width - preferSize.X)); position.Y = Math.Max(0, Math.Min(position.Y, env.Camera.Height - preferSize.Y)); } env.Sprite.Begin(blendState: BlendState.NonPremultiplied); var background = UIGraphics.LayoutNinePatch(this.Resource, new Point((int)preferSize.X, (int)preferSize.Y)); foreach (var block in background) { if (block.Rectangle.Width > 0 && block.Rectangle.Height > 0 && block.Texture != null) { var rect = new Rectangle((int)position.X + block.Rectangle.X, (int)position.Y + block.Rectangle.Y, block.Rectangle.Width, block.Rectangle.Height); env.Sprite.Draw(block.Texture, rect, Color.White); } } if (content.textures != null) { foreach (var block in content.textures) { if (block.Texture != null) { var rect = block.Rectangle; rect.X += (int)(position.X + padding.X); rect.Y += (int)(position.Y + padding.Y); if (rect.Width == 0) { rect.Width = block.Texture.Width; } if (rect.Height == 0) { rect.Height = block.Texture.Height; } env.Sprite.Draw(block.Texture, rect, Color.White); } } } env.Sprite.Flush(); foreach (var block in content.blocks) { var pos = new Vector2(position.X + padding.X + block.Position.X, position.Y + padding.Y + block.Position.Y); var baseFont = block.Font.BaseFont; if (baseFont is XnaFont) { env.Sprite.DrawStringEx((XnaFont)baseFont, block.Text, pos, block.ForeColor); env.Sprite.Flush(); } else if (baseFont is D2DFont) { env.D2DRenderer.Begin(); env.D2DRenderer.DrawString((D2DFont)baseFont, block.Text, pos, block.ForeColor); env.D2DRenderer.End(); } } env.Sprite.End(); }
public EnumConfigField(string displayName, TooltipContent tooltip, Func <T> valueAccessor, Action <T> onValueChanged = null) : base(typeof(T), displayName, tooltip, () => valueAccessor.Invoke()) { ValueAccessor = valueAccessor; OnValueChangedCallback = onValueChanged; }
public IntConfigField(string displayName, TooltipContent tooltip, Func <int> valueAccessor, Action <int> onValueChanged = null, Action <int> onEndEdit = null, int?minimum = null, int?maximum = null) : base(displayName, tooltip, valueAccessor, onValueChanged, onEndEdit, minimum, maximum) { }
private void Awake() { Button = gameObject.GetComponent <Button>(); TooltipContent = gameObject.GetComponent <TooltipContent>(); }
public StringConfigField(string displayName, TooltipContent tooltip, Func <string> valueAccessor, Action <string> onValueChanged, Action <string> onEndEdit = null) : base(displayName, tooltip, valueAccessor, onValueChanged, onEndEdit) { }
private void Awake() { tooltipContent = Label.GetComponent <TooltipContent>(); }
public EnumConfigField(Type enumType, string displayName, TooltipContent tooltip, Func <Enum> valueAccessor, Action <Enum> onValueChanged = null) : base(displayName, tooltip, valueAccessor, onValueChanged) { EnumType = enumType; Options = new ReadOnlyCollection <string>(Enum.GetNames(enumType)); Values = new ReadOnlyCollection <Enum>(Enum.GetValues(enumType).Cast <Enum>().ToList()); }
public BaseNumberInputConfigField(string displayName, TooltipContent tooltip, Func <T> valueAccessor, Action <T> onValueChanged = null, Action <T> onEndEdit = null, T?minimum = null, T?maximum = null) : base(displayName, tooltip, valueAccessor, onValueChanged, onEndEdit) { Minimum = minimum; Maximum = maximum; }
public ColorConfigField(string displayName, TooltipContent tooltip, Func <Color> valueAccessor, Action <Color> onValueChanged = null, Action <Color> onEndEdit = null, bool showAlpha = true) : base(displayName, tooltip, valueAccessor, onValueChanged, onEndEdit) { ShowAlpha = showAlpha; }
public BaseInputConfigField(string displayName, TooltipContent tooltip, Func <T> valueAccessor, Action <T> onValueChanged, Action <T> onEndEdit = null) : base(displayName, tooltip, valueAccessor, onValueChanged) { OnEndEditCallback = onEndEdit; }