Hi, I’m working on an editor plugin.
my problem is I have a few processes in my plugin that take some time and I want to show progress, the problem is the editor freezes and then the process is done, so how to show progress exactly?
I am also making an Editor Plugin and face this issue. The code I have (and was helped with too) is partially:
# Thanks to https://mastodon.gamedev.place/@exoticorn
# Honestly, this func bends my brain! Thanks Exoticorn.
func feedback(msg:StringName, style=&"NORMAL"):
var msg_speed := 1
var _time
_messages.push_back([msg,style])
if _messages.size() == 1:
%feedback.show()
while not _messages.is_empty():
var num:=_messages.size()
_time = msg_speed/num
var _tup = _messages[0]
var _msg = _tup[0]
%feedback/msg.text = _msg
var styl = _tup[1]
if styl == &"WARNING":
%feedback/icon.texture = get_theme_icon(
&"StatusWarning", &"EditorIcons")
push_warning(_msg)
elif styl == &"ERROR":
%feedback/icon.texture = get_theme_icon(
&"StatusError", &"EditorIcons")
push_error(_msg)
else:
%feedback/icon.texture = get_theme_icon(
&"NodeInfo", &"EditorIcons")
print("Feedback: ", _msg)
await get_tree().create_timer(_time).timeout
_messages.pop_front()
%feedback.hide()
This is in a script that is on a UI node (for my plugin). %feedback is a MarginContainer, iirc.
It is called either directly: _main_view.feedback("Possible infinite loop in Array.", &"WARNING")
or by a signal: feedback.emit("%s is not supported." % working_resource, &"NORMAL")
(Where feedback is defined as a signal and is connected to the feedback func)