Example #1
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);
        }
Example #2
0
 private void AddWorldDifficultyOptions(
     UIElement container,
     float accumualtedHeight,
     UIElement.MouseEvent clickEvent,
     string tagGroup,
     float usableWidthPercent)
 {
     UIWorldCreation.WorldDifficultyId[] worldDifficultyIdArray = new UIWorldCreation.WorldDifficultyId[4]
     {
         UIWorldCreation.WorldDifficultyId.Creative,
         UIWorldCreation.WorldDifficultyId.Normal,
         UIWorldCreation.WorldDifficultyId.Expert,
         UIWorldCreation.WorldDifficultyId.Master
     };
     LocalizedText[] localizedTextArray1 = new LocalizedText[4]
     {
         Language.GetText("UI.Creative"),
         Language.GetText("UI.Normal"),
         Language.GetText("UI.Expert"),
         Language.GetText("UI.Master")
     };
     LocalizedText[] localizedTextArray2 = new LocalizedText[4]
     {
         Language.GetText("UI.WorldDescriptionCreative"),
         Language.GetText("UI.WorldDescriptionNormal"),
         Language.GetText("UI.WorldDescriptionExpert"),
         Language.GetText("UI.WorldDescriptionMaster")
     };
     Color[] colorArray = new Color[4]
     {
         Main.creativeModeColor,
         Color.White,
         Main.mcColor,
         Main.hcColor
     };
     string[] strArray = new string[4]
     {
         "Images/UI/WorldCreation/IconDifficultyCreative",
         "Images/UI/WorldCreation/IconDifficultyNormal",
         "Images/UI/WorldCreation/IconDifficultyExpert",
         "Images/UI/WorldCreation/IconDifficultyMaster"
     };
     GroupOptionButton <UIWorldCreation.WorldDifficultyId>[] groupOptionButtonArray = new GroupOptionButton <UIWorldCreation.WorldDifficultyId> [worldDifficultyIdArray.Length];
     for (int id = 0; id < groupOptionButtonArray.Length; ++id)
     {
         GroupOptionButton <UIWorldCreation.WorldDifficultyId> groupOptionButton = new GroupOptionButton <UIWorldCreation.WorldDifficultyId>(worldDifficultyIdArray[id], localizedTextArray1[id], localizedTextArray2[id], colorArray[id], strArray[id], 1f, 1f, 16f);
         groupOptionButton.Width  = StyleDimension.FromPixelsAndPercent((float)(-1 * (groupOptionButtonArray.Length - 1)), 1f / (float)groupOptionButtonArray.Length * usableWidthPercent);
         groupOptionButton.Left   = StyleDimension.FromPercent(1f - usableWidthPercent);
         groupOptionButton.HAlign = (float)id / (float)(groupOptionButtonArray.Length - 1);
         groupOptionButton.Top.Set(accumualtedHeight, 0.0f);
         groupOptionButton.OnMouseDown += clickEvent;
         groupOptionButton.OnMouseOver += new UIElement.MouseEvent(this.ShowOptionDescription);
         groupOptionButton.OnMouseOut  += new UIElement.MouseEvent(this.ClearOptionDescription);
         groupOptionButton.SetSnapPoint(tagGroup, id, new Vector2?(), new Vector2?());
         container.Append((UIElement)groupOptionButton);
         groupOptionButtonArray[id] = groupOptionButton;
     }
     this._difficultyButtons = groupOptionButtonArray;
 }
        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);
        }
Example #4
0
        private static void AddHorizontalSeparator(UIElement Container, float accumualtedHeight)
        {
            UIHorizontalSeparator element = new UIHorizontalSeparator
            {
                Width = StyleDimension.FromPercent(1f),
                Top   = StyleDimension.FromPixels(accumualtedHeight - 8f),
                Color = Color.Lerp(Color.White, new Color(63, 65, 151, 255), 0.85f) * 0.9f
            };

            Container.Append(element);
        }
