Exemplo n.º 1
0
 public static void AddPermissionTextIfNeeded(ICreativePower power, ref string originalText)
 {
     if (!IsAvailableForPlayer(power, Main.myPlayer))
     {
         string textValue = Language.GetTextValue("CreativePowers.CantUsePowerBecauseOfNoPermissionFromServer");
         originalText = originalText + "\n" + textValue;
     }
 }
Exemplo n.º 2
0
        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);
                };
            }
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
 public bool TryGetPower(ushort id, out ICreativePower power)
 {
     return(this._powersById.TryGetValue(id, out power));
 }