Skip to content

Commit

Permalink
Merge pull request armory3d#2816 from rpaladin/clear-console
Browse files Browse the repository at this point in the history
New clear console option + logic node
  • Loading branch information
luboslenco committed Mar 7, 2023
2 parents 8a682f5 + 067e9b1 commit fc5054f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Sources/armory/logicnode/ClearConsoleNode.hx
@@ -0,0 +1,19 @@
package armory.logicnode;

class ClearConsoleNode extends LogicNode {

public function new(tree: LogicTree) {
super(tree);
}

override function run(from: Int) {

#if kha_krom
Krom.sysCommand("cls");
#elseif kha_html5
js.Syntax.code("console.clear();");
#end

runOutput(0);
}
}
12 changes: 12 additions & 0 deletions blender/arm/logicnode/native/LN_clear_console.py
@@ -0,0 +1,12 @@
from arm.logicnode.arm_nodes import *

class PrintNode(ArmLogicTreeNode):
"""Clears the system console."""
bl_idname = 'LNClearConsoleNode'
bl_label = 'Clear Console'
arm_version = 1

def arm_init(self, context):
self.add_input('ArmNodeSocketAction', 'In')

self.add_output('ArmNodeSocketAction', 'Out')
1 change: 1 addition & 0 deletions blender/arm/props.py
Expand Up @@ -244,6 +244,7 @@ def init_properties():
name="Assertion Level", description="Ignore all assertions below this level (assertions are turned off completely for published builds)", default='Warning', update=assets.invalidate_compiler_cache)
bpy.types.World.arm_assert_quit = BoolProperty(name="Quit On Assertion Fail", description="Whether to close the game when an 'Error' level assertion fails", default=False, update=assets.invalidate_compiler_cache)
bpy.types.World.arm_live_patch = BoolProperty(name="Live Patch", description="Live patching for Krom", default=False)
bpy.types.World.arm_clear_on_compile = BoolProperty(name="Clear Console", description="Clears the system console on compile", default=False)
bpy.types.World.arm_play_camera = EnumProperty(
items=[('Scene', 'Scene', 'Scene'),
('Viewport', 'Viewport', 'Viewport')],
Expand Down
9 changes: 9 additions & 0 deletions blender/arm/props_ui.py
Expand Up @@ -1055,6 +1055,7 @@ def draw(self, context):
col = layout.column(heading='Debug', align=True)
col.prop(wrd, 'arm_verbose_output')
col.prop(wrd, 'arm_cache_build')
col.prop(wrd, 'arm_clear_on_compile')
col.prop(wrd, 'arm_assert_level')
col.prop(wrd, 'arm_assert_quit')

Expand Down Expand Up @@ -1178,6 +1179,8 @@ def invoke(self, context, event):
return self.execute(context)

def execute(self, context):
wrd = bpy.data.worlds['Arm']

if state.proc_build is not None:
return {"CANCELLED"}

Expand All @@ -1194,6 +1197,8 @@ def execute(self, context):
arm.utils.check_default_props()

assets.invalidate_enabled = False
if wrd.arm_clear_on_compile:
os.system("cls")
make.play()
assets.invalidate_enabled = True
return{'FINISHED'}
Expand Down Expand Up @@ -1252,6 +1257,8 @@ def execute(self, context):
break
assets.invalidate_shader_cache(None, None)
assets.invalidate_enabled = False
if wrd.arm_clear_on_compile:
os.system("cls")
make.build(item.arm_project_target, is_export=True)
make.compile()
wrd.arm_rplist_index = rplist_index
Expand Down Expand Up @@ -1298,6 +1305,8 @@ def execute(self, context):

make.clean()
assets.invalidate_enabled = False
if wrd.arm_clear_on_compile:
os.system("cls")
make.build(item.arm_project_target, is_publish=True, is_export=True)
make.compile()
wrd.arm_rplist_index = rplist_index
Expand Down

0 comments on commit fc5054f

Please sign in to comment.