Merge pull request #1400 from BlackGoku36/master
Adds canvas element get/set location, rotation, scale and progress bar nodes
This commit is contained in:
commit
7f280538d7
42
Sources/armory/logicnode/CanvasGetLocationNode.hx
Normal file
42
Sources/armory/logicnode/CanvasGetLocationNode.hx
Normal file
|
@ -0,0 +1,42 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import armory.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasGetLocationNode extends LogicNode {
|
||||
|
||||
var canvas:CanvasScript;
|
||||
var element:String;
|
||||
var x:Float;
|
||||
var y:Float;
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if arm_ui
|
||||
function update() {
|
||||
if (!canvas.ready) return;
|
||||
tree.removeUpdate(update);
|
||||
|
||||
x = canvas.getElement(element).x;
|
||||
y = canvas.getElement(element).y;
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function run(from:Int) {
|
||||
element = inputs[1].get();
|
||||
canvas = Scene.active.getTrait(CanvasScript);
|
||||
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
|
||||
|
||||
// Ensure canvas is ready
|
||||
tree.notifyOnUpdate(update);
|
||||
update();
|
||||
}
|
||||
override function get(from:Int):Dynamic {
|
||||
if (from == 1) return x;
|
||||
else if (from == 2) return y;
|
||||
else return 0;
|
||||
}
|
||||
#end
|
||||
}
|
42
Sources/armory/logicnode/CanvasGetPBNode.hx
Normal file
42
Sources/armory/logicnode/CanvasGetPBNode.hx
Normal file
|
@ -0,0 +1,42 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import armory.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasGetPBNode extends LogicNode {
|
||||
|
||||
var canvas:CanvasScript;
|
||||
var element:String;
|
||||
var at:Int;
|
||||
var max:Int;
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if arm_ui
|
||||
function update() {
|
||||
if (!canvas.ready) return;
|
||||
tree.removeUpdate(update);
|
||||
|
||||
at = canvas.getElement(element).progress_at;
|
||||
max = canvas.getElement(element).progress_total;
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function run(from:Int) {
|
||||
element = inputs[1].get();
|
||||
canvas = Scene.active.getTrait(CanvasScript);
|
||||
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
|
||||
|
||||
// Ensure canvas is ready
|
||||
tree.notifyOnUpdate(update);
|
||||
update();
|
||||
}
|
||||
override function get(from:Int):Dynamic {
|
||||
if (from == 1) return at;
|
||||
else if (from == 2) return max;
|
||||
else return 0;
|
||||
}
|
||||
#end
|
||||
}
|
40
Sources/armory/logicnode/CanvasGetRotationNode.hx
Normal file
40
Sources/armory/logicnode/CanvasGetRotationNode.hx
Normal file
|
@ -0,0 +1,40 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import armory.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasGetRotationNode extends LogicNode {
|
||||
|
||||
var canvas:CanvasScript;
|
||||
var element:String;
|
||||
var rad:Float;
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if arm_ui
|
||||
function update() {
|
||||
if (!canvas.ready) return;
|
||||
tree.removeUpdate(update);
|
||||
|
||||
rad = canvas.getElement(element).rotation;
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function run(from:Int) {
|
||||
element = inputs[1].get();
|
||||
canvas = Scene.active.getTrait(CanvasScript);
|
||||
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
|
||||
|
||||
// Ensure canvas is ready
|
||||
tree.notifyOnUpdate(update);
|
||||
update();
|
||||
}
|
||||
override function get(from:Int):Dynamic {
|
||||
if (from == 1) return rad;
|
||||
else return 0;
|
||||
}
|
||||
#end
|
||||
}
|
42
Sources/armory/logicnode/CanvasGetScaleNode.hx
Normal file
42
Sources/armory/logicnode/CanvasGetScaleNode.hx
Normal file
|
@ -0,0 +1,42 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import armory.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasGetScaleNode extends LogicNode {
|
||||
|
||||
var canvas:CanvasScript;
|
||||
var element:String;
|
||||
var width:Int;
|
||||
var height:Int;
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if arm_ui
|
||||
function update() {
|
||||
if (!canvas.ready) return;
|
||||
tree.removeUpdate(update);
|
||||
|
||||
height = canvas.getElement(element).height;
|
||||
width = canvas.getElement(element).width;
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function run(from:Int) {
|
||||
element = inputs[1].get();
|
||||
canvas = Scene.active.getTrait(CanvasScript);
|
||||
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
|
||||
|
||||
// Ensure canvas is ready
|
||||
tree.notifyOnUpdate(update);
|
||||
update();
|
||||
}
|
||||
override function get(from:Int):Dynamic {
|
||||
if (from == 1) return height;
|
||||
else if (from == 2) return width;
|
||||
else return 0;
|
||||
}
|
||||
#end
|
||||
}
|
40
Sources/armory/logicnode/CanvasSetPBNode.hx
Normal file
40
Sources/armory/logicnode/CanvasSetPBNode.hx
Normal file
|
@ -0,0 +1,40 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import armory.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasSetPBNode extends LogicNode {
|
||||
|
||||
var canvas:CanvasScript;
|
||||
var element:String;
|
||||
var newAt:Int;
|
||||
var newMax:Int;
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if arm_ui
|
||||
function update() {
|
||||
if (!canvas.ready) return;
|
||||
tree.removeUpdate(update);
|
||||
|
||||
canvas.getElement(element).progress_at = newAt;
|
||||
canvas.getElement(element).progress_total = newMax;
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function run(from:Int) {
|
||||
element = inputs[1].get();
|
||||
newAt = inputs[2].get();
|
||||
newMax = inputs[3].get();
|
||||
canvas = Scene.active.getTrait(CanvasScript);
|
||||
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
|
||||
|
||||
// Ensure canvas is ready
|
||||
tree.notifyOnUpdate(update);
|
||||
update();
|
||||
}
|
||||
#end
|
||||
}
|
36
Sources/armory/logicnode/CanvasSetRotationNode.hx
Normal file
36
Sources/armory/logicnode/CanvasSetRotationNode.hx
Normal file
|
@ -0,0 +1,36 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import armory.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasSetRotationNode extends LogicNode {
|
||||
|
||||
var canvas:CanvasScript;
|
||||
var element:String;
|
||||
var rad:Float;
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if arm_ui
|
||||
function update() {
|
||||
if (!canvas.ready) return;
|
||||
tree.removeUpdate(update);
|
||||
|
||||
canvas.getElement(element).rotation = rad;
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function run(from:Int) {
|
||||
element = inputs[1].get();
|
||||
rad = inputs[2].get();
|
||||
canvas = Scene.active.getTrait(CanvasScript);
|
||||
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
|
||||
|
||||
// Ensure canvas is ready
|
||||
tree.notifyOnUpdate(update);
|
||||
update();
|
||||
}
|
||||
#end
|
||||
}
|
39
Sources/armory/logicnode/CanvasSetScaleNode.hx
Normal file
39
Sources/armory/logicnode/CanvasSetScaleNode.hx
Normal file
|
@ -0,0 +1,39 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.Scene;
|
||||
import armory.trait.internal.CanvasScript;
|
||||
|
||||
class CanvasSetScaleNode extends LogicNode {
|
||||
|
||||
var canvas:CanvasScript;
|
||||
var element:String;
|
||||
var height:Int;
|
||||
var width:Int;
|
||||
|
||||
public function new(tree:LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
#if arm_ui
|
||||
function update() {
|
||||
if (!canvas.ready) return;
|
||||
tree.removeUpdate(update);
|
||||
|
||||
canvas.getElement(element).height = height;
|
||||
canvas.getElement(element).width = width;
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
override function run(from:Int) {
|
||||
element = inputs[1].get();
|
||||
height = inputs[2].get();
|
||||
width = inputs[3].get();
|
||||
canvas = Scene.active.getTrait(CanvasScript);
|
||||
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
|
||||
|
||||
// Ensure canvas is ready
|
||||
tree.notifyOnUpdate(update);
|
||||
update();
|
||||
}
|
||||
#end
|
||||
}
|
19
blender/arm/logicnode/canvas_get_location.py
Normal file
19
blender/arm/logicnode/canvas_get_location.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import bpy
|
||||
from bpy.props import *
|
||||
from bpy.types import Node, NodeSocket
|
||||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class CanvasGetLocationNode(Node, ArmLogicTreeNode):
|
||||
'''Get canvas element location'''
|
||||
bl_idname = 'LNCanvasGetLocationNode'
|
||||
bl_label = 'Canvas Get Location'
|
||||
bl_icon = 'QUESTION'
|
||||
|
||||
def init(self, context):
|
||||
self.inputs.new('ArmNodeSocketAction', 'In')
|
||||
self.inputs.new('NodeSocketString', 'Element')
|
||||
self.outputs.new('ArmNodeSocketAction', 'Out')
|
||||
self.outputs.new('NodeSocketFloat', 'X')
|
||||
self.outputs.new('NodeSocketFloat', 'Y')
|
||||
|
||||
add_node(CanvasGetLocationNode, category='Canvas')
|
19
blender/arm/logicnode/canvas_get_pb.py
Normal file
19
blender/arm/logicnode/canvas_get_pb.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import bpy
|
||||
from bpy.props import *
|
||||
from bpy.types import Node, NodeSocket
|
||||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class CanvasGetPBNode(Node, ArmLogicTreeNode):
|
||||
'''Get canvas progress bar'''
|
||||
bl_idname = 'LNCanvasGetPBNode'
|
||||
bl_label = 'Canvas Get Progress Bar'
|
||||
bl_icon = 'QUESTION'
|
||||
|
||||
def init(self, context):
|
||||
self.inputs.new('ArmNodeSocketAction', 'In')
|
||||
self.inputs.new('NodeSocketString', 'Element')
|
||||
self.outputs.new('ArmNodeSocketAction', 'Out')
|
||||
self.outputs.new('NodeSocketInt', 'At')
|
||||
self.outputs.new('NodeSocketInt', 'Max')
|
||||
|
||||
add_node(CanvasGetPBNode, category='Canvas')
|
18
blender/arm/logicnode/canvas_get_rotation.py
Normal file
18
blender/arm/logicnode/canvas_get_rotation.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import bpy
|
||||
from bpy.props import *
|
||||
from bpy.types import Node, NodeSocket
|
||||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class CanvasGetRotationNode(Node, ArmLogicTreeNode):
|
||||
'''Get canvas element rotation'''
|
||||
bl_idname = 'LNCanvasGetRotationNode'
|
||||
bl_label = 'Canvas Get Rotation'
|
||||
bl_icon = 'QUESTION'
|
||||
|
||||
def init(self, context):
|
||||
self.inputs.new('ArmNodeSocketAction', 'In')
|
||||
self.inputs.new('NodeSocketString', 'Element')
|
||||
self.outputs.new('ArmNodeSocketAction', 'Out')
|
||||
self.outputs.new('NodeSocketFloat', 'Rad')
|
||||
|
||||
add_node(CanvasGetRotationNode, category='Canvas')
|
19
blender/arm/logicnode/canvas_get_scale.py
Normal file
19
blender/arm/logicnode/canvas_get_scale.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import bpy
|
||||
from bpy.props import *
|
||||
from bpy.types import Node, NodeSocket
|
||||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class CanvasGetScaleNode(Node, ArmLogicTreeNode):
|
||||
'''Get canvas element scale'''
|
||||
bl_idname = 'LNCanvasGetScaleNode'
|
||||
bl_label = 'Canvas Get Scale'
|
||||
bl_icon = 'QUESTION'
|
||||
|
||||
def init(self, context):
|
||||
self.inputs.new('ArmNodeSocketAction', 'In')
|
||||
self.inputs.new('NodeSocketString', 'Element')
|
||||
self.outputs.new('ArmNodeSocketAction', 'Out')
|
||||
self.outputs.new('NodeSocketInt', 'Height')
|
||||
self.outputs.new('NodeSocketInt', 'Width')
|
||||
|
||||
add_node(CanvasGetScaleNode, category='Canvas')
|
|
@ -4,7 +4,7 @@ from bpy.types import Node, NodeSocket
|
|||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class CanvasSetLocationNode(Node, ArmLogicTreeNode):
|
||||
'''Set canvas element position'''
|
||||
'''Set canvas element location'''
|
||||
bl_idname = 'LNCanvasSetLocationNode'
|
||||
bl_label = 'Canvas Set Location'
|
||||
bl_icon = 'QUESTION'
|
||||
|
|
19
blender/arm/logicnode/canvas_set_pb.py
Normal file
19
blender/arm/logicnode/canvas_set_pb.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import bpy
|
||||
from bpy.props import *
|
||||
from bpy.types import Node, NodeSocket
|
||||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class CanvasSetPBNode(Node, ArmLogicTreeNode):
|
||||
'''Set canvas progress bar'''
|
||||
bl_idname = 'LNCanvasSetPBNode'
|
||||
bl_label = 'Canvas Set Progress Bar'
|
||||
bl_icon = 'QUESTION'
|
||||
|
||||
def init(self, context):
|
||||
self.inputs.new('ArmNodeSocketAction', 'In')
|
||||
self.inputs.new('NodeSocketString', 'Element')
|
||||
self.inputs.new('NodeSocketInt', 'At')
|
||||
self.inputs.new('NodeSocketInt', 'Max')
|
||||
self.outputs.new('ArmNodeSocketAction', 'Out')
|
||||
|
||||
add_node(CanvasSetPBNode, category='Canvas')
|
18
blender/arm/logicnode/canvas_set_rotation.py
Normal file
18
blender/arm/logicnode/canvas_set_rotation.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import bpy
|
||||
from bpy.props import *
|
||||
from bpy.types import Node, NodeSocket
|
||||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class CanvasSetRotationNode(Node, ArmLogicTreeNode):
|
||||
'''Set canvas element rotation'''
|
||||
bl_idname = 'LNCanvasSetRotationNode'
|
||||
bl_label = 'Canvas Set Rotation'
|
||||
bl_icon = 'QUESTION'
|
||||
|
||||
def init(self, context):
|
||||
self.inputs.new('ArmNodeSocketAction', 'In')
|
||||
self.inputs.new('NodeSocketString', 'Element')
|
||||
self.inputs.new('NodeSocketFloat', 'Rad')
|
||||
self.outputs.new('ArmNodeSocketAction', 'Out')
|
||||
|
||||
add_node(CanvasSetRotationNode, category='Canvas')
|
19
blender/arm/logicnode/canvas_set_scale.py
Normal file
19
blender/arm/logicnode/canvas_set_scale.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import bpy
|
||||
from bpy.props import *
|
||||
from bpy.types import Node, NodeSocket
|
||||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class CanvasSetScaleNode(Node, ArmLogicTreeNode):
|
||||
'''Set canvas element scale'''
|
||||
bl_idname = 'LNCanvasSetScaleNode'
|
||||
bl_label = 'Canvas Set Scale'
|
||||
bl_icon = 'QUESTION'
|
||||
|
||||
def init(self, context):
|
||||
self.inputs.new('ArmNodeSocketAction', 'In')
|
||||
self.inputs.new('NodeSocketString', 'Element')
|
||||
self.inputs.new('NodeSocketInt', 'Height')
|
||||
self.inputs.new('NodeSocketInt', 'Width')
|
||||
self.outputs.new('ArmNodeSocketAction', 'Out')
|
||||
|
||||
add_node(CanvasSetScaleNode, category='Canvas')
|
Loading…
Reference in a new issue