Cache character pictures and songs on disk
Character pictures are kept in characters/ next to the settings, with an index.json of when the server last changed each one and when it was downloaded. Only new or changed pictures are downloaded, using the server's new /character/details. Older servers fall back to the name list, and pictures are downloaded again after 7 days. Downloaded songs are written to songs/ and only their paths are kept in memory. The folder is emptied when the game starts and when the playlist resets.
This commit is contained in:
1 parent
62fa63fd8b
commit
240c331ab2
17 files changed
+912
-48
No files matched your search
@@ -16,17 +16,15 @@ func _ready() -> void:
|
||||
mouse_exited.connect(_set_hovered.bind(false))
|
||||
|
||||
|
||||
## Shows [param character_name] and fetches its picture from the server.
|
||||
func set_character_name(character_name: String) -> void:
|
||||
## Shows [param character_name] and its picture. [param fetch_image] is called with the
|
||||
## name and a Callable that takes the picture as an [Image], e.g.
|
||||
## [method CharacterCache.fetch_image].
|
||||
func set_character_name(character_name: String, fetch_image: Callable) -> void:
|
||||
character_name_label.text = display_name(character_name)
|
||||
tooltip_text = character_name_label.text
|
||||
var image_fetched: Callable = func image_fetched(image: PackedByteArray) -> void:
|
||||
var picture: Image = image_from_bytes(image)
|
||||
if picture == null:
|
||||
GameLog.warning("Could not load the picture of ", character_name)
|
||||
return
|
||||
var image_fetched: Callable = func image_fetched(picture: Image) -> void:
|
||||
character_image.texture = ImageTexture.create_from_image(picture)
|
||||
MusicServerClient.fetch_character_image(character_name, image_fetched)
|
||||
fetch_image.call(character_name, image_fetched)
|
||||
|
||||
|
||||
## The name to show for a picture's [param file_name]: without the file extension, and
|
||||
|
||||
Reference in new issue
Block a user