Example #5
0
 private void AddWorldEvilOptions(
     UIElement container,
     float accumualtedHeight,
     UIElement.MouseEvent clickEvent,
     string tagGroup,
     float usableWidthPercent)
 {
     UIWorldCreation.WorldEvilId[] worldEvilIdArray = new UIWorldCreation.WorldEvilId[3]
     {
         UIWorldCreation.WorldEvilId.Random,
         UIWorldCreation.WorldEvilId.Corruption,
         UIWorldCreation.WorldEvilId.Crimson
     };
     LocalizedText[] localizedTextArray1 = new LocalizedText[3]
     {
         Lang.misc[103],
         Lang.misc[101],
         Lang.misc[102]
     };
     LocalizedText[] localizedTextArray2 = new LocalizedText[3]
     {
         Language.GetText("UI.WorldDescriptionEvilRandom"),
         Language.GetText("UI.WorldDescriptionEvilCorrupt"),
         Language.GetText("UI.WorldDescriptionEvilCrimson")
     };
     Color[] colorArray = new Color[3]
     {
         Color.White,
         Color.MediumPurple,
         Color.IndianRed
     };
     string[] strArray = new string[3]
     {
         "Images/UI/WorldCreation/IconEvilRandom",
         "Images/UI/WorldCreation/IconEvilCorruption",
         "Images/UI/WorldCreation/IconEvilCrimson"
     };
     GroupOptionButton <UIWorldCreation.WorldEvilId>[] groupOptionButtonArray = new GroupOptionButton <UIWorldCreation.WorldEvilId> [worldEvilIdArray.Length];
     for (int id = 0; id < groupOptionButtonArray.Length; ++id)
     {
         GroupOptionButton <UIWorldCreation.WorldEvilId> groupOptionButton = new GroupOptionButton <UIWorldCreation.WorldEvilId>(worldEvilIdArray[id], localizedTextArray1[id], localizedTextArray2[id], colorArray[id], strArray[id], 1f, 1f, 16f);
         groupOptionButton.Width  = StyleDimension.FromPixelsAndPercent((float)(-4 * (groupOptionButtonArray.Length - 1)), 1f / (float)groupOptionButtonArray.Length * usableWidthPercent);
         groupOptionButton.Left   = StyleDimension.FromPercent(1f - usableWidthPercent);
         groupOptionButton.HAlign = (float)id / (float)(groupOptionButtonArray.Length - 1);
         groupOptionButton.Top.Set(accumualtedHeight, 0.0f);
         groupOptionButton.OnMouseDown += clickEvent;
         groupOptionButton.OnMouseOver += new UIElement.MouseEvent(this.ShowOptionDescription);
         groupOptionButton.OnMouseOut  += new UIElement.MouseEvent(this.ClearOptionDescription);
         groupOptionButton.SetSnapPoint(tagGroup, id, new Vector2?(), new Vector2?());
         container.Append((UIElement)groupOptionButton);
         groupOptionButtonArray[id] = groupOptionButton;
     }
     this._evilButtons = groupOptionButtonArray;
 }
