mirror of
https://github.com/godotengine/godot.git
synced 2024-11-25 13:43:15 +00:00
Merge pull request #30852 from swarnimarun/vs_tools_script
Tool Mode for Visualscript
This commit is contained in:
commit
72d87cfbce
@ -578,6 +578,10 @@ void VisualScript::get_data_connection_list(const StringName &p_func, List<DataC
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScript::set_tool_enabled(bool p_enabled) {
|
||||
is_tool_script = p_enabled;
|
||||
}
|
||||
|
||||
void VisualScript::add_variable(const StringName &p_name, const Variant &p_default_value, bool p_export) {
|
||||
|
||||
ERR_FAIL_COND(instances.size());
|
||||
@ -894,7 +898,7 @@ ScriptInstance *VisualScript::instance_create(Object *p_this) {
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
if (!ScriptServer::is_scripting_enabled()) {
|
||||
if (!ScriptServer::is_scripting_enabled() && !is_tool_script) {
|
||||
|
||||
PlaceHolderScriptInstance *sins = memnew(PlaceHolderScriptInstance(VisualScriptLanguage::singleton, Ref<Script>((Script *)this), p_this));
|
||||
placeholders.insert(sins);
|
||||
@ -958,7 +962,7 @@ Error VisualScript::reload(bool p_keep_state) {
|
||||
|
||||
bool VisualScript::is_tool() const {
|
||||
|
||||
return false;
|
||||
return is_tool_script;
|
||||
}
|
||||
|
||||
bool VisualScript::is_valid() const {
|
||||
@ -1164,6 +1168,11 @@ void VisualScript::_set_data(const Dictionary &p_data) {
|
||||
data_connect(name, data_connections[j + 0], data_connections[j + 1], data_connections[j + 2], data_connections[j + 3]);
|
||||
}
|
||||
}
|
||||
|
||||
if (d.has("is_tool_script"))
|
||||
is_tool_script = d["is_tool_script"];
|
||||
else
|
||||
is_tool_script = false;
|
||||
}
|
||||
|
||||
Dictionary VisualScript::_get_data() const {
|
||||
@ -1246,6 +1255,8 @@ Dictionary VisualScript::_get_data() const {
|
||||
|
||||
d["functions"] = funcs;
|
||||
|
||||
d["is_tool_script"] = is_tool_script;
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
|
@ -247,6 +247,8 @@ private:
|
||||
|
||||
Map<Object *, VisualScriptInstance *> instances;
|
||||
|
||||
bool is_tool_script;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
Set<PlaceHolderScriptInstance *> placeholders;
|
||||
//void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
|
||||
@ -273,6 +275,7 @@ public:
|
||||
Vector2 get_function_scroll(const StringName &p_name) const;
|
||||
void get_function_list(List<StringName> *r_functions) const;
|
||||
int get_function_node_id(const StringName &p_name) const;
|
||||
void set_tool_enabled(bool p_enabled);
|
||||
|
||||
void add_node(const StringName &p_func, int p_id, const Ref<VisualScriptNode> &p_node, const Point2 &p_pos = Point2());
|
||||
void remove_node(const StringName &p_func, int p_id);
|
||||
|
@ -2227,6 +2227,10 @@ void VisualScriptEditor::_change_base_type() {
|
||||
select_base_type->popup_create(true, true);
|
||||
}
|
||||
|
||||
void VisualScriptEditor::_toggle_tool_script() {
|
||||
script->set_tool_enabled(!script->is_tool());
|
||||
}
|
||||
|
||||
void VisualScriptEditor::clear_edit_menu() {
|
||||
memdelete(edit_menu);
|
||||
memdelete(left_vsplit);
|
||||
@ -3448,6 +3452,7 @@ void VisualScriptEditor::_bind_methods() {
|
||||
ClassDB::bind_method("_update_members", &VisualScriptEditor::_update_members);
|
||||
ClassDB::bind_method("_change_base_type", &VisualScriptEditor::_change_base_type);
|
||||
ClassDB::bind_method("_change_base_type_callback", &VisualScriptEditor::_change_base_type_callback);
|
||||
ClassDB::bind_method("_toggle_tool_script", &VisualScriptEditor::_toggle_tool_script);
|
||||
ClassDB::bind_method("_node_selected", &VisualScriptEditor::_node_selected);
|
||||
ClassDB::bind_method("_node_moved", &VisualScriptEditor::_node_moved);
|
||||
ClassDB::bind_method("_move_node", &VisualScriptEditor::_move_node);
|
||||
@ -3533,6 +3538,11 @@ VisualScriptEditor::VisualScriptEditor() {
|
||||
left_vb->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
//left_vb->set_custom_minimum_size(Size2(230, 1) * EDSCALE);
|
||||
|
||||
CheckButton *tool_script_check = memnew(CheckButton);
|
||||
tool_script_check->set_text(TTR("Make Tool:"));
|
||||
left_vb->add_child(tool_script_check);
|
||||
tool_script_check->connect("pressed", this, "_toggle_tool_script");
|
||||
|
||||
base_type_select = memnew(Button);
|
||||
left_vb->add_margin_child(TTR("Base Type:"), base_type_select);
|
||||
base_type_select->connect("pressed", this, "_change_base_type");
|
||||
|
@ -186,6 +186,7 @@ class VisualScriptEditor : public ScriptEditorBase {
|
||||
void _node_filter_changed(const String &p_text);
|
||||
void _change_base_type_callback();
|
||||
void _change_base_type();
|
||||
void _toggle_tool_script();
|
||||
void _member_selected();
|
||||
void _member_edited();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user