forked from Shardstone/trail-into-darkness
Made the popup system a lot more generic
This commit is contained in:
@@ -24,12 +24,33 @@ namespace Jovian.PopupSystem {
|
||||
public float touchHoldDuration = 0.6f;
|
||||
public bool gamepadFocusTrigger = true;
|
||||
|
||||
[Header("Element Prefabs")]
|
||||
public List<PopupElementEntry> elementPrefabs = new();
|
||||
|
||||
[Header("Priority")]
|
||||
public List<CategoryPriority> categoryPriorities = new();
|
||||
|
||||
[Header("Per-Category Overrides")]
|
||||
public List<CategoryDelay> categoryDelayOverrides = new();
|
||||
|
||||
private Dictionary<PopupElementType, GameObject> prefabLookup;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the element prefab registered under the given type, or null if not found.
|
||||
/// </summary>
|
||||
public GameObject GetPrefab(PopupElementType elementType) {
|
||||
if(prefabLookup == null) {
|
||||
prefabLookup = new Dictionary<PopupElementType, GameObject>();
|
||||
foreach(var entry in elementPrefabs) {
|
||||
if(!string.IsNullOrEmpty(entry.type.Id) && entry.prefab != null) {
|
||||
prefabLookup[entry.type] = entry.prefab;
|
||||
}
|
||||
}
|
||||
}
|
||||
prefabLookup.TryGetValue(elementType, out var result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the configured priority for a category, or 0 if not configured.
|
||||
/// </summary>
|
||||
@@ -55,6 +76,12 @@ namespace Jovian.PopupSystem {
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class PopupElementEntry {
|
||||
public PopupElementType type;
|
||||
public GameObject prefab;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class CategoryPriority {
|
||||
public PopupCategory category;
|
||||
|
||||
Reference in New Issue
Block a user