Add fish silhouettes to Logbook
This commit is contained in:
parent
51ce214a25
commit
3dfa6b221e
5 changed files with 173 additions and 33 deletions
|
|
@ -21,6 +21,11 @@ func _run() -> void:
|
|||
await process_frame
|
||||
assert(bool(main.get("_gameplay_started")))
|
||||
_validate_save_round_trip(main, save_manager)
|
||||
var player := main.get("_player") as Player
|
||||
var no_catches: Array[FishCatch] = []
|
||||
var no_discoveries: Array[StringName] = []
|
||||
assert(player.inventory.replace_all_catches(no_catches, 1))
|
||||
assert(player.collection_log.replace_discovered_ids(no_discoveries))
|
||||
|
||||
var game_ui := main.get_node("%GameUI") as GameUI
|
||||
var player_menu := game_ui.get_node("%PlayerMenu") as PlayerMenu
|
||||
|
|
@ -54,7 +59,6 @@ func _run() -> void:
|
|||
logbook.call("_select_category", LogbookCatalog.Category.OTHER)
|
||||
await create_timer(0.25).timeout
|
||||
assert((logbook.get("_entry_buttons") as Dictionary).size() == 4)
|
||||
var player := main.get("_player") as Player
|
||||
player.collection_log.mark_discovered(&"bluegill")
|
||||
await process_frame
|
||||
logbook.call("_select_entry", &"bluegill", &"bluegill")
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ const FishCatchType = preload("res://fish/fish_catch.gd")
|
|||
const FishInventoryType = preload("res://inventory/fish_inventory.gd")
|
||||
const FishPoolType = preload("res://fish/fish_pool.gd")
|
||||
const CollectionLogType = preload("res://collection/collection_log.gd")
|
||||
const FishDataType = preload("res://fish/fish_data.gd")
|
||||
const LogbookPageScene = preload("res://ui/logbook_page.tscn")
|
||||
const CatalogResource: FishPoolType = preload(
|
||||
"res://fish/pools/fish_catalog.tres"
|
||||
|
|
@ -75,30 +76,63 @@ func _validate_page() -> void:
|
|||
page.activate()
|
||||
await process_frame
|
||||
|
||||
var entries: Dictionary = page.get("_entry_buttons")
|
||||
assert(entries.size() == 4)
|
||||
for entry_value: Variant in entries.values():
|
||||
var entry := entry_value as Button
|
||||
assert(entry != null)
|
||||
assert(entry.text.contains("???"))
|
||||
assert(entry.tooltip_text.is_empty())
|
||||
assert(entry.icon == null)
|
||||
assert(entry.accessibility_name == "Unknown catalog entry")
|
||||
for fish in CatalogResource.candidates:
|
||||
assert(not entry.text.contains(fish.display_name))
|
||||
var shared_material: Material
|
||||
var silhouette_count: int = 0
|
||||
for category: LogbookCatalog.Category in [
|
||||
LogbookCatalog.Category.FRESH_WATER,
|
||||
LogbookCatalog.Category.OTHER,
|
||||
]:
|
||||
page.call("_select_category", category)
|
||||
await create_timer(0.25).timeout
|
||||
var entries: Dictionary = page.get("_entry_buttons")
|
||||
assert(entries.size() == 4)
|
||||
for fish: FishDataType in LogbookCatalog.ordered_species(
|
||||
CatalogResource.candidates
|
||||
):
|
||||
if LogbookCatalog.category_for(fish) != category:
|
||||
continue
|
||||
var unknown_key := StringName(
|
||||
"unknown_%d" % LogbookCatalog.catalog_number(fish.id)
|
||||
)
|
||||
var entry := entries.get(unknown_key) as Button
|
||||
assert(entry != null)
|
||||
assert(entry.text.is_empty())
|
||||
assert(entry.tooltip_text.is_empty())
|
||||
assert(entry.icon == null)
|
||||
assert(entry.accessibility_name == "Unknown catalog entry")
|
||||
assert(_has_visible_unknown_name(entry))
|
||||
var portrait := _find_unknown_portrait(entry)
|
||||
assert(portrait != null)
|
||||
assert(portrait.texture == fish.display_texture)
|
||||
assert(
|
||||
portrait.expand_mode
|
||||
== TextureRect.EXPAND_IGNORE_SIZE
|
||||
)
|
||||
assert(
|
||||
portrait.stretch_mode
|
||||
== TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
)
|
||||
assert(portrait.material is ShaderMaterial)
|
||||
if shared_material == null:
|
||||
shared_material = portrait.material
|
||||
else:
|
||||
assert(portrait.material == shared_material)
|
||||
assert(_texture_has_transparency(portrait.texture))
|
||||
silhouette_count += 1
|
||||
for candidate: FishDataType in CatalogResource.candidates:
|
||||
assert(not entry.text.contains(candidate.display_name))
|
||||
assert(
|
||||
not entry.tooltip_text.contains(
|
||||
candidate.display_name
|
||||
)
|
||||
)
|
||||
assert(
|
||||
not entry.accessibility_name.contains(
|
||||
candidate.display_name
|
||||
)
|
||||
)
|
||||
assert(silhouette_count == 8)
|
||||
|
||||
page.call(
|
||||
"_select_category", LogbookCatalog.Category.FRESH_WATER
|
||||
)
|
||||
await create_timer(0.25).timeout
|
||||
assert((page.get("_entry_buttons") as Dictionary).size() == 4)
|
||||
for entry_value: Variant in (
|
||||
page.get("_entry_buttons") as Dictionary
|
||||
).values():
|
||||
var unknown_catfish := entry_value as Button
|
||||
assert(unknown_catfish != null)
|
||||
assert(unknown_catfish.text.contains("???"))
|
||||
assert(unknown_catfish.icon == null)
|
||||
page.call("_select_category", LogbookCatalog.Category.SALT_WATER)
|
||||
await create_timer(0.25).timeout
|
||||
assert((page.get("_entry_buttons") as Dictionary).is_empty())
|
||||
|
|
@ -110,13 +144,20 @@ func _validate_page() -> void:
|
|||
await create_timer(0.25).timeout
|
||||
|
||||
var bluegill = CatalogResource.get_fish_by_id(&"bluegill")
|
||||
page.call("_select_entry", &"unknown_1", StringName())
|
||||
assert(
|
||||
(page.get("_entry_buttons") as Dictionary)
|
||||
.get(&"unknown_1") != null
|
||||
)
|
||||
collection.mark_discovered(&"bluegill")
|
||||
await process_frame
|
||||
entries = page.get("_entry_buttons")
|
||||
var entries: Dictionary = page.get("_entry_buttons")
|
||||
var known := entries.get(&"bluegill") as Button
|
||||
assert(known != null)
|
||||
assert(known.text == bluegill.display_name)
|
||||
assert(known.icon == bluegill.display_texture)
|
||||
assert(_find_unknown_portrait(known) == null)
|
||||
assert(known.button_pressed)
|
||||
|
||||
var fish_catch := FishCatchType.new()
|
||||
fish_catch.fish = bluegill
|
||||
|
|
@ -151,3 +192,28 @@ func _detail_text(page: LogbookPage) -> String:
|
|||
for node: Node in detail_body.find_children("*", "Label", true, false):
|
||||
values.append((node as Label).text)
|
||||
return "\n".join(values)
|
||||
|
||||
|
||||
func _find_unknown_portrait(entry: Button) -> TextureRect:
|
||||
var pending: Array[Node] = [entry]
|
||||
while not pending.is_empty():
|
||||
var node: Node = pending.pop_back()
|
||||
if node is TextureRect:
|
||||
return node as TextureRect
|
||||
pending.append_array(node.get_children())
|
||||
return null
|
||||
|
||||
|
||||
func _has_visible_unknown_name(entry: Button) -> bool:
|
||||
var pending: Array[Node] = [entry]
|
||||
while not pending.is_empty():
|
||||
var node: Node = pending.pop_back()
|
||||
if node is Label and (node as Label).text == "???":
|
||||
return true
|
||||
pending.append_array(node.get_children())
|
||||
return false
|
||||
|
||||
|
||||
func _texture_has_transparency(texture: Texture2D) -> bool:
|
||||
var image: Image = texture.get_image()
|
||||
return image != null and image.detect_alpha() != Image.ALPHA_NONE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue