mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-24 11:17:26 -04:00
gate icon and undiscoverable mode
This commit is contained in:
parent
fb6cf98f2b
commit
414ad4eeda
18 changed files with 108 additions and 52 deletions
|
@ -21,8 +21,8 @@ func get_string(section: String, key: String) -> String:
|
|||
return value
|
||||
|
||||
|
||||
func get_value(section: String, key: String) -> Variant:
|
||||
var value: Variant
|
||||
func get_value(section: String, key: String, default: Variant = null) -> Variant:
|
||||
var value: Variant = default
|
||||
if config.has_section_key(section, key):
|
||||
value = config.get_value(section, key)
|
||||
# Debug.logr(key + "=" + str(value))
|
||||
|
|
|
@ -3,19 +3,30 @@ class_name ConfigGate
|
|||
|
||||
const SECTION = "gate"
|
||||
|
||||
const KEY_TITLE = "title"
|
||||
const KEY_DESCRIPTION = "description"
|
||||
const KEY_ICON = "icon"
|
||||
const KEY_IMAGE = "image"
|
||||
const KEY_RESOURCE_PACK = "resource_pack"
|
||||
const KEY_DISCOVERABLE = "discoverable"
|
||||
|
||||
var title: String
|
||||
var description: String
|
||||
var icon_url: String
|
||||
var image_url: String
|
||||
var resource_pack_url: String
|
||||
var discoverable: bool
|
||||
var libraries: PackedStringArray
|
||||
|
||||
|
||||
func _init(path: String, base_url: String) -> void:
|
||||
super._init(path)
|
||||
title = get_string(SECTION, "title")
|
||||
description = get_string(SECTION, "description")
|
||||
image_url = Url.join(base_url, get_string(SECTION, "image"))
|
||||
resource_pack_url = Url.join(base_url, get_string(SECTION, "resource_pack"))
|
||||
title = get_string(SECTION, KEY_TITLE)
|
||||
description = get_string(SECTION, KEY_DESCRIPTION)
|
||||
icon_url = Url.join(base_url, get_string(SECTION, KEY_ICON))
|
||||
image_url = Url.join(base_url, get_string(SECTION, KEY_IMAGE))
|
||||
resource_pack_url = Url.join(base_url, get_string(SECTION, KEY_RESOURCE_PACK))
|
||||
discoverable = get_value(SECTION, KEY_DISCOVERABLE, true)
|
||||
libraries = get_libraries(base_url)
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,10 @@ var load_resources_done: bool
|
|||
var shared_libs_count: int = -1
|
||||
var shared_libs_done: int
|
||||
|
||||
# Show progress when resource pack is started loading
|
||||
var resource_pack_url: String
|
||||
var resource_pack_started_loading: bool
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
FileDownloader.progress.connect(on_progress)
|
||||
|
@ -26,15 +30,22 @@ func load_gate(config_url: String) -> void:
|
|||
if c_gate.load_result != OK: return error(GateEvents.GateError.INVALID_CONFIG)
|
||||
gate_events.gate_config_loaded_emit(config_url, c_gate)
|
||||
|
||||
gate = Gate.create(config_url, c_gate.title, c_gate.description, "", "", "")
|
||||
gate = Gate.create(config_url, c_gate.title, c_gate.description, "", "", "", "")
|
||||
gate_events.gate_info_loaded_emit(gate)
|
||||
|
||||
# Download all in parallel
|
||||
load_icon(c_gate)
|
||||
load_image(c_gate)
|
||||
load_resources(c_gate)
|
||||
load_shared_libs(c_gate, config_url)
|
||||
|
||||
|
||||
func load_icon(c_gate: ConfigGate) -> void:
|
||||
gate.icon = await FileDownloader.download(c_gate.icon_url)
|
||||
gate_events.gate_icon_loaded_emit(gate)
|
||||
# Finish without icon
|
||||
|
||||
|
||||
func load_image(c_gate: ConfigGate) -> void:
|
||||
gate.image = await FileDownloader.download(c_gate.image_url)
|
||||
gate_events.gate_image_loaded_emit(gate)
|
||||
|
@ -42,6 +53,7 @@ func load_image(c_gate: ConfigGate) -> void:
|
|||
|
||||
|
||||
func load_resources(c_gate: ConfigGate) -> void:
|
||||
resource_pack_url = c_gate.resource_pack_url
|
||||
gate.resource_pack = await FileDownloader.download(c_gate.resource_pack_url)
|
||||
if gate.resource_pack.is_empty(): return error(GateEvents.GateError.MISSING_PACK)
|
||||
|
||||
|
@ -81,6 +93,12 @@ func error(code: GateEvents.GateError) -> void:
|
|||
|
||||
|
||||
func on_progress(url: String, body_size: int, downloaded_bytes: int) -> void:
|
||||
if url == resource_pack_url and not resource_pack_started_loading and body_size > 0:
|
||||
resource_pack_started_loading = true
|
||||
|
||||
if not resource_pack_started_loading:
|
||||
return
|
||||
|
||||
gate_events.download_progress_emit(url, body_size, downloaded_bytes)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue