From 914452de2c4a2273ad9dd58484dbd38a9c77e227 Mon Sep 17 00:00:00 2001 From: t3du <32546729+t3du@users.noreply.github.com> Date: Thu, 26 Dec 2024 19:13:46 -0300 Subject: [PATCH 1/2] Add files via upload --- .../arm/logicnode/native/LN_loadUrl.py | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/armory/blender/arm/logicnode/native/LN_loadUrl.py b/armory/blender/arm/logicnode/native/LN_loadUrl.py index fbbed12bce..a8b6df4905 100644 --- a/armory/blender/arm/logicnode/native/LN_loadUrl.py +++ b/armory/blender/arm/logicnode/native/LN_loadUrl.py @@ -1,11 +1,38 @@ from arm.logicnode.arm_nodes import * class LoadUrlNode(ArmLogicTreeNode): - """Load the given URL in a new tab (works only for web browsers).""" + """Load the given URL in a new or existing tab (works only for web browsers). + + @input URL: use a complete url or partial for a subpage. + @input New: open a new window or redirect existing one. + @input Use values: W,H,L,T: open a new window using Width, Height, Left and Top values. + @input Width: width for New window. + @input Height: height for New window. + @input Left: distance from left for New window position. + @input Top: distance from top for New window position. + + @output True: for New returns true if the window is opened. + @output False: for New returns false if the window is not opened (popup blocked). + """ bl_idname = 'LNLoadUrlNode' bl_label = 'Load URL' - arm_version = 1 + arm_version = 2 def arm_init(self, context): self.add_input('ArmNodeSocketAction', 'In') self.add_input('ArmStringSocket', 'URL') + self.add_input('ArmBoolSocket', 'New Window', default_value=True) + self.add_input('ArmBoolSocket', 'Use values: W,H,L,T', default_value=False) + self.add_input('ArmIntSocket', 'Width', default_value= 500) + self.add_input('ArmIntSocket', 'Height', default_value= 500) + self.add_input('ArmIntSocket', 'Left') + self.add_input('ArmIntSocket', 'Top') + + self.add_output('ArmNodeSocketAction', 'True') + self.add_output('ArmNodeSocketAction', 'False') + + def get_replacement_node(self, node_tree: bpy.types.NodeTree): + if self.arm_version not in (0, 1): + raise LookupError() + + return NodeReplacement.Identity(self) From 40fc96166d7e9b6aa631dc8cd82453e4950f5da5 Mon Sep 17 00:00:00 2001 From: t3du <32546729+t3du@users.noreply.github.com> Date: Thu, 26 Dec 2024 19:14:10 -0300 Subject: [PATCH 2/2] Add files via upload --- armory/Sources/armory/logicnode/LoadUrlNode.hx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/armory/Sources/armory/logicnode/LoadUrlNode.hx b/armory/Sources/armory/logicnode/LoadUrlNode.hx index 7bf8854994..f68fe39dd6 100644 --- a/armory/Sources/armory/logicnode/LoadUrlNode.hx +++ b/armory/Sources/armory/logicnode/LoadUrlNode.hx @@ -11,6 +11,20 @@ class LoadUrlNode extends LogicNode { } override function run(from: Int) { - System.loadUrl(inputs[1].get()); + //System.loadUrl(inputs[1].get()); + + #if kha_html5 + if (inputs[2].get()){ + var window = inputs[3].get() ? js.Browser.window.open(inputs[1].get(), "_blank", "width="+inputs[4].get()+",height="+inputs[5].get()+",left="+inputs[6].get()+",top="+inputs[7].get()) + : js.Browser.window.open(inputs[1].get(), "_blank"); + + if(window != null) + runOutput(0); + else + runOutput(1); + } + else + js.Browser.window.open(inputs[1].get(), "_self"); + #end } }