diff options
44 files changed, 814 insertions, 303 deletions
diff --git a/core/math/vector3.h b/core/math/vector3.h index 528c4d37b3..910446023a 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -44,18 +44,6 @@ struct Vector3 { }; union { - -#ifdef USE_QUAD_VECTORS - - struct { - real_t x; - real_t y; - real_t z; - real_t _unused; - }; - real_t coord[4]; -#else - struct { real_t x; real_t y; @@ -63,7 +51,6 @@ struct Vector3 { }; real_t coord[3]; -#endif }; _FORCE_INLINE_ const real_t& operator[](int p_axis) const { diff --git a/core/object.h b/core/object.h index 66619a1dd4..d7b0f09df9 100644 --- a/core/object.h +++ b/core/object.h @@ -88,6 +88,7 @@ enum PropertyUsageFlags { PROPERTY_USAGE_RESTART_IF_CHANGED=4096, PROPERTY_USAGE_SCRIPT_VARIABLE=8192, PROPERTY_USAGE_STORE_IF_NULL=16384, + PROPERTY_USAGE_ANIMATE_AS_TRIGGER=32768, PROPERTY_USAGE_DEFAULT=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK, PROPERTY_USAGE_DEFAULT_INTL=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK|PROPERTY_USAGE_INTERNATIONALIZED, diff --git a/core/ustring.h b/core/ustring.h index 95096e8f76..8aceb0748c 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -46,11 +46,9 @@ public: operator const char*() {return get_data();}; }; -#ifndef CHARTYPE_16BITS + typedef wchar_t CharType; -#else -typedef wchar_t uint16_t; -#endif + struct StrRange { diff --git a/core/variant.cpp b/core/variant.cpp index 472d6cf568..81d10f379a 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -1445,12 +1445,12 @@ Variant::operator unsigned char() const { return 0; } -#ifndef CHARTYPE_16BITS + Variant::operator CharType() const { return operator unsigned int(); } -#endif + Variant::operator float() const { diff --git a/core/variant.h b/core/variant.h index b95223ecfb..9c93ecb73b 100644 --- a/core/variant.h +++ b/core/variant.h @@ -151,11 +151,7 @@ private: InputEvent *_input_event; Image *_image; void *_ptr; //generic pointer -#ifdef USE_QUAD_VECTORS - uint8_t _mem[sizeof(ObjData) > (sizeof(real_t)*5) ? sizeof(ObjData) : (sizeof(real_t)*5)]; // plane uses an extra real -#else uint8_t _mem[sizeof(ObjData) > (sizeof(real_t)*4) ? sizeof(ObjData) : (sizeof(real_t)*4)]; -#endif } _data; @@ -202,9 +198,8 @@ public: operator unsigned long() const; #endif -#ifndef CHARTYPE_16BITS + operator CharType() const; -#endif operator float() const; operator double() const; operator String() const; diff --git a/main/input_default.cpp b/main/input_default.cpp index ebf5763a6c..a70b66838a 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -355,7 +355,7 @@ void InputDefault::start_joy_vibration(int p_device, float p_weak_magnitude, flo vibration.weak_magnitude = p_weak_magnitude; vibration.strong_magnitude = p_strong_magnitude; vibration.duration = p_duration; - vibration.timestamp = OS::get_singleton()->get_unix_time(); + vibration.timestamp = OS::get_singleton()->get_ticks_usec(); joy_vibration[p_device] = vibration; } diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index 8dd68cf95a..0a77b96569 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -725,7 +725,7 @@ void GDTokenizerText::_advance() { if (hexa_found) { int val = str.hex_to_int(); _make_constant(val); - } else if (period_found) { + } else if (period_found || exponent_found) { real_t val = str.to_double(); //print_line("*%*%*%*% to convert: "+str+" result: "+rtos(val)); _make_constant(val); diff --git a/platform/android/AndroidManifest.xml.template b/platform/android/AndroidManifest.xml.template index 852a821c65..2a24c7cdc2 100644 --- a/platform/android/AndroidManifest.xml.template +++ b/platform/android/AndroidManifest.xml.template @@ -7,7 +7,7 @@ > <supports-screens android:smallScreens="true" android:normalScreens="true" - android:largeScreens="false" + android:largeScreens="true" android:xlargeScreens="true"/> <application android:label="@string/godot_project_name_string" android:icon="@drawable/icon" android:allowBackup="false" $$ADD_APPATTRIBUTE_CHUNKS$$ > diff --git a/platform/windows/joystick.cpp b/platform/windows/joystick.cpp index f8526b5ec1..663bbe3b9b 100644 --- a/platform/windows/joystick.cpp +++ b/platform/windows/joystick.cpp @@ -37,6 +37,7 @@ #endif DWORD WINAPI _xinput_get_state(DWORD dwUserIndex, XINPUT_STATE* pState) { return ERROR_DEVICE_NOT_CONNECTED; } +DWORD WINAPI _xinput_set_state(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration) { return ERROR_DEVICE_NOT_CONNECTED; } joystick_windows::joystick_windows() { @@ -50,6 +51,7 @@ joystick_windows::joystick_windows(InputDefault* _input, HWND* hwnd) { dinput = NULL; xinput_dll = NULL; xinput_get_state = NULL; + xinput_set_state = NULL; load_xinput(); @@ -300,6 +302,9 @@ void joystick_windows::probe_joysticks() { x_joysticks[i].attached = true; x_joysticks[i].id = id; + x_joysticks[i].ff_timestamp = 0; + x_joysticks[i].ff_end_timestamp = 0; + x_joysticks[i].vibrating = false; attached_joysticks[id] = true; input->joy_connection_changed(id, true, "XInput Gamepad","__XINPUT_DEVICE__"); } @@ -358,6 +363,20 @@ unsigned int joystick_windows::process_joysticks(unsigned int p_last_id) { p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_5, axis_correct(joy.state.Gamepad.bRightTrigger, true, true)); joy.last_packet = joy.state.dwPacketNumber; } + uint64_t timestamp = input->get_joy_vibration_timestamp(joy.id); + if (timestamp > joy.ff_timestamp) { + Vector2 strength = input->get_joy_vibration_strength(joy.id); + float duration = input->get_joy_vibration_duration(joy.id); + if (strength.x == 0 && strength.y == 0) { + joystick_vibration_stop_xinput(i, timestamp); + } else { + joystick_vibration_start_xinput(i, strength.x, strength.y, duration, timestamp); + } + } else if (joy.vibrating && joy.ff_end_timestamp != 0) { + uint64_t current_time = OS::get_singleton()->get_ticks_usec(); + if (current_time >= joy.ff_end_timestamp) + joystick_vibration_stop_xinput(i, current_time); + } } for (int i = 0; i < JOYSTICKS_MAX; i++) { @@ -401,7 +420,7 @@ unsigned int joystick_windows::process_joysticks(unsigned int p_last_id) { } } - // on mingw, these constants are not constants + // on mingw, these constants are not constants int count = 6; int axes[] = { DIJOFS_X, DIJOFS_Y, DIJOFS_Z, DIJOFS_RX, DIJOFS_RY, DIJOFS_RZ }; int values[] = { js.lX, js.lY, js.lZ, js.lRx, js.lRy, js.lRz }; @@ -500,9 +519,38 @@ InputDefault::JoyAxis joystick_windows::axis_correct(int p_val, bool p_xinput, b return jx; } +void joystick_windows::joystick_vibration_start_xinput(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp) { + xinput_gamepad &joy = x_joysticks[p_device]; + if (joy.attached) { + XINPUT_VIBRATION effect; + effect.wLeftMotorSpeed = (65535 * p_strong_magnitude); + effect.wRightMotorSpeed = (65535 * p_weak_magnitude); + if (xinput_set_state(p_device, &effect) == ERROR_SUCCESS) { + joy.ff_timestamp = p_timestamp; + joy.ff_end_timestamp = p_duration == 0 ? 0 : p_timestamp + (uint64_t)(p_duration * 1000000.0); + joy.vibrating = true; + } + } +} + +void joystick_windows::joystick_vibration_stop_xinput(int p_device, uint64_t p_timestamp) { + xinput_gamepad &joy = x_joysticks[p_device]; + if (joy.attached) { + XINPUT_VIBRATION effect; + effect.wLeftMotorSpeed = 0; + effect.wRightMotorSpeed = 0; + if (xinput_set_state(p_device, &effect) == ERROR_SUCCESS) { + joy.ff_timestamp = p_timestamp; + joy.vibrating = false; + } + } +} + + void joystick_windows::load_xinput() { xinput_get_state = &_xinput_get_state; + xinput_set_state = &_xinput_set_state; xinput_dll = LoadLibrary( "XInput1_4.dll" ); if (!xinput_dll) { xinput_dll = LoadLibrary("XInput1_3.dll"); @@ -519,12 +567,13 @@ void joystick_windows::load_xinput() { } XInputGetState_t func = (XInputGetState_t)GetProcAddress((HMODULE)xinput_dll, "XInputGetState"); - if (!func) { + XInputSetState_t set_func = (XInputSetState_t)GetProcAddress((HMODULE)xinput_dll, "XInputSetState"); + if (!func || !set_func) { unload_xinput(); return; } xinput_get_state = func; - return; + xinput_set_state = set_func; } void joystick_windows::unload_xinput() { diff --git a/platform/windows/joystick.h b/platform/windows/joystick.h index 332e86fbb8..77dee0466f 100644 --- a/platform/windows/joystick.h +++ b/platform/windows/joystick.h @@ -39,8 +39,8 @@ #define SAFE_RELEASE(x) \ if(x != NULL) \ { \ - x->Release(); \ - x = NULL; \ + x->Release(); \ + x = NULL; \ } #endif @@ -96,16 +96,23 @@ private: int id; bool attached; + bool vibrating; DWORD last_packet; XINPUT_STATE state; + uint64_t ff_timestamp; + uint64_t ff_end_timestamp; xinput_gamepad() { attached = false; + vibrating = false; + ff_timestamp = 0; + ff_end_timestamp = 0; last_packet = 0; } }; typedef DWORD (WINAPI *XInputGetState_t) (DWORD dwUserIndex, XINPUT_STATE* pState); + typedef DWORD (WINAPI *XInputSetState_t) (DWORD dwUserIndex, XINPUT_VIBRATION* pVibration); HWND* hWnd; HANDLE xinput_dll; @@ -132,9 +139,12 @@ private: bool have_device(const GUID &p_guid); bool is_xinput_device(const GUID* p_guid); bool setup_dinput_joystick(const DIDEVICEINSTANCE* instance); + void joystick_vibration_start_xinput(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp); + void joystick_vibration_stop_xinput(int p_device, uint64_t p_timestamp); InputDefault::JoyAxis axis_correct(int p_val, bool p_xinput = false, bool p_trigger = false, bool p_negate = false) const; XInputGetState_t xinput_get_state; + XInputSetState_t xinput_set_state; }; #endif diff --git a/scene/2d/sample_player_2d.cpp b/scene/2d/sample_player_2d.cpp index 4d719b532b..7c997b3f12 100644 --- a/scene/2d/sample_player_2d.cpp +++ b/scene/2d/sample_player_2d.cpp @@ -81,7 +81,7 @@ void SamplePlayer2D::_get_property_list(List<PropertyInfo> *p_list) const { } } - p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR)); + p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER)); } void SamplePlayer2D::_notification(int p_what) { diff --git a/scene/3d/spatial_sample_player.cpp b/scene/3d/spatial_sample_player.cpp index 0df921f208..4c5b2c240e 100644 --- a/scene/3d/spatial_sample_player.cpp +++ b/scene/3d/spatial_sample_player.cpp @@ -82,7 +82,7 @@ void SpatialSamplePlayer::_get_property_list(List<PropertyInfo> *p_list) const { } } - p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR)); + p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER)); } void SpatialSamplePlayer::_notification(int p_what) { diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp index b1123897b2..113e2c2278 100644 --- a/scene/animation/animation_cache.cpp +++ b/scene/animation/animation_cache.cpp @@ -301,7 +301,7 @@ void AnimationCache::set_all(float p_time, float p_delta) { } break; case Animation::TYPE_VALUE: { - if (animation->value_track_is_continuous(i)) { + if (animation->value_track_get_update_mode(i)==Animation::UPDATE_CONTINUOUS || (animation->value_track_get_update_mode(i)==Animation::UPDATE_DISCRETE && p_delta==0)) { Variant v = animation->value_track_interpolate(i,p_time); set_track_value(i,v); } else { diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 2399bee539..0ff6931dcd 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -174,7 +174,7 @@ void AnimationPlayer::_get_property_list( List<PropertyInfo> *p_list) const { hint+=E->get(); } - p_list->push_back( PropertyInfo( Variant::STRING, "playback/play", PROPERTY_HINT_ENUM, hint,PROPERTY_USAGE_EDITOR) ); + p_list->push_back( PropertyInfo( Variant::STRING, "playback/play", PROPERTY_HINT_ENUM, hint,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER) ); p_list->push_back( PropertyInfo( Variant::BOOL, "playback/active", PROPERTY_HINT_NONE,"" ) ); p_list->push_back( PropertyInfo( Variant::REAL, "playback/speed", PROPERTY_HINT_RANGE, "-64,64,0.01") ); @@ -421,12 +421,13 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p TrackNodeCache::PropertyAnim *pa = &E->get(); - if (a->value_track_is_continuous(i) || p_delta==0) { //delta == 0 means seek + if (a->value_track_get_update_mode(i)==Animation::UPDATE_CONTINUOUS || (p_delta==0 && a->value_track_get_update_mode(i)==Animation::UPDATE_DISCRETE)) { //delta == 0 means seek Variant value=a->value_track_interpolate(i,p_time); - if (p_delta==0 && value.get_type()==Variant::STRING) - continue; // doing this with strings is messy, should find another way + //thanks to trigger mode, this should be solved now.. + //if (p_delta==0 && value.get_type()==Variant::STRING) + // continue; // doing this with strings is messy, should find another way if (pa->accum_pass!=accum_pass) { ERR_CONTINUE( cache_update_prop_size >= NODE_CACHE_UPDATE_MAX ); cache_update_prop[cache_update_prop_size++]=pa; @@ -437,11 +438,12 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p } - } else if (p_allow_discrete) { + } else if (p_allow_discrete && p_delta!=0) { List<int> indices; a->value_track_get_key_indices(i,p_time,p_delta,&indices); + for(List<int>::Element *F=indices.front();F;F=F->next()) { Variant value=a->track_get_key_value(i,F->get()); @@ -538,6 +540,7 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd,float p_delta,flo float len=cd.from->animation->get_length(); bool loop=cd.from->animation->has_loop(); + bool loop_interpolation=cd.from->animation->has_loop_interpolation(); if (!loop) { @@ -563,10 +566,21 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd,float p_delta,flo } - } else { + } else if (loop_interpolation) { next_pos=Math::fposmod(next_pos,len); + } else { + + if (next_pos<0 or next_pos>len) { + if (!backwards) + next_pos=0; + else if (backwards) + next_pos=len; + } + // fix delta - not sure if needed here + delta=next_pos-cd.pos; + } cd.pos=next_pos; diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index 0f7ed1cb29..628edf09de 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_player.cpp @@ -825,7 +825,7 @@ void AnimationTreePlayer::_process_animation(float p_delta) { } break; case Animation::TYPE_VALUE: { ///< Set a value in a property, can be interpolated. - if (a->value_track_is_continuous(tr.local_track)) { + if (a->value_track_get_update_mode(tr.local_track)==Animation::UPDATE_CONTINUOUS) { Variant value = a->value_track_interpolate(tr.local_track,anim_list->time); Variant::blend(tr.track->value,value,blend,tr.track->value); } else { diff --git a/scene/audio/sample_player.cpp b/scene/audio/sample_player.cpp index bcd4354975..3827d40a71 100644 --- a/scene/audio/sample_player.cpp +++ b/scene/audio/sample_player.cpp @@ -152,7 +152,7 @@ void SamplePlayer::_get_property_list(List<PropertyInfo> *p_list) const { } } - p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR)); + p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER)); p_list->push_back( PropertyInfo( Variant::INT, "config/polyphony", PROPERTY_HINT_RANGE, "1,256,1")); p_list->push_back( PropertyInfo( Variant::OBJECT, "config/samples", PROPERTY_HINT_RESOURCE_TYPE, "SampleLibrary")); p_list->push_back( PropertyInfo( Variant::REAL, "default/volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01")); diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index bd24b43761..d6bbdf2d21 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -664,10 +664,15 @@ bool ColorPickerButton::is_editing_alpha() const{ } +ColorPicker *ColorPickerButton::get_picker() { + return picker; +} + void ColorPickerButton::_bind_methods(){ ObjectTypeDB::bind_method(_MD("set_color","color"),&ColorPickerButton::set_color); ObjectTypeDB::bind_method(_MD("get_color"),&ColorPickerButton::get_color); + ObjectTypeDB::bind_method(_MD("get_picker:ColorPicker"),&ColorPickerButton::get_picker); ObjectTypeDB::bind_method(_MD("set_edit_alpha","show"),&ColorPickerButton::set_edit_alpha); ObjectTypeDB::bind_method(_MD("is_editing_alpha"),&ColorPickerButton::is_editing_alpha); ObjectTypeDB::bind_method(_MD("_color_changed"),&ColorPickerButton::_color_changed); diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index 4559bc7391..f5de982200 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -133,6 +133,8 @@ public: void set_edit_alpha(bool p_show); bool is_editing_alpha() const; + ColorPicker *get_picker(); + ColorPickerButton(); }; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index ab556ede0c..52ef57cf1c 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -32,6 +32,11 @@ #include "print_string.h" #include "label.h" +static bool _is_text_char(CharType c) { + + return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || c=='_'; +} + void LineEdit::_input_event(InputEvent p_event) { @@ -54,26 +59,36 @@ void LineEdit::_input_event(InputEvent p_event) { if (b.pressed) { + shift_selection_check_pre(b.mod.shift); + set_cursor_at_pixel_pos(b.x); - if (b.doubleclick) { + if (b.mod.shift) { - selection.enabled=true; - selection.begin=0; - selection.end=text.length(); - selection.doubleclick=true; - } + selection_fill_at_cursor(); + selection.creating=true; - selection.drag_attempt=false; + } else { - if ((cursor_pos<selection.begin) || (cursor_pos>selection.end) || !selection.enabled) { + if (b.doubleclick) { - selection_clear(); - selection.cursor_start=cursor_pos; - selection.creating=true; - } else if (selection.enabled) { + selection.enabled=true; + selection.begin=0; + selection.end=text.length(); + selection.doubleclick=true; + } + + selection.drag_attempt=false; + + if ((cursor_pos<selection.begin) || (cursor_pos>selection.end) || !selection.enabled) { + + selection_clear(); + selection.cursor_start=cursor_pos; + selection.creating=true; + } else if (selection.enabled) { - selection.drag_attempt=true; + selection.drag_attempt=true; + } } // if (!editable) @@ -124,7 +139,7 @@ void LineEdit::_input_event(InputEvent p_event) { case (KEY_X): { // CUT - if(k.mod.command && editable) { + if(editable) { cut_text(); } @@ -132,15 +147,13 @@ void LineEdit::_input_event(InputEvent p_event) { case (KEY_C): { // COPY - if(k.mod.command) { - copy_text(); - } + copy_text(); } break; case (KEY_V): { // PASTE - if(k.mod.command && editable) { + if(editable) { paste_text(); } @@ -149,7 +162,7 @@ void LineEdit::_input_event(InputEvent p_event) { case (KEY_Z): { // Simple One level undo - if( k.mod.command && editable) { + if(editable) { undo(); @@ -160,7 +173,7 @@ void LineEdit::_input_event(InputEvent p_event) { case (KEY_U): { // Delete from start to cursor - if( k.mod.command && editable) { + if(editable) { selection_clear(); undo_text = text; @@ -184,7 +197,7 @@ void LineEdit::_input_event(InputEvent p_event) { case (KEY_Y): { // PASTE (Yank for unix users) - if(k.mod.command && editable) { + if(editable) { paste_text(); } @@ -192,7 +205,7 @@ void LineEdit::_input_event(InputEvent p_event) { } break; case (KEY_K): { // Delete from cursor_pos to end - if(k.mod.command && editable) { + if(editable) { selection_clear(); undo_text = text; @@ -215,7 +228,7 @@ void LineEdit::_input_event(InputEvent p_event) { } - if (!k.mod.alt && !k.mod.meta && !k.mod.command) { + if (!k.mod.meta) { bool handled=true; switch (code) { @@ -232,13 +245,45 @@ void LineEdit::_input_event(InputEvent p_event) { case KEY_BACKSPACE: { - if (editable) { - undo_text = text; - if (selection.enabled) - selection_delete(); - else - delete_char(); + if (!editable) + break; + + if (selection.enabled) { + undo_text=text; + selection_delete(); + break; + } + +#ifdef APPLE_STYLE_KEYS + if (k.mod.alt) { +#else + if (k.mod.alt) { + handled=false; + break; + } else if (k.mod.command) { +#endif + int cc=cursor_pos; + bool prev_char=false; + + while (cc>0) { + bool ischar=_is_text_char(text[cc-1]); + + if (prev_char && !ischar) + break; + + prev_char=ischar; + cc--; + } + + delete_text(cc, cursor_pos); + + set_cursor_pos(cc); + + } else { + undo_text=text; + delete_char(); } + } break; case KEY_KP_4: { if (k.unicode != 0) { @@ -248,8 +293,39 @@ void LineEdit::_input_event(InputEvent p_event) { // numlock disabled. fallthrough to key_left } case KEY_LEFT: { + shift_selection_check_pre(k.mod.shift); - set_cursor_pos(get_cursor_pos()-1); + +#ifdef APPLE_STYLE_KEYS + if (k.mod.command) { + set_cursor_pos(0); + } else if (k.mod.alt) { + +#else + if (k.mod.alt) { + handled=false; + break; + } else if (k.mod.command) { +#endif + bool prev_char=false; + int cc=cursor_pos; + + while (cc>0) { + bool ischar=_is_text_char(text[cc-1]); + + if (prev_char && !ischar) + break; + + prev_char=ischar; + cc--; + } + + set_cursor_pos(cc); + + } else { + set_cursor_pos(get_cursor_pos()-1); + } + shift_selection_check_post(k.mod.shift); } break; @@ -263,25 +339,88 @@ void LineEdit::_input_event(InputEvent p_event) { case KEY_RIGHT: { shift_selection_check_pre(k.mod.shift); - set_cursor_pos(get_cursor_pos()+1); + +#ifdef APPLE_STYLE_KEYS + if (k.mod.command) { + set_cursor_pos(text.length()); + } else if (k.mod.alt) { +#else + if (k.mod.alt) { + handled=false; + break; + } else if (k.mod.command) { +#endif + bool prev_char=false; + int cc=cursor_pos; + + while (cc<text.length()) { + bool ischar=_is_text_char(text[cc]); + + if (prev_char && !ischar) + break; + + prev_char=ischar; + cc++; + } + + set_cursor_pos(cc); + + } else { + set_cursor_pos(get_cursor_pos()+1); + } + shift_selection_check_post(k.mod.shift); + } break; case KEY_DELETE: { - if (k.mod.shift && !k.mod.command && !k.mod.alt && editable) { + if (!editable) + break; + + if (k.mod.shift && !k.mod.command && !k.mod.alt) { cut_text(); break; } - if (editable) { - undo_text = text; - if (selection.enabled) - selection_delete(); - else if (cursor_pos<text.length()) { + if (selection.enabled) { + undo_text=text; + selection_delete(); + break; + } + + int text_len = text.length(); + + if (cursor_pos==text_len) + break; // nothing to do + +#ifdef APPLE_STYLE_KEYS + if (k.mod.alt) { +#else + if (k.mod.alt) { + handled=false; + break; + } else if (k.mod.command) { +#endif + int cc=cursor_pos; + + bool prev_char=false; + + while (cc<text.length()) { - set_cursor_pos(get_cursor_pos()+1); - delete_char(); + bool ischar=_is_text_char(text[cc]); + + if (prev_char && !ischar) + break; + prev_char=ischar; + cc++; } + + delete_text(cursor_pos,cc); + + } else { + undo_text=text; + set_cursor_pos(cursor_pos+1); + delete_char(); } } break; @@ -339,8 +478,6 @@ void LineEdit::_input_event(InputEvent p_event) { } } - - selection.old_shift=k.mod.shift; update(); } @@ -577,7 +714,7 @@ void LineEdit::undo() { void LineEdit::shift_selection_check_pre(bool p_shift) { - if (!selection.old_shift && p_shift) { + if (!selection.enabled && p_shift) { selection.cursor_start=cursor_pos; } if (!p_shift) @@ -673,6 +810,39 @@ void LineEdit::delete_char() { _change_notify("text"); } +void LineEdit::delete_text(int p_from_column, int p_to_column) { + + undo_text = text; + + if (text.size() > 0) + { + Ref<Font> font = get_font("font"); + if (font != NULL) { + for (int i = p_from_column; i < p_to_column; i++) + cached_width -= font->get_char_size(text[i]).width; + } + } + else + { + cached_width = 0; + } + + text.erase(p_from_column,p_to_column-p_from_column); + cursor_pos-=CLAMP( cursor_pos-p_from_column, 0, p_to_column-p_from_column); + + if (cursor_pos>=text.length()) { + + cursor_pos=text.length(); + } + if (window_pos>cursor_pos) { + + window_pos=cursor_pos; + } + + emit_signal("text_changed",text); + _change_notify("text"); +} + void LineEdit::set_text(String p_text) { clear_internal(); @@ -820,46 +990,14 @@ void LineEdit::selection_clear() { selection.cursor_start=0; selection.enabled=false; selection.creating=false; - selection.old_shift=false; selection.doubleclick=false; update(); } - void LineEdit::selection_delete() { - if (selection.enabled) { - - undo_text = text; - - if (text.size() > 0) - { - Ref<Font> font = get_font("font"); - if (font != NULL) { - for (int i = selection.begin; i < selection.end; i++) - cached_width -= font->get_char_size(text[i]).width; - } - } - else - { - cached_width = 0; - } - - text.erase(selection.begin,selection.end-selection.begin); - cursor_pos-=CLAMP( cursor_pos-selection.begin, 0, selection.end-selection.begin); - - if (cursor_pos>=text.length()) { - - cursor_pos=text.length(); - } - if (window_pos>cursor_pos) { - - window_pos=cursor_pos; - } - - emit_signal("text_changed",text); - _change_notify("text"); - }; + if (selection.enabled) + delete_text(selection.begin,selection.end); selection_clear(); } @@ -946,7 +1084,6 @@ void LineEdit::select(int p_from, int p_to) { selection.begin=p_from; selection.end=p_to; selection.creating=false; - selection.old_shift=false; selection.doubleclick=false; update(); } diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index 586a54e950..ce3958db02 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -83,7 +83,6 @@ private: int cursor_start; bool enabled; bool creating; - bool old_shift; bool doubleclick; bool drag_attempt; } selection; @@ -123,6 +122,7 @@ public: void select_all(); void delete_char(); + void delete_text(int p_from_column, int p_to_column); void set_text(String p_text); String get_text() const; void set_cursor_pos(int p_pos); diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 37c68a295d..5eb579f1d2 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -412,8 +412,9 @@ void TabContainer::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - - call_deferred("set_current_tab",get_current_tab()); //wait until all changed theme + if (get_tab_count() > 0) { + call_deferred("set_current_tab",get_current_tab()); //wait until all changed theme + } } break; } } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 49d7527786..c08247095a 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1452,10 +1452,10 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { } if (mb.pressed) { - if (mb.button_index==BUTTON_WHEEL_UP) { + if (mb.button_index==BUTTON_WHEEL_UP && !mb.mod.command) { v_scroll->set_val( v_scroll->get_val() -3 ); } - if (mb.button_index==BUTTON_WHEEL_DOWN) { + if (mb.button_index==BUTTON_WHEEL_DOWN && !mb.mod.command) { v_scroll->set_val( v_scroll->get_val() +3 ); } if (mb.button_index==BUTTON_WHEEL_LEFT) { diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index f7d5ddc744..b6fc3eb419 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -38,6 +38,8 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) { set_length(p_value); else if (name=="loop") set_loop(p_value); + else if (name=="loop_interpolation") + set_loop_interpolation(p_value); else if (name=="step") set_step(p_value); else if (name.begins_with("tracks/")) { @@ -154,8 +156,20 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) { Dictionary d = p_value; ERR_FAIL_COND_V(!d.has("times"),false); ERR_FAIL_COND_V(!d.has("values"),false); - if (d.has("cont")) - vt->continuous=d["cont"]; + if (d.has("cont")) { + bool v = d["cont"]; + vt->update_mode=v?UPDATE_CONTINUOUS:UPDATE_DISCRETE; + } + + if (d.has("update")) { + int um =d["update"]; + if (um<0) + um=0; + else if (um>2) + um=2; + vt->update_mode=UpdateMode(um); + } + DVector<float> times=d["times"]; Array values=d["values"]; @@ -353,7 +367,7 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const { d["transitions"]=key_transitions; d["values"]=key_values; if (track_get_type(track)==TYPE_VALUE) { - d["cont"]=value_track_is_continuous(track); + d["update"]=value_track_get_update_mode(track); } r_ret=d; @@ -394,7 +408,7 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const { d["transitions"]=key_transitions; d["values"]=key_values; if (track_get_type(track)==TYPE_VALUE) { - d["cont"]=value_track_is_continuous(track); + d["update"]=value_track_get_update_mode(track); } r_ret=d; @@ -1221,7 +1235,7 @@ T Animation::_interpolate( const Vector< TKey<T> >& p_keys, float p_time, Inter float c=0; // prepare for all cases of interpolation - if (loop) { + if (loop and loop_interpolation) { // loop if (idx>=0) { @@ -1373,7 +1387,7 @@ Variant Animation::value_track_interpolate(int p_track, float p_time) const { bool ok; - Variant res = _interpolate( vt->values, p_time, vt->interpolation, &ok ); + Variant res = _interpolate( vt->values, p_time, vt->update_mode==UPDATE_CONTINUOUS?vt->interpolation:INTERPOLATION_NEAREST, &ok ); if (ok) { @@ -1461,28 +1475,30 @@ void Animation::value_track_get_key_indices(int p_track, float p_time, float p_d } -void Animation::value_track_set_continuous(int p_track, bool p_continuous) { +void Animation::value_track_set_update_mode(int p_track, UpdateMode p_mode) { ERR_FAIL_INDEX(p_track, tracks.size()); Track *t=tracks[p_track]; ERR_FAIL_COND( t->type != TYPE_VALUE ); + ERR_FAIL_INDEX(p_mode,3); ValueTrack * vt = static_cast<ValueTrack*>(t); - vt->continuous=p_continuous; + vt->update_mode=p_mode; } -bool Animation::value_track_is_continuous(int p_track) const{ +Animation::UpdateMode Animation::value_track_get_update_mode(int p_track) const { - ERR_FAIL_INDEX_V(p_track, tracks.size(), false); + ERR_FAIL_INDEX_V(p_track, tracks.size(), UPDATE_CONTINUOUS); Track *t=tracks[p_track]; - ERR_FAIL_COND_V( t->type != TYPE_VALUE, false ); + ERR_FAIL_COND_V( t->type != TYPE_VALUE, UPDATE_CONTINUOUS ); ValueTrack * vt = static_cast<ValueTrack*>(t); - return vt->continuous; + return vt->update_mode; } + void Animation::_method_track_get_key_indices_in_range(const MethodTrack * mt, float from_time, float to_time,List<int> *p_indices) const { if (from_time!=length && to_time==length) @@ -1607,10 +1623,19 @@ void Animation::set_loop(bool p_enabled) { loop=p_enabled; emit_changed(); } +void Animation::set_loop_interpolation(bool p_enabled) { + + loop_interpolation=p_enabled; + emit_changed(); +} bool Animation::has_loop() const { return loop; } +bool Animation::has_loop_interpolation() const { + + return loop_interpolation; +} void Animation::track_move_up(int p_track) { @@ -1676,8 +1701,8 @@ void Animation::_bind_methods() { ObjectTypeDB::bind_method(_MD("transform_track_interpolate","idx","time_sec"),&Animation::_transform_track_interpolate); - ObjectTypeDB::bind_method(_MD("value_track_set_continuous","idx","continuous"),&Animation::value_track_set_continuous); - ObjectTypeDB::bind_method(_MD("value_track_is_continuous","idx"),&Animation::value_track_is_continuous); + ObjectTypeDB::bind_method(_MD("value_track_set_update_mode","idx","mode"),&Animation::value_track_set_update_mode); + ObjectTypeDB::bind_method(_MD("value_track_get_update_mode","idx"),&Animation::value_track_get_update_mode); ObjectTypeDB::bind_method(_MD("value_track_get_key_indices","idx","time_sec","delta"),&Animation::_value_track_get_key_indices); @@ -1689,7 +1714,9 @@ void Animation::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_length"),&Animation::get_length); ObjectTypeDB::bind_method(_MD("set_loop","enabled"),&Animation::set_loop); + ObjectTypeDB::bind_method(_MD("set_loop_interpolation","enabled"),&Animation::set_loop_interpolation); ObjectTypeDB::bind_method(_MD("has_loop"),&Animation::has_loop); + ObjectTypeDB::bind_method(_MD("has_loop_interpolation"),&Animation::has_loop_interpolation); ObjectTypeDB::bind_method(_MD("set_step","size_sec"),&Animation::set_step); ObjectTypeDB::bind_method(_MD("get_step"),&Animation::get_step); @@ -1704,6 +1731,11 @@ void Animation::_bind_methods() { BIND_CONSTANT( INTERPOLATION_LINEAR ); BIND_CONSTANT( INTERPOLATION_CUBIC ); + BIND_CONSTANT( UPDATE_CONTINUOUS ); + BIND_CONSTANT( UPDATE_DISCRETE ); + BIND_CONSTANT( UPDATE_TRIGGER ); + + } void Animation::clear() { @@ -1712,6 +1744,7 @@ void Animation::clear() { memdelete( tracks[i] ); tracks.clear(); loop=false; + loop_interpolation=true; length=1; } @@ -1971,6 +2004,7 @@ Animation::Animation() { step=0.1; loop=false; + loop_interpolation=true; length=1; } diff --git a/scene/resources/animation.h b/scene/resources/animation.h index 1f2d9b80ab..8b677fe0da 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -58,6 +58,13 @@ public: INTERPOLATION_CUBIC }; + enum UpdateMode { + UPDATE_CONTINUOUS, + UPDATE_DISCRETE, + UPDATE_TRIGGER, + + }; + private: struct Track { @@ -105,10 +112,11 @@ private: struct ValueTrack : public Track { - bool continuous; + UpdateMode update_mode; + bool update_on_seek; Vector< TKey<Variant> > values; - ValueTrack() { type=TYPE_VALUE; continuous=true; } + ValueTrack() { type=TYPE_VALUE; update_mode=UPDATE_CONTINUOUS; } }; @@ -163,6 +171,7 @@ private: float length; float step; bool loop; + bool loop_interpolation; // bind helpers private: @@ -253,8 +262,9 @@ public: Variant value_track_interpolate(int p_track, float p_time) const; void value_track_get_key_indices(int p_track, float p_time, float p_delta,List<int> *p_indices) const; - void value_track_set_continuous(int p_track, bool p_continuous); - bool value_track_is_continuous(int p_track) const; + void value_track_set_update_mode(int p_track, UpdateMode p_mode); + UpdateMode value_track_get_update_mode(int p_track) const; + void method_track_get_key_indices(int p_track, float p_time, float p_delta,List<int> *p_indices) const; Vector<Variant> method_track_get_params(int p_track,int p_key_idx) const; @@ -265,7 +275,9 @@ public: float get_length() const; void set_loop(bool p_enabled); + void set_loop_interpolation(bool p_enabled); bool has_loop() const; + bool has_loop_interpolation() const; void set_step(float p_step); float get_step() const; @@ -281,5 +293,8 @@ public: VARIANT_ENUM_CAST( Animation::TrackType ); VARIANT_ENUM_CAST( Animation::InterpolationType ); +VARIANT_ENUM_CAST( Animation::UpdateMode ); + + #endif diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 09c4f4e8cb..bb40c5ed93 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -555,7 +555,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) { if (tex.texture.is_null()) { tex.texture.instance(); - tex.texture->create_from_image(img,0/*Texture::FLAG_FILTER*/); + tex.texture->create_from_image(img,Texture::FLAG_VIDEO_SURFACE); } else { tex.texture->set_data(img); //update } diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index e6356d3366..a1a1f0a935 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -149,12 +149,6 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) { return true; } - if (what=="custom_aabb") { - - surface_set_custom_aabb(idx,p_value); - return true; - } - return false; } diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp index 08b90b5408..dd3c3fee32 100644 --- a/tools/editor/animation_editor.cpp +++ b/tools/editor/animation_editor.cpp @@ -754,7 +754,7 @@ void AnimationKeyEditor::_menu_track(int p_type) { undo_redo->add_undo_method(animation.ptr(),"track_set_interpolation_type",idx,animation->track_get_interpolation_type(idx)); if (animation->track_get_type(idx)==Animation::TYPE_VALUE) { - undo_redo->add_undo_method(animation.ptr(),"value_track_set_continuous",idx,animation->value_track_is_continuous(idx)); + undo_redo->add_undo_method(animation.ptr(),"value_track_set_update_mode",idx,animation->value_track_get_update_mode(idx)); } @@ -918,7 +918,7 @@ void AnimationKeyEditor::_menu_track(int p_type) { pos=animation->get_length(); timeline_pos=pos; track_pos->update(); - emit_signal("timeline_changed",pos); + emit_signal("timeline_changed",pos,true); } break; case TRACK_MENU_PREV_STEP: { @@ -934,7 +934,7 @@ void AnimationKeyEditor::_menu_track(int p_type) { pos=0; timeline_pos=pos; track_pos->update(); - emit_signal("timeline_changed",pos); + emit_signal("timeline_changed",pos,true); } break; @@ -1169,8 +1169,9 @@ void AnimationKeyEditor::_track_editor_draw() { get_icon("InterpCubic","EditorIcons") }; Ref<Texture> cont_icon[3]={ + get_icon("TrackContinuous","EditorIcons"), get_icon("TrackDiscrete","EditorIcons"), - get_icon("TrackContinuous","EditorIcons") + get_icon("TrackTrigger","EditorIcons") }; Ref<Texture> type_icon[3]={ get_icon("KeyValue","EditorIcons"), @@ -1442,15 +1443,15 @@ void AnimationKeyEditor::_track_editor_draw() { if (animation->track_get_type(idx)==Animation::TYPE_VALUE) { - int continuous = animation->value_track_is_continuous(idx)?1:0; + int umode = animation->value_track_get_update_mode(idx); icon_ofs.x-=hsep; icon_ofs.x-=down_icon->get_width(); te->draw_texture(down_icon,icon_ofs); icon_ofs.x-=hsep; - icon_ofs.x-=cont_icon[continuous]->get_width(); - te->draw_texture(cont_icon[continuous],icon_ofs); + icon_ofs.x-=cont_icon[umode]->get_width(); + te->draw_texture(cont_icon[umode],icon_ofs); } else { icon_ofs.x -= hsep*2 + cont_icon[0]->get_width() + down_icon->get_width(); @@ -1626,8 +1627,8 @@ void AnimationKeyEditor::_track_menu_selected(int p_idx) { ERR_FAIL_INDEX(cont_editing,animation->get_track_count()); undo_redo->create_action(TTR("Anim Track Change Value Mode")); - undo_redo->add_do_method(animation.ptr(),"value_track_set_continuous",cont_editing,p_idx); - undo_redo->add_undo_method(animation.ptr(),"value_track_set_continuous",cont_editing,animation->value_track_is_continuous(cont_editing)); + undo_redo->add_do_method(animation.ptr(),"value_track_set_update_mode",cont_editing,p_idx); + undo_redo->add_undo_method(animation.ptr(),"value_track_set_update_mode",cont_editing,animation->value_track_get_update_mode(cont_editing)); undo_redo->commit_action(); } @@ -1820,8 +1821,9 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { get_icon("InterpCubic","EditorIcons") }; Ref<Texture> cont_icon[3]={ + get_icon("TrackContinuous","EditorIcons"), get_icon("TrackDiscrete","EditorIcons"), - get_icon("TrackContinuous","EditorIcons") + get_icon("TrackTrigger","EditorIcons") }; Ref<Texture> type_icon[3]={ get_icon("KeyValue","EditorIcons"), @@ -1972,7 +1974,7 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { click.click=ClickOver::CLICK_DRAG_TIMELINE; click.at=Point2(mb.x,mb.y); click.to=click.at; - emit_signal("timeline_changed",pos); + emit_signal("timeline_changed",pos,false); } @@ -2184,8 +2186,8 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { track_menu->clear(); track_menu->set_size(Point2(1,1)); - static const char *cont_name[3]={"Discrete","Continuous"}; - for(int i=0;i<2;i++) { + String cont_name[3]={TTR("Continuous"),TTR("Discrete"),TTR("Trigger")}; + for(int i=0;i<3;i++) { track_menu->add_icon_item(cont_icon[i],cont_name[i]); } @@ -2594,7 +2596,7 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { } timeline_pos=pos; - emit_signal("timeline_changed",pos); + emit_signal("timeline_changed",pos,true); @@ -2920,6 +2922,7 @@ void AnimationKeyEditor::_notification(int p_what) { edit_button->connect("pressed",this,"_toggle_edit_curves"); loop->set_icon(get_icon("Loop","EditorIcons")); + loop_interpolation->set_icon(get_icon("LoopInterpolation","EditorIcons")); curve_edit->connect("transition_changed",this,"_curve_transition_changed"); //edit_button->add_color_override("font_color",get_color("font_color","Tree")); @@ -2940,8 +2943,9 @@ void AnimationKeyEditor::_notification(int p_what) { get_icon("InterpCubic","EditorIcons") }; Ref<Texture> cont_icon[3]={ + get_icon("TrackContinuous","EditorIcons"), get_icon("TrackDiscrete","EditorIcons"), - get_icon("TrackContinuous","EditorIcons") + get_icon("TrackTrigger","EditorIcons") }; //right_data_size_cache = remove_icon->get_width() + move_up_icon->get_width() + move_down_icon->get_width() + down_icon->get_width() *2 + interp_icon[0]->get_width() + cont_icon[0]->get_width() + add_key_icon->get_width() + hsep*11; @@ -3009,6 +3013,7 @@ void AnimationKeyEditor::_update_menu() { length->set_val(animation->get_length()); loop->set_pressed(animation->has_loop()); + loop_interpolation->set_pressed(animation->has_loop_interpolation()); step->set_val(animation->get_step()); } @@ -3311,7 +3316,7 @@ int AnimationKeyEditor::_confirm_insert(InsertData p_id,int p_last_track) { created=true; undo_redo->create_action(TTR("Anim Insert Track & Key")); - bool continuous=false; + Animation::UpdateMode update_mode=Animation::UPDATE_DISCRETE; if (p_id.type==Animation::TYPE_VALUE) { //wants a new tack @@ -3324,16 +3329,21 @@ int AnimationKeyEditor::_confirm_insert(InsertData p_id,int p_last_track) { PropertyInfo h = _find_hint_for_track(animation->get_track_count()-1,np); animation->remove_track(animation->get_track_count()-1); //hack - - continuous = - h.type==Variant::REAL || + if ( h.type==Variant::REAL || h.type==Variant::VECTOR2 || h.type==Variant::RECT2 || h.type==Variant::VECTOR3 || h.type==Variant::_AABB || h.type==Variant::QUAT || h.type==Variant::COLOR || - h.type==Variant::TRANSFORM ; + h.type==Variant::TRANSFORM ) { + + update_mode=Animation::UPDATE_CONTINUOUS; + } + + if (h.usage&PROPERTY_USAGE_ANIMATE_AS_TRIGGER) { + update_mode=Animation::UPDATE_TRIGGER; + } } } @@ -3342,7 +3352,7 @@ int AnimationKeyEditor::_confirm_insert(InsertData p_id,int p_last_track) { undo_redo->add_do_method(animation.ptr(),"add_track",p_id.type); undo_redo->add_do_method(animation.ptr(),"track_set_path",p_id.track_idx,p_id.path); if (p_id.type==Animation::TYPE_VALUE) - undo_redo->add_do_method(animation.ptr(),"value_track_set_continuous",p_id.track_idx,continuous); + undo_redo->add_do_method(animation.ptr(),"value_track_set_update_mode",p_id.track_idx,update_mode); } else { undo_redo->create_action(TTR("Anim Insert Key")); @@ -3459,6 +3469,21 @@ void AnimationKeyEditor::_animation_loop_changed() { } +void AnimationKeyEditor::_animation_loop_interpolation_changed() { + + if (updating) + return; + + if (!animation.is_null()) { + + undo_redo->create_action(TTR("Change Anim Loop Interpolation")); + undo_redo->add_do_method(animation.ptr(),"set_loop_interpolation",loop_interpolation->is_pressed()); + undo_redo->add_undo_method(animation.ptr(),"set_loop_interpolation",!loop_interpolation->is_pressed()); + undo_redo->commit_action(); + } + +} + void AnimationKeyEditor::_create_value_item(int p_type) { @@ -3536,7 +3561,7 @@ void AnimationKeyEditor::_insert_delay() { pos=animation->get_length(); timeline_pos=pos; track_pos->update(); - emit_signal("timeline_changed",pos); + emit_signal("timeline_changed",pos,true); } insert_queue=false; } @@ -3744,6 +3769,7 @@ void AnimationKeyEditor::_bind_methods() { ObjectTypeDB::bind_method(_MD("_animation_loop_changed"),&AnimationKeyEditor::_animation_loop_changed); + ObjectTypeDB::bind_method(_MD("_animation_loop_interpolation_changed"),&AnimationKeyEditor::_animation_loop_interpolation_changed); ObjectTypeDB::bind_method(_MD("_animation_len_changed"),&AnimationKeyEditor::_animation_len_changed); ObjectTypeDB::bind_method(_MD("_create_value_item"),&AnimationKeyEditor::_create_value_item); ObjectTypeDB::bind_method(_MD("_pane_drag"),&AnimationKeyEditor::_pane_drag); @@ -3759,7 +3785,7 @@ void AnimationKeyEditor::_bind_methods() { ADD_SIGNAL( MethodInfo("resource_selected", PropertyInfo( Variant::OBJECT, "res"),PropertyInfo( Variant::STRING, "prop") ) ); ADD_SIGNAL( MethodInfo("keying_changed" ) ); - ADD_SIGNAL( MethodInfo("timeline_changed", PropertyInfo(Variant::REAL,"pos") ) ); + ADD_SIGNAL( MethodInfo("timeline_changed", PropertyInfo(Variant::REAL,"pos"), PropertyInfo(Variant::BOOL,"drag") ) ); ADD_SIGNAL( MethodInfo("animation_len_changed", PropertyInfo(Variant::REAL,"len") ) ); ADD_SIGNAL( MethodInfo("animation_step_changed", PropertyInfo(Variant::REAL,"step") ) ); ADD_SIGNAL( MethodInfo("key_edited", PropertyInfo(Variant::INT,"track"), PropertyInfo(Variant::INT,"key") ) ); @@ -3854,6 +3880,12 @@ AnimationKeyEditor::AnimationKeyEditor() { hb->add_child(loop); loop->set_tooltip(TTR("Enable/Disable looping in animation.")); + loop_interpolation = memnew( ToolButton ); + loop_interpolation->set_toggle_mode(true); + loop_interpolation->connect("pressed",this,"_animation_loop_interpolation_changed"); + hb->add_child(loop_interpolation); + loop_interpolation->set_tooltip(TTR("Enable/Disable interpolation when looping animation.")); + hb->add_child( memnew( VSeparator ) ); menu_add_track = memnew( MenuButton ); diff --git a/tools/editor/animation_editor.h b/tools/editor/animation_editor.h index 413c73b4b9..c8de1d87c1 100644 --- a/tools/editor/animation_editor.h +++ b/tools/editor/animation_editor.h @@ -173,6 +173,7 @@ class AnimationKeyEditor : public VBoxContainer { //MenuButton *menu; SpinBox *length; Button *loop; + Button *loop_interpolation; bool keying; ToolButton *edit_button; ToolButton *move_up_button; @@ -238,6 +239,7 @@ class AnimationKeyEditor : public VBoxContainer { void _animation_len_changed(float p_len); void _animation_loop_changed(); + void _animation_loop_interpolation_changed(); void _step_changed(float p_len); struct InsertData { diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index be5d9c47ff..644478923c 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -30,6 +30,7 @@ #include "editor_settings.h" #include "scene/gui/margin_container.h" #include "scene/gui/separator.h" +#include "scene/resources/dynamic_font.h" #include "os/keyboard.h" void GotoLineDialog::popup_find_line(TextEdit *p_edit) { @@ -974,6 +975,48 @@ FindReplaceDialog::FindReplaceDialog() { /*** CODE EDITOR ****/ +void CodeTextEditor::_text_editor_input_event(const InputEvent& p_event) { + + if (p_event.type==InputEvent::MOUSE_BUTTON) { + + const InputEventMouseButton& mb=p_event.mouse_button; + + if (mb.pressed && mb.mod.command) { + + if (mb.button_index==BUTTON_WHEEL_UP) { + + font_resize_val+=1; + + if (font_resize_timer->get_time_left()==0) + font_resize_timer->start(); + + } else if (mb.button_index==BUTTON_WHEEL_DOWN) { + + font_resize_val-=1; + + if (font_resize_timer->get_time_left()==0) + font_resize_timer->start(); + } + } + } else if (p_event.type==InputEvent::KEY) { + + const InputEventKey& k=p_event.key; + + if (k.pressed && k.mod.command) { + + if (k.scancode==KEY_0) { // reset source font size to default + + Ref<DynamicFont> font = text_editor->get_font("font"); + + if (font.is_valid()) { + EditorSettings::get_singleton()->set("global/source_font_size",14); + font->set_size(14); + } + } + } + } +} + void CodeTextEditor::_line_col_changed() { String text = String()+TTR("Line:")+" "+itos(text_editor->cursor_get_line()+1)+", "+TTR("Col:")+" "+itos(text_editor->cursor_get_column()); @@ -1011,6 +1054,22 @@ void CodeTextEditor::_complete_request() { text_editor->code_complete(strs); } +void CodeTextEditor::_font_resize_timeout() { + + Ref<DynamicFont> font = text_editor->get_font("font"); + + if (font.is_valid()) { + int size=font->get_size()+font_resize_val; + + if (size>=8 && size<=96) { + EditorSettings::get_singleton()->set("global/source_font_size",size); + font->set_size(size); + } + + font_resize_val=0; + } +} + void CodeTextEditor::set_error(const String& p_error) { if (p_error!="") { @@ -1026,15 +1085,15 @@ void CodeTextEditor::_update_font() { // FONTS String editor_font = EDITOR_DEF("text_editor/font", ""); - bool font_overrode = false; + bool font_overridden = false; if (editor_font!="") { Ref<Font> fnt = ResourceLoader::load(editor_font); if (fnt.is_valid()) { text_editor->add_font_override("font",fnt); - font_overrode = true; + font_overridden = true; } } - if(!font_overrode) + if(!font_overridden) text_editor->add_font_override("font",get_font("source","EditorFonts")); } @@ -1078,12 +1137,14 @@ void CodeTextEditor::_notification(int p_what) { void CodeTextEditor::_bind_methods() { + ObjectTypeDB::bind_method("_text_editor_input_event",&CodeTextEditor::_text_editor_input_event); ObjectTypeDB::bind_method("_line_col_changed",&CodeTextEditor::_line_col_changed); ObjectTypeDB::bind_method("_text_changed",&CodeTextEditor::_text_changed); ObjectTypeDB::bind_method("_on_settings_change",&CodeTextEditor::_on_settings_change); ObjectTypeDB::bind_method("_text_changed_idle_timeout",&CodeTextEditor::_text_changed_idle_timeout); ObjectTypeDB::bind_method("_code_complete_timer_timeout",&CodeTextEditor::_code_complete_timer_timeout); ObjectTypeDB::bind_method("_complete_request",&CodeTextEditor::_complete_request); + ObjectTypeDB::bind_method("_font_resize_timeout",&CodeTextEditor::_font_resize_timeout); } CodeTextEditor::CodeTextEditor() { @@ -1139,6 +1200,7 @@ CodeTextEditor::CodeTextEditor() { line_col->set_valign(Label::VALIGN_CENTER); + text_editor->connect("input_event", this,"_text_editor_input_event"); text_editor->connect("cursor_changed", this,"_line_col_changed"); text_editor->connect("text_changed", this,"_text_changed"); text_editor->connect("request_completion", this,"_complete_request"); @@ -1151,5 +1213,12 @@ CodeTextEditor::CodeTextEditor() { code_complete_timer->connect("timeout", this,"_code_complete_timer_timeout"); + font_resize_val=0; + font_resize_timer = memnew(Timer); + add_child(font_resize_timer); + font_resize_timer->set_one_shot(true); + font_resize_timer->set_wait_time(0.07); + font_resize_timer->connect("timeout", this, "_font_resize_timeout"); + EditorSettings::get_singleton()->connect("settings_changed",this,"_on_settings_change"); } diff --git a/tools/editor/code_editor.h b/tools/editor/code_editor.h index 2e1bf46c02..bdfd295ded 100644 --- a/tools/editor/code_editor.h +++ b/tools/editor/code_editor.h @@ -202,22 +202,27 @@ class CodeTextEditor : public VBoxContainer { Timer *code_complete_timer; bool enable_complete_timer; + Timer *font_resize_timer; + int font_resize_val; + Label *error; void _on_settings_change(); void _update_font(); void _complete_request(); + void _font_resize_timeout(); + + void _text_editor_input_event(const InputEvent& p_event); + protected: void set_error(const String& p_error); - virtual void _load_theme_settings() {} virtual void _validate_script()=0; virtual void _code_complete_script(const String& p_code, List<String>* r_options) {}; - void _text_changed_idle_timeout(); void _code_complete_timer_timeout(); void _text_changed(); @@ -225,7 +230,6 @@ protected: void _notification(int); static void _bind_methods(); - public: TextEdit *get_text_edit() { return text_editor; } diff --git a/tools/editor/editor_dir_dialog.cpp b/tools/editor/editor_dir_dialog.cpp index fda2d9bacf..a6e231cf18 100644 --- a/tools/editor/editor_dir_dialog.cpp +++ b/tools/editor/editor_dir_dialog.cpp @@ -78,6 +78,11 @@ void EditorDirDialog::_update_dir(TreeItem* p_item) { void EditorDirDialog::reload() { + if (!is_visible()) { + must_reload=true; + return; + } + tree->clear(); TreeItem *root = tree->create_item(); root->set_metadata(0,"res://"); @@ -85,6 +90,8 @@ void EditorDirDialog::reload() { root->set_text(0,"/"); _update_dir(root); _item_collapsed(root); + must_reload=false; + } @@ -96,6 +103,12 @@ void EditorDirDialog::_notification(int p_what) { EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"reload"); } + + if (p_what==NOTIFICATION_VISIBILITY_CHANGED) { + if (must_reload && is_visible()) { + reload(); + } + } } void EditorDirDialog::_item_collapsed(Object* _p_item){ @@ -243,6 +256,8 @@ EditorDirDialog::EditorDirDialog() { get_ok()->set_text(TTR("Choose")); + must_reload=false; + } diff --git a/tools/editor/editor_dir_dialog.h b/tools/editor/editor_dir_dialog.h index 94facceed4..69f9850c30 100644 --- a/tools/editor/editor_dir_dialog.h +++ b/tools/editor/editor_dir_dialog.h @@ -54,6 +54,8 @@ class EditorDirDialog : public ConfirmationDialog { void ok_pressed(); + bool must_reload; + protected: diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 73af310877..dd50b720f7 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -29,8 +29,7 @@ #include "version.h" #include "editor_node.h" #include "print_string.h" -#include "editor_icons.h" -#include "editor_fonts.h" +#include "editor_themes.h" #include "editor_help.h" #include "core/io/resource_saver.h" @@ -2118,7 +2117,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { String existing; if (extensions.size()) { String root_name(get_edited_scene()->get_name()); - existing=root_name+"."+extensions.front()->get().to_lower(); + existing=root_name+".tscn";//+extensions.front()->get().to_lower(); } file->set_current_path(existing); @@ -5227,44 +5226,9 @@ EditorNode::EditorNode() { theme_base->add_child(gui_base); gui_base->set_area_as_parent_rect(); - - theme = Ref<Theme>( memnew( Theme ) ); - theme_base->set_theme( theme ); - editor_register_icons(theme); - editor_register_fonts(theme); - - //theme->set_icon("folder","EditorFileDialog",Theme::get_default()->get_icon("folder","EditorFileDialog")); - //theme->set_color("files_disabled","EditorFileDialog",Color(0,0,0,0.7)); - - String global_font = EditorSettings::get_singleton()->get("global/custom_font"); - if (global_font!="") { - Ref<Font> fnt = ResourceLoader::load(global_font); - if (fnt.is_valid()) { - theme->set_default_theme_font(fnt); - } - } - - - - 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_draw_center(false); - theme->set_stylebox("EditorFocus","EditorStyles",focus_sbt); - - - String custom_theme = EditorSettings::get_singleton()->get("global/custom_theme"); - if (custom_theme!="") { - Ref<Theme> theme = ResourceLoader::load(custom_theme); - if (theme.is_valid()) { - gui_base->set_theme(theme); - } - } - - + theme_base->set_theme( create_default_theme() ); + theme = create_editor_theme(); + gui_base->set_theme(theme); resource_preview = memnew( EditorResourcePreview ); add_child(resource_preview); @@ -5550,8 +5514,8 @@ EditorNode::EditorNode() { p->add_submenu_item(TTR("Convert To.."),"Export"); pm_export->add_item(TTR("Translatable Strings.."),FILE_DUMP_STRINGS); pm_export->add_separator(); - pm_export->add_item(TTR("MeshLibrary.."),FILE_EXPORT_MESH_LIBRARY); - pm_export->add_item(TTR("TileSet.."),FILE_EXPORT_TILESET); + pm_export->add_shortcut(ED_SHORTCUT("editor/convert_to_MeshLibrary", TTR("MeshLibrary..")), FILE_EXPORT_MESH_LIBRARY); + pm_export->add_shortcut(ED_SHORTCUT("editor/convert_to_TileSet", TTR("TileSet..")), FILE_EXPORT_TILESET); pm_export->connect("item_pressed",this,"_menu_option"); p->add_separator(); diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 9b91f3969a..0fffaca782 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/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); set("global/source_font_size",14); - hints["global/source_font_size"]=PropertyInfo(Variant::INT,"global/source_font_size",PROPERTY_HINT_RANGE,"10,40,1",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED); + hints["global/source_font_size"]=PropertyInfo(Variant::INT,"global/source_font_size",PROPERTY_HINT_RANGE,"8,96,1",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED); set("global/custom_font",""); hints["global/custom_font"]=PropertyInfo(Variant::STRING,"global/custom_font",PROPERTY_HINT_GLOBAL_FILE,"*.fnt",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED); set("global/custom_theme",""); diff --git a/tools/editor/editor_themes.cpp b/tools/editor/editor_themes.cpp new file mode 100644 index 0000000000..44e21aee85 --- /dev/null +++ b/tools/editor/editor_themes.cpp @@ -0,0 +1,77 @@ +/*************************************************************************/ +/* editor_themes.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "editor_themes.h" +#include "editor_icons.h" +#include "editor_fonts.h" +#include "editor_settings.h" +#include "core/io/resource_loader.h" + +Ref<Theme> create_default_theme() +{ + Ref<Theme> theme = Ref<Theme>( memnew( Theme ) ); + + editor_register_fonts(theme); + editor_register_icons(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_draw_center(false); + theme->set_stylebox("EditorFocus","EditorStyles",focus_sbt); + + return theme; +} + +Ref<Theme> create_editor_theme() +{ + Ref<Theme> theme = NULL; + + String custom_theme = EditorSettings::get_singleton()->get("global/custom_theme"); + if (custom_theme!="") { + theme = ResourceLoader::load(custom_theme); + } + + if (theme.is_null() || !theme.is_valid()) { + theme = create_default_theme(); + } + + String global_font = EditorSettings::get_singleton()->get("global/custom_font"); + if (global_font!="") { + Ref<Font> fnt = ResourceLoader::load(global_font); + if (fnt.is_valid()) { + theme->set_default_theme_font(fnt); + } + } + + return theme; +} diff --git a/tools/editor/editor_themes.h b/tools/editor/editor_themes.h new file mode 100644 index 0000000000..dbff8b3079 --- /dev/null +++ b/tools/editor/editor_themes.h @@ -0,0 +1,38 @@ +/*************************************************************************/ +/* editor_themes.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef EDITOR_THEMES_H +#define EDITOR_THEMES_H + +#include "scene/resources/theme.h" + +Ref<Theme> create_default_theme(); + +Ref<Theme> create_editor_theme(); + +#endif diff --git a/tools/editor/icons/icon_loop_interpolation.png b/tools/editor/icons/icon_loop_interpolation.png Binary files differnew file mode 100644 index 0000000000..2f92ab7bf3 --- /dev/null +++ b/tools/editor/icons/icon_loop_interpolation.png diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index 2fbc4af94f..a6de849e44 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -528,6 +528,16 @@ class EditorFontImportDialog : public ConfirmationDialog { dest->get_line_edit()->set_text(dest->get_line_edit()->get_text().get_base_dir() + "/" + source->get_line_edit()->get_text().get_file().basename() + ".fnt" ); } + if (dest->get_line_edit()->get_text().extension() == dest->get_line_edit()->get_text()) { + dest->get_line_edit()->set_text(dest->get_line_edit()->get_text() + ".fnt"); + } + + if (dest->get_line_edit()->get_text().extension().to_lower() != "fnt") { + error_dialog->set_text("Invalid file extension. \nPlease use .fnt"); + error_dialog->popup_centered(Size2(200,100)); + return; + } + Ref<ResourceImportMetadata> rimd = get_rimd(); if (rimd.is_null()) { diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index f346306f61..ed766c6598 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -30,6 +30,7 @@ #include "globals.h" #include "tools/editor/editor_node.h" #include "scene/resources/packed_scene.h" +#include "scene/resources/box_shape.h" #include "os/file_access.h" #include "scene/3d/path.h" #include "scene/animation/animation_player.h" @@ -1073,7 +1074,7 @@ const EditorSceneImportDialog::FlagInfo EditorSceneImportDialog::scene_flag_name {EditorSceneImportPlugin::SCENE_FLAG_LINEARIZE_DIFFUSE_TEXTURES,("Actions"),"SRGB->Linear Of Diffuse Textures",false}, {EditorSceneImportPlugin::SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY,("Actions"),"Convert Normal Maps to XY",true}, {EditorSceneImportPlugin::SCENE_FLAG_SET_LIGHTMAP_TO_UV2_IF_EXISTS,("Actions"),"Set Material Lightmap to UV2 if Tex2Array Exists",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_COLLISIONS,("Create"),"Create Collisions (-col},-colonly)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_CREATE_COLLISIONS,("Create"),"Create Collisions and/or Rigid Bodies (-col,-colonly,-rigid)",true}, {EditorSceneImportPlugin::SCENE_FLAG_CREATE_PORTALS,("Create"),"Create Portals (-portal)",true}, {EditorSceneImportPlugin::SCENE_FLAG_CREATE_ROOMS,("Create"),"Create Rooms (-room)",true}, {EditorSceneImportPlugin::SCENE_FLAG_SIMPLIFY_ROOMS,("Create"),"Simplify Rooms",false}, @@ -1745,6 +1746,49 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> colshape->set_owner(sb->get_owner()); } + } else if (p_flags&SCENE_FLAG_CREATE_COLLISIONS && _teststr(name,"rigid") && p_node->cast_to<MeshInstance>()) { + + if (isroot) + return p_node; + + // get mesh instance and bounding box + MeshInstance *mi = p_node->cast_to<MeshInstance>(); + AABB aabb = mi->get_aabb(); + + // create a new rigid body collision node + RigidBody * rigid_body = memnew( RigidBody ); + Node * col = rigid_body; + ERR_FAIL_COND_V(!col,NULL); + + // remove node name postfix + col->set_name(_fixstr(name,"rigid")); + // get mesh instance xform matrix to the rigid body collision node + col->cast_to<Spatial>()->set_transform(mi->get_transform()); + // save original node by duplicating it into a new instance and correcting the name + Node * mesh = p_node->duplicate(); + mesh->set_name(_fixstr(name,"rigid")); + // reset the xform matrix of the duplicated node so it can inherit parent node xform + mesh->cast_to<Spatial>()->set_transform(Transform(Matrix3())); + // reparent the new mesh node to the rigid body collision node + p_node->add_child(mesh); + mesh->set_owner(p_node->get_owner()); + // replace the original node with the rigid body collision node + p_node->replace_by(col); + memdelete(p_node); + p_node=col; + + // create an alias for the rigid body collision node + RigidBody *rb = col->cast_to<RigidBody>(); + // create a new Box collision shape and set the right extents + Ref<BoxShape> shape = memnew( BoxShape ); + shape->set_extents(aabb.get_size() * 0.5); + CollisionShape *colshape = memnew( CollisionShape); + colshape->set_name("shape"); + colshape->set_shape(shape); + // reparent the new collision shape to the rigid body collision node + rb->add_child(colshape); + colshape->set_owner(p_node->get_owner()); + } else if (p_flags&SCENE_FLAG_CREATE_COLLISIONS &&_teststr(name,"col") && p_node->cast_to<MeshInstance>()) { diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp index 4bbcb396af..10c7bf79a3 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.cpp +++ b/tools/editor/plugins/animation_player_editor_plugin.cpp @@ -952,7 +952,7 @@ void AnimationPlayerEditor::_animation_duplicate() { } -void AnimationPlayerEditor::_seek_value_changed(float p_value) { +void AnimationPlayerEditor::_seek_value_changed(float p_value,bool p_set) { if (updating || !player || player->is_playing()) { return; @@ -980,7 +980,7 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value) { pos=anim->get_length(); } - if (player->is_valid()) { + if (player->is_valid() && !p_set) { float cpos = player->get_current_animation_pos(); player->seek_delta(pos,pos-cpos); @@ -988,6 +988,7 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value) { player->seek(pos,true); } + key_editor->set_anim_pos(pos); updating=true; @@ -1078,6 +1079,7 @@ void AnimationPlayerEditor::_editor_load(){ void AnimationPlayerEditor::_animation_key_editor_anim_len_changed(float p_len) { + frame->set_max(p_len); } @@ -1092,7 +1094,7 @@ void AnimationPlayerEditor::_animation_key_editor_anim_step_changed(float p_len) } -void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos) { +void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos,bool p_drag) { if (!is_visible()) return; @@ -1102,7 +1104,11 @@ void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos) { if (player->is_playing() ) return; - frame->set_val(p_pos); + updating=true; + frame->set_val(p_pos); + updating=false; + _seek_value_changed(p_pos,!p_drag); + EditorNode::get_singleton()->get_property_editor()->refresh(); @@ -1254,7 +1260,7 @@ void AnimationPlayerEditor::_bind_methods() { ObjectTypeDB::bind_method(_MD("_animation_edit"),&AnimationPlayerEditor::_animation_edit); ObjectTypeDB::bind_method(_MD("_animation_resource_edit"),&AnimationPlayerEditor::_animation_resource_edit); ObjectTypeDB::bind_method(_MD("_dialog_action"),&AnimationPlayerEditor::_dialog_action); - ObjectTypeDB::bind_method(_MD("_seek_value_changed"),&AnimationPlayerEditor::_seek_value_changed); + ObjectTypeDB::bind_method(_MD("_seek_value_changed"),&AnimationPlayerEditor::_seek_value_changed,DEFVAL(true)); ObjectTypeDB::bind_method(_MD("_animation_player_changed"),&AnimationPlayerEditor::_animation_player_changed); ObjectTypeDB::bind_method(_MD("_blend_edited"),&AnimationPlayerEditor::_blend_edited); // ObjectTypeDB::bind_method(_MD("_seek_frame_changed"),&AnimationPlayerEditor::_seek_frame_changed); @@ -1350,19 +1356,23 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { add_anim = memnew( ToolButton ); + ED_SHORTCUT("animation_player_editor/add_animation", TTR("Create new animation in player.")); + add_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/add_animation")); add_anim->set_tooltip(TTR("Create new animation in player.")); hb->add_child(add_anim); load_anim = memnew( ToolButton ); + ED_SHORTCUT("animation_player_editor/load_from_disk", TTR("Load animation from disk.")); + add_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/load_from_disk")); load_anim->set_tooltip(TTR("Load an animation from disk.")); hb->add_child(load_anim); save_anim = memnew(MenuButton); save_anim->set_tooltip(TTR("Save the current animation")); - save_anim->get_popup()->add_item(TTR("Save"), ANIM_SAVE); - save_anim->get_popup()->add_item(TTR("Save As.."), ANIM_SAVE_AS); + save_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/save", TTR("Save")), ANIM_SAVE); + save_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/save_as", TTR("Save As")), ANIM_SAVE_AS); save_anim->set_focus_mode(Control::FOCUS_NONE); hb->add_child(save_anim); @@ -1372,15 +1382,21 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { duplicate_anim = memnew( ToolButton ); hb->add_child(duplicate_anim); + ED_SHORTCUT("animation_player_editor/duplicate_animation", TTR("Duplicate Animation")); + duplicate_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/duplicate_animation")); duplicate_anim->set_tooltip(TTR("Duplicate Animation")); rename_anim = memnew( ToolButton ); hb->add_child(rename_anim); + ED_SHORTCUT("animation_player_editor/rename_animation", TTR("Rename Animation")); + rename_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/rename_animation")); rename_anim->set_tooltip(TTR("Rename Animation")); remove_anim = memnew( ToolButton ); hb->add_child(remove_anim); + ED_SHORTCUT("animation_player_editor/remove_animation", TTR("Remove Animation")); + remove_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/remove_animation")); remove_anim->set_tooltip(TTR("Remove Animation")); @@ -1402,8 +1418,8 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { tool_anim = memnew( MenuButton); //tool_anim->set_flat(false); tool_anim->set_tooltip(TTR("Animation Tools")); - tool_anim->get_popup()->add_item(TTR("Copy Animation"),TOOL_COPY_ANIM); - tool_anim->get_popup()->add_item(TTR("Paste Animation"),TOOL_PASTE_ANIM); + tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/copy_animation", TTR("Copy Animation")),TOOL_COPY_ANIM); + tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/paste_animation", TTR("Paste Animation")),TOOL_PASTE_ANIM); //tool_anim->get_popup()->add_separator(); //tool_anim->get_popup()->add_item("Edit Anim Resource",TOOL_PASTE_ANIM); hb->add_child(tool_anim); @@ -1487,8 +1503,8 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { animation->connect("item_selected", this,"_animation_selected",Vector<Variant>(),true); resource_edit_anim->connect("pressed", this,"_animation_resource_edit"); file->connect("file_selected", this,"_dialog_action"); - frame->connect("value_changed", this, "_seek_value_changed",Vector<Variant>(),true); - scale->connect("text_entered", this, "_scale_changed",Vector<Variant>(),true); + frame->connect("value_changed", this, "_seek_value_changed",Vector<Variant>(),true); + scale->connect("text_entered", this, "_scale_changed",Vector<Variant>(),true); diff --git a/tools/editor/plugins/animation_player_editor_plugin.h b/tools/editor/plugins/animation_player_editor_plugin.h index 3f3cda25b2..b0c930b66e 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.h +++ b/tools/editor/plugins/animation_player_editor_plugin.h @@ -145,7 +145,7 @@ class AnimationPlayerEditor : public VBoxContainer { void _scale_changed(const String& p_scale); void _dialog_action(String p_file); void _seek_frame_changed(const String& p_frame); - void _seek_value_changed(float p_value); + void _seek_value_changed(float p_value, bool p_set=false); void _blend_editor_next_changed(const int p_idx); void _list_changed(); @@ -158,7 +158,7 @@ class AnimationPlayerEditor : public VBoxContainer { void _animation_player_changed(Object *p_pl); - void _animation_key_editor_seek(float p_pos); + void _animation_key_editor_seek(float p_pos, bool p_drag); void _animation_key_editor_anim_len_changed(float p_new); void _animation_key_editor_anim_step_changed(float p_len); diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index 5a40777665..d5f85d3333 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -893,59 +893,53 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { if (tool!=TOOL_NONE || !mouse_over) return false; - if (k.scancode==KEY_DELETE) { - + if (ED_IS_SHORTCUT("tile_map_editor/erase_selection", p_event)) { _menu_option(OPTION_ERASE_SELECTION); return true; } + if (ED_IS_SHORTCUT("tile_map_editor/select", p_event)) { + tool=TOOL_SELECTING; + selection_active=false; - if (k.mod.command) { - - if (k.scancode==KEY_F) { - - search_box->select_all(); - search_box->grab_focus(); + canvas_item_editor->update(); - return true; - } - if (k.scancode==KEY_B) { + return true; + } + if (ED_IS_SHORTCUT("tile_map_editor/duplicate_selection", p_event)) { + _update_copydata(); - tool=TOOL_SELECTING; - selection_active=false; + if (selection_active) { + tool=TOOL_DUPLICATING; canvas_item_editor->update(); return true; } - if (k.scancode==KEY_D) { - - _update_copydata(); - - if (selection_active) { - tool=TOOL_DUPLICATING; - - canvas_item_editor->update(); - - return true; - } - } - } else { - - if (k.scancode==KEY_A) { - - flip_h=!flip_h; - mirror_x->set_pressed(flip_h); - canvas_item_editor->update(); - return true; - } - if (k.scancode==KEY_S) { + } + if (ED_IS_SHORTCUT("tile_map_editor/find_tile", p_event)) { + search_box->select_all(); + search_box->grab_focus(); - flip_v=!flip_v; - mirror_y->set_pressed(flip_v); - canvas_item_editor->update(); - return true; - } + return true; + } + if (ED_IS_SHORTCUT("tile_map_editor/mirror_x", p_event)) { + flip_h=!flip_h; + mirror_x->set_pressed(flip_h); + canvas_item_editor->update(); + return true; + } + if (ED_IS_SHORTCUT("tile_map_editor/mirror_y", p_event)) { + flip_v=!flip_v; + mirror_y->set_pressed(flip_v); + canvas_item_editor->update(); + return true; + } + if (ED_IS_SHORTCUT("tile_map_editor/transpose", p_event)) { + transpose = !transpose; + transp->set_pressed(transpose); + canvas_item_editor->update(); + return true; } } break; } @@ -1308,6 +1302,12 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { flip_v=false; transpose=false; + ED_SHORTCUT("tile_map_editor/erase_selection", TTR("Erase selection"), KEY_DELETE); + ED_SHORTCUT("tile_map_editor/find_tile", TTR("Find tile"), KEY_MASK_CMD+KEY_F); + ED_SHORTCUT("tile_map_editor/transpose", TTR("Transpose")); + ED_SHORTCUT("tile_map_editor/mirror_x", TTR("Mirror X"), KEY_A); + ED_SHORTCUT("tile_map_editor/mirror_y", TTR("Mirror Y"), KEY_S); + search_box = memnew( LineEdit ); search_box->set_h_size_flags(SIZE_EXPAND_FILL); search_box->connect("text_entered", this, "_text_entered"); @@ -1349,9 +1349,9 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { p->add_separator(); p->add_item(TTR("Pick Tile"), OPTION_PICK_TILE, KEY_CONTROL); p->add_separator(); - p->add_item(TTR("Select"), OPTION_SELECT, KEY_MASK_CMD+KEY_B); - p->add_item(TTR("Duplicate Selection"), OPTION_DUPLICATE, KEY_MASK_CMD+KEY_D); - p->add_item(TTR("Erase Selection"), OPTION_ERASE_SELECTION, KEY_DELETE); + p->add_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_MASK_CMD+KEY_B), OPTION_SELECT); + p->add_shortcut(ED_SHORTCUT("tile_map_editor/duplicate_selection", TTR("Duplicate Selection"), KEY_MASK_CMD+KEY_D), OPTION_DUPLICATE); + p->add_shortcut(ED_GET_SHORTCUT("tile_map_editor/erase_selection"), OPTION_ERASE_SELECTION); p->connect("item_pressed", this, "_menu_option"); @@ -1361,19 +1361,19 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { transp = memnew( ToolButton ); transp->set_toggle_mode(true); - transp->set_tooltip(TTR("Transpose")); + transp->set_tooltip(TTR("Transpose") + " ("+ED_GET_SHORTCUT("tile_map_editor/transpose")->get_as_text()+")"); transp->set_focus_mode(FOCUS_NONE); transp->connect("pressed", this, "_update_transform_buttons", make_binds(transp)); toolbar->add_child(transp); mirror_x = memnew( ToolButton ); mirror_x->set_toggle_mode(true); - mirror_x->set_tooltip(TTR("Mirror X (A)")); + mirror_x->set_tooltip(TTR("Mirror X") + " ("+ED_GET_SHORTCUT("tile_map_editor/mirror_x")->get_as_text()+")"); mirror_x->set_focus_mode(FOCUS_NONE); mirror_x->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_x)); toolbar->add_child(mirror_x); mirror_y = memnew( ToolButton ); mirror_y->set_toggle_mode(true); - mirror_y->set_tooltip(TTR("Mirror Y (S)")); + mirror_y->set_tooltip(TTR("Mirror Y") + " ("+ED_GET_SHORTCUT("tile_map_editor/mirror_y")->get_as_text()+")"); mirror_y->set_focus_mode(FOCUS_NONE); mirror_y->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_y)); toolbar->add_child(mirror_y); diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index 419f05f2cf..d8814fd50e 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -45,8 +45,7 @@ #include "scene/gui/margin_container.h" #include "io/resource_saver.h" -#include "editor_icons.h" -#include "editor_fonts.h" +#include "editor_themes.h" #include "editor_scale.h" @@ -846,21 +845,16 @@ ProjectManager::ProjectManager() { set_area_as_parent_rect(); - Ref<Theme> theme = Ref<Theme>( memnew( Theme ) ); - set_theme(theme); - editor_register_icons(theme); - editor_register_fonts(theme); + gui_base = memnew( Control ); + add_child(gui_base); + gui_base->set_area_as_parent_rect(); - String global_font = EditorSettings::get_singleton()->get("global/font"); - if (global_font!="") { - Ref<Font> fnt = ResourceLoader::load(global_font); - if (fnt.is_valid()) { - theme->set_default_theme_font(fnt); - } - } + set_theme(create_default_theme()); + Ref<Theme> theme = create_editor_theme(); + gui_base->set_theme(theme); Panel *panel = memnew( Panel ); - add_child(panel); + gui_base->add_child(panel); panel->set_area_as_parent_rect(); VBoxContainer *vb = memnew( VBoxContainer ); @@ -961,7 +955,7 @@ ProjectManager::ProjectManager() { scan_dir->set_access(FileDialog::ACCESS_FILESYSTEM); scan_dir->set_mode(FileDialog::MODE_OPEN_DIR); scan_dir->set_current_dir( EditorSettings::get_singleton()->get("global/default_project_path") ); - add_child(scan_dir); + gui_base->add_child(scan_dir); scan_dir->connect("dir_selected",this,"_scan_begin"); @@ -1010,26 +1004,26 @@ ProjectManager::ProjectManager() { erase_ask->get_ok()->set_text(TTR("Remove")); erase_ask->get_ok()->connect("pressed", this,"_erase_project_confirm"); - add_child(erase_ask); + gui_base->add_child(erase_ask); multi_open_ask = memnew( ConfirmationDialog ); multi_open_ask->get_ok()->set_text(TTR("Edit")); multi_open_ask->get_ok()->connect("pressed", this, "_open_project_confirm"); - add_child(multi_open_ask); + gui_base->add_child(multi_open_ask); multi_run_ask = memnew( ConfirmationDialog ); multi_run_ask->get_ok()->set_text(TTR("Run")); multi_run_ask->get_ok()->connect("pressed", this, "_run_project_confirm"); - add_child(multi_run_ask); + gui_base->add_child(multi_run_ask); OS::get_singleton()->set_low_processor_usage_mode(true); npdialog = memnew( NewProjectDialog ); - add_child(npdialog); + gui_base->add_child(npdialog); npdialog->connect("project_created", this,"_load_recent_projects"); _load_recent_projects(); diff --git a/tools/editor/project_manager.h b/tools/editor/project_manager.h index cfedfd7a69..2db1bb839e 100644 --- a/tools/editor/project_manager.h +++ b/tools/editor/project_manager.h @@ -67,6 +67,8 @@ class ProjectManager : public Control { TabContainer *tabs; + Control *gui_base; + void _item_doubleclicked(); |