public static void AddPermissionTextIfNeeded(ICreativePower power, ref string originalText) { if (!IsAvailableForPlayer(power, Main.myPlayer)) { string textValue = Language.GetTextValue("CreativePowers.CantUsePowerBecauseOfNoPermissionFromServer"); originalText = originalText + "\n" + textValue; } }
public static void UpdateUnlockStateByPower(ICreativePower power, UIElement button, Color colorWhenSelected) { IGroupOptionButton asButton = button as IGroupOptionButton; if (asButton != null) { button.OnUpdate += delegate { UpdateUnlockStateByPowerInternal(power, colorWhenSelected, asButton); }; } }
public static void UpdateUnlockStateByPower( ICreativePower power, UIElement button, Color colorWhenSelected) { IGroupOptionButton asButton = button as IGroupOptionButton; if (asButton == null) { return; } button.OnUpdate += (UIElement.ElementEvent)(element => CreativePowersHelper.UpdateUnlockStateByPowerInternal(power, colorWhenSelected, asButton)); }
public static bool IsAvailableForPlayer(ICreativePower power, int playerIndex) { switch (power.CurrentPermissionLevel) { case PowerPermissionLevel.CanBeChangedByHostAlone: return(Main.netMode == 0 || Main.countsAsHostForGameplay[playerIndex]); case PowerPermissionLevel.CanBeChangedByEveryone: return(true); default: return(false); } }
private static void UpdateUnlockStateByPowerInternal(ICreativePower power, Color colorWhenSelected, IGroupOptionButton asButton) { bool isUnlocked = power.GetIsUnlocked(); bool flag = !IsAvailableForPlayer(power, Main.myPlayer); asButton.SetBorderColor(flag ? Color.DimGray : Color.White); if (flag) { asButton.SetColorsBasedOnSelectionState(new Color(60, 60, 60), new Color(60, 60, 60), 0.7f, 0.7f); } else if (isUnlocked) { asButton.SetColorsBasedOnSelectionState(colorWhenSelected, Colors.InventoryDefaultColor, 1f, 0.7f); } else { asButton.SetColorsBasedOnSelectionState(Color.Crimson, Color.Red, 0.7f, 0.7f); } }
public bool TryGetPower(ushort id, out ICreativePower power) { return(this._powersById.TryGetValue(id, out power)); }