-Moved script run to editor, removed from project
-fixed to code completion -fix shader crash bug reported by tagcup
This commit is contained in:
parent
909c9e0ba0
commit
d23f323cde
@ -1971,7 +1971,6 @@ FRAGMENT_SHADER_CODE
|
|||||||
|
|
||||||
|
|
||||||
#ifdef SHADELESS
|
#ifdef SHADELESS
|
||||||
frag_color=vec4(albedo,alpha);
|
|
||||||
diffuse_buffer=vec4(albedo.rgb,0.0);
|
diffuse_buffer=vec4(albedo.rgb,0.0);
|
||||||
specular_buffer=vec4(0.0);
|
specular_buffer=vec4(0.0);
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@
|
|||||||
#include "editor/editor_help.h"
|
#include "editor/editor_help.h"
|
||||||
#include "editor/editor_initialize_ssl.h"
|
#include "editor/editor_initialize_ssl.h"
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
#include "editor/editor_settings.h"
|
|
||||||
#include "editor/editor_themes.h"
|
#include "editor/editor_themes.h"
|
||||||
#include "editor/import/editor_import_collada.h"
|
#include "editor/import/editor_import_collada.h"
|
||||||
#include "editor/import/editor_scene_importer_gltf.h"
|
#include "editor/import/editor_scene_importer_gltf.h"
|
||||||
@ -972,26 +971,6 @@ void EditorNode::_dialog_action(String p_file) {
|
|||||||
//would be nice to show the project manager opened with the highlighted field..
|
//would be nice to show the project manager opened with the highlighted field..
|
||||||
_run(false, ""); // automatically run the project
|
_run(false, ""); // automatically run the project
|
||||||
} break;
|
} break;
|
||||||
case FILE_RUN_SCRIPT: {
|
|
||||||
|
|
||||||
Ref<Script> scr = ResourceLoader::load(p_file, "Script", true);
|
|
||||||
if (scr.is_null()) {
|
|
||||||
add_io_error("Script Failed to Load:\n" + p_file);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!scr->is_tool()) {
|
|
||||||
|
|
||||||
add_io_error("Script is not tool, will not be able to run:\n" + p_file);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ref<EditorScript> es = memnew(EditorScript);
|
|
||||||
es->set_script(scr.get_ref_ptr());
|
|
||||||
es->set_editor(this);
|
|
||||||
es->_run();
|
|
||||||
|
|
||||||
get_undo_redo()->clear_history();
|
|
||||||
} break;
|
|
||||||
case FILE_CLOSE:
|
case FILE_CLOSE:
|
||||||
case FILE_CLOSE_ALL_AND_QUIT:
|
case FILE_CLOSE_ALL_AND_QUIT:
|
||||||
case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER:
|
case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER:
|
||||||
@ -1652,10 +1631,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||||||
quick_open->set_title(TTR("Quick Open Script.."));
|
quick_open->set_title(TTR("Quick Open Script.."));
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case FILE_RUN_SCRIPT: {
|
|
||||||
|
|
||||||
file_script->popup_centered_ratio();
|
|
||||||
} break;
|
|
||||||
case FILE_OPEN_PREV: {
|
case FILE_OPEN_PREV: {
|
||||||
|
|
||||||
if (previous_scenes.empty())
|
if (previous_scenes.empty())
|
||||||
@ -4806,7 +4781,7 @@ EditorNode::EditorNode() {
|
|||||||
p->add_item(TTR("Project Settings"), RUN_SETTINGS);
|
p->add_item(TTR("Project Settings"), RUN_SETTINGS);
|
||||||
p->add_separator();
|
p->add_separator();
|
||||||
p->connect("id_pressed", this, "_menu_option");
|
p->connect("id_pressed", this, "_menu_option");
|
||||||
p->add_item(TTR("Run Script"), FILE_RUN_SCRIPT, KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_R);
|
//p->add_item(TTR("Run Script"), FILE_RUN_SCRIPT, KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_R);
|
||||||
p->add_item(TTR("Export"), FILE_EXPORT_PROJECT);
|
p->add_item(TTR("Export"), FILE_EXPORT_PROJECT);
|
||||||
|
|
||||||
PopupMenu *tool_menu = memnew(PopupMenu);
|
PopupMenu *tool_menu = memnew(PopupMenu);
|
||||||
|
@ -129,7 +129,6 @@ private:
|
|||||||
FILE_OPEN_OLD_SCENE,
|
FILE_OPEN_OLD_SCENE,
|
||||||
FILE_QUICK_OPEN_SCENE,
|
FILE_QUICK_OPEN_SCENE,
|
||||||
FILE_QUICK_OPEN_SCRIPT,
|
FILE_QUICK_OPEN_SCRIPT,
|
||||||
FILE_RUN_SCRIPT,
|
|
||||||
FILE_OPEN_PREV,
|
FILE_OPEN_PREV,
|
||||||
FILE_CLOSE,
|
FILE_CLOSE,
|
||||||
FILE_CLOSE_ALL_AND_QUIT,
|
FILE_CLOSE_ALL_AND_QUIT,
|
||||||
|
@ -965,7 +965,33 @@ void ScriptEditor::_menu_option(int p_option) {
|
|||||||
current->reload(p_option == FILE_TOOL_RELOAD_SOFT);
|
current->reload(p_option == FILE_TOOL_RELOAD_SOFT);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
case FILE_RUN: {
|
||||||
|
|
||||||
|
Ref<Script> scr = current->get_edited_script();
|
||||||
|
if (scr.is_null()) {
|
||||||
|
EditorNode::get_singleton()->show_warning("Can't obtain the script for running");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!scr->is_tool()) {
|
||||||
|
|
||||||
|
EditorNode::get_singleton()->show_warning("Script is not in tool mode, will not be able to run");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ClassDB::is_parent_class(scr->get_instance_base_type(), "EditorScript")) {
|
||||||
|
|
||||||
|
EditorNode::get_singleton()->show_warning("To run this script, it must inherit EditorScript and be set to tool mode");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<EditorScript> es = memnew(EditorScript);
|
||||||
|
es->set_script(scr.get_ref_ptr());
|
||||||
|
es->set_editor(EditorNode::get_singleton());
|
||||||
|
|
||||||
|
es->_run();
|
||||||
|
|
||||||
|
EditorNode::get_undo_redo()->clear_history();
|
||||||
|
} break;
|
||||||
case FILE_CLOSE: {
|
case FILE_CLOSE: {
|
||||||
if (current->is_unsaved()) {
|
if (current->is_unsaved()) {
|
||||||
_ask_close_current_unsaved_tab(current);
|
_ask_close_current_unsaved_tab(current);
|
||||||
@ -2220,6 +2246,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
|
|||||||
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_file", TTR("Close"), KEY_MASK_CMD | KEY_W), FILE_CLOSE);
|
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_file", TTR("Close"), KEY_MASK_CMD | KEY_W), FILE_CLOSE);
|
||||||
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_all", TTR("Close All")), CLOSE_ALL);
|
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_all", TTR("Close All")), CLOSE_ALL);
|
||||||
file_menu->get_popup()->add_separator();
|
file_menu->get_popup()->add_separator();
|
||||||
|
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/run_file", TTR("Run"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_X), FILE_RUN);
|
||||||
|
file_menu->get_popup()->add_separator();
|
||||||
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/toggle_scripts_panel", TTR("Toggle Scripts Panel"), KEY_MASK_CMD | KEY_BACKSLASH), TOGGLE_SCRIPTS_PANEL);
|
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/toggle_scripts_panel", TTR("Toggle Scripts Panel"), KEY_MASK_CMD | KEY_BACKSLASH), TOGGLE_SCRIPTS_PANEL);
|
||||||
file_menu->get_popup()->connect("id_pressed", this, "_menu_option");
|
file_menu->get_popup()->connect("id_pressed", this, "_menu_option");
|
||||||
|
|
||||||
|
@ -131,6 +131,7 @@ class ScriptEditor : public PanelContainer {
|
|||||||
FILE_RELOAD_THEME,
|
FILE_RELOAD_THEME,
|
||||||
FILE_SAVE_THEME,
|
FILE_SAVE_THEME,
|
||||||
FILE_SAVE_THEME_AS,
|
FILE_SAVE_THEME_AS,
|
||||||
|
FILE_RUN,
|
||||||
FILE_CLOSE,
|
FILE_CLOSE,
|
||||||
CLOSE_DOCS,
|
CLOSE_DOCS,
|
||||||
CLOSE_ALL,
|
CLOSE_ALL,
|
||||||
|
@ -365,7 +365,7 @@ struct GDCompletionIdentifier {
|
|||||||
Variant value; //im case there is a value, also return it
|
Variant value; //im case there is a value, also return it
|
||||||
};
|
};
|
||||||
|
|
||||||
static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant) {
|
static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant, bool p_allow_gdnative_class = false) {
|
||||||
|
|
||||||
GDCompletionIdentifier t;
|
GDCompletionIdentifier t;
|
||||||
t.type = p_variant.get_type();
|
t.type = p_variant.get_type();
|
||||||
@ -373,14 +373,14 @@ static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant) {
|
|||||||
if (p_variant.get_type() == Variant::OBJECT) {
|
if (p_variant.get_type() == Variant::OBJECT) {
|
||||||
Object *obj = p_variant;
|
Object *obj = p_variant;
|
||||||
if (obj) {
|
if (obj) {
|
||||||
/*
|
|
||||||
if (Object::cast_to<GDNativeClass>(obj)) {
|
if (p_allow_gdnative_class && Object::cast_to<GDNativeClass>(obj)) {
|
||||||
t.obj_type=Object::cast_to<GDNativeClass>(obj)->get_name();
|
t.obj_type = Object::cast_to<GDNativeClass>(obj)->get_name();
|
||||||
t.value=Variant();
|
t.value = Variant();
|
||||||
} else {
|
} else {
|
||||||
*/
|
|
||||||
t.obj_type = obj->get_class();
|
t.obj_type = obj->get_class();
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
@ -513,9 +513,9 @@ static GDCompletionIdentifier _get_native_class(GDCompletionContext &context) {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type);
|
static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type, bool p_for_indexing);
|
||||||
|
|
||||||
static bool _guess_expression_type(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, GDCompletionIdentifier &r_type) {
|
static bool _guess_expression_type(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, GDCompletionIdentifier &r_type, bool p_for_indexing = false) {
|
||||||
|
|
||||||
if (p_node->type == GDParser::Node::TYPE_CONSTANT) {
|
if (p_node->type == GDParser::Node::TYPE_CONSTANT) {
|
||||||
|
|
||||||
@ -566,7 +566,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
|
|||||||
return true;
|
return true;
|
||||||
} else if (p_node->type == GDParser::Node::TYPE_IDENTIFIER) {
|
} else if (p_node->type == GDParser::Node::TYPE_IDENTIFIER) {
|
||||||
|
|
||||||
return _guess_identifier_type(context, p_line - 1, static_cast<const GDParser::IdentifierNode *>(p_node)->name, r_type);
|
return _guess_identifier_type(context, p_line - 1, static_cast<const GDParser::IdentifierNode *>(p_node)->name, r_type, p_for_indexing);
|
||||||
} else if (p_node->type == GDParser::Node::TYPE_SELF) {
|
} else if (p_node->type == GDParser::Node::TYPE_SELF) {
|
||||||
//eeh...
|
//eeh...
|
||||||
|
|
||||||
@ -812,23 +812,38 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
|
|||||||
|
|
||||||
if (p1.value.get_type() == Variant::OBJECT) {
|
if (p1.value.get_type() == Variant::OBJECT) {
|
||||||
//??
|
//??
|
||||||
|
|
||||||
if (p1.obj_type != StringName() && p2.type == Variant::STRING) {
|
if (p1.obj_type != StringName() && p2.type == Variant::STRING) {
|
||||||
|
|
||||||
|
StringName base_type = p1.obj_type;
|
||||||
|
|
||||||
|
if (p1.obj_type == "GDNativeClass") {
|
||||||
|
//native enum
|
||||||
|
Ref<GDNativeClass> gdn = p1.value;
|
||||||
|
if (gdn.is_valid()) {
|
||||||
|
|
||||||
|
base_type = gdn->get_name();
|
||||||
|
}
|
||||||
|
}
|
||||||
StringName index = p2.value;
|
StringName index = p2.value;
|
||||||
bool valid;
|
bool valid;
|
||||||
Variant::Type t = ClassDB::get_property_type(p1.obj_type, index, &valid);
|
Variant::Type t = ClassDB::get_property_type(base_type, index, &valid);
|
||||||
if (t != Variant::NIL && valid) {
|
if (t != Variant::NIL && valid) {
|
||||||
r_type.type = t;
|
r_type.type = t;
|
||||||
if (t == Variant::INT) {
|
if (t == Variant::INT || t == Variant::OBJECT) {
|
||||||
//check for enum!
|
//check for enum!
|
||||||
#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
|
#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
|
||||||
|
|
||||||
StringName getter = ClassDB::get_property_getter(p1.obj_type, index);
|
StringName getter = ClassDB::get_property_getter(base_type, index);
|
||||||
if (getter != StringName()) {
|
if (getter != StringName()) {
|
||||||
MethodBind *mb = ClassDB::get_method(p1.obj_type, getter);
|
MethodBind *mb = ClassDB::get_method(base_type, getter);
|
||||||
if (mb) {
|
if (mb) {
|
||||||
PropertyInfo rt = mb->get_return_info();
|
PropertyInfo rt = mb->get_return_info();
|
||||||
if (rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
|
if (rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM && t == Variant::INT) {
|
||||||
r_type.enumeration = rt.class_name;
|
r_type.enumeration = rt.class_name;
|
||||||
|
} else if (t == Variant::OBJECT) {
|
||||||
|
|
||||||
|
r_type.obj_type = rt.class_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1056,7 +1071,7 @@ static bool _guess_identifier_from_assignment_in_function(GDCompletionContext &c
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type) {
|
static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type, bool p_for_indexing) {
|
||||||
|
|
||||||
//go to block first
|
//go to block first
|
||||||
|
|
||||||
@ -1210,7 +1225,7 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con
|
|||||||
for (Map<StringName, int>::Element *E = GDScriptLanguage::get_singleton()->get_global_map().front(); E; E = E->next()) {
|
for (Map<StringName, int>::Element *E = GDScriptLanguage::get_singleton()->get_global_map().front(); E; E = E->next()) {
|
||||||
if (E->key() == p_identifier) {
|
if (E->key() == p_identifier) {
|
||||||
|
|
||||||
r_type = _get_type_from_variant(GDScriptLanguage::get_singleton()->get_global_array()[E->get()]);
|
r_type = _get_type_from_variant(GDScriptLanguage::get_singleton()->get_global_array()[E->get()], !p_for_indexing);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2082,7 +2097,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
GDCompletionIdentifier t;
|
GDCompletionIdentifier t;
|
||||||
if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t)) {
|
if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t, true)) {
|
||||||
|
|
||||||
if (t.type == Variant::OBJECT && t.obj_type == "GDNativeClass") {
|
if (t.type == Variant::OBJECT && t.obj_type == "GDNativeClass") {
|
||||||
//native enum
|
//native enum
|
||||||
|
Loading…
Reference in New Issue
Block a user