mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 16:33:30 +00:00
add a [Signal] attribute to CSharpScripts
This commit is contained in:
parent
3d4bf5a90e
commit
efd52cd172
7 changed files with 103 additions and 1 deletions
|
@ -721,8 +721,10 @@ void CSharpLanguage::reload_assemblies_if_needed(bool p_soft_reload) {
|
|||
for (Map<Ref<CSharpScript>, Map<ObjectID, List<Pair<StringName, Variant> > > >::Element *E = to_reload.front(); E; E = E->next()) {
|
||||
|
||||
Ref<CSharpScript> scr = E->key();
|
||||
scr->signals_invalidated = true;
|
||||
scr->exports_invalidated = true;
|
||||
scr->reload(p_soft_reload);
|
||||
scr->update_signals();
|
||||
scr->update_exports();
|
||||
|
||||
//restore state if saved
|
||||
|
@ -755,8 +757,10 @@ void CSharpLanguage::reload_assemblies_if_needed(bool p_soft_reload) {
|
|||
//if instance states were saved, set them!
|
||||
}
|
||||
|
||||
if (Engine::get_singleton()->is_editor_hint())
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
EditorNode::get_singleton()->get_property_editor()->update_tree();
|
||||
NodeDock::singleton->update_lists();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1545,6 +1549,42 @@ bool CSharpScript::_update_exports() {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool CSharpScript::_update_signals() {
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (!valid)
|
||||
return false;
|
||||
|
||||
bool changed = false;
|
||||
|
||||
if (signals_invalidated) {
|
||||
signals_invalidated = false;
|
||||
|
||||
GDMonoClass *top = script_class;
|
||||
|
||||
_signals.clear();
|
||||
changed = true; // TODO Do a real check for change
|
||||
|
||||
while (top && top != native) {
|
||||
const Vector<GDMonoClass *> &delegates = top->get_all_delegates();
|
||||
for (int i = delegates.size() - 1; i >= 0; i--) {
|
||||
GDMonoClass *delegate = delegates[i];
|
||||
|
||||
if (delegate->has_attribute(CACHED_CLASS(SignalAttribute))) {
|
||||
StringName name = delegate->get_name();
|
||||
|
||||
_signals[name] = Vector<StringName>(); // TODO Retrieve arguments
|
||||
}
|
||||
}
|
||||
|
||||
top = top->get_parent_class();
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
bool CSharpScript::_get_member_export(GDMonoClass *p_class, GDMonoClassMember *p_member, PropertyInfo &r_prop_info, bool &r_exported) {
|
||||
|
||||
|
@ -1866,6 +1906,7 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
|
|||
PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(CSharpLanguage::get_singleton(), Ref<Script>(this), p_this));
|
||||
placeholders.insert(si);
|
||||
_update_exports();
|
||||
_update_signals();
|
||||
return si;
|
||||
#else
|
||||
return NULL;
|
||||
|
@ -2035,6 +2076,12 @@ void CSharpScript::update_exports() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void CSharpScript::update_signals() {
|
||||
#ifdef TOOLS_ENABLED
|
||||
_update_signals();
|
||||
#endif
|
||||
}
|
||||
|
||||
Ref<Script> CSharpScript::get_base_script() const {
|
||||
|
||||
// TODO search in metadata file once we have it, not important any way?
|
||||
|
@ -2099,6 +2146,7 @@ CSharpScript::CSharpScript() :
|
|||
#ifdef TOOLS_ENABLED
|
||||
source_changed_cache = false;
|
||||
exports_invalidated = true;
|
||||
signals_invalidated = true;
|
||||
#endif
|
||||
|
||||
_resource_path_changed();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue