summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--core/bind/core_bind.cpp7
-rw-r--r--core/bind/core_bind.h4
-rw-r--r--core/os/os.h4
-rw-r--r--doc/base/classes.xml36
-rw-r--r--drivers/unix/os_unix.cpp3
-rw-r--r--platform/nacl/os_nacl.cpp6
-rw-r--r--scene/gui/item_list.cpp56
-rw-r--r--scene/gui/item_list.h7
-rw-r--r--scene/gui/text_edit.cpp31
-rw-r--r--scene/gui/text_edit.h3
-rw-r--r--tools/editor/editor_settings.cpp3
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp2
-rw-r--r--tools/export/blender25/io_scene_dae/export_dae.py2
14 files changed, 134 insertions, 33 deletions
diff --git a/.gitignore b/.gitignore
index bf5be79d55..15ca139916 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,6 +65,9 @@ platform/android/libs/play_licensing/gen/*
.deps/*
.dirstamp
+# Vim temp files
+*.swo
+*.swp
# QT project files
*.config
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index bf611f89c9..915cbc0578 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -508,11 +508,11 @@ Dictionary _OS::get_time(bool utc) const {
}
/**
- * Get a dictionary of time values when given epoc time
+ * Get a dictionary of time values when given epoch time
*
* Dictionary Time values will be a union if values from #get_time
* and #get_date dictionaries (with the exception of dst =
- * day light standard time, as it cannot be determined from epoc)
+ * day light standard time, as it cannot be determined from epoch)
*/
Dictionary _OS::get_time_from_unix_time( uint64_t unix_time_val) const {
@@ -552,7 +552,8 @@ Dictionary _OS::get_time_from_unix_time( uint64_t unix_time_val) const {
imonth++;
}
- date.month = static_cast<OS::Month>(imonth);
+ /// Add 1 to month to make sure months are indexed starting at 1
+ date.month = static_cast<OS::Month>(imonth+1);
date.day = dayno + 1;
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index ab11c4804c..db5ff42cfe 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -81,7 +81,9 @@ public:
};
enum Month {
- MONTH_JANUARY,
+ /// Start at 1 to follow Windows SYSTEMTIME structure
+ /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
+ MONTH_JANUARY = 1,
MONTH_FEBRUARY,
MONTH_MARCH,
MONTH_APRIL,
diff --git a/core/os/os.h b/core/os/os.h
index 73726feb37..160c0495bb 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -224,7 +224,9 @@ public:
};
enum Month {
- MONTH_JANUARY,
+ /// Start at 1 to follow Windows SYSTEMTIME structure
+ /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
+ MONTH_JANUARY = 1,
MONTH_FEBRUARY,
MONTH_MARCH,
MONTH_APRIL,
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index 04e08f166e..bc8bec4bbf 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -20639,6 +20639,18 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8)
<description>
</description>
</method>
+ <method name="get_time_from_unix_time" qualifiers="const">
+ <return type="Dictionary">
+ </return>
+ <argument index="0" name="unix_time_val" type="int">
+ </argument>
+ <description>
+ Get a dictionary of time values when given epoch time.
+ Dictionary Time values will be a union of values from [method get_time]
+ and [method get_date] dictionaries (with the exception of dst =
+ day light standard time, as it cannot be determined from epoc)
+ </description>
+ </method>
<method name="get_time_zone_info" qualifiers="const">
<return type="Dictionary">
</return>
@@ -20922,29 +20934,29 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8)
</constant>
<constant name="DAY_SATURDAY" value="6">
</constant>
- <constant name="MONTH_JANUARY" value="0">
+ <constant name="MONTH_JANUARY" value="1">
</constant>
- <constant name="MONTH_FEBRUARY" value="1">
+ <constant name="MONTH_FEBRUARY" value="2">
</constant>
- <constant name="MONTH_MARCH" value="2">
+ <constant name="MONTH_MARCH" value="3">
</constant>
- <constant name="MONTH_APRIL" value="3">
+ <constant name="MONTH_APRIL" value="4">
</constant>
- <constant name="MONTH_MAY" value="4">
+ <constant name="MONTH_MAY" value="5">
</constant>
- <constant name="MONTH_JUNE" value="5">
+ <constant name="MONTH_JUNE" value="6">
</constant>
- <constant name="MONTH_JULY" value="6">
+ <constant name="MONTH_JULY" value="7">
</constant>
- <constant name="MONTH_AUGUST" value="7">
+ <constant name="MONTH_AUGUST" value="8">
</constant>
- <constant name="MONTH_SEPTEMBER" value="8">
+ <constant name="MONTH_SEPTEMBER" value="9">
</constant>
- <constant name="MONTH_OCTOBER" value="9">
+ <constant name="MONTH_OCTOBER" value="10">
</constant>
- <constant name="MONTH_NOVEMBER" value="10">
+ <constant name="MONTH_NOVEMBER" value="11">
</constant>
- <constant name="MONTH_DECEMBER" value="11">
+ <constant name="MONTH_DECEMBER" value="12">
</constant>
<constant name="SCREEN_ORIENTATION_LANDSCAPE" value="0">
</constant>
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index a004a116e0..84b6dc24dc 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -251,6 +251,9 @@ OS::Date OS_Unix::get_date(bool utc) const {
lt=localtime(&t);
Date ret;
ret.year=1900+lt->tm_year;
+ // Index starting at 1 to match OS_Unix::get_date
+ // and Windows SYSTEMTIME and tm_mon follows the typical structure
+ // of 0-11, noted here: http://www.cplusplus.com/reference/ctime/tm/
ret.month=(Month)(lt->tm_mon + 1);
ret.day=lt->tm_mday;
ret.weekday=(Weekday)lt->tm_wday;
diff --git a/platform/nacl/os_nacl.cpp b/platform/nacl/os_nacl.cpp
index de6a15525b..e2a92ee8c7 100644
--- a/platform/nacl/os_nacl.cpp
+++ b/platform/nacl/os_nacl.cpp
@@ -249,7 +249,11 @@ OS::Date OSNacl::get_date(bool utc) const {
lt=localtime(&t);
Date ret;
ret.year=lt->tm_year;
- ret.month=(Month)lt->tm_mon;
+
+ // Index starting at 1 to match OS_Unix::get_date
+ // and Windows SYSTEMTIME and tm_mon follows the typical structure
+ // of 0-11, noted here: http://www.cplusplus.com/reference/ctime/tm/
+ ret.month=(Month)(lt->tm_mon+1);
ret.day=lt->tm_mday;
ret.weekday=(Weekday)lt->tm_wday;
ret.dst=lt->tm_isdst;
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 2d2cabfc01..171dd94bfa 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -7,6 +7,7 @@ void ItemList::add_item(const String& p_item,const Ref<Texture>& p_texture,bool
Item item;
item.icon=p_texture;
+ item.icon_region=Rect2i();
item.text=p_item;
item.selectable=p_selectable;
item.selected=false;
@@ -23,6 +24,7 @@ void ItemList::add_icon_item(const Ref<Texture>& p_item,bool p_selectable){
Item item;
item.icon=p_item;
+ item.icon_region=Rect2i();
//item.text=p_item;
item.selectable=p_selectable;
item.selected=false;
@@ -79,6 +81,7 @@ void ItemList::set_item_icon(int p_idx,const Ref<Texture>& p_icon){
}
+
Ref<Texture> ItemList::get_item_icon(int p_idx) const{
ERR_FAIL_INDEX_V(p_idx,items.size(),Ref<Texture>());
@@ -87,6 +90,22 @@ Ref<Texture> ItemList::get_item_icon(int p_idx) const{
}
+void ItemList::set_item_icon_region(int p_idx,const Rect2& p_region) {
+
+ ERR_FAIL_INDEX(p_idx,items.size());
+
+ items[p_idx].icon_region=p_region;
+ update();
+ shape_changed=true;
+}
+
+Rect2 ItemList::get_item_icon_region(int p_idx) const {
+
+ ERR_FAIL_INDEX_V(p_idx,items.size(),Rect2());
+
+ return items[p_idx].icon_region;
+}
+
void ItemList::set_item_custom_bg_color(int p_idx,const Color& p_custom_bg_color) {
ERR_FAIL_INDEX(p_idx,items.size());
@@ -362,7 +381,15 @@ Size2 ItemList::get_min_icon_size() const {
return min_icon_size;
}
+Size2 ItemList::Item::get_icon_size() const {
+ if (icon.is_null())
+ return Size2();
+ if (icon_region.has_no_area())
+ return icon->get_size();
+
+ return icon_region.size;
+}
void ItemList::_input_event(const InputEvent& p_event) {
if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT && p_event.mouse_button.pressed) {
@@ -702,7 +729,9 @@ void ItemList::_notification(int p_what) {
Size2 minsize;
if (items[i].icon.is_valid()) {
- minsize=items[i].icon->get_size();
+
+ minsize=items[i].get_icon_size();
+
if (min_icon_size.x!=0)
minsize.x = MAX(minsize.x,min_icon_size.x);
if (min_icon_size.y!=0)
@@ -851,18 +880,30 @@ void ItemList::_notification(int p_what) {
Vector2 text_ofs;
if (items[i].icon.is_valid()) {
+ Size2 icon_size = items[i].get_icon_size();
+
Vector2 icon_ofs;
if (min_icon_size!=Vector2()) {
- icon_ofs = (min_icon_size - items[i].icon->get_size())/2;
+ icon_ofs = (min_icon_size - icon_size)/2;
}
+ Point2 pos = items[i].rect_cache.pos + icon_ofs + base_ofs;
+
if (icon_mode==ICON_MODE_TOP) {
- draw_texture(items[i].icon,icon_ofs+items[i].rect_cache.pos+Vector2(items[i].rect_cache.size.width/2-items[i].icon->get_width()/2,0).floor()+base_ofs);
- text_ofs.y = MAX(items[i].icon->get_height(),min_icon_size.y)+icon_margin;
+
+ pos.x += Math::floor((items[i].rect_cache.size.width - icon_size.width)/2);
+ text_ofs.y = MAX(icon_size.height, min_icon_size.y) + icon_margin;
} else {
- draw_texture(items[i].icon,icon_ofs+items[i].rect_cache.pos+Vector2(0,items[i].rect_cache.size.height/2-items[i].icon->get_height()/2).floor()+base_ofs);
- text_ofs.x = MAX(items[i].icon->get_width(),min_icon_size.x)+icon_margin;
+
+ pos.y += Math::floor((items[i].rect_cache.size.height - icon_size.height)/2);
+ text_ofs.x = MAX(icon_size.width, min_icon_size.x) + icon_margin;
}
+
+ if (items[i].icon_region.has_no_area())
+ draw_texture(items[i].icon, pos);
+ else
+ draw_texture_rect_region(items[i].icon, Rect2(pos, icon_size), items[i].icon_region);
+
}
if (items[i].tag_icon.is_valid()) {
@@ -1061,6 +1102,9 @@ void ItemList::_bind_methods(){
ObjectTypeDB::bind_method(_MD("set_item_icon","idx","icon:Texture"),&ItemList::set_item_icon);
ObjectTypeDB::bind_method(_MD("get_item_icon:Texture","idx"),&ItemList::get_item_icon);
+ ObjectTypeDB::bind_method(_MD("set_item_icon_region","idx","rect"),&ItemList::set_item_icon_region);
+ ObjectTypeDB::bind_method(_MD("get_item_icon_region","idx"),&ItemList::get_item_icon_region);
+
ObjectTypeDB::bind_method(_MD("set_item_selectable","idx","selectable"),&ItemList::set_item_selectable);
ObjectTypeDB::bind_method(_MD("is_item_selectable","idx"),&ItemList::is_item_selectable);
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index bd3cf6484e..c9c575fd54 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -22,6 +22,7 @@ private:
struct Item {
Ref<Texture> icon;
+ Rect2i icon_region;
Ref<Texture> tag_icon;
String text;
bool selectable;
@@ -31,9 +32,10 @@ private:
String tooltip;
Color custom_bg;
-
Rect2 rect_cache;
+ Size2 get_icon_size() const;
+
bool operator<(const Item& p_another) const { return text<p_another.text; }
};
@@ -76,6 +78,9 @@ public:
void set_item_icon(int p_idx,const Ref<Texture>& p_icon);
Ref<Texture> get_item_icon(int p_idx) const;
+ void set_item_icon_region(int p_idx,const Rect2& p_region);
+ Rect2 get_item_icon_region(int p_idx) const;
+
void set_item_selectable(int p_idx,bool p_selectable);
bool is_item_selectable(int p_idx) const;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 32f4be5d17..e268375c8a 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2515,6 +2515,7 @@ void TextEdit::_insert_text(int p_line, int p_char,const String& p_text,int *r_e
//see if it shold just be set as current op
if (current_op.type!=op.type) {
+ op.prev_version = get_version();
_push_current_op();
current_op=op;
@@ -2522,6 +2523,7 @@ void TextEdit::_insert_text(int p_line, int p_char,const String& p_text,int *r_e
}
//see if it can be merged
if (current_op.to_line!=p_line || current_op.to_column!=p_char) {
+ op.prev_version = get_version();
_push_current_op();
current_op=op;
return; //set as current op, return
@@ -2565,6 +2567,7 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column,int p_to_line,int
//see if it shold just be set as current op
if (current_op.type!=op.type) {
+ op.prev_version = get_version();
_push_current_op();
current_op=op;
return; //set as current op, return
@@ -2585,6 +2588,7 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column,int p_to_line,int
//return; //update current op
}
+ op.prev_version = get_version();
_push_current_op();
current_op=op;
@@ -3418,11 +3422,15 @@ void TextEdit::undo() {
else
undo_stack_pos=undo_stack_pos->prev();
- _do_text_op( undo_stack_pos->get(),true);
+ TextOperation op = undo_stack_pos->get();
+ _do_text_op(op, true);
+ current_op.version=op.prev_version;
if(undo_stack_pos->get().chain_backward) {
do {
undo_stack_pos = undo_stack_pos->prev();
- _do_text_op(undo_stack_pos->get(), true);
+ op = undo_stack_pos->get();
+ _do_text_op(op, true);
+ current_op.version = op.prev_version;
} while(!undo_stack_pos->get().chain_forward);
}
@@ -3438,15 +3446,19 @@ void TextEdit::redo() {
if (undo_stack_pos==NULL)
return; //nothing to do.
- _do_text_op(undo_stack_pos->get(), false);
+ TextOperation op = undo_stack_pos->get();
+ _do_text_op(op, false);
+ current_op.version = op.version;
if(undo_stack_pos->get().chain_forward) {
do {
undo_stack_pos=undo_stack_pos->next();
- _do_text_op(undo_stack_pos->get(), false);
+ op = undo_stack_pos->get();
+ _do_text_op(op, false);
+ current_op.version = op.version;
} while(!undo_stack_pos->get().chain_backward);
}
- cursor_set_line(undo_stack_pos->get().from_line);
- cursor_set_column(undo_stack_pos->get().from_column);
+ cursor_set_line(undo_stack_pos->get().to_line);
+ cursor_set_column(undo_stack_pos->get().to_column);
undo_stack_pos=undo_stack_pos->next();
update();
}
@@ -3495,6 +3507,13 @@ void TextEdit::_push_current_op() {
}
+void TextEdit::set_tab_size(const int p_size) {
+ ERR_FAIL_COND(p_size <= 0);
+ tab_size = p_size;
+ text.set_tab_size(p_size);
+ update();
+}
+
void TextEdit::set_draw_tabs(bool p_draw) {
draw_tabs=p_draw;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 2eff8e89c7..d38c57804d 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -156,6 +156,7 @@ class TextEdit : public Control {
int from_line,from_column;
int to_line, to_column;
String text;
+ uint32_t prev_version;
uint32_t version;
bool chain_forward;
bool chain_backward;
@@ -378,7 +379,7 @@ public:
void redo();
void clear_undo_history();
-
+ void set_tab_size(const int p_size);
void set_draw_tabs(bool p_draw);
bool is_drawing_tabs() const;
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index fda51423d2..1133acb48c 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -406,6 +406,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("text_editor/scroll_past_end_of_file", false);
+ set("text_editor/tab_size", 4);
+ hints["text_editor/tab_size"]=PropertyInfo(Variant::INT,"text_editor/tab_size",PROPERTY_HINT_RANGE,"1, 64, 1"); // size of 0 crashes.
+
set("text_editor/idle_parse_delay",2);
set("text_editor/create_signal_callbacks",true);
set("text_editor/autosave_interval_secs",0);
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 76c64beb61..03db293959 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -1930,6 +1930,7 @@ void ScriptEditor::edit(const Ref<Script>& p_script) {
ste->get_text_edit()->set_tooltip_request_func(this,"_get_debug_tooltip",ste);
ste->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file"));
ste->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete"));
+ ste->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size"));
ste->get_text_edit()->set_callhint_settings(
EditorSettings::get_singleton()->get("text_editor/put_callhint_tooltip_below_current_line"),
EditorSettings::get_singleton()->get("text_editor/callhint_tooltip_offset"));
@@ -2067,6 +2068,7 @@ void ScriptEditor::_editor_settings_changed() {
ste->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete"));
ste->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file"));
+ ste->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size"));
}
}
diff --git a/tools/export/blender25/io_scene_dae/export_dae.py b/tools/export/blender25/io_scene_dae/export_dae.py
index 7ee0e179b8..370dc359b5 100644
--- a/tools/export/blender25/io_scene_dae/export_dae.py
+++ b/tools/export/blender25/io_scene_dae/export_dae.py
@@ -1087,7 +1087,7 @@ class DaeExporter:
self.writel(S_LAMPS,5,'<color>'+strarr(light.color)+'</color>')
att_by_distance = 2.0 / light.distance # convert to linear attenuation
self.writel(S_LAMPS,5,'<linear_attenuation>'+str(att_by_distance)+'</linear_attenuation>')
- self.writel(S_LAMPS,5,'<falloff_angle>'+str(math.degrees(light.spot_size))+'</falloff_angle>')
+ self.writel(S_LAMPS,5,'<falloff_angle>'+str(math.degrees(light.spot_size/2))+'</falloff_angle>')
self.writel(S_LAMPS,4,'</spot>')