netfishing/ui/logbook_catalog.gd

51 lines
1.3 KiB
GDScript3
Raw Normal View History

2026-07-30 23:16:28 -04:00
class_name LogbookCatalog
extends RefCounted
const FishDataType = preload("res://fish/fish_data.gd")
2026-08-02 09:57:05 -04:00
static func category_for(fish: FishDataType) -> WaterType.Type:
2026-07-30 23:16:28 -04:00
if fish == null:
return WaterType.Type.OTHER
return fish.get_primary_water_type()
2026-07-30 23:16:28 -04:00
static func category_label(category: WaterType.Type) -> String:
return WaterType.label(category)
2026-07-30 23:16:28 -04:00
static func empty_state(category: WaterType.Type) -> String:
2026-07-30 23:16:28 -04:00
match category:
WaterType.Type.FRESH_WATER:
2026-07-30 23:16:28 -04:00
return "No freshwater catches cataloged yet."
WaterType.Type.SALT_WATER:
2026-07-30 23:16:28 -04:00
return "No saltwater catches cataloged yet."
_:
return "No entries available."
2026-08-14 16:31:28 -04:00
static func catalog_number(fish: FishDataType) -> int:
return fish.catalog_number if fish != null else 0
2026-07-30 23:16:28 -04:00
2026-08-14 16:31:28 -04:00
static func facts_for(fish: FishDataType) -> String:
if fish == null or fish.logbook_fact.strip_edges().is_empty():
return "unknown"
return fish.logbook_fact
2026-08-02 09:57:05 -04:00
2026-07-30 23:16:28 -04:00
static func ordered_species(
candidates: Array[FishDataType],
) -> Array[FishDataType]:
var ordered: Array[FishDataType] = []
2026-08-14 16:31:28 -04:00
for fish: FishDataType in candidates:
if fish != null and fish.active and not fish.id.is_empty():
ordered.append(fish)
ordered.sort_custom(
func(a: FishDataType, b: FishDataType) -> bool:
if a.catalog_number == b.catalog_number:
return String(a.id) < String(b.id)
return a.catalog_number < b.catalog_number
)
2026-07-30 23:16:28 -04:00
return ordered