Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
        private UIElement CreateOffsetButton(ResourcePack resourcePack, int offset)
        {
            GroupOptionButton <bool> groupOptionButton = new GroupOptionButton <bool>(option: true, null, null, Color.White, null, 0.8f)
            {
                Left   = StyleDimension.FromPercent(0.5f),
                Width  = StyleDimension.FromPixelsAndPercent(0f, 0.5f),
                Height = StyleDimension.Fill
            };
            bool  num       = (offset == -1 && resourcePack.SortingOrder == 0) | (offset == 1 && resourcePack.SortingOrder == _packsList.EnabledPacks.Count() - 1);
            Color lightCyan = Color.LightCyan;

            groupOptionButton.SetColorsBasedOnSelectionState(lightCyan, lightCyan, 0.7f, 0.7f);
            groupOptionButton.ShowHighlightWhenSelected = false;
            groupOptionButton.SetPadding(0f);
            Asset <Texture2D> obj     = Main.Assets.Request <Texture2D>("Images/UI/TexturePackButtons", Main.content, (AssetRequestMode)1);
            UIImageFramed     element = new UIImageFramed(obj, obj.Frame(2, 2, (offset == 1) ? 1 : 0))
            {
                HAlign = 0.5f,
                VAlign = 0.5f,
                IgnoresMouseInteraction = true
            };

            groupOptionButton.Append(element);
            groupOptionButton.OnMouseOver += delegate
            {
                SoundEngine.PlaySound(12);
            };
            int offsetLocalForLambda = offset;

            if (num)
            {
                groupOptionButton.OnClick += delegate
                {
                    SoundEngine.PlaySound(12);
                };
            }
            else
            {
                groupOptionButton.OnClick += delegate
                {
                    SoundEngine.PlaySound(12);
                    OffsetResourcePackPriority(resourcePack, offsetLocalForLambda);
                    PopulatePackList();
                    Main.instance.TilePaintSystem.Reset();
                };
            }
            if (offset == 1)
            {
                groupOptionButton.OnUpdate += OffsetFrontwardUpdate;
            }
            else
            {
                groupOptionButton.OnUpdate += OffsetBackwardUpdate;
            }
            return(groupOptionButton);
        }
Exemplo n.º 4
0
        private UIElement CreateOffsetButton(ResourcePack resourcePack, int offset)
        {
            GroupOptionButton <bool> groupOptionButton1 = new GroupOptionButton <bool>(true, (LocalizedText)null, (LocalizedText)null, Color.White, (string)null, 0.8f, 0.5f, 10f);

            groupOptionButton1.Left   = StyleDimension.FromPercent(0.5f);
            groupOptionButton1.Width  = StyleDimension.FromPixelsAndPercent(0.0f, 0.5f);
            groupOptionButton1.Height = StyleDimension.Fill;
            GroupOptionButton <bool> groupOptionButton2 = groupOptionButton1;
            int   num       = (offset != -1 ? 0 : (resourcePack.SortingOrder == 0 ? 1 : 0)) | (offset != 1 ? 0 : (resourcePack.SortingOrder == this._packsList.EnabledPacks.Count <ResourcePack>() - 1 ? 1 : 0));
            Color lightCyan = Color.LightCyan;

            groupOptionButton2.SetColorsBasedOnSelectionState(lightCyan, lightCyan, 0.7f, 0.7f);
            groupOptionButton2.ShowHighlightWhenSelected = false;
            groupOptionButton2.SetPadding(0.0f);
            Asset <Texture2D> asset          = Main.Assets.Request <Texture2D>("Images/UI/TexturePackButtons", (AssetRequestMode)1);
            UIImageFramed     uiImageFramed1 = new UIImageFramed((Asset <Texture2D>)asset, ((Asset <Texture2D>)asset).Frame(2, 2, offset == 1 ? 1 : 0, 0, 0, 0));

            uiImageFramed1.HAlign = 0.5f;
            uiImageFramed1.VAlign = 0.5f;
            uiImageFramed1.IgnoresMouseInteraction = true;
            UIImageFramed uiImageFramed2 = uiImageFramed1;

            groupOptionButton2.Append((UIElement)uiImageFramed2);
            groupOptionButton2.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => SoundEngine.PlaySound(12, -1, -1, 1, 1f, 0.0f));
            int offsetLocalForLambda = offset;

            if (num != 0)
            {
                groupOptionButton2.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => SoundEngine.PlaySound(12, -1, -1, 1, 1f, 0.0f));
            }
            else
            {
                groupOptionButton2.OnClick += (UIElement.MouseEvent)((evt, listeningElement) =>
                {
                    SoundEngine.PlaySound(12, -1, -1, 1, 1f, 0.0f);
                    this.OffsetResourcePackPriority(resourcePack, offsetLocalForLambda);
                    this.PopulatePackList();
                    Main.instance.TilePaintSystem.Reset();
                });
            }
            if (offset == 1)
            {
                groupOptionButton2.OnUpdate += new UIElement.ElementEvent(this.OffsetFrontwardUpdate);
            }
            else
            {
                groupOptionButton2.OnUpdate += new UIElement.ElementEvent(this.OffsetBackwardUpdate);
            }
            return((UIElement)groupOptionButton2);
        }