Example #6
0
 private void AddWorldSizeOptions(
     UIElement container,
     float accumualtedHeight,
     UIElement.MouseEvent clickEvent,
     string tagGroup,
     float usableWidthPercent)
 {
     UIWorldCreation.WorldSizeId[] worldSizeIdArray = new UIWorldCreation.WorldSizeId[3]
     {
         UIWorldCreation.WorldSizeId.Small,
         UIWorldCreation.WorldSizeId.Medium,
         UIWorldCreation.WorldSizeId.Large
     };
     LocalizedText[] localizedTextArray1 = new LocalizedText[3]
     {
         Lang.menu[92],
         Lang.menu[93],
         Lang.menu[94]
     };
     LocalizedText[] localizedTextArray2 = new LocalizedText[3]
     {
         Language.GetText("UI.WorldDescriptionSizeSmall"),
         Language.GetText("UI.WorldDescriptionSizeMedium"),
         Language.GetText("UI.WorldDescriptionSizeLarge")
     };
     Color[] colorArray = new Color[3]
     {
         Color.Cyan,
         Color.Lerp(Color.Cyan, Color.LimeGreen, 0.5f),
         Color.LimeGreen
     };
     string[] strArray = new string[3]
     {
         "Images/UI/WorldCreation/IconSizeSmall",
         "Images/UI/WorldCreation/IconSizeMedium",
         "Images/UI/WorldCreation/IconSizeLarge"
     };
     GroupOptionButton <UIWorldCreation.WorldSizeId>[] groupOptionButtonArray = new GroupOptionButton <UIWorldCreation.WorldSizeId> [worldSizeIdArray.Length];
     for (int id = 0; id < groupOptionButtonArray.Length; ++id)
     {
         GroupOptionButton <UIWorldCreation.WorldSizeId> groupOptionButton = new GroupOptionButton <UIWorldCreation.WorldSizeId>(worldSizeIdArray[id], localizedTextArray1[id], localizedTextArray2[id], colorArray[id], strArray[id], 1f, 1f, 16f);
         groupOptionButton.Width  = StyleDimension.FromPixelsAndPercent((float)(-4 * (groupOptionButtonArray.Length - 1)), 1f / (float)groupOptionButtonArray.Length * usableWidthPercent);
         groupOptionButton.Left   = StyleDimension.FromPercent(1f - usableWidthPercent);
         groupOptionButton.HAlign = (float)id / (float)(groupOptionButtonArray.Length - 1);
         groupOptionButton.Top.Set(accumualtedHeight, 0.0f);
         groupOptionButton.OnMouseDown += clickEvent;
         groupOptionButton.OnMouseOver += new UIElement.MouseEvent(this.ShowOptionDescription);
         groupOptionButton.OnMouseOut  += new UIElement.MouseEvent(this.ClearOptionDescription);
         groupOptionButton.SetSnapPoint(tagGroup, id, new Vector2?(), new Vector2?());
         container.Append((UIElement)groupOptionButton);
         groupOptionButtonArray[id] = groupOptionButton;
     }
     this._sizeButtons = groupOptionButtonArray;
 }
Example #7
0
        private static void AddHorizontalSeparator(UIElement Container, float accumualtedHeight)
        {
            UIHorizontalSeparator horizontalSeparator1 = new UIHorizontalSeparator(2, true);

            horizontalSeparator1.Width = StyleDimension.FromPercent(1f);
            horizontalSeparator1.Top   = StyleDimension.FromPixels(accumualtedHeight - 8f);
            horizontalSeparator1.Color = Color.Lerp(Color.White, new Color(63, 65, 151, (int)byte.MaxValue), 0.85f) * 0.9f;
            UIHorizontalSeparator horizontalSeparator2 = horizontalSeparator1;

            Container.Append((UIElement)horizontalSeparator2);
        }
Example #8
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);
        }
Example #9
0
 private void AddWorldSizeOptions(UIElement container, float accumualtedHeight, MouseEvent clickEvent, string tagGroup, float usableWidthPercent)
 {
     WorldSizeId[] array = new WorldSizeId[3]
     {
         WorldSizeId.Small,
         WorldSizeId.Medium,
         WorldSizeId.Large
     };
     LocalizedText[] array2 = new LocalizedText[3]
     {
         Lang.menu[92],
         Lang.menu[93],
         Lang.menu[94]
     };
     LocalizedText[] array3 = new LocalizedText[3]
     {
         Language.GetText("UI.WorldDescriptionSizeSmall"),
         Language.GetText("UI.WorldDescriptionSizeMedium"),
         Language.GetText("UI.WorldDescriptionSizeLarge")
     };
     Color[] array4 = new Color[3]
     {
         Color.Cyan,
         Color.Lerp(Color.Cyan, Color.LimeGreen, 0.5f),
         Color.LimeGreen
     };
     string[] array5 = new string[3]
     {
         "Images/UI/WorldCreation/IconSizeSmall",
         "Images/UI/WorldCreation/IconSizeMedium",
         "Images/UI/WorldCreation/IconSizeLarge"
     };
     GroupOptionButton <WorldSizeId>[] array6 = new GroupOptionButton <WorldSizeId> [array.Length];
     for (int i = 0; i < array6.Length; i++)
     {
         GroupOptionButton <WorldSizeId> groupOptionButton = new GroupOptionButton <WorldSizeId>(array[i], array2[i], array3[i], array4[i], array5[i], 1f, 1f, 16f);
         groupOptionButton.Width  = StyleDimension.FromPixelsAndPercent(-4 * (array6.Length - 1), 1f / (float)array6.Length * usableWidthPercent);
         groupOptionButton.Left   = StyleDimension.FromPercent(1f - usableWidthPercent);
         groupOptionButton.HAlign = (float)i / (float)(array6.Length - 1);
         groupOptionButton.Top.Set(accumualtedHeight, 0f);
         groupOptionButton.OnMouseDown += clickEvent;
         groupOptionButton.OnMouseOver += ShowOptionDescription;
         groupOptionButton.OnMouseOut  += ClearOptionDescription;
         groupOptionButton.SetSnapPoint(tagGroup, i);
         container.Append(groupOptionButton);
         array6[i] = groupOptionButton;
     }
     _sizeButtons = array6;
 }
