示例#1
0
        private UIElement CreatePackToggleButton(ResourcePack resourcePack)
        {
            Language.GetText(resourcePack.IsEnabled ? "GameUI.Enabled" : "GameUI.Disabled");
            GroupOptionButton <bool> groupOptionButton = new GroupOptionButton <bool>(true, (LocalizedText)null, (LocalizedText)null, Color.White, (string)null, 0.8f, 0.5f, 10f);

            groupOptionButton.Left   = StyleDimension.FromPercent(0.5f);
            groupOptionButton.Width  = StyleDimension.FromPixelsAndPercent(0.0f, 0.5f);
            groupOptionButton.Height = StyleDimension.Fill;
            groupOptionButton.SetColorsBasedOnSelectionState(Color.LightGreen, Color.PaleVioletRed, 0.7f, 0.7f);
            groupOptionButton.SetCurrentOption(resourcePack.IsEnabled);
            groupOptionButton.ShowHighlightWhenSelected = false;
            groupOptionButton.SetPadding(0.0f);
            Asset <M0>    asset         = Main.Assets.Request <Texture2D>("Images/UI/TexturePackButtons", (AssetRequestMode)1);
            UIImageFramed uiImageFramed = new UIImageFramed((Asset <Texture2D>)asset, ((Asset <Texture2D>)asset).Frame(2, 2, resourcePack.IsEnabled ? 0 : 1, 1, 0, 0));

            uiImageFramed.HAlign = 0.5f;
            uiImageFramed.VAlign = 0.5f;
            uiImageFramed.IgnoresMouseInteraction = true;
            groupOptionButton.Append((UIElement)uiImageFramed);
            groupOptionButton.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => SoundEngine.PlaySound(12, -1, -1, 1, 1f, 0.0f));
            groupOptionButton.OnClick     += (UIElement.MouseEvent)((evt, listeningElement) =>
            {
                SoundEngine.PlaySound(12, -1, -1, 1, 1f, 0.0f);
                resourcePack.IsEnabled = !resourcePack.IsEnabled;
                this.SetResourcePackAsTopPriority(resourcePack);
                this.PopulatePackList();
            });
            return((UIElement)groupOptionButton);
        }
示例#2
0
        private UIElement CreatePackToggleButton(ResourcePack resourcePack)
        {
            Language.GetText(resourcePack.IsEnabled ? "GameUI.Enabled" : "GameUI.Disabled");
            GroupOptionButton <bool> groupOptionButton = new GroupOptionButton <bool>(option: true, null, null, Color.White, null, 0.8f);

            groupOptionButton.Left   = StyleDimension.FromPercent(0.5f);
            groupOptionButton.Width  = StyleDimension.FromPixelsAndPercent(0f, 0.5f);
            groupOptionButton.Height = StyleDimension.Fill;
            groupOptionButton.SetColorsBasedOnSelectionState(Color.LightGreen, Color.PaleVioletRed, 0.7f, 0.7f);
            groupOptionButton.SetCurrentOption(resourcePack.IsEnabled);
            groupOptionButton.ShowHighlightWhenSelected = false;
            groupOptionButton.SetPadding(0f);
            Asset <Texture2D> obj     = Main.Assets.Request <Texture2D>("Images/UI/TexturePackButtons", (AssetRequestMode)1);
            UIImageFramed     element = new UIImageFramed(obj, obj.Frame(2, 2, (!resourcePack.IsEnabled) ? 1 : 0, 1))
            {
                HAlign = 0.5f,
                VAlign = 0.5f,
                IgnoresMouseInteraction = true
            };

            groupOptionButton.Append(element);
            groupOptionButton.OnMouseOver += delegate
            {
                SoundEngine.PlaySound(12);
            };
            groupOptionButton.OnClick += delegate
            {
                SoundEngine.PlaySound(12);
                resourcePack.IsEnabled = !resourcePack.IsEnabled;
                SetResourcePackAsTopPriority(resourcePack);
                PopulatePackList();
                Main.instance.TilePaintSystem.Reset();
            };
            return(groupOptionButton);
        }
示例#3
0
        public static GroupOptionButton <T> CreateCategoryButton <T>(CreativePowerUIElementRequestInfo info, T option, T currentOption) where T : IConvertible, IEquatable <T>
        {
            GroupOptionButton <T> groupOptionButton = new GroupOptionButton <T>(option, null, null, Color.White, null, 0.8f);

            groupOptionButton.Width  = new StyleDimension(info.PreferredButtonWidth, 0f);
            groupOptionButton.Height = new StyleDimension(info.PreferredButtonHeight, 0f);
            groupOptionButton.ShowHighlightWhenSelected = false;
            groupOptionButton.SetCurrentOption(currentOption);
            groupOptionButton.SetColorsBasedOnSelectionState(new Color(152, 175, 235), Colors.InventoryDefaultColor, 1f, 0.7f);
            return(groupOptionButton);
        }
示例#4
0
        public static GroupOptionButton <bool> CreateSimpleButton(CreativePowerUIElementRequestInfo info)
        {
            GroupOptionButton <bool> groupOptionButton = new GroupOptionButton <bool>(option: true, null, null, Color.White, null, 0.8f);

            groupOptionButton.Width  = new StyleDimension(info.PreferredButtonWidth, 0f);
            groupOptionButton.Height = new StyleDimension(info.PreferredButtonHeight, 0f);
            groupOptionButton.ShowHighlightWhenSelected = false;
            groupOptionButton.SetCurrentOption(option: false);
            groupOptionButton.SetColorsBasedOnSelectionState(new Color(152, 175, 235), Colors.InventoryDefaultColor, 1f, 0.7f);
            return(groupOptionButton);
        }
示例#5
0
        public static GroupOptionButton <bool> CreateToggleButton(
            CreativePowerUIElementRequestInfo info)
        {
            GroupOptionButton <bool> groupOptionButton = new GroupOptionButton <bool>(true, (LocalizedText)null, (LocalizedText)null, Color.White, (string)null, 0.8f, 0.5f, 10f);

            groupOptionButton.Width  = new StyleDimension((float)info.PreferredButtonWidth, 0.0f);
            groupOptionButton.Height = new StyleDimension((float)info.PreferredButtonHeight, 0.0f);
            groupOptionButton.ShowHighlightWhenSelected = false;
            groupOptionButton.SetCurrentOption(false);
            groupOptionButton.SetColorsBasedOnSelectionState(new Color(152, 175, 235), Colors.InventoryDefaultColor, 1f, 0.7f);
            groupOptionButton.SetColorsBasedOnSelectionState(Main.OurFavoriteColor, Colors.InventoryDefaultColor, 1f, 0.7f);
            return(groupOptionButton);
        }