public void UpdateValue() { SetName(Resource.ProperName()); bool allowInsufficientMaterialBuild = GenericGameSettings.instance.allowInsufficientMaterialBuild; GetAmounts(allowInsufficientMaterialBuild, out float available, out float total, out float reserved); if (currentQuantity != available) { currentQuantity = available; QuantityLabel.text = ResourceCategoryScreen.QuantityTextForMeasure(available, Measure); } Color color = AvailableColor; if (reserved > total) { color = OverdrawnColor; } else if (available == 0f) { color = UnavailableColor; } if (QuantityLabel.color != color) { QuantityLabel.color = color; } if (NameLabel.color != color) { NameLabel.color = color; } }
private string OnTooltip() { GetAmounts(true, out float available, out float total, out float reserved); string str = elements.LabelText.text + "\n"; return(str + string.Format(UI.RESOURCESCREEN.AVAILABLE_TOOLTIP, ResourceCategoryScreen.QuantityTextForMeasure(available, Measure), ResourceCategoryScreen.QuantityTextForMeasure(reserved, Measure), ResourceCategoryScreen.QuantityTextForMeasure(total, Measure))); }
/// <summary> /// Applied after OnActivate runs. /// </summary> /// <param name="__instance">The current resource category list.</param> /// <param name="___Prefab_CategoryBar">The category bar prefab used to create categories.</param> internal static void Postfix(ResourceCategoryScreen __instance, GameObject ___Prefab_CategoryBar) { critterTame = CritterResourceHeader.Create(__instance, ___Prefab_CategoryBar, CritterType.Tame); critterWild = CritterResourceHeader.Create(__instance, ___Prefab_CategoryBar, CritterType.Wild); }
/// <summary> /// Applied after Update runs. /// </summary> internal static void Postfix(ResourceCategoryScreen __instance) { var headers = __instance.GetComponent <CritterHeaders>(); if (ClusterManager.Instance.activeWorld.worldInventory != null && headers != null) { headers.UpdateContents(); } }
/// <summary> /// Applied after OnActivate runs. /// </summary> internal static void Postfix(ResourceCategoryScreen __instance, GameObject ___Prefab_CategoryBar) { var headers = __instance.gameObject.AddOrGet <CritterHeaders>(); foreach (var type in Enum.GetValues(typeof(CritterType))) { if (type is CritterType ct) { headers.Create(__instance, ___Prefab_CategoryBar, ct); } } }
protected override void OnActivate() { base.OnActivate(); Instance = this; ConsumeMouseScroll = true; MultiToggle hiderButton = HiderButton; hiderButton.onClick = (System.Action)Delegate.Combine(hiderButton.onClick, new System.Action(OnHiderClick)); CreateTagSetHeaders(GameTags.MaterialCategories, GameUtil.MeasureUnit.mass); CreateTagSetHeaders(GameTags.CalorieCategories, GameUtil.MeasureUnit.kcal); CreateTagSetHeaders(GameTags.UnitCategories, GameUtil.MeasureUnit.quantity); if (!DisplayedCategories.ContainsKey(GameTags.Miscellaneous)) { ResourceCategoryHeader value = NewCategoryHeader(GameTags.Miscellaneous, GameUtil.MeasureUnit.mass); DisplayedCategories.Add(GameTags.Miscellaneous, value); } DisplayedCategoryKeys = DisplayedCategories.Keys.ToArray(); }
/// <summary> /// Creates a resource category header for critters. /// </summary> /// <param name="resList">The parent category screen for this header.</param> /// <param name="prefab">The prefab to use for creating the headers.</param> /// <param name="type">The critter type to create.</param> internal void Create(ResourceCategoryScreen resList, GameObject prefab, CritterType type) { var tag = GameTags.BagableCreature; // Create a heading for Critter (Type) PUtil.LogDebug("Creating Critter ({0}) category".F(type.GetProperName())); var gameObject = Util.KInstantiateUI(prefab, resList.CategoryContainer.gameObject, false); gameObject.name = "CategoryHeader_{0}_{1}".F(tag.Name, type.ToString()); var header = gameObject.GetComponent <ResourceCategoryHeader>(); header.SetTag(tag, GameUtil.MeasureUnit.quantity); // Tag it with a wild/tame tag header.gameObject.AddComponent <CritterResourceHeader>().CritterType = type; header.elements.LabelText.SetText(CritterInventoryUtils.GetTitle(tag, type)); headers.Add(header); }
/// <summary> /// Creates a resource category header for critters. /// </summary> /// <param name="resList">The parent category screen for this header.</param> /// <param name="prefab">The prefab to use for creating the headers.</param> /// <param name="type">The critter type to create.</param> /// <returns>The heading for that critter type.</returns> public static ResourceCategoryHeader Create(ResourceCategoryScreen resList, GameObject prefab, CritterType type) { var tag = GameTags.BagableCreature; string typeStr = type.GetDescription(); // Create a heading for Critter (Type) PUtil.LogDebug("Creating Critter ({0}) category".F(typeStr)); var gameObject = Util.KInstantiateUI(prefab, resList.CategoryContainer.gameObject, false); gameObject.name = "CategoryHeader_{0}_{1}".F(tag.Name, type.ToString()); var header = gameObject.GetComponent <ResourceCategoryHeader>(); header.SetTag(tag, GameUtil.MeasureUnit.quantity); // Tag it with a wild/tame tag header.gameObject.AddComponent <CritterResourceInfo>().CritterType = type; header.elements.LabelText.SetText("{0} ({1})".F(tag.ProperName(), typeStr)); return(header); }
public static void Postfix(ResourceCategoryScreen __instance) { // Create Favorites tag Tag favoritesTag = TagManager.Create("Favorites", "Favorites"); // Create Favorites Header var createTagSetHeaders = Traverse.Create(__instance).Method("CreateTagSetHeaders", new[] { typeof(IEnumerable <Tag>), typeof(GameUtil.MeasureUnit) }); createTagSetHeaders.GetValue(new TagSet { favoritesTag }, GameUtil.MeasureUnit.mass); // reset DisplayedCategories, so Favorites is displayed var displayedCategoryKeys = Traverse.Create(__instance).Field("DisplayedCategoryKeys"); displayedCategoryKeys.SetValue(__instance.DisplayedCategories.Keys.ToArray <Tag>()); // keep our instance of favoritesCategoryHeader saved __instance.DisplayedCategories.TryGetValue(favoritesTag, out favoritesCategoryHeader); // move Favorites to the top of the list favoritesCategoryHeader.transform.SetAsFirstSibling(); }
public static void DestroyInstance() { Instance = null; }