mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-25 14:17:29 -04:00
ext_texture_format and first_frame_drawn for swapchaing copying
This commit is contained in:
parent
644a8bb969
commit
78ad658f06
7 changed files with 151 additions and 49 deletions
41
app/scripts/ui/world/splash_screen.gd
Normal file
41
app/scripts/ui/world/splash_screen.gd
Normal file
|
@ -0,0 +1,41 @@
|
|||
extends TextureRect
|
||||
class_name SplashScreen
|
||||
|
||||
@export var gate_events: GateEvents
|
||||
@export var ui_events: UiEvents
|
||||
@export var splash_screen: Texture2D
|
||||
|
||||
@onready var width: int = int(ui_events.current_ui_size.x)
|
||||
@onready var height: int = int(ui_events.current_ui_size.y)
|
||||
|
||||
|
||||
func _ready():
|
||||
gate_events.gate_info_loaded.connect(show_thumbnail)
|
||||
gate_events.gate_entered.connect(show_splash_screen)
|
||||
|
||||
# Change size
|
||||
show_splash_screen()
|
||||
|
||||
|
||||
func show_thumbnail(gate: Gate, is_cached: bool) -> void:
|
||||
if is_cached: return # Resource pack is already downloaded
|
||||
|
||||
var image: Image
|
||||
var tex = FileTools.load_external_tex(gate.image)
|
||||
|
||||
if tex != null: image = resize_and_convert(tex.get_image(), Image.FORMAT_RGB8)
|
||||
else: image = Image.create(width, height, false, Image.FORMAT_RGB8)
|
||||
|
||||
self.texture = ImageTexture.create_from_image(image)
|
||||
|
||||
|
||||
func show_splash_screen() -> void:
|
||||
var image = resize_and_convert(splash_screen.get_image(), Image.FORMAT_RGBA8)
|
||||
self.texture = ImageTexture.create_from_image(image)
|
||||
|
||||
|
||||
func resize_and_convert(image: Image, format: Image.Format) -> Image:
|
||||
image.resize(width, height)
|
||||
image.convert(format)
|
||||
#image.clear_mipmaps()
|
||||
return image
|
Loading…
Add table
Add a link
Reference in a new issue