summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/input_map.cpp6
-rw-r--r--core/input_map.h2
-rw-r--r--core/register_core_types.cpp2
-rw-r--r--core/variant.h1
-rw-r--r--core/variant_op.cpp54
-rw-r--r--doc/base/classes.xml2
-rw-r--r--main/input_default.cpp14
-rw-r--r--modules/gdscript/gd_parser.cpp7
-rw-r--r--modules/gdscript/gd_parser.h1
-rw-r--r--modules/visual_script/visual_script_nodes.cpp7
-rw-r--r--platform/android/export/export.cpp38
-rw-r--r--scene/gui/range.cpp17
-rw-r--r--tools/editor/editor_run_native.cpp23
-rw-r--r--tools/editor/editor_settings.cpp1
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.cpp23
-rw-r--r--tools/editor/scene_tree_dock.cpp73
-rw-r--r--tools/editor/scene_tree_dock.h5
-rw-r--r--tools/editor/script_create_dialog.cpp124
-rw-r--r--tools/editor/script_create_dialog.h4
19 files changed, 243 insertions, 161 deletions
diff --git a/core/input_map.cpp b/core/input_map.cpp
index 09cb7ce426..ad1403a64b 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -106,7 +106,7 @@ List<StringName> InputMap::get_actions() const {
return actions;
}
-List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const InputEvent& p_event) const {
+List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const InputEvent& p_event, bool p_mod_ignore=false) const {
for (List<InputEvent>::Element *E=p_list.front();E;E=E->next()) {
@@ -122,7 +122,7 @@ List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const
case InputEvent::KEY: {
- same=(e.key.scancode==p_event.key.scancode && e.key.mod == p_event.key.mod);
+ same=(e.key.scancode==p_event.key.scancode && (p_mod_ignore || e.key.mod == p_event.key.mod));
} break;
case InputEvent::JOYSTICK_BUTTON: {
@@ -229,7 +229,7 @@ bool InputMap::event_is_action(const InputEvent& p_event, const StringName& p_ac
return p_event.action.action==E->get().id;
}
- return _find_event(E->get().inputs,p_event)!=NULL;
+ return _find_event(E->get().inputs,p_event,!p_event.is_pressed())!=NULL;
}
const Map<StringName, InputMap::Action>& InputMap::get_action_map() const {
diff --git a/core/input_map.h b/core/input_map.h
index 21c479588d..a974f6f103 100644
--- a/core/input_map.h
+++ b/core/input_map.h
@@ -46,7 +46,7 @@ private:
mutable Map<StringName, Action> input_map;
mutable Map<int,StringName> input_id_map;
- List<InputEvent>::Element *_find_event(List<InputEvent> &p_list,const InputEvent& p_event) const;
+ List<InputEvent>::Element *_find_event(List<InputEvent> &p_list,const InputEvent& p_event, bool p_mod_ignore) const;
Array _get_action_list(const StringName& p_action);
Array _get_actions();
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 4c9d121781..3d15eb44aa 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -34,6 +34,7 @@
#include "os/main_loop.h"
#include "io/packet_peer.h"
#include "math/a_star.h"
+#include "math/triangle_mesh.h"
#include "globals.h"
#include "object_type_db.h"
#include "geometry.h"
@@ -134,6 +135,7 @@ void register_core_types() {
ObjectTypeDB::register_type<PHashTranslation>();
ObjectTypeDB::register_type<UndoRedo>();
ObjectTypeDB::register_type<HTTPClient>();
+ ObjectTypeDB::register_type<TriangleMesh>();
ObjectTypeDB::register_virtual_type<ResourceInteractiveLoader>();
diff --git a/core/variant.h b/core/variant.h
index 90be593bd9..ccb8c5e3df 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -336,6 +336,7 @@ public:
OP_MULTIPLY,
OP_DIVIDE,
OP_NEGATE,
+ OP_POSITIVE,
OP_MODULE,
OP_STRING_CONCAT,
//bitwise
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index fd64b58bd5..73ed85db12 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -97,6 +97,12 @@ case m_name: {\
_RETURN( -p_a._data.m_type);\
};
+#define DEFAULT_OP_NUM_POS(m_name,m_type)\
+case m_name: {\
+\
+ _RETURN( p_a._data.m_type);\
+};
+
#define DEFAULT_OP_NUM_VEC(m_op,m_name,m_type)\
case m_name: {\
switch(p_b.type) {\
@@ -136,6 +142,10 @@ case m_name: {\
_RETURN( -*reinterpret_cast<const m_type*>(p_a._data._mem));\
}
+#define DEFAULT_OP_LOCALMEM_POS(m_name,m_type)\
+case m_name: {\
+ _RETURN( *reinterpret_cast<const m_type*>(p_a._data._mem));\
+}
#define DEFAULT_OP_LOCALMEM_NUM(m_op,m_name,m_type)\
case m_name: {switch(p_b.type) {\
@@ -740,6 +750,48 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
}
} break;
+ case OP_POSITIVE: {
+ // Simple case when user defines variable as +value.
+ switch(p_a.type) {
+
+ DEFAULT_OP_FAIL(NIL);
+ DEFAULT_OP_FAIL(STRING);
+ DEFAULT_OP_FAIL(RECT2);
+ DEFAULT_OP_FAIL(MATRIX32);
+ DEFAULT_OP_FAIL(_AABB);
+ DEFAULT_OP_FAIL(MATRIX3);
+ DEFAULT_OP_FAIL(TRANSFORM);
+ DEFAULT_OP_NUM_POS(BOOL,_bool);
+ DEFAULT_OP_NUM_POS(INT,_int);
+ DEFAULT_OP_NUM_POS(REAL,_real);
+ DEFAULT_OP_LOCALMEM_POS(VECTOR3,Vector3);
+ DEFAULT_OP_LOCALMEM_POS(PLANE,Plane);
+ DEFAULT_OP_LOCALMEM_POS(QUAT,Quat);
+ DEFAULT_OP_LOCALMEM_POS(VECTOR2,Vector2);
+
+ DEFAULT_OP_FAIL(COLOR);
+ DEFAULT_OP_FAIL(IMAGE);
+ DEFAULT_OP_FAIL(NODE_PATH);
+ DEFAULT_OP_FAIL(_RID);
+ DEFAULT_OP_FAIL(OBJECT);
+ DEFAULT_OP_FAIL(INPUT_EVENT);
+ DEFAULT_OP_FAIL(DICTIONARY);
+ DEFAULT_OP_FAIL(ARRAY);
+ DEFAULT_OP_FAIL(RAW_ARRAY);
+ DEFAULT_OP_FAIL(INT_ARRAY);
+ DEFAULT_OP_FAIL(REAL_ARRAY);
+ DEFAULT_OP_FAIL(STRING_ARRAY);
+ DEFAULT_OP_FAIL(VECTOR2_ARRAY);
+ DEFAULT_OP_FAIL(VECTOR3_ARRAY);
+ DEFAULT_OP_FAIL(COLOR_ARRAY);
+ case VARIANT_MAX: {
+ r_valid=false;
+ return;
+
+ } break;
+
+ }
+ } break;
case OP_NEGATE: {
switch(p_a.type) {
@@ -778,9 +830,7 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
return;
} break;
-
}
-
} break;
case OP_MODULE: {
if (p_a.type==INT && p_b.type==INT) {
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index f1155be854..246f8cdac6 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -18023,7 +18023,7 @@
<argument index="1" name="action" type="String">
</argument>
<description>
- Return whether the given event is part of an existing action.
+ Return whether the given event is part of an existing action. This method ignores keyboard modifiers if the given [InputEvent] is not pressed (for proper release detection). See [method action_has_event] if you don't want this behavior.
</description>
</method>
<method name="get_action_from_id" qualifiers="const">
diff --git a/main/input_default.cpp b/main/input_default.cpp
index 0995f7132d..f4590fd070 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -377,13 +377,13 @@ void InputDefault::parse_input_event(const InputEvent& p_event) {
if (InputMap::get_singleton()->event_is_action(p_event,E->key())) {
- Action action;
- action.fixed_frame=OS::get_singleton()->get_fixed_frames();
- action.idle_frame=OS::get_singleton()->get_idle_frames();
- action.pressed=p_event.is_pressed();
-
- action_state[E->key()]=action;
-
+ if(is_action_pressed(E->key()) != p_event.is_pressed()) {
+ Action action;
+ action.fixed_frame=OS::get_singleton()->get_fixed_frames();
+ action.idle_frame=OS::get_singleton()->get_idle_frames();
+ action.pressed=p_event.is_pressed();
+ action_state[E->key()]=action;
+ }
}
}
}
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 131b9a0853..1f2b7291e5 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -540,14 +540,15 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
expr = id;
}
- } else if (/*tokenizer->get_token()==GDTokenizer::TK_OP_ADD ||*/ tokenizer->get_token()==GDTokenizer::TK_OP_SUB || tokenizer->get_token()==GDTokenizer::TK_OP_NOT || tokenizer->get_token()==GDTokenizer::TK_OP_BIT_INVERT) {
+ } else if (tokenizer->get_token()==GDTokenizer::TK_OP_ADD || tokenizer->get_token()==GDTokenizer::TK_OP_SUB || tokenizer->get_token()==GDTokenizer::TK_OP_NOT || tokenizer->get_token()==GDTokenizer::TK_OP_BIT_INVERT) {
- //single prefix operators like !expr -expr ++expr --expr
+ //single prefix operators like !expr +expr -expr ++expr --expr
alloc_node<OperatorNode>();
Expression e;
e.is_op=true;
switch(tokenizer->get_token()) {
+ case GDTokenizer::TK_OP_ADD: e.op=OperatorNode::OP_POS; break;
case GDTokenizer::TK_OP_SUB: e.op=OperatorNode::OP_NEG; break;
case GDTokenizer::TK_OP_NOT: e.op=OperatorNode::OP_NOT; break;
case GDTokenizer::TK_OP_BIT_INVERT: e.op=OperatorNode::OP_BIT_INVERT;; break;
@@ -995,6 +996,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
case OperatorNode::OP_BIT_INVERT: priority=0; unary=true; break;
case OperatorNode::OP_NEG: priority=1; unary=true; break;
+ case OperatorNode::OP_POS: priority=1; unary=true; break;
case OperatorNode::OP_MUL: priority=2; break;
case OperatorNode::OP_DIV: priority=2; break;
@@ -1512,6 +1514,7 @@ GDParser::Node* GDParser::_reduce_expression(Node *p_node,bool p_to_const) {
//unary operators
case OperatorNode::OP_NEG: { _REDUCE_UNARY(Variant::OP_NEGATE); } break;
+ case OperatorNode::OP_POS: { _REDUCE_UNARY(Variant::OP_POSITIVE); } break;
case OperatorNode::OP_NOT: { _REDUCE_UNARY(Variant::OP_NOT); } break;
case OperatorNode::OP_BIT_INVERT: { _REDUCE_UNARY(Variant::OP_BIT_NEGATE); } break;
//binary operators (in precedence order)
diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gd_parser.h
index 75653e0916..000fb70295 100644
--- a/modules/gdscript/gd_parser.h
+++ b/modules/gdscript/gd_parser.h
@@ -209,6 +209,7 @@ public:
OP_INDEX_NAMED,
//unary operators
OP_NEG,
+ OP_POS,
OP_NOT,
OP_BIT_INVERT,
OP_PREINC,
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 7ada292b13..8ffbcc6e62 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -334,7 +334,7 @@ bool VisualScriptOperator::has_input_sequence_port() const{
int VisualScriptOperator::get_input_value_port_count() const{
- return (op==Variant::OP_BIT_NEGATE || op==Variant::OP_NOT || op==Variant::OP_NEGATE) ? 1 : 2;
+ return (op==Variant::OP_BIT_NEGATE || op==Variant::OP_NOT || op==Variant::OP_NEGATE || op==Variant::OP_POSITIVE) ? 1 : 2;
}
int VisualScriptOperator::get_output_value_port_count() const{
@@ -361,6 +361,7 @@ PropertyInfo VisualScriptOperator::get_input_value_port_info(int p_idx) const{
{Variant::NIL,Variant::NIL}, //OP_MULTIPLY,
{Variant::NIL,Variant::NIL}, //OP_DIVIDE,
{Variant::NIL,Variant::NIL}, //OP_NEGATE,
+ {Variant::NIL,Variant::NIL}, //OP_POSITIVE,
{Variant::INT,Variant::INT}, //OP_MODULE,
{Variant::STRING,Variant::STRING}, //OP_STRING_CONCAT,
//bitwise
@@ -403,6 +404,7 @@ PropertyInfo VisualScriptOperator::get_output_value_port_info(int p_idx) const{
Variant::NIL, //OP_MULTIPLY,
Variant::NIL, //OP_DIVIDE,
Variant::NIL, //OP_NEGATE,
+ Variant::NIL, //OP_POSITIVE,
Variant::INT, //OP_MODULE,
Variant::STRING, //OP_STRING_CONCAT,
//bitwise
@@ -444,6 +446,7 @@ static const char* op_names[]={
"Multiply", //OP_MULTIPLY,
"Divide", //OP_DIVIDE,
"Negate", //OP_NEGATE,
+ "Positive", //OP_POSITIVE,
"Remainder", //OP_MODULE,
"Concat", //OP_STRING_CONCAT,
//bitwise
@@ -485,6 +488,7 @@ String VisualScriptOperator::get_text() const {
L"A x B", //OP_MULTIPLY,
L"A \u00F7 B", //OP_DIVIDE,
L"\u00AC A", //OP_NEGATE,
+ L"+ A", //OP_POSITIVE,
L"A mod B", //OP_MODULE,
L"A .. B", //OP_STRING_CONCAT,
//bitwise
@@ -3900,6 +3904,7 @@ void register_visual_script_nodes() {
VisualScriptLanguage::singleton->add_register_func("operators/math/multiply",create_op_node<Variant::OP_MULTIPLY>);
VisualScriptLanguage::singleton->add_register_func("operators/math/divide",create_op_node<Variant::OP_DIVIDE>);
VisualScriptLanguage::singleton->add_register_func("operators/math/negate",create_op_node<Variant::OP_NEGATE>);
+ VisualScriptLanguage::singleton->add_register_func("operators/math/positive",create_op_node<Variant::OP_POSITIVE>);
VisualScriptLanguage::singleton->add_register_func("operators/math/remainder",create_op_node<Variant::OP_MODULE>);
VisualScriptLanguage::singleton->add_register_func("operators/math/string_concat",create_op_node<Variant::OP_STRING_CONCAT>);
//bitwise
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 4735a91f43..88a5554eef 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -531,9 +531,9 @@ void EditorExportPlatformAndroid::_fix_resources(Vector<uint8_t>& p_manifest) {
Vector<String> string_table;
- printf("stirng block len: %i\n",string_block_len);
- printf("stirng count: %i\n",string_count);
- printf("flags: %x\n",string_flags);
+ //printf("stirng block len: %i\n",string_block_len);
+ //printf("stirng count: %i\n",string_count);
+ //printf("flags: %x\n",string_flags);
for(uint32_t i=0;i<string_count;i++) {
@@ -617,7 +617,7 @@ void EditorExportPlatformAndroid::_fix_resources(Vector<uint8_t>& p_manifest) {
p_manifest=ret;
- printf("end\n");
+ //printf("end\n");
}
String EditorExportPlatformAndroid::get_project_name() const {
@@ -778,16 +778,16 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool
else
nspace="";
- printf("ATTR %i NSPACE: %i\n",i,attr_nspace);
- printf("ATTR %i NAME: %i (%s)\n",i,attr_name,attrname.utf8().get_data());
- printf("ATTR %i VALUE: %i (%s)\n",i,attr_value,value.utf8().get_data());
- printf("ATTR %i FLAGS: %x\n",i,attr_flags);
- printf("ATTR %i RESID: %x\n",i,attr_resid);
+ //printf("ATTR %i NSPACE: %i\n",i,attr_nspace);
+ //printf("ATTR %i NAME: %i (%s)\n",i,attr_name,attrname.utf8().get_data());
+ //printf("ATTR %i VALUE: %i (%s)\n",i,attr_value,value.utf8().get_data());
+ //printf("ATTR %i FLAGS: %x\n",i,attr_flags);
+ //printf("ATTR %i RESID: %x\n",i,attr_resid);
//replace project information
if (tname=="manifest" && attrname=="package") {
- print_line("FOUND PACKAGE");
+ print_line("FOUND package");
string_table[attr_value]=get_package_name();
}
@@ -796,14 +796,14 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool
//print_line("attrname: "+attrname);
if (tname=="manifest" && /*nspace=="android" &&*/ attrname=="versionCode") {
- print_line("FOUND versioncode");
+ print_line("FOUND versionCode");
encode_uint32(version_code,&p_manifest[iofs+16]);
}
if (tname=="manifest" && /*nspace=="android" &&*/ attrname=="versionName") {
- print_line("FOUND versionname");
+ print_line("FOUND versionName");
if (attr_value==0xFFFFFFFF) {
WARN_PRINT("Version name in a resource, should be plaintext")
} else
@@ -834,10 +834,10 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool
} else if (value.begins_with("godot.")) {
String perm = value.get_slice(".",1);
- print_line("PERM: "+perm+" HAS: "+itos(perms.has(perm)));
if (perms.has(perm) || (p_give_internet && perm=="INTERNET")) {
+ print_line("PERM: "+perm);
string_table[attr_value]="android.permission."+perm;
}
@@ -871,12 +871,12 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool
} break;
}
- printf("chunk %x: size: %d\n",chunk,size);
+ //printf("chunk %x: size: %d\n",chunk,size);
ofs+=size;
}
- printf("end\n");
+ //printf("end\n");
//create new andriodmanifest binary
@@ -893,14 +893,14 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool
encode_uint32(ofs,&ret[string_table_begins+i*4]);
ofs+=string_table[i].length()*2+2+2;
- print_line("ofs: "+itos(i)+": "+itos(ofs));
+ //print_line("ofs: "+itos(i)+": "+itos(ofs));
}
ret.resize(ret.size()+ofs);
uint8_t *chars=&ret[ret.size()-ofs];
for(int i=0;i<string_table.size();i++) {
String s = string_table[i];
- print_line("savint string :"+s);
+ //print_line("savint string :"+s);
encode_uint16(s.length(),chars);
chars+=2;
for(int j=0;j<s.length();j++) { //include zero?
@@ -934,7 +934,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool
encode_uint32(new_stable_end-8,&ret[12]); //update new string table size
- print_line("file size: "+itos(ret.size()));
+ //print_line("file size: "+itos(ret.size()));
p_manifest=ret;
@@ -949,7 +949,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool
header[i]=decode_uint32(&p_manifest[i*4]);
}
- print_line("STO: "+itos(header[3]));
+ //print_line("STO: "+itos(header[3]));
uint32_t st_offset=9*4;
//ERR_FAIL_COND(header[3]!=0x24)
uint32_t string_count=header[4];
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index e056c55f71..ed58c4eb49 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -136,16 +136,25 @@ double Range::get_page() const {
}
void Range::set_unit_value(double p_value) {
+
+ double v;
+
if (shared->exp_unit_value && get_min()>0) {
double exp_min = Math::log(get_min())/Math::log(2);
double exp_max = Math::log(get_max())/Math::log(2);
- double v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value);
-
- set_val( v );
+ v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value);
} else {
- set_val( (get_max() - get_min()) * p_value + get_min() );
+
+ double percent = (get_max() - get_min()) * p_value;
+ if (get_step() > 0) {
+ double steps = round(percent / get_step());
+ v = steps * get_step() + get_min();
+ } else {
+ v = percent + get_min();
+ }
}
+ set_val( v );
}
double Range::get_unit_value() const {
diff --git a/tools/editor/editor_run_native.cpp b/tools/editor/editor_run_native.cpp
index edbcc71284..330103923d 100644
--- a/tools/editor/editor_run_native.cpp
+++ b/tools/editor/editor_run_native.cpp
@@ -55,6 +55,7 @@ void EditorRunNative::_notification(int p_what) {
small_icon->create_from_image(im);
MenuButton *mb = memnew( MenuButton );
mb->get_popup()->connect("item_pressed",this,"_run_native",varray(E->get()));
+ mb->connect("pressed",this,"_run_native",varray(-1, E->get()));
mb->set_icon(small_icon);
add_child(mb);
menus[E->get()]=mb;
@@ -79,13 +80,16 @@ void EditorRunNative::_notification(int p_what) {
if (dc==0) {
mb->hide();
} else {
-
mb->get_popup()->clear();
mb->show();
- for(int i=0;i<dc;i++) {
-
- mb->get_popup()->add_icon_item(get_icon("Play","EditorIcons"),eep->get_device_name(i));
- mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() -1,eep->get_device_info(i));
+ if (dc == 1) {
+ mb->set_tooltip(eep->get_device_name(0) + "\n\n" + eep->get_device_info(0).strip_edges());
+ } else {
+ mb->set_tooltip("Select device from the list");
+ for(int i=0;i<dc;i++) {
+ mb->get_popup()->add_icon_item(get_icon("Play","EditorIcons"),eep->get_device_name(i));
+ mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() -1,eep->get_device_info(i).strip_edges());
+ }
}
}
}
@@ -96,11 +100,18 @@ void EditorRunNative::_notification(int p_what) {
}
-
void EditorRunNative::_run_native(int p_idx,const String& p_platform) {
Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(p_platform);
ERR_FAIL_COND(eep.is_null());
+ if (p_idx == -1) {
+ if (eep->get_device_count() == 1) {
+ menus[p_platform]->get_popup()->hide();
+ p_idx = 0;
+ } else {
+ return;
+ }
+ }
emit_signal("native_run");
int flags=0;
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index 78bfd7cf25..2a355d95f3 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -1098,7 +1098,6 @@ EditorSettings::EditorSettings() {
}
_load_defaults();
- save_changed_setting=false;
}
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp
index af9fd69ae7..709091cf4c 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp
@@ -529,17 +529,24 @@ void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2& p_rect,Node* p_no
CanvasItem *c=p_node->cast_to<CanvasItem>();
- for (int i=p_node->get_child_count()-1;i>=0;i--) {
-
- if (c && !c->is_set_as_toplevel())
- _find_canvas_items_at_rect(p_rect,p_node->get_child(i),p_parent_xform * c->get_transform(),p_canvas_xform,r_items);
- else {
- CanvasLayer *cl = p_node->cast_to<CanvasLayer>();
- _find_canvas_items_at_rect(p_rect,p_node->get_child(i),transform,cl?cl->get_transform():p_canvas_xform,r_items);
+ bool inherited=p_node!=get_tree()->get_edited_scene_root() && p_node->get_filename()!="";
+ bool editable=false;
+ if (inherited){
+ editable=EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(p_node);
+ }
+ bool lock_children=p_node->has_meta("_edit_group_") && p_node->get_meta("_edit_group_");
+ if (!lock_children && (!inherited || editable)) {
+ for (int i=p_node->get_child_count()-1;i>=0;i--) {
+
+ if (c && !c->is_set_as_toplevel())
+ _find_canvas_items_at_rect(p_rect,p_node->get_child(i),p_parent_xform * c->get_transform(),p_canvas_xform,r_items);
+ else {
+ CanvasLayer *cl = p_node->cast_to<CanvasLayer>();
+ _find_canvas_items_at_rect(p_rect,p_node->get_child(i),transform,cl?cl->get_transform():p_canvas_xform,r_items);
+ }
}
}
-
if (c && c->is_visible() && !c->has_meta("_edit_lock_") && !c->cast_to<CanvasLayer>()) {
Rect2 rect = c->get_item_rect();
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp
index b9cce34454..990d14196e 100644
--- a/tools/editor/scene_tree_dock.cpp
+++ b/tools/editor/scene_tree_dock.cpp
@@ -80,11 +80,8 @@ void SceneTreeDock::_unhandled_key_input(InputEvent p_event) {
else if (ED_IS_SHORTCUT("scene_tree/duplicate", p_event)) {
_tool_selected(TOOL_DUPLICATE);
}
- else if (ED_IS_SHORTCUT("scene_tree/add_script", p_event)) {
- _tool_selected(TOOL_CREATE_SCRIPT);
- }
- else if (ED_IS_SHORTCUT("scene_tree/load_script", p_event)) {
- _tool_selected(TOOL_LOAD_SCRIPT);
+ else if (ED_IS_SHORTCUT("scene_tree/attach_script", p_event)) {
+ _tool_selected(TOOL_ATTACH_SCRIPT);
}
else if(ED_IS_SHORTCUT("scene_tree/clear_script", p_event)) {
_tool_selected(TOOL_CLEAR_SCRIPT);
@@ -272,24 +269,6 @@ void SceneTreeDock::_replace_with_branch_scene(const String& p_file,Node* base)
scene_tree->set_selected(instanced_scene);
}
-
-void SceneTreeDock::_file_selected(String p_file) {
- RES p_script = ResourceLoader::load(p_file, "Script");
- if (p_script.is_null()) {
- accept->get_ok()->set_text(TTR("Ugh"));
- accept->set_text(vformat(TTR("Error loading script from %s"), p_file));
- accept->popup_centered_minsize();
- return;
- }
-
- Node *selected = scene_tree->get_selected();
- if (!selected)
- return;
- selected->set_script(p_script.get_ref_ptr());
- editor->push_item(p_script.operator->());
- file_dialog->hide();
-}
-
bool SceneTreeDock::_cyclical_dependency_exists(const String& p_target_scene_path, Node* p_desired_node) {
int childCount = p_desired_node->get_child_count();
@@ -382,22 +361,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
//groups_editor->set_current(current);
//groups_editor->popup_centered_ratio();
} break;
- case TOOL_LOAD_SCRIPT: {
- Node *selected = scene_tree->get_selected();
- if (!selected)
- break;
-
- file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
-
- List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
- file_dialog->clear_filters();
- for (List<String>::Element *E = extensions.front(); E; E = E->next())
- file_dialog->add_filter("*." + E->get() + " ; " + E->get().to_upper());
-
- file_dialog->popup_centered_ratio();
- } break;
- case TOOL_CREATE_SCRIPT: {
+ case TOOL_ATTACH_SCRIPT: {
Node *selected = scene_tree->get_selected();
if (!selected)
@@ -725,7 +689,6 @@ void SceneTreeDock::_notification(int p_what) {
button_add->set_icon(get_icon("Add","EditorIcons"));
button_instance->set_icon(get_icon("Instance","EditorIcons"));
button_create_script->set_icon(get_icon("ScriptCreate","EditorIcons"));
- button_load_script->set_icon(get_icon("Script", "EditorIcons"));
button_clear_script->set_icon(get_icon("Remove", "EditorIcons"));
@@ -1359,17 +1322,14 @@ void SceneTreeDock::_selection_changed() {
if (selection_size==1) {
if(EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) {
button_create_script->show();
- button_load_script->show();
button_clear_script->hide();
}
else {
button_create_script->hide();
- button_load_script->hide();
button_clear_script->show();
}
} else {
button_create_script->hide();
- button_load_script->hide();
button_clear_script->hide();
}
@@ -1823,8 +1783,7 @@ void SceneTreeDock::_tree_rmb(const Vector2& p_menu_pos) {
//menu->add_icon_item(get_icon("Groups","EditorIcons"),TTR("Edit Groups"),TOOL_GROUP);
//menu->add_icon_item(get_icon("Connect","EditorIcons"),TTR("Edit Connections"),TOOL_CONNECT);
menu->add_separator();
- menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_script"), TOOL_CREATE_SCRIPT);
- menu->add_icon_shortcut(get_icon("Script", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/load_script"), TOOL_LOAD_SCRIPT);
+ menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT);
menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
menu->add_separator();
}
@@ -1884,7 +1843,7 @@ void SceneTreeDock::_focus_node() {
void SceneTreeDock::open_script_dialog(Node* p_for_node) {
scene_tree->set_selected(p_for_node,false);
- _tool_selected(TOOL_CREATE_SCRIPT);
+ _tool_selected(TOOL_ATTACH_SCRIPT);
}
void SceneTreeDock::_bind_methods() {
@@ -1913,7 +1872,6 @@ void SceneTreeDock::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_tree_rmb"),&SceneTreeDock::_tree_rmb);
ObjectTypeDB::bind_method(_MD("_filter_changed"),&SceneTreeDock::_filter_changed);
ObjectTypeDB::bind_method(_MD("_focus_node"),&SceneTreeDock::_focus_node);
- ObjectTypeDB::bind_method(_MD("_file_selected"), &SceneTreeDock::_file_selected);
ObjectTypeDB::bind_method(_MD("instance"),&SceneTreeDock::instance);
@@ -1937,8 +1895,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
ED_SHORTCUT("scene_tree/add_child_node",TTR("Add Child Node"), KEY_MASK_CMD|KEY_A);
ED_SHORTCUT("scene_tree/instance_scene",TTR("Instance Child Scene"));
ED_SHORTCUT("scene_tree/change_node_type", TTR("Change Type"));
- ED_SHORTCUT("scene_tree/add_script", TTR("Add Script"));
- ED_SHORTCUT("scene_tree/load_script", TTR("Load Script"));
+ ED_SHORTCUT("scene_tree/attach_script", TTR("Attach Script"));
ED_SHORTCUT("scene_tree/clear_script", TTR("Clear Script"));
ED_SHORTCUT("scene_tree/move_up", TTR("Move Up"), KEY_MASK_CMD | KEY_UP);
ED_SHORTCUT("scene_tree/move_down", TTR("Move Down"), KEY_MASK_CMD | KEY_DOWN);
@@ -1976,20 +1933,13 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
tb = memnew( ToolButton );
- tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_CREATE_SCRIPT, false));
- tb->set_tooltip(TTR("Create a new script for the selected node."));
- tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/add_script"));
+ tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_ATTACH_SCRIPT, false));
+ tb->set_tooltip(TTR("Attach a new or existing script for the selected node."));
+ tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/attach_script"));
filter_hbc->add_child(tb);
button_create_script=tb;
tb = memnew(ToolButton);
- tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_LOAD_SCRIPT, false));
- tb->set_tooltip(TTR("Load a script for the selected node."));
- tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/load_script"));
- filter_hbc->add_child(tb);
- button_load_script = tb;
-
- tb = memnew(ToolButton);
tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_CLEAR_SCRIPT, false));
tb->set_tooltip(TTR("Clear a script for the selected node."));
tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/clear_script"));
@@ -2023,11 +1973,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
add_child(create_dialog);
create_dialog->connect("create",this,"_create");
- file_dialog = memnew(EditorFileDialog);
- add_child(file_dialog);
- file_dialog->hide();
- file_dialog->connect("file_selected", this, "_file_selected");
-
//groups_editor = memnew( GroupsEditor );
//add_child(groups_editor);
//groups_editor->set_undo_redo(&editor_data->get_undo_redo());
diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h
index 86fe3bb136..f1b366a4c5 100644
--- a/tools/editor/scene_tree_dock.h
+++ b/tools/editor/scene_tree_dock.h
@@ -58,8 +58,7 @@ class SceneTreeDock : public VBoxContainer {
TOOL_REPLACE,
TOOL_CONNECT,
TOOL_GROUP,
- TOOL_CREATE_SCRIPT,
- TOOL_LOAD_SCRIPT,
+ TOOL_ATTACH_SCRIPT,
TOOL_CLEAR_SCRIPT,
TOOL_MOVE_UP,
TOOL_MOVE_DOWN,
@@ -77,12 +76,10 @@ class SceneTreeDock : public VBoxContainer {
int current_option;
CreateDialog *create_dialog;
- EditorFileDialog *file_dialog;
ToolButton *button_add;
ToolButton *button_instance;
ToolButton *button_create_script;
- ToolButton *button_load_script;
ToolButton *button_clear_script;
SceneTreeEditor *scene_tree;
diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp
index 62d5c7cd84..d7fc87167b 100644
--- a/tools/editor/script_create_dialog.cpp
+++ b/tools/editor/script_create_dialog.cpp
@@ -96,8 +96,20 @@ void ScriptCreateDialog::_class_name_changed(const String& p_name) {
void ScriptCreateDialog::ok_pressed() {
- if (class_name->is_editable() && !_validate(class_name->get_text())) {
+ if (create_new){
+ _create_new();
+ } else {
+ _load_exist();
+ }
+
+ create_new=true;
+ _update_controls();
+
+}
+
+void ScriptCreateDialog::_create_new() {
+ if (class_name->is_editable() && !_validate(class_name->get_text())) {
alert->set_text(TTR("Class name is invalid!"));
alert->popup_centered_minsize();
return;
@@ -105,21 +117,14 @@ void ScriptCreateDialog::ok_pressed() {
if (!_validate(parent_name->get_text())) {
alert->set_text(TTR("Parent class name is invalid!"));
alert->popup_centered_minsize();
-
return;
-
}
-
String cname;
if (class_name->is_editable())
cname=class_name->get_text();
-
-
-
Ref<Script> scr = ScriptServer::get_language( language_menu->get_selected() )->get_template(cname,parent_name->get_text());
- //scr->set_source_code(text);
String selected_language = language_menu->get_item_text(language_menu->get_selected());
editor_settings->set_last_selected_language(selected_language);
@@ -127,34 +132,40 @@ void ScriptCreateDialog::ok_pressed() {
if (cname!="")
scr->set_name(cname);
-
if (!internal->is_pressed()) {
-
-
String lpath = Globals::get_singleton()->localize_path(file_path->get_text());
scr->set_path(lpath);
if (!path_valid) {
-
alert->set_text(TTR("Invalid path!"));
alert->popup_centered_minsize();
return;
-
}
Error err = ResourceSaver::save(lpath,scr,ResourceSaver::FLAG_CHANGE_PATH);
if (err!=OK) {
-
alert->set_text(TTR("Could not create script in filesystem."));
alert->popup_centered_minsize();
return;
}
- //scr->set_path(lpath);
- //EditorFileSystem::get_singleton()->update_file(lpath,scr->get_type());
+ }
+ hide();
+ emit_signal("script_created",scr);
+
+}
+void ScriptCreateDialog::_load_exist() {
+
+ String path=file_path->get_text();
+ RES p_script = ResourceLoader::load(path, "Script");
+ if (p_script.is_null()) {
+ alert->get_ok()->set_text(TTR("Ugh"));
+ alert->set_text(vformat(TTR("Error loading script from %s"), path));
+ alert->popup_centered_minsize();
+ return;
}
hide();
- emit_signal("script_created",scr);
+ emit_signal("script_created",p_script.get_ref_ptr());
}
@@ -166,10 +177,35 @@ void ScriptCreateDialog::_lang_changed(int l) {
} else {
class_name->set_editable(false);
}
- if (file_path->get_text().basename()==initial_bp) {
- file_path->set_text(initial_bp+"."+ScriptServer::get_language( l )->get_extension());
- _path_changed(file_path->get_text());
+
+ String selected_ext="."+ScriptServer::get_language( l )->get_extension();
+ String path=file_path->get_text();
+ String extension="";
+ if (path.find(".")>=0) {
+ extension=path.extension();
+ }
+
+ if (extension.length()==0) {
+ // add extension if none
+ path+=selected_ext;
+ _path_changed(path);
+ } else {
+ // change extension by selected language
+ List<String> extensions;
+ // get all possible extensions for script
+ for (int l=0;l<language_menu->get_item_count();l++) {
+ ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
+ }
+
+ for(List<String>::Element *E=extensions.front();E;E=E->next()) {
+ if (E->get().nocasecmp_to(extension)==0) {
+ path=path.basename()+selected_ext;
+ _path_changed(path);
+ break;
+ }
+ }
}
+ file_path->set_text(path);
_class_name_changed(class_name->get_text());
}
@@ -191,8 +227,10 @@ void ScriptCreateDialog::_browse_path() {
file_browse->clear_filters();
List<String> extensions;
- int l=language_menu->get_selected();
- ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
+ // get all possible extensions for script
+ for (int l=0;l<language_menu->get_item_count();l++) {
+ ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
+ }
for(List<String>::Element *E=extensions.front();E;E=E->next()) {
file_browse->add_filter("*."+E->get());
@@ -246,49 +284,57 @@ void ScriptCreateDialog::_path_changed(const String& p_path) {
memdelete(d);
}
-
-
FileAccess *f = FileAccess::create(FileAccess::ACCESS_RESOURCES);
-
- if (f->file_exists(p)) {
-
- path_error_label->set_text(TTR("File exists"));
- path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
- memdelete(f);
- return;
- }
-
+ create_new=!f->file_exists(p);
memdelete(f);
String extension=p.extension();
List<String> extensions;
- int l=language_menu->get_selected();
- ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
+ // get all possible extensions for script
+ for (int l=0;l<language_menu->get_item_count();l++) {
+ ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
+ }
bool found=false;
+ int index=0;
for(List<String>::Element *E=extensions.front();E;E=E->next()) {
if (E->get().nocasecmp_to(extension)==0) {
+ language_menu->select(index); // change Language option by extension
found=true;
break;
}
+ index++;
}
if (!found) {
-
path_error_label->set_text(TTR("Invalid extension"));
path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
return;
}
+ _update_controls();
- path_error_label->set_text(TTR("Valid path"));
path_error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8));
path_valid=true;
}
+void ScriptCreateDialog::_update_controls() {
+
+ if (create_new) {
+ path_error_label->set_text(TTR("Create new script"));
+ get_ok()->set_text(TTR("Create"));
+ } else {
+ path_error_label->set_text(TTR("Load existing script"));
+ get_ok()->set_text(TTR("Load"));
+ }
+ parent_name->set_editable(create_new);
+ internal->set_disabled(!create_new);
+
+}
+
void ScriptCreateDialog::_bind_methods() {
@@ -376,7 +422,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
set_size(Size2(200,150));
set_hide_on_ok(false);
- set_title(TTR("Create Node Script"));
+ set_title(TTR("Attach Node Script"));
file_browse = memnew( EditorFileDialog );
file_browse->connect("file_selected",this,"_file_selected");
@@ -385,4 +431,6 @@ ScriptCreateDialog::ScriptCreateDialog() {
alert = memnew( AcceptDialog );
add_child(alert);
_lang_changed(0);
+
+ create_new=true;
}
diff --git a/tools/editor/script_create_dialog.h b/tools/editor/script_create_dialog.h
index c71ea16d39..77e5a9fddd 100644
--- a/tools/editor/script_create_dialog.h
+++ b/tools/editor/script_create_dialog.h
@@ -50,6 +50,7 @@ class ScriptCreateDialog : public ConfirmationDialog {
VBoxContainer *path_vb;
AcceptDialog *alert;
bool path_valid;
+ bool create_new;
String initial_bp;
EditorSettings *editor_settings;
@@ -62,6 +63,9 @@ class ScriptCreateDialog : public ConfirmationDialog {
void _browse_path();
void _file_selected(const String& p_file);
virtual void ok_pressed();
+ void _create_new();
+ void _load_exist();
+ void _update_controls();
protected:
static void _bind_methods();