Count compilation warnings and show them in the UI and console

This commit is contained in:
Moritz Brückner 2020-03-06 23:49:14 +01:00
parent 6e9dfd8504
commit 1da4b02cef
3 changed files with 22 additions and 10 deletions

View file

@ -1,12 +1,14 @@
info_text = ''
num_warnings = 0
def clear():
global info_text
def clear(clear_warnings=False):
global info_text, num_warnings
info_text = ''
if clear_warnings:
num_warnings = 0
def format_text(text):
return (text[:80] + '..') if len(text) > 80 else text # Limit str size
return (text[:80] + '..') if len(text) > 80 else text # Limit str size
def print_info(text):
global info_text
@ -14,4 +16,6 @@ def print_info(text):
info_text = format_text(text)
def warn(text):
global num_warnings
num_warnings += 1
print('Armory Warning: ' + text)

View file

@ -315,7 +315,7 @@ def build(target, is_play=False, is_publish=False, is_export=False):
if arm.utils.get_save_on_build():
bpy.ops.wm.save_mainfile()
log.clear()
log.clear(clear_warnings=True)
# Set camera in active scene
active_scene = arm.utils.get_active_scene()
@ -409,7 +409,9 @@ def compilation_server_done():
def build_done():
print('Finished in ' + str(time.time() - profile_time))
if state.proc_build == None:
if log.num_warnings > 0:
print(f'{log.num_warnings} warnings occurred during compilation!')
if state.proc_build is None:
return
result = state.proc_build.poll()
state.proc_build = None
@ -476,8 +478,6 @@ def play():
global scripts_mtime
wrd = bpy.data.worlds['Arm']
log.clear()
build(target=runtime_to_target(), is_play=True)
khajs_path = get_khajs_path(state.target)

View file

@ -265,7 +265,7 @@ class ARM_PT_ArmoryPlayerPanel(bpy.types.Panel):
wrd = bpy.data.worlds['Arm']
row = layout.row(align=True)
row.alignment = 'EXPAND'
if state.proc_play == None and state.proc_build == None:
if state.proc_play is None and state.proc_build is None:
row.operator("arm.play", icon="PLAY")
else:
row.operator("arm.stop", icon="MESH_PLANE")
@ -273,6 +273,14 @@ class ARM_PT_ArmoryPlayerPanel(bpy.types.Panel):
layout.prop(wrd, 'arm_runtime')
layout.prop(wrd, 'arm_play_camera')
if log.num_warnings > 0:
box = layout.box()
# Less spacing between lines
col = box.column(align=True)
col.label(text=f'{log.num_warnings} warnings occurred during compilation!', icon='ERROR')
# Blank icon to achieve the same indentation as the line before
col.label(text='Please open the console to get more information.', icon='BLANK1')
class ARM_PT_ArmoryExporterPanel(bpy.types.Panel):
bl_label = "Armory Exporter"
bl_space_type = "PROPERTIES"
@ -612,7 +620,7 @@ class ArmoryCleanProjectButton(bpy.types.Operator):
return{'FINISHED'}
def draw_view3d_header(self, context):
if state.proc_build != None:
if state.proc_build is not None:
self.layout.label(text='Compiling..')
elif log.info_text != '':
self.layout.label(text=log.info_text)