Example #10
0
 public UIResourcePack(ResourcePack pack, int order)
 {
     ResourcePack    = pack;
     Order           = order;
     BackgroundColor = DefaultBackgroundColor;
     BorderColor     = DefaultBorderColor;
     Height          = StyleDimension.FromPixels(102f);
     MinHeight       = Height;
     MaxHeight       = Height;
     MinWidth        = StyleDimension.FromPixels(102f);
     Width           = StyleDimension.FromPercent(1f);
     SetPadding(5f);
     _iconBorderTexture = Main.Assets.Request <Texture2D>("Images/UI/Achievement_Borders", Main.content, (AssetRequestMode)1);
     OverflowHidden     = true;
     BuildChildren();
 }
Example #11
0
 public UIResourcePack(ResourcePack pack, int order)
 {
     this.ResourcePack    = pack;
     this.Order           = order;
     this.BackgroundColor = UIResourcePack.DefaultBackgroundColor;
     this.BorderColor     = UIResourcePack.DefaultBorderColor;
     this.Height          = StyleDimension.FromPixels(102f);
     this.MinHeight       = this.Height;
     this.MaxHeight       = this.Height;
     this.MinWidth        = StyleDimension.FromPixels(102f);
     this.Width           = StyleDimension.FromPercent(1f);
     this.SetPadding(5f);
     this._iconBorderTexture = (Asset <Texture2D>)Main.Assets.Request <Texture2D>("Images/UI/Achievement_Borders", (AssetRequestMode)1);
     this.OverflowHidden     = true;
     this.BuildChildren();
 }
Example #12
0
        private void BuildPage()
        {
            int num = 18;

            this.RemoveAllChildren();
            UIElement uiElement1 = new UIElement()
            {
                Width  = StyleDimension.FromPixels(500f),
                Height = StyleDimension.FromPixels(434f + (float)num),
                Top    = StyleDimension.FromPixels(170f - (float)num),
                HAlign = 0.5f,
                VAlign = 0.0f
            };

            uiElement1.SetPadding(0.0f);
            this.Append(uiElement1);
            UIPanel uiPanel1 = new UIPanel();

            uiPanel1.Width           = StyleDimension.FromPercent(1f);
            uiPanel1.Height          = StyleDimension.FromPixels((float)(280 + num));
            uiPanel1.Top             = StyleDimension.FromPixels(50f);
            uiPanel1.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            UIPanel uiPanel2 = uiPanel1;

            uiPanel2.SetPadding(0.0f);
            uiElement1.Append((UIElement)uiPanel2);
            this.MakeBackAndCreatebuttons(uiElement1);
            UIElement uiElement2 = new UIElement()
            {
                Top    = StyleDimension.FromPixelsAndPercent(0.0f, 0.0f),
                Width  = StyleDimension.FromPixelsAndPercent(0.0f, 1f),
                Height = StyleDimension.FromPixelsAndPercent(0.0f, 1f),
                HAlign = 1f
            };

            uiElement2.SetPadding(0.0f);
            uiElement2.PaddingTop    = 8f;
            uiElement2.PaddingBottom = 12f;
            uiPanel2.Append(uiElement2);
            this.MakeInfoMenu(uiElement2);
        }