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); }
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); }
private List <UIElement> CreateMainPowerStrip() { MenuTree <OpenMainSubCategory> mainCategory = _mainCategory; mainCategory.Buttons.Clear(); List <UIElement> list = new List <UIElement>(); CreativePowerUIElementRequestInfo creativePowerUIElementRequestInfo = default(CreativePowerUIElementRequestInfo); creativePowerUIElementRequestInfo.PreferredButtonWidth = 40; creativePowerUIElementRequestInfo.PreferredButtonHeight = 40; CreativePowerUIElementRequestInfo request = creativePowerUIElementRequestInfo; GroupOptionButton <int> groupOptionButton = CreativePowersHelper.CreateCategoryButton(request, 1, 0); groupOptionButton.Append(CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.ItemDuplication)); groupOptionButton.OnClick += MainCategoryButtonClick; groupOptionButton.OnUpdate += itemsWindowButton_OnUpdate; mainCategory.Buttons.Add(1, groupOptionButton); list.Add(groupOptionButton); GroupOptionButton <int> groupOptionButton2 = CreativePowersHelper.CreateCategoryButton(request, 2, 0); groupOptionButton2.Append(CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.ItemResearch)); groupOptionButton2.OnClick += MainCategoryButtonClick; groupOptionButton2.OnUpdate += researchWindowButton_OnUpdate; mainCategory.Buttons.Add(2, groupOptionButton2); list.Add(groupOptionButton2); GroupOptionButton <int> groupOptionButton3 = CreativePowersHelper.CreateCategoryButton(request, 3, 0); groupOptionButton3.Append(CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.TimeCategory)); groupOptionButton3.OnClick += MainCategoryButtonClick; groupOptionButton3.OnUpdate += timeCategoryButton_OnUpdate; mainCategory.Buttons.Add(3, groupOptionButton3); list.Add(groupOptionButton3); GroupOptionButton <int> groupOptionButton4 = CreativePowersHelper.CreateCategoryButton(request, 4, 0); groupOptionButton4.Append(CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.WeatherCategory)); groupOptionButton4.OnClick += MainCategoryButtonClick; groupOptionButton4.OnUpdate += weatherCategoryButton_OnUpdate; mainCategory.Buttons.Add(4, groupOptionButton4); list.Add(groupOptionButton4); GroupOptionButton <int> groupOptionButton5 = CreativePowersHelper.CreateCategoryButton(request, 6, 0); groupOptionButton5.Append(CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.PersonalCategory)); groupOptionButton5.OnClick += MainCategoryButtonClick; groupOptionButton5.OnUpdate += personalCategoryButton_OnUpdate; mainCategory.Buttons.Add(6, groupOptionButton5); list.Add(groupOptionButton5); CreativePowerManager.Instance.GetPower <CreativePowers.StopBiomeSpreadPower>().ProvidePowerButtons(request, list); GroupOptionButton <int> groupOptionButton6 = CreateSubcategoryButton <CreativePowers.DifficultySliderPower>(ref request, 1, "strip 1", 5, 0, mainCategory.Buttons, mainCategory.Sliders); groupOptionButton6.OnClick += MainCategoryButtonClick; list.Add(groupOptionButton6); return(list); }
private List <UIElement> CreateMainPowerStrip() { UICreativePowersMenu.MenuTree <UICreativePowersMenu.OpenMainSubCategory> mainCategory = this._mainCategory; mainCategory.Buttons.Clear(); List <UIElement> elements = new List <UIElement>(); CreativePowerUIElementRequestInfo request = new CreativePowerUIElementRequestInfo() { PreferredButtonWidth = 40, PreferredButtonHeight = 40 }; GroupOptionButton <int> categoryButton1 = CreativePowersHelper.CreateCategoryButton <int>(request, 1, 0); categoryButton1.Append((UIElement)CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.ItemDuplication)); categoryButton1.OnClick += new UIElement.MouseEvent(this.MainCategoryButtonClick); categoryButton1.OnUpdate += new UIElement.ElementEvent(this.itemsWindowButton_OnUpdate); mainCategory.Buttons.Add(1, categoryButton1); elements.Add((UIElement)categoryButton1); GroupOptionButton <int> categoryButton2 = CreativePowersHelper.CreateCategoryButton <int>(request, 2, 0); categoryButton2.Append((UIElement)CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.ItemResearch)); categoryButton2.OnClick += new UIElement.MouseEvent(this.MainCategoryButtonClick); categoryButton2.OnUpdate += new UIElement.ElementEvent(this.researchWindowButton_OnUpdate); mainCategory.Buttons.Add(2, categoryButton2); elements.Add((UIElement)categoryButton2); GroupOptionButton <int> categoryButton3 = CreativePowersHelper.CreateCategoryButton <int>(request, 3, 0); categoryButton3.Append((UIElement)CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.TimeCategory)); categoryButton3.OnClick += new UIElement.MouseEvent(this.MainCategoryButtonClick); categoryButton3.OnUpdate += new UIElement.ElementEvent(this.timeCategoryButton_OnUpdate); mainCategory.Buttons.Add(3, categoryButton3); elements.Add((UIElement)categoryButton3); GroupOptionButton <int> categoryButton4 = CreativePowersHelper.CreateCategoryButton <int>(request, 4, 0); categoryButton4.Append((UIElement)CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.WeatherCategory)); categoryButton4.OnClick += new UIElement.MouseEvent(this.MainCategoryButtonClick); categoryButton4.OnUpdate += new UIElement.ElementEvent(this.weatherCategoryButton_OnUpdate); mainCategory.Buttons.Add(4, categoryButton4); elements.Add((UIElement)categoryButton4); GroupOptionButton <int> categoryButton5 = CreativePowersHelper.CreateCategoryButton <int>(request, 6, 0); categoryButton5.Append((UIElement)CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.PersonalCategory)); categoryButton5.OnClick += new UIElement.MouseEvent(this.MainCategoryButtonClick); categoryButton5.OnUpdate += new UIElement.ElementEvent(this.personalCategoryButton_OnUpdate); mainCategory.Buttons.Add(6, categoryButton5); elements.Add((UIElement)categoryButton5); CreativePowerManager.Instance.GetPower <CreativePowers.StopBiomeSpreadPower>().ProvidePowerButtons(request, elements); GroupOptionButton <int> subcategoryButton = this.CreateSubcategoryButton <CreativePowers.DifficultySliderPower>(ref request, 1, "strip 1", 5, 0, mainCategory.Buttons, mainCategory.Sliders); subcategoryButton.OnClick += new UIElement.MouseEvent(this.MainCategoryButtonClick); elements.Add((UIElement)subcategoryButton); return(elements); }
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); }