Log errors and show them in the blender UI

This commit is contained in:
N8n5h 2021-03-19 11:39:06 -03:00
parent d4463a3611
commit 57660631b5
2 changed files with 16 additions and 1 deletions

View file

@ -29,6 +29,7 @@ else:
info_text = ''
num_warnings = 0
num_errors = 0
def clear(clear_warnings=False):
global info_text, num_warnings
@ -62,4 +63,6 @@ def warn(text):
print_warn(text)
def error(text):
global num_errors
num_errors += 1
log('ERROR: ' + text, ERROR)

View file

@ -560,7 +560,19 @@ class ARM_PT_ArmoryPlayerPanel(bpy.types.Panel):
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')
warnings = 'warnings' if log.num_warnings > 1 else 'warning'
col.label(text=f'{log.num_warnings} {warnings} occurred during compilation!', icon='ERROR')
# Blank icon to achieve the same indentation as the line before
# prevent showing "open console" twice:
if log.num_errors == 0:
col.label(text='Please open the console to get more information.', icon='BLANK1')
if log.num_errors > 0:
box = layout.box()
# Less spacing between lines
col = box.column(align=True)
errors = 'errors' if log.num_errors > 1 else 'error'
col.label(text=f'{log.num_errors} {errors} occurred during compilation!', icon='CANCEL')
# Blank icon to achieve the same indentation as the line before
col.label(text='Please open the console to get more information.', icon='BLANK1')