/// <summary> /// DefaultLabelForAction /// </summary> /// <param name="action"> </param> /// <param name="use_originals">If true, will return the value pulled /// from Terraria's code for that action. </param> /// <returns>Corresponding label for the action or the empty string "" /// if one could not be found.</returns> public static string DefaultLabelForAction(this TIH action, bool use_originals) { if (use_originals) { switch (action) { case TIH.LootAll: case TIH.DepositAll: case TIH.QuickStack: case TIH.Rename: case TIH.SaveName: case TIH.CancelEdit: return(IHBase.OriginalButtonLabels[action]); } } string label; if (Constants.DefaultButtonLabels.TryGetValue(action, out label)) { return(label); } return(""); }
/// <summary> /// Create a new TextButton instance with the given properties /// and automatically associate it with its base.</summary> /// <param name="parent"> </param> /// <param name="action"> </param> /// <param name="label"> </param> /// <returns>The newly created TextButton</returns> public static TextButton New(ButtonSlot <TextButton> parent, TIH action, string label = "") { var newThis = new TextButton(parent, action, label); parent.AddButton(newThis); return(newThis); }
/// returns the key-bind (as a string) for the button with the given action. /// return value will be something like "(X)" public static string GetKeyTip(TIH action) { string kbopt; if (Constants.ButtonActionToKeyBindOption.TryGetValue(action, out kbopt)) { return(IHBase.ButtonKeyTips[kbopt]); } return(""); }
// Constructors protected CoreButton(IButtonSlot parent, TIH action, string label = "", Color?tint = null) { ButtonBase = parent; Action = action; Label = label; Hooks = new ButtonHooks(); Services = new Dictionary <string, ButtonService>(); Tint = tint ?? Color.White; ID = UICore.GenerateHoverID(); }
/// <summary> /// Create a new TexturedButton instance with the given properties /// and automatically associate it with its base (ButtonSlot). /// </summary> /// <param name="parent"> </param> /// <param name="action"> </param> /// <param name="label"> </param> /// <param name="tooltip"> </param> /// <param name="bg_color"> </param> /// <param name="texture"> </param> /// <param name="inactive_rect"> </param> /// <param name="active_rect"> </param> /// <returns>The newly created TexturedButton</returns> public static TexturedButton New(ButtonSlot <TexturedButton> parent, TIH action, string label, string tooltip = "", Color?bg_color = null, Texture2D texture = null, Rectangle?inactive_rect = null, Rectangle?active_rect = null) { var newThis = new TexturedButton(parent, action, label, tooltip, bg_color, texture, inactive_rect, active_rect); parent.AddButton(newThis); return(newThis); }
protected TexturedButton(ButtonSlot <TexturedButton> parent, TIH action, string label, string tooltip = "", Color?bg_color = null, Texture2D texture = null, Rectangle?inactive_rect = null, Rectangle?active_rect = null ) : base(parent, action, label) { Tooltip = tooltip; // this should set ShowTooltip = true automatically if not "" BackgroundColor = bg_color ?? Color.White; Texture = (texture == null) ? IHBase.ButtonGrid : texture; InactiveRect = inactive_rect.HasValue ? inactive_rect : IHUtils.GetSourceRect(action); ActiveRect = active_rect.HasValue ? active_rect : IHUtils.GetSourceRect(action, true); }
///Get source Texels for the button based what @action it performs /// @param action /// @param active - false = default/inactive button appearance; /// true = focused/mouseover/active appearance public static Rectangle?GetSourceRect(TIH action, bool active = false) { return(RectFromGridIndex(Constants.ButtonGridIndexByActionType[action], active)); }
protected TextButton(ButtonSlot <TextButton> parent, TIH action, string label = "") : base(parent, action, label) { }
public static void ToggleActionLock(TIH actionID) { Instance.LockedActions[actionID] = !Instance.LockedActions[actionID]; }
/// Set indicated action to respect/not-respect locked slots, /// depending on current status. public static void ToggleActionLock(Player p, TIH actionID) { IHPlayer mp = p.GetSubClass <IHPlayer>(); mp.LockedActions[actionID] = !mp.LockedActions[actionID]; }
public static bool ActionLocked(TIH actionID) { return(Instance.LockedActions[actionID]); }
/// <returns>True if indicated action is set to respect locked slots.</returns> public static bool ActionLocked(Player player, TIH actionID) { IHPlayer mp = player.GetSubClass <IHPlayer>(); return(mp.LockedActions[actionID]); }