mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-23 17:17:31 -04:00
gd: send filehandle path
This commit is contained in:
parent
7348f2b9d5
commit
94fd2ec903
5 changed files with 11 additions and 18 deletions
|
@ -10,7 +10,7 @@ func _ready() -> void:
|
||||||
|
|
||||||
|
|
||||||
func load_gate(config_url: String) -> void:
|
func load_gate(config_url: String) -> void:
|
||||||
Debug.logr("======== " + config_url + " ========")
|
Debug.logclr("======== " + config_url + " ========", Color.GREEN)
|
||||||
var config_path: String = await FileDownloader.download(config_url)
|
var config_path: String = await FileDownloader.download(config_url)
|
||||||
c_gate = ConfigGate.new(config_path, config_url)
|
c_gate = ConfigGate.new(config_path, config_url)
|
||||||
|
|
||||||
|
|
|
@ -19,14 +19,11 @@ func create_process(gate: Gate) -> void:
|
||||||
var pack_file = ProjectSettings.globalize_path(gate.resource_pack)
|
var pack_file = ProjectSettings.globalize_path(gate.resource_pack)
|
||||||
var args = [
|
var args = [
|
||||||
"--main-pack", pack_file,
|
"--main-pack", pack_file,
|
||||||
"--resolution", "%dx%d" % [render_result.width, render_result.height],
|
"--resolution", "%dx%d" % [render_result.width, render_result.height]
|
||||||
"--fd-path", render_result.fd_path
|
|
||||||
]
|
]
|
||||||
Debug.logclr(snbx_executable.path + " " + " ".join(args), Color.DARK_VIOLET)
|
Debug.logclr(snbx_executable.path + " " + " ".join(args), Color.DARK_VIOLET)
|
||||||
sandbox_pid = OS.create_process(snbx_executable.path, args)
|
sandbox_pid = OS.create_process(snbx_executable.path, args)
|
||||||
|
|
||||||
if OS.get_name() == "Windows": render_result.fd_path += "|" + str(sandbox_pid)
|
|
||||||
|
|
||||||
gate_events.gate_entered_emit()
|
gate_events.gate_entered_emit()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
extends Resource
|
extends Resource
|
||||||
class_name CommandEvents
|
class_name CommandEvents
|
||||||
|
|
||||||
signal send_filehandle
|
signal send_filehandle(filehandle_path: String)
|
||||||
signal set_mouse_mode(mode: int)
|
signal set_mouse_mode(mode: int)
|
||||||
|
|
||||||
|
|
||||||
func send_filehandle_emit() -> void:
|
func send_filehandle_emit(filehandle_path: String) -> void:
|
||||||
send_filehandle.emit()
|
send_filehandle.emit(filehandle_path)
|
||||||
|
|
||||||
|
|
||||||
func set_mouse_mode_emit(mode: int) -> void:
|
func set_mouse_mode_emit(mode: int) -> void:
|
||||||
|
|
|
@ -14,10 +14,11 @@ func _physics_process(_delta: float) -> void:
|
||||||
|
|
||||||
|
|
||||||
func _execute_function(command: Command) -> Variant:
|
func _execute_function(command: Command) -> Variant:
|
||||||
Debug.logclr("Recieved command: " + command.name, Color.SANDY_BROWN)
|
Debug.logclr("Recieved command: " + command.name + ". Args: " + str(command.args), Color.SANDY_BROWN)
|
||||||
match command.name:
|
match command.name:
|
||||||
"send_filehandle":
|
"send_filehandle":
|
||||||
command_events.send_filehandle_emit()
|
if command.args.size() != 1: Debug.logerr("Arg count should be 1"); return ""
|
||||||
|
command_events.send_filehandle_emit(command.args[0])
|
||||||
"set_mouse_mode":
|
"set_mouse_mode":
|
||||||
if command.args.size() != 1: Debug.logerr("Arg count should be 1"); return ""
|
if command.args.size() != 1: Debug.logerr("Arg count should be 1"); return ""
|
||||||
command_events.set_mouse_mode_emit(command.args[0])
|
command_events.set_mouse_mode_emit(command.args[0])
|
||||||
|
|
|
@ -8,16 +8,12 @@ class_name RenderResult
|
||||||
@onready var width = get_viewport().size.x
|
@onready var width = get_viewport().size.x
|
||||||
@onready var height = get_viewport().size.y
|
@onready var height = get_viewport().size.y
|
||||||
|
|
||||||
var fd_path: String
|
|
||||||
var rd: RenderingDevice
|
var rd: RenderingDevice
|
||||||
var ext_texure: ExternalTexture
|
var ext_texure: ExternalTexture
|
||||||
var texture_rid: RID
|
var texture_rid: RID
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
if OS.get_name() == "Windows": fd_path = "ipc://external_texture"
|
|
||||||
else: fd_path = "/tmp/external_texture"
|
|
||||||
|
|
||||||
gate_events.gate_entered.connect(create_external_texture)
|
gate_events.gate_entered.connect(create_external_texture)
|
||||||
command_events.send_filehandle.connect(send_filehandle)
|
command_events.send_filehandle.connect(send_filehandle)
|
||||||
initialize()
|
initialize()
|
||||||
|
@ -30,7 +26,6 @@ func initialize() -> void:
|
||||||
self.texture = ImageTexture.create_from_image(image)
|
self.texture = ImageTexture.create_from_image(image)
|
||||||
texture_rid = RenderingServer.texture_get_rd_texture(self.texture.get_rid())
|
texture_rid = RenderingServer.texture_get_rd_texture(self.texture.get_rid())
|
||||||
if not texture_rid.is_valid(): Debug.logerr("Cannot create ImageTexture")
|
if not texture_rid.is_valid(): Debug.logerr("Cannot create ImageTexture")
|
||||||
else: Debug.logclr("Render result texture created", Color.AQUAMARINE)
|
|
||||||
|
|
||||||
|
|
||||||
func create_external_texture() -> void:
|
func create_external_texture() -> void:
|
||||||
|
@ -53,11 +48,11 @@ func create_external_texture() -> void:
|
||||||
else: Debug.logclr("External texture created", Color.AQUAMARINE)
|
else: Debug.logclr("External texture created", Color.AQUAMARINE)
|
||||||
|
|
||||||
|
|
||||||
func send_filehandle() -> void:
|
func send_filehandle(filehandle_path: String) -> void:
|
||||||
Debug.logr("Sending send_filehandle...")
|
Debug.logr("Sending filehandle...")
|
||||||
var sent = false
|
var sent = false
|
||||||
while not sent:
|
while not sent:
|
||||||
sent = ext_texure.send_filehandle(fd_path)
|
sent = ext_texure.send_filehandle(filehandle_path)
|
||||||
await get_tree().create_timer(0.1).timeout
|
await get_tree().create_timer(0.1).timeout
|
||||||
Debug.logr("filehandle was sent")
|
Debug.logr("filehandle was sent")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue