/// <summary> /// Initializes the list of discovered resources, accounting for both DLC and Vanilla. /// </summary> private void InitDiscovered() { Type baseType; object instance; // TODO Vanilla/DLC code if ((baseType = PPatchTools.GetTypeSafe("DiscoveredResources")) == null) { // Vanilla baseType = PPatchTools.GetTypeSafe(nameof(WorldInventory)); instance = baseType?.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null, null); } else { // DLC instance = baseType.GetFieldSafe("Instance", true)?.GetValue(null); } #if DEBUG PUtil.LogDebug("Using inventory type: " + (baseType?.Name ?? "None")); #endif if (instance != null) { discovered = baseType.CreateDelegate <ResourceCheckDelegate>( "TryGetDiscoveredResourcesFromTag", instance, typeof(Tag), typeof( HashSet <Tag>).MakeByRefType()); } else { PUtil.LogWarning("Unable to find discovered resource list, no resources will be available to sweep"); } }
public TypeSelectControl(bool disableIcons = false) { discovered = null; DisableIcons = disableIcons; // Select/deselect all types var cp = new PPanel("Categories") { Direction = PanelDirection.Vertical, Alignment = TextAnchor.UpperLeft, Spacing = ROW_SPACING, Margin = ELEMENT_MARGIN, FlexSize = Vector2.right, // Background ensures that scrolling works properly! BackColor = PUITuning.Colors.BackgroundLight }.AddChild(new PCheckBox("SelectAll") { Text = STRINGS.UI.UISIDESCREENS.TREEFILTERABLESIDESCREEN.ALLBUTTON, CheckSize = ROW_SIZE, InitialState = PCheckBox.STATE_CHECKED, OnChecked = OnCheck, TextStyle = PUITuning.Fonts.TextDarkStyle }.AddOnRealize((obj) => allItems = obj)).AddOnRealize((obj) => childPanel = obj); // Scroll to select elements var sp = new PScrollPane("Scroll") { Child = cp, ScrollHorizontal = false, ScrollVertical = true, AlwaysShowVertical = true, TrackSize = 8.0f, FlexSize = Vector2.one }; // Title bar var title = new PLabel("Title") { TextAlignment = TextAnchor.MiddleCenter, Text = SweepByTypeStrings. DIALOG_TITLE, FlexSize = Vector2.right, Margin = TITLE_MARGIN, Sprite = PUITuning.Images.BoxBorder, SpriteMode = Image.Type.Sliced }.SetKleiPinkColor(); // 1px black border on the rest of the dialog for contrast RootPanel = new PRelativePanel("Border") { BackImage = PUITuning.Images.BoxBorder, ImageMode = Image.Type.Sliced, DynamicSize = false, BackColor = PUITuning.Colors.BackgroundLight }.AddChild(sp).AddChild(title).SetMargin(sp, OUTER_MARGIN). SetLeftEdge(title, fraction: 0.0f).SetRightEdge(title, fraction: 1.0f). SetLeftEdge(sp, fraction: 0.0f).SetRightEdge(sp, fraction: 1.0f). SetTopEdge(title, fraction: 1.0f).SetBottomEdge(sp, fraction: 0.0f). SetTopEdge(sp, below: title).Build(); RootPanel.SetMinUISize(PANEL_SIZE); children = new SortedList <Tag, TypeSelectCategory>(16, TagAlphabetComparer. INSTANCE); RootPanel.AddComponent <Canvas>(); RootPanel.AddComponent <TypeSelectScreen>(); RootPanel.SetActive(false); }