Add controls view to instruments and set address with property

This commit is contained in:
Marek S. Łukasiewicz 2025-03-03 11:07:09 +01:00
parent f8d769ebc6
commit d1c450493d
3 changed files with 48 additions and 65 deletions

View file

@ -1,31 +1,12 @@
extends Node
@export var browser_name: String = "browser"
@export var url: String = "http://192.168.1.2:5555/pfd"
const PFD_PATH: String = "pfd#adi,vsi,alt,ias,rht,rpm,hsi"
const CONTROLS_PATH: String = "controls#collective,cyclic,rudder"
@export var lidia_hostname: String = "localhost"
@export var lidia_port: int = 5555
# ==============================================================================
# Create a single browser named "browser_name" that is attached as child node to $CEF.
# ==============================================================================
func _ready():
# See API.md for more details. CEF Configuration is:
# resource_path := {"artifacts", CEF_ARTIFACTS_FOLDER}
# resource_path := {"exported_artifacts", application_real_path()}
# {"incognito":false}
# {"cache_path", resource_path / "cache"}
# {"root_cache_path", resource_path / "cache"}
# {"browser_subprocess_path", resource_path / SUBPROCESS_NAME }
# {"log_file", resource_path / "debug.log"}
# {log_severity", "warning"}
# {"remote_debugging_port", 7777}
# {"exception_stack_size", 5}
# {"enable_media_stream", false}
#
# Configurate CEF. In incognito mode cache directories not used and in-memory
# caches are used instead and no data is persisted to disk.
#
# artifacts: allows path such as "build" or "res://cef_artifacts/". Note that "res://"
# will use ProjectSettings.globalize_path but exported projects don't support globalize_path:
# https://docs.godotengine.org/en/3.5/classes/class_projectsettings.html#class-projectsettings-method-globalize-path
if !$CEF.initialize({"incognito":true, "locale":"en-US"}):
push_error($CEF.get_error())
get_tree().quit()
@ -35,40 +16,18 @@ func _ready():
# Wait one frame for the texture rect to get its size
await get_tree().process_frame
# See API.md for more details. Browser configuration is:
# {"frame_rate", 30}
# {"javascript", true}
# {"javascript_close_windows", false}
# {"javascript_access_clipboard", false}
# {"javascript_dom_paste", false}
# {"image_loading", true}
# {"databases", true}
# {"webgl", true}
var browser = $CEF.create_browser(url, $SubViewport/TextureRect, {
"frame_rate": 90,
"javascript": true,
})
browser.name = browser_name
browser.connect("on_page_loaded", _on_page_loaded)
browser.connect("on_page_failed_loading", _on_page_failed_loading)
#browser.set_zoom_level(0.05)
var browser_pfd = $CEF.create_browser(
"http://{}:{}/{}".format([lidia_hostname, lidia_port, PFD_PATH], "{}"),
$SubViewport/TextureRect,
{ "frame_rate": 90, "javascript": true },
)
browser_pfd.name = "pfd"
browser_pfd.enable_ad_block(false) # Required for lidia static assets
# Required for lidia static assets
browser.enable_ad_block(false)
# ==============================================================================
# Callback when a page has ended to load: we print a message
# ==============================================================================
func _on_page_loaded(node):
print(node.name + ": page " + node.get_url() + " loaded")
# ==============================================================================
# Callback when a page has ended to load with failure.
# Display a load error message using a data: URI.
# ==============================================================================
func _on_page_failed_loading(err_code, err_msg, node):
if err_code == -3:
return
push_error("The browser " + node.name + " failed loading " + \
node.get_url() + ": " + err_msg)
pass
var browser_ctrl = $CEF.create_browser(
"http://{}:{}/{}".format([lidia_hostname, lidia_port, CONTROLS_PATH], "{}"),
$SubViewport2/TextureRect,
{ "frame_rate": 90, "javascript": true },
)
browser_ctrl.name = "controls"
browser_ctrl.enable_ad_block(false) # Required for lidia static assets