Esempio 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;
     }
 }
Esempio 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);
                };
            }
        }
Esempio 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));
        }
Esempio 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);
            }
        }
Esempio 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);
            }
        }
Esempio n. 6
0
 public bool TryGetPower(ushort id, out ICreativePower power)
 {
     return(this._powersById.TryGetValue(id, out power));
 }