P2P Export - Nodes - Patch

This commit is contained in:
2026-10-06 02:10:08 -07:00
parent 9fee67d231
commit 4ab646015d
49 changed files with 2478 additions and 1164 deletions

View File

@ -158,7 +158,7 @@ def remove_readonly(func, path, excinfo):
func(path)
def write_khafilejs(is_play, export_physics: bool, export_navigation: bool, export_ui: bool, export_network: bool, is_publish: bool,
def write_khafilejs(is_play, export_physics: bool, export_navigation: bool, export_ui: bool, export_network: bool, export_torrent: bool, is_publish: bool,
import_traits: List[str]) -> None:
wrd = bpy.data.worlds['Lnx']
rpdat = lnx.utils.get_rp()
@ -482,9 +482,16 @@ let project = new Project('""" + lnx.utils.safesrc(wrd.lnx_project_name + '-' +
if not os.path.exists('Libraries/network'):
khafile.write(add_leenkx_library(sdk_path, 'lib/network', rel_path=do_relpath_sdk))
assets.add_khafile_def('lnx_network')
lnxjs_path = sdk_path + '/lib/leenkx_tools/lnxjs/Leenkx.js'
lnxjs_path = lnxjs_path.replace('\\', '/').replace('//', '/')
khafile.write(add_assets(lnxjs_path, rel_path=do_relpath_sdk))
#lnxjs_path = sdk_path + '/lib/leenkx_tools/lnxjs/Leenkx.js'
#lnxjs_path = lnxjs_path.replace('\\', '/').replace('//', '/')
#khafile.write(add_assets(lnxjs_path, rel_path=do_relpath_sdk))
if export_torrent:
assets.add_khafile_def('lnx_torrent')
if state.target in ('windows-hl', 'linux-hl', 'macos-hl'):
if not os.path.exists('Libraries/datachannel'):
khafile.write(add_leenkx_library(sdk_path + '/lib/', 'datachannel', rel_path=do_relpath_sdk))
assets.add_khafile_def('lnx_datachannel')
if not wrd.lnx_minimize:
assets.add_khafile_def('lnx_json')
@ -736,6 +743,19 @@ class Main {
elif wrd.lnx_canvas_img_scaling_quality == 'high':
f.write("\n" + content_indent + "leenkx.ui.Canvas.imageScaleQuality = kha.graphics2.ImageScaleQuality.High;")
if wrd.lnx_torrent != 'Disabled':
dl_dir = wrd.lnx_torrent_download_dir
if dl_dir.startswith('//'):
dl_dir = bpy.path.abspath(dl_dir)
if dl_dir != '':
f.write("\n" + content_indent + "leenkx.network.torrent.TorrentClient.defaultDownloadDir = " + json.dumps(dl_dir) + ";")
trackers_list = [json.dumps(t.name) for t in wrd.lnx_torrent_trackers if t.name != '']
f.write("\n" + content_indent + "leenkx.network.torrent.TorrentClient.defaultTrackers = [" + ", ".join(trackers_list) + "];")
ice_list = [json.dumps(t.name) for t in wrd.lnx_torrent_ice_servers if t.name != '']
f.write("\n" + content_indent + "leenkx.network.torrent.peer.RtcPeerPool.defaultIceServers = [" + ", ".join(ice_list) + "];")
f.write("\n" + content_indent + "leenkx.network.torrent.LeenkxClient.PEERTIMEOUT = " + str(wrd.lnx_torrent_peer_timeout) + ";")
f.write("\n" + content_indent + "leenkx.network.torrent.LeenkxClient.defaultHeartbeat = " + str(wrd.lnx_torrent_heartbeat) + ";")
# Write Starter.main call
starter_indent = content_indent + " "
f.write("\n" + content_indent + "leenkx.system.Starter.main(")