summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct3
-rw-r--r--bin/tests/test_math.cpp400
-rw-r--r--core/input_map.cpp58
-rw-r--r--core/input_map.h1
-rw-r--r--core/math/a_star.cpp412
-rw-r--r--core/math/a_star.h92
-rw-r--r--core/math/math_2d.cpp22
-rw-r--r--core/math/math_2d.h15
-rw-r--r--core/object_type_db.cpp174
-rw-r--r--core/object_type_db.h15
-rw-r--r--core/os/input.cpp6
-rw-r--r--core/os/input.h5
-rw-r--r--core/os/input_event.cpp2
-rw-r--r--core/register_core_types.cpp2
-rw-r--r--core/script_language.h20
-rw-r--r--core/ustring.cpp2
-rw-r--r--core/ustring.h2
-rw-r--r--core/variant_call.cpp2
-rw-r--r--doc/base/classes.xml377
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp12
-rw-r--r--drivers/gles2/shader_compiler_gles2.cpp1
-rw-r--r--drivers/gles2/shaders/canvas.glsl4
-rw-r--r--drivers/gles2/shaders/material.glsl4
-rw-r--r--drivers/vorbis/SCsub4
-rw-r--r--main/input_default.cpp65
-rw-r--r--main/input_default.h5
-rw-r--r--main/main.cpp5
-rwxr-xr-xmethods.py1
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp2
-rw-r--r--modules/gdscript/gd_compiler.cpp59
-rw-r--r--modules/gdscript/gd_editor.cpp441
-rw-r--r--modules/gdscript/gd_parser.cpp107
-rw-r--r--modules/gdscript/gd_parser.h6
-rw-r--r--modules/gdscript/gd_script.h17
-rw-r--r--platform/android/export/export.cpp10
-rw-r--r--platform/android/os_android.cpp13
-rw-r--r--platform/windows/os_windows.cpp7
-rw-r--r--platform/winrt/SCsub7
-rw-r--r--platform/winrt/detect.py8
-rw-r--r--platform/winrt/joystick_winrt.cpp3
-rw-r--r--platform/x11/detect.py2
-rw-r--r--platform/x11/os_x11.cpp13
-rw-r--r--scene/2d/area_2d.cpp4
-rw-r--r--scene/2d/camera_2d.cpp70
-rw-r--r--scene/2d/camera_2d.h5
-rw-r--r--scene/2d/node_2d.cpp2
-rw-r--r--scene/2d/node_2d.h4
-rw-r--r--scene/2d/polygon_2d.cpp4
-rw-r--r--scene/2d/polygon_2d.h6
-rw-r--r--scene/3d/area.cpp4
-rw-r--r--scene/3d/immediate_geometry.cpp1
-rw-r--r--scene/3d/visual_instance.cpp4
-rw-r--r--scene/gui/line_edit.cpp21
-rw-r--r--scene/gui/scroll_container.cpp4
-rw-r--r--scene/gui/text_edit.cpp169
-rw-r--r--scene/gui/text_edit.h8
-rw-r--r--scene/main/canvas_layer.cpp60
-rw-r--r--scene/main/canvas_layer.h14
-rw-r--r--scene/main/viewport.cpp54
-rw-r--r--scene/main/viewport.h2
-rw-r--r--scene/resources/default_theme/default_theme.cpp31
-rw-r--r--scene/resources/default_theme/default_theme.h2
-rw-r--r--scene/resources/shader_graph.cpp4
-rw-r--r--servers/physics_2d/shape_2d_sw.cpp14
-rw-r--r--servers/physics_2d/shape_2d_sw.h18
-rw-r--r--servers/visual/shader_language.cpp1
-rw-r--r--tools/editor/create_dialog.cpp324
-rw-r--r--tools/editor/create_dialog.h19
-rw-r--r--tools/editor/editor_fonts.cpp15
-rw-r--r--tools/editor/editor_node.cpp121
-rw-r--r--tools/editor/editor_node.h15
-rw-r--r--tools/editor/editor_plugin.cpp19
-rw-r--r--tools/editor/editor_plugin.h4
-rw-r--r--tools/editor/editor_scale.cpp11
-rw-r--r--tools/editor/editor_scale.h6
-rw-r--r--tools/editor/editor_settings.cpp2
-rw-r--r--tools/editor/editor_themes.cpp5
-rw-r--r--tools/editor/icons/2x/icon_distraction_free.pngbin0 -> 575 bytes
-rw-r--r--tools/editor/icons/2x/icon_remote_transform.pngbin1435 -> 1140 bytes
-rw-r--r--tools/editor/icons/SCsub6
-rw-r--r--tools/editor/icons/icon_distraction_free.pngbin0 -> 397 bytes
-rw-r--r--tools/editor/icons/icon_remote_transform.pngbin680 -> 530 bytes
-rw-r--r--tools/editor/icons/source/icon_distraction_free.svg104
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp79
-rw-r--r--tools/editor/plugins/script_editor_plugin.h4
-rw-r--r--tools/editor/plugins/script_text_editor.cpp77
-rw-r--r--tools/editor/plugins/script_text_editor.h1
-rw-r--r--tools/editor/plugins/shader_graph_editor_plugin.cpp2
-rw-r--r--tools/editor/project_manager.cpp12
-rw-r--r--tools/editor/property_editor.cpp16
-rw-r--r--tools/editor/property_editor.h1
-rw-r--r--tools/editor/scene_tree_dock.cpp6
-rw-r--r--tools/editor/scene_tree_dock.h1
-rw-r--r--tools/editor/scene_tree_editor.cpp2
94 files changed, 3406 insertions, 358 deletions
diff --git a/SConstruct b/SConstruct
index d168820f66..e08c46c51e 100644
--- a/SConstruct
+++ b/SConstruct
@@ -138,7 +138,8 @@ opts.Add('etc1','etc1 Texture compression support (yes/no)','yes')
opts.Add('builtin_zlib','Use built-in zlib (yes/no)','yes')
opts.Add('openssl','Use OpenSSL (yes/no/builtin)','no')
opts.Add('musepack','Musepack Audio (yes/no)','yes')
-opts.Add("CXX", "Compiler");
+opts.Add("CXX", "C++ Compiler")
+opts.Add("CC", "C Compiler")
opts.Add("CCFLAGS", "Custom flags for the C++ compiler");
opts.Add("CFLAGS", "Custom flags for the C compiler");
opts.Add("LINKFLAGS", "Custom flags for the linker");
diff --git a/bin/tests/test_math.cpp b/bin/tests/test_math.cpp
index 4b686e8af8..e5667bff64 100644
--- a/bin/tests/test_math.cpp
+++ b/bin/tests/test_math.cpp
@@ -40,12 +40,376 @@
#include "scene/resources/texture.h"
#include "vmap.h"
#include "os/os.h"
+#include "os/file_access.h"
#include "method_ptrcall.h"
namespace TestMath {
+class GetClassAndNamespace {
+
+ String code;
+ int idx;
+ int line;
+ String error_str;
+ bool error;
+ Variant value;
+
+ String class_name;
+
+ enum Token {
+ TK_BRACKET_OPEN,
+ TK_BRACKET_CLOSE,
+ TK_CURLY_BRACKET_OPEN,
+ TK_CURLY_BRACKET_CLOSE,
+ TK_PERIOD,
+ TK_COLON,
+ TK_COMMA,
+ TK_SYMBOL,
+ TK_IDENTIFIER,
+ TK_STRING,
+ TK_NUMBER,
+ TK_EOF,
+ TK_ERROR
+ };
+
+
+ Token get_token() {
+
+ while (true) {
+ switch(code[idx]) {
+
+ case '\n': {
+
+ line++;
+ idx++;
+ break;
+ };
+ case 0: {
+ return TK_EOF;
+
+ } break;
+ case '{': {
+
+ idx++;
+ return TK_CURLY_BRACKET_OPEN;
+ };
+ case '}': {
+
+ idx++;
+ return TK_CURLY_BRACKET_CLOSE;
+ };
+ case '[': {
+
+ idx++;
+ return TK_BRACKET_OPEN;
+ };
+ case ']': {
+
+ idx++;
+ return TK_BRACKET_CLOSE;
+ };
+ case ':': {
+
+ idx++;
+ return TK_COLON;
+ };
+ case ',': {
+
+ idx++;
+ return TK_COMMA;
+ };
+ case '.': {
+
+ idx++;
+ return TK_PERIOD;
+ };
+ case '#': {
+ //compiler directive
+ while(code[idx]!='\n' && code[idx]!=0) {
+ idx++;
+ }
+ continue;
+ } break;
+ case '/': {
+
+
+ switch(code[idx+1]) {
+ case '*': { // block comment
+
+ idx+=2;
+ while(true) {
+ if (code[idx]==0) {
+ error_str="Unterminated comment";
+ error=true;
+ return TK_ERROR;
+ } if (code[idx]=='*' &&code[idx+1]=='/') {
+
+ idx+=2;
+ break;
+ } if (code[idx]=='\n') {
+ line++;
+ }
+
+ idx++;
+ }
+
+ } break;
+ case '/': { // line comment skip
+
+ while(code[idx]!='\n' && code[idx]!=0) {
+ idx++;
+ }
+
+ } break;
+ default: {
+ value="/";
+ idx++;
+ return TK_SYMBOL;
+ }
+
+ }
+
+ continue; // a comment
+ } break;
+ case '\'':
+ case '"': {
+
+ CharType begin_str = code[idx];
+ idx++;
+ String tk_string=String();
+ while(true) {
+ if (code[idx]==0) {
+ error_str="Unterminated String";
+ error=true;
+ return TK_ERROR;
+ } else if (code[idx]==begin_str) {
+ idx++;
+ break;
+ } else if (code[idx]=='\\') {
+ //escaped characters...
+ idx++;
+ CharType next = code[idx];
+ if (next==0) {
+ error_str="Unterminated String";
+ error=true;
+ return TK_ERROR;
+ }
+ CharType res=0;
+
+ switch(next) {
+
+ case 'b': res=8; break;
+ case 't': res=9; break;
+ case 'n': res=10; break;
+ case 'f': res=12; break;
+ case 'r': res=13; break;
+ /* too much, not needed for now
+ case 'u': {
+ //hexnumbarh - oct is deprecated
+
+
+ for(int j=0;j<4;j++) {
+ CharType c = code[idx+j+1];
+ if (c==0) {
+ r_err_str="Unterminated String";
+ return ERR_PARSE_ERROR;
+ }
+ if (!((c>='0' && c<='9') || (c>='a' && c<='f') || (c>='A' && c<='F'))) {
+
+ r_err_str="Malformed hex constant in string";
+ return ERR_PARSE_ERROR;
+ }
+ CharType v;
+ if (c>='0' && c<='9') {
+ v=c-'0';
+ } else if (c>='a' && c<='f') {
+ v=c-'a';
+ v+=10;
+ } else if (c>='A' && c<='F') {
+ v=c-'A';
+ v+=10;
+ } else {
+ ERR_PRINT("BUG");
+ v=0;
+ }
+
+ res<<=4;
+ res|=v;
+
+
+ }
+ idx+=4; //will add at the end anyway
+
+
+ } break;*/
+ case '\"': res='\"'; break;
+ case '\\': res='\\'; break;
+ //case '/': res='/'; break;
+ default: {
+ res = next;
+ //r_err_str="Invalid escape sequence";
+ //return ERR_PARSE_ERROR;
+ } break;
+ }
+
+ tk_string+=res;
+
+ } else {
+ if (code[idx]=='\n')
+ line++;
+ tk_string+=code[idx];
+ }
+ idx++;
+ }
+
+ value=tk_string;
+
+ return TK_STRING;
+
+ } break;
+ default: {
+
+ if (code[idx]<=32) {
+ idx++;
+ break;
+ }
+
+ if ( (code[idx]>=33 && code[idx]<=47) || (code[idx]>=58 && code[idx]<=64) || (code[idx]>=91 && code[idx]<=96) || (code[idx]>=123 && code[idx]<=127)){
+ value=String::chr(code[idx]);
+ idx++;
+ return TK_SYMBOL;
+ }
+
+ if (code[idx]=='-' || (code[idx]>='0' && code[idx]<='9')) {
+ //a number
+ const CharType *rptr;
+ double number = String::to_double(&code[idx],&rptr);
+ idx+=(rptr - &code[idx]);
+ value=number;
+ return TK_NUMBER;
+
+ } else if ((code[idx]>='A' && code[idx]<='Z') || (code[idx]>='a' && code[idx]<='z') || code[idx]>127) {
+
+ String id;
+
+ while((code[idx]>='A' && code[idx]<='Z') || (code[idx]>='a' && code[idx]<='z') || code[idx]>127) {
+
+ id+=code[idx];
+ idx++;
+ }
+
+ value=id;
+ return TK_IDENTIFIER;
+ } else {
+ error_str="Unexpected character.";
+ error=true;
+ return TK_ERROR;
+ }
+ }
+
+ }
+ }
+ }
+
+public:
+ Error parse(const String& p_code,const String& p_known_class_name=String()) {
+
+ code=p_code;
+ idx=0;
+ line=0;
+ error_str=String();
+ error=false;
+ value=Variant();
+ class_name=String();
+
+ bool use_next_class=false;
+ Token tk = get_token();
+
+ Map<int,String> namespace_stack;
+ int curly_stack=0;
+
+
+ while(!error || tk!=TK_EOF) {
+
+ if (tk==TK_BRACKET_OPEN) {
+ tk = get_token();
+ if (tk==TK_IDENTIFIER && String(value)=="ScriptClass") {
+ if (get_token()==TK_BRACKET_CLOSE) {
+ use_next_class=true;
+ }
+ }
+ } else if (tk==TK_IDENTIFIER && String(value)=="class") {
+ tk = get_token();
+ if (tk==TK_IDENTIFIER) {
+ String name = value;
+ if (use_next_class || p_known_class_name==name) {
+ for (Map<int,String>::Element *E=namespace_stack.front();E;E=E->next()) {
+ class_name+=E->get()+".";
+ }
+ class_name+=String(value);
+ break;
+ }
+ }
+
+ } else if (tk==TK_IDENTIFIER && String(value)=="namespace") {
+ String name;
+ int at_level = curly_stack;
+ while(true) {
+ tk = get_token();
+ if (tk==TK_IDENTIFIER) {
+ name+=String(value);
+ }
+
+ tk = get_token();
+ if (tk==TK_PERIOD) {
+ name+=".";
+ } else if (tk==TK_CURLY_BRACKET_OPEN) {
+ curly_stack++;
+ break;
+ } else {
+ break; //whathever else
+ }
+
+ }
+
+ if (name!=String()) {
+ namespace_stack[at_level]=name;
+ }
+
+ } else if (tk==TK_CURLY_BRACKET_OPEN) {
+ curly_stack++;
+ } else if (tk==TK_CURLY_BRACKET_CLOSE) {
+ curly_stack--;
+ if (namespace_stack.has(curly_stack)) {
+ namespace_stack.erase(curly_stack);
+ }
+ }
+
+ tk = get_token();
+ }
+
+ if (error)
+ return ERR_PARSE_ERROR;
+
+
+
+ return OK;
+
+ }
+
+ String get_error() {
+ return error_str;
+ }
+
+ String get_class() {
+ return class_name;
+ }
+
+};
+
+
void test_vec(Plane p_vec) {
@@ -113,7 +477,41 @@ uint32_t ihash3( uint32_t a)
MainLoop* test() {
- print_line(itos(Math::step_decimals( 0.0001 )));
+
+ List<String> cmdlargs = OS::get_singleton()->get_cmdline_args();
+
+ if (cmdlargs.empty()) {
+ //try editor!
+ return NULL;
+ }
+
+ String test = cmdlargs.back()->get();
+
+ FileAccess *fa = FileAccess::open(test,FileAccess::READ);
+
+ if (!fa) {
+ ERR_EXPLAIN("Could not open file: "+test);
+ ERR_FAIL_V(NULL);
+ }
+
+
+ Vector<uint8_t> buf;
+ int flen = fa->get_len();
+ buf.resize(fa->get_len()+1);
+ fa->get_buffer(&buf[0],flen);
+ buf[flen]=0;
+
+
+ String code;
+ code.parse_utf8((const char*)&buf[0]);
+
+ GetClassAndNamespace getclass;
+ if (getclass.parse(code)) {
+ print_line("Parse error: "+getclass.get_error());
+ } else {
+ print_line("Found class: "+getclass.get_class());
+ }
+
return NULL;
{
diff --git a/core/input_map.cpp b/core/input_map.cpp
index 3a0f9596f5..09cb7ce426 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -232,64 +232,6 @@ bool InputMap::event_is_action(const InputEvent& p_event, const StringName& p_ac
return _find_event(E->get().inputs,p_event)!=NULL;
}
-bool InputMap::event_is_joy_motion_action_pressed(const InputEvent& p_event) const {
-
- ERR_FAIL_COND_V(p_event.type!=InputEvent::JOYSTICK_MOTION,false);
- bool pressed=false;
-
- //this could be optimized by having a separate list of joymotions?
-
- for (Map<StringName, Action>::Element *A=input_map.front();A;A=A->next()) {
-
- for (List<InputEvent>::Element *E=A->get().inputs.front();E;E=E->next()) {
-
- const InputEvent& e=E->get();
- if(e.type!=p_event.type)
- continue;
- if (e.type!=InputEvent::KEY && e.device!=p_event.device)
- continue;
-
- switch(p_event.type) {
-
- case InputEvent::KEY: {
-
- if (e.key.scancode==p_event.key.scancode && e.key.mod == p_event.key.mod)
- return e.key.pressed;
-
- } break;
- case InputEvent::JOYSTICK_BUTTON: {
-
- if (e.joy_button.button_index==p_event.joy_button.button_index) {
- return e.joy_button.pressed;
- }
-
- } break;
- case InputEvent::MOUSE_BUTTON: {
-
- if (e.mouse_button.button_index==p_event.mouse_button.button_index) {
- return e.mouse_button.pressed;
- }
-
- } break;
- case InputEvent::JOYSTICK_MOTION: {
-
- if (e.joy_motion.axis==p_event.joy_motion.axis) {
- if (
- (e.joy_motion.axis_value * p_event.joy_motion.axis_value >0) && //same axis
- ABS(e.joy_motion.axis_value)>0.5 && ABS(p_event.joy_motion.axis_value)>0.5 )
- pressed=true;
- }
-
- } break;
- }
-
- }
- }
-
- return pressed;
-
-}
-
const Map<StringName, InputMap::Action>& InputMap::get_action_map() const {
return input_map;
}
diff --git a/core/input_map.h b/core/input_map.h
index a224765d8c..21c479588d 100644
--- a/core/input_map.h
+++ b/core/input_map.h
@@ -72,7 +72,6 @@ public:
const List<InputEvent> *get_action_list(const StringName& p_action);
bool event_is_action(const InputEvent& p_event, const StringName& p_action) const;
- bool event_is_joy_motion_action_pressed(const InputEvent& p_event) const;
const Map<StringName, Action>& get_action_map() const;
void load_from_globals();
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
new file mode 100644
index 0000000000..5bbbbdaa5a
--- /dev/null
+++ b/core/math/a_star.cpp
@@ -0,0 +1,412 @@
+#include "a_star.h"
+#include "geometry.h"
+
+
+int AStar::get_available_point_id() const {
+
+ if (points.empty()) {
+ return 1;
+ }
+
+ return points.back()->key()+1;
+}
+
+void AStar::add_point(int p_id, const Vector3 &p_pos, float p_weight_scale) {
+ ERR_FAIL_COND(p_id<0);
+ if (!points.has(p_id)) {
+ Point *pt = memnew( Point );
+ pt->id=p_id;
+ pt->pos=p_pos;
+ pt->weight_scale=p_weight_scale;
+ pt->prev_point=NULL;
+ pt->last_pass=0;
+ points[p_id]=pt;
+ } else {
+ points[p_id]->pos=p_pos;
+ points[p_id]->weight_scale=p_weight_scale;
+ }
+}
+
+Vector3 AStar::get_point_pos(int p_id) const{
+
+ ERR_FAIL_COND_V(!points.has(p_id),Vector3());
+
+ return points[p_id]->pos;
+
+}
+float AStar::get_point_weight_scale(int p_id) const{
+
+ ERR_FAIL_COND_V(!points.has(p_id),0);
+
+ return points[p_id]->weight_scale;
+
+}
+void AStar::remove_point(int p_id){
+
+ ERR_FAIL_COND(!points.has(p_id));
+
+ Point* p = points[p_id];
+
+ for(int i=0;i<p->neighbours.size();i++) {
+
+ Segment s(p_id,p->neighbours[i]->id);
+ segments.erase(s);
+ p->neighbours[i]->neighbours.erase(p);
+ }
+
+ memdelete(p);
+ points.erase(p_id);
+}
+
+void AStar::connect_points(int p_id,int p_with_id){
+
+ ERR_FAIL_COND(!points.has(p_id));
+ ERR_FAIL_COND(!points.has(p_with_id));
+ ERR_FAIL_COND(p_id==p_with_id);
+
+
+ Point* a = points[p_id];
+ Point* b = points[p_with_id];
+ a->neighbours.push_back(b);
+ b->neighbours.push_back(a);
+
+ Segment s(p_id,p_with_id);
+ if (s.from==p_id) {
+ s.from_point=a;
+ s.to_point=b;
+ } else {
+ s.from_point=b;
+ s.to_point=a;
+ }
+
+ segments.insert(s);
+
+
+}
+void AStar::disconnect_points(int p_id,int p_with_id){
+
+ Segment s(p_id,p_with_id);
+ ERR_FAIL_COND(!segments.has(s));
+
+
+ segments.erase(s);
+
+ Point *a = points[p_id];
+ Point *b = points[p_with_id];
+ a->neighbours.erase(b);
+ b->neighbours.erase(a);
+
+}
+bool AStar::are_points_connected(int p_id,int p_with_id) const{
+
+ Segment s(p_id,p_with_id);
+ return segments.has(s);
+}
+
+void AStar::clear(){
+
+ for (const Map<int,Point*>::Element *E=points.front();E;E=E->next()) {
+
+ memdelete(E->get());
+ }
+ segments.clear();
+ points.clear();
+}
+
+
+int AStar::get_closest_point(const Vector3& p_point) const{
+
+ int closest_id=-1;
+ float closest_dist=1e20;
+
+ for (const Map<int,Point*>::Element *E=points.front();E;E=E->next()) {
+
+ float d = p_point.distance_squared_to(E->get()->pos);
+ if (closest_id<0 || d<closest_dist) {
+ closest_dist=d;
+ closest_id=E->key();
+ }
+ }
+
+ return closest_id;
+
+
+}
+Vector3 AStar::get_closest_pos_in_segment(const Vector3& p_point) const {
+
+ float closest_dist = 1e20;
+ bool found=false;
+ Vector3 closest_point;
+
+
+ for (const Set<Segment>::Element *E=segments.front();E;E=E->next()) {
+
+ Vector3 segment[2]={
+ E->get().from_point->pos,
+ E->get().to_point->pos,
+ };
+
+ Vector3 p = Geometry::get_closest_point_to_segment(p_point,segment);
+ float d = p_point.distance_squared_to(p);
+ if (!found || d<closest_dist) {
+
+ closest_point=p;
+ closest_dist=d;
+ found=true;
+ }
+ }
+
+ return closest_point;
+}
+
+bool AStar::_solve(Point* begin_point, Point* end_point) {
+
+ pass++;
+
+ SelfList<Point>::List open_list;
+
+ bool found_route=false;
+
+
+ for(int i=0;i<begin_point->neighbours.size();i++) {
+
+ Point *n = begin_point->neighbours[i];
+ n->prev_point=begin_point;
+ n->distance=n->pos.distance_to(begin_point->pos);
+ n->distance*=n->weight_scale;
+ n->last_pass=pass;
+ open_list.add(&n->list);
+
+ if (end_point==n) {
+ found_route=true;
+ break;
+ }
+ }
+
+ while(!found_route) {
+
+ if (open_list.first()==NULL) {
+ //could not find path sadly
+ break;
+ }
+ //check open list
+
+ SelfList<Point> *least_cost_point=NULL;
+ float least_cost=1e30;
+
+ //this could be faster (cache previous results)
+ for (SelfList<Point> *E=open_list.first();E;E=E->next()) {
+
+ Point *p=E->self();
+
+ float cost=p->distance;
+ cost+=p->pos.distance_to(end_point->pos);
+ cost*=p->weight_scale;
+
+ if (cost<least_cost) {
+
+ least_cost_point=E;
+ least_cost=cost;
+ }
+ }
+
+
+ Point *p=least_cost_point->self();
+ //open the neighbours for search
+ int es = p->neighbours.size();
+
+ for(int i=0;i<es;i++) {
+
+
+ Point* e=p->neighbours[i];
+
+
+ float distance = p->pos.distance_to(e->pos) + p->distance;
+ distance*=e->weight_scale;
+
+
+
+ if (e->last_pass==pass) {
+ //oh this was visited already, can we win the cost?
+
+ if (e->distance>distance) {
+
+ e->prev_point=p;
+ e->distance=distance;
+ }
+ } else {
+ //add to open neighbours
+
+ e->prev_point=p;
+ e->distance=distance;
+ e->last_pass=pass; //mark as used
+ open_list.add(&e->list);
+
+ if (e==end_point) {
+ //oh my reached end! stop algorithm
+ found_route=true;
+ break;
+
+ }
+
+ }
+ }
+
+ if (found_route)
+ break;
+
+ open_list.remove(least_cost_point);
+ }
+
+ //clear the openf list
+ while(open_list.first()) {
+ open_list.remove( open_list.first() );
+ }
+
+ return found_route;
+
+}
+
+DVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
+
+ ERR_FAIL_COND_V(!points.has(p_from_id),DVector<Vector3>());
+ ERR_FAIL_COND_V(!points.has(p_to_id),DVector<Vector3>());
+
+
+ pass++;
+
+ Point* a = points[p_from_id];
+ Point* b = points[p_to_id];
+
+ if (a==b) {
+ DVector<Vector3> ret;
+ ret.push_back(a->pos);
+ return ret;
+ }
+
+
+ Point *begin_point=a;
+ Point *end_point=b;
+
+ bool found_route=_solve(begin_point,end_point);
+
+ if (!found_route)
+ return DVector<Vector3>();
+
+ //midpoints
+ Point *p=end_point;
+ int pc=1; //begin point
+ while(p!=begin_point) {
+ pc++;
+ p=p->prev_point;
+ }
+
+ DVector<Vector3> path;
+ path.resize(pc);
+
+ {
+ DVector<Vector3>::Write w = path.write();
+
+ Point *p=end_point;
+ int idx=pc-1;
+ while(p!=begin_point) {
+ w[idx--]=p->pos;
+ p=p->prev_point;
+ }
+
+ w[0]=p->pos; //assign first
+
+ }
+
+ return path;
+
+}
+
+
+DVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
+
+ ERR_FAIL_COND_V(!points.has(p_from_id),DVector<int>());
+ ERR_FAIL_COND_V(!points.has(p_to_id),DVector<int>());
+
+
+ pass++;
+
+ Point* a = points[p_from_id];
+ Point* b = points[p_to_id];
+
+ if (a==b) {
+ DVector<int> ret;
+ ret.push_back(a->id);
+ return ret;
+ }
+
+
+ Point *begin_point=a;
+ Point *end_point=b;
+
+ bool found_route=_solve(begin_point,end_point);
+
+ if (!found_route)
+ return DVector<int>();
+
+ //midpoints
+ Point *p=end_point;
+ int pc=1; //begin point
+ while(p!=begin_point) {
+ pc++;
+ p=p->prev_point;
+ }
+
+ DVector<int> path;
+ path.resize(pc);
+
+ {
+ DVector<int>::Write w = path.write();
+
+ p=end_point;
+ int idx=pc-1;
+ while(p!=begin_point) {
+ w[idx--]=p->id;
+ p=p->prev_point;
+ }
+
+ w[0]=p->id; //assign first
+
+ }
+
+ return path;
+}
+
+void AStar::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("get_available_point_id"),&AStar::get_available_point_id);
+ ObjectTypeDB::bind_method(_MD("add_point","id","pos","weight_scale"),&AStar::add_point,DEFVAL(1.0));
+ ObjectTypeDB::bind_method(_MD("get_point_pos","id"),&AStar::get_point_pos);
+ ObjectTypeDB::bind_method(_MD("get_point_weight_scale","id"),&AStar::get_point_weight_scale);
+ ObjectTypeDB::bind_method(_MD("remove_point","id"),&AStar::remove_point);
+
+ ObjectTypeDB::bind_method(_MD("connect_points","id","to_id"),&AStar::connect_points);
+ ObjectTypeDB::bind_method(_MD("disconnect_points","id","to_id"),&AStar::disconnect_points);
+ ObjectTypeDB::bind_method(_MD("are_points_connected","id","to_id"),&AStar::are_points_connected);
+
+ ObjectTypeDB::bind_method(_MD("clear"),&AStar::clear);
+
+ ObjectTypeDB::bind_method(_MD("get_closest_point","to_pos"),&AStar::get_closest_point);
+ ObjectTypeDB::bind_method(_MD("get_closest_pos_in_segment","to_pos"),&AStar::get_closest_pos_in_segment);
+
+ ObjectTypeDB::bind_method(_MD("get_point_path","from_id","to_id"),&AStar::get_point_path);
+ ObjectTypeDB::bind_method(_MD("get_id_path","from_id","to_id"),&AStar::get_id_path);
+
+}
+
+
+AStar::AStar() {
+
+ pass=1;
+}
+
+
+AStar::~AStar() {
+
+ pass=1;
+}
diff --git a/core/math/a_star.h b/core/math/a_star.h
new file mode 100644
index 0000000000..a0517b5941
--- /dev/null
+++ b/core/math/a_star.h
@@ -0,0 +1,92 @@
+#ifndef ASTAR_H
+#define ASTAR_H
+
+#include "reference.h"
+#include "self_list.h"
+
+class AStar: public Reference {
+
+ OBJ_TYPE(AStar,Reference)
+
+
+ uint64_t pass;
+
+ struct Point {
+
+ SelfList<Point> list;
+
+ int id;
+ Vector3 pos;
+ float weight_scale;
+ uint64_t last_pass;
+
+ Vector<Point*> neighbours;
+
+ //used for pathfinding
+ Point *prev_point;
+ float distance;
+
+ Point() : list(this) {}
+ };
+
+ Map<int,Point*> points;
+
+ struct Segment {
+ union {
+ struct {
+ int32_t from;
+ int32_t to;
+ };
+ uint64_t key;
+ };
+
+ Point *from_point;
+ Point *to_point;
+
+ bool operator<(const Segment& p_s) const { return key<p_s.key; }
+ Segment() { key=0; }
+ Segment(int p_from,int p_to) {
+ if (p_from > p_to) {
+ SWAP(p_from,p_to);
+ }
+
+ from=p_from;
+ to=p_to;
+ }
+ };
+
+
+ Set<Segment> segments;
+
+ bool _solve(Point *begin_point, Point *end_point);
+
+protected:
+
+ static void _bind_methods();
+public:
+
+ int get_available_point_id() const;
+
+ void add_point(int p_id,const Vector3& p_pos,float p_weight_scale=1);
+ Vector3 get_point_pos(int p_id) const;
+ float get_point_weight_scale(int p_id) const;
+ void remove_point(int p_id);
+
+ void connect_points(int p_id,int p_with_id);
+ void disconnect_points(int p_id,int p_with_id);
+ bool are_points_connected(int p_id,int p_with_id) const;
+
+ void clear();
+
+
+ int get_closest_point(const Vector3& p_point) const;
+ Vector3 get_closest_pos_in_segment(const Vector3& p_point) const;
+
+ DVector<Vector3> get_point_path(int p_from_id, int p_to_id);
+ DVector<int> get_id_path(int p_from_id, int p_to_id);
+
+ AStar();
+ ~AStar();
+};
+
+#endif // ASTAR_H
diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp
index 0e2060008c..2cc11aa738 100644
--- a/core/math/math_2d.cpp
+++ b/core/math/math_2d.cpp
@@ -475,18 +475,18 @@ Matrix32::Matrix32(real_t p_rot, const Vector2& p_pos) {
elements[2]=p_pos;
}
-Vector2 Matrix32::get_scale() const {
+Size2 Matrix32::get_scale() const {
- return Vector2( elements[0].length(), elements[1].length() );
+ return Size2( elements[0].length(), elements[1].length() );
}
-void Matrix32::scale(const Vector2& p_scale) {
+void Matrix32::scale(const Size2& p_scale) {
elements[0]*=p_scale;
elements[1]*=p_scale;
elements[2]*=p_scale;
}
-void Matrix32::scale_basis(const Vector2& p_scale) {
+void Matrix32::scale_basis(const Size2& p_scale) {
elements[0]*=p_scale;
elements[1]*=p_scale;
@@ -501,7 +501,6 @@ void Matrix32::translate( const Vector2& p_translation ) {
elements[2]+=basis_xform(p_translation);
}
-
void Matrix32::orthonormalize() {
// Gram-Schmidt Process
@@ -550,11 +549,6 @@ void Matrix32::operator*=(const Matrix32& p_transform) {
elements[2] = xform(p_transform.elements[2]);
float x0,x1,y0,y1;
-/*
- x0 = p_transform.tdotx(elements[0]);
- x1 = p_transform.tdoty(elements[0]);
- y0 = p_transform.tdotx(elements[1]);
- y1 = p_transform.tdoty(elements[1]);*/
x0 = tdotx(p_transform.elements[0]);
x1 = tdoty(p_transform.elements[0]);
@@ -576,7 +570,7 @@ Matrix32 Matrix32::operator*(const Matrix32& p_transform) const {
}
-Matrix32 Matrix32::scaled(const Vector2& p_scale) const {
+Matrix32 Matrix32::scaled(const Size2& p_scale) const {
Matrix32 copy=*this;
copy.scale(p_scale);
@@ -584,7 +578,7 @@ Matrix32 Matrix32::scaled(const Vector2& p_scale) const {
}
-Matrix32 Matrix32::basis_scaled(const Vector2& p_scale) const {
+Matrix32 Matrix32::basis_scaled(const Size2& p_scale) const {
Matrix32 copy=*this;
copy.scale_basis(p_scale);
@@ -629,8 +623,8 @@ Matrix32 Matrix32::interpolate_with(const Matrix32& p_transform, float p_c) cons
real_t r1 = get_rotation();
real_t r2 = p_transform.get_rotation();
- Vector2 s1 = get_scale();
- Vector2 s2 = p_transform.get_scale();
+ Size2 s1 = get_scale();
+ Size2 s2 = p_transform.get_scale();
//slerp rotation
Vector2 v1(Math::cos(r1), Math::sin(r1));
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index 90aae9fe50..38c1ac9656 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -553,10 +553,8 @@ struct Rect2i {
struct Matrix32 {
-
Vector2 elements[3];
-
_FORCE_INLINE_ float tdotx(const Vector2& v) const { return elements[0][0] * v.x + elements[1][0] * v.y; }
_FORCE_INLINE_ float tdoty(const Vector2& v) const { return elements[0][1] * v.x + elements[1][1] * v.y; }
@@ -577,26 +575,25 @@ struct Matrix32 {
_FORCE_INLINE_ void set_rotation_and_scale(real_t p_phi,const Size2& p_scale);
void rotate(real_t p_phi);
- void scale(const Vector2& p_scale);
- void scale_basis(const Vector2& p_scale);
+ void scale(const Size2& p_scale);
+ void scale_basis(const Size2& p_scale);
void translate( real_t p_tx, real_t p_ty);
void translate( const Vector2& p_translation );
float basis_determinant() const;
- Vector2 get_scale() const;
+ Size2 get_scale() const;
_FORCE_INLINE_ const Vector2& get_origin() const { return elements[2]; }
_FORCE_INLINE_ void set_origin(const Vector2& p_origin) { elements[2]=p_origin; }
- Matrix32 scaled(const Vector2& p_scale) const;
- Matrix32 basis_scaled(const Vector2& p_scale) const;
+ Matrix32 scaled(const Size2& p_scale) const;
+ Matrix32 basis_scaled(const Size2& p_scale) const;
Matrix32 translated(const Vector2& p_offset) const;
Matrix32 rotated(float p_phi) const;
Matrix32 untranslated() const;
-
void orthonormalize();
Matrix32 orthonormalized() const;
@@ -615,7 +612,6 @@ struct Matrix32 {
_FORCE_INLINE_ Rect2 xform(const Rect2& p_vec) const;
_FORCE_INLINE_ Rect2 xform_inv(const Rect2& p_vec) const;
-
operator String() const;
Matrix32(real_t xx, real_t xy, real_t yx, real_t yy, real_t ox, real_t oy) {
@@ -630,7 +626,6 @@ struct Matrix32 {
Matrix32(real_t p_rot, const Vector2& p_pos);
Matrix32() { elements[0][0]=1.0; elements[1][1]=1.0; }
-
};
bool Rect2::intersects_transformed(const Matrix32& p_xform, const Rect2& p_rect) const {
diff --git a/core/object_type_db.cpp b/core/object_type_db.cpp
index aa641923e6..e121dc9e98 100644
--- a/core/object_type_db.cpp
+++ b/core/object_type_db.cpp
@@ -189,6 +189,14 @@ MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,co
#endif
+
+ObjectTypeDB::APIType ObjectTypeDB::current_api=API_CORE;
+
+void ObjectTypeDB::set_current_api(APIType p_api) {
+
+ current_api=p_api;
+}
+
HashMap<StringName,ObjectTypeDB::TypeInfo,StringNameHasher> ObjectTypeDB::types;
HashMap<StringName,StringName,StringNameHasher> ObjectTypeDB::resource_base_extensions;
HashMap<StringName,StringName,StringNameHasher> ObjectTypeDB::compat_types;
@@ -258,6 +266,171 @@ StringName ObjectTypeDB::type_inherits_from(const StringName& p_type) {
return ti->inherits;
}
+ObjectTypeDB::APIType ObjectTypeDB::get_api_type(const StringName &p_type) {
+
+ OBJTYPE_LOCK;
+
+ TypeInfo *ti = types.getptr(p_type);
+ ERR_FAIL_COND_V(!ti,API_NONE);
+ return ti->api;
+}
+
+uint64_t ObjectTypeDB::get_api_hash(APIType p_api) {
+
+#ifdef DEBUG_METHODS_ENABLED
+
+ uint64_t hash = hash_djb2_one_64(HashMapHahserDefault::hash(VERSION_FULL_NAME));
+
+ List<StringName> names;
+
+ const StringName *k=NULL;
+
+ while((k=types.next(k))) {
+
+ names.push_back(*k);
+ }
+ //must be alphabetically sorted for hash to compute
+ names.sort_custom<StringName::AlphCompare>();
+
+ for (List<StringName>::Element *E=names.front();E;E=E->next()) {
+
+ TypeInfo *t = types.getptr(E->get());
+ ERR_FAIL_COND_V(!t,0);
+ if (t->api!=p_api)
+ continue;
+ hash = hash_djb2_one_64(t->name.hash(),hash);
+ hash = hash_djb2_one_64(t->inherits.hash(),hash);
+
+ { //methods
+
+ List<StringName> snames;
+
+ k=NULL;
+
+ while((k=t->method_map.next(k))) {
+
+ snames.push_back(*k);
+ }
+
+ snames.sort_custom<StringName::AlphCompare>();
+
+ for (List<StringName>::Element *F=snames.front();F;F=F->next()) {
+
+ MethodBind *mb = t->method_map[F->get()];
+ hash = hash_djb2_one_64( mb->get_name().hash(), hash);
+ hash = hash_djb2_one_64( mb->get_argument_count(), hash);
+ hash = hash_djb2_one_64( mb->get_argument_type(-1), hash); //return
+
+ for(int i=0;i<mb->get_argument_count();i++) {
+ hash = hash_djb2_one_64( mb->get_argument_info(i).type, hash );
+ hash = hash_djb2_one_64( mb->get_argument_info(i).name.hash(), hash );
+ hash = hash_djb2_one_64( mb->get_argument_info(i).hint, hash );
+ hash = hash_djb2_one_64( mb->get_argument_info(i).hint_string.hash(), hash );
+ }
+
+ hash = hash_djb2_one_64( mb->get_default_argument_count(), hash);
+
+ for(int i=0;i<mb->get_default_argument_count();i++) {
+ //hash should not change, i hope for tis
+ Variant da = mb->get_default_argument(i);
+ hash = hash_djb2_one_64( da.hash(), hash );
+ }
+
+ hash = hash_djb2_one_64( mb->get_hint_flags(), hash);
+
+ }
+ }
+
+
+ { //constants
+
+ List<StringName> snames;
+
+ k=NULL;
+
+ while((k=t->constant_map.next(k))) {
+
+ snames.push_back(*k);
+ }
+
+ snames.sort_custom<StringName::AlphCompare>();
+
+ for (List<StringName>::Element *F=snames.front();F;F=F->next()) {
+
+ hash = hash_djb2_one_64(F->get().hash(), hash);
+ hash = hash_djb2_one_64( t->constant_map[F->get()], hash);
+ }
+ }
+
+
+ { //signals
+
+ List<StringName> snames;
+
+ k=NULL;
+
+ while((k=t->signal_map.next(k))) {
+
+ snames.push_back(*k);
+ }
+
+ snames.sort_custom<StringName::AlphCompare>();
+
+ for (List<StringName>::Element *F=snames.front();F;F=F->next()) {
+
+ MethodInfo &mi = t->signal_map[F->get()];
+ hash = hash_djb2_one_64( F->get().hash(), hash);
+ for(int i=0;i<mi.arguments.size();i++) {
+ hash = hash_djb2_one_64( mi.arguments[i].type, hash);
+ }
+ }
+ }
+
+ { //properties
+
+ List<StringName> snames;
+
+ k=NULL;
+
+ while((k=t->property_setget.next(k))) {
+
+ snames.push_back(*k);
+ }
+
+ snames.sort_custom<StringName::AlphCompare>();
+
+ for (List<StringName>::Element *F=snames.front();F;F=F->next()) {
+
+ PropertySetGet *psg=t->property_setget.getptr(F->get());
+
+ hash = hash_djb2_one_64( F->get().hash(), hash);
+ hash = hash_djb2_one_64( psg->setter.hash(), hash);
+ hash = hash_djb2_one_64( psg->getter.hash(), hash);
+
+ }
+ }
+
+ //property list
+ for (List<PropertyInfo>::Element *F=t->property_list.front();F;F=F->next()) {
+
+ hash = hash_djb2_one_64( F->get().name.hash(), hash);
+ hash = hash_djb2_one_64( F->get().type, hash);
+ hash = hash_djb2_one_64( F->get().hint, hash);
+ hash = hash_djb2_one_64( F->get().hint_string.hash(), hash);
+ hash = hash_djb2_one_64( F->get().usage, hash);
+ }
+
+
+ }
+
+
+ return hash;
+#else
+ return 0;
+#endif
+
+}
+
bool ObjectTypeDB::type_exists(const StringName &p_type) {
OBJTYPE_LOCK;
@@ -309,6 +482,7 @@ void ObjectTypeDB::_add_type2(const StringName& p_type, const StringName& p_inhe
TypeInfo &ti=types[name];
ti.name=name;
ti.inherits=p_inherits;
+ ti.api=current_api;
if (ti.inherits) {
diff --git a/core/object_type_db.h b/core/object_type_db.h
index 725b424c9a..9e9029ff2f 100644
--- a/core/object_type_db.h
+++ b/core/object_type_db.h
@@ -109,7 +109,13 @@ static _FORCE_INLINE_ const char* _MD(const char* m_name, ...) { return m_name;
#endif
class ObjectTypeDB {
-
+public:
+ enum APIType {
+ API_CORE,
+ API_EDITOR,
+ API_NONE
+ };
+public:
struct PropertySetGet {
int index;
@@ -122,6 +128,7 @@ class ObjectTypeDB {
struct TypeInfo {
+ APIType api;
TypeInfo *inherits_ptr;
HashMap<StringName,MethodBind*,StringNameHasher> method_map;
HashMap<StringName,int,StringNameHasher> constant_map;
@@ -161,6 +168,7 @@ class ObjectTypeDB {
#endif
+ static APIType current_api;
static void _add_type2(const StringName& p_type, const StringName& p_inherits);
public:
@@ -236,6 +244,9 @@ public:
static bool is_type(const StringName &p_type,const StringName& p_inherits);
static bool can_instance(const StringName &p_type);
static Object *instance(const StringName &p_type);
+ static APIType get_api_type(const StringName &p_type);
+
+ static uint64_t get_api_hash(APIType p_api);
#if 0
template<class N, class M>
@@ -499,6 +510,8 @@ public:
static void add_compatibility_type(const StringName& p_type,const StringName& p_fallback);
static void init();
+
+ static void set_current_api(APIType p_api);
static void cleanup();
};
diff --git a/core/os/input.cpp b/core/os/input.cpp
index 401ab7ffe2..4ab57a84ea 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -64,6 +64,10 @@ void Input::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_connected_joysticks"),&Input::get_connected_joysticks);
ObjectTypeDB::bind_method(_MD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength);
ObjectTypeDB::bind_method(_MD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration);
+ ObjectTypeDB::bind_method(_MD("get_joy_button_string", "button_index"), &Input::get_joy_button_string);
+ ObjectTypeDB::bind_method(_MD("get_joy_button_index_from_string", "button"), &Input::get_joy_button_index_from_string);
+ ObjectTypeDB::bind_method(_MD("get_joy_axis_string", "axis_index"), &Input::get_joy_axis_string);
+ ObjectTypeDB::bind_method(_MD("get_joy_axis_index_from_string", "axis"), &Input::get_joy_axis_index_from_string);
ObjectTypeDB::bind_method(_MD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0));
ObjectTypeDB::bind_method(_MD("stop_joy_vibration", "device"), &Input::stop_joy_vibration);
ObjectTypeDB::bind_method(_MD("get_accelerometer"),&Input::get_accelerometer);
@@ -90,7 +94,7 @@ void Input::get_argument_options(const StringName& p_function,int p_idx,List<Str
#ifdef TOOLS_ENABLED
String pf=p_function;
- if (p_idx==0 && (pf=="is_action_pressed" || pf=="action_press" || pf=="action_release")) {
+ if (p_idx==0 && (pf=="is_action_pressed" || pf=="action_press" || pf=="action_release" || pf=="is_action_just_pressed" || pf=="is_action_just_released")) {
List<PropertyInfo> pinfo;
Globals::get_singleton()->get_property_list(&pinfo);
diff --git a/core/os/input.h b/core/os/input.h
index 665fb4ad99..d8f3be09df 100644
--- a/core/os/input.h
+++ b/core/os/input.h
@@ -96,6 +96,11 @@ public:
virtual void set_custom_mouse_cursor(const RES& p_cursor,const Vector2& p_hotspot=Vector2())=0;
virtual void set_mouse_in_window(bool p_in_window)=0;
+ virtual String get_joy_button_string(int p_button)=0;
+ virtual String get_joy_axis_string(int p_axis)=0;
+ virtual int get_joy_button_index_from_string(String p_button)=0;
+ virtual int get_joy_axis_index_from_string(String p_axis)=0;
+
Input();
};
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 9d920724e1..9982767be1 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -204,7 +204,7 @@ bool InputEvent::is_pressed() const {
case MOUSE_BUTTON: return mouse_button.pressed;
case JOYSTICK_BUTTON: return joy_button.pressed;
case SCREEN_TOUCH: return screen_touch.pressed;
- case JOYSTICK_MOTION: return InputMap::get_singleton()->event_is_joy_motion_action_pressed(*this);
+ case JOYSTICK_MOTION: return ABS(joy_motion.axis_value) > 0.5;
case ACTION: return action.pressed;
default: {}
}
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 3de26573f4..7e4ba039c5 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -33,6 +33,7 @@
#include "io/config_file.h"
#include "os/main_loop.h"
#include "io/packet_peer.h"
+#include "math/a_star.h"
#include "globals.h"
#include "object_type_db.h"
#include "geometry.h"
@@ -147,6 +148,7 @@ void register_core_types() {
ObjectTypeDB::register_type<PackedDataContainer>();
ObjectTypeDB::register_virtual_type<PackedDataContainerRef>();
+ ObjectTypeDB::register_type<AStar>();
ip = IP::create();
diff --git a/core/script_language.h b/core/script_language.h
index 1b037e908c..53af4c74d1 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -122,6 +122,7 @@ public:
virtual void get_script_method_list(List<MethodInfo> *p_list) const=0;
virtual void get_script_property_list(List<PropertyInfo> *p_list) const=0;
+ virtual int get_member_line(const StringName& p_member) const { return 0; }
Script() {}
};
@@ -207,7 +208,26 @@ public:
virtual bool has_named_classes() const=0;
virtual int find_function(const String& p_function,const String& p_code) const=0;
virtual String make_function(const String& p_class,const String& p_name,const StringArray& p_args) const=0;
+
virtual Error complete_code(const String& p_code, const String& p_base_path, Object*p_owner,List<String>* r_options,String& r_call_hint) { return ERR_UNAVAILABLE; }
+
+ struct LookupResult {
+ enum Type {
+ RESULT_SCRIPT_LOCATION,
+ RESULT_CLASS,
+ RESULT_CLASS_CONSTANT,
+ RESULT_CLASS_PROPERTY,
+ RESULT_CLASS_METHOD
+ };
+ Type type;
+ Ref<Script> script;
+ String class_name;
+ String class_member;
+ int location;
+ };
+
+ virtual Error lookup_code(const String& p_code, const String& p_symbol,const String& p_base_path, Object*p_owner,LookupResult& r_result) { return ERR_UNAVAILABLE; }
+
virtual void auto_indent_code(String& p_code,int p_from_line,int p_to_line) const=0;
virtual void add_global_constant(const StringName& p_variable,const Variant& p_value)=0;
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 0d887210c3..f7dcba6b14 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -3173,7 +3173,7 @@ bool String::is_valid_identifier() const {
//kind of poor should be rewritten properly
-String String::world_wrap(int p_chars_per_line) const {
+String String::word_wrap(int p_chars_per_line) const {
int from=0;
int last_space=0;
diff --git a/core/ustring.h b/core/ustring.h
index bb57b11d88..09d13a9e64 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -218,7 +218,7 @@ public:
String c_escape() const;
String c_unescape() const;
String json_escape() const;
- String world_wrap(int p_chars_per_line) const;
+ String word_wrap(int p_chars_per_line) const;
String percent_encode() const;
String percent_decode() const;
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index f7bc38ac06..a84eed4d88 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -346,6 +346,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM0R(Vector2,angle);
// VCALL_LOCALMEM1R(Vector2,cross);
VCALL_LOCALMEM0R(Vector2,abs);
+ VCALL_LOCALMEM1R(Vector2,clamped);
VCALL_LOCALMEM0R(Rect2,get_area);
VCALL_LOCALMEM1R(Rect2,intersects);
@@ -1457,6 +1458,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(VECTOR2,VECTOR2,Vector2,reflect,VECTOR2,"vec",varray());
//ADDFUNC1(VECTOR2,REAL,Vector2,cross,VECTOR2,"with",varray());
ADDFUNC0(VECTOR2,VECTOR2,Vector2,abs,varray());
+ ADDFUNC1(VECTOR2,VECTOR2,Vector2,clamped,REAL,"length",varray());
ADDFUNC0(RECT2,REAL,Rect2,get_area,varray());
ADDFUNC1(RECT2,BOOL,Rect2,intersects,RECT2,"b",varray());
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index 916ca09c92..deed5c5cda 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -2153,6 +2153,120 @@
<constants>
</constants>
</class>
+<class name="AStar" inherits="Reference" category="Core">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <methods>
+ <method name="add_point">
+ <argument index="0" name="id" type="int">
+ </argument>
+ <argument index="1" name="pos" type="Vector3">
+ </argument>
+ <argument index="2" name="weight_scale" type="float" default="1">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="are_points_connected" qualifiers="const">
+ <return type="bool">
+ </return>
+ <argument index="0" name="id" type="int">
+ </argument>
+ <argument index="1" name="to_id" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="clear">
+ <description>
+ </description>
+ </method>
+ <method name="connect_points">
+ <argument index="0" name="id" type="int">
+ </argument>
+ <argument index="1" name="to_id" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="disconnect_points">
+ <argument index="0" name="id" type="int">
+ </argument>
+ <argument index="1" name="to_id" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_available_point_id" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_closest_point" qualifiers="const">
+ <return type="int">
+ </return>
+ <argument index="0" name="to_pos" type="Vector3">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_closest_pos_in_segment" qualifiers="const">
+ <return type="Vector3">
+ </return>
+ <argument index="0" name="to_pos" type="Vector3">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_id_path">
+ <return type="IntArray">
+ </return>
+ <argument index="0" name="from_id" type="int">
+ </argument>
+ <argument index="1" name="to_id" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_point_path">
+ <return type="Vector3Array">
+ </return>
+ <argument index="0" name="from_id" type="int">
+ </argument>
+ <argument index="1" name="to_id" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_point_pos" qualifiers="const">
+ <return type="Vector3">
+ </return>
+ <argument index="0" name="id" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_point_weight_scale" qualifiers="const">
+ <return type="float">
+ </return>
+ <argument index="0" name="id" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="remove_point">
+ <argument index="0" name="id" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ </methods>
+ <constants>
+ </constants>
+</class>
<class name="AcceptDialog" inherits="WindowDialog" category="Core">
<brief_description>
Base dialog for user notification.
@@ -4024,7 +4138,7 @@
</argument>
<argument index="2" name="area_shape" type="int">
</argument>
- <argument index="3" name="area_shape" type="int">
+ <argument index="3" name="self_shape" type="int">
</argument>
<description>
This signal triggers only once when an area enters this area. The first parameter is the area's [RID]. The second one is the area as an object. The third one is the index of the shape entering this area, and the fourth one is the index of the shape in this area that reported the entering.
@@ -4044,7 +4158,7 @@
</argument>
<argument index="2" name="area_shape" type="int">
</argument>
- <argument index="3" name="area_shape" type="int">
+ <argument index="3" name="self_shape" type="int">
</argument>
<description>
This signal triggers only once when an area exits this area. The first parameter is the area's [RID]. The second one is the area as an object. The third one is the index of the shape entering this area, and the fourth one is the index of the shape in this area that reported the entering.
@@ -4366,7 +4480,7 @@
</argument>
<argument index="2" name="area_shape" type="int">
</argument>
- <argument index="3" name="area_shape" type="int">
+ <argument index="3" name="self_shape" type="int">
</argument>
<description>
This signal triggers only once when an area enters this area. The first parameter is the area's [RID]. The second one is the area as an object. The third one is the index of the shape entering this area, and the fourth one is the index of the shape in this area that reported the entering.
@@ -4386,7 +4500,7 @@
</argument>
<argument index="2" name="area_shape" type="int">
</argument>
- <argument index="3" name="area_shape" type="int">
+ <argument index="3" name="self_shape" type="int">
</argument>
<description>
This signal triggers only once when an area exits this area. The first parameter is the area's [RID]. The second one is the area as an object. The third one is the index of the shape entering this area, and the fourth one is the index of the shape in this area that reported the entering.
@@ -6755,6 +6869,12 @@
<description>
</description>
</method>
+ <method name="get_custom_viewport" qualifiers="const">
+ <return type="Viewport">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_drag_margin" qualifiers="const">
<return type="float">
</return>
@@ -6858,6 +6978,12 @@
<description>
</description>
</method>
+ <method name="set_custom_viewport">
+ <argument index="0" name="viewport" type="Viewport">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_drag_margin">
<argument index="0" name="margin" type="int">
</argument>
@@ -7560,6 +7686,12 @@
Canvas Item layer. [CanvasItem] nodes that are direct or indirect children of a [CanvasLayer] will be drawn in that layer. The layer is a numeric index that defines the draw order. The default 2D scene renders with index 0, so a [CanvasLayer] with index -1 will be drawn below, and one with index 1 will be drawn above. This is very useful for HUDs (in layer 1+ or above), or backgrounds (in layer -1 or below).
</description>
<methods>
+ <method name="get_custom_viewport" qualifiers="const">
+ <return type="Viewport">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_layer" qualifiers="const">
<return type="int">
</return>
@@ -7602,13 +7734,6 @@
Return the base transform for this layer.
</description>
</method>
- <method name="get_viewport" qualifiers="const">
- <return type="RID">
- </return>
- <description>
- Return the viewport RID for this layer.
- </description>
- </method>
<method name="get_world_2d" qualifiers="const">
<return type="World2D">
</return>
@@ -7616,6 +7741,12 @@
Return the [World2D] used by this layer.
</description>
</method>
+ <method name="set_custom_viewport">
+ <argument index="0" name="viewport" type="Viewport">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_layer">
<argument index="0" name="layer" type="int">
</argument>
@@ -8678,6 +8809,28 @@
<constants>
</constants>
</class>
+<class name="ColorFrame" inherits="Control" category="Core">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <methods>
+ <method name="get_frame_color" qualifiers="const">
+ <return type="Color">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="set_frame_color">
+ <argument index="0" name="color" type="Color">
+ </argument>
+ <description>
+ </description>
+ </method>
+ </methods>
+ <constants>
+ </constants>
+</class>
<class name="ColorPicker" inherits="BoxContainer" category="Core">
<brief_description>
Color picker control.
@@ -11697,6 +11850,13 @@
Get the general settings for the editor (the same window that appears in the Settings menu).
</description>
</method>
+ <method name="get_editor_viewport">
+ <return type="Control">
+ </return>
+ <description>
+ Get the main editor control. Use this as a parent for main screens.
+ </description>
+ </method>
<method name="get_name" qualifiers="virtual">
<return type="String">
</return>
@@ -11762,6 +11922,10 @@
Return true if this is a main screen editor plugin (it goes in the main screen selector together with 2D, 3D, Script).
</description>
</method>
+ <method name="hide_bottom_panel">
+ <description>
+ </description>
+ </method>
<method name="inspect_object">
<argument index="0" name="object" type="Object">
</argument>
@@ -11771,6 +11935,12 @@
Inspect an object in the inspector.
</description>
</method>
+ <method name="make_bottom_panel_item_visible">
+ <argument index="0" name="item" type="Control">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="make_visible" qualifiers="virtual">
<argument index="0" name="visible" type="bool">
</argument>
@@ -12069,7 +12239,7 @@
<return type="Array">
</return>
<description>
- Get the list of selected nodes, optimized for transform operations (ie, moving them, rotating, etc). This list avoids situations where a node is selected and also chid/grandchild.
+ Get the list of selected nodes, optimized for transform operations (ie, moving them, rotating, etc). This list avoids situations where a node is selected and also chid/grandchild.
</description>
</method>
<method name="remove_node">
@@ -16480,6 +16650,38 @@
Returns the current value of the joystick axis at given index (see JOY_* constants in [@Global Scope])
</description>
</method>
+ <method name="get_joy_axis_index_from_string">
+ <return type="int">
+ </return>
+ <argument index="0" name="axis" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_joy_axis_string">
+ <return type="String">
+ </return>
+ <argument index="0" name="axis_index" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_joy_button_index_from_string">
+ <return type="int">
+ </return>
+ <argument index="0" name="button" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="get_joy_button_string">
+ <return type="String">
+ </return>
+ <argument index="0" name="button_index" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="get_joy_guid" qualifiers="const">
<return type="String">
</return>
@@ -16640,7 +16842,8 @@
<argument index="3" name="duration" type="float" default="0">
</argument>
<description>
- Starts to vibrate the joystick. Joysticks usually come with two rumble motors, a strong and a weak one. weak_magnitude is the strength of the weak motor (between 0 and 1) and strong_magnitude is the strength of the strong motor (between 0 and 1). duration is the duration of the effect in seconds (a duration of 0 will play the vibration indefinitely).
+ Starts to vibrate the joystick. Joysticks usually come with two rumble motors, a strong and a weak one. weak_magnitude is the strength of the weak motor (between 0 and 1) and strong_magnitude is the strength of the strong motor (between 0 and 1). duration is the duration of the effect in seconds (a duration of 0 will try to play the vibration indefinitely).
+ Note that not every hardware is compatible with long effect durations, it is recommended to restart an effect if in need to play it for more than a few seconds.
</description>
</method>
<method name="stop_joy_vibration">
@@ -40902,6 +41105,16 @@
<description>
</description>
</signal>
+ <signal name="symbol_lookup">
+ <argument index="0" name="symbol" type="String">
+ </argument>
+ <argument index="1" name="row" type="int">
+ </argument>
+ <argument index="2" name="column" type="int">
+ </argument>
+ <description>
+ </description>
+ </signal>
<signal name="text_changed">
<description>
Emitted when the text changes.
@@ -42912,18 +43125,33 @@
</class>
<class name="Tree" inherits="Control" category="Core">
<brief_description>
+ Control to show a tree of items.
</brief_description>
<description>
+ This shows a tree of items that can be selected, expanded and collapsed. The tree can have multiple columns with custom controls like text editing, buttons and popups. It can be useful for structural displaying and interactions.
+ Trees are built via code, using [TreeItem] objects to create the structure. They have a single root but multiple root can be simulated if a dummy hidden root is added.
+ [codeblock]
+ func _ready():
+ var tree = Tree.new()
+ var root = tree.create_item()
+ tree.set_hide_root(true)
+ var child1 = tree.create_item(root)
+ var child2 = tree.create_item(root)
+ var subchild1 = tree.create_item(child1)
+ subchild1.set_text(0, "Subchild1")
+ [/codeblock]
</description>
<methods>
<method name="are_column_titles_visible" qualifiers="const">
<return type="bool">
</return>
<description>
+ Get whether the column titles are being shown.
</description>
</method>
<method name="clear">
<description>
+ Clear the tree. This erases all of the items.
</description>
</method>
<method name="create_item">
@@ -42932,16 +43160,19 @@
<argument index="0" name="parent" type="TreeItem" default="NULL">
</argument>
<description>
+ Create an item in the tree and add it as the last child of [code]parent[/code]. If parent is not given, it will be added as the last child of the root, or it'll the be the root itself if the tree is empty.
</description>
</method>
<method name="ensure_cursor_is_visible">
<description>
+ Make the current selected item visible. This will scroll the tree to make sure the selected item is in sight.
</description>
</method>
<method name="get_allow_rmb_select" qualifiers="const">
<return type="bool">
</return>
<description>
+ Get whether a right click can select items.
</description>
</method>
<method name="get_column_at_pos" qualifiers="const">
@@ -42950,6 +43181,7 @@
<argument index="0" name="pos" type="Vector2">
</argument>
<description>
+ Get the column index under the given point.
</description>
</method>
<method name="get_column_title" qualifiers="const">
@@ -42958,6 +43190,7 @@
<argument index="0" name="column" type="int">
</argument>
<description>
+ Get the title of the given column.
</description>
</method>
<method name="get_column_width" qualifiers="const">
@@ -42966,36 +43199,42 @@
<argument index="0" name="column" type="int">
</argument>
<description>
+ Get the width of the given column in pixels.
</description>
</method>
<method name="get_columns" qualifiers="const">
<return type="int">
</return>
<description>
+ Get the amount of columns.
</description>
</method>
<method name="get_custom_popup_rect" qualifiers="const">
<return type="Rect2">
</return>
<description>
+ Get the rectangle for custom popups. Helper to create custom cell controls that display a popup. See [method TreeItem.set_cell_mode].
</description>
</method>
<method name="get_drop_mode_flags" qualifiers="const">
<return type="int">
</return>
<description>
+ Get the flags of the current drop mode.
</description>
</method>
<method name="get_edited" qualifiers="const">
<return type="TreeItem">
</return>
<description>
+ Get the current edited item. This is only available for custom cell mode.
</description>
</method>
<method name="get_edited_column" qualifiers="const">
<return type="int">
</return>
<description>
+ Get the column of the cell for the current edited icon. This is only available for custom cell mode.
</description>
</method>
<method name="get_item_area_rect" qualifiers="const">
@@ -43006,6 +43245,7 @@
<argument index="1" name="column" type="int" default="-1">
</argument>
<description>
+ Get the rectangle area of the the specified item. If column is specified, only get the position and size of that column, otherwise get the rectangle containing all columns.
</description>
</method>
<method name="get_item_at_pos" qualifiers="const">
@@ -43014,6 +43254,7 @@
<argument index="0" name="pos" type="Vector2">
</argument>
<description>
+ Get the tree item at the specified position (relative to the tree origin position).
</description>
</method>
<method name="get_next_selected">
@@ -43022,42 +43263,49 @@
<argument index="0" name="from" type="TreeItem">
</argument>
<description>
+ Get the next selected item after the given one.
</description>
</method>
<method name="get_pressed_button" qualifiers="const">
<return type="int">
</return>
<description>
+ Get the index of the last pressed button.
</description>
</method>
<method name="get_root">
<return type="TreeItem">
</return>
<description>
+ Get the root item of the tree.
</description>
</method>
<method name="get_scroll" qualifiers="const">
<return type="Vector2">
</return>
<description>
+ Get the current scrolling position.
</description>
</method>
<method name="get_selected" qualifiers="const">
<return type="TreeItem">
</return>
<description>
+ Get the currently selected item.
</description>
</method>
<method name="get_selected_column" qualifiers="const">
<return type="int">
</return>
<description>
+ Get the column number of the current selection.
</description>
</method>
<method name="get_single_select_cell_editing_only_when_already_selected" qualifiers="const">
<return type="bool">
</return>
<description>
+ Get whether the editing of a cell should only happen when it is already selected.
</description>
</method>
<method name="is_delayed_text_editor_enabled" qualifiers="const">
@@ -43070,12 +43318,14 @@
<return type="bool">
</return>
<description>
+ Get whether the folding arrow is hidden.
</description>
</method>
<method name="set_allow_rmb_select">
<argument index="0" name="allow" type="bool">
</argument>
<description>
+ Set whether or not a right mouse button click can select items.
</description>
</method>
<method name="set_column_expand">
@@ -43084,6 +43334,7 @@
<argument index="1" name="expand" type="bool">
</argument>
<description>
+ Set whether a column will have the "Expand" flag of [Control].
</description>
</method>
<method name="set_column_min_width">
@@ -43092,6 +43343,7 @@
<argument index="1" name="min_width" type="int">
</argument>
<description>
+ Set the minimum width of a column.
</description>
</method>
<method name="set_column_title">
@@ -43100,18 +43352,21 @@
<argument index="1" name="title" type="String">
</argument>
<description>
+ Set the title of a column.
</description>
</method>
<method name="set_column_titles_visible">
<argument index="0" name="visible" type="bool">
</argument>
<description>
+ Set whether the column titles visibility.
</description>
</method>
<method name="set_columns">
<argument index="0" name="amount" type="int">
</argument>
<description>
+ Set the amount of columns.
</description>
</method>
<method name="set_delayed_text_editor">
@@ -43124,30 +43379,35 @@
<argument index="0" name="flags" type="int">
</argument>
<description>
+ Set the drop mode as an OR combination of flags. See [code]DROP_MODE_*[/code] constants.
</description>
</method>
<method name="set_hide_folding">
<argument index="0" name="hide" type="bool">
</argument>
<description>
+ Set whether the folding arrow should be hidden.
</description>
</method>
<method name="set_hide_root">
<argument index="0" name="enable" type="bool">
</argument>
<description>
+ Set whether the root of the tree should be hidden.
</description>
</method>
<method name="set_select_mode">
<argument index="0" name="mode" type="int">
</argument>
<description>
+ Set the selection mode. Use one of the [code]SELECT_*[/code] constants.
</description>
</method>
<method name="set_single_select_cell_editing_only_when_already_selected">
<argument index="0" name="enable" type="bool">
</argument>
<description>
+ Set whether the editing of a cell should only happen when it is already selected.
</description>
</method>
</methods>
@@ -43160,32 +43420,38 @@
<argument index="2" name="id" type="int">
</argument>
<description>
+ Emitted when a button on the tree was pressed (see [method TreeItem.add_button]).
</description>
</signal>
<signal name="cell_selected">
<description>
+ Emitted when a cell is selected.
</description>
</signal>
<signal name="custom_popup_edited">
<argument index="0" name="arrow_clicked" type="bool">
</argument>
<description>
+ Emitted when a cell with the [code]CELL_MODE_CUSTOM[/code] is clicked to be edited.
</description>
</signal>
<signal name="empty_tree_rmb_selected">
<argument index="0" name="pos" type="Vector2">
</argument>
<description>
+ Emitted when the right mouse button is pressed if RMB selection is active and the tree is empty.
</description>
</signal>
<signal name="item_activated">
<description>
+ Emitted when an item is activated (double-clicked).
</description>
</signal>
<signal name="item_collapsed">
<argument index="0" name="item" type="Object">
</argument>
<description>
+ Emitted when an item is collapsed by a click on the folding arrow.
</description>
</signal>
<signal name="item_double_clicked">
@@ -43194,16 +43460,19 @@
</signal>
<signal name="item_edited">
<description>
+ Emitted when an item is editted.
</description>
</signal>
<signal name="item_rmb_selected">
<argument index="0" name="pos" type="Vector2">
</argument>
<description>
+ Emitted when an item is selected with right mouse button.
</description>
</signal>
<signal name="item_selected">
<description>
+ Emitted when an item is selected with right mouse button.
</description>
</signal>
<signal name="multi_selected">
@@ -44477,6 +44746,14 @@ do_property].
Returns the angle in radians between the line connecting the two points and the x coordinate.
</description>
</method>
+ <method name="clamped">
+ <return type="Vector2">
+ </return>
+ <argument index="0" name="length" type="float">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="cubic_interpolate">
<return type="Vector2">
</return>
@@ -45230,136 +45507,160 @@ do_property].
</class>
<class name="VideoPlayer" inherits="Control" category="Core">
<brief_description>
+ Control to play video files.
</brief_description>
<description>
+ This control has the ability to play video streams. The only format accepted is the OGV Theora, so any other format must be converted before using in a project.
</description>
<methods>
<method name="get_audio_track" qualifiers="const">
<return type="int">
</return>
<description>
+ Get the selected audio track (for multitrack videos).
</description>
</method>
<method name="get_buffering_msec" qualifiers="const">
<return type="int">
</return>
<description>
+ Get the amount of miliseconds to store in buffer while playing.
</description>
</method>
<method name="get_stream" qualifiers="const">
<return type="VideoStream">
</return>
<description>
+ Get the video stream.
</description>
</method>
<method name="get_stream_name" qualifiers="const">
<return type="String">
</return>
<description>
+ Get the name of the video stream.
</description>
</method>
<method name="get_stream_pos" qualifiers="const">
<return type="float">
</return>
<description>
+ Get the current position of the stream, in seconds.
</description>
</method>
<method name="get_video_texture">
<return type="Texture">
</return>
<description>
+ Get the current frame of the video as a [Texture].
</description>
</method>
<method name="get_volume" qualifiers="const">
<return type="float">
</return>
<description>
+ Get the volume of the audio track as a linear value.
</description>
</method>
<method name="get_volume_db" qualifiers="const">
<return type="float">
</return>
<description>
+ Get the volume of the audio track in decibels.
</description>
</method>
<method name="has_autoplay" qualifiers="const">
<return type="bool">
</return>
<description>
+ Get whether or not the video is set as autoplay.
</description>
</method>
<method name="has_expand" qualifiers="const">
<return type="bool">
</return>
<description>
+ Get whether or not the expand property is set.
</description>
</method>
<method name="is_paused" qualifiers="const">
<return type="bool">
</return>
<description>
+ Get whether or not the video is paused.
</description>
</method>
<method name="is_playing" qualifiers="const">
<return type="bool">
</return>
<description>
+ Get whether or not the video is playing.
</description>
</method>
<method name="play">
<description>
+ Start the video playback.
</description>
</method>
<method name="set_audio_track">
<argument index="0" name="track" type="int">
</argument>
<description>
+ Set the audio track (for multitrack videos).
</description>
</method>
<method name="set_autoplay">
<argument index="0" name="enabled" type="bool">
</argument>
<description>
+ Set whether this node should start playing automatically.
</description>
</method>
<method name="set_buffering_msec">
<argument index="0" name="msec" type="int">
</argument>
<description>
+ Set the amount of miliseconds to buffer during playback.
</description>
</method>
<method name="set_expand">
<argument index="0" name="enable" type="bool">
</argument>
<description>
+ Set the expand property. If enabled, the video will grow or shrink to fit the player size, otherwise it will play at the stream resolution.
</description>
</method>
<method name="set_paused">
<argument index="0" name="paused" type="bool">
</argument>
<description>
+ Set whether the video should pause the playback.
</description>
</method>
<method name="set_stream">
<argument index="0" name="stream" type="VideoStream">
</argument>
<description>
+ Set the video stream for this player.
</description>
</method>
<method name="set_volume">
<argument index="0" name="volume" type="float">
</argument>
<description>
+ Set the audio volume as a linear value.
</description>
</method>
<method name="set_volume_db">
<argument index="0" name="db" type="float">
</argument>
<description>
+ Set the audio volume in decibels.
</description>
</method>
<method name="stop">
<description>
+ Stop the video playback.
</description>
</method>
</methods>
@@ -45539,6 +45840,12 @@ do_property].
Return the 3D world of the viewport.
</description>
</method>
+ <method name="get_world_2d" qualifiers="const">
+ <return type="World2D">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="gui_get_drag_data" qualifiers="const">
<return type="Variant">
</return>
@@ -45762,6 +46069,12 @@ do_property].
Change the 3D world of the viewport.
</description>
</method>
+ <method name="set_world_2d">
+ <argument index="0" name="world_2d" type="World2D">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="unhandled_input">
<argument index="0" name="local_event" type="InputEvent">
</argument>
@@ -46082,12 +46395,24 @@ do_property].
<description>
</description>
<methods>
+ <method name="get_aabb" qualifiers="const">
+ <return type="AABB">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_layer_mask" qualifiers="const">
<return type="int">
</return>
<description>
</description>
</method>
+ <method name="get_transformed_aabb" qualifiers="const">
+ <return type="AABB">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="set_base">
<argument index="0" name="base" type="RID">
</argument>
@@ -49759,14 +50084,17 @@ do_property].
</class>
<class name="XMLParser" inherits="Reference" category="Core">
<brief_description>
+ Low-level class for creating parsers for XML files.
</brief_description>
<description>
+ This class can serve as base to make custom XML parsers. Since XML is a very flexible standard, this interface is low level so it can be applied to any possible schema.
</description>
<methods>
<method name="get_attribute_count" qualifiers="const">
<return type="int">
</return>
<description>
+ Get the amount of attributes in the current element.
</description>
</method>
<method name="get_attribute_name" qualifiers="const">
@@ -49775,6 +50103,7 @@ do_property].
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Get the name of the attribute specified by the index in [code]idx[/code] argument.
</description>
</method>
<method name="get_attribute_value" qualifiers="const">
@@ -49783,12 +50112,14 @@ do_property].
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Get the value of the attribute specified by the index in [code]idx[/code] argument.
</description>
</method>
<method name="get_current_line" qualifiers="const">
<return type="int">
</return>
<description>
+ Get the current line in the parsed file (currently not implemented).
</description>
</method>
<method name="get_named_attribute_value" qualifiers="const">
@@ -49797,6 +50128,7 @@ do_property].
<argument index="0" name="name" type="String">
</argument>
<description>
+ Get the value of a certain attribute of the current element by name. This will raise an error if the element has no such attribute.
</description>
</method>
<method name="get_named_attribute_value_safe" qualifiers="const">
@@ -49805,30 +50137,35 @@ do_property].
<argument index="0" name="name" type="String">
</argument>
<description>
+ Get the value of a certain attribute of the current element by name. This will return an empty [String] if the attribute is not found.
</description>
</method>
<method name="get_node_data" qualifiers="const">
<return type="String">
</return>
<description>
+ Get the contents of a text node. This will raise an error in any other type of node.
</description>
</method>
<method name="get_node_name" qualifiers="const">
<return type="String">
</return>
<description>
+ Get the name of the current element node. This will raise an error if the current node type is not [code]NODE_ELEMENT[/code] nor [code]NODE_ELEMENT_END[/code]
</description>
</method>
<method name="get_node_offset" qualifiers="const">
<return type="int">
</return>
<description>
+ Get the byte offset of the current node since the beginning of the file or buffer.
</description>
</method>
<method name="get_node_type">
<return type="int">
</return>
<description>
+ Get the type of the current node. Compare with [code]NODE_*[/code] constants.
</description>
</method>
<method name="has_attribute" qualifiers="const">
@@ -49837,12 +50174,14 @@ do_property].
<argument index="0" name="name" type="String">
</argument>
<description>
+ Check whether or not the current element has a certain attribute.
</description>
</method>
<method name="is_empty" qualifiers="const">
<return type="bool">
</return>
<description>
+ Check whether the current element is empty (this only works for completely empty tags, e.g. &lt;element \&gt;).
</description>
</method>
<method name="open">
@@ -49851,6 +50190,7 @@ do_property].
<argument index="0" name="file" type="String">
</argument>
<description>
+ Open a XML file for parsing. This returns an error code.
</description>
</method>
<method name="open_buffer">
@@ -49859,12 +50199,14 @@ do_property].
<argument index="0" name="buffer" type="RawArray">
</argument>
<description>
+ Open a XML raw buffer for parsing. This returns an error code.
</description>
</method>
<method name="read">
<return type="int">
</return>
<description>
+ Read the next node of the file. This returns an error code.
</description>
</method>
<method name="seek">
@@ -49873,27 +50215,36 @@ do_property].
<argument index="0" name="pos" type="int">
</argument>
<description>
+ Move the buffer cursor to a certain offset (since the beginning) and read the next node there. This returns an error code.
</description>
</method>
<method name="skip_section">
<description>
+ Skips the current section. If the node contains other elements, they will be ignored and the cursor will go to the closing of the current element.
</description>
</method>
</methods>
<constants>
<constant name="NODE_NONE" value="0">
+ There's no node (no file or buffer opened)
</constant>
<constant name="NODE_ELEMENT" value="1">
+ Element (tag)
</constant>
<constant name="NODE_ELEMENT_END" value="2">
+ End of element
</constant>
<constant name="NODE_TEXT" value="3">
+ Text node
</constant>
<constant name="NODE_COMMENT" value="4">
+ Comment node
</constant>
<constant name="NODE_CDATA" value="5">
+ CDATA content
</constant>
<constant name="NODE_UNKNOWN" value="6">
+ Unknown node
</constant>
</constants>
</class>
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 8350fb0674..aeb3d9e039 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -1998,7 +1998,6 @@ void RasterizerGLES2::mesh_add_surface(RID p_mesh,VS::PrimitiveType p_primitive,
if (use_VBO) {
elem_size=VS::ARRAY_WEIGHTS_SIZE*sizeof(GLushort);
- elem_count=VS::ARRAY_WEIGHTS_SIZE;
valid_local=false;
bind=true;
normalize=true;
@@ -2007,7 +2006,6 @@ void RasterizerGLES2::mesh_add_surface(RID p_mesh,VS::PrimitiveType p_primitive,
} else {
elem_size=VS::ARRAY_WEIGHTS_SIZE*sizeof(GLfloat);
- elem_count=VS::ARRAY_WEIGHTS_SIZE;
valid_local=false;
bind=false;
datatype=GL_FLOAT;
@@ -2019,7 +2017,6 @@ void RasterizerGLES2::mesh_add_surface(RID p_mesh,VS::PrimitiveType p_primitive,
if (use_VBO) {
elem_size=VS::ARRAY_WEIGHTS_SIZE*sizeof(GLubyte);
- elem_count=VS::ARRAY_WEIGHTS_SIZE;
valid_local=false;
bind=true;
datatype=GL_UNSIGNED_BYTE;
@@ -2027,7 +2024,6 @@ void RasterizerGLES2::mesh_add_surface(RID p_mesh,VS::PrimitiveType p_primitive,
} else {
elem_size=VS::ARRAY_WEIGHTS_SIZE*sizeof(GLushort);
- elem_count=VS::ARRAY_WEIGHTS_SIZE;
valid_local=false;
bind=false;
datatype=GL_UNSIGNED_SHORT;
@@ -4666,7 +4662,7 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
enablers.push_back("#define USE_LIGHT_SHADER_CODE\n");
}
if (light_flags.uses_shadow_color) {
- enablers.push_back("#define USE_LIGHT_SHADOW_COLOR\n");
+ enablers.push_back("#define USE_OUTPUT_SHADOW_COLOR\n");
}
if (light_flags.uses_time || fragment_flags.uses_time || vertex_flags.uses_time) {
enablers.push_back("#define USE_TIME\n");
@@ -4709,7 +4705,7 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
enablers.push_back("#define USE_TEXPIXEL_SIZE\n");
}
if (light_flags.uses_shadow_color) {
- enablers.push_back("#define USE_LIGHT_SHADOW_COLOR\n");
+ enablers.push_back("#define USE_OUTPUT_SHADOW_COLOR\n");
}
if (vertex_flags.uses_worldvec) {
@@ -7022,6 +7018,10 @@ void RasterizerGLES2::_process_glow_bloom() {
void RasterizerGLES2::_process_hdr() {
+ if (framebuffer.luminance.empty()) {
+ return;
+ }
+
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.luminance[0].fbo);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, framebuffer.color );
diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp
index 3be0fdab17..d4636ed444 100644
--- a/drivers/gles2/shader_compiler_gles2.cpp
+++ b/drivers/gles2/shader_compiler_gles2.cpp
@@ -904,6 +904,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_VEC"]="light_vec";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_HEIGHT"]="light_height";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_COLOR"]="light";
+ mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_SHADOW"]="light_shadow_color";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_UV"]="light_uv";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT"]="light_out";
mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["SHADOW"]="shadow_color";
diff --git a/drivers/gles2/shaders/canvas.glsl b/drivers/gles2/shaders/canvas.glsl
index 285abd30ff..5f4767940d 100644
--- a/drivers/gles2/shaders/canvas.glsl
+++ b/drivers/gles2/shaders/canvas.glsl
@@ -244,7 +244,7 @@ FRAGMENT_SHADER_CODE
vec2 light_uv = light_uv_interp.xy;
vec4 light = texture2D(light_texture,light_uv) * light_color;
-#if defined(USE_LIGHT_SHADOW_COLOR)
+#if defined(USE_OUTPUT_SHADOW_COLOR)
vec4 shadow_color=vec4(0.0,0.0,0.0,0.0);
#endif
@@ -380,7 +380,7 @@ LIGHT_SHADER_CODE
#endif
-#if defined(USE_LIGHT_SHADOW_COLOR)
+#if defined(USE_OUTPUT_SHADOW_COLOR)
color=mix(shadow_color,color,shadow_attenuation);
#else
//color*=shadow_attenuation;
diff --git a/drivers/gles2/shaders/material.glsl b/drivers/gles2/shaders/material.glsl
index fd778f3442..477a451f2f 100644
--- a/drivers/gles2/shaders/material.glsl
+++ b/drivers/gles2/shaders/material.glsl
@@ -1185,7 +1185,7 @@ FRAGMENT_SHADER_CODE
vec3 mdiffuse = diffuse.rgb;
vec3 light;
-#if defined(USE_LIGHT_SHADOW_COLOR)
+#if defined(USE_OUTPUT_SHADOW_COLOR)
vec3 shadow_color=vec3(0.0,0.0,0.0);
#endif
@@ -1209,7 +1209,7 @@ LIGHT_SHADER_CODE
#endif
diffuse.rgb = const_light_mult * ambient_light *diffuse.rgb + light * attenuation * shadow_attenuation;
-#if defined(USE_LIGHT_SHADOW_COLOR)
+#if defined(USE_OUTPUT_SHADOW_COLOR)
diffuse.rgb += light * shadow_color * attenuation * (1.0 - shadow_attenuation);
#endif
diff --git a/drivers/vorbis/SCsub b/drivers/vorbis/SCsub
index 87805cc2d8..4afafcc4ba 100644
--- a/drivers/vorbis/SCsub
+++ b/drivers/vorbis/SCsub
@@ -5,7 +5,7 @@ sources = [
]
sources_lib = [
- "vorbis/analysis.c",
+ #"vorbis/analysis.c",
#"vorbis/barkmel.c",
"vorbis/bitrate.c",
"vorbis/block.c",
@@ -27,7 +27,7 @@ sources_lib = [
"vorbis/smallft.c",
"vorbis/synthesis.c",
#"vorbis/tone.c",
- "vorbis/vorbisenc.c",
+ #"vorbis/vorbisenc.c",
"vorbis/vorbisfile.c",
"vorbis/window.c",
]
diff --git a/main/input_default.cpp b/main/input_default.cpp
index 089772edc5..92f4a6fb72 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -849,6 +849,13 @@ uint32_t InputDefault::joy_axis(uint32_t p_last_id, int p_device, int p_axis, co
return p_last_id;
}
+ if (ABS(joy.last_axis[p_axis]) > 0.5 && joy.last_axis[p_axis] * p_value.value < 0) {
+ //changed direction quickly, insert fake event to release pending inputmap actions
+ JoyAxis jx;
+ jx.min = p_value.min;
+ jx.value = p_value.value < 0 ? 0.1 : -0.1;
+ p_last_id = joy_axis(p_last_id, p_device, p_axis, jx);
+ }
joy.last_axis[p_axis] = p_value.value;
float val = p_value.min == 0 ? -1.0f + 2.0f * p_value.value : p_value.value;
@@ -1152,3 +1159,61 @@ Array InputDefault::get_connected_joysticks() {
}
return ret;
}
+
+static const char* _buttons[] = {
+ "Face Button Bottom",
+ "Face Button Right",
+ "Face Button Left",
+ "Face Button Top",
+ "L",
+ "R",
+ "L2",
+ "R2",
+ "L3",
+ "R3",
+ "Select",
+ "Start",
+ "DPAD Up",
+ "DPAD Down",
+ "DPAD Left",
+ "DPAD Right"
+};
+
+static const char* _axes[] = {
+ "Left Stick X",
+ "Left Stick Y",
+ "Right Stick X",
+ "Right Stick Y",
+ "",
+ "",
+ "L2",
+ "R2"
+};
+
+String InputDefault::get_joy_button_string(int p_button) {
+ ERR_FAIL_INDEX_V(p_button, JOY_BUTTON_MAX, "");
+ return _buttons[p_button];
+}
+
+int InputDefault::get_joy_button_index_from_string(String p_button) {
+ for (int i = 0; i < JOY_BUTTON_MAX; i++) {
+ if (p_button == _buttons[i]) {
+ return i;
+ }
+ }
+ ERR_FAIL_V(-1);
+}
+
+String InputDefault::get_joy_axis_string(int p_axis) {
+ ERR_FAIL_INDEX_V(p_axis, JOY_AXIS_MAX, "");
+ return _axes[p_axis];
+}
+
+int InputDefault::get_joy_axis_index_from_string(String p_axis) {
+ for (int i = 0; i < JOY_AXIS_MAX; i++) {
+ if (p_axis == _axes[i]) {
+ return i;
+ }
+ }
+ ERR_FAIL_V(-1);
+}
diff --git a/main/input_default.h b/main/input_default.h
index fbf7837b3b..2db6d28abf 100644
--- a/main/input_default.h
+++ b/main/input_default.h
@@ -235,6 +235,11 @@ public:
virtual bool is_joy_known(int p_device);
virtual String get_joy_guid(int p_device) const;
+ virtual String get_joy_button_string(int p_button);
+ virtual String get_joy_axis_string(int p_axis);
+ virtual int get_joy_axis_index_from_string(String p_axis);
+ virtual int get_joy_button_index_from_string(String p_button);
+
bool is_joy_mapped(int p_device);
String get_joy_guid_remapped(int p_device) const;
void set_fallback_mapping(String p_guid);
diff --git a/main/main.cpp b/main/main.cpp
index ec4386ab20..d2ba38b094 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -994,8 +994,11 @@ Error Main::setup2() {
}
}
#ifdef TOOLS_ENABLED
+ ObjectTypeDB::set_current_api(ObjectTypeDB::API_EDITOR);
EditorNode::register_editor_types();
ObjectTypeDB::register_type<PCKPacker>(); // todo: move somewhere else
+ ObjectTypeDB::set_current_api(ObjectTypeDB::API_CORE);
+
#endif
MAIN_PRINT("Main: Load Scripts, Modules, Drivers");
@@ -1022,6 +1025,8 @@ Error Main::setup2() {
_start_success=true;
locale=String();
+ ObjectTypeDB::set_current_api(ObjectTypeDB::API_NONE); //no more api is registered at this point
+
MAIN_PRINT("Main: Done");
return OK;
diff --git a/methods.py b/methods.py
index 8c99794d7a..c28ed55dda 100755
--- a/methods.py
+++ b/methods.py
@@ -1379,6 +1379,7 @@ def use_windows_spawn_fix(self, platform=None):
cmdline = cmd + " " + newargs
rv=0
+ env = {str(key): str(value) for key, value in env.iteritems()}
if len(cmdline) > 32000 and cmd.endswith("ar") :
cmdline = cmd + " " + args[1] + " " + args[2] + " "
for i in range(3,len(args)) :
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index 18a4347edf..4134ed037f 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -359,7 +359,7 @@ Error NetworkedMultiplayerENet::get_packet(const uint8_t **r_buffer,int &r_buffe
incoming_packets.pop_front();
*r_buffer=(const uint8_t*)(&current_packet.packet->data[12]);
- r_buffer_size=current_packet.packet->dataLength;
+ r_buffer_size=current_packet.packet->dataLength-12;
return OK;
}
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp
index ce8b6a6ea4..2e2cbe7b29 100644
--- a/modules/gdscript/gd_compiler.cpp
+++ b/modules/gdscript/gd_compiler.cpp
@@ -662,6 +662,46 @@ int GDCompiler::_parse_expression(CodeGen& codegen,const GDParser::Node *p_expre
return p_stack_level|GDFunction::ADDR_TYPE_STACK<<GDFunction::ADDR_BITS;
} break;
+ // ternary operators
+ case GDParser::OperatorNode::OP_TERNARY_IF: {
+
+ // x IF a ELSE y operator with early out on failure
+
+ int res = _parse_expression(codegen,on->arguments[0],p_stack_level);
+ if (res<0)
+ return res;
+ codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT);
+ codegen.opcodes.push_back(res);
+ int jump_fail_pos=codegen.opcodes.size();
+ codegen.opcodes.push_back(0);
+
+
+ res = _parse_expression(codegen,on->arguments[1],p_stack_level);
+ if (res<0)
+ return res;
+
+ codegen.alloc_stack(p_stack_level); //it will be used..
+ codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN);
+ codegen.opcodes.push_back(p_stack_level|GDFunction::ADDR_TYPE_STACK<<GDFunction::ADDR_BITS);
+ codegen.opcodes.push_back(res);
+ codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ int jump_past_pos=codegen.opcodes.size();
+ codegen.opcodes.push_back(0);
+
+ codegen.opcodes[jump_fail_pos]=codegen.opcodes.size();
+ res = _parse_expression(codegen,on->arguments[2],p_stack_level);
+ if (res<0)
+ return res;
+
+ codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN);
+ codegen.opcodes.push_back(p_stack_level|GDFunction::ADDR_TYPE_STACK<<GDFunction::ADDR_BITS);
+ codegen.opcodes.push_back(res);
+
+ codegen.opcodes[jump_past_pos]=codegen.opcodes.size();
+
+ return p_stack_level|GDFunction::ADDR_TYPE_STACK<<GDFunction::ADDR_BITS;
+
+ } break;
//unary operators
case GDParser::OperatorNode::OP_NEG: { if (!_create_unary_operator(codegen,on,Variant::OP_NEGATE,p_stack_level)) return -1;} break;
case GDParser::OperatorNode::OP_NOT: { if (!_create_unary_operator(codegen,on,Variant::OP_NOT,p_stack_level)) return -1;} break;
@@ -1403,6 +1443,10 @@ Error GDCompiler::_parse_function(GDScript *p_script,const GDParser::ClassNode *
#endif
if (p_func) {
gdfunc->_initial_line=p_func->line;
+#ifdef TOOLS_ENABLED
+
+ p_script->member_lines[func_name]=p_func->line;
+#endif
} else {
gdfunc->_initial_line=0;
}
@@ -1632,6 +1676,12 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
p_script->member_indices[name]=minfo;
p_script->members.insert(name);
+#ifdef TOOLS_ENABLED
+
+ p_script->member_lines[name]=p_class->variables[i].line;
+#endif
+
+
}
for(int i=0;i<p_class->constant_expressions.size();i++) {
@@ -1643,6 +1693,11 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
p_script->constants.insert(name,constant->value);
//p_script->constants[constant->value].make_const();
+#ifdef TOOLS_ENABLED
+
+ p_script->member_lines[name]=p_class->constant_expressions[i].expression->line;
+#endif
+
}
for(int i=0;i<p_class->_signals.size();i++) {
@@ -1691,6 +1746,10 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
if (err)
return err;
+#ifdef TOOLS_ENABLED
+
+ p_script->member_lines[name]=p_class->subclasses[i]->line;
+#endif
p_script->constants.insert(name,subclass); //once parsed, goes to the list of constants
p_script->subclasses.insert(name,subclass);
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index 29dbe82a47..c3e59836a2 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -351,6 +351,7 @@ struct GDCompletionIdentifier {
Ref<GDScript> script;
Variant::Type type;
Variant value; //im case there is a value, also return it
+
};
@@ -935,6 +936,7 @@ static bool _guess_expression_type(GDCompletionContext& context,const GDParser::
return false;
}
+
static bool _guess_identifier_type_in_block(GDCompletionContext& context,int p_line,const StringName& p_identifier,GDCompletionIdentifier &r_type) {
@@ -2522,3 +2524,442 @@ void GDScriptLanguage::auto_indent_code(String& p_code,int p_from_line,int p_to_
}
}
+
+#ifdef TOOLS_ENABLED
+
+Error GDScriptLanguage::lookup_code(const String& p_code, const String& p_symbol,const String& p_base_path, Object*p_owner,LookupResult& r_result) {
+
+
+ //before parsing, try the usual stuff
+ if (ObjectTypeDB::type_exists(p_symbol)) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS;
+ r_result.class_name=p_symbol;
+ return OK;
+ }
+
+ for(int i=0;i<Variant::VARIANT_MAX;i++) {
+ Variant::Type t = Variant::Type(i);
+ if (Variant::get_type_name(t)==p_symbol) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS;
+ r_result.class_name=Variant::get_type_name(t);
+ return OK;
+ }
+ }
+
+ for(int i=0;i<GDFunctions::FUNC_MAX;i++) {
+ if (GDFunctions::get_func_name(GDFunctions::Function(i))==p_symbol) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
+ r_result.class_name="@GDScript";
+ r_result.class_member=p_symbol;
+ return OK;
+ }
+ }
+
+ GDParser p;
+ p.parse(p_code,p_base_path,false,"",true);
+
+ if (p.get_completion_type()==GDParser::COMPLETION_NONE)
+ return ERR_CANT_RESOLVE;
+
+ GDCompletionContext context;
+
+ context._class=p.get_completion_class();
+ context.block=p.get_completion_block();
+ context.function=p.get_completion_function();
+ context.base=p_owner;
+ context.base_path=p_base_path;
+ bool isfunction=false;
+
+ switch(p.get_completion_type()) {
+
+ case GDParser::COMPLETION_NONE: {
+ } break;
+ case GDParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: {
+
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
+ r_result.class_name=Variant::get_type_name(p.get_completion_built_in_constant());
+ r_result.class_member=p_symbol;
+ return OK;
+
+ } break;
+ case GDParser::COMPLETION_FUNCTION: {
+
+
+ if (context._class && context._class->functions.size()) {
+ for(int i=0;i<context._class->functions.size();i++) {
+ if (context._class->functions[i]->name==p_symbol) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.location=context._class->functions[i]->line;
+ return OK;
+ }
+ }
+ }
+
+ Ref<GDScript> parent = _get_parent_class(context);
+ while(parent.is_valid()) {
+ int line = parent->get_member_line(p_symbol);
+ if (line>=0) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.location=line;
+ r_result.script=parent;
+ return OK;
+
+ }
+
+ parent=parent->get_base();
+ }
+
+ GDCompletionIdentifier identifier = _get_native_class(context);
+ print_line("identifier: "+String(identifier.obj_type));
+
+ if (ObjectTypeDB::has_method(identifier.obj_type,p_symbol)) {
+
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
+ r_result.class_name=identifier.obj_type;
+ r_result.class_member=p_symbol;
+ return OK;
+ }
+
+
+ } break;
+ case GDParser::COMPLETION_IDENTIFIER: {
+
+ //check if a function
+ if (p.get_completion_identifier_is_function()) {
+ if (context._class && context._class->functions.size()) {
+ for(int i=0;i<context._class->functions.size();i++) {
+ if (context._class->functions[i]->name==p_symbol) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.location=context._class->functions[i]->line;
+ return OK;
+ }
+ }
+ }
+
+ Ref<GDScript> parent = _get_parent_class(context);
+ while(parent.is_valid()) {
+ int line = parent->get_member_line(p_symbol);
+ if (line>=0) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.location=line;
+ r_result.script=parent;
+ return OK;
+
+ }
+
+ parent=parent->get_base();
+ }
+
+ GDCompletionIdentifier identifier = _get_native_class(context);
+
+
+ if (ObjectTypeDB::has_method(identifier.obj_type,p_symbol)) {
+
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
+ r_result.class_name=identifier.obj_type;
+ r_result.class_member=p_symbol;
+ return OK;
+ }
+ } else {
+
+
+ const GDParser::BlockNode *block=context.block;
+ //search in blocks going up (local var?)
+ while(block) {
+
+
+
+ for (int i=0;i<block->statements.size();i++) {
+
+ if (block->statements[i]->line>p.get_completion_line())
+ continue;
+
+
+ if (block->statements[i]->type==GDParser::BlockNode::TYPE_LOCAL_VAR) {
+
+ const GDParser::LocalVarNode *lv=static_cast<const GDParser::LocalVarNode *>(block->statements[i]);
+
+ if (lv->assign && lv->name==p_symbol) {
+
+ r_result.type=ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.location=block->statements[i]->line;
+ return OK;
+ }
+ }
+ }
+ block=block->parent_block;
+ }
+
+ //guess from function arguments
+ if (context.function && context.function->name!=StringName()) {
+
+ for(int i=0;i<context.function->arguments.size();i++) {
+
+ if (context.function->arguments[i]==p_symbol) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.location=context.function->line;
+ return OK;
+ }
+
+ }
+ }
+
+ //guess in class constants
+
+ for(int i=0;i<context._class->constant_expressions.size();i++) {
+
+ if (context._class->constant_expressions[i].identifier==p_symbol) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.location=context._class->constant_expressions[i].expression->line;
+ return OK;
+ }
+ }
+
+ //guess in class variables
+ if (!(context.function && context.function->_static)) {
+
+ for(int i=0;i<context._class->variables.size();i++) {
+
+ if (context._class->variables[i].identifier==p_symbol) {
+
+ r_result.type=ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.location=context._class->variables[i].line;
+ return OK;
+ }
+ }
+ }
+
+ //guess in autoloads as singletons
+ List<PropertyInfo> props;
+ Globals::get_singleton()->get_property_list(&props);
+
+ for(List<PropertyInfo>::Element *E=props.front();E;E=E->next()) {
+
+ String s = E->get().name;
+ if (!s.begins_with("autoload/"))
+ continue;
+ String name = s.get_slice("/",1);
+ if (name==String(p_symbol)) {
+
+ String path = Globals::get_singleton()->get(s);
+ if (path.begins_with("*")) {
+ String script =path.substr(1,path.length());
+
+ if (!script.ends_with(".gd")) {
+ //not a script, try find the script anyway,
+ //may have some success
+ script=script.basename()+".gd";
+ }
+
+ if (FileAccess::exists(script)) {
+
+ r_result.type=ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.location=0;
+ r_result.script=ResourceLoader::load(script);
+ return OK;
+ }
+ }
+ }
+ }
+
+ //global
+ for(Map<StringName,int>::Element *E=GDScriptLanguage::get_singleton()->get_global_map().front();E;E=E->next()) {
+ if (E->key()==p_symbol) {
+
+ Variant value = GDScriptLanguage::get_singleton()->get_global_array()[E->get()];
+ if (value.get_type()==Variant::OBJECT) {
+ Object *obj = value;
+ if (obj) {
+
+ if (obj->cast_to<GDNativeClass>()) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS;
+ r_result.class_name=obj->cast_to<GDNativeClass>()->get_name();
+
+ } else {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS;
+ r_result.class_name=obj->get_type();
+ }
+ return OK;
+ }
+ } else {
+
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
+ r_result.class_name="@Global Scope";
+ r_result.class_member=p_symbol;
+ return OK;
+ }
+ }
+
+ }
+#if 0
+ GDCompletionIdentifier identifier;
+ if (_guess_identifier_type(context,p.get_completion_line(),p_symbol,identifier)) {
+
+ print_line("var type: "+Variant::get_type_name(identifier.type));
+ if (identifier.script.is_valid()) {
+ print_line("var script: "+identifier.script->get_path());
+ }
+ print_line("obj type: "+String(identifier.obj_type));
+ print_line("value: "+String(identifier.value));
+ }
+#endif
+ }
+
+ } break;
+ case GDParser::COMPLETION_PARENT_FUNCTION: {
+
+ } break;
+ case GDParser::COMPLETION_METHOD:
+ isfunction=true;
+ case GDParser::COMPLETION_INDEX: {
+
+ const GDParser::Node *node = p.get_completion_node();
+ if (node->type!=GDParser::Node::TYPE_OPERATOR)
+ break;
+
+
+
+
+ GDCompletionIdentifier t;
+ if (_guess_expression_type(context,static_cast<const GDParser::OperatorNode *>(node)->arguments[0],p.get_completion_line(),t)) {
+
+ if (t.type==Variant::OBJECT && t.obj_type=="GDNativeClass") {
+ //native enum
+ Ref<GDNativeClass> gdn = t.value;
+ if (gdn.is_valid()) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
+ r_result.class_name=gdn->get_name();;
+ r_result.class_member=p_symbol;
+ return OK;
+
+ }
+ } else if (t.type==Variant::OBJECT && t.obj_type!=StringName()) {
+
+ Ref<GDScript> on_script;
+
+ if (t.value.get_type()) {
+ Object *obj=t.value;
+
+
+ if (obj) {
+
+
+ on_script=obj->get_script();
+
+ if (on_script.is_valid()) {
+ int loc = on_script->get_member_line(p_symbol);
+ if (loc>=0) {
+ r_result.script=on_script;
+ r_result.type=ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.location=loc;
+ return OK;
+ }
+ }
+ }
+ }
+
+ if (ObjectTypeDB::has_method(t.obj_type,p_symbol)) {
+
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
+ r_result.class_name=t.obj_type;
+ r_result.class_member=p_symbol;
+ return OK;
+
+ }
+
+ bool success;
+ ObjectTypeDB::get_integer_constant(t.obj_type,p_symbol,&success);
+ if (success) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
+ r_result.class_name=t.obj_type;
+ r_result.class_member=p_symbol;
+ return OK;
+ }
+
+ ObjectTypeDB::get_property_type(t.obj_type,p_symbol,&success);
+
+ if (success) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_PROPERTY;
+ r_result.class_name=t.obj_type;
+ r_result.class_member=p_symbol;
+ return OK;
+ }
+
+
+ } else {
+
+ Variant::CallError ce;
+ Variant v = Variant::construct(t.type,NULL,0,ce);
+
+ bool valid;
+ v.get_numeric_constant_value(t.type,p_symbol,&valid);
+ if (valid) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
+ r_result.class_name=Variant::get_type_name(t.type);
+ r_result.class_member=p_symbol;
+ return OK;
+ }
+
+ //todo check all inputevent types for property
+
+ v.get(p_symbol,&valid);
+
+ if (valid) {
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_PROPERTY;
+ r_result.class_name=Variant::get_type_name(t.type);
+ r_result.class_member=p_symbol;
+ return OK;
+ }
+
+ if (v.has_method(p_symbol)) {
+
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
+ r_result.class_name=Variant::get_type_name(t.type);
+ r_result.class_member=p_symbol;
+ return OK;
+
+ }
+
+
+ }
+ }
+
+
+ } break;
+ case GDParser::COMPLETION_CALL_ARGUMENTS: {
+
+ return ERR_CANT_RESOLVE;
+ } break;
+ case GDParser::COMPLETION_VIRTUAL_FUNC: {
+
+ GDCompletionIdentifier cid = _get_native_class(context);
+
+ if (cid.obj_type!=StringName()) {
+ List<MethodInfo> vm;
+ ObjectTypeDB::get_virtual_methods(cid.obj_type,&vm);
+ for(List<MethodInfo>::Element *E=vm.front();E;E=E->next()) {
+
+ if (p_symbol==E->get().name) {
+
+ r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
+ r_result.class_name=cid.obj_type;
+ r_result.class_member=p_symbol;
+ return OK;
+
+ }
+ }
+ }
+ } break;
+ case GDParser::COMPLETION_YIELD: {
+
+ return ERR_CANT_RESOLVE;
+
+ } break;
+
+ }
+
+
+ return ERR_CANT_RESOLVE;
+}
+
+#endif
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 4a32bec73a..8f4f5ef4ca 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -203,6 +203,7 @@ bool GDParser::_get_completable_identifier(CompletionType p_type,StringName& ide
completion_line=tokenizer->get_token_line();
completion_block=current_block;
completion_found=true;
+ completion_ident_is_call=false;
tokenizer->advance();
if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER) {
@@ -210,6 +211,9 @@ bool GDParser::_get_completable_identifier(CompletionType p_type,StringName& ide
tokenizer->advance();
}
+ if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_OPEN) {
+ completion_ident_is_call=true;
+ }
return true;
}
@@ -936,6 +940,8 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
case GDTokenizer::TK_OP_BIT_OR: op=OperatorNode::OP_BIT_OR ; break;
case GDTokenizer::TK_OP_BIT_XOR: op=OperatorNode::OP_BIT_XOR ; break;
case GDTokenizer::TK_PR_EXTENDS: op=OperatorNode::OP_EXTENDS; break;
+ case GDTokenizer::TK_CF_IF: op=OperatorNode::OP_TERNARY_IF; break;
+ case GDTokenizer::TK_CF_ELSE: op=OperatorNode::OP_TERNARY_ELSE; break;
default: valid=false; break;
}
@@ -958,6 +964,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
int next_op=-1;
int min_priority=0xFFFFF;
bool is_unary=false;
+ bool is_ternary=false;
for(int i=0;i<expression.size();i++) {
@@ -971,6 +978,8 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
int priority;
bool unary=false;
+ bool ternary=false;
+ bool error=false;
switch(expression[i].op) {
@@ -1001,25 +1010,27 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
case OperatorNode::OP_EQUAL: priority=8; break;
case OperatorNode::OP_NOT_EQUAL: priority=8; break;
+
case OperatorNode::OP_IN: priority=10; break;
-
+
case OperatorNode::OP_NOT: priority=11; unary=true; break;
case OperatorNode::OP_AND: priority=12; break;
case OperatorNode::OP_OR: priority=13; break;
-
- // ?: = 10
-
- case OperatorNode::OP_ASSIGN: priority=14; break;
- case OperatorNode::OP_ASSIGN_ADD: priority=14; break;
- case OperatorNode::OP_ASSIGN_SUB: priority=14; break;
- case OperatorNode::OP_ASSIGN_MUL: priority=14; break;
- case OperatorNode::OP_ASSIGN_DIV: priority=14; break;
- case OperatorNode::OP_ASSIGN_MOD: priority=14; break;
- case OperatorNode::OP_ASSIGN_SHIFT_LEFT: priority=14; break;
- case OperatorNode::OP_ASSIGN_SHIFT_RIGHT: priority=14; break;
- case OperatorNode::OP_ASSIGN_BIT_AND: priority=14; break;
- case OperatorNode::OP_ASSIGN_BIT_OR: priority=14; break;
- case OperatorNode::OP_ASSIGN_BIT_XOR: priority=14; break;
+
+ case OperatorNode::OP_TERNARY_IF: priority=14; ternary=true; break;
+ case OperatorNode::OP_TERNARY_ELSE: priority=14; error=true; break; // Errors out when found without IF (since IF would consume it)
+
+ case OperatorNode::OP_ASSIGN: priority=15; break;
+ case OperatorNode::OP_ASSIGN_ADD: priority=15; break;
+ case OperatorNode::OP_ASSIGN_SUB: priority=15; break;
+ case OperatorNode::OP_ASSIGN_MUL: priority=15; break;
+ case OperatorNode::OP_ASSIGN_DIV: priority=15; break;
+ case OperatorNode::OP_ASSIGN_MOD: priority=15; break;
+ case OperatorNode::OP_ASSIGN_SHIFT_LEFT: priority=15; break;
+ case OperatorNode::OP_ASSIGN_SHIFT_RIGHT: priority=15; break;
+ case OperatorNode::OP_ASSIGN_BIT_AND: priority=15; break;
+ case OperatorNode::OP_ASSIGN_BIT_OR: priority=15; break;
+ case OperatorNode::OP_ASSIGN_BIT_XOR: priority=15; break;
default: {
@@ -1030,11 +1041,16 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
}
if (priority<min_priority) {
+ if(error) {
+ _set_error("Unexpected operator");
+ return NULL;
+ }
// < is used for left to right (default)
// <= is used for right to left
next_op=i;
min_priority=priority;
is_unary=unary;
+ is_ternary=ternary;
}
}
@@ -1075,6 +1091,62 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
}
+ } else if(is_ternary) {
+ if (next_op <1 || next_op>=(expression.size()-1)) {
+ _set_error("Parser bug..");
+ ERR_FAIL_V(NULL);
+ }
+
+ if(next_op>=(expression.size()-2) || expression[next_op+2].op != OperatorNode::OP_TERNARY_ELSE) {
+ _set_error("Expected else after ternary if.");
+ ERR_FAIL_V(NULL);
+ }
+ if(next_op>=(expression.size()-3)) {
+ _set_error("Expected value after ternary else.");
+ ERR_FAIL_V(NULL);
+ }
+
+ OperatorNode *op = alloc_node<OperatorNode>();
+ op->op=expression[next_op].op;
+ op->line=op_line; //line might have been changed from a \n
+
+ if (expression[next_op-1].is_op) {
+
+ _set_error("Parser bug..");
+ ERR_FAIL_V(NULL);
+ }
+
+ if (expression[next_op+1].is_op) {
+ // this is not invalid and can really appear
+ // but it becomes invalid anyway because no binary op
+ // can be followed by an unary op in a valid combination,
+ // due to how precedence works, unaries will always dissapear first
+
+ _set_error("Unexpected two consecutive operators after ternary if.");
+ return NULL;
+ }
+
+ if (expression[next_op+3].is_op) {
+ // this is not invalid and can really appear
+ // but it becomes invalid anyway because no binary op
+ // can be followed by an unary op in a valid combination,
+ // due to how precedence works, unaries will always dissapear first
+
+ _set_error("Unexpected two consecutive operators after ternary else.");
+ return NULL;
+ }
+
+
+ op->arguments.push_back(expression[next_op+1].node); //next expression goes as first
+ op->arguments.push_back(expression[next_op-1].node); //left expression goes as when-true
+ op->arguments.push_back(expression[next_op+3].node); //expression after next goes as when-false
+
+ //replace all 3 nodes by this operator and make it an expression
+ expression[next_op-1].node=op;
+ expression.remove(next_op);
+ expression.remove(next_op);
+ expression.remove(next_op);
+ expression.remove(next_op);
} else {
if (next_op <1 || next_op>=(expression.size()-1)) {
@@ -3484,6 +3556,11 @@ int GDParser::get_completion_argument_index() {
return completion_argument;
}
+int GDParser::get_completion_identifier_is_function() {
+
+ return completion_ident_is_call;
+}
+
GDParser::GDParser() {
head=NULL;
diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gd_parser.h
index 9e6f6e6765..75653e0916 100644
--- a/modules/gdscript/gd_parser.h
+++ b/modules/gdscript/gd_parser.h
@@ -247,6 +247,9 @@ public:
OP_BIT_AND,
OP_BIT_OR,
OP_BIT_XOR,
+ //ternary operators
+ OP_TERNARY_IF,
+ OP_TERNARY_ELSE,
};
Operator op;
@@ -429,6 +432,7 @@ private:
int completion_line;
int completion_argument;
bool completion_found;
+ bool completion_ident_is_call;
PropertyInfo current_export;
@@ -475,7 +479,7 @@ public:
BlockNode *get_completion_block();
FunctionNode *get_completion_function();
int get_completion_argument_index();
-
+ int get_completion_identifier_is_function();
void clear();
GDParser();
diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h
index 0c3e1eb614..051e80634f 100644
--- a/modules/gdscript/gd_script.h
+++ b/modules/gdscript/gd_script.h
@@ -65,6 +65,7 @@ class GDScript : public Script {
StringName setter;
StringName getter;
ScriptInstance::RPCMode rpc_mode;
+
};
friend class GDInstance;
@@ -86,8 +87,11 @@ friend class GDScriptLanguage;
Map<StringName,Ref<GDScript> > subclasses;
Map<StringName,Vector<StringName> > _signals;
+
#ifdef TOOLS_ENABLED
+ Map<StringName,int> member_lines;
+
Map<StringName,Variant> member_default_values;
List<PropertyInfo> members_cache;
@@ -193,6 +197,16 @@ public:
virtual ScriptLanguage *get_language() const;
+ virtual int get_member_line(const StringName& p_member) const {
+#ifdef TOOLS_ENABLED
+ if (member_lines.has(p_member))
+ return member_lines[p_member];
+ else
+#endif
+ return -1;
+
+ }
+
GDScript();
~GDScript();
};
@@ -394,6 +408,9 @@ public:
virtual int find_function(const String& p_function,const String& p_code) const;
virtual String make_function(const String& p_class,const String& p_name,const StringArray& p_args) const;
virtual Error complete_code(const String& p_code, const String& p_base_path, Object*p_owner,List<String>* r_options,String& r_call_hint);
+#ifdef TOOLS_ENABLED
+ virtual Error lookup_code(const String& p_code, const String& p_symbol, const String& p_base_path, Object*p_owner, LookupResult& r_result);
+#endif
virtual void auto_indent_code(String& p_code,int p_from_line,int p_to_line) const;
virtual void add_global_constant(const StringName& p_variable,const Variant& p_value);
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 8f3edfcaa7..4735a91f43 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -913,15 +913,13 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool
}
- ret.resize(ret.size()+stable_extra.size());
- while(ret.size()%4)
- ret.push_back(0);
-
for(int i=0;i<stable_extra.size();i++) {
-
- chars[i]=stable_extra[i];
+ ret.push_back(stable_extra[i]);
}
+ while(ret.size()%4)
+ ret.push_back(0);
+
uint32_t new_stable_end=ret.size();
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 4e395a6f9f..862709fc7d 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -132,15 +132,10 @@ void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_
AudioDriverManagerSW::add_driver(&audio_driver_android);
- if (true) {
- RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,use_reload_hooks,false,use_reload_hooks ) );
- if (gl_extensions)
- rasterizer_gles22->set_extensions(gl_extensions);
- rasterizer = rasterizer_gles22;
- } else {
- //rasterizer = memnew( RasterizerGLES1(use_reload_hooks, use_reload_hooks) );
-
- }
+ RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,use_reload_hooks,false,use_reload_hooks ) );
+ if (gl_extensions)
+ rasterizer_gles22->set_extensions(gl_extensions);
+ rasterizer = rasterizer_gles22;
rasterizer->set_force_16_bits_fbo(use_16bits_fbo);
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index cebafdabce..f38bda5899 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -1312,10 +1312,13 @@ void OS_Windows::finalize_core() {
void OS_Windows::vprint(const char* p_format, va_list p_list, bool p_stderr) {
- char buf[16384+1];
- int len = vsnprintf(buf,16384,p_format,p_list);
+ const unsigned int BUFFER_SIZE = 16384;
+ char buf[BUFFER_SIZE+1]; // +1 for the terminating character
+ int len = vsnprintf(buf,BUFFER_SIZE,p_format,p_list);
if (len<=0)
return;
+ if(len >= BUFFER_SIZE)
+ len = BUFFER_SIZE; // Output is too big, will be truncated
buf[len]=0;
diff --git a/platform/winrt/SCsub b/platform/winrt/SCsub
index ef7a653d53..fde0c11f3b 100644
--- a/platform/winrt/SCsub
+++ b/platform/winrt/SCsub
@@ -13,7 +13,10 @@ files = [
'os_winrt.cpp',
]
-cmd = env.AlwaysBuild(env.ANGLE('libANGLE.lib', None))
+if "build_angle" in env and env["build_angle"]:
+ cmd = env.AlwaysBuild(env.ANGLE('libANGLE.lib', None))
prog = env.Program('#bin/godot', files)
-env.Depends(prog, [cmd])
+
+if "build_angle" in env and env["build_angle"]:
+ env.Depends(prog, [cmd])
diff --git a/platform/winrt/detect.py b/platform/winrt/detect.py
index 6ba4cf5cbc..7f220736d7 100644
--- a/platform/winrt/detect.py
+++ b/platform/winrt/detect.py
@@ -17,11 +17,6 @@ def can_build():
if (os.getenv("VSINSTALLDIR")):
if (os.getenv("ANGLE_SRC_PATH") == None):
- print("You need to define ANGLE_SRC_PATH to the path of ANGLE source root.")
- return False
-
- if not os.path.isfile(str(os.getenv("ANGLE_SRC_PATH")) + "/winrt/10/src/angle.sln"):
- print ("Couldn't find the ANGLE solution. Is ANGLE_SRC_PATH configured to the right path?")
return False
return True
@@ -56,6 +51,9 @@ def configure(env):
jobs = str(env.GetOption("num_jobs"))
angle_build_cmd = "msbuild.exe " + angle_root + "/winrt/10/src/angle.sln /nologo /v:m /m:" + jobs + " /p:Configuration=Release /p:Platform="
+ if os.path.isfile(str(os.getenv("ANGLE_SRC_PATH")) + "/winrt/10/src/angle.sln"):
+ env["build_angle"] = True
+
if os.getenv('Platform') == "ARM":
print "Compiled program architecture will be an ARM executable. (forcing bits=32)."
diff --git a/platform/winrt/joystick_winrt.cpp b/platform/winrt/joystick_winrt.cpp
index 4816e9c831..9f93c5a26b 100644
--- a/platform/winrt/joystick_winrt.cpp
+++ b/platform/winrt/joystick_winrt.cpp
@@ -103,9 +103,10 @@ void JoystickWinrt::OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::I
controllers[idx].connected = true;
controllers[idx].controller_reference = value;
+ controllers[idx].id = idx;
controllers[idx].type = ControllerType::GAMEPAD_CONTROLLER;
- input->joy_connection_changed(idx, true, "Xbox Controller", "__WINRT_GAMEPAD__");
+ input->joy_connection_changed(controllers[idx].id, true, "Xbox Controller", "__WINRT_GAMEPAD__");
}
void JoystickWinrt::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) {
diff --git a/platform/x11/detect.py b/platform/x11/detect.py
index 356de7b2bc..ba232f6d4e 100644
--- a/platform/x11/detect.py
+++ b/platform/x11/detect.py
@@ -155,7 +155,7 @@ def configure(env):
if os.system("pkg-config --exists alsa")==0:
print("Enabling ALSA")
env.Append(CPPFLAGS=["-DALSA_ENABLED"])
- env.Append(LIBS=['asound'])
+ env.ParseConfig('pkg-config alsa --cflags --libs')
else:
print("ALSA libraries not found, disabling driver")
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 9a2d610e78..5f1ab5b4aa 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -1176,6 +1176,19 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
event.key.mod.shift=true;
}
+ //don't set mod state if modifier keys are released by themselves
+ //else event.is_action() will not work correctly here
+ if (!event.key.pressed) {
+ if (event.key.scancode == KEY_SHIFT)
+ event.key.mod.shift = false;
+ else if (event.key.scancode == KEY_CONTROL)
+ event.key.mod.control = false;
+ else if (event.key.scancode == KEY_ALT)
+ event.key.mod.alt = false;
+ else if (event.key.scancode == KEY_META)
+ event.key.mod.meta = false;
+ }
+
//printf("key: %x\n",event.key.scancode);
input->parse_input_event( event);
}
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index 71728966fd..e8954b7e98 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -650,8 +650,8 @@ void Area2D::_bind_methods() {
ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D")));
ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D")));
- ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape")));
+ ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape")));
+ ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape")));
ADD_SIGNAL( MethodInfo("area_enter",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D")));
ADD_SIGNAL( MethodInfo("area_exit",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D")));
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index e576aa10e0..f33faaabd8 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -44,6 +44,9 @@ void Camera2D::_update_scroll() {
}
if (current) {
+
+ ERR_FAIL_COND( custom_viewport && !ObjectDB::get_instance(custom_viewport_id) );
+
Matrix32 xform = get_camera_transform();
if (viewport) {
@@ -73,8 +76,9 @@ Matrix32 Camera2D::get_camera_transform() {
if (!get_tree())
return Matrix32();
- Size2 screen_size = get_viewport_rect().size;
- screen_size=get_viewport_rect().size;
+ ERR_FAIL_COND_V( custom_viewport && !ObjectDB::get_instance(custom_viewport_id), Matrix32() );
+
+ Size2 screen_size = viewport->get_visible_rect().size;
Point2 new_camera_pos = get_global_transform().get_origin();
@@ -240,14 +244,10 @@ void Camera2D::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- viewport = NULL;
- Node *n=this;
- while(n){
-
- viewport = n->cast_to<Viewport>();
- if (viewport)
- break;
- n=n->get_parent();
+ if (custom_viewport && ObjectDB::get_instance(custom_viewport_id)) {
+ viewport=custom_viewport;
+ } else {
+ viewport=get_viewport();
}
canvas = get_canvas();
@@ -270,8 +270,8 @@ void Camera2D::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
- if (is_current()) {
- if (viewport) {
+ if (is_current()) {
+ if (viewport && !(custom_viewport && !ObjectDB::get_instance(custom_viewport_id))) {
viewport->set_canvas_transform( Matrix32() );
}
}
@@ -447,8 +447,10 @@ void Camera2D::reset_smoothing() {
void Camera2D::align() {
- Size2 screen_size = get_viewport_rect().size;
- screen_size=get_viewport_rect().size;
+ ERR_FAIL_COND( custom_viewport && !ObjectDB::get_instance(custom_viewport_id) );
+
+ Size2 screen_size = viewport->get_visible_rect().size;
+
Point2 current_camera_pos = get_global_transform().get_origin();
if (anchor_mode==ANCHOR_MODE_DRAG_CENTER) {
if (h_ofs<0) {
@@ -549,6 +551,42 @@ bool Camera2D::is_follow_smoothing_enabled() const {
return smoothing_enabled;
}
+void Camera2D::set_custom_viewport(Node *p_viewport) {
+ ERR_FAIL_NULL(p_viewport);
+ if (is_inside_tree()) {
+ remove_from_group(group_name);
+ remove_from_group(canvas_group_name);
+ }
+
+ custom_viewport=p_viewport->cast_to<Viewport>();
+
+ if (custom_viewport) {
+ custom_viewport_id=custom_viewport->get_instance_ID();
+ } else {
+ custom_viewport_id=0;
+ }
+
+ if (is_inside_tree()) {
+
+ if (custom_viewport)
+ viewport=custom_viewport;
+ else
+ viewport=get_viewport();
+
+ RID vp = viewport->get_viewport();
+ group_name = "__cameras_"+itos(vp.get_id());
+ canvas_group_name ="__cameras_c"+itos(canvas.get_id());
+ add_to_group(group_name);
+ add_to_group(canvas_group_name);
+ }
+
+}
+
+Node* Camera2D::get_custom_viewport() const {
+
+ return custom_viewport;
+}
+
void Camera2D::_bind_methods() {
@@ -597,6 +635,8 @@ void Camera2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_zoom","zoom"),&Camera2D::set_zoom);
ObjectTypeDB::bind_method(_MD("get_zoom"),&Camera2D::get_zoom);
+ ObjectTypeDB::bind_method(_MD("set_custom_viewport","viewport:Viewport"),&Camera2D::set_custom_viewport);
+ ObjectTypeDB::bind_method(_MD("get_custom_viewport:Viewport"),&Camera2D::get_custom_viewport);
ObjectTypeDB::bind_method(_MD("set_follow_smoothing","follow_smoothing"),&Camera2D::set_follow_smoothing);
ObjectTypeDB::bind_method(_MD("get_follow_smoothing"),&Camera2D::get_follow_smoothing);
@@ -662,6 +702,8 @@ Camera2D::Camera2D() {
first=true;
smoothing_enabled=false;
limit_smoothing_enabled=false;
+ custom_viewport=NULL;
+ custom_viewport_id=0;
smoothing=5.0;
zoom = Vector2(1, 1);
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h
index 9f3e4254bb..a4d6dc5b96 100644
--- a/scene/2d/camera_2d.h
+++ b/scene/2d/camera_2d.h
@@ -48,6 +48,8 @@ protected:
Point2 smoothed_camera_pos;
bool first;
+ ObjectID custom_viewport_id; // to check validity
+ Viewport *custom_viewport;
Viewport *viewport;
StringName group_name;
@@ -128,6 +130,9 @@ public:
Point2 get_camera_screen_center() const;
+ void set_custom_viewport(Node *p_viewport);
+ Node* get_custom_viewport() const;
+
Vector2 get_camera_pos() const;
void force_update_scroll();
void reset_smoothing();
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index df43e8e373..b3f925cb14 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -253,7 +253,7 @@ void Node2D::global_translate(const Vector2& p_amount) {
set_global_pos( get_global_pos() + p_amount );
}
-void Node2D::scale(const Vector2& p_amount) {
+void Node2D::scale(const Size2& p_amount) {
set_scale( get_scale() * p_amount );
}
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index aa8d0ef33c..b31ee08af6 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -79,7 +79,7 @@ public:
void move_y(float p_delta,bool p_scaled=false);
void translate(const Vector2& p_amount);
void global_translate(const Vector2& p_amount);
- void scale(const Vector2& p_amount);
+ void scale(const Size2& p_amount);
Point2 get_pos() const;
float get_rot() const;
@@ -110,8 +110,6 @@ public:
Matrix32 get_relative_transform_to_parent(const Node *p_parent) const;
-
-
Matrix32 get_transform() const;
Node2D();
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index cfb87fb998..12893524d1 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -288,12 +288,12 @@ float Polygon2D::_get_texture_rotationd() const{
}
-void Polygon2D::set_texture_scale(const Vector2& p_scale){
+void Polygon2D::set_texture_scale(const Size2& p_scale){
tex_scale=p_scale;
update();
}
-Vector2 Polygon2D::get_texture_scale() const{
+Size2 Polygon2D::get_texture_scale() const{
return tex_scale;
}
diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h
index 04e8aeb6fd..cecb9081f7 100644
--- a/scene/2d/polygon_2d.h
+++ b/scene/2d/polygon_2d.h
@@ -40,7 +40,7 @@ class Polygon2D : public Node2D {
DVector<Color> vertex_colors;
Color color;
Ref<Texture> texture;
- Vector2 tex_scale;
+ Size2 tex_scale;
Vector2 tex_ofs;
bool tex_tile;
float tex_rot;
@@ -81,8 +81,8 @@ public:
void set_texture_rotation(float p_rot);
float get_texture_rotation() const;
- void set_texture_scale(const Vector2& p_scale);
- Vector2 get_texture_scale() const;
+ void set_texture_scale(const Size2& p_scale);
+ Size2 get_texture_scale() const;
void set_invert(bool p_rot);
bool get_invert() const;
diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp
index a8a4122016..c1d0d1a97c 100644
--- a/scene/3d/area.cpp
+++ b/scene/3d/area.cpp
@@ -640,8 +640,8 @@ void Area::_bind_methods() {
ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body")));
ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body")));
- ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape")));
+ ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape")));
+ ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape")));
ADD_SIGNAL( MethodInfo("area_enter",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area")));
ADD_SIGNAL( MethodInfo("area_exit",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area")));
diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp
index c9319904bd..99c7fd047f 100644
--- a/scene/3d/immediate_geometry.cpp
+++ b/scene/3d/immediate_geometry.cpp
@@ -72,6 +72,7 @@ void ImmediateGeometry::add_vertex(const Vector3& p_vertex){
if (empty) {
aabb.pos=p_vertex;
aabb.size=Vector3();
+ empty=false;
} else {
aabb.expand_to(p_vertex);
}
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index b15226cce3..b4f7a4e5b4 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -128,6 +128,8 @@ void VisualInstance::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"), &VisualInstance::set_layer_mask);
ObjectTypeDB::bind_method(_MD("get_layer_mask"), &VisualInstance::get_layer_mask);
+ ObjectTypeDB::bind_method(_MD("get_transformed_aabb"), &VisualInstance::get_transformed_aabb);
+
ADD_PROPERTY( PropertyInfo( Variant::INT, "layers",PROPERTY_HINT_ALL_FLAGS), _SCS("set_layer_mask"), _SCS("get_layer_mask"));
@@ -376,6 +378,8 @@ void GeometryInstance::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_extra_cull_margin","margin"), &GeometryInstance::set_extra_cull_margin);
ObjectTypeDB::bind_method(_MD("get_extra_cull_margin"), &GeometryInstance::get_extra_cull_margin);
+ ObjectTypeDB::bind_method(_MD("get_aabb"),&GeometryInstance::get_aabb);
+
ObjectTypeDB::bind_method(_MD("_baked_light_changed"), &GeometryInstance::_baked_light_changed);
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/visible"), _SCS("set_flag"), _SCS("get_flag"),FLAG_VISIBLE);
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 90a8af9238..f7d74b2b49 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -639,6 +639,7 @@ void LineEdit::_notification(int p_what) {
if(text.empty())
font_color.a *= placeholder_alpha;
+ int caret_height = font->get_height() > y_area ? y_area : font->get_height();
while(true) {
//end of string, break!
@@ -657,14 +658,14 @@ void LineEdit::_notification(int p_what) {
bool selected=selection.enabled && char_ofs>=selection.begin && char_ofs<selection.end;
if (selected)
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(char_width, y_area)), selection_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(char_width, caret_height)), selection_color);
font->draw_char(ci, Point2(x_ofs, y_ofs + font_ascent), cchar, next, selected ? font_color_selected : font_color);
if (char_ofs==cursor_pos && draw_caret) {
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(
- Point2( x_ofs , y_ofs ), Size2( 1, y_area ) ), cursor_color );
+ Point2( x_ofs , y_ofs ), Size2( 1, caret_height ) ), cursor_color );
}
x_ofs+=char_width;
@@ -673,7 +674,7 @@ void LineEdit::_notification(int p_what) {
if (char_ofs==cursor_pos && draw_caret) {//may be at the end
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(
- Point2( x_ofs , y_ofs ), Size2( 1, y_area ) ), cursor_color );
+ Point2( x_ofs , y_ofs ), Size2( 1, caret_height ) ), cursor_color );
}
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -1191,24 +1192,28 @@ void LineEdit::menu_option(int p_option) {
switch(p_option) {
case MENU_CUT: {
- cut_text();
+ if (editable) {
+ cut_text();
+ }
} break;
case MENU_COPY: {
copy_text();
} break;
case MENU_PASTE: {
-
- paste_text();
+ if (editable) {
+ paste_text();
+ }
} break;
case MENU_CLEAR: {
- clear();
+ if (editable) {
+ clear();
+ }
} break;
case MENU_SELECT_ALL: {
select_all();
} break;
case MENU_UNDO: {
-
undo();
} break;
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 0fa2856ca4..479bb96fe2 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -228,14 +228,14 @@ void ScrollContainer::_notification(int p_what) {
child_max_size.y = MAX(child_max_size.y, minsize.y);
Rect2 r = Rect2(-scroll,minsize);
- if (!h_scroll->is_visible()) {
+ if (!(scroll_h || h_scroll->is_visible())) {
r.pos.x=0;
if (c->get_h_size_flags()&SIZE_EXPAND)
r.size.width=MAX(size.width,minsize.width);
else
r.size.width=minsize.width;
}
- if (!v_scroll->is_visible()) {
+ if (!(scroll_v || v_scroll->is_visible())) {
r.pos.y=0;
r.size.height=size.height;
if (c->get_v_size_flags()&SIZE_EXPAND)
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 87df8c076e..8a9ed98a5f 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -700,6 +700,7 @@ void TextEdit::_notification(int p_what) {
bool prev_is_char=false;
bool prev_is_number = false;
bool in_keyword=false;
+ bool underlined=false;
bool in_word = false;
bool in_function_name = false;
bool in_member_variable = false;
@@ -825,8 +826,10 @@ void TextEdit::_notification(int p_what) {
}
}
- if (!is_char)
+ if (!is_char) {
in_keyword=false;
+ underlined=false;
+ }
if (in_region==-1 && !in_keyword && is_char && !prev_is_char) {
@@ -844,6 +847,12 @@ void TextEdit::_notification(int p_what) {
in_keyword=true;
keyword_color=*col;
}
+
+ if (select_identifiers_enabled && hilighted_word!=String()) {
+ if (hilighted_word==range) {
+ underlined=true;
+ }
+ }
}
if (!in_function_name && in_word && !in_keyword) {
@@ -1024,8 +1033,12 @@ void TextEdit::_notification(int p_what) {
color = cache.caret_background_color;
}
- if (str[j]>=32)
- cache.font->draw_char(ci,Point2i( char_ofs+char_margin, ofs_y+ascent),str[j],str[j+1],in_selection?cache.font_selected_color:color);
+ if (str[j]>=32) {
+ int w = cache.font->draw_char(ci,Point2i( char_ofs+char_margin, ofs_y+ascent),str[j],str[j+1],in_selection?cache.font_selected_color:color);
+ if (underlined) {
+ draw_rect(Rect2( char_ofs+char_margin, ofs_y+ascent+2,w,1),in_selection?cache.font_selected_color:color);
+ }
+ }
else if (draw_tabs && str[j]=='\t') {
int yofs= (get_row_height() - cache.tab_icon->get_height())/2;
@@ -1501,11 +1514,19 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
}
if (mb.button_index==BUTTON_LEFT) {
+
_reset_caret_blink_timer();
int row,col;
_get_mouse_pos(Point2i(mb.x,mb.y), row,col);
+ if (mb.mod.command && hilighted_word!=String()) {
+
+ emit_signal("symbol_lookup",hilighted_word,row,col);
+ return;
+ }
+
+
// toggle breakpoint on gutter click
if (draw_breakpoint_gutter) {
int gutter=cache.style_normal->get_margin(MARGIN_LEFT);
@@ -1652,6 +1673,22 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
const InputEventMouseMotion &mm=p_input_event.mouse_motion;
+ if (select_identifiers_enabled) {
+ if (mm.mod.command && mm.button_mask==0) {
+
+ String new_word = get_word_at_pos(Vector2(mm.x,mm.y));
+ if (new_word!=hilighted_word) {
+ hilighted_word=new_word;
+ update();
+ }
+ } else {
+ if (hilighted_word!=String()) {
+ hilighted_word=String();
+ update();
+ }
+ }
+ }
+
if (mm.button_mask&BUTTON_MASK_LEFT && get_viewport()->gui_get_drag_data()==Variant()) { //ignore if dragging
if (selection.selecting_mode!=Selection::MODE_NONE) {
@@ -1679,6 +1716,27 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
InputEventKey k=p_input_event.key;
+
+#ifdef OSX_ENABLED
+ if (k.scancode==KEY_META) {
+#else
+ if (k.scancode==KEY_CONTROL) {
+
+#endif
+ if (select_identifiers_enabled) {
+
+ if (k.pressed) {
+
+ hilighted_word = get_word_at_pos(get_local_mouse_pos());
+ update();
+
+ } else {
+ hilighted_word=String();
+ update();
+ }
+ }
+ }
+
if (!k.pressed)
return;
@@ -1846,6 +1904,8 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (!k.mod.command) {
_reset_caret_blink_timer();
}
+
+
// save here for insert mode, just in case it is cleared in the following section
bool had_selection = selection.active;
@@ -2482,7 +2542,9 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
} break;
case KEY_X: {
-
+ if (readonly) {
+ break;
+ }
if (!k.mod.command || k.mod.shift || k.mod.alt) {
scancode_handled=false;
break;
@@ -2514,7 +2576,9 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
undo();
} break;
case KEY_V: {
-
+ if (readonly) {
+ break;
+ }
if (!k.mod.command || k.mod.shift || k.mod.alt) {
scancode_handled=false;
break;
@@ -2559,7 +2623,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
}
update();
}
- break;}
+ } break;
default: {
@@ -3223,6 +3287,9 @@ void TextEdit::insert_text_at_cursor(const String& p_text) {
}
Control::CursorShape TextEdit::get_cursor_shape(const Point2& p_pos) const {
+ if (hilighted_word!=String())
+ return CURSOR_POINTING_HAND;
+
int gutter=cache.style_normal->get_margin(MARGIN_LEFT)+cache.line_number_w+cache.breakpoint_gutter_width;
if((completion_active && completion_rect.has_point(p_pos)) || p_pos.x < gutter) {
return CURSOR_ARROW;
@@ -3265,6 +3332,36 @@ String TextEdit::get_text() {
};
+
+String TextEdit::get_text_for_lookup_completion() {
+
+
+ int row,col;
+ _get_mouse_pos(get_local_mouse_pos(), row,col);
+
+
+ String longthing;
+ int len = text.size();
+ for (int i=0;i<len;i++) {
+
+ if (i==row) {
+ longthing+=text[i].substr(0,col);
+ longthing+=String::chr(0xFFFF); //not unicode, represents the cursor
+ longthing+=text[i].substr(col,text[i].size());
+ } else {
+
+ longthing+=text[i];
+ }
+
+
+ if (i!=len-1)
+ longthing+="\n";
+ }
+
+ return longthing;
+
+}
+
String TextEdit::get_text_for_completion() {
String longthing;
@@ -4302,6 +4399,38 @@ void TextEdit::code_complete(const Vector<String> &p_strings) {
}
+String TextEdit::get_word_at_pos(const Vector2& p_pos) const {
+
+ int row,col;
+ _get_mouse_pos(p_pos, row, col);
+
+ String s = text[row];
+ if (s.length()==0)
+ return "";
+ int beg=CLAMP(col,0,s.length());
+ int end=beg;
+
+
+ if (s[beg]>32 || beg==s.length()) {
+
+ bool symbol = beg < s.length() && _is_symbol(s[beg]); //not sure if right but most editors behave like this
+
+ while(beg>0 && s[beg-1]>32 && (symbol==_is_symbol(s[beg-1]))) {
+ beg--;
+ }
+ while(end<s.length() && s[end+1]>32 && (symbol==_is_symbol(s[end+1]))) {
+ end++;
+ }
+
+ if (end<s.length())
+ end+=1;
+
+ return s.substr(beg,end-beg);
+ }
+
+ return String();
+}
+
String TextEdit::get_tooltip(const Point2& p_pos) const {
if (!tooltip_obj)
@@ -4402,18 +4531,22 @@ void TextEdit::menu_option(int p_option) {
switch( p_option ) {
case MENU_CUT: {
-
- cut();
+ if (!readonly) {
+ cut();
+ }
} break;
case MENU_COPY: {
copy();
} break;
case MENU_PASTE: {
-
- paste();
+ if (!readonly) {
+ paste();
+ }
} break;
case MENU_CLEAR: {
- clear();
+ if (!readonly) {
+ clear();
+ }
} break;
case MENU_SELECT_ALL: {
select_all();
@@ -4425,6 +4558,18 @@ void TextEdit::menu_option(int p_option) {
};
}
+
+void TextEdit::set_select_identifiers_on_hover(bool p_enable) {
+
+ select_identifiers_enabled=p_enable;
+}
+
+bool TextEdit::is_selecting_identifiers_on_hover_enabled() const {
+
+ return select_identifiers_enabled;
+}
+
+
PopupMenu *TextEdit::get_menu() const {
return menu;
}
@@ -4521,6 +4666,7 @@ void TextEdit::_bind_methods() {
ADD_SIGNAL(MethodInfo("text_changed"));
ADD_SIGNAL(MethodInfo("request_completion"));
ADD_SIGNAL(MethodInfo("breakpoint_toggled", PropertyInfo( Variant::INT, "row")));
+ ADD_SIGNAL(MethodInfo("symbol_lookup", PropertyInfo(Variant::STRING,"symbol"),PropertyInfo( Variant::INT, "row"),PropertyInfo( Variant::INT, "column")));
BIND_CONSTANT( MENU_CUT );
BIND_CONSTANT( MENU_COPY );
@@ -4641,6 +4787,7 @@ TextEdit::TextEdit() {
auto_indent=false;
insert_mode = false;
window_has_focus=true;
+ select_identifiers_enabled=false;
menu = memnew( PopupMenu );
add_child(menu);
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index f0301fc250..cb49618f18 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -242,6 +242,9 @@ class TextEdit : public Control {
bool auto_indent;
bool cut_copy_line;
bool insert_mode;
+ bool select_identifiers_enabled;
+
+ String hilighted_word;
uint64_t last_dblclk;
@@ -444,6 +447,7 @@ public:
String get_selection_text() const;
String get_word_under_cursor() const;
+ String get_word_at_pos(const Vector2& p_pos) const;
bool search(const String &p_key,uint32_t p_search_flags, int p_from_line, int p_from_column,int &r_line,int &r_column) const;
@@ -492,9 +496,13 @@ public:
void set_code_hint(const String& p_hint);
void query_code_comple();
+ void set_select_identifiers_on_hover(bool p_enable);
+ bool is_selecting_identifiers_on_hover_enabled() const;
+
PopupMenu *get_menu() const;
String get_text_for_completion();
+ String get_text_for_lookup_completion();
virtual bool is_text_field() const;
TextEdit();
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index c31a57f819..8e238c7d77 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -168,20 +168,13 @@ void CanvasLayer::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- Node *n = this;
- vp=NULL;
+ if (custom_viewport && ObjectDB::get_instance(custom_viewport_id)) {
- while(n) {
+ vp=custom_viewport;
+ } else {
+ vp=Node::get_viewport();
- if (n->cast_to<Viewport>()) {
-
- vp = n->cast_to<Viewport>();
- break;
- }
- n=n->get_parent();
}
-
-
ERR_FAIL_COND(!vp);
viewport=vp->get_viewport();
@@ -205,6 +198,7 @@ Size2 CanvasLayer::get_viewport_size() const {
if (!is_inside_tree())
return Size2(1,1);
+
Rect2 r = vp->get_visible_rect();
return r.size;
}
@@ -215,6 +209,43 @@ RID CanvasLayer::get_viewport() const {
return viewport;
}
+void CanvasLayer::set_custom_viewport(Node *p_viewport) {
+ ERR_FAIL_NULL(p_viewport);
+ if (is_inside_tree()) {
+ VisualServer::get_singleton()->viewport_remove_canvas(viewport,canvas->get_canvas());
+ viewport=RID();
+ }
+
+ custom_viewport=p_viewport->cast_to<Viewport>();
+
+ if (custom_viewport) {
+ custom_viewport_id=custom_viewport->get_instance_ID();
+ } else {
+ custom_viewport_id=0;
+ }
+
+ if (is_inside_tree()) {
+
+
+ if (custom_viewport)
+ vp=custom_viewport;
+ else
+ vp=Node::get_viewport();
+
+ viewport = vp->get_viewport();
+
+ VisualServer::get_singleton()->viewport_attach_canvas(viewport,canvas->get_canvas());
+ VisualServer::get_singleton()->viewport_set_canvas_layer(viewport,canvas->get_canvas(),layer);
+ VisualServer::get_singleton()->viewport_set_canvas_transform(viewport,canvas->get_canvas(),transform);
+ }
+
+}
+
+Node* CanvasLayer::get_custom_viewport() const {
+
+ return custom_viewport;
+}
+
void CanvasLayer::_bind_methods() {
@@ -241,8 +272,11 @@ void CanvasLayer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_scale","scale"),&CanvasLayer::set_scale);
ObjectTypeDB::bind_method(_MD("get_scale"),&CanvasLayer::get_scale);
+ ObjectTypeDB::bind_method(_MD("set_custom_viewport","viewport:Viewport"),&CanvasLayer::set_custom_viewport);
+ ObjectTypeDB::bind_method(_MD("get_custom_viewport:Viewport"),&CanvasLayer::get_custom_viewport);
+
ObjectTypeDB::bind_method(_MD("get_world_2d:World2D"),&CanvasLayer::get_world_2d);
- ObjectTypeDB::bind_method(_MD("get_viewport"),&CanvasLayer::get_viewport);
+// ObjectTypeDB::bind_method(_MD("get_viewport"),&CanvasLayer::get_viewport);
ADD_PROPERTY( PropertyInfo(Variant::INT,"layer",PROPERTY_HINT_RANGE,"-128,128,1"),_SCS("set_layer"),_SCS("get_layer") );
//ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"transform",PROPERTY_HINT_RANGE),_SCS("set_transform"),_SCS("get_transform") );
@@ -260,4 +294,6 @@ CanvasLayer::CanvasLayer() {
locrotscale_dirty=false;
layer=1;
canvas = Ref<World2D>( memnew(World2D) );
+ custom_viewport=NULL;
+ custom_viewport_id=0;
}
diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h
index a3e8211a43..a1311390be 100644
--- a/scene/main/canvas_layer.h
+++ b/scene/main/canvas_layer.h
@@ -40,11 +40,15 @@ class CanvasLayer : public Node {
bool locrotscale_dirty;
Vector2 ofs;
- Vector2 scale;
+ Size2 scale;
real_t rot;
int layer;
Matrix32 transform;
Ref<World2D> canvas;
+
+ ObjectID custom_viewport_id; // to check validity
+ Viewport *custom_viewport;
+
RID viewport;
Viewport *vp;
@@ -55,6 +59,7 @@ class CanvasLayer : public Node {
void _update_xform();
void _update_locrotscale();
+
protected:
void _notification(int p_what);
@@ -76,8 +81,8 @@ public:
void set_rotationd(real_t p_degrees);
real_t get_rotationd() const;
- void set_scale(const Vector2& p_scale);
- Vector2 get_scale() const;
+ void set_scale(const Size2& p_scale);
+ Size2 get_scale() const;
Ref<World2D> get_world_2d() const;
@@ -85,6 +90,9 @@ public:
RID get_viewport() const;
+ void set_custom_viewport(Node *p_viewport);
+ Node* get_custom_viewport() const;
+
CanvasLayer();
};
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 347d72aecd..b22d1fcdf4 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -359,13 +359,7 @@ void Viewport::_notification(int p_what) {
_update_listener_2d();
_update_rect();
- if (world_2d.is_valid()) {
- find_world_2d()->_register_viewport(this,Rect2());
-//best to defer this and not do it here, as it can annoy a lot of setup logic if user
-//adds a node and then moves it, will get enter/exit screen/viewport notifications
-//unnecesarily
-// update_worlds();
- }
+ find_world_2d()->_register_viewport(this,Rect2());
add_to_group("_viewports");
if (get_tree()->is_debugging_collisions_hint()) {
@@ -1001,19 +995,34 @@ bool Viewport::has_transparent_background() const {
return transparent_bg;
}
-#if 0
void Viewport::set_world_2d(const Ref<World2D>& p_world_2d) {
+ if (world_2d==p_world_2d)
+ return;
+
+ if (parent && parent->find_world_2d()==p_world_2d) {
+ WARN_PRINT("Unable to use parent world as world_2d");
+ return;
+ }
+
+ if (is_inside_tree()) {
+ find_world_2d()->_remove_viewport(this);
+ VisualServer::get_singleton()->viewport_remove_canvas(viewport,current_canvas);
+ }
+
+ if (p_world_2d.is_valid())
+ world_2d=p_world_2d;
+ else {
+ WARN_PRINT("Invalid world");
+ world_2d=Ref<World2D>( memnew( World2D ));
+ }
- world_2d=p_world_2d;
_update_listener_2d();
- if (is_inside_scene()) {
- if (current_canvas.is_valid())
- VisualServer::get_singleton()->viewport_remove_canvas(viewport,current_canvas);
+ if (is_inside_tree()) {
current_canvas=find_world_2d()->get_canvas();
VisualServer::get_singleton()->viewport_attach_canvas(viewport,current_canvas);
+ find_world_2d()->_register_viewport(this,Rect2());
}
-
}
Ref<World2D> Viewport::find_world_2d() const{
@@ -1025,13 +1034,6 @@ Ref<World2D> Viewport::find_world_2d() const{
else
return Ref<World2D>();
}
-#endif
-
-Ref<World2D> Viewport::find_world_2d() const{
-
- return world_2d;
-}
-
void Viewport::_propagate_enter_world(Node *p_node) {
@@ -1141,6 +1143,11 @@ Ref<World> Viewport::get_world() const{
return world;
}
+Ref<World2D> Viewport::get_world_2d() const{
+
+ return world_2d;
+}
+
Ref<World> Viewport::find_world() const{
if (own_world.is_valid())
@@ -1303,6 +1310,9 @@ void Viewport::render_target_clear() {
void Viewport::set_render_target_filter(bool p_enable) {
+ if(!render_target)
+ return;
+
render_target_texture->set_flags(p_enable?int(Texture::FLAG_FILTER):int(0));
}
@@ -2587,8 +2597,8 @@ void Viewport::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_rect","rect"), &Viewport::set_rect);
ObjectTypeDB::bind_method(_MD("get_rect"), &Viewport::get_rect);
- //ObjectTypeDB::bind_method(_MD("set_world_2d","world_2d:World2D"), &Viewport::set_world_2d);
- //ObjectTypeDB::bind_method(_MD("get_world_2d:World2D"), &Viewport::get_world_2d);
+ ObjectTypeDB::bind_method(_MD("set_world_2d","world_2d:World2D"), &Viewport::set_world_2d);
+ ObjectTypeDB::bind_method(_MD("get_world_2d:World2D"), &Viewport::get_world_2d);
ObjectTypeDB::bind_method(_MD("find_world_2d:World2D"), &Viewport::find_world_2d);
ObjectTypeDB::bind_method(_MD("set_world","world:World"), &Viewport::set_world);
ObjectTypeDB::bind_method(_MD("get_world:World"), &Viewport::get_world);
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 145f642fd3..f657f0507d 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -305,9 +305,11 @@ public:
RID get_viewport() const;
void set_world(const Ref<World>& p_world);
+ void set_world_2d(const Ref<World2D>& p_world_2d);
Ref<World> get_world() const;
Ref<World> find_world() const;
+ Ref<World2D> get_world_2d() const;
Ref<World2D> find_world_2d() const;
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 03f28bef08..dea612735c 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -40,7 +40,7 @@
typedef Map<const void*,Ref<ImageTexture> > TexCacheMap;
static TexCacheMap *tex_cache;
-static int scale=1;
+static float scale=1;
template<class T>
static Ref<StyleBoxTexture> make_stylebox(T p_src,float p_left, float p_top, float p_right, float p_botton,float p_margin_left=-1, float p_margin_top=-1, float p_margin_right=-1, float p_margin_botton=-1, bool p_draw_center=true) {
@@ -54,10 +54,21 @@ static Ref<StyleBoxTexture> make_stylebox(T p_src,float p_left, float p_top, flo
texture = Ref<ImageTexture>( memnew( ImageTexture ) );
Image img(p_src);
+
if (scale>1) {
+ Size2 orig_size = Size2(img.get_width(),img.get_height());
+
img.convert(Image::FORMAT_RGBA);
img.expand_x2_hq2x();
+ if (scale!=2.0) {
+ img.resize(orig_size.x*scale,orig_size.y*scale);
+ }
+ } else if (scale<1) {
+ Size2 orig_size = Size2(img.get_width(),img.get_height());
+ img.convert(Image::FORMAT_RGBA);
+ img.resize(orig_size.x*scale,orig_size.y*scale);
}
+
texture->create_from_image( img,ImageTexture::FLAG_FILTER );
(*tex_cache)[p_src]=texture;
}
@@ -95,8 +106,17 @@ static Ref<Texture> make_icon(T p_src) {
Ref<ImageTexture> texture( memnew( ImageTexture ) );
Image img = Image(p_src);
if (scale>1) {
+ Size2 orig_size = Size2(img.get_width(),img.get_height());
+
img.convert(Image::FORMAT_RGBA);
img.expand_x2_hq2x();
+ if (scale!=2.0) {
+ img.resize(orig_size.x*scale,orig_size.y*scale);
+ }
+ } else if (scale<1) {
+ Size2 orig_size = Size2(img.get_width(),img.get_height());
+ img.convert(Image::FORMAT_RGBA);
+ img.resize(orig_size.x*scale,orig_size.y*scale);
}
texture->create_from_image( img,ImageTexture::FLAG_FILTER );
@@ -194,12 +214,9 @@ static Ref<StyleBox> make_empty_stylebox(float p_margin_left=-1, float p_margin_
return style;
}
-void fill_default_theme(Ref<Theme>& t,const Ref<Font> & default_font,const Ref<Font> & large_font,Ref<Texture>& default_icon, Ref<StyleBox>& default_style,bool p_hidpi) {
+void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref<Font> & large_font, Ref<Texture>& default_icon, Ref<StyleBox>& default_style, float p_scale) {
- if (p_hidpi)
- scale=2;
- else
- scale=1;
+ scale=p_scale;
tex_cache = memnew( TexCacheMap );
@@ -969,7 +986,7 @@ void make_default_theme(bool p_hidpi,Ref<Font> p_font) {
default_font=make_font2(_lodpi_font_height,_lodpi_font_ascent,_lodpi_font_charcount,&_lodpi_font_charrects[0][0],_lodpi_font_kerning_pair_count,&_lodpi_font_kerning_pairs[0][0],_lodpi_font_img_width,_lodpi_font_img_height,_lodpi_font_img_data);
}
Ref<BitmapFont> large_font=default_font;
- fill_default_theme(t,default_font,large_font,default_icon,default_style,p_hidpi);
+ fill_default_theme(t,default_font,large_font,default_icon,default_style,p_hidpi?2.0:1.0);
Theme::set_default( t );
Theme::set_default_icon( default_icon );
diff --git a/scene/resources/default_theme/default_theme.h b/scene/resources/default_theme/default_theme.h
index a2a45ac004..3312b2d812 100644
--- a/scene/resources/default_theme/default_theme.h
+++ b/scene/resources/default_theme/default_theme.h
@@ -35,7 +35,7 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
-void fill_default_theme(Ref<Theme>& theme,const Ref<Font> & default_font,const Ref<Font> & large_font,Ref<Texture>& default_icon, Ref<StyleBox>& default_style,bool p_hidpi);
+void fill_default_theme(Ref<Theme>& theme,const Ref<Font> & default_font,const Ref<Font> & large_font,Ref<Texture>& default_icon, Ref<StyleBox>& default_style,float p_scale);
void make_default_theme(bool p_hidpi, Ref<Font> p_font);
void clear_default_theme();
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp
index 40ae26ba5d..02faa9425d 100644
--- a/scene/resources/shader_graph.cpp
+++ b/scene/resources/shader_graph.cpp
@@ -1483,6 +1483,8 @@ const ShaderGraph::InOutParamInfo ShaderGraph::inout_param_info[]={
{MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"LightColor","LIGHT_COLOR.rgb","",SLOT_TYPE_VEC,SLOT_IN},
{MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"LightAlpha","LIGHT_COLOR.a","",SLOT_TYPE_SCALAR,SLOT_IN},
{MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"LightHeight","LIGHT_HEIGHT","",SLOT_TYPE_SCALAR,SLOT_IN},
+ {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"ShadowColor","LIGHT_SHADOW.rgb","",SLOT_TYPE_VEC,SLOT_IN},
+ {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"ShadowAlpha","LIGHT_SHADOW.a","",SLOT_TYPE_SCALAR,SLOT_IN},
{MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"TexPixelSize","vec3(TEXTURE_PIXEL_SIZE,0)","",SLOT_TYPE_VEC,SLOT_IN},
{MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"Var1","VAR1.rgb","",SLOT_TYPE_VEC,SLOT_IN},
{MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"Var2","VAR2.rgb","",SLOT_TYPE_VEC,SLOT_IN},
@@ -1490,6 +1492,8 @@ const ShaderGraph::InOutParamInfo ShaderGraph::inout_param_info[]={
//canvas item light out
{MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"LightColor","LIGHT.rgb","",SLOT_TYPE_VEC,SLOT_OUT},
{MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"LightAlpha","LIGHT.a","",SLOT_TYPE_SCALAR,SLOT_OUT},
+ {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"ShadowColor","SHADOW.rgb","",SLOT_TYPE_VEC,SLOT_OUT},
+ {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"ShadowAlpha","SHADOW.a","",SLOT_TYPE_SCALAR,SLOT_OUT},
//end
{MODE_MATERIAL,SHADER_TYPE_FRAGMENT,NULL,NULL,NULL,SLOT_TYPE_SCALAR,SLOT_OUT},
diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp
index 9291aa6c17..77245c687d 100644
--- a/servers/physics_2d/shape_2d_sw.cpp
+++ b/servers/physics_2d/shape_2d_sw.cpp
@@ -136,7 +136,7 @@ bool LineShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p_en
return true;
}
-real_t LineShape2DSW::get_moment_of_inertia(float p_mass, const Vector2 &p_scale) const {
+real_t LineShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
return 0;
}
@@ -191,7 +191,7 @@ bool RayShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p_end
}
-real_t RayShape2DSW::get_moment_of_inertia(float p_mass, const Vector2 &p_scale) const {
+real_t RayShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
return 0; //rays are mass-less
}
@@ -252,7 +252,7 @@ bool SegmentShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p
return true;
}
-real_t SegmentShape2DSW::get_moment_of_inertia(float p_mass, const Vector2 &p_scale) const {
+real_t SegmentShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
Vector2 s[2]={a*p_scale,b*p_scale};
@@ -336,7 +336,7 @@ bool CircleShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p_
return true;
}
-real_t CircleShape2DSW::get_moment_of_inertia(float p_mass, const Vector2 &p_scale) const {
+real_t CircleShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
return (radius*radius)*(p_scale.x*0.5+p_scale.y*0.5);
@@ -407,7 +407,7 @@ bool RectangleShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2&
return get_aabb().intersects_segment(p_begin,p_end,&r_point,&r_normal);
}
-real_t RectangleShape2DSW::get_moment_of_inertia(float p_mass,const Vector2& p_scale) const {
+real_t RectangleShape2DSW::get_moment_of_inertia(float p_mass,const Size2& p_scale) const {
Vector2 he2=half_extents*2*p_scale;
return p_mass*he2.dot(he2)/12.0f;
@@ -540,7 +540,7 @@ bool CapsuleShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p
return collided; //todo
}
-real_t CapsuleShape2DSW::get_moment_of_inertia(float p_mass, const Vector2 &p_scale) const {
+real_t CapsuleShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
Vector2 he2=Vector2(radius*2,height+radius*2)*p_scale;
return p_mass*he2.dot(he2)/12.0f;
@@ -670,7 +670,7 @@ bool ConvexPolygonShape2DSW::intersect_segment(const Vector2& p_begin,const Vect
return inters; //todo
}
-real_t ConvexPolygonShape2DSW::get_moment_of_inertia(float p_mass,const Vector2& p_scale) const {
+real_t ConvexPolygonShape2DSW::get_moment_of_inertia(float p_mass,const Size2& p_scale) const {
Rect2 aabb;
aabb.pos=points[0].pos*p_scale;
diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h
index 4164896696..b90c36bc04 100644
--- a/servers/physics_2d/shape_2d_sw.h
+++ b/servers/physics_2d/shape_2d_sw.h
@@ -86,7 +86,7 @@ public:
virtual void get_supports(const Vector2& p_normal,Vector2 *r_supports,int & r_amount) const=0;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const=0;
- virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const=0;
+ virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const=0;
virtual void set_data(const Variant& p_data)=0;
virtual Variant get_data() const=0;
@@ -175,7 +175,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const;
+ virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -218,7 +218,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const;
+ virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -266,7 +266,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const;
+ virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -304,7 +304,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const;
+ virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -344,7 +344,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const;
+ virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -432,7 +432,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const;
+ virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -495,7 +495,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const;
+ virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -584,7 +584,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const { return 0; }
+ virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const { return 0; }
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 09b3ada509..fdf3cb622d 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -1180,6 +1180,7 @@ const ShaderLanguage::BuiltinsDef ShaderLanguage::ci_light_builtins_defs[]={
{ "LIGHT_HEIGHT", TYPE_FLOAT},
{ "LIGHT_COLOR", TYPE_VEC4},
{ "LIGHT_UV", TYPE_VEC2},
+ { "LIGHT_SHADOW", TYPE_VEC4},
{ "LIGHT", TYPE_VEC4},
{ "SHADOW", TYPE_VEC4},
{ "POINT_COORD", TYPE_VEC2},
diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp
index 5aac8bff09..320939cb97 100644
--- a/tools/editor/create_dialog.cpp
+++ b/tools/editor/create_dialog.cpp
@@ -42,11 +42,84 @@
void CreateDialog::popup(bool p_dontclear) {
+ recent->clear();
+
+ FileAccess *f = FileAccess::open( EditorSettings::get_singleton()->get_project_settings_path().plus_file("create_recent."+base_type), FileAccess::READ );
+
+ if (f) {
+
+ TreeItem *root = recent->create_item();
+
+ while(!f->eof_reached()) {
+ String l = f->get_line().strip_edges();
+
+ if (l!=String()) {
+
+ TreeItem *ti = recent->create_item(root);
+ ti->set_text(0,l);
+ if (has_icon(l,"EditorIcons")) {
+
+ ti->set_icon(0,get_icon(l,"EditorIcons"));
+ } else {
+ ti->set_icon(0,get_icon("Object","EditorIcons"));
+ }
+ }
+ }
+
+ memdelete(f);
+ }
+
+ favorites->clear();
+
+ f = FileAccess::open( EditorSettings::get_singleton()->get_project_settings_path().plus_file("favorites."+base_type), FileAccess::READ );
+
+ favorite_list.clear();
+
+ if (f) {
+
+
+ while(!f->eof_reached()) {
+ String l = f->get_line().strip_edges();
+
+ if (l!=String()) {
+ favorite_list.push_back(l);
+ }
+ }
+
+ memdelete(f);
+ } else {
+#if 0
+// I think this was way too confusing
+ if (base_type=="Node") {
+ //harcode some favorites :D
+ favorite_list.push_back("Panel");
+ favorite_list.push_back("Button");
+ favorite_list.push_back("Label");
+ favorite_list.push_back("LineEdit");
+ favorite_list.push_back("Node2D");
+ favorite_list.push_back("Sprite");
+ favorite_list.push_back("Camera2D");
+ favorite_list.push_back("Area2D");
+ favorite_list.push_back("CollisionShape2D");
+ favorite_list.push_back("Spatial");
+ favorite_list.push_back("Camera");
+ favorite_list.push_back("Area");
+ favorite_list.push_back("CollisionShape");
+ favorite_list.push_back("TestCube");
+ favorite_list.push_back("AnimationPlayer");
+
+ }
+#endif
+ }
+
+ _update_favorite_list();
+
popup_centered_ratio();
if (p_dontclear)
search_box->select_all();
- else
+ else {
search_box->clear();
+ }
search_box->grab_focus();
_update_search();
@@ -104,7 +177,7 @@ void CreateDialog::add_type(const String& p_type,HashMap<String,TreeItem*>& p_ty
item->set_selectable(0,false);
} else {
- if (!*to_select && (search_box->get_text().is_subsequence_ofi(p_type))) {
+ if ((!*to_select && (search_box->get_text().is_subsequence_ofi(p_type))) || search_box->get_text()==p_type) {
*to_select=item;
}
@@ -140,6 +213,8 @@ void CreateDialog::_update_search() {
search_options->clear();
+ favorite->set_disabled(true);
+
help_bit->set_text("");
/*
TreeItem *root = search_options->create_item();
@@ -225,7 +300,7 @@ void CreateDialog::_update_search() {
}
- if (!to_select) {
+ if (!to_select || ct[i].name==search_box->get_text()) {
to_select=item;
}
@@ -234,8 +309,11 @@ void CreateDialog::_update_search() {
}
}
- if (to_select)
+ if (to_select) {
to_select->select(0);
+ favorite->set_disabled(false);
+ favorite->set_pressed(favorite_list.find(to_select->get_text(0))!=-1);
+ }
get_ok()->set_disabled(root->get_children()==NULL);
@@ -246,6 +324,32 @@ void CreateDialog::_confirmed() {
TreeItem *ti = search_options->get_selected();
if (!ti)
return;
+
+ FileAccess *f = FileAccess::open( EditorSettings::get_singleton()->get_project_settings_path().plus_file("create_recent."+base_type), FileAccess::WRITE );
+
+ if (f) {
+ f->store_line(get_selected_type());
+ TreeItem *t = recent->get_root();
+ if (t)
+ t=t->get_children();
+ int count=0;
+ while(t) {
+ if (t->get_text(0)!=get_selected_type()) {
+
+ f->store_line(t->get_text(0));
+ }
+
+ if (count>32) {
+ //limit it to 32 entries..
+ break;
+ }
+ t=t->get_next();
+ count++;
+ }
+
+ memdelete(f);
+ }
+
emit_signal("create");
hide();
}
@@ -255,6 +359,7 @@ void CreateDialog::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
connect("confirmed",this,"_confirmed");
+ favorite->set_icon(get_icon("Favorites","EditorIcons"));
}
if (p_what==NOTIFICATION_EXIT_TREE) {
@@ -344,6 +449,9 @@ void CreateDialog::_item_selected() {
String name = item->get_text(0);
+ favorite->set_disabled(false);
+ favorite->set_pressed(favorite_list.find(name)!=-1);
+
if (!EditorHelp::get_doc_data()->class_list.has(name))
return;
@@ -351,12 +459,182 @@ void CreateDialog::_item_selected() {
}
+
+void CreateDialog::_favorite_toggled() {
+
+ TreeItem *item = search_options->get_selected();
+ if (!item)
+ return;
+
+ String name = item->get_text(0);
+
+ if (favorite_list.find(name)==-1) {
+ favorite_list.push_back(name);
+ favorite->set_pressed(true);
+ } else {
+ favorite_list.erase(name);
+ favorite->set_pressed(false);
+ }
+
+ _save_favorite_list();
+ _update_favorite_list();
+}
+
+void CreateDialog::_save_favorite_list() {
+
+ FileAccess *f = FileAccess::open( EditorSettings::get_singleton()->get_project_settings_path().plus_file("favorites."+base_type), FileAccess::WRITE );
+
+ if (f) {
+
+ for(int i=0;i<favorite_list.size();i++) {
+
+ f->store_line(favorite_list[i]);
+ }
+ memdelete(f);
+ }
+}
+
+void CreateDialog::_update_favorite_list() {
+
+ favorites->clear();
+ TreeItem *root = favorites->create_item();
+ for(int i=0;i<favorite_list.size();i++) {
+ TreeItem *ti = favorites->create_item(root);
+ String l = favorite_list[i];
+ ti->set_text(0,l);
+
+ if (has_icon(l,"EditorIcons")) {
+
+ ti->set_icon(0,get_icon(l,"EditorIcons"));
+ } else {
+ ti->set_icon(0,get_icon("Object","EditorIcons"));
+ }
+ }
+}
+
+
+void CreateDialog::_history_selected() {
+
+ TreeItem *item = recent->get_selected();
+ if (!item)
+ return;
+
+ search_box->set_text(item->get_text(0));
+ _update_search();
+
+}
+
+void CreateDialog::_favorite_selected(){
+
+ TreeItem *item = favorites->get_selected();
+ if (!item)
+ return;
+
+ search_box->set_text(item->get_text(0));
+ _update_search();
+
+}
+
+void CreateDialog::_history_activated() {
+
+ _confirmed();
+}
+
+void CreateDialog::_favorite_activated(){
+
+ _confirmed();
+}
+
+Variant CreateDialog::get_drag_data_fw(const Point2& p_point,Control* p_from) {
+
+ TreeItem *ti = favorites->get_item_at_pos(p_point);
+ if (ti) {
+ Dictionary d;
+ d["type"]="create_favorite_drag";
+ d["class"]=ti->get_text(0);
+
+ ToolButton *tb = memnew( ToolButton );
+ tb->set_icon(ti->get_icon(0));
+ tb->set_text(ti->get_text(0));
+ set_drag_preview(tb);
+
+ return d;
+ }
+
+ return Variant();
+}
+
+bool CreateDialog::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{
+
+ Dictionary d = p_data;
+ if (d.has("type") && String(d["type"])=="create_favorite_drag") {
+ favorites->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
+ return true;
+ }
+
+ return false;
+}
+void CreateDialog::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){
+
+ Dictionary d = p_data;
+
+ TreeItem *ti = favorites->get_item_at_pos(p_point);
+ if (!ti)
+ return;
+
+ String drop_at = ti->get_text(0);
+ int ds = favorites->get_drop_section_at_pos(p_point);
+
+ int drop_idx = favorite_list.find(drop_at);
+ if (drop_idx<0)
+ return;
+
+ String type = d["class"];
+
+ int from_idx = favorite_list.find(type);
+ if (from_idx<0)
+ return;
+
+ if (drop_idx==from_idx) {
+ ds=-1; //cause it will be gone
+ } else if (drop_idx>from_idx) {
+ drop_idx--;
+ }
+
+ favorite_list.remove(from_idx);
+
+ if (ds<0) {
+ favorite_list.insert(drop_idx,type);
+ } else {
+ if (drop_idx>=favorite_list.size()-1) {
+ favorite_list.push_back(type);
+ } else {
+ favorite_list.insert(drop_idx+1,type);
+ }
+ }
+
+ _save_favorite_list();
+ _update_favorite_list();
+
+
+}
+
void CreateDialog::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_text_changed"),&CreateDialog::_text_changed);
ObjectTypeDB::bind_method(_MD("_confirmed"),&CreateDialog::_confirmed);
ObjectTypeDB::bind_method(_MD("_sbox_input"),&CreateDialog::_sbox_input);
ObjectTypeDB::bind_method(_MD("_item_selected"),&CreateDialog::_item_selected);
+ ObjectTypeDB::bind_method(_MD("_favorite_toggled"),&CreateDialog::_favorite_toggled);
+ ObjectTypeDB::bind_method(_MD("_history_selected"),&CreateDialog::_history_selected);
+ ObjectTypeDB::bind_method(_MD("_favorite_selected"),&CreateDialog::_favorite_selected);
+ ObjectTypeDB::bind_method(_MD("_history_activated"),&CreateDialog::_history_activated);
+ ObjectTypeDB::bind_method(_MD("_favorite_activated"),&CreateDialog::_favorite_activated);
+
+
+ ObjectTypeDB::bind_method("get_drag_data_fw",&CreateDialog::get_drag_data_fw);
+ ObjectTypeDB::bind_method("can_drop_data_fw",&CreateDialog::can_drop_data_fw);
+ ObjectTypeDB::bind_method("drop_data_fw",&CreateDialog::drop_data_fw);
ADD_SIGNAL(MethodInfo("create"));
@@ -365,12 +643,44 @@ void CreateDialog::_bind_methods() {
CreateDialog::CreateDialog() {
+ HSplitContainer *hbc = memnew( HSplitContainer );
+
+ add_child(hbc);
+ set_child_rect(hbc);
+
+ VBoxContainer *lvbc = memnew( VBoxContainer);
+ hbc->add_child(lvbc);
+ lvbc->set_custom_minimum_size(Size2(150,0)*EDSCALE);
+
+ favorites = memnew (Tree );
+ lvbc->add_margin_child(TTR("Favorites:"),favorites,true);
+ favorites->set_hide_root(true);
+ favorites->set_hide_folding(true);
+ favorites->connect("cell_selected",this,"_favorite_selected");
+ favorites->connect("item_activated",this,"_favorite_activated");
+ favorites->set_drag_forwarding(this);
+
+
+ recent = memnew (Tree );
+ lvbc->add_margin_child(TTR("Recent:"),recent,true);
+ recent->set_hide_root(true);
+ recent->set_hide_folding(true);
+ recent->connect("cell_selected",this,"_history_selected");
+ recent->connect("item_activated",this,"_history_activated");
+
VBoxContainer *vbc = memnew( VBoxContainer );
- add_child(vbc);
- set_child_rect(vbc);
+ hbc->add_child(vbc);
+ vbc->set_h_size_flags(SIZE_EXPAND_FILL);
+ HBoxContainer *search_hb = memnew( HBoxContainer );
search_box = memnew( LineEdit );
- vbc->add_margin_child(TTR("Search:"),search_box);
+ search_box->set_h_size_flags(SIZE_EXPAND_FILL);
+ search_hb->add_child(search_box);
+ favorite = memnew( Button );
+ favorite->set_toggle_mode(true);
+ search_hb->add_child(favorite);
+ favorite->connect("pressed",this,"_favorite_toggled");
+ vbc->add_margin_child(TTR("Search:"),search_hb);
search_box->connect("text_changed",this,"_text_changed");
search_box->connect("input_event",this,"_sbox_input");
search_options = memnew( Tree );
diff --git a/tools/editor/create_dialog.h b/tools/editor/create_dialog.h
index 41156b538a..706a06ae16 100644
--- a/tools/editor/create_dialog.h
+++ b/tools/editor/create_dialog.h
@@ -32,6 +32,7 @@
#include "scene/gui/dialogs.h"
#include "scene/gui/button.h"
#include "scene/gui/tree.h"
+#include "scene/gui/item_list.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/label.h"
#include "editor_help.h"
@@ -46,6 +47,12 @@ class CreateDialog : public ConfirmationDialog {
OBJ_TYPE(CreateDialog,ConfirmationDialog )
+
+ Vector<String> favorite_list;
+ Tree *favorites;
+ Tree *recent;
+
+ Button *favorite;
LineEdit *search_box;
Tree *search_options;
String base_type;
@@ -55,6 +62,15 @@ class CreateDialog : public ConfirmationDialog {
void _item_selected();
void _update_search();
+ void _update_favorite_list();
+ void _save_favorite_list();
+ void _favorite_toggled();
+
+ void _history_selected();
+ void _favorite_selected();
+
+ void _history_activated();
+ void _favorite_activated();
void _sbox_input(const InputEvent& p_ie);
@@ -63,6 +79,9 @@ class CreateDialog : public ConfirmationDialog {
void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root,TreeItem **to_select);
+ Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
+ bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
+ void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
protected:
diff --git a/tools/editor/editor_fonts.cpp b/tools/editor/editor_fonts.cpp
index 47891eef6c..bcf41cbac8 100644
--- a/tools/editor/editor_fonts.cpp
+++ b/tools/editor/editor_fonts.cpp
@@ -158,17 +158,10 @@ void editor_register_fonts(Ref<Theme> p_theme) {
p_theme->set_font("doc_source","EditorFonts",df_doc_code);
- if (editor_is_hidpi()) {
- //replace default theme
- Ref<Texture> di;
- Ref<StyleBox> ds;
- fill_default_theme(p_theme,df,df_doc,di,ds,true);
+ //replace default theme
+ Ref<Texture> di;
+ Ref<StyleBox> ds;
+ fill_default_theme(p_theme,df,df_doc,di,ds,EDSCALE);
- } else {
- Ref<Texture> di;
- Ref<StyleBox> ds;
- fill_default_theme(p_theme,df,df_doc,di,ds,false);
-
- }
}
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index e88a155d95..fe97fe2881 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -176,17 +176,6 @@ void EditorNode::_unhandled_input(const InputEvent& p_event) {
if (p_event.type==InputEvent::KEY && p_event.key.pressed && !p_event.key.echo && !gui_base->get_viewport()->gui_has_modal_stack()) {
- if (ED_IS_SHORTCUT("editor/fullscreen_mode", p_event)) {
- if (distraction_free_mode) {
- distraction_free_mode = false;
- _update_top_menu_visibility();
- } else {
- set_docks_visible(!get_docks_visible());
- }
- }
- if (ED_IS_SHORTCUT("editor/distraction_free_mode", p_event)) {
- set_distraction_free_mode(!get_distraction_free_mode());
- }
if (ED_IS_SHORTCUT("editor/next_tab", p_event)) {
int next_tab = editor_data.get_edited_scene() + 1;
next_tab %= editor_data.get_edited_scene_count();
@@ -1228,6 +1217,7 @@ void EditorNode::_dialog_action(String p_file) {
//_save_scene(p_file);
_save_scene_with_preview(p_file);
+ _call_build();
_run(true);
}
} break;
@@ -1374,6 +1364,7 @@ void EditorNode::_dialog_action(String p_file) {
unzClose(pkg);
} break;
+
case RESOURCE_SAVE:
case RESOURCE_SAVE_AS: {
@@ -2646,6 +2637,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case RUN_PLAY: {
_menu_option_confirm(RUN_STOP,true);
+ _call_build();
_run(false);
} break;
@@ -2681,6 +2673,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case RUN_PLAY_SCENE: {
_menu_option_confirm(RUN_STOP,true);
+ _call_build();
_run(true);
} break;
@@ -2692,6 +2685,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
}
if (run_native->is_deploy_debug_remote_enabled()){
_menu_option_confirm(RUN_STOP,true);
+ _call_build();
emit_signal("play_pressed");
editor_run.run_native_notify();
}
@@ -2817,6 +2811,12 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
file_templates->popup_centered_ratio();
} break;
+ case SETTINGS_TOGGLE_FULLSCREN: {
+
+ OS::get_singleton()->set_window_fullscreen( !OS::get_singleton()->is_window_fullscreen() );
+
+
+ } break;
case SETTINGS_PICK_MAIN_SCENE: {
@@ -3002,6 +3002,8 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor) {
singleton->main_editor_buttons.push_back(tb);
singleton->main_editor_button_vb->add_child(tb);
singleton->editor_table.push_back(p_editor);
+
+ singleton->distraction_free->raise();
}
singleton->editor_data.add_editor_plugin( p_editor );
singleton->add_child(p_editor);
@@ -3014,7 +3016,11 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor) {
for(int i=0;i<singleton->main_editor_buttons.size();i++) {
- if (p_editor->get_name()==singleton->main_editor_buttons[i]->get_name()) {
+ if (p_editor->get_name()==singleton->main_editor_buttons[i]->get_text()) {
+
+ if (singleton->main_editor_buttons[i]->is_pressed()) {
+ singleton->_editor_select(EDITOR_SCRIPT);
+ }
memdelete( singleton->main_editor_buttons[i] );
singleton->main_editor_buttons.remove(i);
@@ -4044,6 +4050,7 @@ void EditorNode::_quick_opened() {
void EditorNode::_quick_run() {
+ _call_build();
_run(false,quick_run->get_selected());
}
@@ -4607,7 +4614,10 @@ void EditorNode::_update_dock_slots_visibility() {
}
void EditorNode::_update_top_menu_visibility() {
- if (distraction_free_mode) {
+
+ return; // I think removing top menu is too much
+ /*
+ if (distraction_free->is_pressed()) {
play_cc->hide();
menu_hb->hide();
scene_tabs->hide();
@@ -4615,7 +4625,7 @@ void EditorNode::_update_top_menu_visibility() {
play_cc->show();
menu_hb->show();
scene_tabs->show();
- }
+ }*/
}
void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String& p_section) {
@@ -4991,8 +5001,14 @@ bool EditorNode::get_docks_visible() const {
return docks_visible;
}
+void EditorNode::_toggle_distraction_free_mode() {
+
+ set_distraction_free_mode( distraction_free->is_pressed() );
+}
+
void EditorNode::set_distraction_free_mode(bool p_enter) {
- distraction_free_mode = p_enter;
+
+ distraction_free->set_pressed(p_enter);
if (p_enter) {
if (docks_visible) {
@@ -5005,7 +5021,7 @@ void EditorNode::set_distraction_free_mode(bool p_enter) {
}
bool EditorNode::get_distraction_free_mode() const {
- return distraction_free_mode;
+ return distraction_free->is_pressed();
}
void EditorNode::add_control_to_dock(DockSlot p_slot,Control* p_control) {
@@ -5237,6 +5253,24 @@ void EditorNode::add_plugin_init_callback(EditorPluginInitializeCallback p_callb
EditorPluginInitializeCallback EditorNode::plugin_init_callbacks[EditorNode::MAX_INIT_CALLBACKS];
+int EditorNode::build_callback_count=0;
+
+void EditorNode::add_build_callback(EditorBuildCallback p_callback) {
+
+ ERR_FAIL_COND(build_callback_count==MAX_INIT_CALLBACKS);
+
+ build_callbacks[build_callback_count++]=p_callback;
+}
+
+EditorPluginInitializeCallback EditorNode::build_callbacks[EditorNode::MAX_BUILD_CALLBACKS];
+
+void EditorNode::_call_build() {
+
+ for(int i=0;i<build_callback_count;i++) {
+ build_callbacks[i]();
+ }
+}
+
void EditorNode::_bind_methods() {
@@ -5305,6 +5339,7 @@ void EditorNode::_bind_methods() {
ObjectTypeDB::bind_method("_clear_search_box",&EditorNode::_clear_search_box);
ObjectTypeDB::bind_method("_clear_undo_history",&EditorNode::_clear_undo_history);
ObjectTypeDB::bind_method("_dropped_files",&EditorNode::_dropped_files);
+ ObjectTypeDB::bind_method("_toggle_distraction_free_mode",&EditorNode::_toggle_distraction_free_mode);
@@ -5349,7 +5384,7 @@ EditorNode::EditorNode() {
changing_scene=false;
_initializing_addons=false;
docks_visible = true;
- distraction_free_mode=false;
+
FileAccess::set_backup_save(true);
@@ -5358,19 +5393,27 @@ EditorNode::EditorNode() {
// load settings
if (!EditorSettings::get_singleton())
EditorSettings::create();
+
+ bool use_single_dock_column = false;
{
int dpi_mode = EditorSettings::get_singleton()->get("global/hidpi_mode");
if (dpi_mode==0) {
- editor_set_hidpi( OS::get_singleton()->get_screen_dpi(0) > 150 );
+ editor_set_scale( OS::get_singleton()->get_screen_dpi(0) > 150 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x>2000 ? 2.0 : 1.0 );
+
+ use_single_dock_column = OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x<1200;
+
+ } else if (dpi_mode==1) {
+ editor_set_scale(0.75);
} else if (dpi_mode==2) {
- editor_set_hidpi(true);
- } else {
- editor_set_hidpi(false);
+ editor_set_scale(1.0);
+ } else if (dpi_mode==3) {
+ editor_set_scale(1.5);
+ } else if (dpi_mode==4) {
+ editor_set_scale(2.0);
}
}
-
ResourceLoader::set_abort_on_missing_resources(false);
FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"));
EditorFileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"));
@@ -5677,8 +5720,6 @@ EditorNode::EditorNode() {
prev_scene->set_pos(Point2(3,24));
prev_scene->hide();
- ED_SHORTCUT("editor/fullscreen_mode",TTR("Fullscreen Mode"),KEY_MASK_SHIFT|KEY_F11);
- ED_SHORTCUT("editor/distraction_free_mode",TTR("Distraction Free Mode"),KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_F11);
ED_SHORTCUT("editor/next_tab", TTR("Next tab"), KEY_MASK_CMD+KEY_TAB);
@@ -5749,6 +5790,13 @@ EditorNode::EditorNode() {
editor_region->add_child(main_editor_button_vb);
menu_hb->add_child(editor_region);
+ distraction_free = memnew( ToolButton );
+ main_editor_button_vb->add_child(distraction_free);
+ distraction_free->set_shortcut( ED_SHORTCUT("editor/distraction_free_mode",TTR("Distraction Free Mode"),KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_F11) );
+ distraction_free->connect("pressed",this,"_toggle_distraction_free_mode");
+ distraction_free->set_icon(gui_base->get_icon("DistractionFree","EditorIcons"));
+ distraction_free->set_toggle_mode(true);
+
//menu_hb->add_spacer();
#if 0
node_menu = memnew( MenuButton );
@@ -5989,6 +6037,9 @@ EditorNode::EditorNode() {
p->add_child(editor_layouts);
editor_layouts->connect("item_pressed",this,"_layout_menu_option");
p->add_submenu_item(TTR("Editor Layout"), "Layouts");
+
+ p->add_shortcut(ED_SHORTCUT("editor/fullscreen_mode",TTR("Toggle Fullscreen"),KEY_MASK_SHIFT|KEY_F11),SETTINGS_TOGGLE_FULLSCREN);
+
p->add_separator();
p->add_item(TTR("Install Export Templates"),SETTINGS_LOAD_EXPORT_TEMPLATES);
p->add_separator();
@@ -6181,12 +6232,24 @@ EditorNode::EditorNode() {
node_dock = memnew( NodeDock );
//node_dock->set_undoredo(&editor_data.get_undo_redo());
- dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(node_dock);
+ if (use_single_dock_column) {
+ dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(node_dock);
+ } else {
+ dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(node_dock);
+ }
scenes_dock = memnew( FileSystemDock(this) );
scenes_dock->set_name(TTR("FileSystem"));
scenes_dock->set_display_mode(int(EditorSettings::get_singleton()->get("filesystem_dock/display_mode")));
- dock_slot[DOCK_SLOT_LEFT_UR]->add_child(scenes_dock);
+
+ if (use_single_dock_column) {
+ dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(scenes_dock);
+ left_r_vsplit->hide();
+ dock_slot[DOCK_SLOT_LEFT_UR]->hide();
+ dock_slot[DOCK_SLOT_LEFT_BR]->hide();
+ } else {
+ dock_slot[DOCK_SLOT_LEFT_UR]->add_child(scenes_dock);
+ }
//prop_pallete->add_child(scenes_dock);
scenes_dock->connect("open",this,"open_request");
scenes_dock->connect("instance",this,"_instance_request");
@@ -6195,9 +6258,9 @@ EditorNode::EditorNode() {
overridden_default_layout=-1;
default_layout.instance();
- default_layout->set_value(docks_section, "dock_3", TTR("Scene"));
- default_layout->set_value(docks_section, "dock_4", TTR("FileSystem"));
- default_layout->set_value(docks_section, "dock_5", TTR("Inspector"));
+ default_layout->set_value(docks_section, "dock_3", TTR("FileSystem"));
+ default_layout->set_value(docks_section, "dock_5", TTR("Scene"));
+ default_layout->set_value(docks_section, "dock_6", TTR("Inspector")+","+TTR("Node"));
for(int i=0;i<DOCK_SLOT_MAX/2;i++)
default_layout->set_value(docks_section, "dock_hsplit_"+itos(i+1), 0);
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index 147a0fd6ed..2fae5daced 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -95,6 +95,7 @@
typedef void (*EditorNodeInitCallback)();
typedef void (*EditorPluginInitializeCallback)();
+typedef void (*EditorBuildCallback)();
class EditorPluginList;
@@ -186,6 +187,7 @@ private:
SETTINGS_LAYOUT_DEFAULT,
SETTINGS_LOAD_EXPORT_TEMPLATES,
SETTINGS_PICK_MAIN_SCENE,
+ SETTINGS_TOGGLE_FULLSCREN,
SETTINGS_HELP,
SETTINGS_ABOUT,
SOURCES_REIMPORT,
@@ -356,7 +358,7 @@ private:
int dock_popup_selected;
Timer *dock_drag_timer;
bool docks_visible;
- bool distraction_free_mode;
+ ToolButton *distraction_free;
String _tmp_import_path;
@@ -576,13 +578,21 @@ private:
static void _file_access_close_error_notify(const String& p_str);
+ void _toggle_distraction_free_mode();
enum {
- MAX_INIT_CALLBACKS=128
+ MAX_INIT_CALLBACKS=128,
+ MAX_BUILD_CALLBACKS=128
};
+
+
static int plugin_init_callback_count;
static EditorPluginInitializeCallback plugin_init_callbacks[MAX_INIT_CALLBACKS];
+
+ void _call_build();
+ static int build_callback_count;
+ static EditorBuildCallback build_callbacks[MAX_BUILD_CALLBACKS];
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -750,6 +760,7 @@ public:
void get_singleton(const char* arg1, bool arg2);
static void add_init_callback(EditorNodeInitCallback p_callback) { _init_callbacks.push_back(p_callback); }
+ static void add_build_callback(EditorBuildCallback p_callback);
diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp
index 55f0e52c88..4b82d5e59c 100644
--- a/tools/editor/editor_plugin.cpp
+++ b/tools/editor/editor_plugin.cpp
@@ -71,6 +71,11 @@ void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) {
}
+Control * EditorPlugin::get_editor_viewport() {
+
+ return EditorNode::get_singleton()->get_viewport();
+}
+
void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Control *p_control) {
switch(p_location) {
@@ -315,6 +320,16 @@ Control *EditorPlugin::get_base_control() {
return EditorNode::get_singleton()->get_gui_base();
}
+void EditorPlugin::make_bottom_panel_item_visible(Control * p_item) {
+
+ EditorNode::get_singleton()->make_bottom_panel_item_visible(p_item);
+}
+
+void EditorPlugin::hide_bottom_panel() {
+
+ EditorNode::get_singleton()->hide_bottom_panel();
+}
+
void EditorPlugin::inspect_object(Object *p_obj,const String& p_for_property) {
EditorNode::get_singleton()->push_item(p_obj,p_for_property);
@@ -333,6 +348,7 @@ void EditorPlugin::_bind_methods() {
ObjectTypeDB::bind_method(_MD("remove_control_from_bottom_panel","control:Control"),&EditorPlugin::remove_control_from_bottom_panel);
ObjectTypeDB::bind_method(_MD("add_custom_type","type","base","script:Script","icon:Texture"),&EditorPlugin::add_custom_type);
ObjectTypeDB::bind_method(_MD("remove_custom_type","type"),&EditorPlugin::remove_custom_type);
+ ObjectTypeDB::bind_method(_MD("get_editor_viewport:Control"), &EditorPlugin::get_editor_viewport);
ObjectTypeDB::bind_method(_MD("add_import_plugin","plugin:EditorImportPlugin"),&EditorPlugin::add_import_plugin);
ObjectTypeDB::bind_method(_MD("remove_import_plugin","plugin:EditorImportPlugin"),&EditorPlugin::remove_import_plugin);
@@ -346,6 +362,9 @@ void EditorPlugin::_bind_methods() {
ObjectTypeDB::bind_method(_MD("inspect_object","object","for_property"),&EditorPlugin::inspect_object,DEFVAL(String()));
ObjectTypeDB::bind_method(_MD("update_canvas"),&EditorPlugin::update_canvas);
+ ObjectTypeDB::bind_method(_MD("make_bottom_panel_item_visible","item:Control"), &EditorPlugin::make_bottom_panel_item_visible);
+ ObjectTypeDB::bind_method(_MD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel);
+
ObjectTypeDB::bind_method(_MD("get_base_control:Control"),&EditorPlugin::get_base_control);
ObjectTypeDB::bind_method(_MD("get_undo_redo:UndoRedo"),&EditorPlugin::_get_undo_redo);
ObjectTypeDB::bind_method(_MD("get_selection:EditorSelection"),&EditorPlugin::get_selection);
diff --git a/tools/editor/editor_plugin.h b/tools/editor/editor_plugin.h
index 5b944cc27a..2700c49a6c 100644
--- a/tools/editor/editor_plugin.h
+++ b/tools/editor/editor_plugin.h
@@ -100,6 +100,7 @@ public:
void add_control_to_dock(DockSlot p_slot,Control *p_control);
void remove_control_from_docks(Control *p_control);
void remove_control_from_bottom_panel(Control *p_control);
+ Control* get_editor_viewport();
virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial* p_spatial);
virtual bool forward_canvas_input_event(const Matrix32& p_canvas_xform, const InputEvent& p_event);
@@ -130,6 +131,9 @@ public:
Control *get_base_control();
+ void make_bottom_panel_item_visible(Control *p_item);
+ void hide_bottom_panel();
+
void add_import_plugin(const Ref<EditorImportPlugin>& p_editor_import);
void remove_import_plugin(const Ref<EditorImportPlugin>& p_editor_import);
diff --git a/tools/editor/editor_scale.cpp b/tools/editor/editor_scale.cpp
index c332acc0ca..8575e1c30a 100644
--- a/tools/editor/editor_scale.cpp
+++ b/tools/editor/editor_scale.cpp
@@ -1,14 +1,13 @@
#include "editor_scale.h"
#include "os/os.h"
-static bool editor_hidpi=false;
+static float scale = 1.0;
-void editor_set_hidpi(bool p_hidpi) {
+void editor_set_scale(float p_scale) {
- editor_hidpi=p_hidpi;
+ scale=p_scale;
}
+float editor_get_scale() {
-bool editor_is_hidpi() {
-
- return editor_hidpi;
+ return scale;
}
diff --git a/tools/editor/editor_scale.h b/tools/editor/editor_scale.h
index a60cf00f0a..90e575f771 100644
--- a/tools/editor/editor_scale.h
+++ b/tools/editor/editor_scale.h
@@ -1,8 +1,8 @@
#ifndef EDITOR_SCALE_H
#define EDITOR_SCALE_H
-void editor_set_hidpi(bool p_hidpi);
-bool editor_is_hidpi();
+void editor_set_scale(float p_scale);
+float editor_get_scale();
-#define EDSCALE (editor_is_hidpi() ? 2 : 1)
+#define EDSCALE (editor_get_scale())
#endif // EDITOR_SCALE_H
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index ad5cd86b4b..4778a7ce90 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -511,7 +511,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
}
set("global/hidpi_mode",0);
- hints["global/hidpi_mode"]=PropertyInfo(Variant::INT,"global/hidpi_mode",PROPERTY_HINT_ENUM,"Auto,LoDPI,HiDPI",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED);
+ hints["global/hidpi_mode"]=PropertyInfo(Variant::INT,"global/hidpi_mode",PROPERTY_HINT_ENUM,"Auto,VeryLoDPI,LoDPI,MidDPI,HiDPI",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED);
set("global/show_script_in_scene_tabs",false);
set("global/font_size",14);
hints["global/font_size"]=PropertyInfo(Variant::INT,"global/font_size",PROPERTY_HINT_RANGE,"10,40,1",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED);
diff --git a/tools/editor/editor_themes.cpp b/tools/editor/editor_themes.cpp
index 80ba4c46e0..08f14ec167 100644
--- a/tools/editor/editor_themes.cpp
+++ b/tools/editor/editor_themes.cpp
@@ -32,6 +32,7 @@
#include "editor_fonts.h"
#include "editor_settings.h"
#include "core/io/resource_loader.h"
+#include "editor_scale.h"
Ref<Theme> create_editor_theme()
{
@@ -43,8 +44,8 @@ Ref<Theme> create_editor_theme()
Ref<StyleBoxTexture> focus_sbt=memnew( StyleBoxTexture );
focus_sbt->set_texture(theme->get_icon("EditorFocus","EditorIcons"));
for(int i=0;i<4;i++) {
- focus_sbt->set_margin_size(Margin(i),16);
- focus_sbt->set_default_margin(Margin(i),16);
+ focus_sbt->set_margin_size(Margin(i),16*EDSCALE);
+ focus_sbt->set_default_margin(Margin(i),16*EDSCALE);
}
focus_sbt->set_draw_center(false);
theme->set_stylebox("EditorFocus","EditorStyles",focus_sbt);
diff --git a/tools/editor/icons/2x/icon_distraction_free.png b/tools/editor/icons/2x/icon_distraction_free.png
new file mode 100644
index 0000000000..034239a4e7
--- /dev/null
+++ b/tools/editor/icons/2x/icon_distraction_free.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_remote_transform.png b/tools/editor/icons/2x/icon_remote_transform.png
index 9ee66bc70c..dad528615a 100644
--- a/tools/editor/icons/2x/icon_remote_transform.png
+++ b/tools/editor/icons/2x/icon_remote_transform.png
Binary files differ
diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub
index bc104294cb..44e28f49e6 100644
--- a/tools/editor/icons/SCsub
+++ b/tools/editor/icons/SCsub
@@ -61,8 +61,10 @@ def make_editor_icons_action(target, source, env):
s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n")
s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n")
- s.write("\tImage img((editor_is_hidpi()&&p_hidpi_png)?p_hidpi_png:p_png);\n")
- s.write("\tif (editor_is_hidpi() && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); }\n")
+ s.write("\tbool use_hidpi_image=(editor_get_scale()>1.0&&p_hidpi_png);\n")
+ s.write("\tImage img(use_hidpi_image?p_hidpi_png:p_png);\n")
+ s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); use_hidpi_image=true;}\n")
+ s.write("\timg.resize(img.get_width()*EDSCALE/(use_hidpi_image?2:1),img.get_height()*EDSCALE/(use_hidpi_image?2:1));\n")
s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n")
s.write("\treturn texture;\n")
s.write("}\n\n")
diff --git a/tools/editor/icons/icon_distraction_free.png b/tools/editor/icons/icon_distraction_free.png
new file mode 100644
index 0000000000..c6f8a08874
--- /dev/null
+++ b/tools/editor/icons/icon_distraction_free.png
Binary files differ
diff --git a/tools/editor/icons/icon_remote_transform.png b/tools/editor/icons/icon_remote_transform.png
index deff925b53..2a8b5f4d0e 100644
--- a/tools/editor/icons/icon_remote_transform.png
+++ b/tools/editor/icons/icon_remote_transform.png
Binary files differ
diff --git a/tools/editor/icons/source/icon_distraction_free.svg b/tools/editor/icons/source/icon_distraction_free.svg
new file mode 100644
index 0000000000..4ae48b2fb6
--- /dev/null
+++ b/tools/editor/icons/source/icon_distraction_free.svg
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_add_track.png"
+ inkscape:export-xdpi="45"
+ inkscape:export-ydpi="45"
+ sodipodi:docname="icon_distraction_free.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="32.000001"
+ inkscape:cx="10.344519"
+ inkscape:cy="8.9631686"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="px"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-paths="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:snap-bbox-midpoints="false"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1016"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:snap-midpoints="true"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3336" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 3.7578125 2.34375 L 2.34375 3.7578125 L 5.2929688 6.7070312 L 6.7070312 5.2929688 L 3.7578125 2.34375 z M 12.242188 2.34375 L 9.2929688 5.2929688 L 10.707031 6.7070312 L 13.65625 3.7578125 L 12.242188 2.34375 z M 5.2929688 9.2929688 L 2.34375 12.242188 L 3.7578125 13.65625 L 6.7070312 10.707031 L 5.2929688 9.2929688 z M 10.707031 9.2929688 L 9.2929688 10.707031 L 12.242188 13.65625 L 13.65625 12.242188 L 10.707031 9.2929688 z "
+ transform="translate(0,1036.3622)"
+ id="rect4137" />
+ <path
+ style="fill:#e0e0e0;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 1,1051.3622 0,-5 5,5 z"
+ id="path4155"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccc" />
+ <path
+ sodipodi:nodetypes="cccc"
+ inkscape:connector-curvature="0"
+ id="path4158"
+ d="m 15,1051.3622 0,-5 -5,5 z"
+ style="fill:#e0e0e0;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ style="fill:#e0e0e0;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 15,1037.3622 0,5 -5,-5 z"
+ id="path4160"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccc" />
+ <path
+ sodipodi:nodetypes="cccc"
+ inkscape:connector-curvature="0"
+ id="path4162"
+ d="m 1,1037.3622 0,5 5,-5 z"
+ style="fill:#e0e0e0;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ </g>
+</svg>
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 77b4106473..fd25843de9 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -43,6 +43,17 @@
/*** SCRIPT EDITOR ****/
+
+void ScriptEditorBase::_bind_methods() {
+
+ ADD_SIGNAL(MethodInfo("name_changed"));
+ ADD_SIGNAL(MethodInfo("request_help_search",PropertyInfo(Variant::STRING,"topic")));
+ ADD_SIGNAL(MethodInfo("request_open_script_at_line",PropertyInfo(Variant::OBJECT,"script"),PropertyInfo(Variant::INT,"line")));
+ ADD_SIGNAL(MethodInfo("request_save_history"));
+ ADD_SIGNAL(MethodInfo("go_to_help",PropertyInfo(Variant::STRING,"what")));
+
+}
+
static bool _can_open_in_editor(Script* p_script) {
String path = p_script->get_path();
@@ -346,6 +357,34 @@ void ScriptEditor::_update_history_arrows() {
script_forward->set_disabled( history_pos>=history.size()-1 );
}
+void ScriptEditor::_save_history() {
+
+
+ if (history_pos>=0 && history_pos<history.size() && history[history_pos].control==tab_container->get_current_tab_control()) {
+
+ Node *n = tab_container->get_current_tab_control();
+
+ if (n->cast_to<ScriptEditorBase>()) {
+
+ history[history_pos].state=n->cast_to<ScriptEditorBase>()->get_edit_state();
+ }
+ if (n->cast_to<EditorHelp>()) {
+
+ history[history_pos].state=n->cast_to<EditorHelp>()->get_scroll();
+ }
+ }
+
+ history.resize(history_pos+1);
+ ScriptHistory sh;
+ sh.control=tab_container->get_current_tab_control();
+ sh.state=Variant();
+
+ history.push_back(sh);
+ history_pos++;
+
+ _update_history_arrows();
+}
+
void ScriptEditor::_go_to_tab(int p_idx) {
@@ -1323,10 +1362,8 @@ struct _ScriptEditorItemData {
void ScriptEditor::_update_script_colors() {
- bool enabled = EditorSettings::get_singleton()->get("text_editor/script_temperature_enabled");
+ bool script_temperature_enabled = EditorSettings::get_singleton()->get("text_editor/script_temperature_enabled");
bool highlight_current = EditorSettings::get_singleton()->get("text_editor/highlight_current_script");
- if (!enabled)
- return;
int hist_size = EditorSettings::get_singleton()->get("text_editor/script_temperature_history_size");
Color hot_color=EditorSettings::get_singleton()->get("text_editor/script_temperature_hot_color");
@@ -1340,22 +1377,25 @@ void ScriptEditor::_update_script_colors() {
continue;
script_list->set_item_custom_bg_color(i,Color(0,0,0,0));
- if (!n->has_meta("__editor_pass")) {
- continue;
- }
-
- int pass=n->get_meta("__editor_pass");
- int h = edit_pass - pass;
- if (h>hist_size) {
- continue;
- }
- int non_zero_hist_size = ( hist_size == 0 ) ? 1 : hist_size;
- float v = Math::ease((edit_pass-pass)/float(non_zero_hist_size),0.4);
bool current = tab_container->get_current_tab() == c;
if (current && highlight_current) {
script_list->set_item_custom_bg_color(i, EditorSettings::get_singleton()->get("text_editor/current_script_background_color"));
- } else {
+
+ } else if (script_temperature_enabled) {
+
+ if (!n->has_meta("__editor_pass")) {
+ continue;
+ }
+
+ int pass=n->get_meta("__editor_pass");
+ int h = edit_pass - pass;
+ if (h>hist_size) {
+ continue;
+ }
+ int non_zero_hist_size = ( hist_size == 0 ) ? 1 : hist_size;
+ float v = Math::ease((edit_pass-pass)/float(non_zero_hist_size),0.4);
+
script_list->set_item_custom_bg_color(i,hot_color.linear_interpolate(cold_color,v));
}
}
@@ -1535,6 +1575,11 @@ void ScriptEditor::edit(const Ref<Script>& p_script, bool p_grab_focus) {
_save_layout();
se->connect("name_changed",this,"_update_script_names");
se->connect("request_help_search",this,"_help_search");
+ se->connect("request_open_script_at_line",this,"_goto_script_line");
+ se->connect("go_to_help",this,"_help_class_goto");
+ se->connect("request_save_history",this,"_save_history");
+
+
//test for modification, maybe the script was not edited but was loaded
@@ -1691,6 +1736,7 @@ void ScriptEditor::_editor_settings_changed() {
se->update_settings();
}
+ _update_script_colors();
ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/auto_reload_and_parse_scripts_on_save",true));
@@ -1840,7 +1886,6 @@ void ScriptEditor::_help_class_open(const String& p_class) {
void ScriptEditor::_help_class_goto(const String& p_desc) {
-
String cname=p_desc.get_slice(":",1);
for(int i=0;i<tab_container->get_child_count();i++) {
@@ -2021,6 +2066,8 @@ void ScriptEditor::_bind_methods() {
ObjectTypeDB::bind_method("_goto_script_line",&ScriptEditor::_goto_script_line);
ObjectTypeDB::bind_method("_goto_script_line2",&ScriptEditor::_goto_script_line2);
ObjectTypeDB::bind_method("_help_search",&ScriptEditor::_help_search);
+ ObjectTypeDB::bind_method("_save_history",&ScriptEditor::_save_history);
+
ObjectTypeDB::bind_method("_breaked",&ScriptEditor::_breaked);
diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h
index 907240a352..10f3bce14e 100644
--- a/tools/editor/plugins/script_editor_plugin.h
+++ b/tools/editor/plugins/script_editor_plugin.h
@@ -78,7 +78,8 @@ class ScriptEditorDebugger;
class ScriptEditorBase : public Control {
OBJ_TYPE( ScriptEditorBase, Control );
-
+protected:
+ static void _bind_methods();
public:
virtual void apply_code()=0;
@@ -282,6 +283,7 @@ class ScriptEditor : public VBoxContainer {
void _help_class_open(const String& p_class);
void _help_class_goto(const String& p_desc);
void _update_history_arrows();
+ void _save_history();
void _go_to_tab(int p_idx);
void _update_history_pos(int p_new_pos);
void _update_script_colors();
diff --git a/tools/editor/plugins/script_text_editor.cpp b/tools/editor/plugins/script_text_editor.cpp
index 68b1042565..ca0398f069 100644
--- a/tools/editor/plugins/script_text_editor.cpp
+++ b/tools/editor/plugins/script_text_editor.cpp
@@ -526,6 +526,74 @@ static void swap_lines(TextEdit *tx, int line1, int line2)
tx->cursor_set_line(line2);
}
+void ScriptTextEditor::_lookup_symbol(const String& p_symbol,int p_row, int p_column) {
+
+ Node *base = get_tree()->get_edited_scene_root();
+ if (base) {
+ base = _find_node_for_script(base,base,script);
+ }
+
+
+ ScriptLanguage::LookupResult result;
+ if (script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(),p_symbol,script->get_path().get_base_dir(),base,result)==OK) {
+
+ _goto_line(p_row);
+
+ switch(result.type) {
+ case ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION: {
+
+ if (result.script.is_valid()) {
+ emit_signal("request_open_script_at_line",result.script,result.location-1);
+ } else {
+ emit_signal("request_save_history");
+ _goto_line(result.location-1);
+ }
+ } break;
+ case ScriptLanguage::LookupResult::RESULT_CLASS: {
+ emit_signal("go_to_help","class_name:"+result.class_name);
+ } break;
+ case ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT: {
+
+ StringName cname = result.class_name;
+ bool success;
+ while(true) {
+ ObjectTypeDB::get_integer_constant(cname,result.class_member,&success);
+ if (success) {
+ result.class_name=cname;
+ cname=ObjectTypeDB::type_inherits_from(cname);
+ } else {
+ break;
+ }
+ }
+
+
+ emit_signal("go_to_help","class_constant:"+result.class_name+":"+result.class_member);
+
+ } break;
+ case ScriptLanguage::LookupResult::RESULT_CLASS_PROPERTY: {
+ emit_signal("go_to_help","class_property:"+result.class_name+":"+result.class_member);
+
+ } break;
+ case ScriptLanguage::LookupResult::RESULT_CLASS_METHOD: {
+
+ StringName cname = result.class_name;
+
+ while(true) {
+ if (ObjectTypeDB::has_method(cname,result.class_member)) {
+ result.class_name=cname;
+ cname=ObjectTypeDB::type_inherits_from(cname);
+ } else {
+ break;
+ }
+ }
+
+ emit_signal("go_to_help","class_method:"+result.class_name+":"+result.class_member);
+
+ } break;
+ }
+
+ }
+}
void ScriptTextEditor::_edit_option(int p_op) {
@@ -920,13 +988,14 @@ void ScriptTextEditor::_bind_methods() {
ObjectTypeDB::bind_method("_breakpoint_toggled",&ScriptTextEditor::_breakpoint_toggled);
ObjectTypeDB::bind_method("_edit_option",&ScriptTextEditor::_edit_option);
ObjectTypeDB::bind_method("_goto_line",&ScriptTextEditor::_goto_line);
+ ObjectTypeDB::bind_method("_lookup_symbol",&ScriptTextEditor::_lookup_symbol);
+
+
ObjectTypeDB::bind_method("get_drag_data_fw",&ScriptTextEditor::get_drag_data_fw);
ObjectTypeDB::bind_method("can_drop_data_fw",&ScriptTextEditor::can_drop_data_fw);
ObjectTypeDB::bind_method("drop_data_fw",&ScriptTextEditor::drop_data_fw);
- ADD_SIGNAL(MethodInfo("name_changed"));
- ADD_SIGNAL(MethodInfo("request_help_search",PropertyInfo(Variant::STRING,"topic")));
}
Control *ScriptTextEditor::get_edit_menu() {
@@ -1109,6 +1178,8 @@ ScriptTextEditor::ScriptTextEditor() {
code_editor->connect("load_theme_settings",this,"_load_theme_settings");
code_editor->set_code_complete_func(_code_complete_scripts,this);
code_editor->get_text_edit()->connect("breakpoint_toggled", this, "_breakpoint_toggled");
+ code_editor->get_text_edit()->connect("symbol_lookup", this, "_lookup_symbol");
+
code_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file"));
code_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete"));
@@ -1125,6 +1196,8 @@ ScriptTextEditor::ScriptTextEditor() {
EditorSettings::get_singleton()->get("text_editor/put_callhint_tooltip_below_current_line"),
EditorSettings::get_singleton()->get("text_editor/callhint_tooltip_offset"));
+ code_editor->get_text_edit()->set_select_identifiers_on_hover(true);
+
edit_hb = memnew (HBoxContainer);
edit_menu = memnew( MenuButton );
diff --git a/tools/editor/plugins/script_text_editor.h b/tools/editor/plugins/script_text_editor.h
index c311a21131..2c7eac6095 100644
--- a/tools/editor/plugins/script_text_editor.h
+++ b/tools/editor/plugins/script_text_editor.h
@@ -98,6 +98,7 @@ protected:
void _edit_option(int p_op);
void _goto_line(int p_line) { goto_line(p_line); }
+ void _lookup_symbol(const String& p_symbol,int p_row, int p_column);
Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp
index aa66a2e0d9..3ab906f84e 100644
--- a/tools/editor/plugins/shader_graph_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp
@@ -2422,6 +2422,7 @@ void ShaderGraphView::_create_node(int p_id) {
colors.push_back("Color");
colors.push_back("LightColor");
colors.push_back("Light");
+ colors.push_back("ShadowColor");
colors.push_back("Diffuse");
colors.push_back("Specular");
colors.push_back("Emmision");
@@ -2434,6 +2435,7 @@ void ShaderGraphView::_create_node(int p_id) {
reals.push_back("ShadeParam");
reals.push_back("SpecularExp");
reals.push_back("LightAlpha");
+ reals.push_back("ShadowAlpha");
reals.push_back("PointSize");
reals.push_back("Discard");
diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp
index b884e0d111..b2eae2f6d1 100644
--- a/tools/editor/project_manager.cpp
+++ b/tools/editor/project_manager.cpp
@@ -1185,11 +1185,15 @@ ProjectManager::ProjectManager() {
{
int dpi_mode = EditorSettings::get_singleton()->get("global/hidpi_mode");
if (dpi_mode==0) {
- editor_set_hidpi( OS::get_singleton()->get_screen_dpi(0) > 150 );
+ editor_set_scale( OS::get_singleton()->get_screen_dpi(0) > 150 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x>2000 ? 2.0 : 1.0 );
+ } else if (dpi_mode==1) {
+ editor_set_scale(0.75);
} else if (dpi_mode==2) {
- editor_set_hidpi(true);
- } else {
- editor_set_hidpi(false);
+ editor_set_scale(1.0);
+ } else if (dpi_mode==3) {
+ editor_set_scale(1.5);
+ } else if (dpi_mode==4) {
+ editor_set_scale(2.0);
}
}
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index de10e68f33..6641297491 100644
--- a/tools/editor/property_editor.cpp
+++ b/tools/editor/property_editor.cpp
@@ -214,6 +214,12 @@ void CustomPropertyEditor::_menu_option(int p_which) {
}
}
} break;
+ case OBJ_MENU_NEW_SCRIPT: {
+
+ if (owner->cast_to<Node>())
+ EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(owner->cast_to<Node>());
+
+ } break;
default: {
@@ -850,8 +856,10 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
menu->clear();
menu->set_size(Size2(1,1));
-
- if (hint_text!="") {
+ if (p_name=="script/script" && hint_text=="Script" && owner->cast_to<Node>()) {
+ menu->add_icon_item(get_icon("Script","EditorIcons"),TTR("New Script"),OBJ_MENU_NEW_SCRIPT);
+ menu->add_separator();
+ } else if (hint_text!="") {
int idx=0;
for(int i=0;i<hint_text.get_slice_count(",");i++) {
@@ -3041,7 +3049,7 @@ void PropertyEditor::update_tree() {
if (E) {
descr=E->get().brief_description;
}
- class_descr_cache[type]=descr.world_wrap(80);
+ class_descr_cache[type]=descr.word_wrap(80);
}
@@ -3134,7 +3142,7 @@ void PropertyEditor::update_tree() {
if (E) {
for(int i=0;i<E->get().methods.size();i++) {
if (E->get().methods[i].name==setter.operator String()) {
- descr=E->get().methods[i].description.strip_edges().world_wrap(80);
+ descr=E->get().methods[i].description.strip_edges().word_wrap(80);
}
}
}
diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h
index 6c6c309d32..3fe332bf87 100644
--- a/tools/editor/property_editor.h
+++ b/tools/editor/property_editor.h
@@ -65,6 +65,7 @@ class CustomPropertyEditor : public Popup {
OBJ_MENU_COPY=4,
OBJ_MENU_PASTE=5,
OBJ_MENU_REIMPORT=6,
+ OBJ_MENU_NEW_SCRIPT=7,
TYPE_BASE_ID=100
};
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp
index 506dfd3889..9c4e641535 100644
--- a/tools/editor/scene_tree_dock.cpp
+++ b/tools/editor/scene_tree_dock.cpp
@@ -1841,6 +1841,12 @@ void SceneTreeDock::_focus_node() {
}
}
+void SceneTreeDock::open_script_dialog(Node* p_for_node) {
+
+ scene_tree->set_selected(p_for_node,false);
+ _tool_selected(TOOL_SCRIPT);
+}
+
void SceneTreeDock::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_tool_selected"),&SceneTreeDock::_tool_selected,DEFVAL(false));
diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h
index d92f12c34b..971013a568 100644
--- a/tools/editor/scene_tree_dock.h
+++ b/tools/editor/scene_tree_dock.h
@@ -175,6 +175,7 @@ public:
SceneTreeEditor *get_tree_editor() { return scene_tree; }
+ void open_script_dialog(Node* p_for_node);
SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelection *p_editor_selection,EditorData &p_editor_data);
};
diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp
index e5a97fa26e..53bfe8cc57 100644
--- a/tools/editor/scene_tree_editor.cpp
+++ b/tools/editor/scene_tree_editor.cpp
@@ -254,7 +254,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id)
String config_err = n->get_configuration_warning();
if (config_err==String())
return;
- config_err=config_err.world_wrap(80);
+ config_err=config_err.word_wrap(80);
warning->set_text(config_err);
warning->popup_centered_minsize();