public void UpdateAvailability() { GetDisplaySettings(out int widthPerButton, out int heightPerButton, out int widthWithSpacing, out int heightWithSpacing, out int perRow, out float offsetLeft, out float offsetTop, out int _); _container.RemoveAllChildren(); _filterButtons.Clear(); _areFiltersAvailable.Clear(); int num = -1; int num2 = -1; for (int i = 0; i < _filterer.AvailableFilters.Count; i++) { int num3 = i / perRow; int num4 = i % perRow; IBestiaryEntryFilter bestiaryEntryFilter = _filterer.AvailableFilters[i]; List <BestiaryEntry> entries = _filterAvailabilityTests[i]; if (GetIsFilterAvailableForEntries(bestiaryEntryFilter, entries)) { GroupOptionButton <int> groupOptionButton = new GroupOptionButton <int>(i, null, null, Color.White, null) { Width = new StyleDimension(widthPerButton, 0f), Height = new StyleDimension(heightPerButton, 0f), HAlign = 0f, VAlign = 0f, Top = new StyleDimension(offsetTop + (float)(num3 * heightWithSpacing), 0f), Left = new StyleDimension(offsetLeft + (float)(num4 * widthWithSpacing), 0f) }; groupOptionButton.OnClick += ClickOption; groupOptionButton.SetSnapPoint("Filters", i); groupOptionButton.ShowHighlightWhenSelected = false; AddOnHover(bestiaryEntryFilter, groupOptionButton); _container.Append(groupOptionButton); UIElement image = bestiaryEntryFilter.GetImage(); if (image != null) { image.Left = new StyleDimension(num, 0f); image.Top = new StyleDimension(num2, 0f); groupOptionButton.Append(image); } _filterButtons.Add(groupOptionButton); } else { _filterer.ActiveFilters.Remove(bestiaryEntryFilter); GroupOptionButton <int> groupOptionButton2 = new GroupOptionButton <int>(-2, null, null, Color.White, null) { Width = new StyleDimension(widthPerButton, 0f), Height = new StyleDimension(heightPerButton, 0f), HAlign = 0f, VAlign = 0f, Top = new StyleDimension(offsetTop + (float)(num3 * heightWithSpacing), 0f), Left = new StyleDimension(offsetLeft + (float)(num4 * widthWithSpacing), 0f), FadeFromBlack = 0.5f }; groupOptionButton2.ShowHighlightWhenSelected = false; groupOptionButton2.SetPadding(0f); groupOptionButton2.SetSnapPoint("Filters", i); Asset <Texture2D> obj = Main.Assets.Request <Texture2D>("Images/UI/Bestiary/Icon_Tags_Shadow", (AssetRequestMode)1); UIImageFramed uIImageFramed = new UIImageFramed(obj, obj.Frame(16, 5, 0, 4)) { HAlign = 0.5f, VAlign = 0.5f, Color = Color.White * 0.2f }; uIImageFramed.Left = new StyleDimension(num, 0f); uIImageFramed.Top = new StyleDimension(num2, 0f); groupOptionButton2.Append(uIImageFramed); _filterButtons.Add(groupOptionButton2); _container.Append(groupOptionButton2); } } UpdateButtonSelections(); }
public void UpdateAvailability() { int widthPerButton; int heightPerButton; int widthWithSpacing; int heightWithSpacing; int perRow; float offsetLeft; float offsetTop; this.GetDisplaySettings(out widthPerButton, out heightPerButton, out widthWithSpacing, out heightWithSpacing, out perRow, out offsetLeft, out offsetTop, out int _); this._container.RemoveAllChildren(); this._filterButtons.Clear(); this._areFiltersAvailable.Clear(); int num1 = -1; int num2 = -1; for (int index = 0; index < this._filterer.AvailableFilters.Count; ++index) { int num3 = index / perRow; int num4 = index % perRow; IBestiaryEntryFilter availableFilter = this._filterer.AvailableFilters[index]; List <BestiaryEntry> availabilityTest = this._filterAvailabilityTests[index]; if (this.GetIsFilterAvailableForEntries(availableFilter, availabilityTest)) { GroupOptionButton <int> groupOptionButton1 = new GroupOptionButton <int>(index, (LocalizedText)null, (LocalizedText)null, Color.White, (string)null, 1f, 0.5f, 10f); groupOptionButton1.Width = new StyleDimension((float)widthPerButton, 0.0f); groupOptionButton1.Height = new StyleDimension((float)heightPerButton, 0.0f); groupOptionButton1.HAlign = 0.0f; groupOptionButton1.VAlign = 0.0f; groupOptionButton1.Top = new StyleDimension(offsetTop + (float)(num3 * heightWithSpacing), 0.0f); groupOptionButton1.Left = new StyleDimension(offsetLeft + (float)(num4 * widthWithSpacing), 0.0f); GroupOptionButton <int> groupOptionButton2 = groupOptionButton1; groupOptionButton2.OnClick += new UIElement.MouseEvent(this.ClickOption); groupOptionButton2.SetSnapPoint("Filters", index, new Vector2?(), new Vector2?()); groupOptionButton2.ShowHighlightWhenSelected = false; this.AddOnHover(availableFilter, (UIElement)groupOptionButton2); this._container.Append((UIElement)groupOptionButton2); UIElement image = availableFilter.GetImage(); if (image != null) { image.Left = new StyleDimension((float)num1, 0.0f); image.Top = new StyleDimension((float)num2, 0.0f); groupOptionButton2.Append(image); } this._filterButtons.Add(groupOptionButton2); } else { this._filterer.ActiveFilters.Remove(availableFilter); GroupOptionButton <int> groupOptionButton1 = new GroupOptionButton <int>(-2, (LocalizedText)null, (LocalizedText)null, Color.White, (string)null, 1f, 0.5f, 10f); groupOptionButton1.Width = new StyleDimension((float)widthPerButton, 0.0f); groupOptionButton1.Height = new StyleDimension((float)heightPerButton, 0.0f); groupOptionButton1.HAlign = 0.0f; groupOptionButton1.VAlign = 0.0f; groupOptionButton1.Top = new StyleDimension(offsetTop + (float)(num3 * heightWithSpacing), 0.0f); groupOptionButton1.Left = new StyleDimension(offsetLeft + (float)(num4 * widthWithSpacing), 0.0f); groupOptionButton1.FadeFromBlack = 0.5f; GroupOptionButton <int> groupOptionButton2 = groupOptionButton1; groupOptionButton2.ShowHighlightWhenSelected = false; groupOptionButton2.SetPadding(0.0f); groupOptionButton2.SetSnapPoint("Filters", index, new Vector2?(), new Vector2?()); Asset <M0> asset = Main.Assets.Request <Texture2D>("Images/UI/Bestiary/Icon_Tags_Shadow", (AssetRequestMode)1); UIImageFramed uiImageFramed1 = new UIImageFramed((Asset <Texture2D>)asset, ((Asset <Texture2D>)asset).Frame(16, 5, 0, 4, 0, 0)); uiImageFramed1.HAlign = 0.5f; uiImageFramed1.VAlign = 0.5f; uiImageFramed1.Color = Color.White * 0.2f; UIImageFramed uiImageFramed2 = uiImageFramed1; uiImageFramed2.Left = new StyleDimension((float)num1, 0.0f); uiImageFramed2.Top = new StyleDimension((float)num2, 0.0f); groupOptionButton2.Append((UIElement)uiImageFramed2); this._filterButtons.Add(groupOptionButton2); this._container.Append((UIElement)groupOptionButton2); } } this.UpdateButtonSelections(); }