mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-25 14:17:29 -04:00
load global_script_class_cache
This commit is contained in:
parent
65c0766f9c
commit
5b597cf055
8 changed files with 56 additions and 31 deletions
|
@ -13,7 +13,7 @@ config_version=5
|
||||||
config/name="TheGates"
|
config/name="TheGates"
|
||||||
config/description="Building new Internet"
|
config/description="Building new Internet"
|
||||||
run/main_scene="res://the_gates/scenes/app.tscn"
|
run/main_scene="res://the_gates/scenes/app.tscn"
|
||||||
config/features=PackedStringArray("4.1")
|
config/features=PackedStringArray("4.0")
|
||||||
config/icon="res://the_gates/icons/icon_64.png"
|
config/icon="res://the_gates/icons/icon_64.png"
|
||||||
config/windows_native_icon="res://the_gates/icons/icon.ico"
|
config/windows_native_icon="res://the_gates/icons/icon.ico"
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ pointing/emulate_touch_from_mouse=true
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
textures/canvas_textures/default_texture_filter=2
|
|
||||||
driver/threads/thread_model=2
|
driver/threads/thread_model=2
|
||||||
textures/default_filters/anisotropic_filtering_level=1
|
textures/default_filters/anisotropic_filtering_level=1
|
||||||
anti_aliasing/quality/use_taa=true
|
anti_aliasing/quality/use_taa=true
|
||||||
|
textures/canvas_textures/default_texture_filter=2
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
extends ConfigBase
|
extends ConfigBase
|
||||||
class_name GateConfig
|
class_name ConfigGate
|
||||||
|
|
||||||
var title: String
|
var title: String
|
||||||
var description: String
|
var description: String
|
||||||
var image_url: String
|
var image_url: String
|
||||||
var godot_config_url: String
|
var godot_config_url: String
|
||||||
|
var global_script_class_url: String
|
||||||
var resource_pack_url: String
|
var resource_pack_url: String
|
||||||
|
|
||||||
const section = "gate"
|
const section = "gate"
|
||||||
|
@ -16,4 +17,5 @@ func _init(path: String, base_url: String) -> void:
|
||||||
description = get_string(section, "description")
|
description = get_string(section, "description")
|
||||||
image_url = Url.join(base_url, get_string(section, "image"))
|
image_url = Url.join(base_url, get_string(section, "image"))
|
||||||
godot_config_url = Url.join(base_url, get_string(section, "godot_config"))
|
godot_config_url = Url.join(base_url, get_string(section, "godot_config"))
|
||||||
|
global_script_class_url = Url.join(base_url, get_string(section, "global_script_class"))
|
||||||
resource_pack_url = Url.join(base_url, get_string(section, "resource_pack"))
|
resource_pack_url = Url.join(base_url, get_string(section, "resource_pack"))
|
28
project/the_gates/scripts/loading/config_global_script.gd
Normal file
28
project/the_gates/scripts/loading/config_global_script.gd
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
extends ConfigBase
|
||||||
|
class_name ConfigGlobalScript
|
||||||
|
|
||||||
|
# for unloading
|
||||||
|
var scripts
|
||||||
|
|
||||||
|
|
||||||
|
func _init(path: String) -> void:
|
||||||
|
super._init(path)
|
||||||
|
|
||||||
|
|
||||||
|
func load_config() -> void:
|
||||||
|
load_global_classes()
|
||||||
|
|
||||||
|
|
||||||
|
func unload_config() -> void:
|
||||||
|
unload_global_classes()
|
||||||
|
|
||||||
|
|
||||||
|
func load_global_classes() -> void:
|
||||||
|
scripts = get_value("", "list")
|
||||||
|
if scripts == null: return
|
||||||
|
for script in scripts: CppExposed.add_global_class(script)
|
||||||
|
|
||||||
|
|
||||||
|
func unload_global_classes() -> void:
|
||||||
|
if scripts == null: return
|
||||||
|
for script in scripts: CppExposed.remove_global_class(script)
|
|
@ -1,10 +1,9 @@
|
||||||
extends ConfigBase
|
extends ConfigBase
|
||||||
class_name PackConfig
|
class_name ConfigGodot
|
||||||
|
|
||||||
var scene_path: String
|
var scene_path: String
|
||||||
|
|
||||||
# for unloading
|
# for unloading
|
||||||
var scripts
|
|
||||||
var autoloads
|
var autoloads
|
||||||
var actions
|
var actions
|
||||||
|
|
||||||
|
@ -15,29 +14,16 @@ func _init(path: String) -> void:
|
||||||
|
|
||||||
|
|
||||||
func load_config() -> void:
|
func load_config() -> void:
|
||||||
load_global_classes()
|
|
||||||
load_autoloads()
|
load_autoloads()
|
||||||
load_input_map()
|
load_input_map()
|
||||||
load_settings()
|
load_settings()
|
||||||
|
|
||||||
|
|
||||||
func unload_config() -> void:
|
func unload_config() -> void:
|
||||||
unload_global_classes()
|
|
||||||
unload_autoloads()
|
unload_autoloads()
|
||||||
unload_input_map()
|
unload_input_map()
|
||||||
|
|
||||||
|
|
||||||
func load_global_classes() -> void:
|
|
||||||
scripts = get_value("", "_global_script_classes")
|
|
||||||
if scripts == null: return
|
|
||||||
for script in scripts: CppExposed.add_global_class(script)
|
|
||||||
|
|
||||||
|
|
||||||
func unload_global_classes() -> void:
|
|
||||||
if scripts == null: return
|
|
||||||
for script in scripts: CppExposed.remove_global_class(script)
|
|
||||||
|
|
||||||
|
|
||||||
func load_autoloads() -> void:
|
func load_autoloads() -> void:
|
||||||
autoloads = get_section_keys("autoload")
|
autoloads = get_section_keys("autoload")
|
||||||
if autoloads == null: return
|
if autoloads == null: return
|
|
@ -2,7 +2,7 @@ extends Node
|
||||||
|
|
||||||
@export var gate_events: GateEvents
|
@export var gate_events: GateEvents
|
||||||
|
|
||||||
var g_config: GateConfig
|
var c_gate: ConfigGate
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
@ -14,13 +14,14 @@ func load_gate(config_url: String) -> void:
|
||||||
|
|
||||||
Debug.logr("======== " + config_url + " ========")
|
Debug.logr("======== " + config_url + " ========")
|
||||||
var config_path: String = await FileDownloader.download(config_url)
|
var config_path: String = await FileDownloader.download(config_url)
|
||||||
g_config = GateConfig.new(config_path, config_url)
|
c_gate = ConfigGate.new(config_path, config_url)
|
||||||
|
|
||||||
var image_path = await FileDownloader.download(g_config.image_url)
|
var image_path = await FileDownloader.download(c_gate.image_url)
|
||||||
var gate = Gate.create(config_url, g_config.title, g_config.description,
|
var gate = Gate.create(config_url, c_gate.title, c_gate.description,
|
||||||
image_path, "", "")
|
image_path, "", "", "")
|
||||||
gate_events.gate_info_loaded_emit(gate)
|
gate_events.gate_info_loaded_emit(gate)
|
||||||
|
|
||||||
gate.godot_config = await FileDownloader.download(g_config.godot_config_url)
|
gate.godot_config = await FileDownloader.download(c_gate.godot_config_url)
|
||||||
gate.resource_pack = await FileDownloader.download(g_config.resource_pack_url)
|
gate.global_script_class = await FileDownloader.download(c_gate.global_script_class_url)
|
||||||
|
gate.resource_pack = await FileDownloader.download(c_gate.resource_pack_url)
|
||||||
gate_events.gate_loaded_emit(gate)
|
gate_events.gate_loaded_emit(gate)
|
||||||
|
|
|
@ -5,7 +5,8 @@ class_name PackLoader
|
||||||
@export var scenes_parent: Node
|
@export var scenes_parent: Node
|
||||||
|
|
||||||
var gate: Gate
|
var gate: Gate
|
||||||
var p_config: PackConfig
|
var c_g_script: ConfigGlobalScript
|
||||||
|
var c_godot: ConfigGodot
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
@ -17,10 +18,13 @@ func load_pack(_gate: Gate) -> void:
|
||||||
var success = ProjectSettings.load_resource_pack(gate.resource_pack)
|
var success = ProjectSettings.load_resource_pack(gate.resource_pack)
|
||||||
if not success: Debug.logerr("cannot load pck"); return
|
if not success: Debug.logerr("cannot load pck"); return
|
||||||
|
|
||||||
p_config = PackConfig.new(gate.godot_config)
|
c_g_script = ConfigGlobalScript.new(gate.global_script_class)
|
||||||
p_config.load_config()
|
c_godot = ConfigGodot.new(gate.godot_config)
|
||||||
|
|
||||||
var scene = load(p_config.scene_path)
|
c_g_script.load_config() # Loading order is important
|
||||||
|
c_godot.load_config()
|
||||||
|
|
||||||
|
var scene = load(c_godot.scene_path)
|
||||||
scenes_parent.add_child(scene.instantiate())
|
scenes_parent.add_child(scene.instantiate())
|
||||||
|
|
||||||
gate_events.gate_entered_emit()
|
gate_events.gate_entered_emit()
|
||||||
|
@ -32,7 +36,8 @@ func unload_pack() -> void:
|
||||||
if not success: Debug.logerr("cannot unload pck")
|
if not success: Debug.logerr("cannot unload pck")
|
||||||
else: Debug.logr("\nunloaded " + gate.resource_pack + "\n")
|
else: Debug.logr("\nunloaded " + gate.resource_pack + "\n")
|
||||||
|
|
||||||
if p_config != null: p_config.unload_config()
|
if c_godot != null: c_godot.unload_config()
|
||||||
|
if c_g_script != null: c_g_script.unload_config()
|
||||||
|
|
||||||
|
|
||||||
func _exit_tree() -> void:
|
func _exit_tree() -> void:
|
||||||
|
|
|
@ -8,16 +8,18 @@ class_name Gate
|
||||||
@export var description: String
|
@export var description: String
|
||||||
@export_file("*.png", "*.jpg") var image: String
|
@export_file("*.png", "*.jpg") var image: String
|
||||||
var godot_config: String
|
var godot_config: String
|
||||||
|
var global_script_class: String
|
||||||
var resource_pack: String
|
var resource_pack: String
|
||||||
|
|
||||||
|
|
||||||
static func create(_url: String, _title: String, _description: String,
|
static func create(_url: String, _title: String, _description: String,
|
||||||
_image: String, _godot_config: String, _resource_pack: String) -> Gate:
|
_image: String, _godot_config: String, _global_script_class: String, _resource_pack: String) -> Gate:
|
||||||
var gate = Gate.new()
|
var gate = Gate.new()
|
||||||
gate.url = _url
|
gate.url = _url
|
||||||
gate.title = _title
|
gate.title = _title
|
||||||
gate.description = _description
|
gate.description = _description
|
||||||
gate.image = _image
|
gate.image = _image
|
||||||
gate.godot_config = _godot_config
|
gate.godot_config = _godot_config
|
||||||
|
gate.global_script_class = _global_script_class
|
||||||
gate.resource_pack = _resource_pack
|
gate.resource_pack = _resource_pack
|
||||||
return gate
|
return gate
|
||||||
|
|
|
@ -32,4 +32,5 @@ func gate_entered_emit() -> void:
|
||||||
|
|
||||||
func exit_gate_emit() -> void:
|
func exit_gate_emit() -> void:
|
||||||
current_gate_url = ""
|
current_gate_url = ""
|
||||||
|
current_gate = null
|
||||||
exit_gate.emit()
|
exit_gate.emit()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue